-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Description
Bug report
As I worked on issue #135801, I realized that the solution to issue #131927 was wrong. _PyErr_WarnExplicitObjectWithContext()
takes the module name and the warning registry from the current Python frame. In case of import it is importlib._bootstrap_external
.
Wrong module name which makes difficult to filter syntax warnings is an old issue, but the main problem is that syntax warnings for imported modules share the same warning registry. When you import two modules why by accident emit the same syntax warning at the same line number, you will only see one warning by default. It may be argued that swallowing a warning is worse that emitting a warning twice.
The following PR reverts PR #131993 and provides an alternative solution that fixes all double warnings but keeps warnings for repeated compilation. ast.parse()
no longer emits warnings that are emitted in the AST optimizer (return
/break
/continue
in finally
) -- they are only emitted during compiling.