Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
523f765
gh-125038: PyIter_Checks are added for some FOR_ITER bytecodes
efimov-mikhail Oct 7, 2024
e316cb4
gh-125038: Test on gi_frame.f_locals change for a generator
efimov-mikhail Oct 7, 2024
09df328
gh-125038: News entry is added.
efimov-mikhail Oct 7, 2024
d3d5b39
gh-125038: Raise TypeError on such case instead of silently stopping …
efimov-mikhail Oct 7, 2024
c353cf1
gh-125038: Test improvement, assertRaisesRegex is used
efimov-mikhail Oct 7, 2024
1941ced
Update Misc/NEWS.d/next/Core_and_Builtins/2024-10-07-19-26-50.gh-issu…
efimov-mikhail Oct 8, 2024
3e0b12f
gh-125038: Tests on generator modifying through gi_frame.f_locals are…
efimov-mikhail Oct 9, 2024
25e3a80
Merge branch 'sigsegv_fix_in_iterators' of github.com:efimov-mikhail/…
efimov-mikhail Oct 9, 2024
d0fa5ff
gh-124502: Add PyUnicode_Equal() function (#124504)
vstinner Oct 7, 2024
2e541a7
gh-125072: Add label for assignment expressions; update tracked secti…
emilyemorehouse Oct 7, 2024
4e25977
Docs: make a tutorial example more precise (#125066)
nedbat Oct 7, 2024
c214282
gh-90102: Remove isatty call during regular open (#124922)
cmaloney Oct 8, 2024
7788578
gh-70870: Clarify dual usage of 'free variable' (#122545)
ncoghlan Oct 8, 2024
c0a9b19
gh-69998: Fix decoding error in locale.nl_langinfo() (GH-124963)
serhiy-storchaka Oct 8, 2024
fdf1648
bpo-34206: Improve docs and test coverage for pre-init functions (#8023)
ncoghlan Oct 8, 2024
7c34a23
gh-53203: Improve tests for strptime() (GH-125090)
serhiy-storchaka Oct 8, 2024
0056888
gh-123378: fix a crash in `UnicodeError.__str__` (#124935)
picnixz Oct 8, 2024
c4812df
gh-123961: Convert _curses to a multi-phase init module (PEP-489) (#1…
picnixz Oct 8, 2024
148e3fe
gh-90102: Fix pyio _isatty_open_only() (#125089)
cmaloney Oct 8, 2024
753347e
gh-75898: make use of thread more explicit in the "Socket Programming…
zuo Oct 8, 2024
6002315
gh-121404: typo fix in compile.c: MATADATA -> METADATA (#125101)
efimov-mikhail Oct 8, 2024
8e98322
Doc: Improve description of ``GET_LEN`` opcode (#114583)
Eclips4 Oct 8, 2024
6b6d27f
gh-112433 add versionadded for `ctypes.Structure._align_` (#125087)
monkeyman192 Oct 8, 2024
b926c8e
gh-125096: Don't import _pyrepl in site if PYTHON_BASIC_REPL (#125097)
vstinner Oct 8, 2024
fc4dc44
gh-115999: Stop the world when invalidating function versions (#124997)
mpage Oct 8, 2024
8eec02d
gh-124502: Optimize unicode_eq() (#125105)
vstinner Oct 8, 2024
bd716e0
gh-117721: use PyMutex in `_thread.lock` (#125110)
kumaraditya303 Oct 8, 2024
b2764a9
gh-125084: Resolve paths in generator common code (GH-125085)
cmaloney Oct 8, 2024
320d1ab
gh-125063: Emit slices as constants in the bytecode compiler (#125064)
mdboom Oct 8, 2024
bbe670b
gh-124832: Add a note to indicate that `datetime.now` may return the …
spacemanspiff2007 Oct 8, 2024
7a4b55c
Misc improvements to the itertools docs (gh-125147)
rhettinger Oct 8, 2024
3b823fd
gh-116110: remove extra processing for the __signature__ attribute (G…
skirpichev Oct 8, 2024
0dcbd9b
GH-124478: Cleanup argparse documentation (#124877)
savannahostrowski Oct 8, 2024
5f4da9b
gh-123849: Fix test_sqlite3.test_table_dump when foreign keys are ena…
felixxm Oct 8, 2024
7c10a29
gh-124612: Use ghcr.io/python/autoconf instead of public image (#124657)
corona10 Oct 9, 2024
8192c63
gh-101552: Allow pydoc to display signatures in source format (#124669)
JelleZijlstra Oct 9, 2024
6996d4e
docs: in venv table use executable name (GH-124315)
musvaage Oct 9, 2024
0d0e6f3
gh-124502: Remove _PyUnicode_EQ() function (#125114)
vstinner Oct 9, 2024
376a1d7
gh-125150: Skip test_fma_zero_result on NetBSD due to IEE 754-2008 im…
furkanonder Oct 9, 2024
fbb424b
gh-124969: Fix locale.nl_langinfo(locale.ALT_DIGITS) (GH-124974)
serhiy-storchaka Oct 9, 2024
2c98a00
gh-107562: make_ssl_certs.py: produce test certificates that expire f…
kanavin Oct 9, 2024
8da7ac6
gh-125038: Little change in test, readability slightly improved
efimov-mikhail Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/test/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,16 @@ def loop():
#This should not raise
loop()

def test_issue125038(self):
def get_generator():
g = (x for x in range(10))
g.gi_frame.f_locals['.0'] = range(20)
return g

err_msg = "'for' requires an object with __iter__ method, got range"
with self.assertRaisesRegex(TypeError, err_msg):
l = list(get_generator())

class ExceptionTest(unittest.TestCase):
# Tests for the issue #23353: check that the currently handled exception
# is correctly saved/restored in PyEval_EvalFrameEx().
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix SIGSEGV in genexpr after direct changes on gi_frame.f_locals. Patch by
Mikhail Efimov.
33 changes: 30 additions & 3 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2806,7 +2806,16 @@ dummy_func(
replaced op(_FOR_ITER, (iter -- iter, next)) {
/* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
PyObject *next_o = (*Py_TYPE(iter_o)->tp_iternext)(iter_o);
PyTypeObject *type = Py_TYPE(iter_o);
iternextfunc iternext = type->tp_iternext;
if (iternext == NULL) {
_PyErr_Format(tstate, PyExc_TypeError,
"'for' requires an object with "
"__iter__ method, got %.100s",
type->tp_name);
ERROR_NO_POP();
}
PyObject *next_o = (*iternext)(iter_o);
if (next_o == NULL) {
if (_PyErr_Occurred(tstate)) {
int matches = _PyErr_ExceptionMatches(tstate, PyExc_StopIteration);
Expand All @@ -2832,7 +2841,16 @@ dummy_func(
op(_FOR_ITER_TIER_TWO, (iter -- iter, next)) {
/* before: [iter]; after: [iter, iter()] *or* [] (and jump over END_FOR.) */
PyObject *iter_o = PyStackRef_AsPyObjectBorrow(iter);
PyObject *next_o = (*Py_TYPE(iter_o)->tp_iternext)(iter_o);
PyTypeObject *type = Py_TYPE(iter_o);
iternextfunc iternext = type->tp_iternext;
if (iternext == NULL) {
_PyErr_Format(tstate, PyExc_TypeError,
"'for' requires an object with "
"__iter__ method, got %.100s",
type->tp_name);
ERROR_NO_POP();
}
PyObject *next_o = (*iternext)(iter_o);
if (next_o == NULL) {
if (_PyErr_Occurred(tstate)) {
int matches = _PyErr_ExceptionMatches(tstate, PyExc_StopIteration);
Expand All @@ -2856,7 +2874,16 @@ dummy_func(
_Py_CODEUNIT *target;
_PyStackRef iter_stackref = TOP();
PyObject *iter = PyStackRef_AsPyObjectBorrow(iter_stackref);
PyObject *next = (*Py_TYPE(iter)->tp_iternext)(iter);
PyTypeObject *type = Py_TYPE(iter);
iternextfunc iternext = type->tp_iternext;
if (iternext == NULL) {
_PyErr_Format(tstate, PyExc_TypeError,
"'for' requires an object with "
"__iter__ method, got %.100s",
type->tp_name);
ERROR_NO_POP();
}
PyObject *next = (*iternext)(iter);
if (next != NULL) {
PUSH(PyStackRef_FromPyObjectSteal(next));
target = next_instr;
Expand Down
13 changes: 12 additions & 1 deletion Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 24 additions & 2 deletions Python/generated_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading