-
-
Notifications
You must be signed in to change notification settings - Fork 32k
./Modules/_datetimemodule.c:290: days_before_year: Assertion `year >= 1' failed. #117534
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
Comments
Hello! |
For comparison, on macOS: ❯ ./python.exe
Python 3.13.0a5+ (heads/main:9dae05ee59, Apr 4 2024, 13:17:17) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> y = datetime.datetime.fromisoformat('0000W25')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
y = datetime.datetime.fromisoformat('0000W25')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
ValueError: month must be in 1..12 Same with 3.11.8 and 3.12.2. |
I get the same results as Hugo on Ubuntu 24.04, Python 3.12. |
Also on 3.11-3.13 on Windows, macOS and Ubuntu on GitHub Actions: (3.8-3.10 also has a |
It is interesting. I've just forked the repository, make and run my test. After it I got the Assertion: |
Could you try this, just to be sure: $ git clean -fdx
$ ./configure --with-pydebug
$ make # no -j8 |
Debug build on current main branch (clean build), macOS Sonoma 14.2.1: ./python.exe example.py
Assertion failed: (year >= 1), function days_before_year, file _datetimemodule.c, line 290.
zsh: abort ./python.exe example.py |
I've tried as suggested Erlend and got the same result: I've the following back trace for this:
|
I can reproduce on a fresh build on macOS. HEAD at b32789c. |
I got ValueError on Windows installed 3.13.0a5, March 12. Crash on fresh debug no-gil build, so there is a regression for me also. |
Moves the validation for invalid years in the C implementation of the `datetime` module into a common location between `fromisoformat` and `fromisocalendar`, which improves the error message and fixes a failed assertion when parsing invalid ISO 8601 years using one of the "ISO weeks" formats. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…onGH-117543) Moves the validation for invalid years in the C implementation of the `datetime` module into a common location between `fromisoformat` and `fromisocalendar`, which improves the error message and fixes a failed assertion when parsing invalid ISO 8601 years using one of the "ISO weeks" formats. --------- (cherry picked from commit d5f1139) Co-authored-by: Vlad4896 <[email protected]> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
I was able to reproduce this with Should be fixed with #117534. |
…117543) (#117689) gh-117534: Add checking for input parameter in iso_to_ymd (GH-117543) Moves the validation for invalid years in the C implementation of the `datetime` module into a common location between `fromisoformat` and `fromisocalendar`, which improves the error message and fixes a failed assertion when parsing invalid ISO 8601 years using one of the "ISO weeks" formats. --------- (cherry picked from commit d5f1139) Co-authored-by: Vlad4896 <[email protected]> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
…on#117543) Moves the validation for invalid years in the C implementation of the `datetime` module into a common location between `fromisoformat` and `fromisocalendar`, which improves the error message and fixes a failed assertion when parsing invalid ISO 8601 years using one of the "ISO weeks" formats. --------- Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Crash report
What happened?
Python terminates with core dumped on the following test:
The test result:
The issue happened due to lack of checking for input parameters in iso_to_ymd().
The 'iso_year' input parameter should be checked to fix the issue.
CPython versions tested on:
3.11, 3.12, CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.13.0a5+ (heads/main:dc54714044, Apr 4 2024, 12:28:42) [GCC 11.4.0]
Linked PRs
The text was updated successfully, but these errors were encountered: