Skip to content

Commit afa13d4

Browse files
gpsheadclaude
andcommitted
Merge branch 'main' into traceback-timestamps
Resolved conflict in initconfig.c --help-env: main cleaned up duplicate entries; keep only our PYTHON_TRACEBACK_TIMESTAMPS addition. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2 parents c9ce9f8 + 83edae3 commit afa13d4

File tree

11 files changed

+93
-78
lines changed

11 files changed

+93
-78
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,13 +1014,6 @@ symtable
10141014
(Contributed by Yashp002 in :gh:`143504`.)
10151015

10161016

1017-
symtable
1018-
--------
1019-
1020-
* Add :meth:`symtable.Function.get_cells` and :meth:`symtable.Symbol.is_cell` methods.
1021-
(Contributed by Yashp002 in :gh:`143504`.)
1022-
1023-
10241017
sys
10251018
---
10261019

Lib/test/test_cmd_line.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# See test_cmd_line_script.py for testing of script execution
44

55
import os
6+
import re
67
import subprocess
78
import sys
89
import sysconfig
@@ -59,11 +60,22 @@ def test_help(self):
5960
def test_help_env(self):
6061
out = self.verify_valid_flag('--help-env')
6162
self.assertIn(b'PYTHONHOME', out)
63+
# Env vars in each section should be sorted alphabetically
64+
# (ignoring underscores so PYTHON_FOO and PYTHONFOO intermix naturally)
65+
sort_key = lambda name: name.replace(b'_', b'').lower()
66+
sections = out.split(b'These variables have equivalent')
67+
for section in sections:
68+
envvars = re.findall(rb'^(PYTHON\w+)', section, re.MULTILINE)
69+
self.assertEqual(envvars, sorted(envvars, key=sort_key),
70+
"env vars should be sorted alphabetically")
6271

6372
@support.cpython_only
6473
def test_help_xoptions(self):
6574
out = self.verify_valid_flag('--help-xoptions')
6675
self.assertIn(b'-X dev', out)
76+
options = re.findall(rb'^-X (\w+)', out, re.MULTILINE)
77+
self.assertEqual(options, sorted(options),
78+
"options should be sorted alphabetically")
6779

6880
@support.cpython_only
6981
def test_help_all(self):

Lib/test/test_pyexpat.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,25 @@ def test_trigger_leak(self):
701701
parser.ElementDeclHandler = lambda _1, _2: None
702702
self.assertRaises(TypeError, parser.Parse, data, True)
703703

704+
@support.skip_if_unlimited_stack_size
705+
@support.skip_emscripten_stack_overflow()
706+
@support.skip_wasi_stack_overflow()
707+
def test_deeply_nested_content_model(self):
708+
# This should raise a RecursionError and not crash.
709+
# See https://github.com/python/cpython/issues/145986.
710+
N = 500_000
711+
data = (
712+
b'<!DOCTYPE root [\n<!ELEMENT root '
713+
+ b'(a, ' * N + b'a' + b')' * N
714+
+ b'>\n]>\n<root/>\n'
715+
)
716+
717+
parser = expat.ParserCreate()
718+
parser.ElementDeclHandler = lambda _1, _2: None
719+
with support.infinite_recursion():
720+
with self.assertRaises(RecursionError):
721+
parser.Parse(data)
722+
704723
class MalformedInputTest(unittest.TestCase):
705724
def test1(self):
706725
xml = b"\0\r\n"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``python --help-xoptions`` is now sorted by ``-X`` option name.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``python --help-env`` sections are now sorted by environment variable name.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
:mod:`xml.parsers.expat`: Fixed a crash caused by unbounded C recursion when
2+
converting deeply nested XML content models with
3+
:meth:`~xml.parsers.expat.xmlparser.ElementDeclHandler`.
4+
This addresses :cve:`2026-4224`.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Remove :file:`Misc/indent.pro`, a configuration file for GNU
2+
:manpage:`indent(1)`.

Misc/README

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ Files found here
99

1010
ACKS Acknowledgements
1111
HISTORY News from previous releases -- oldest last
12-
indent.pro GNU indent profile approximating my C style
13-
NEWS News for this release (for some meaning of "this")
12+
NEWS.d/ News files for this release (for some meaning of "this")
1413
python-config.in Python script template for python-config
1514
python.man UNIX man page for the python interpreter
1615
python.pc.in Package configuration info template for pkg-config

Misc/indent.pro

Lines changed: 0 additions & 24 deletions
This file was deleted.

Modules/pyexpat.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#endif
44

55
#include "Python.h"
6+
#include "pycore_ceval.h" // _Py_EnterRecursiveCall()
67
#include "pycore_import.h" // _PyImport_SetModule()
78
#include "pycore_pyhash.h" // _Py_HashSecret
89
#include "pycore_traceback.h" // _PyTraceback_Add()
@@ -607,6 +608,10 @@ static PyObject *
607608
conv_content_model(XML_Content * const model,
608609
PyObject *(*conv_string)(void *))
609610
{
611+
if (_Py_EnterRecursiveCall(" in conv_content_model")) {
612+
return NULL;
613+
}
614+
610615
PyObject *result = NULL;
611616
PyObject *children = PyTuple_New(model->numchildren);
612617
int i;
@@ -618,14 +623,16 @@ conv_content_model(XML_Content * const model,
618623
conv_string);
619624
if (child == NULL) {
620625
Py_XDECREF(children);
621-
return NULL;
626+
goto done;
622627
}
623628
PyTuple_SET_ITEM(children, i, child);
624629
}
625630
result = Py_BuildValue("(iiO&N)",
626631
model->type, model->quant,
627632
conv_string, model->name, children);
628633
}
634+
done:
635+
_Py_LeaveRecursiveCall();
629636
return result;
630637
}
631638

0 commit comments

Comments
 (0)