Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed as duplicate of#127682
Closed as duplicate of#127682
Copy link
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
I can't upload comprehensionTestbed2.py because I am told the .py type is not allowed so I here is the script I used to reproduce this issue:
===========================================
# TestClass: Class that interacts with the DVD data file.classTestClass: # Initialize the file timestamp.def__init__(self): pass# The iterator method.def__iter__(self): print('S1') self._index=0returnself# The next method.def__next__(self): print('S5') ifself._index==5: raiseStopIterationvalue=self._indexself._index+=1returnvalue# Test code.print('#1') forninTestClass(): print(n) print('#2') numbers= [nforninTestClass()] print(numbers)==============================================
Here is the output of the Python script above:
D:\Files\Testing> comprehensionTestbed2.py #1 S1 S5 0 S5 1 S5 2 S5 3 S5 4 S5 #2 S1 S1 <----- The __iter__ method is invoked twice in the list comprehension when using 3.13.3 (and 3.13.2). S5 S5 S5 S5 S5 S5 [0, 1, 2, 3, 4] This does not happen with python 3.12.9 and is a real problem when the iter method creates a mutex.
Edward
CPython versions tested on:
3.13
Operating systems tested on:
Windows
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is providedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error