Message395030
The cause of DeprecationWarning sometimes [1] not being issued is I believe because in string_parser.c [2] the module is explicitly set to NULL and the filename will be '<string>' or '<stdin>' or somesuch, which eventually that ends up being normalized to something that isn't '__main__'.
Not sure if this is stating the obvious and I don't see any general solution short of adding a filter for the special filenames, but I caught wind of this in #python on Libera, got curious, and thought I'd share what I learned here. I've also attached a gdb session showing how changing the filename affects this behavior.
Reproducing this in debug/dev contexts is definitely fraught, since the warning behavior is different.
[1] The given compile() sample, at the REPL, when using -c, or when piping input via stdin are the ones I know about
[2] https://github.com/python/cpython/blob/f3fa63ec75fdbb4a08a10957a5c631bf0c4a5970/Parser/string_parser.c#L19-L20 |
|
Date |
User |
Action |
Args |
2021-06-03 18:25:46 | SnoopJeDi | set | recipients:
+ SnoopJeDi, terry.reedy, ncoghlan, vstinner, habnabit, serhiy.storchaka, Numerlor |
2021-06-03 18:25:46 | SnoopJeDi | set | messageid: <1622744746.76.0.702609732096.issue40199@roundup.psfhosted.org> |
2021-06-03 18:25:46 | SnoopJeDi | link | issue40199 messages |
2021-06-03 18:25:46 | SnoopJeDi | create | |
|