Message394633
Right now:
>>> from fractions import Fraction as F
>>> F(1_2_3, 3_2_1)
Fraction(41, 107)
but
>>> F('1_2_3/3_2_1')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sk/src/cpython/Lib/fractions.py", line 115, in __new__
raise ValueError('Invalid literal for Fraction: %r' %
ValueError: Invalid literal for Fraction: '1_2_3/3_2_1'
or even this (should be consistent with int constructor, isn't?):
>>> F('1_2_3')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sk/src/cpython/Lib/fractions.py", line 115, in __new__
raise ValueError('Invalid literal for Fraction: %r' %
ValueError: Invalid literal for Fraction: '1_2_3'
Tentative patch attached. Let me know if this does make sense as a PR. |
|
| Date |
User |
Action |
Args |
| 2021-05-28 05:47:31 | Sergey.Kirpichev | set | recipients:
+ Sergey.Kirpichev |
| 2021-05-28 05:47:31 | Sergey.Kirpichev | set | messageid: <[email protected]> |
| 2021-05-28 05:47:31 | Sergey.Kirpichev | link | issue44258 messages |
| 2021-05-28 05:47:31 | Sergey.Kirpichev | create | |
|