[New-bugs-announce] [issue43520] Fraction only handles regular slashes ("/") and fails with other similar slashes

Carl Anderson report at bugs.python.org
Tue Mar 16 14:09:04 EDT 2021


New submission from Carl Anderson <carl.anderson at ww.com>:

Fraction works with a regular slash:

>>> from fractions import Fraction
>>> Fraction("1/2")
Fraction(1, 2)

but there are other similar slashes such as (0x2044) in which it throws an error:

>>> Fraction("0⁄2")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/anaconda3/lib/python3.7/fractions.py", line 138, in __new__
    numerator)
ValueError: Invalid literal for Fraction: '0⁄2'


This seems to come from the (?:/(?P<denom>\d+))? section of the regex _RATIONAL_FORMAT in fractions.py

----------
components: Library (Lib)
messages: 388865
nosy: weightwatchers-carlanderson
priority: normal
severity: normal
status: open
title: Fraction only handles regular slashes ("/") and fails with other similar slashes
type: enhancement
versions: Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43520>
_______________________________________


More information about the New-bugs-announce mailing list