You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
❯ ./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
It is interesting. I've just forked the repository, make and run my test.
I've used the following command to build Python:
./configure --with-pydebug && make -j8
After it I got the Assertion:
python: ./Modules/_datetimemodule.c:290: days_before_year: Assertion `year >= 1' failed.
Aborted (core dumped)
I've tried as suggested Erlend and got the same result:
$ ./python mytest.py
python: ./Modules/_datetimemodule.c:290: days_before_year: Assertion `year >= 1' failed.
Aborted (core dumped)
I've the following back trace for this:
#1 __pthread_kill_internal (signo=6, threadid=140737352808256) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140737352808256, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff7c42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff7c287f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff7c2871b in __assert_fail_base (fmt=0x7ffff7ddd150 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x7ffff7e4e0e0 "year >= 1",
file=0x7ffff7e4e000 "./Modules/_datetimemodule.c", line=290, function=<optimized out>) at ./assert/assert.c:92
#6 0x00007ffff7c39e96 in __GI___assert_fail (assertion=assertion@entry=0x7ffff7e4e0e0 "year >= 1", file=file@entry=0x7ffff7e4e000 "./Modules/_datetimemodule.c", line=line@entry=290,
function=function@entry=0x7ffff7e50520 <__PRETTY_FUNCTION__.0> "days_before_year") at ./assert/assert.c:101
#7 0x00007ffff7e3d6bf in days_before_year (year=year@entry=0) at ./Modules/_datetimemodule.c:290
#8 0x00007ffff7e3d6d8 in ymd_to_ord (year=year@entry=0, month=month@entry=1, day=day@entry=1) at ./Modules/_datetimemodule.c:389
#9 0x00007ffff7e3d73b in iso_week1_monday (year=year@entry=0) at ./Modules/_datetimemodule.c:405
#10 0x00007ffff7e3d7d6 in iso_to_ymd (iso_year=0, iso_week=25, iso_day=1, year=year@entry=0x7fffffffd71c, month=month@entry=0x7fffffffd720, day=day@entry=0x7fffffffd724)
at ./Modules/_datetimemodule.c:440
#11 0x00007ffff7e3d998 in parse_isoformat_date (dtstr=dtstr@entry=0x7ffff74dd328 "0000W25", len=len@entry=7, year=year@entry=0x7fffffffd71c, month=month@entry=0x7fffffffd720,
day=day@entry=0x7fffffffd724) at ./Modules/_datetimemodule.c:803
#12 0x00007ffff7e479c0 in datetime_fromisoformat (cls=0x7ffff7e58000 <PyDateTime_DateTimeType>, dtstr=0x7ffff74dd300) at ./Modules/_datetimemodule.c:5506
#13 0x00005555556f8c0b in cfunction_vectorcall_O (func=0x7ffff74d0ef0, args=<optimized out>, nargsf=<optimized out>, kwnames=<optimized out>) at Objects/methodobject.c:512
#14 0x000055555568692c in _PyObject_VectorcallTstate (tstate=0x555555c04510 <_PyRuntime+280656>, callable=0x7ffff74d0ef0, args=0x7ffff7fb0078, nargsf=9223372036854775809, kwnames=0x0)
at ./Include/internal/pycore_call.h:168
#15 0x0000555555686a4b in PyObject_Vectorcall (callable=callable@entry=0x7ffff74d0ef0, args=args@entry=0x7ffff7fb0078, nargsf=<optimized out>, kwnames=kwnames@entry=0x0) at Objects/call.c:327
#16 0x00005555558124c1 in _PyEval_EvalFrameDefault (tstate=tstate@entry=0x555555c04510 <_PyRuntime+280656>, frame=0x7ffff7fb0020, throwflag=throwflag@entry=0) at Python/generated_cases.c.h:813
#17 0x0000555555834f71 in _PyEval_EvalFrame (throwflag=0, frame=<optimized out>, tstate=0x555555c04510 <_PyRuntime+280656>) at ./Include/internal/pycore_ceval.h:114
#18 _PyEval_Vector (tstate=tstate@entry=0x555555c04510 <_PyRuntime+280656>, func=func@entry=0x7ffff746a2d0, locals=locals@entry=0x7ffff74785f0, args=args@entry=0x0, argcount=argcount@entry=0,
kwnames=kwnames@entry=0x0) at Python/ceval.c:1807
#19 0x000055555583502f in PyEval_EvalCode (co=co@entry=0x7ffff75a2480, globals=globals@entry=0x7ffff74785f0, locals=locals@entry=0x7ffff74785f0) at Python/ceval.c:600
#20 0x00005555558bc6ae in run_eval_code_obj (tstate=tstate@entry=0x555555c04510 <_PyRuntime+280656>, co=co@entry=0x7ffff75a2480, globals=globals@entry=0x7ffff74785f0,
locals=locals@entry=0x7ffff74785f0) at Python/pythonrun.c:1291
#21 0x00005555558bdf7b in run_mod (mod=mod@entry=0x555555d32e28, filename=filename@entry=0x7ffff74a5ac0, globals=globals@entry=0x7ffff74785f0, locals=locals@entry=0x7ffff74785f0,
flags=flags@entry=0x7fffffffdc68, arena=arena@entry=0x7ffff74d0ca0, interactive_src=0x0, generate_new_source=0) at Python/pythonrun.c:1376
#22 0x00005555558be660 in pyrun_file (fp=fp@entry=0x555555cac010, filename=filename@entry=0x7ffff74a5ac0, start=start@entry=257, globals=globals@entry=0x7ffff74785f0,
locals=locals@entry=0x7ffff74785f0, closeit=closeit@entry=1, flags=0x7fffffffdc68) at Python/pythonrun.c:1212
#23 0x00005555558bf87d in _PyRun_SimpleFileObject (fp=fp@entry=0x555555cac010, filename=filename@entry=0x7ffff74a5ac0, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffdc68)
at Python/pythonrun.c:461
#24 0x00005555558bfb50 in _PyRun_AnyFileObject (fp=fp@entry=0x555555cac010, filename=filename@entry=0x7ffff74a5ac0, closeit=closeit@entry=1, flags=flags@entry=0x7fffffffdc68)
at Python/pythonrun.c:77
#25 0x00005555558ea520 in pymain_run_file_obj (program_name=program_name@entry=0x7ffff74a5b40, filename=filename@entry=0x7ffff74a5ac0, skip_source_first_line=0) at Modules/main.c:357
#26 0x00005555558eb76b in pymain_run_file (config=config@entry=0x555555bd7438 <_PyRuntime+96120>) at Modules/main.c:376
#27 0x00005555558ebc45 in pymain_run_python (exitcode=exitcode@entry=0x7fffffffddf4) at Modules/main.c:628
--Type <RET> for more, q to quit, c to continue without paging--
#28 0x00005555558ebcb5 in Py_RunMain () at Modules/main.c:707
#29 0x00005555558ebd2c in pymain_main (args=args@entry=0x7fffffffde50) at Modules/main.c:737
#30 0x00005555558ebdef in Py_BytesMain (argc=<optimized out>, argv=<optimized out>) at Modules/main.c:761
#31 0x00005555555d48c6 in main (argc=<optimized out>, argv=<optimized out>) at ./Programs/python.c:15
I was able to reproduce this with ./configure --with-assertions. In some ways the core dump is an overactive assertion error, because this particular case incidentally fails for other reasons (hence the weird message about months being out of range), but regardless of whether it's an interpreter crash, it still should be fixed.
Activity
Eclips4 commentedon Apr 4, 2024
Hello!
Thanks for the report.
Would you like to submit a PR with fix? :)
hugovk commentedon Apr 4, 2024
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..12Same with 3.11.8 and 3.12.2.
erlend-aasland commentedon Apr 4, 2024
I get the same results as Hugo on Ubuntu 24.04, Python 3.12.
hugovk commentedon Apr 4, 2024
Also on 3.11-3.13 on Windows, macOS and Ubuntu on GitHub Actions:
(3.8-3.10 also has a
ValueErrorwith a different error message.)Vlad4896 commentedon Apr 4, 2024
It is interesting. I've just forked the repository, make and run my test.
I've used the following command to build Python:
./configure --with-pydebug && make -j8
After it I got the Assertion:
python: ./Modules/_datetimemodule.c:290: days_before_year: Assertion `year >= 1' failed.
Aborted (core dumped)
erlend-aasland commentedon Apr 4, 2024
Could you try this, just to be sure:
Eclips4 commentedon Apr 4, 2024
Debug build on current main branch (clean build), macOS Sonoma 14.2.1:
Vlad4896 commentedon Apr 4, 2024
I've tried as suggested Erlend and got the same result:
$ ./python mytest.py
python: ./Modules/_datetimemodule.c:290: days_before_year: Assertion `year >= 1' failed.
Aborted (core dumped)
I've the following back trace for this:
erlend-aasland commentedon Apr 4, 2024
I can reproduce on a fresh build on macOS. HEAD at b32789c.
pythongh-117534: Add checking for input parameter in iso_to_ymd
terryjreedy commentedon Apr 4, 2024
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.
pythongh-117534: Add checking for input parameter in iso_to_ymd
pythongh-117534: Add checking for input parameter in iso_to_ymd (upda…
gh-117534: Add checking for input parameter in iso_to_ymd (#117543)
pythongh-117534: Add checking for input parameter in iso_to_ymd (pyth…
pganssle commentedon Apr 9, 2024
I was able to reproduce this with
./configure --with-assertions. In some ways the core dump is an overactive assertion error, because this particular case incidentally fails for other reasons (hence the weird message about months being out of range), but regardless of whether it's an interpreter crash, it still should be fixed.Should be fixed with #117534.
erlend-aasland commentedon Apr 9, 2024
That would be #117543 :)
[3.12] gh-117534: Add checking for input parameter in iso_to_ymd (GH-…
pythongh-117534: Add checking for input parameter in iso_to_ymd (pyth…