Skip to content

Commit fd5cd26

Browse files
Merge branch '3.13' into unrevert-datetime-multiphase-init
2 parents 81bb872 + 40a024c commit fd5cd26

18 files changed

+70
-22
lines changed

Lib/_pyrepl/simple_interact.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ def runsource(self, source, filename="<input>", symbol="single"):
9595
the_symbol = symbol if stmt is last_stmt else "exec"
9696
item = wrapper([stmt])
9797
try:
98-
code = compile(item, filename, the_symbol)
99-
except (OverflowError, ValueError):
98+
code = compile(item, filename, the_symbol, dont_inherit=True)
99+
except (OverflowError, ValueError, SyntaxError):
100100
self.showsyntaxerror(filename)
101101
return False
102102

Lib/test/test_pyrepl/test_interact.py

+17
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,20 @@ def test_runsource_shows_syntax_error_for_failed_compilation(self):
9494
with patch.object(console, "showsyntaxerror") as mock_showsyntaxerror:
9595
console.runsource(source)
9696
mock_showsyntaxerror.assert_called_once()
97+
source = dedent("""\
98+
match 1:
99+
case {0: _, 0j: _}:
100+
pass
101+
""")
102+
with patch.object(console, "showsyntaxerror") as mock_showsyntaxerror:
103+
console.runsource(source)
104+
mock_showsyntaxerror.assert_called_once()
105+
106+
def test_no_active_future(self):
107+
console = InteractiveColoredConsole()
108+
source = "x: int = 1; print(__annotations__)"
109+
f = io.StringIO()
110+
with contextlib.redirect_stdout(f):
111+
result = console.runsource(source)
112+
self.assertFalse(result)
113+
self.assertEqual(f.getvalue(), "{'x': <class 'int'>}\n")

Makefile.pre.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,9 @@ LIBEXPAT_HEADERS= \
631631
Modules/expat/utf8tab.h \
632632
Modules/expat/xmlrole.h \
633633
Modules/expat/xmltok.h \
634-
Modules/expat/xmltok_impl.h
634+
Modules/expat/xmltok_impl.h \
635+
Modules/expat/xmltok_impl.c \
636+
Modules/expat/xmltok_ns.c
635637

636638
##########################################################################
637639
# hashlib's HACL* library
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The interactive REPL no longer runs with ``from __future__ import
2+
annotations`` enabled. Patch by Jelle Zijlstra.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Catch :exc:`SyntaxError` from :func:`compile` in the runsource() method of
2+
the InteractiveColoredConsole. Patch by Sergey B Kirpichev.

Modules/_ctypes/clinic/_ctypes.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/bufferedio.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/iobase.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/_io/clinic/textio.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_curses_panel.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_dbmmodule.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_elementtree.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_gdbmmodule.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/_pickle.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/arraymodule.c.h

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/clinic/pyexpat.c.h

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/Python-tokenize.c

+1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ static void
311311
tokenizeriter_dealloc(tokenizeriterobject *it)
312312
{
313313
PyTypeObject *tp = Py_TYPE(it);
314+
Py_XDECREF(it->last_line);
314315
_PyTokenizer_Free(it->tok);
315316
tp->tp_free(it);
316317
Py_DECREF(tp);

Tools/clinic/libclinic/parse_args.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def declare_parser(
3838
p for p in f.parameters.values()
3939
if not p.is_positional_only() and not p.is_vararg()
4040
])
41+
42+
condition = '#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)'
4143
if limited_capi:
4244
declarations = """
4345
#define KWTUPLE NULL
@@ -50,6 +52,9 @@ def declare_parser(
5052
# define KWTUPLE NULL
5153
#endif
5254
"""
55+
56+
codegen.add_include('pycore_runtime.h', '_Py_SINGLETON()',
57+
condition=condition)
5358
else:
5459
# XXX Why do we not statically allocate the tuple
5560
# for non-builtin modules?
@@ -73,9 +78,10 @@ def declare_parser(
7378
#endif // !Py_BUILD_CORE
7479
""" % num_keywords
7580

76-
condition = '#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)'
77-
codegen.add_include('pycore_gc.h', 'PyGC_Head', condition=condition)
78-
codegen.add_include('pycore_runtime.h', '_Py_ID()', condition=condition)
81+
codegen.add_include('pycore_gc.h', 'PyGC_Head',
82+
condition=condition)
83+
codegen.add_include('pycore_runtime.h', '_Py_ID()',
84+
condition=condition)
7985

8086
declarations += """
8187
static const char * const _keywords[] = {{{keywords_c} NULL}};

0 commit comments

Comments
 (0)