Commit Graph

113713 Commits

Author SHA1 Message Date
Victor Stinner 4caf5c2753
gh-91321: Fix compatibility with C++ older than C++11 (#93784)
Fix the compatibility of the Python C API with C++ older than C++11.

_Py_NULL is only defined as nullptr on C++11 and newer.
2022-06-14 11:43:08 +02:00
Petr Viktorin 3597c12941
gh-89546: Clean up PyType_FromMetaclass (GH-93686)
When changing PyType_FromMetaclass recently (GH-93012, GH-93466, GH-28748)
I found a bunch of opportunities to improve the code. Here they are.

Fixes: #89546

Automerge-Triggered-By: GH:encukou
2022-06-14 02:13:29 -07:00
Vinay Sajip 5bcf33de0b
gh-93761: Fix test to avoid simple delay when synchronizing. (GH-93779) 2022-06-14 06:41:16 +01:00
Serhiy Storchaka d7db9dc3cc
gh-91810: Fix regression with writing an XML declaration with encoding='unicode' (GH-93426)
Suppress writing an XML declaration in open files in ElementTree.write()
with encoding='unicode' and xml_declaration=None.

If file patch is passed to ElementTree.write() with encoding='unicode',
always open a new file in UTF-8.
2022-06-14 07:25:33 +03:00
Serhiy Storchaka 8352e322e8
gh-79512: Fixed names and __module__ value of weakref classes (GH-93719)
Classes ReferenceType, ProxyType and CallableProxyType have now correct
atrtributes __module__, __name__ and __qualname__.
It makes them (types, not instances) pickleable.
2022-06-14 07:18:03 +03:00
Serhiy Storchaka 6fd4c8ec77
gh-93741: Add private C API _PyImport_GetModuleAttrString() (GH-93742)
It combines PyImport_ImportModule() and PyObject_GetAttrString()
and saves 4-6 lines of code on every use.

Add also _PyImport_GetModuleAttr() which takes Python strings as arguments.
2022-06-14 07:15:26 +03:00
Victor Stinner 7b2064b4b9
gh-93353: Add test.support.late_deletion() (#93774) 2022-06-14 01:09:23 +02:00
Victor Stinner df22eec421
gh-89653: PEP 670: Macros always cast arguments in cpython/ (#93766)
Header files in the Include/cpython/ are only included if
the Py_LIMITED_API macro is not defined.
2022-06-13 20:09:40 +02:00
Christian Heimes c2007573dd
gh-84461: Fix parallel testing on WebAssembly (GH-93768) 2022-06-13 19:51:04 +02:00
Victor Stinner 443ca731d6
gh-93353: Fix importlib.resources._tempfile() finalizer (#93377)
Fix the importlib.resources.as_file() context manager to remove the
temporary file if destroyed late during Python finalization: keep a
local reference to the os.remove() function. Patch by Victor Stinner.
2022-06-13 19:24:00 +02:00
Victor Stinner 3ceb4b8d3a
gh-84623: Remove unused imports in tests (#93772) 2022-06-13 16:56:03 +02:00
Pablo Galindo Salgado 65ff27c7d3
gh-91731: Don't define 'static_assert' in C++11 where is a keyword to avoid UB (GH-93700) 2022-06-13 15:49:08 +01:00
Victor Stinner 259dd71c32
gh-84623: Remove unused imports in stdlib (#93773) 2022-06-13 16:28:41 +02:00
Victor Stinner 65ac273280
Remove ANY_VARARGS() macro from the C API (#93764)
The macro was exposed by mistake.
2022-06-13 16:24:19 +02:00
Victor Stinner 272bec4adf
gh-89653: PEP 670: Convert PyFunction macros (#93765)
Convert PyFunction macros to static inline functions.
2022-06-13 15:15:27 +02:00
Dennis Sweeney c5d0517ea4
Add more FOR_ITER specialization stats (GH-32151) 2022-06-13 01:40:54 -04:00
Kumar Aditya 9331087966
GH-90699: use statically allocated strings in typeobject.c (gh-93751) 2022-06-13 01:38:18 +09:00
Dong-hee Na ae1ca74513
gh-93747: Fix Refleak when handling multiple Py_tp_doc slots (gh-93749) 2022-06-13 00:55:01 +09:00
Kumar Aditya 8f728e5baa
gh-93728: fix memory leak in deepfrozen code objects (GH-93729) 2022-06-12 22:42:18 +08:00
Serhiy Storchaka 3473817106
gh-91162: Support splitting of unpacked arbitrary-length tuple over TypeVar and TypeVarTuple parameters (alt) (GH-93412)
For example:

  A[T, *Ts][*tuple[int, ...]] -> A[int, *tuple[int, ...]]
  A[*Ts, T][*tuple[int, ...]] -> A[*tuple[int, ...], int]
2022-06-12 16:22:01 +03:00
Dong-hee Na 23c9febdc6
Remove usage of _Py_IDENTIFIER from math module (#93739) 2022-06-12 18:45:02 +09:00
Davide Rizzo 733e15f170
gh-84508: tool to generate cjk traditional chinese mappings (gh-93272) 2022-06-11 23:19:41 +09:00
Pamela Fox 5d8e7a1240
Change list to view object (#93661) 2022-06-11 11:54:31 +01:00
Julien Palard bc3b31ea77
gh-86404: [doc] A make sucpicious false positive. (GH-93710) 2022-06-11 12:52:25 +02:00
John Belmonte 010284b46b
gh-90153: whatsnew: "z" option in format spec (GH-93624)
Add what's new entry for PEP 682 in Python 3.11.
2022-06-11 10:58:49 +01:00
Christian Heimes f0b7aa71c4
gh-90473: Skip test_queue when threading is not available (GH-93712) 2022-06-11 11:55:11 +02:00
Christian Heimes dc5e02b2f4
gh-84461: Use HOSTRUNNER to run regression tests (GH-93694)
Co-authored-by: Brett Cannon <brett@python.org>
2022-06-11 08:42:23 +02:00
Dennis Sweeney 4c496f1f11
gh-92930: _pickle.c: Acquire strong references before calling save() (GH-92931) 2022-06-10 21:50:11 -04:00
jackh-ncl 484a2357c8
gh-92886: Fix tests that fail when running with optimizations (`-O`) in `test_zipimport.py` (GH-93236) 2022-06-10 15:57:04 -07:00
Oleg Iarygin 78f1a43694
gh-91317: Document that Path does not collapse initial `//` (GH-32193)
Documentation for `pathlib` says:

> Spurious slashes and single dots are collapsed, but double dots ('..') are not, since this would change the meaning of a path in the face of symbolic links:

However, it omits that initial double slashes also aren't collapsed.

Later, in documentation of `PurePath.drive`, `PurePath.root`, and `PurePath.name` it mentions UNC but:

- this abbreviation says nothing to a person who is unaware about existence of UNC (Wikipedia doesn't help either by [giving a disambiguation page](https://en.wikipedia.org/wiki/UNC))
- it shows up only if a person needs to use a specific property or decides to fully learn what the module provides.

For context, see the BPO entry.
2022-06-10 15:52:36 -07:00
Christian Heimes 09243b898a
gh-93461: Invalidate sys.path_importer_cache entries with relative paths (GH-93653) 2022-06-10 23:56:26 +02:00
Irit Katriel cf730b595e
GH-93621: reorder code in with/async-with exception exit path to reduce the size of the exception table (GH-93622) 2022-06-10 17:53:34 +01:00
Barney Gale 2ba0fd5767
gh-81790: support "UNC" device paths in `ntpath.splitdrive()` (GH-91882) 2022-06-10 16:59:55 +01:00
Pablo Galindo Salgado 53a8b17895
gh-93671: Avoid exponential backtracking in deeply nested sequence patterns in match statements (GH-93680)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-10 17:56:45 +02:00
Petr Viktorin 21a9a85ff4
gh-93466: Document PyType_Spec doesn't accept repeated slot IDs; raise where this was problematic (GH-93471) 2022-06-10 15:55:09 +02:00
Christian Heimes 3124d9a5aa
gh-93491: Add support tier detection to configure (GH-93492)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Steve Dower <steve.dower@microsoft.com>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
2022-06-10 15:25:33 +02:00
Erlend Egeberg Aasland a87c9b538f
gh-90763: Modernise xx template module initialisation (#93078)
Use C APIs such as PyModule_AddType instead of PyModule_AddObject.
Also remove incorrect module decrefs if module fails to initialise.
2022-06-10 12:39:02 +02:00
neonene d8395eb38d
gh-92434: Silence compiler warning in Modules/_sqlite/connection.c on 32-bit systems (#93090) 2022-06-10 10:10:04 +02:00
Leo Trol 30610d2837
gh-90549: Fix leak of global named resources using multiprocessing spawn (#30617)
Co-authored-by: XD Trol <milestonejxd@gmail.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
2022-06-09 18:55:12 +02:00
Christian Heimes 6099611af5
gh-90473: Skip get_config_h() tests on WASI (GH-93645) 2022-06-09 18:08:03 +02:00
Christian Heimes 5a4af3ab03
gh-90473: disable user site packages on WASI/Emscripten (GH-93633) 2022-06-09 17:45:29 +02:00
Vinay Sajip e974b3e333
Improve logging documentation with example and additional cookbook re… (GH-93644) 2022-06-09 16:43:35 +01:00
Sebastian Berg 7fef847662
bpo-45383: Get metaclass from bases in PyType_From* (GH-28748)
This checks the bases of of a type created using the FromSpec
API to inherit the bases metaclasses.  The metaclass's alloc
function will be called as is done in `tp_new` for classes
created in Python.

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@protonmail.com>
2022-06-09 17:11:08 +02:00
CAM Gerlach a5ba0f4ebc
Doc: Update references and examples of old, unsupported OSes and uarches (GH-92791) 2022-06-09 15:55:06 +02:00
Serhiy Storchaka a365dd64c2
gh-90494: Reject 6th element of the __reduce__() tuple (GH-93609)
copy.copy() and copy.deepcopy() now always raise a TypeError if
__reduce__() returns a tuple with length 6 instead of silently ignore
the 6th item or produce incorrect result.
2022-06-09 10:12:43 +03:00
Christian Heimes cffa4f7854
gh-93616: Fix env changed issue in test_modulefinder (GH-93617) 2022-06-09 08:32:35 +02:00
Christian Heimes 68f6a5da19
gh-79096: Fix/improve http cookiejar tests (GH-93614)
Fixup of GH-93463:
- remove stray print
- use proper way to check file mode
- add working chmod decorator

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-06-08 23:51:04 +02:00
Christian Heimes 22df2e0322
gh-90473: Define HOSTRUNNER for WASI (GH-93606) 2022-06-08 20:18:46 +02:00
Christian Heimes 5442561c1a
gh-93575: Use correct way to calculate PyUnicode struct sizes (GH-93602)
* gh-93575: Use correct way to calculate PyUnicode struct sizes

* Add comment to keep test_sys and test_unicode in sync

* Fix case code < 256
2022-06-08 20:18:08 +02:00
Illia Volochii 2dece90808
gh-93180: Update os.copy_file_range() documentation (#93182) 2022-06-08 17:49:13 +02:00