Message415372
> Ouch, is Python crashes because of an unsupported strftime call?
It's not a crash. It's a CRT error report dialog, which is enabled by default for the _CRT_ASSERT and _CRT_ERROR macros in debug builds. This dialog can be helpful when debugging interactively. It gives a developer the option to abort, retry, or ignore. If a debugger is attached, the retry option breaks into the debugger. I attached a debugger to the test runner to diagnose the problem with format code "%4Y". For example:
>>> time.strftime('%4Y')
Debug Assertion Failed!
[...]
(Press Retry to debug the application)
(1a6c.101c): Break instruction exception - code 80000003 (first chance)
ucrtbased!_Wcsftime_l+0x5af:
00007ff8`a582b9af cc int 3
backtrace:
0:000> kc 4
Call Site
ucrtbased!_Wcsftime_l
ucrtbased!_Strftime_l
ucrtbased!strftime
python311_d!time_strftime
locals:
0:000> dv
_Expr_val = 0n0
string = 0x00000226`fe38d1c0 ""
max_size = 0x400
format = 0x00000226`fe37e7d0 "%4Y"
timeptr = 0x00000041`c1feeda0
lc_time_arg = 0x00000000`00000000
locale = 0x00000000`00000000
locale_update = class _LocaleUpdate
format_it = 0x00000226`fe37e7d2 "4Y"
remaining = 0x400
lc_time = 0x00007ff8`a5868550
failed = true
string_it = 0x00000226`fe38d1c0 ""
resume, with the STATUS_BREAKPOINT (0x80000003) exception handled:
0:000> gh
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid format string
>>>
For non-interactive testing the report mode needs to be configured to 0 (no report) or to report to stderr. For example:
>>> msvcrt.CrtSetReportMode(msvcrt.CRT_ERROR, msvcrt.CRTDBG_MODE_FILE)
4
>>> msvcrt.CrtSetReportFile(msvcrt.CRT_ERROR, msvcrt.CRTDBG_FILE_STDERR)
18446744073709551615
>>> os.abort()
abort() has been called
For time.strftime('%4Y'), the source of the report is _VALIDATE_RETURN(false, EINVAL, 0) in _Wcsftime_l(). This macro includes an _ASSERT_EXPR(expr, msg) check. In a debug build, this calls _CrtDbgReportW(_CRT_ASSERT, ...) if the expression is false. If the latter returns 1 (retry), the __debugbreak() intrinsic is called to break into the debugger. To suppress the dialog, either temporarily set the CRT_ASSERT report mode to 0, or set it to report to stderr. For example:
>>> msvcrt.CrtSetReportMode(msvcrt.CRT_ASSERT, msvcrt.CRTDBG_MODE_FILE)
4
>>> msvcrt.CrtSetReportFile(msvcrt.CRT_ASSERT, msvcrt.CRTDBG_FILE_STDERR)
18446744073709551615
>>> time.strftime('%4Y')
minkernel\crts\ucrt\src\appcrt\time\wcsftime.cpp(1163) : Assertion failed: false
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: Invalid format string |
|
Date |
User |
Action |
Args |
2022-03-16 21:59:22 | eryksun | set | recipients:
+ eryksun, tim.peters, terry.reedy, paul.moore, christian.heimes, tim.golden, lukasz.langa, zach.ware, steve.dower, pablogsal, Dennis Sweeney |
2022-03-16 21:59:21 | eryksun | set | messageid: <1647467961.95.0.957292319555.issue47037@roundup.psfhosted.org> |
2022-03-16 21:59:21 | eryksun | link | issue47037 messages |
2022-03-16 21:59:21 | eryksun | create | |
|