[New-bugs-announce] [issue44994] datetime's C implementation verifies fromisoformat is ASCII, but the pure python implementation does not

Julian Berman report at bugs.python.org
Tue Aug 24 16:32:18 EDT 2021


New submission from Julian Berman <Julian+Python.org at GrayVines.com>:

This line (which contains a non-ASCII digit):

    python3.9 -c "import datetime; datetime.date.fromisoformat('1963-06-1৪')"

raises:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ValueError: Invalid isoformat string: '1963-06-1৪'

under the C implementation of the datetime module, but when the pure Python implementation is the one imported, succeeds (and produces `datetime.date(1963, 6, 14)`)

The pure Python implementation should instead explicitly check and raise when encountering a non-ASCII string.

(On PyPy, which always uses the pure-Python implementation, this contributes to a behavioral difference)

----------
components: Library (Lib)
messages: 400235
nosy: Julian, p-ganssle
priority: normal
severity: normal
status: open
title: datetime's C implementation verifies fromisoformat is ASCII, but the pure python implementation does not
type: behavior
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

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


More information about the New-bugs-announce mailing list