Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Crash report
What happened?
There is an assert insysmodule.c that makes the interpreter abort when callingsys.audit with a non-string value in debug builds:
Line 522 inf6cc7c8
| assert(PyUnicode_Check(args[0])); |
Python3.14.0a1+ (heads/main:c5b99f5c2c,Oct262024,12:35:53) [GCC13.2.0]onlinuxType"help","copyright","credits"or"license"formoreinformation.>>>importsys>>>sys.audit(9)python: ./Python/sysmodule.c:522:sys_audit:Assertion `PyUnicode_Check(args[0])'failed.Aborted (coredumped)
This assert seems completely unnecessary, as the code that runs the hooks (which only triggers if there is some hook registered) will raise an exception if the first argument tosys.audit isn't a string:
Python3.14.0a1+ (heads/remove_sysaudit_assert:ba8ac4d398,Oct262024,19:45:11) [GCC11.4.0]onlinuxType"help","copyright","credits"or"license"formoreinformation.>>>importsys>>>sys.addaudithook(lambda*args:None)>>>sys.audit(9)Traceback (mostrecentcalllast):File"<python-input-2>",line1,in<module>sys.audit(9)~~~~~~~~~^^^TypeError:expectedstrforargument'event',notint
I'll submit a trivial PR removing this assert.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux, Windows
Output from running 'python -VV' on the command line:
Python 3.14.0a1+ (heads/main:c5b99f5c2c, Oct 26 2024, 12:35:53) [GCC 13.2.0]