]> granicus.if.org Git - python/commit
bpo-34454: fix .fromisoformat() methods crashing on inputs with surrogate code points...
authorPaul Ganssle <pganssle@users.noreply.github.com>
Thu, 23 Aug 2018 15:06:20 +0000 (11:06 -0400)
committerTal Einat <taleinat+github@gmail.com>
Thu, 23 Aug 2018 15:06:20 +0000 (18:06 +0300)
commit096329f0b2bf5e3f0a16363aa631d993ce078737
tree503291191bdb7ecd0d42d02bd8a35b72af468d81
parentc33bb5d4016fb2fc8f3b6d4b0c14b73b33cdb3cf
bpo-34454: fix .fromisoformat() methods crashing on inputs with surrogate code points (GH-8862)

The current C implementations **crash** if the input includes a surrogate
Unicode code point, which is not possible to encode in UTF-8.

Important notes:

1.  It is possible to pass a non-UTF-8 string as a separator to the
    `.isoformat()` methods.
2.  The pure-Python `datetime.fromisoformat()` implementation accepts
    strings with a surrogate as the separator.

In `datetime.fromisoformat()`, in the special case of non-UTF-8 separators,
this implementation will take a performance hit by making a copy of the
input string and replacing the separator with 'T'.

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Co-authored-by: Paul Ganssle <paul@ganssle.io>
Lib/test/datetimetester.py
Misc/NEWS.d/next/Library/2018-08-22-21-59-08.bpo-34454.z7uG4b.rst [new file with mode: 0644]
Modules/_datetimemodule.c