New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generator expressions trace differently on Windows than on Mac #88616
Comments
Here is a trace involving generator expressions. Using 3.10.0b3 on Mac, there are "line" events within the expression. Those events are missing on Windows. --- 8< ------------------------------- import linecache, sys
def trace(frame, event, arg):
# The weird globals here is to avoid a NameError on shutdown...
if frame.f_code.co_filename == globals().get("__file__"):
lineno = frame.f_lineno
print("{} {}: {}".format(event[:4], lineno, linecache.getline(__file__, lineno).rstrip()))
return trace
def doit():
o = ((1,2), (3,4))
o = (a for a in o)
for tup in o:
x = tup[0]
y = tup[1]
print(sys.version)
sys.settrace(trace)
doit() When run on Mac, it produces this output: 3.10.0b3 (default, Jun 18 2021, 06:43:38) [Clang 12.0.0 (clang-1200.0.32.29)] When run on Windows, it produces this output: 3.10.0b3 (tags/v3.10.0b3:865714a, Jun 17 2021, 20:39:25) [MSC v.1929 64 bit (AMD64)] On Windows, the "line 12" events are missing. |
Ned, is this a regression (does 3.9 do the right thing on Windows) or an inconsistency between Mac and Windows? I suspect this might have something to do with the PREDICT macros. If that the were the case 3.9 should show the same inconsistency between Windows and the Mac. |
This happens with all the 3.10 betas, and does not happen in 3.9 and earlier: |
I think this is a combination of https://bugs.python.org/issue44297 and the PREDICT macros. I don't have a windows machine to confirm this on, but I suspect that if you rewrite def doit():
o = ((1,2), (3,4))
o = (a for
a in
o)
for tup in o:
x = tup[0]
y = tup[1] then you should be able to observe a difference between Windows and Mac on 3.9 as well. |
I tried adding that rewritten doit as a new test, and it does not show a mac/win difference on 3.9. In fact, it doesn't show a mac/win difference on 3.10! |
Hmm, I'm a bit puzzled by that. Did you test with 3.10b3 or the latest build from the 3.10 branch with the fix to https://bugs.python.org/issue44297 included? |
This was with 3.10.0b3. I haven't got a way (yet) to build with my own-built versions of CPython. |
Ned, is this still an issue with the release candidate of 3.10? |
Looks like this is fixed with 3.10.0rc1, thanks. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: