James Gerity <snoop.j...@gmail.com> added the comment:
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 ---------- nosy: +SnoopJeDi2 Added file: https://bugs.python.org/file50091/gdb_deprecationwarning_session.txt _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40199> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com