Skip to content

datetime's C implementation verifies fromisoformat is ASCII, but the pure python implementation does not #89157

Closed

Description

@Julian
mannequin
BPO 44994
Nosy @Julian, @pganssle

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2021-08-24.20:32:18.922>
labels = ['type-bug', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
title = "datetime's C implementation verifies fromisoformat is ASCII, but the pure python implementation does not"
updated_at = <Date 2021-08-24.20:32:18.922>
user = 'https://github.com/Julian'

bugs.python.org fields:

activity = <Date 2021-08-24.20:32:18.922>
actor = 'Julian'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-08-24.20:32:18.922>
creator = 'Julian'
dependencies = []
files = []
hgrepos = []
issue_num = 44994
keywords = []
message_count = 1.0
messages = ['400235']
nosy_count = 2.0
nosy_names = ['Julian', 'p-ganssle']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue44994'
versions = ['Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

Linked PRs

Activity

  1. Julian commented on Aug 24, 2021

    Julianmannequin
    MannequinAuthor

    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)

  2. added
    3.11only security fixes
    stdlibStandard Library Python modules in the Lib/ directory
    type-bugAn unexpected behavior, bug, or error
    on Aug 24, 2021
  3. transferred this issue fromon Apr 10, 2022
  4. lucasalavapena commented on Mar 1, 2023

    @lucasalavapena

    I was able to reproduce this.

    A Related issue is https://bugs.python.org/issue39280 (on GH #83461), there is an extensive discussion on there. Based on the discussion in that issue, unicode characters were deemed fine by @pganssle . The main problem is the inconsistency between the C and python implementation. I could try making a PR so that the C implementation can accept unicode character, if @pganssle think that is a good idea.

  5. StanFromIreland commented on Mar 9, 2025

    @StanFromIreland
    Member

    The dupe was closed without a real conclusion but I think @pganssle's suggestion is what we should do here.

    we're better off resolving the inconsistency by requiring ASCII digits and considering non-ASCII support to be a separate feature request

    I'll implement it for fromisoformat to close this issue.

  6. added and removed
    3.11only security fixes
    on Mar 9, 2025
  7. added a commit that references this issue on Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulesC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions