[Python-checkins] gh-125660: Reject invalid unicode escapes for Python implementation of JSON decoder (GH-125683)
https://github.com/python/cpython/commit/df751363e386d1f77c5ba9515a5539902457d386
commit: df751363e386d1f77c5ba9515a5539902457d386
branch: main
author: Nice Zombies
committer: serhiy-storchaka
date: 2024-10-18T15:29:47+03:00
summary:
gh-125660: Reject invalid unicode escapes for Python implementation of JSON
decoder (GH-125683)
files:
A Misc/NEWS.d/next/Library/2024-10-18-08-58-10.gh-issue-125660.sDdDqO.rst
M Lib/json/decoder.py
M Lib/test/test_json/test_scanstring.py
diff --git a/Lib/json/decoder.py b/Lib/json/decoder.py
index d69a45d6793069..ff4bfcdcc407b9 100644
--- a/Lib/json/decoder.py
+++ b/Lib/json/decoder.py
@@ -50,17 +50,18 @@ def __reduce__(self):
}
+HEXDIGITS = re.compile(r'[0-9A-Fa-f]{4}', FLAGS)
STRINGCHUNK = re.compile(r'(.*?)(["\\\x00-\x1f])', FLAGS)
BACKSLASH = {
'"': '"', '\\': '\\', '/': '/',
'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t',
}
-def _decode_u(s, pos):
-esc = s[pos + 1:pos + 5]
-if len(esc) == 4 and esc[1] not in 'xX':
+def _decode_u(s, pos, _m=HEXDIGITS.match):
+esc = _m(s, pos + 1)
+if esc is not None:
try:
-return int(esc, 16)
+return int(esc.group(), 16)
except ValueError:
pass
msg = "Invalid \\u escape"
diff --git a/Lib/test/test_json/test_scanstring.py
b/Lib/test/test_json/test_scanstring.py
index 2d3ee8a8bf0f92..cca556a3b95bab 100644
--- a/Lib/test/test_json/test_scanstring.py
+++ b/Lib/test/test_json/test_scanstring.py
@@ -116,6 +116,11 @@ def test_bad_escapes(self):
'"\\u012z"',
'"\\u0x12"',
'"\\u0X12"',
+'"\\u{0}"'.format("\uff10" * 4),
+'"\\u 123"',
+'"\\u-123"',
+'"\\u+123"',
+'"\\u1_23"',
'"\\ud834\\"',
'"\\ud834\\u"',
'"\\ud834\\ud"',
@@ -127,6 +132,11 @@ def test_bad_escapes(self):
'"\\ud834\\udd2z"',
'"\\ud834\\u0x20"',
'"\\ud834\\u0X20"',
+'"\\ud834\\u{0}"'.format("\uff10" * 4),
+'"\\ud834\\u 123"',
+'"\\ud834\\u-123"',
+'"\\ud834\\u+123"',
+'"\\ud834\\u1_23"',
]
for s in bad_escapes:
with self.assertRaises(self.JSONDecodeError, msg=s):
diff --git
a/Misc/NEWS.d/next/Library/2024-10-18-08-58-10.gh-issue-125660.sDdDqO.rst
b/Misc/NEWS.d/next/Library/2024-10-18-08-58-10.gh-issue-125660.sDdDqO.rst
new file mode 100644
index 00..74d76c7bddae7d
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2024-10-18-08-58-10.gh-issue-125660.sDdDqO.rst
@@ -0,0 +1 @@
+Reject invalid unicode escapes for Python implementation of :func:`json.loads`.
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605)
https://github.com/python/cpython/commit/6d93690954daae9e9a368084765a4005f957686d
commit: 6d93690954daae9e9a368084765a4005f957686d
branch: main
author: Eric Snow
committer: ericsnowcurrently
date: 2024-10-18T09:26:08-06:00
summary:
gh-125604: Move _Py_AuditHookEntry, etc. Out of pycore_runtime.h (gh-125605)
This is essentially a cleanup, moving a handful of API declarations to the
header files where they fit best, creating new ones when needed.
We do the following:
* add pycore_debug_offsets.h and move _Py_DebugOffsets, etc. there
* inline struct _getargs_runtime_state and struct _gilstate_runtime_state in
_PyRuntimeState
* move struct _reftracer_runtime_state to the existing pycore_object_state.h
* add pycore_audit.h and move to it _Py_AuditHookEntry , _PySys_Audit(), and
_PySys_ClearAuditHooks
* add audit.h and cpython/audit.h and move the existing audit-related API there
*move the perfmap/trampoline API from cpython/sysmodule.h to cpython/ceval.h,
and remove the now-empty cpython/sysmodule.h
files:
A Include/audit.h
A Include/cpython/audit.h
A Include/internal/pycore_audit.h
A Include/internal/pycore_debug_offsets.h
D Include/cpython/sysmodule.h
M Include/Python.h
M Include/cpython/ceval.h
M Include/internal/pycore_object_state.h
M Include/internal/pycore_runtime.h
M Include/internal/pycore_runtime_init.h
M Include/internal/pycore_sysmodule.h
M Include/sysmodule.h
M Makefile.pre.in
M Modules/_testexternalinspection.c
M Objects/object.c
M PCbuild/pythoncore.vcxproj
M PCbuild/pythoncore.vcxproj.filters
M Python/bytecodes.c
M Python/ceval.c
M Python/errors.c
M Python/import.c
M Python/legacy_tracing.c
M Python/pylifecycle.c
M Python/pystate.c
M Python/pythonrun.c
M Python/sysmodule.c
diff --git a/Include/Python.h b/Include/Python.h
index e1abdd16f031fb..717e27feab62db 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -124,6 +124,7 @@
#include "pylifecycle.h"
#include "ceval.h"
#include "sysmodule.h"
+#include "audit.h"
#include "osmodule.h"
#include "intrcheck.h"
#include "import.h"
diff --git a/Include/audit.h b/Include/audit.h
new file mode 100644
index 00..793b7077e1027b
--- /dev/null
+++ b/Include/audit.h
@@ -0,0 +1,30 @@
+#ifndef Py_AUDIT_H
+#define Py_AUDIT_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030d
+PyAPI_FUNC(int) PySys_Audit(
+const char *event,
+const char *argFormat,
+...);
+
+PyAPI_FUNC(int) PySys_AuditTuple(
+const char *event,
+PyObject *args);
+#endif
+
+
+#ifndef Py_LIMITED_API
+# define Py_CPYTHON_AUDIT_H
+# include "cpython/audit.h"
+# undef Py_CPYTHON_AUDIT_H
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* !Py_AUDIT_H */
diff --git a/Include/cpython/audit.h b/Include/cpython/audit.h
new file mode 100644
index 00..3c5c7a8c06091d
--- /dev/null
+++ b/Include/cpython/audit.h
@@ -0,0 +1,8 @@
+#ifndef Py_CPYTHON_AUDIT_H
+# error "this header file must not be included directly"
+#endif
+
+
+typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
+
+PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
diff --git a/Include/cpython/ceval.h b/Include/cpython/ceval.h
index 78f7405661662f..ca8109e3248a8d 100644
--- a/Include/cpython/ceval.h
+++ b/Include/cpython/ceval.h
@@ -23,3 +23,21 @@ _PyEval_RequestCodeExtraIndex(freefunc f) {
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
+
+
+// Trampoline API
+
+typedef struct {
+FILE* perf_map;
+PyThread_type_lock map_lock;
+} PerfMapState;
+
+PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
+PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(
+const void *code_addr,
+unsigned int code_size,
+const char *entry_name);
+PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);
+PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename);
+PyAPI_FUNC(int) PyUnstable_PerfTrampoline_CompileCode(PyCodeObject *);
+PyAPI_FUNC(int) PyUnstable_PerfTrampoline_SetPersistAfterFork(int enable);
diff --git a/Include/cpython/sysmodule.h b/Include/cpython/sysmodule.h
deleted file mode 100644
index a3ac07f538a94f..00
--- a/Include/cpython/sysmodule.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef Py_CPYTHON_SYSMODULE_H
-# error "this header file must not be included directly"
-#endif
-
-typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
-
-PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
-
-typedef struct {
-FILE* perf_map;
-PyThread_type_lock map_lock;
-} PerfMapState;
-
-PyAPI_FUNC(int) PyUnstable_PerfMapState_Init(void);
-PyAPI_FUNC(int) PyUnstable_WritePerfMapEntry(
-const void *code_addr,
-unsigned int code_size,
-const char *entry_name);
-PyAPI_FUNC(void) PyUnstable_PerfMapState_Fini(void);
-PyAPI_FUNC(int) PyUnstable_CopyPerfMapFile(const char* parent_filename);
-PyAPI_FUNC(int) PyUnstable_PerfTrampoline_CompileCode(PyCodeObject
[Python-checkins] [3.12] Add tests for time.strftime() with invalid format string (GH-125696) (GH-125701)
https://github.com/python/cpython/commit/93933782d999ef58682a8713e5cd3cf92166048e commit: 93933782d999ef58682a8713e5cd3cf92166048e branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka date: 2024-10-18T14:13:31Z summary: [3.12] Add tests for time.strftime() with invalid format string (GH-125696) (GH-125701) (cherry picked from commit 2e950e341930ea79549137d4d3771d5edb940e65) Co-authored-by: Serhiy Storchaka files: M Lib/test/test_time.py diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index b020787dacac1c..9463adda88db0d 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -14,7 +14,7 @@ except ImportError: _testcapi = None -from test.support import skip_if_buggy_ucrt_strfptime +from test.support import skip_if_buggy_ucrt_strfptime, SuppressCrashReport # Max year is only limited by the size of C int. SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4 @@ -178,6 +178,17 @@ def test_strftime(self): self.assertRaises(TypeError, time.strftime, b'%S', tt) +def test_strftime_invalid_format(self): +tt = time.gmtime(self.t) +with SuppressCrashReport(): +for i in range(1, 128): +format = ' %' + chr(i) +with self.subTest(format=format): +try: +time.strftime(format, tt) +except ValueError as exc: +self.assertEqual(str(exc), 'Invalid format string') + def test_strftime_special(self): tt = time.gmtime(self.t) s1 = time.strftime('%c', tt) ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-125682: Reject non-ASCII digits in the Python implementation of JSON decoder (GH-125687)
https://github.com/python/cpython/commit/d358425e6968858e52908794d15f37e62abc74ec commit: d358425e6968858e52908794d15f37e62abc74ec branch: main author: Nice Zombies committer: serhiy-storchaka date: 2024-10-18T15:26:29+03:00 summary: gh-125682: Reject non-ASCII digits in the Python implementation of JSON decoder (GH-125687) files: A Misc/NEWS.d/next/Library/2024-10-18-09-51-29.gh-issue-125682.vsj4cU.rst M Lib/json/scanner.py M Lib/test/test_json/test_decode.py diff --git a/Lib/json/scanner.py b/Lib/json/scanner.py index 7a61cfc2d24dce..090897515fe2f3 100644 --- a/Lib/json/scanner.py +++ b/Lib/json/scanner.py @@ -9,7 +9,7 @@ __all__ = ['make_scanner'] NUMBER_RE = re.compile( -r'(-?(?:0|[1-9]\d*))(\.\d+)?([eE][-+]?\d+)?', +r'(-?(?:0|[1-9][0-9]*))(\.[0-9]+)?([eE][-+]?[0-9]+)?', (re.VERBOSE | re.MULTILINE | re.DOTALL)) def py_make_scanner(context): diff --git a/Lib/test/test_json/test_decode.py b/Lib/test/test_json/test_decode.py index 79fb239b35d3f2..2250af964c022b 100644 --- a/Lib/test/test_json/test_decode.py +++ b/Lib/test/test_json/test_decode.py @@ -16,6 +16,12 @@ def test_float(self): self.assertIsInstance(rval, float) self.assertEqual(rval, 1.0) +def test_nonascii_digits_rejected(self): +# JSON specifies only ascii digits, see gh-125687 +for num in ["1\uff10", "0.\uff10", "0e\uff10"]: +with self.assertRaises(self.JSONDecodeError): +self.loads(num) + def test_bytes(self): self.assertEqual(self.loads(b"1"), 1) diff --git a/Misc/NEWS.d/next/Library/2024-10-18-09-51-29.gh-issue-125682.vsj4cU.rst b/Misc/NEWS.d/next/Library/2024-10-18-09-51-29.gh-issue-125682.vsj4cU.rst new file mode 100644 index 00..3eb2905ad8d810 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2024-10-18-09-51-29.gh-issue-125682.vsj4cU.rst @@ -0,0 +1,2 @@ +Reject non-ASCII digits in the Python implementation of :func:`json.loads` +conforming to the JSON specification. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.12] GH-125277: Increase minimum supported Sphinx to 7.2.6 (GH-125368) (#125721)
https://github.com/python/cpython/commit/2ce10b17293c67e2ceeef9ced3719a49c61aa80c commit: 2ce10b17293c67e2ceeef9ced3719a49c61aa80c branch: 3.12 author: Miss Islington (bot) <[email protected]> committer: AA-Turner <[email protected]> date: 2024-10-19T04:27:44Z summary: [3.12] GH-125277: Increase minimum supported Sphinx to 7.2.6 (GH-125368) (#125721) files: A Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst M .github/workflows/reusable-docs.yml M Doc/conf.py M Doc/requirements-oldest-sphinx.txt diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 4d1dc04e8b638a..d575963e3cec4a 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -81,7 +81,7 @@ jobs: - name: 'Set up Python' uses: actions/setup-python@v5 with: -python-version: '3.12' # known to work with Sphinx 6.2.1 +python-version: '3.13' # known to work with Sphinx 7.2.6 cache: 'pip' cache-dependency-path: 'Doc/requirements-oldest-sphinx.txt' - name: 'Install build dependencies' diff --git a/Doc/conf.py b/Doc/conf.py index fb55c5c65c2f35..f8e13cd109d7f4 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -82,7 +82,7 @@ highlight_language = 'python3' # Minimum version of sphinx required -needs_sphinx = '6.2.1' +needs_sphinx = '7.2.6' # Create table of contents entries for domain objects (e.g. functions, classes, # attributes, etc.). Default is True. diff --git a/Doc/requirements-oldest-sphinx.txt b/Doc/requirements-oldest-sphinx.txt index 068fe0cb426ecd..3483faea6b56cb 100644 --- a/Doc/requirements-oldest-sphinx.txt +++ b/Doc/requirements-oldest-sphinx.txt @@ -7,29 +7,29 @@ blurb python-docs-theme>=2022.1 # Generated from: -# pip install "Sphinx~=6.2.1" +# pip install "Sphinx~=7.2.6" # pip freeze # -# Sphinx 6.2.1 comes from ``needs_sphinx = '6.2.1'`` in ``Doc/conf.py``. +# Sphinx 7.2.6 comes from ``needs_sphinx = '7.2.6'`` in ``Doc/conf.py``. alabaster==0.7.16 -Babel==2.15.0 -certifi==2024.7.4 -charset-normalizer==3.3.2 -docutils==0.19 -idna==3.7 +Babel==2.16.0 +certifi==2024.8.30 +charset-normalizer==3.4.0 +docutils==0.20.1 +idna==3.10 imagesize==1.4.1 Jinja2==3.1.4 -MarkupSafe==2.1.5 +MarkupSafe==3.0.1 packaging==24.1 Pygments==2.18.0 requests==2.32.3 snowballstemmer==2.2.0 -Sphinx==6.2.1 -sphinxcontrib-applehelp==1.0.8 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +Sphinx==7.2.6 +sphinxcontrib-applehelp==2.0.0 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -urllib3==2.2.2 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +urllib3==2.2.3 diff --git a/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst b/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst new file mode 100644 index 00..fcd6e22c27b5f4 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst @@ -0,0 +1,2 @@ +Require Sphinx 7.2.6 or later to build the Python documentation. +Patch by Adam Turner. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] GH-125277: Increase minimum supported Sphinx to 7.2.6 (#125368)
https://github.com/python/cpython/commit/2bb7ab7ad364ec804eab8ed6867df01ece887240 commit: 2bb7ab7ad364ec804eab8ed6867df01ece887240 branch: main author: Adam Turner <[email protected]> committer: AA-Turner <[email protected]> date: 2024-10-19T04:59:22+01:00 summary: GH-125277: Increase minimum supported Sphinx to 7.2.6 (#125368) files: A Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst M .github/workflows/reusable-docs.yml M Doc/conf.py M Doc/requirements-oldest-sphinx.txt diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 3809f24dcc977e..39a97392e898aa 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -84,7 +84,7 @@ jobs: - name: 'Set up Python' uses: actions/setup-python@v5 with: -python-version: '3.12' # known to work with Sphinx 6.2.1 +python-version: '3.13' # known to work with Sphinx 7.2.6 cache: 'pip' cache-dependency-path: 'Doc/requirements-oldest-sphinx.txt' - name: 'Install build dependencies' diff --git a/Doc/conf.py b/Doc/conf.py index 839beaad08bebd..db8fb9a9a68c6b 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -90,7 +90,7 @@ highlight_language = 'python3' # Minimum version of sphinx required -needs_sphinx = '6.2.1' +needs_sphinx = '7.2.6' # Create table of contents entries for domain objects (e.g. functions, classes, # attributes, etc.). Default is True. diff --git a/Doc/requirements-oldest-sphinx.txt b/Doc/requirements-oldest-sphinx.txt index 068fe0cb426ecd..3483faea6b56cb 100644 --- a/Doc/requirements-oldest-sphinx.txt +++ b/Doc/requirements-oldest-sphinx.txt @@ -7,29 +7,29 @@ blurb python-docs-theme>=2022.1 # Generated from: -# pip install "Sphinx~=6.2.1" +# pip install "Sphinx~=7.2.6" # pip freeze # -# Sphinx 6.2.1 comes from ``needs_sphinx = '6.2.1'`` in ``Doc/conf.py``. +# Sphinx 7.2.6 comes from ``needs_sphinx = '7.2.6'`` in ``Doc/conf.py``. alabaster==0.7.16 -Babel==2.15.0 -certifi==2024.7.4 -charset-normalizer==3.3.2 -docutils==0.19 -idna==3.7 +Babel==2.16.0 +certifi==2024.8.30 +charset-normalizer==3.4.0 +docutils==0.20.1 +idna==3.10 imagesize==1.4.1 Jinja2==3.1.4 -MarkupSafe==2.1.5 +MarkupSafe==3.0.1 packaging==24.1 Pygments==2.18.0 requests==2.32.3 snowballstemmer==2.2.0 -Sphinx==6.2.1 -sphinxcontrib-applehelp==1.0.8 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +Sphinx==7.2.6 +sphinxcontrib-applehelp==2.0.0 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -urllib3==2.2.2 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +urllib3==2.2.3 diff --git a/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst b/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst new file mode 100644 index 00..fcd6e22c27b5f4 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst @@ -0,0 +1,2 @@ +Require Sphinx 7.2.6 or later to build the Python documentation. +Patch by Adam Turner. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-124694: In test_interpreter_pool, Restore the Asyncio Event Loop Policy During Cleanup (gh-125708)
https://github.com/python/cpython/commit/322f14eeff9e3b5853eaac3233f7580ca0214cf8 commit: 322f14eeff9e3b5853eaac3233f7580ca0214cf8 branch: main author: Eric Snow committer: ericsnowcurrently date: 2024-10-18T16:05:12-06:00 summary: gh-124694: In test_interpreter_pool, Restore the Asyncio Event Loop Policy During Cleanup (gh-125708) This resolves a failure on the android buildbot. files: M Lib/test/test_concurrent_futures/test_interpreter_pool.py diff --git a/Lib/test/test_concurrent_futures/test_interpreter_pool.py b/Lib/test/test_concurrent_futures/test_interpreter_pool.py index 0de03c0d669399..5264b1bb6e9c75 100644 --- a/Lib/test/test_concurrent_futures/test_interpreter_pool.py +++ b/Lib/test/test_concurrent_futures/test_interpreter_pool.py @@ -282,6 +282,19 @@ def test_idle_thread_reuse(self): class AsyncioTest(InterpretersMixin, testasyncio_utils.TestCase): +@classmethod +def setUpClass(cls): +# Most uses of asyncio will implicitly call set_event_loop_policy() +# with the default policy if a policy hasn't been set already. +# If that happens in a test, like here, we'll end up with a failure +# when --fail-env-changed is used. That's why the other tests that +# use asyncio are careful to set the policy back to None and why +# we're careful to do so here. We also validate that no other +# tests left a policy in place, just in case. +policy = support.maybe_get_event_loop_policy() +assert policy is None, policy +cls.addClassCleanup(lambda: asyncio.set_event_loop_policy(None)) + def setUp(self): super().setUp() self.loop = asyncio.new_event_loop() ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] [3.13] Add tests for time.strftime() with invalid format string (GH-125696) (GH-125702)
https://github.com/python/cpython/commit/8204014280fcb07c9321305a729716326e625c6e commit: 8204014280fcb07c9321305a729716326e625c6e branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: serhiy-storchaka date: 2024-10-18T14:22:41Z summary: [3.13] Add tests for time.strftime() with invalid format string (GH-125696) (GH-125702) (cherry picked from commit 2e950e341930ea79549137d4d3771d5edb940e65) Co-authored-by: Serhiy Storchaka files: M Lib/test/test_time.py diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py index f8b99a9b6a63f5..d368f08b610870 100644 --- a/Lib/test/test_time.py +++ b/Lib/test/test_time.py @@ -18,7 +18,7 @@ except ImportError: _testinternalcapi = None -from test.support import skip_if_buggy_ucrt_strfptime +from test.support import skip_if_buggy_ucrt_strfptime, SuppressCrashReport # Max year is only limited by the size of C int. SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4 @@ -182,6 +182,17 @@ def test_strftime(self): self.assertRaises(TypeError, time.strftime, b'%S', tt) +def test_strftime_invalid_format(self): +tt = time.gmtime(self.t) +with SuppressCrashReport(): +for i in range(1, 128): +format = ' %' + chr(i) +with self.subTest(format=format): +try: +time.strftime(format, tt) +except ValueError as exc: +self.assertEqual(str(exc), 'Invalid format string') + def test_strftime_special(self): tt = time.gmtime(self.t) s1 = time.strftime('%c', tt) ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] Add tests for time.strftime() with invalid format string (GH-125696)
https://github.com/python/cpython/commit/2e950e341930ea79549137d4d3771d5edb940e65
commit: 2e950e341930ea79549137d4d3771d5edb940e65
branch: main
author: Serhiy Storchaka
committer: serhiy-storchaka
date: 2024-10-18T16:51:29+03:00
summary:
Add tests for time.strftime() with invalid format string (GH-125696)
files:
M Lib/test/test_time.py
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index f8b99a9b6a63f5..d368f08b610870 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -18,7 +18,7 @@
except ImportError:
_testinternalcapi = None
-from test.support import skip_if_buggy_ucrt_strfptime
+from test.support import skip_if_buggy_ucrt_strfptime, SuppressCrashReport
# Max year is only limited by the size of C int.
SIZEOF_INT = sysconfig.get_config_var('SIZEOF_INT') or 4
@@ -182,6 +182,17 @@ def test_strftime(self):
self.assertRaises(TypeError, time.strftime, b'%S', tt)
+def test_strftime_invalid_format(self):
+tt = time.gmtime(self.t)
+with SuppressCrashReport():
+for i in range(1, 128):
+format = ' %' + chr(i)
+with self.subTest(format=format):
+try:
+time.strftime(format, tt)
+except ValueError as exc:
+self.assertEqual(str(exc), 'Invalid format string')
+
def test_strftime_special(self):
tt = time.gmtime(self.t)
s1 = time.strftime('%c', tt)
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] gh-124102: Clean up unsupported VS and WiX detections (GH-124784)
https://github.com/python/cpython/commit/cda0ec8e7c4e9a010e5f73c5afaf18f86cb27b97
commit: cda0ec8e7c4e9a010e5f73c5afaf18f86cb27b97
branch: main
author: Wulian
committer: zooba
date: 2024-10-18T13:48:18+01:00
summary:
gh-124102: Clean up unsupported VS and WiX detections (GH-124784)
files:
M PCbuild/pyproject.props
M Tools/msi/README.txt
M Tools/msi/wix.props
diff --git a/PCbuild/pyproject.props b/PCbuild/pyproject.props
index 9c85e5efa4af4a..c65341179376ea 100644
--- a/PCbuild/pyproject.props
+++ b/PCbuild/pyproject.props
@@ -217,11 +217,6 @@ public override bool Execute() {
-
-
- $(VCInstallDir)\redist\
-
-
<_RedistFiles Include="$(VCInstallDir)\Redist\MSVC\*\*.*" />
diff --git a/Tools/msi/README.txt b/Tools/msi/README.txt
index 98e5ba039d2bcd..8ae156450d5240 100644
--- a/Tools/msi/README.txt
+++ b/Tools/msi/README.txt
@@ -61,18 +61,20 @@ the initial download size by separating them into their own
MSIs.
Building the Installer
==
-Before building the installer, download extra build dependencies using
-Tools\msi\get_externals.bat. (Note that this is in addition to the
+Before building the installer, download the extra build dependencies
+using Tools\msi\get_externals.bat. (Note that this is in addition to the
similarly named file in PCbuild.)
-One of the dependencies used in builds is WiX, a toolset that lets developers
-create installers for Windows Installer, the Windows installation engine.
+One of the dependencies used in the build process is WiX, a toolset that
+allows developers to create installers for Windows Installer, the
+Windows installation engine. If you're not using the copy of WiX
+installed by Tools\msi\get_externals.bat, you'll need to set the
+"WixInstallPath" environment variable before building.
-Additionally, make sure "MSVC v14x - VS 20xx C++ ARM64 build tools" are
-selected under "Desktop Development with C++" in "Visual Studio installer",
-even if you are not building on ARM64. This is required because we have
-upgraded to WiX-3.14, which requires these tools for Python 3.11 and later
-versions.
+Additionally, ensure that "MSVC v14x - VS 20xx C++ ARM64/ARM64EC build tools"
+is selected under "Desktop Development with C++" in the "Visual Studio
Installer",
+even if you're not building on ARM64. This is required because we've upgraded
+to WiX 3.14, which requires these tools for Python 3.10 and later versions.
For testing, the installer should be built with the Tools/msi/build.bat
script:
diff --git a/Tools/msi/wix.props b/Tools/msi/wix.props
index d8ced317d0ce81..707c8aeacb648d 100644
--- a/Tools/msi/wix.props
+++ b/Tools/msi/wix.props
@@ -5,8 +5,6 @@
$(MSBuildThisFileDirectory)\Wix\
$(ExternalsDir)\windows-installer\wix-314\
-$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Installer
XML\3.10@InstallRoot)
-$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows
Installer XML\3.10@InstallRoot)
$(WixInstallPath)\Wix.targets
\ No newline at end of file
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] gh-123610: Added additional types to ctypes/wintypes.py (GH-124086)
https://github.com/python/cpython/commit/10c4c95395771fb37e93811aaace42f026c16de5 commit: 10c4c95395771fb37e93811aaace42f026c16de5 branch: main author: RUANG (Roy James) committer: zooba date: 2024-10-18T13:45:17+01:00 summary: gh-123610: Added additional types to ctypes/wintypes.py (GH-124086) files: M Lib/ctypes/wintypes.py diff --git a/Lib/ctypes/wintypes.py b/Lib/ctypes/wintypes.py index 9c4e721438aad5..4beba0d19513e2 100644 --- a/Lib/ctypes/wintypes.py +++ b/Lib/ctypes/wintypes.py @@ -63,10 +63,16 @@ def __repr__(self): HBITMAP = HANDLE HBRUSH = HANDLE HCOLORSPACE = HANDLE +HCONV = HANDLE +HCONVLIST = HANDLE +HCURSOR = HANDLE HDC = HANDLE +HDDEDATA = HANDLE HDESK = HANDLE +HDROP = HANDLE HDWP = HANDLE HENHMETAFILE = HANDLE +HFILE = INT HFONT = HANDLE HGDIOBJ = HANDLE HGLOBAL = HANDLE @@ -82,9 +88,11 @@ def __repr__(self): HMONITOR = HANDLE HPALETTE = HANDLE HPEN = HANDLE +HRESULT = LONG HRGN = HANDLE HRSRC = HANDLE HSTR = HANDLE +HSZ = HANDLE HTASK = HANDLE HWINSTA = HANDLE HWND = HANDLE ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
[Python-checkins] gh-125703: Correctly honour tracemalloc hooks on specialized DECREF paths (#125704)
https://github.com/python/cpython/commit/f8ba9fb2ce6690d2dd05b356583e8e4790badad7
commit: f8ba9fb2ce6690d2dd05b356583e8e4790badad7
branch: main
author: Pablo Galindo Salgado
committer: pablogsal
date: 2024-10-18T17:09:34+01:00
summary:
gh-125703: Correctly honour tracemalloc hooks on specialized DECREF paths
(#125704)
files:
A
Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst
M Include/internal/pycore_object.h
diff --git a/Include/internal/pycore_object.h b/Include/internal/pycore_object.h
index ad1a7d7e120519..96f6d61e1c620b 100644
--- a/Include/internal/pycore_object.h
+++ b/Include/internal/pycore_object.h
@@ -208,6 +208,11 @@ _Py_DECREF_SPECIALIZED(PyObject *op, const destructor
destruct)
#ifdef Py_TRACE_REFS
_Py_ForgetReference(op);
#endif
+struct _reftracer_runtime_state *tracer = &_PyRuntime.ref_tracer;
+if (tracer->tracer_func != NULL) {
+void* data = tracer->tracer_data;
+tracer->tracer_func(op, PyRefTracer_DESTROY, data);
+}
destruct(op);
}
}
diff --git
a/Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst
b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst
new file mode 100644
index 00..7cbfa725e78cef
--- /dev/null
+++
b/Misc/NEWS.d/next/Core_and_Builtins/2024-10-18-16-00-10.gh-issue-125703.QRoqMo.rst
@@ -0,0 +1,2 @@
+Correctly honour :mod:`tracemalloc` hooks in specialized ``Py_DECREF``
+paths. Patch by Pablo Galindo
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] gh-125207: Fix MSVC 1935 build with JIT (#125209)
https://github.com/python/cpython/commit/c8fd4b12e3db49d795de55f74d9bac445c059f1b
commit: c8fd4b12e3db49d795de55f74d9bac445c059f1b
branch: main
author: Michael Droettboom
committer: mdboom
date: 2024-10-18T15:51:29-04:00
summary:
gh-125207: Fix MSVC 1935 build with JIT (#125209)
* gh-125207: Use {0} array initializers
* Simplify, as suggested in PR
* Revert change to explicitly specify length
files:
M Python/jit.c
M Tools/jit/_stencils.py
M Tools/jit/_writer.py
diff --git a/Python/jit.c b/Python/jit.c
index 234fc7dda83231..963bde2303dc2c 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -469,7 +469,7 @@ _PyJIT_Compile(_PyExecutorObject *executor, const
_PyUOpInstruction trace[], siz
// Loop once to find the total compiled size:
size_t code_size = 0;
size_t data_size = 0;
-jit_state state = {};
+jit_state state = {0};
group = &trampoline;
code_size += group->code_size;
data_size += group->data_size;
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index bbb52f391f4b01..e4b2bf6e4702b3 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -339,7 +339,7 @@ def _get_trampoline_mask(self) -> str:
word = bitmask & ((1 << 32) - 1)
trampoline_mask.append(f"{word:#04x}")
bitmask >>= 32
-return "{" + ", ".join(trampoline_mask) + "}"
+return "{" + (", ".join(trampoline_mask) or "0") + "}"
def as_c(self, opname: str) -> str:
"""Dump this hole as a StencilGroup initializer."""
diff --git a/Tools/jit/_writer.py b/Tools/jit/_writer.py
index 7b99d10310a645..4e7f614b0e9d23 100644
--- a/Tools/jit/_writer.py
+++ b/Tools/jit/_writer.py
@@ -32,8 +32,11 @@ def _dump_footer(
yield "};"
yield ""
yield f"static const void * const symbols_map[{max(len(symbols), 1)}] = {{"
-for symbol, ordinal in symbols.items():
-yield f"[{ordinal}] = &{symbol},"
+if symbols:
+for symbol, ordinal in symbols.items():
+yield f"[{ordinal}] = &{symbol},"
+else:
+yield "0"
yield "};"
___
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]
[Python-checkins] [3.13] GH-125277: Increase minimum supported Sphinx to 7.2.6 (GH-125368) (#125720)
https://github.com/python/cpython/commit/fbbc79ea252fcf8e7557d6057688a8041fcafaef commit: fbbc79ea252fcf8e7557d6057688a8041fcafaef branch: 3.13 author: Miss Islington (bot) <[email protected]> committer: AA-Turner <[email protected]> date: 2024-10-19T04:23:22Z summary: [3.13] GH-125277: Increase minimum supported Sphinx to 7.2.6 (GH-125368) (#125720) files: A Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst M .github/workflows/reusable-docs.yml M Doc/conf.py M Doc/requirements-oldest-sphinx.txt diff --git a/.github/workflows/reusable-docs.yml b/.github/workflows/reusable-docs.yml index 3809f24dcc977e..39a97392e898aa 100644 --- a/.github/workflows/reusable-docs.yml +++ b/.github/workflows/reusable-docs.yml @@ -84,7 +84,7 @@ jobs: - name: 'Set up Python' uses: actions/setup-python@v5 with: -python-version: '3.12' # known to work with Sphinx 6.2.1 +python-version: '3.13' # known to work with Sphinx 7.2.6 cache: 'pip' cache-dependency-path: 'Doc/requirements-oldest-sphinx.txt' - name: 'Install build dependencies' diff --git a/Doc/conf.py b/Doc/conf.py index 839beaad08bebd..db8fb9a9a68c6b 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -90,7 +90,7 @@ highlight_language = 'python3' # Minimum version of sphinx required -needs_sphinx = '6.2.1' +needs_sphinx = '7.2.6' # Create table of contents entries for domain objects (e.g. functions, classes, # attributes, etc.). Default is True. diff --git a/Doc/requirements-oldest-sphinx.txt b/Doc/requirements-oldest-sphinx.txt index 068fe0cb426ecd..3483faea6b56cb 100644 --- a/Doc/requirements-oldest-sphinx.txt +++ b/Doc/requirements-oldest-sphinx.txt @@ -7,29 +7,29 @@ blurb python-docs-theme>=2022.1 # Generated from: -# pip install "Sphinx~=6.2.1" +# pip install "Sphinx~=7.2.6" # pip freeze # -# Sphinx 6.2.1 comes from ``needs_sphinx = '6.2.1'`` in ``Doc/conf.py``. +# Sphinx 7.2.6 comes from ``needs_sphinx = '7.2.6'`` in ``Doc/conf.py``. alabaster==0.7.16 -Babel==2.15.0 -certifi==2024.7.4 -charset-normalizer==3.3.2 -docutils==0.19 -idna==3.7 +Babel==2.16.0 +certifi==2024.8.30 +charset-normalizer==3.4.0 +docutils==0.20.1 +idna==3.10 imagesize==1.4.1 Jinja2==3.1.4 -MarkupSafe==2.1.5 +MarkupSafe==3.0.1 packaging==24.1 Pygments==2.18.0 requests==2.32.3 snowballstemmer==2.2.0 -Sphinx==6.2.1 -sphinxcontrib-applehelp==1.0.8 -sphinxcontrib-devhelp==1.0.6 -sphinxcontrib-htmlhelp==2.0.5 +Sphinx==7.2.6 +sphinxcontrib-applehelp==2.0.0 +sphinxcontrib-devhelp==2.0.0 +sphinxcontrib-htmlhelp==2.1.0 sphinxcontrib-jsmath==1.0.1 -sphinxcontrib-qthelp==1.0.7 -sphinxcontrib-serializinghtml==1.1.10 -urllib3==2.2.2 +sphinxcontrib-qthelp==2.0.0 +sphinxcontrib-serializinghtml==2.0.0 +urllib3==2.2.3 diff --git a/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst b/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst new file mode 100644 index 00..fcd6e22c27b5f4 --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2024-10-10-23-46-54.gh-issue-125277.QAby09.rst @@ -0,0 +1,2 @@ +Require Sphinx 7.2.6 or later to build the Python documentation. +Patch by Adam Turner. ___ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: [email protected]
