Skip to content

[3.7] bpo-34454: fix .fromisoformat() methods crashing on inputs with surrogate code points (GH-8862) #8877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 23, 2018

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Aug 23, 2018

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 [email protected]
Co-authored-by: Paul Ganssle [email protected]
(cherry picked from commit 096329f)

Co-authored-by: Paul Ganssle [email protected]

https://bugs.python.org/issue34454

…gate code points (pythonGH-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 <[email protected]>
Co-authored-by: Paul Ganssle <[email protected]>
(cherry picked from commit 096329f)

Co-authored-by: Paul Ganssle <[email protected]>
@miss-islington
Copy link
Contributor Author

@pganssle and @taleinat: Backport status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit 89b1654 into python:3.7 Aug 23, 2018
@miss-islington miss-islington deleted the backport-096329f-3.7 branch August 23, 2018 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants