]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-135801: Improve filtering by module in warn_explicit() without module argument...
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 30 Oct 2025 13:55:39 +0000 (15:55 +0200)
committerGitHub <noreply@github.com>
Thu, 30 Oct 2025 13:55:39 +0000 (15:55 +0200)
commit6826166280d6518441a729b444173db205c4ab20
treec8e571888be237ebf566bd7579220512790af3ad
parentefc37ba49eef07dad83698cf8e68820c955aacf9
gh-135801: Improve filtering by module in warn_explicit() without module argument (GH-140151)

* Try to match the module name pattern with module names constructed
  starting from different parent directories of the filename.
  E.g., for "/path/to/package/module" try to match with
  "path.to.package.module", "to.package.module", "package.module" and
  "module".
* Ignore trailing "/__init__.py".
* Ignore trailing ".pyw" on Windows.
* Keep matching with the full filename (without optional ".py" extension)
  for compatibility.
* Only ignore the case of the ".py" extension on Windows.
13 files changed:
Doc/library/warnings.rst
Doc/whatsnew/3.15.rst
Lib/_py_warnings.py
Lib/test/test_ast/test_ast.py
Lib/test/test_builtin.py
Lib/test/test_cmd_line_script.py
Lib/test/test_compile.py
Lib/test/test_import/__init__.py
Lib/test/test_import/data/syntax_warnings.py [new file with mode: 0644]
Lib/test/test_symtable.py
Lib/test/test_warnings/__init__.py
Misc/NEWS.d/next/Library/2025-10-16-17-17-20.gh-issue-135801.faH3fa.rst [new file with mode: 0644]
Python/_warnings.c