bpo-40941: Unify implicit and explicit state in the frame and generator objects into a single value. (GH-20803)
* Merge gen and frame state variables into one.
* Replace stack pointer with depth in PyFrameObject. Makes code easier to read and saves a word of memory.
diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
index 3bf1522..a634ccd 100644
--- a/Lib/test/test_generators.py
+++ b/Lib/test/test_generators.py
@@ -881,7 +881,7 @@
>>> i.gi_running = 42
Traceback (most recent call last):
...
-AttributeError: readonly attribute
+AttributeError: attribute 'gi_running' of 'generator' objects is not writable
>>> def g():
... yield me.gi_running
>>> me = g()
diff --git a/Lib/test/test_sys.py b/Lib/test/test_sys.py
index aaba663..7a5df46 100644
--- a/Lib/test/test_sys.py
+++ b/Lib/test/test_sys.py
@@ -1236,7 +1236,7 @@
nfrees = len(x.f_code.co_freevars)
extras = x.f_code.co_stacksize + x.f_code.co_nlocals +\
ncells + nfrees - 1
- check(x, vsize('5P2c4P3ic' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P'))
+ check(x, vsize('4Pi2c4P3ic' + CO_MAXBLOCKS*'3i' + 'P' + extras*'P'))
# function
def func(): pass
check(func, size('13P'))
@@ -1253,7 +1253,7 @@
check(bar, size('PP'))
# generator
def get_gen(): yield 1
- check(get_gen(), size('Pb2PPP4P'))
+ check(get_gen(), size('P2PPP4P'))
# iterator
check(iter('abc'), size('lP'))
# callable-iterator
diff --git a/Lib/test/test_yield_from.py b/Lib/test/test_yield_from.py
index 4735ef4..d105d8c 100644
--- a/Lib/test/test_yield_from.py
+++ b/Lib/test/test_yield_from.py
@@ -938,6 +938,9 @@
res.append(g1.throw(MyErr))
except StopIteration:
pass
+ except:
+ self.assertEqual(res, [0, 1, 2, 3])
+ raise
# Check with close
class MyIt(object):
def __iter__(self):