GeezerVison is showing github.com — gh-135801: Improve filtering by module in warn_explicit() without module argument by serhiy-storchaka · Pull Request #140151 · python/cpython
Conversation
- 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" suffix) for compatibility.
- Only ignore the case of the ".py" extension on Windows.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Since we need the code for Python and C implementations of warn_explicit(), and it is relatively complex, it is only implemented in Python, and the C code imports the Python implementation.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…ut module argument
* 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 ".py" on Windows.
* Keep matching with the full filename (without optional ".py" extension)
for compatibility.
* Only ignore the case of the ".py" extension on Windows.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
This is definitely a new feature, but it would be nice to backport it to 3.14.1, taking into account how much fuss was made by new syntax warnings in 3.14. This would mitigate impact. cc @hugovk
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thank you for working on this.
Before even considering this for 3.14, I'd want to see it in a 3.15 alpha first, with testing and feedback from those unhappy with the 3.14 syntax warnings that this addresses their needs.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+537
to
+540
|
|
if is_py and filename[-9:].lower() in (r'\__init__', '/__init__'):
|
|
|
filename = filename[:-9]
|
|
|
elif not is_py and filename[-4:].lower() == '.pyw':
|
|
|
filename = filename[:-4]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\__init__.pyw is supported on Windows, you can do something like:
|
if is_py and filename[-9:].lower() in (r'\__init__', '/__init__'): |
|
filename = filename[:-9] |
|
elif not is_py and filename[-4:].lower() == '.pyw': |
|
filename = filename[:-4] |
|
if not is_py and filename[-4:].lower() == '.pyw': |
|
filename = filename[:-4] |
|
is_py = True |
|
if is_py and filename[-9:].lower() in (r'\__init__', '/__init__'): |
|
filename = filename[:-9] |
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
serhiy-storchaka reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was too lazy to check and mistakenly supposed that .pyw is not supported for __init__. But I just checked -- indeed, it works.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner reacted with thumbs up emoji
|
|
filename = support.findfile('test_import/data/syntax_warnings.py')
|
|
|
with open(filename, 'rb') as f:
|
|
|
source = f.read()
|
|
|
with warnings.catch_warnings(record=True) as wlog:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may use a loop since the code is basically duplicated. Something like:
for exec_globals in ...:
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner reacted with thumbs up emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your review. You noticed 👀 some details that I missed.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+537
to
+540
|
|
if is_py and filename[-9:].lower() in (r'\__init__', '/__init__'):
|
|
|
filename = filename[:-9]
|
|
|
elif not is_py and filename[-4:].lower() == '.pyw':
|
|
|
filename = filename[:-4]
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I was too lazy to check and mistakenly supposed that .pyw is not supported for __init__. But I just checked -- indeed, it works.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner reacted with thumbs up emoji
|
|
filename = support.findfile('test_import/data/syntax_warnings.py')
|
|
|
with open(filename, 'rb') as f:
|
|
|
source = f.read()
|
|
|
with warnings.catch_warnings(record=True) as wlog:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
vstinner reacted with thumbs up emoji
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
⚠️⚠️⚠️ Buildbot failure ⚠️⚠️⚠️
Hi! The buildbot aarch64 Android 3.x (tier-3) has failed when building commit 6826166.
What do you need to do:
- Don't panic.
- Check the buildbot page in the devguide if you don't know what the buildbots are or how they work.
- Go to the page of the buildbot that failed (https://buildbot.python.org/#/builders/1594/builds/3659) and take a look at the build logs.
- Check if the failure is related to this commit (6826166) or if it is a false positive.
- If the failure is related to this commit, please, reflect that on the issue and make a new Pull Request with a fix.
You can take a look at the buildbot page here:
https://buildbot.python.org/#/builders/1594/builds/3659
Summary of the results of the build (if available):
Click to see traceback logs
remote: Enumerating objects: 55, done.
remote: Counting objects: 1% (1/55)
remote: Counting objects: 3% (2/55)
remote: Counting objects: 5% (3/55)
remote: Counting objects: 7% (4/55)
remote: Counting objects: 9% (5/55)
remote: Counting objects: 10% (6/55)
remote: Counting objects: 12% (7/55)
remote: Counting objects: 14% (8/55)
remote: Counting objects: 16% (9/55)
remote: Counting objects: 18% (10/55)
remote: Counting objects: 20% (11/55)
remote: Counting objects: 21% (12/55)
remote: Counting objects: 23% (13/55)
remote: Counting objects: 25% (14/55)
remote: Counting objects: 27% (15/55)
remote: Counting objects: 29% (16/55)
remote: Counting objects: 30% (17/55)
remote: Counting objects: 32% (18/55)
remote: Counting objects: 34% (19/55)
remote: Counting objects: 36% (20/55)
remote: Counting objects: 38% (21/55)
remote: Counting objects: 40% (22/55)
remote: Counting objects: 41% (23/55)
remote: Counting objects: 43% (24/55)
remote: Counting objects: 45% (25/55)
remote: Counting objects: 47% (26/55)
remote: Counting objects: 49% (27/55)
remote: Counting objects: 50% (28/55)
remote: Counting objects: 52% (29/55)
remote: Counting objects: 54% (30/55)
remote: Counting objects: 56% (31/55)
remote: Counting objects: 58% (32/55)
remote: Counting objects: 60% (33/55)
remote: Counting objects: 61% (34/55)
remote: Counting objects: 63% (35/55)
remote: Counting objects: 65% (36/55)
remote: Counting objects: 67% (37/55)
remote: Counting objects: 69% (38/55)
remote: Counting objects: 70% (39/55)
remote: Counting objects: 72% (40/55)
remote: Counting objects: 74% (41/55)
remote: Counting objects: 76% (42/55)
remote: Counting objects: 78% (43/55)
remote: Counting objects: 80% (44/55)
remote: Counting objects: 81% (45/55)
remote: Counting objects: 83% (46/55)
remote: Counting objects: 85% (47/55)
remote: Counting objects: 87% (48/55)
remote: Counting objects: 89% (49/55)
remote: Counting objects: 90% (50/55)
remote: Counting objects: 92% (51/55)
remote: Counting objects: 94% (52/55)
remote: Counting objects: 96% (53/55)
remote: Counting objects: 98% (54/55)
remote: Counting objects: 100% (55/55)
remote: Counting objects: 100% (55/55), done.
remote: Compressing objects: 5% (1/20)
remote: Compressing objects: 10% (2/20)
remote: Compressing objects: 15% (3/20)
remote: Compressing objects: 20% (4/20)
remote: Compressing objects: 25% (5/20)
remote: Compressing objects: 30% (6/20)
remote: Compressing objects: 35% (7/20)
remote: Compressing objects: 40% (8/20)
remote: Compressing objects: 45% (9/20)
remote: Compressing objects: 50% (10/20)
remote: Compressing objects: 55% (11/20)
remote: Compressing objects: 60% (12/20)
remote: Compressing objects: 65% (13/20)
remote: Compressing objects: 70% (14/20)
remote: Compressing objects: 75% (15/20)
remote: Compressing objects: 80% (16/20)
remote: Compressing objects: 85% (17/20)
remote: Compressing objects: 90% (18/20)
remote: Compressing objects: 95% (19/20)
remote: Compressing objects: 100% (20/20)
remote: Compressing objects: 100% (20/20), done.
remote: Total 29 (delta 24), reused 14 (delta 9), pack-reused 0 (from 0)
From https://github.com/python/cpython
* branch main -> FETCH_HEAD
Note: switching to '6826166280d6518441a729b444173db205c4ab20'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:
git switch -c <new-branch-name>
Or undo this operation with:
git switch -
Turn off this advice by setting config variable advice.detachedHead to false
HEAD is now at 6826166280d gh-135801: Improve filtering by module in warn_explicit() without module argument (GH-140151)
Switched to and reset branch 'main'
configure: WARNING: no system libmpdec found; falling back to pure-Python version for the decimal module
configure: WARNING: pkg-config is missing. Some dependencies may not be detected correctly.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 192k 100 192k 0 0 1371k 0 --:--:-- --:--:-- --:--:-- 1371k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 42455 100 42455 0 0 419k 0 --:--:-- --:--:-- --:--:-- 419k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 5044k 100 5044k 0 0 21.0M 0 --:--:-- --:--:-- --:--:-- 21.0M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
44 1257k 44 556k 0 0 4751k 0 --:--:-- --:--:-- --:--:-- 4751k
100 1257k 100 1257k 0 0 9995k 0 --:--:-- --:--:-- --:--:-- 85.5M
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 635k 100 635k 0 0 5205k 0 --:--:-- --:--:-- --:--:-- 5205k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 479k 100 479k 0 0 3970k 0 --:--:-- --:--:-- --:--:-- 3970k
../../configure: line 4071: pkg-config: command not found
configure: WARNING: no system libmpdec found; falling back to pure-Python version for the decimal module
configure: WARNING: pkg-config is missing. Some dependencies may not be detected correctly.
../../Python/fileutils.c:458:1: warning: unused function 'decode_current_locale' [-Wunused-function]
458 | decode_current_locale(const char* arg, wchar_t **wstr, size_t *wlen,
| ^~~~~~~~~~~~~~~~~~~~~
../../Python/fileutils.c:677:1: warning: unused function 'encode_current_locale' [-Wunused-function]
677 | encode_current_locale(const wchar_t *text, char **str,
| ^~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
../../Modules/_localemodule.c:195:1: warning: unused function 'is_all_ascii' [-Wunused-function]
195 | is_all_ascii(const char *str)
| ^~~~~~~~~~~~
1 warning generated.
../../Modules/pwdmodule.c:69:16: warning: unused variable 'pwd_db_mutex' [-Wunused-variable]
69 | static PyMutex pwd_db_mutex = {0};
| ^~~~~~~~~~~~
1 warning generated.
../../Modules/_hacl/Lib_Memzero0.c:66:6: warning: "Your platform does not support any safe implementation of memzero -- consider a pull request!" [-W#warnings]
66 | #warning "Your platform does not support any safe implementation of memzero -- consider a pull request!"
| ^
1 warning generated.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 8784 100 8784 0 0 852k 0 --:--:-- --:--:-- --:--:-- 857k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 2894 100 2894 0 0 394k 0 --:--:-- --:--:-- --:--:-- 403k
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 43504 100 43504 0 0 1709k 0 --:--:-- --:--:-- --:--:-- 1770k
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
The Android failure was probably caused by low disk space, as in #138649 (comment). This time there was no CoreSimulator.prev.log, so I had to delete the live CoreSimulator.log (over 20 GB), and then kill
this process to release the open file:
502 45605 1 0 17Jun25 ?? 1253:47.79 /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc/Contents/MacOS/com.apple.CoreSimulator.CoreSimulatorService
It restarted automatically on the next iOS buildbot run.
@freakboy3742: is there any way we can stop this log file from getting so large?
/Users/buildbot/Library/Logs/CoreSimulator also contains 7,000 smaller log files, which is a number that might start causing its own problems (my terminal wasn't very happy when I tried to list them).
|
vstinner reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
The Android failure was probably caused by low disk space, as in #138649 (comment). This time there was no CoreSimulator.prev.log, so I had to delete the live CoreSimulator.log (over 20 GB), and then kill this process to release the open file:
502 45605 1 0 17Jun25 ?? 1253:47.79 /Library/Developer/PrivateFrameworks/CoreSimulator.framework/Versions/A/XPCServices/com.apple.CoreSimulator.CoreSimulatorService.xpc/Contents/MacOS/com.apple.CoreSimulator.CoreSimulatorService
It restarted automatically on the next iOS buildbot run.
@freakboy3742: is there any way we can stop this log file from getting so large?
So - I've taken a look at the log file, and it looks like the simulator itself might have gotten into a weird state. The log was filled with errors that indicated problems with missing SDKs and the like.
I've updated the SDK on the buildbot machine, and purged all the simulators except for the one that we're - and now it's not even creating a CoreSimulator.log... so... success? I'll keep an eye on this, but maybe it was just a configuration issue.
/Users/buildbot/Library/Logs/CoreSimulator also contains 7,000 smaller log files, which is a number that might start causing its own problems (my terminal wasn't very happy when I tried to list them).
This looks like it might have been an artefact of the Xcode setup that existed before August. It was creating a cloned simulator every time it ran the test suite; evidently it wasn't cleaning up those clones. I've purged them all, and now there's a single simulator image in that directory.
|
mhsmith reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
StanFromIreland
pushed a commit
to StanFromIreland/cpython
that referenced
this pull request
Dec 6, 2025
…ut module argument (pythonGH-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.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|