]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
2 years agogh-104504: Cases generator: enable mypy's `possibly-undefined` error code (#108454)
Alex Waygood [Fri, 25 Aug 2023 17:08:29 +0000 (18:08 +0100)] 
gh-104504: Cases generator: enable mypy's `possibly-undefined` error code (#108454)

2 years agogh-102211: Document `re.{Pattern,Match}`’s existence (#102212)
Philipp A [Fri, 25 Aug 2023 16:53:11 +0000 (18:53 +0200)] 
gh-102211: Document `re.{Pattern,Match}`’s existence (#102212)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2 years agogh-108311: Fix test_store_attr_with_hint by disabling optimizer in decorator (#108312)
Guido van Rossum [Fri, 25 Aug 2023 16:40:27 +0000 (09:40 -0700)] 
gh-108311: Fix test_store_attr_with_hint by disabling optimizer in decorator (#108312)

See https://github.com/python/cpython/issues/108311#issuecomment-1693569380

---------

Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2 years agogh-107265: Revert "Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR" (#108485)
Dong-hee Na [Fri, 25 Aug 2023 15:23:39 +0000 (00:23 +0900)] 
gh-107265: Revert "Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR" (#108485)

This reverts commit d6ac5c7b105fe57266bd71248e3ada41fedb5ba9.

Reason: the assert we just added could be triggered (see issue).

2 years agogh-108364: Simplify quoting values and identifiers in sqlite3's iterdump() (#108472)
Mariusz Felisiak [Fri, 25 Aug 2023 12:31:52 +0000 (14:31 +0200)] 
gh-108364: Simplify quoting values and identifiers in sqlite3's iterdump() (#108472)

2 years agogh-107932: Fix merge conflict in test_dis (GH-108478)
Mark Shannon [Fri, 25 Aug 2023 12:02:10 +0000 (13:02 +0100)] 
gh-107932: Fix merge conflict in test_dis (GH-108478)

Fix merge conflict in test_dis

2 years agoDocs: Resolve Sphinx warnings in dis.rst (#108476)
Erlend E. Aasland [Fri, 25 Aug 2023 11:28:47 +0000 (13:28 +0200)] 
Docs: Resolve Sphinx warnings in dis.rst (#108476)

- Link to the code objects reference
- Suppress link to deliberately undocumented builtins.__build_class__
- Suppress links for example methods

2 years agoDatamodel: Add headings to the standard type hierarchy (#108146)
Adam Turner [Fri, 25 Aug 2023 11:02:36 +0000 (12:02 +0100)] 
Datamodel: Add headings to the standard type hierarchy (#108146)

Dedent content according to the new layout.

2 years agoDocs: Datamodel: Merge "Notes on using __slots__" with the parent section (#108400)
Adam Turner [Fri, 25 Aug 2023 10:27:36 +0000 (11:27 +0100)] 
Docs: Datamodel: Merge "Notes on using __slots__" with the parent section (#108400)

2 years agogh-108418: Speed up bigmem compression tests in dry mode (GH-108419)
Serhiy Storchaka [Fri, 25 Aug 2023 09:37:27 +0000 (12:37 +0300)] 
gh-108418: Speed up bigmem compression tests in dry mode (GH-108419)

Only generate and compress small amount of random data in dry run.

2 years agogh-108444: Remove _PyLong_AsInt() function (#108461)
Victor Stinner [Fri, 25 Aug 2023 09:13:59 +0000 (11:13 +0200)] 
gh-108444: Remove _PyLong_AsInt() function (#108461)

* Update Parser/asdl_c.py to regenerate Python/Python-ast.c.
* Remove _PyLong_AsInt() alias to PyLong_AsInt().

2 years agogh-107932: Fix dis module for bytecode that does not have an associated source line...
Corvin [Fri, 25 Aug 2023 08:31:26 +0000 (04:31 -0400)] 
gh-107932: Fix dis module for bytecode that does not have an associated source line (GH-107988)

2 years agogh-103384: Generalize the regex pattern `BaseConfigurator.INDEX_PATTERN` to allow...
Peeyush Aggarwal [Fri, 25 Aug 2023 08:15:26 +0000 (13:45 +0530)] 
gh-103384: Generalize the regex pattern `BaseConfigurator.INDEX_PATTERN` to allow spaces and non-alphanumeric characters in keys. (GH-103391)

Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2 years agoGH-108202: Document ``calendar`` exceptions (#108398)
Adam Turner [Fri, 25 Aug 2023 05:56:54 +0000 (06:56 +0100)] 
GH-108202: Document ``calendar`` exceptions (#108398)

2 years agogh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)
Guido van Rossum [Fri, 25 Aug 2023 00:36:00 +0000 (17:36 -0700)] 
gh-106581: Split CALL_BOUND_METHOD_EXACT_ARGS into uops (#108462)

Instead of using `GO_TO_INSTRUCTION(CALL_PY_EXACT_ARGS)` we just add the macro elements of the latter to the macro for the former. This requires lengthening the uops array in struct opcode_macro_expansion. (It also required changes to stacking.py that were merged already.)

2 years agogh-106320: Remove private _PyTraceback functions (#108453)
Victor Stinner [Thu, 24 Aug 2023 23:35:47 +0000 (01:35 +0200)] 
gh-106320: Remove private _PyTraceback functions (#108453)

Move private functions to the internal C API (pycore_traceback.h):

* _Py_DisplaySourceLine()
* _PyTraceback_Add()

2 years agogh-107265: Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR (gh-108460)
Dong-hee Na [Thu, 24 Aug 2023 23:03:26 +0000 (08:03 +0900)] 
gh-107265: Ensure _PyCode_Quicken does not handle ENTER_EXECUTOR (gh-108460)

2 years agogh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() (#108459)
Victor Stinner [Thu, 24 Aug 2023 23:01:30 +0000 (01:01 +0200)] 
gh-108444: Replace _PyLong_AsInt() with PyLong_AsInt() (#108459)

Change generated by the command:

sed -i -e 's!_PyLong_AsInt!PyLong_AsInt!g' \
    $(find -name "*.c" -o -name "*.h")

2 years agogh-108444: Argument Clinic uses PyLong_AsInt() (#108458)
Victor Stinner [Thu, 24 Aug 2023 22:51:22 +0000 (00:51 +0200)] 
gh-108444: Argument Clinic uses PyLong_AsInt() (#108458)

Argument Clinic now uses the new public PyLong_AsInt(), rather than
the old name _PyLong_AsInt().

2 years agoRun `mypy` when `Tools/requirements-dev.txt` changes (#108457)
Nikita Sobolev [Thu, 24 Aug 2023 22:05:23 +0000 (01:05 +0300)] 
Run `mypy` when `Tools/requirements-dev.txt` changes (#108457)

2 years agogh-108444: Add PyLong_AsInt() public function (#108445)
Victor Stinner [Thu, 24 Aug 2023 21:55:30 +0000 (23:55 +0200)] 
gh-108444: Add PyLong_AsInt() public function (#108445)

* Rename _PyLong_AsInt() to PyLong_AsInt().
* Add documentation.
* Add test.
* For now, keep _PyLong_AsInt() as an alias to PyLong_AsInt().

2 years agoGH-103247: bypass the import cache on the _require_loader helper
Filipe Laíns [Thu, 24 Aug 2023 21:05:03 +0000 (22:05 +0100)] 
GH-103247: bypass the import cache on the _require_loader helper

2 years agogh-108447: Detect platform triplets for x86_64 GNU/Hurd (#108045)
Samuel Thibault [Thu, 24 Aug 2023 20:37:20 +0000 (22:37 +0200)] 
gh-108447: Detect platform triplets for x86_64 GNU/Hurd (#108045)

2 years agogh-106320: Remove private _PySys functions (#108452)
Victor Stinner [Thu, 24 Aug 2023 20:02:09 +0000 (22:02 +0200)] 
gh-106320: Remove private _PySys functions (#108452)

Move private functions to the internal C API (pycore_sysmodule.h):

* _PySys_GetAttr()
* _PySys_GetSizeOf()

No longer export most of these functions.

Fix also a typo in Include/cpython/optimizer.h: add a missing space.

2 years agogh-106320: Remove private _PyDict functions (#108449)
Victor Stinner [Thu, 24 Aug 2023 20:01:50 +0000 (22:01 +0200)] 
gh-106320: Remove private _PyDict functions (#108449)

Move private functions to the internal C API (pycore_dict.h):

* _PyDictView_Intersect()
* _PyDictView_New()
* _PyDict_ContainsId()
* _PyDict_DelItemId()
* _PyDict_DelItem_KnownHash()
* _PyDict_GetItemIdWithError()
* _PyDict_GetItem_KnownHash()
* _PyDict_HasSplitTable()
* _PyDict_NewPresized()
* _PyDict_Next()
* _PyDict_Pop()
* _PyDict_SetItemId()
* _PyDict_SetItem_KnownHash()
* _PyDict_SizeOf()

No longer export most of these functions.

Move also the _PyDictViewObject structure to the internal C API.

Move dict_getitem_knownhash() function from _testcapi to the
_testinternalcapi extension. Update test_capi.test_dict for this
change.

2 years agogh-106320: Remove private _PyList functions (#108451)
Victor Stinner [Thu, 24 Aug 2023 19:44:34 +0000 (21:44 +0200)] 
gh-106320: Remove private _PyList functions (#108451)

Move private functions to the internal C API (pycore_list.h):

* _PyList_Extend()
* _PyList_DebugMallocStats()

No longer export these functions.

2 years agogh-106581: Fix two bugs in the code generator's copy optimization (#108380)
Guido van Rossum [Thu, 24 Aug 2023 19:10:51 +0000 (12:10 -0700)] 
gh-106581: Fix two bugs in the code generator's copy optimization (#108380)

I was comparing the last preceding poke with the *last* peek,
rather than the *first* peek.

Unfortunately this bug obscured another bug:
When the last preceding poke is UNUSED, the first peek disappears,
leaving the variable unassigned. This is how I fixed it:

- Rename CopyEffect to CopyItem.
- Change CopyItem to contain StackItems instead of StackEffects.
- Update those StackItems when adjusting the manager higher or lower.
- Assert that those StackItems' offsets are equivalent.
- Other clever things.

---------

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2 years agogh-106320: Remove private _PyEval function (#108433)
Victor Stinner [Thu, 24 Aug 2023 18:25:22 +0000 (20:25 +0200)] 
gh-106320: Remove private _PyEval function (#108433)

Move private _PyEval functions to the internal C API
(pycore_ceval.h):

* _PyEval_GetBuiltin()
* _PyEval_GetBuiltinId()
* _PyEval_GetSwitchInterval()
* _PyEval_MakePendingCalls()
* _PyEval_SetProfile()
* _PyEval_SetSwitchInterval()
* _PyEval_SetTrace()

No longer export most of these functions.

2 years agogh-80527: Change support.requires_legacy_unicode_capi() (#108438)
Victor Stinner [Thu, 24 Aug 2023 18:09:23 +0000 (20:09 +0200)] 
gh-80527: Change support.requires_legacy_unicode_capi() (#108438)

The decorator now requires to be called with parenthesis:

    @support.requires_legacy_unicode_capi()

instead of:

    @support.requires_legacy_unicode_capi

The implementation now only imports _testcapi when the decorator is
called, so "import test.support" no longer imports the _testcapi
extension.

2 years agogh-107211: Fix test_peg_generator (#108435)
Victor Stinner [Thu, 24 Aug 2023 17:47:44 +0000 (19:47 +0200)] 
gh-107211: Fix test_peg_generator (#108435)

Export these internal functions for test_peg_generator

* _PyArena_AddPyObject()
* _PyArena_Free()
* _PyArena_Malloc()
* _PyArena_New()

2 years agogh-107178: Remove _testcapi.test_dict_capi() (#108436)
Victor Stinner [Thu, 24 Aug 2023 17:43:29 +0000 (19:43 +0200)] 
gh-107178: Remove _testcapi.test_dict_capi() (#108436)

The new _testcapi.test_dict tests are more complete,
_testcapi.test_dict_capi() became redundant.

2 years agogh-106320: Remove private _PyContext_NewHamtForTests() (#108434)
Victor Stinner [Thu, 24 Aug 2023 17:37:41 +0000 (19:37 +0200)] 
gh-106320: Remove private _PyContext_NewHamtForTests() (#108434)

Move the function to the internal C API.

2 years agogh-108388: Convert test_concurrent_futures to package (#108401)
Victor Stinner [Thu, 24 Aug 2023 17:21:44 +0000 (19:21 +0200)] 
gh-108388: Convert test_concurrent_futures to package (#108401)

Convert test_concurrent_futures to a package of sub-tests.

2 years agogh-106320: Remove private float C API functions (#108430)
Victor Stinner [Thu, 24 Aug 2023 17:09:49 +0000 (19:09 +0200)] 
gh-106320: Remove private float C API functions (#108430)

106320: Remove private float C API functions

Remove private C API functions:

* _Py_parse_inf_or_nan()
* _Py_string_to_number_with_underscores()

Move these functions to the internal C API and no longer export them.

2 years agogh-106320: Remove private _PyManagedBuffer_Type (#108431)
Victor Stinner [Thu, 24 Aug 2023 17:07:54 +0000 (19:07 +0200)] 
gh-106320: Remove private _PyManagedBuffer_Type (#108431)

Remove private _PyManagedBuffer_Type variable. Move it to the
internal C API and no longer export it.

2 years agogh-106320: Remove private PyLong C API functions (#108429)
Victor Stinner [Thu, 24 Aug 2023 16:53:50 +0000 (18:53 +0200)] 
gh-106320: Remove private PyLong C API functions (#108429)

Remove private PyLong C API functions:

* _PyLong_AsByteArray()
* _PyLong_DivmodNear()
* _PyLong_Format()
* _PyLong_Frexp()
* _PyLong_FromByteArray()
* _PyLong_FromBytes()
* _PyLong_GCD()
* _PyLong_Lshift()
* _PyLong_Rshift()

Move these functions to the internal C API. No longer export
_PyLong_FromBytes() function.

2 years agoFix a code snippet typo in asyncio docs (#108427)
A [Thu, 24 Aug 2023 16:27:54 +0000 (00:27 +0800)] 
Fix a code snippet typo in asyncio docs (#108427)

2 years agogh-107211: No longer export internal functions (5) (#108423)
Victor Stinner [Thu, 24 Aug 2023 16:06:53 +0000 (18:06 +0200)] 
gh-107211: No longer export internal functions (5) (#108423)

No longer export _PyCompile_AstOptimize() internal C API function.

Change comment style to "// comment" and add comment explaining why
other functions have to be exported.

2 years agogh-107211: No longer export internal functions (7) (#108425)
Victor Stinner [Thu, 24 Aug 2023 15:40:56 +0000 (17:40 +0200)] 
gh-107211: No longer export internal functions (7) (#108425)

No longer export _PyUnicode_FromId() internal C API function.

Change comment style to "// comment" and add comment explaining why
other functions have to be exported.

Update Tools/build/generate_token.py to update Include/internal/pycore_token.h
comments.

2 years agogh-108308: Remove _PyDict_GetItemStringWithError() function (#108426)
Victor Stinner [Thu, 24 Aug 2023 15:34:22 +0000 (17:34 +0200)] 
gh-108308: Remove _PyDict_GetItemStringWithError() function (#108426)

Remove the internal _PyDict_GetItemStringWithError() function. It can
now be replaced with the new public PyDict_ContainsString() and
PyDict_GetItemStringRef() functions.

getargs.c now now uses a strong reference for current_arg.
find_keyword() returns a strong reference.

2 years agogh-107211: No longer export internal functions (6) (#108424)
Victor Stinner [Thu, 24 Aug 2023 15:28:35 +0000 (17:28 +0200)] 
gh-107211: No longer export internal functions (6) (#108424)

No longer export these 5 internal C API functions:

* _PyArena_AddPyObject()
* _PyArena_Free()
* _PyArena_Malloc()
* _PyArena_New()
* _Py_FatalRefcountErrorFunc()

Change comment style to "// comment" and add comment explaining why
other functions have to be exported.

2 years agogh-107211: No longer export PyTime internal functions (#108422)
Victor Stinner [Thu, 24 Aug 2023 15:17:40 +0000 (17:17 +0200)] 
gh-107211: No longer export PyTime internal functions (#108422)

No longer export these 2 internal C API functions:

* _PyTime_AsNanoseconds()
* _PyTime_GetSystemClockWithInfo()

Change comment style to "// comment" and add comment explaining why
other functions have to be exported.

2 years agogh-108240: _PyCapsule_SetTraverse() rejects NULL callbacks (#108417)
Victor Stinner [Thu, 24 Aug 2023 14:37:59 +0000 (16:37 +0200)] 
gh-108240: _PyCapsule_SetTraverse() rejects NULL callbacks (#108417)

2 years agogh-108314: Add PyDict_ContainsString() function (#108323)
Victor Stinner [Thu, 24 Aug 2023 13:59:12 +0000 (15:59 +0200)] 
gh-108314: Add PyDict_ContainsString() function (#108323)

2 years agogh-95855: Refactor platform triplet detection code, add detection for MIPS soft float...
Jeffery To [Thu, 24 Aug 2023 12:22:50 +0000 (20:22 +0800)] 
gh-95855: Refactor platform triplet detection code, add detection for MIPS soft float and musl libc (#107221)

- Move platform triplet detection code into Misc/platform_triplet.c
- Refactor MIPS detection, use defined(__mips64) to detect MIPS64
- Compute libc values in separate section
- Add detection for MIPS soft float
- Add detection for musl

musl supports SPE with its soft-float ABI:
https://git.musl-libc.org/cgit/musl/commit/?id=7be59733d71ada3a32a98622507399253f1d5e48

Original patch by Christian Heimes.

Co-authored-by: Christian Heimes <christian@python.org>
Co-authored-by: Erlend E. Aasland <erlend@python.org>
2 years agogh-107432 Update Porting Python 2 Code to Python 3 how-to (GH-107434)
Daniele Procida [Thu, 24 Aug 2023 09:28:23 +0000 (11:28 +0200)] 
gh-107432 Update Porting Python 2 Code to Python 3 how-to (GH-107434)

https://docs.python.org/3/howto/pyporting.html#porting-python-2-code-to-python-3 was written for another time. In this patch:

- material that frames Python 3 as "new" is removed
- descriptions and directions have been trimmed

2 years agogh-108111: Flush gzip write buffer before seeking, fixing bad writes (#108341)
Chris Markiewicz [Thu, 24 Aug 2023 08:23:01 +0000 (04:23 -0400)] 
gh-108111: Flush gzip write buffer before seeking, fixing bad writes (#108341)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2 years agogh-108388: Split test_multiprocessing_spawn (#108396)
Victor Stinner [Thu, 24 Aug 2023 03:35:39 +0000 (05:35 +0200)] 
gh-108388: Split test_multiprocessing_spawn (#108396)

Split test_multiprocessing_fork, test_multiprocessing_forkserver and
test_multiprocessing_spawn into test packages. Each package is made
of 4 sub-tests: processes, threads, manager and misc. It allows
running more tests in parallel and so reduce the total test duration.

2 years agogh-108388: regrtest splits test_asyncio package (#108393)
Victor Stinner [Thu, 24 Aug 2023 02:44:58 +0000 (04:44 +0200)] 
gh-108388: regrtest splits test_asyncio package (#108393)

Currently, test_asyncio package is only splitted into sub-tests when
using command "./python -m test". With this change, it's also
splitted when passing it on the command line:
"./python -m test test_asyncio".

Remove the concept of "STDTESTS". Python is now mature enough to not
have to bother with that anymore. Removing STDTESTS simplify the
code.

2 years agotest_peg_generator and test_freeze require cpu (#108386)
Victor Stinner [Wed, 23 Aug 2023 22:52:48 +0000 (00:52 +0200)] 
test_peg_generator and test_freeze require cpu (#108386)

The test_peg_generator and test_tools.test_freeze tests now require
the 'cpu' resource. Skip these tests unless the 'cpu' resource is
enabled (it is disabled by default).

These tests are no longer skipped if Python is built with ASAN or
MSAN sanitizer.

2 years agogh-108253: Fix reads of uninitialized memory in funcobject.c (#108383)
Guido van Rossum [Wed, 23 Aug 2023 22:36:19 +0000 (15:36 -0700)] 
gh-108253: Fix reads of uninitialized memory in funcobject.c (#108383)

2 years agogh-108240: Add _PyCapsule_SetTraverse() internal function (#108339)
Victor Stinner [Wed, 23 Aug 2023 22:19:11 +0000 (00:19 +0200)] 
gh-108240: Add _PyCapsule_SetTraverse() internal function (#108339)

The _socket extension uses _PyCapsule_SetTraverse() to visit and clear
the socket type in the garbage collector. So the _socket.socket type
can be cleared in some corner cases when it wasn't possible before.

2 years agogh-70766: Mention the object getstate caveat in 3.11 What's new. (#108379)
Gregory P. Smith [Wed, 23 Aug 2023 22:00:09 +0000 (15:00 -0700)] 
gh-70766: Mention the object getstate caveat in 3.11 What's new. (#108379)

2 years agogh-108308: Use PyDict_GetItemRef() in moduleobject.c (#108381)
Victor Stinner [Wed, 23 Aug 2023 21:57:40 +0000 (23:57 +0200)] 
gh-108308: Use PyDict_GetItemRef() in moduleobject.c (#108381)

Replace PyDict_GetItemWithError() with PyDict_GetItemRef() which
returns a strong reference.

Cleanup also the function: move variable definition to their first
assignation, rename variable names to use name longer than 1
character.

2 years agogh-108342: Make ssl TestPreHandshakeClose more reliable (#108370)
Victor Stinner [Wed, 23 Aug 2023 21:57:11 +0000 (23:57 +0200)] 
gh-108342: Make ssl TestPreHandshakeClose more reliable (#108370)

* In preauth tests of test_ssl, explicitly break reference cycles
  invoving SingleConnectionTestServerThread to make sure that the
  thread is deleted. Otherwise, the test marks the environment as
  altered because the threading module sees a "dangling thread"
  (SingleConnectionTestServerThread). This test leak was introduced
  by the test added for the fix of issue gh-108310.
* Use support.SHORT_TIMEOUT instead of hardcoded 1.0 or 2.0 seconds
  timeout.
* SingleConnectionTestServerThread.run() catchs TimeoutError
* Fix a race condition (missing synchronization) in
  test_preauth_data_to_tls_client(): the server now waits until the
  client connect() completed in call_after_accept().
* test_https_client_non_tls_response_ignored() calls server.join()
  explicitly.
* Replace "localhost" with server.listener.getsockname()[0].

2 years agogh-108308: config_dict_get() uses PyDict_GetItemRef() (#108371)
Victor Stinner [Wed, 23 Aug 2023 21:12:08 +0000 (23:12 +0200)] 
gh-108308: config_dict_get() uses PyDict_GetItemRef() (#108371)

Replace _PyDict_GetItemStringWithError() with PyDict_GetItemRef() in
config_dict_get() to get a strong reference to the item.

2 years agogh-108308: Replace _PyDict_GetItemStringWithError() (#108372)
Victor Stinner [Wed, 23 Aug 2023 20:59:00 +0000 (22:59 +0200)] 
gh-108308: Replace _PyDict_GetItemStringWithError() (#108372)

Replace _PyDict_GetItemStringWithError() calls with
PyDict_GetItemStringRef() which returns a strong reference to the
item.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2 years agogh-77377: Ensure multiprocessing SemLock is valid for spawn-based Process before...
albanD [Wed, 23 Aug 2023 20:27:35 +0000 (16:27 -0400)] 
gh-77377: Ensure multiprocessing SemLock is valid for spawn-based Process before serializing it (#107275)

Ensure multiprocessing SemLock is valid for spawn Process before serializing it.

Creating a multiprocessing SemLock with a fork context, and then trying to pass it to a spawn-created Process, would segfault if not detected early.

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2 years agogh-107811: tarfile: treat overflow in UID/GID as failure to set it (#108369)
Petr Viktorin [Wed, 23 Aug 2023 18:00:07 +0000 (20:00 +0200)] 
gh-107811: tarfile: treat overflow in UID/GID as failure to set it (#108369)

2 years agogh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. (#108367)
Irit Katriel [Wed, 23 Aug 2023 17:39:00 +0000 (18:39 +0100)] 
gh-105481: remove regen-opcode. Generated _PyOpcode_Caches in regen-cases. (#108367)

2 years agogh-107298: Fix a few more refs in the C API docs (GH-108361)
Serhiy Storchaka [Wed, 23 Aug 2023 17:12:42 +0000 (20:12 +0300)] 
gh-107298: Fix a few more refs in the C API docs (GH-108361)

gh-107298: Fix few more refs in the C API docs

2 years agogh-107265: Ensure de_instrument does not handle ENTER_EXECUTOR (#108366)
Dong-hee Na [Wed, 23 Aug 2023 15:45:20 +0000 (00:45 +0900)] 
gh-107265: Ensure de_instrument does not handle ENTER_EXECUTOR (#108366)

2 years agogh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354)
Nikita Sobolev [Wed, 23 Aug 2023 15:42:08 +0000 (18:42 +0300)] 
gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354)

2 years agogh-108308: Replace PyDict_GetItem() with PyDict_GetItemRef() (#108309)
Victor Stinner [Wed, 23 Aug 2023 15:40:26 +0000 (17:40 +0200)] 
gh-108308: Replace PyDict_GetItem() with PyDict_GetItemRef() (#108309)

Replace PyDict_GetItem() calls with PyDict_GetItemRef()
or PyDict_GetItemWithError() to handle errors.

* Replace PyLong_AS_LONG() with _PyLong_AsInt()
  and check for errors.
* Check for PyDict_Contains() error.
* pycore_init_builtins() checks for _PyType_Lookup() failure.

2 years agogh-50002: xml.dom.minidom now preserves whitespaces in attributes (GH-107947)
Serhiy Storchaka [Wed, 23 Aug 2023 12:23:41 +0000 (15:23 +0300)] 
gh-50002: xml.dom.minidom now preserves whitespaces in attributes (GH-107947)

Also double quotes (") are now only quoted in attributes.

2 years agogh-105539: Fix ResourceWarning from unclosed SQLite connections in test_sqlite3 ...
Mariusz Felisiak [Wed, 23 Aug 2023 10:10:08 +0000 (12:10 +0200)] 
gh-105539: Fix ResourceWarning from unclosed SQLite connections in test_sqlite3 (#108360)

Follow up to 1a1bfc28912a39b500c578e9f10a8a222638d411.

Explicitly manage connections in:

- test_audit.test_sqlite3
- test_sqlite3.test_audit
- test_sqlite3.test_backup

Co-authored-by: Erlend E. Aasland <erlend@python.org>
2 years agogh-108294: Add time.sleep audit event (GH-108298)
Petr Viktorin [Wed, 23 Aug 2023 09:00:22 +0000 (11:00 +0200)] 
gh-108294: Add time.sleep audit event (GH-108298)

2 years agogh-108113: Make it possible to optimize an AST (#108282)
Irit Katriel [Wed, 23 Aug 2023 08:01:17 +0000 (09:01 +0100)] 
gh-108113: Make it possible to optimize an AST (#108282)

2 years agogh-108267: Dataclasses docs: Fix object.__setattr__ typo (#108355)
FrozenBob [Wed, 23 Aug 2023 07:11:15 +0000 (00:11 -0700)] 
gh-108267: Dataclasses docs: Fix object.__setattr__ typo (#108355)

Fixed a sentence in dataclasses.rst

Changed "__setattr__" to "object.__setattr__" in a section that was specifically supposed to refer to the __setattr__ method of the object class. Also suppressed the link to the data model docs for __setattr__, since we're talking about a specific __setattr__ implementation, not __setattr__ methods in general.

2 years agogh-108342: Break ref cycle in SSLSocket._create() exc (#108344)
Victor Stinner [Wed, 23 Aug 2023 05:26:01 +0000 (07:26 +0200)] 
gh-108342: Break ref cycle in SSLSocket._create() exc (#108344)

Explicitly break a reference cycle when SSLSocket._create() raises an
exception. Clear the variable storing the exception, since the
exception traceback contains the variables and so creates a reference
cycle.

This test leak was introduced by the test added for the fix of #108310.

2 years agogh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)
Victor Stinner [Wed, 23 Aug 2023 02:52:56 +0000 (04:52 +0200)] 
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)

Fix test_cppext when the C compiler command has the "-std=c11" option.
Remove "-std=" options from the compiler command.

2 years agogh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)
Victor Stinner [Tue, 22 Aug 2023 23:39:50 +0000 (01:39 +0200)] 
gh-90791: test.pythoninfo logs ASAN_OPTIONS env var (#108289)

* Cleanup libregrtest code logging ASAN_OPTIONS.
* Fix a typo on "ASAN_OPTIONS" vs "MSAN_OPTIONS".

2 years agoFix spurious diff if the cases generator is run on Windows (#108319)
Alex Waygood [Tue, 22 Aug 2023 19:49:39 +0000 (20:49 +0100)] 
Fix spurious diff if the cases generator is run on Windows (#108319)

2 years agogh-107136: Remove Plausible for docs metrics (#107856)
Hugo van Kemenade [Tue, 22 Aug 2023 18:45:22 +0000 (21:45 +0300)] 
gh-107136: Remove Plausible for docs metrics (#107856)

2 years agoGH-92584: Remove distutils from the newtypes tutorial includes (#108024)
Adam Turner [Tue, 22 Aug 2023 18:42:51 +0000 (19:42 +0100)] 
GH-92584: Remove distutils from the newtypes tutorial includes (#108024)

2 years agogh-105857: Document that asyncio subprocess std{in,out,err} can be file handles ...
Hadházy Tamás [Tue, 22 Aug 2023 18:41:56 +0000 (19:41 +0100)] 
gh-105857: Document that asyncio subprocess std{in,out,err} can be file handles (#107986)

stdin/out can be filehandles -> add to docs.

2 years agoDocument 3.13, 3.14 and future removals (#108055)
Hugo van Kemenade [Tue, 22 Aug 2023 18:40:46 +0000 (21:40 +0300)] 
Document 3.13, 3.14 and future removals (#108055)

2 years agoDocs: Add link to skip to datetime's format codes (#108027)
Hugo van Kemenade [Tue, 22 Aug 2023 18:38:38 +0000 (21:38 +0300)] 
Docs: Add link to skip to datetime's format codes (#108027)

2 years agogh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)
Victor Stinner [Tue, 22 Aug 2023 18:30:18 +0000 (20:30 +0200)] 
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)

* Move test_cppext to its own directory
* Rename setup_testcppext.py to setup.py
* Rename _testcppext.cpp to extension.cpp
* The source (extension.cpp) is now also copied by the test.

2 years agogh-89745: Remove commented code in getpath.c (#108307)
Victor Stinner [Tue, 22 Aug 2023 18:25:06 +0000 (20:25 +0200)] 
gh-89745: Remove commented code in getpath.c (#108307)

2 years agogh-106320: Remove _PyDict_GetItemStringWithError() function (#108313)
Victor Stinner [Tue, 22 Aug 2023 18:17:25 +0000 (20:17 +0200)] 
gh-106320: Remove _PyDict_GetItemStringWithError() function (#108313)

Remove private _PyDict_GetItemStringWithError() function of the
public C API: the new PyDict_GetItemStringRef() can be used instead.

* Move private _PyDict_GetItemStringWithError() to the internal C API.
* _testcapi get_code_extra_index() uses PyDict_GetItemStringRef().
  Avoid using private functions in _testcapi which tests the public C
  API.

2 years agogh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108315)
Łukasz Langa [Tue, 22 Aug 2023 17:53:15 +0000 (19:53 +0200)] 
gh-108310: Fix CVE-2023-40217: Check for & avoid the ssl pre-close flaw (#108315)

Instances of `ssl.SSLSocket` were vulnerable to a bypass of the TLS handshake
and included protections (like certificate verification) and treating sent
unencrypted data as if it were post-handshake TLS encrypted data.

The vulnerability is caused when a socket is connected, data is sent by the
malicious peer and stored in a buffer, and then the malicious peer closes the
socket within a small timing window before the other peers’ TLS handshake can
begin. After this sequence of events the closed socket will not immediately
attempt a TLS handshake due to not being connected but will also allow the
buffered data to be read as if a successful TLS handshake had occurred.

Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>
2 years agogh-108303: Remove unused Lib/test/sgml_input.html (#108305)
Victor Stinner [Tue, 22 Aug 2023 17:12:51 +0000 (19:12 +0200)] 
gh-108303: Remove unused Lib/test/sgml_input.html (#108305)

In Python 2.7, the file was used by Lib/test/test_sgmllib.py to test
Lib/sgmllib.py. The sgmllib module and its tests have been removed in
Python 3.0.

2 years agogh-108253: Fix bug in func version cache (#108296)
Guido van Rossum [Tue, 22 Aug 2023 15:29:49 +0000 (08:29 -0700)] 
gh-108253: Fix bug in func version cache (#108296)

When a function object changed its version, a stale pointer might remain in the cache.
Zap these whenever `func_version` changes (even when set to 0).

2 years agogh-106016: Add Lib/test/test_module/ directory (#108293)
Victor Stinner [Tue, 22 Aug 2023 14:53:49 +0000 (16:53 +0200)] 
gh-106016: Add Lib/test/test_module/ directory (#108293)

* Move Python scripts related to test_module to this new directory:
  good_getattr.py and bad_getattrX.py scripts.
* Move Lib/test/test_module.py to Lib/test/test_module/__init__.py.

2 years agogh-107700: [Enum] Document that `EnumType` was added in 3.11 (GH-108260)
Nikita Sobolev [Tue, 22 Aug 2023 14:34:18 +0000 (17:34 +0300)] 
gh-107700: [Enum] Document that `EnumType` was added in 3.11 (GH-108260)

2 years agoIgnore _Py_write_noraise() result: cast to (void) (#108291)
Victor Stinner [Tue, 22 Aug 2023 14:28:20 +0000 (16:28 +0200)] 
Ignore _Py_write_noraise() result: cast to (void) (#108291)

Code using _Py_write_noraise() usually cannot report. Ignore errors
is the least surprising behavior for users.

2 years agogh-90791: Enable test___all__ on ASAN build (#108286)
Victor Stinner [Tue, 22 Aug 2023 13:52:32 +0000 (15:52 +0200)] 
gh-90791: Enable test___all__ on ASAN build (#108286)

* Only skip modules and tests related to X11 on ASAN builds: run
  other tests with ASAN.
* Use print(flush=True) to see output earlier when it's redirected to
  a pipe.
* Update issue reference: replace bpo-46633 with gh-90791.

2 years agoDocs: align the param spec of sqlite3.Connection methods with the implementation...
Erlend E. Aasland [Tue, 22 Aug 2023 13:20:58 +0000 (15:20 +0200)] 
Docs: align the param spec of sqlite3.Connection methods with the implementation (#108285)

- no parameters of create_aggregate() are positional-only
- all parameters of create_collation() are positional-only

2 years agogh-107298: Fix numerous ref errors and typos in the C API docs (GH-108258)
Serhiy Storchaka [Tue, 22 Aug 2023 12:50:30 +0000 (15:50 +0300)] 
gh-107298: Fix numerous ref errors and typos in the C API docs (GH-108258)

2 years agogh-106971: Docs: Add missing issue reference (#106992)
Junya Fukuda [Tue, 22 Aug 2023 12:38:01 +0000 (21:38 +0900)] 
gh-106971: Docs: Add missing issue reference (#106992)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2 years agogh-105539: Emit ResourceWarning if sqlite3 database is not closed explicitly (#108015)
Erlend E. Aasland [Tue, 22 Aug 2023 11:10:29 +0000 (13:10 +0200)] 
gh-105539: Emit ResourceWarning if sqlite3 database is not closed explicitly (#108015)

2 years agogh-108179: Add error message for parser stack overflows (#108256)
Dennis Sweeney [Tue, 22 Aug 2023 07:41:50 +0000 (03:41 -0400)] 
gh-108179: Add error message for parser stack overflows (#108256)

2 years agogh-107801: Improve the accuracy of io.TextIOWrapper.seek docs (#107933)
Erlend E. Aasland [Tue, 22 Aug 2023 07:37:53 +0000 (09:37 +0200)] 
gh-107801: Improve the accuracy of io.TextIOWrapper.seek docs (#107933)

Clearly document the supported seek() operations:

- Rewind to the start of the stream
- Restore a previous stream position (given by tell())
- Fast-forward to the end of the stream

2 years agoFix test_faulthandler for sanitizers (#108245)
Victor Stinner [Tue, 22 Aug 2023 01:16:12 +0000 (03:16 +0200)] 
Fix test_faulthandler for sanitizers (#108245)

Set environment options to ask sanitizers to not handle SIGSEGV.

This change allows running test_enable_fd() and test_enable_file()
with sanitizers. Previously, they were skipped.

2 years agoDefine _Py_NULL as nullptr on C23 and newer (#108244)
Victor Stinner [Tue, 22 Aug 2023 00:37:32 +0000 (02:37 +0200)] 
Define _Py_NULL as nullptr on C23 and newer (#108244)

C23 standard added nullptr constant:
https://en.wikipedia.org/wiki/C23_(C_standard_revision)

2 years agogh-106242: Make ntpath.realpath errors consistent with abspath when there are embedde...
Steve Dower [Tue, 22 Aug 2023 00:16:02 +0000 (01:16 +0100)] 
gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls (GH-108248)

* gh-106242: Make ntpath.realpath errors consistent with abspath when there are embedded nulls

* Update 2023-08-22-00-36-57.gh-issue-106242.q24ITw.rst

mention Windows and the former incorrect ValueError.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2 years agoFix test_generators: save/restore warnings filters (#108246)
Victor Stinner [Mon, 21 Aug 2023 23:41:13 +0000 (01:41 +0200)] 
Fix test_generators: save/restore warnings filters (#108246)

Previously, depending on existing filters, the test
could modify the warnings and so fail as "env changed".

2 years agogh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop (#108242)
Irit Katriel [Mon, 21 Aug 2023 22:44:31 +0000 (23:44 +0100)] 
gh-107901: Fix missing line number on BACKWARD_JUMP at the end of a for loop (#108242)

2 years agogh-107265: Fix code_hash for ENTER_EXECUTOR case (#108188)
Dong-hee Na [Mon, 21 Aug 2023 21:22:18 +0000 (06:22 +0900)] 
gh-107265: Fix code_hash for ENTER_EXECUTOR case (#108188)