Commit graph

51625 commits

Author SHA1 Message Date
Bénédikt Tran
fbbef609d1
[3.12] gh-127637: add tests for dis command-line interface (#127759) (#127780) 2025-01-18 12:01:56 +01:00
Miss Islington (bot)
405f6d72bb
[3.12] gh-128961: Fix exhausted array iterator crash in __setstate__() (GH-128962) (#128977)
(cherry picked from commit 4dade055f4)

Co-authored-by: Tomasz Pytel <tompytel@gmail.com>
2025-01-18 10:14:07 +00:00
Miss Islington (bot)
8a8f5d636d
[3.12] gh-128916: Do not set SO_REUSEPORT on non-AF_INET* sockets (GH-128933) (#128970)
gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets (GH-128933)

* gh-128916: Do not set `SO_REUSEPORT` on non-`AF_INET*` sockets

Do not attempt to set ``SO_REUSEPORT`` on sockets of address familifies other
than ``AF_INET`` and ``AF_INET6``, as it is meaningless with these address
families, and the call with fail with Linux kernel 6.12.9 and newer.

* Apply suggestions from code review



---------
(cherry picked from commit 3829104ab4)

Co-authored-by: Michał Górny <mgorny@gentoo.org>
Co-authored-by: Vinay Sajip <vinay_sajip@yahoo.co.uk>
2025-01-18 01:06:45 +00:00
Tian Gao
f45da82c11
[3.12] gh-58956: Fix a frame refleak in bdb (GH-128190) (#128953)
* [3.12] gh-58956: Fix a frame refleak in bdb (GH-128190)
(cherry picked from commit 767c89ba7c)

Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
2025-01-17 14:19:37 -05:00
Miss Islington (bot)
45b89bf0da
[3.12] gh-128816: Fix warnings in test_doctest (GH-128817) (GH-128871)
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
(cherry picked from commit 599be687ec)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2025-01-16 09:09:13 +00:00
Bénédikt Tran
6c9b7e591b
[3.12] gh-128833: Patch test_embed.test_specialized_static_code_gets_unspecialized_at_Py_FINALIZE on Windows (#128860)
Hotfix for `test_embed`
2025-01-15 14:22:45 +01:00
Miss Islington (bot)
febe67b993
[3.12] gh-109959: Skip test_glob.test_selflink() flaky test (GH-128812) (#128834)
gh-109959: Skip test_glob.test_selflink() flaky test (GH-128812)
(cherry picked from commit 1153e66e20)

Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-14 15:32:11 +00:00
Miss Islington (bot)
e7400d7877
[3.12] gh-125997: Increase test coverage for time.sleep() (GH-128751) (#128795)
gh-125997: Increase test coverage for `time.sleep()` (GH-128751)

- Add tests for durations of invalid types.
- Add tests for `int` and `float` durations, including signed zeroes durations.
- Add tests for nonzero very small durations and durations close to the clock resolution.

---------
(cherry picked from commit b70a567575)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-13 17:16:25 +00:00
Miss Islington (bot)
552b2a0f6e
[3.12] Explicitly import urllib.error in urllib.robotparser (GH-128737) (#128794)
Explicitly import `urllib.error` in `urllib.robotparser` (GH-128737)
(cherry picked from commit 53e8942e69)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-13 16:32:38 +00:00
Miss Islington (bot)
ca5ff6b40c
[3.12] gh-128562: Fix generation of the tkinter widget names (GH-128604) (GH-128792)
There were possible conflicts if the widget class name ends with a digit.
(cherry picked from commit da8825ea95)

Co-authored-by: Zhikang Yan <2951256653@qq.com>
2025-01-13 18:23:53 +02:00
Miss Islington (bot)
4facd7d119
[3.12] gh-128078: Clear exception in anext before calling _PyGen_SetStopIterationValue (GH-128780) (#128784)
gh-128078: Clear exception in `anext` before calling `_PyGen_SetStopIterationValue` (GH-128780)
(cherry picked from commit 76ffaef729)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
2025-01-13 18:45:20 +05:30
Miss Islington (bot)
b773f591a8
[3.12] gh-128731: Explicitly close socket on error in robotparser.RobotFileParser.read() (GH-128733) (GH-128756)
(cherry picked from commit 5e65a1acc0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-01-12 13:34:24 +00:00
Serhiy Storchaka
c20c551ce3
[3.12] gh-128734: Explicitly close sockets in urllib tests (GH-128735) (GH-128750)
(cherry picked from commit 5ace71713b)
2025-01-12 11:30:07 +00:00
Miss Islington (bot)
07a65cdcc5
[3.12] gh-128302: Fix bugs in xml.dom.xmlbuilder (GH-128284) (#128583)
gh-128302: Fix bugs in xml.dom.xmlbuilder (GH-128284)

* Allow DOMParser.parse() to correctly handle DOMInputSource instances
  that only have a systemId attribute set.
* Fix DOMEntityResolver.resolveEntity(), which was broken by the
  Python 3.0 transition.
* Add Lib/test/test_xml_dom_xmlbuilder.py with few tests.
(cherry picked from commit 6ea04da270)

Co-authored-by: Stephen Morton <git@tungol.org>
2025-01-11 13:30:29 +02:00
Miss Islington (bot)
4c130c9238
[3.12] gh-128615: Cover pickling of ParamSpecArgs and ParamSpecKwargs (GH-128616) (#128626)
Co-authored-by: sobolevn <mail@sobolevn.me>
2025-01-08 12:25:59 +00:00
Miss Islington (bot)
b69b9da9b5
[3.12] gh-41872: Fix quick extraction of module docstrings from a file in pydoc (GH-127520) (GH-128621)
It now supports docstrings with single quotes, escape sequences,
raw string literals, and other Python syntax.

(cherry picked from commit 474e419792)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2025-01-08 14:21:30 +02:00
Miss Islington (bot)
d8890fb82d
[3.12] gh-128613: Increase typing.Concatenate coverage (GH-128614) (#128624)
gh-128613: Increase `typing.Concatenate` coverage (GH-128614)
(cherry picked from commit eb26e17069)

Co-authored-by: sobolevn <mail@sobolevn.me>
2025-01-08 12:20:00 +00:00
Erlend E. Aasland
b46addafb1
[3.12] gh-123085: Remove double 'import os' added by PR #124021 (#128600)
gh-123085: Remove double 'import os' added by PR #124021
2025-01-07 19:23:17 -05:00
Miss Islington (bot)
dae5b16bb3
[3.12] gh-98188: Fix EmailMessage.get_payload to decode data when CTE value has extra text (GH-127547) (#128529)
gh-98188: Fix EmailMessage.get_payload to decode data when CTE value has extra text (GH-127547)

Up to this point message handling has been very strict with regards to content encoding values: mixed case was accepted, but trailing blanks or other text would cause decoding failure, even if the first token was a valid encoding.  By Postel's Rule we should go ahead and decode as long as we can recognize that first token.  We have not thought of any security or backward compatibility concerns with this fix.

This fix does introduce a new technique/pattern to the Message code: we look to see if the header has a 'cte' attribute, and if so we use that.  This effectively promotes the header API exposed by HeaderRegistry to an API that any header parser "should" support.  This seems like a reasonable thing to do.  It is not, however, a requirement, as the string value of the header is still used if there is no cte attribute.

The full fix (ignore any trailing blanks or blank-separated trailing text) applies only to the non-compat32 API.  compat32 is only fixed to the extent that it now ignores trailing spaces.  Note that the HeaderRegistry parsing still records a HeaderDefect if there is extra text.

(cherry picked from commit a62ba52f14)

Co-authored-by: RanKKI <hliu86.me@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2025-01-07 12:44:56 -05:00
Miss Islington (bot)
e758eb3018
[3.12] gh-123085: _compile_importlib: Avoid copying sources before compilation (GH-124131) (GH-128581)
gh-123085: _compile_importlib: Avoid copying sources before compilation (GH-124131)
(cherry picked from commit 42c8b0556c)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2025-01-07 12:28:03 +01:00
Miss Islington (bot)
f9aac4a76d
[3.12] gh-128519: Align the docstring of untokenize() to match the docs (GH-128521) (#128532)
(cherry picked from commit aef52ca8b3)

Co-authored-by: Tomas R <tomas.roun8@gmail.com>
2025-01-06 08:59:24 +00:00
Jason R. Coombs
d712ece43f
[3.12] gh-123085: Fix issue in inferred caller when resources package has no source (GH-123102) (#124021)
gh-123085: Fix issue in inferred caller when resources package has no source.

From importlib_resources 6.4.3 (python/importlib_resourcesGH-314).
(cherry picked from commit a53812df12)
2025-01-05 16:53:55 -05:00
Miss Islington (bot)
06e4173393
[3.12] gh-127553: Remove outdated TODO comment in _pydatetime (GH-127564) (#128501)
(cherry picked from commit e8b6b39ff7)

Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
2025-01-04 22:55:24 +00:00
Miss Islington (bot)
e44045924d
[3.12] gh-127903: Fix a crash on debug builds when calling Objects/unicodeobject::_copy_characters (GH-127876) (#128459)
gh-127903: Fix a crash on debug builds when calling `Objects/unicodeobject::_copy_characters`` (GH-127876)
(cherry picked from commit 46cb6340d7)

Co-authored-by: Alexander Shadchin <shadchin@yandex-team.com>
2025-01-03 21:21:08 +02:00
Serhiy Storchaka
7ce09fc93b
[3.12] gh-128014: Fix passing default='' to the tkinter method wm_iconbitmap() (GH-128015) (GH-128420)
(cherry picked from commit 58e9f95c4a)

Co-authored-by: Zhikang Yan <2951256653@qq.com>
2025-01-02 16:21:00 +00:00
Miss Islington (bot)
ca017a171a
[3.12] gh-88834: Unify the instance check for typing.Union and types.UnionType (GH-128363) (GH-128371)
Union now uses the instance checks against its parameters instead of
the subclass checks.
(cherry picked from commit b2ac70a62a)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2024-12-31 08:19:45 +00:00
Miss Islington (bot)
fcc9bc49c4
[3.12] gh-128342: Specify timeout unit in subprocess docstrings (GH-128343) (#128366)
gh-128342: Specify timeout unit in subprocess docstrings (GH-128343)

Specify timeout unit (seconds) in subprocess docstrings
(cherry picked from commit dafe7a4463)

Co-authored-by: n-l-i <57808975+n-l-i@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2024-12-30 13:14:27 -08:00
Miss Islington (bot)
be7314ffac
[3.12] gh-127586: multiprocessing.Pool does not properly restore blocked signals (try 2) (GH-128011) (#128299)
gh-127586: multiprocessing.Pool does not properly restore blocked signals (try 2) (GH-128011)

Correct pthread_sigmask in resource_tracker to restore old signals

Using SIG_UNBLOCK to remove blocked "ignored signals" may accidentally
cause side effects if the calling parent already had said signals
blocked to begin with and did not intend to unblock them when
creating a pool. Use SIG_SETMASK instead with the previous mask of
blocked signals to restore the original blocked set.
(cherry picked from commit aeb9b65aa2)

Co-authored-by: Stephen Hansen <stephen.paul.hansen@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2024-12-29 11:02:59 -08:00
Miss Islington (bot)
3a726be127
[3.12] Mention loop_factory argument in docstring for asyncio.run() (GH-128288) (#128292)
Mention loop_factory argument in docstring for asyncio.run() (GH-128288)
(cherry picked from commit 0b5f1fae57)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2024-12-27 14:15:40 +00:00
Shantanu
82dbfbfec9
[3.12] gh-127537: Add __class_getitem__ to the python implementation of functools.partial (#127537) (#128282)
gh-127537: Add __class_getitem__ to the python implementation of functools.partial (#127537)

(cherry picked from commit 401bba6b58)

Co-authored-by: CF Bolz-Tereick <cfbolz@gmx.de>
2024-12-27 01:25:07 +00:00
Miss Islington (bot)
fe41537c60
[3.12] gh-127847: Fix position in the special-cased zipfile seek (GH-127856) (#128226)
gh-127847: Fix position in the special-cased zipfile seek (GH-127856)

---------
(cherry picked from commit 7ed6c5c696)

Co-authored-by: Dima Ryazanov <dima@bucket.xxx>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2024-12-24 16:15:45 +00:00
Miss Islington (bot)
f65ac86ca1
[3.12] gh-128049: Fix type confusion bug with the return value of a custom ExceptionGroup split function (GH-128079) (#128140)
gh-128049: Fix type confusion bug with the return value of a custom ExceptionGroup split function (GH-128079)
(cherry picked from commit 3879ca0100)

Co-authored-by: Nico-Posada <102486290+Nico-Posada@users.noreply.github.com>
2024-12-20 20:19:12 +00:00
Miss Islington (bot)
23e8fc2775
[3.12] gh-128116: Skip test_socket VSOCK testStream() on PermissionError (GH-128120) (#128124)
gh-128116: Skip test_socket VSOCK testStream() on PermissionError (GH-128120)
(cherry picked from commit cbfe3023e4)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-20 13:39:26 +00:00
Miss Islington (bot)
6ffa564446
[3.12] gh-126742: Avoid checking for library filename in test_ctypes (GH-128034) (#128057)
gh-126742: Avoid checking for library filename in test_ctypes (GH-128034)

Avoid checking for library filename in `dlerror()` error messages of test_ctypes.
(cherry picked from commit 335e24fb0a)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-18 08:45:34 +00:00
Bénédikt Tran
e0b61ffa38
[3.12] gh-126742: Add _PyErr_SetLocaleString, use it for gdbm & dlerror messages (GH-126746) (GH-128027)
- Add a helper to set an error from locale-encoded `char*`
- Use the helper for gdbm & dlerror messages

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-17 14:53:16 +02:00
Bénédikt Tran
6ac578cf53
[3.12] gh-126554: ctypes: Correctly handle NULL dlsym values (GH-126555) (GH-127764)
For dlsym(), a return value of NULL does not necessarily indicate
an error [1].

Therefore, to avoid using stale (or NULL) dlerror() values, we must:

 1. clear the previous error state by calling dlerror()
 2. call dlsym()
 3. call dlerror()

If the return value of dlerror() is not NULL, an error occured.

In ctypes we choose to treat a NULL return value from dlsym()
as a "not found" error. This is the same as the fallback
message we use on Windows, Cygwin or when getting/formatting
the error reason fails.

[1]: https://man7.org/linux/man-pages/man3/dlsym.3.html

Signed-off-by: Georgios Alexopoulos <grgalex42@gmail.com>
Signed-off-by: Georgios Alexopoulos <grgalex@ba.uoa.gr>
Co-authored-by: George Alexopoulos <giorgosalexo0@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-12-17 13:53:43 +02:00
Victor Stinner
b1cc62ae0f
[3.12] gh-127906: Skip limited C API test_cext tests if Py_TRACE_REFS (#127993)
gh-127906: Skip limited C API test_cext tests if Py_TRACE_REFS

Skip limited C API tests in test_cext and test_cppext if Python is
configured with --with-trace-refs (if the Py_TRACE_REFS macro is
defined).
2024-12-16 18:15:17 +01:00
Petr Viktorin
d0368556b5
[3.12] gh-126937: ctypes: add test for maximum size of a struct field (GH-126938) (GH-127825) (GH-127909)
This backports the *test* from GH-126938, with changed limit and exception class.

Co-authored-by: Melissa0x1f992 <70096546+Melissa0x1f992@users.noreply.github.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>

(cherry-picked from d51c1444e3)
2024-12-13 16:51:55 +01:00
Miss Islington (bot)
58916eb211
[3.12] gh-127906: Test the limited C API in test_cppext (GH-127916) (#127920)
gh-127906: Test the limited C API in test_cppext (GH-127916)
(cherry picked from commit d05a4e6a0d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-13 14:14:20 +00:00
Victor Stinner
5a658d85d5
[3.12] gh-127906: Backport test_cext from the main branch (#127912) 2024-12-13 14:48:32 +01:00
Victor Stinner
21c056ec27
[3.12] gh-127870: Detect recursive calls in ctypes _as_parameter_ handling (#127872) (#127918)
gh-127870: Detect recursive calls in ctypes _as_parameter_ handling (#127872)

(cherry picked from commit 6ff38fc4e2)
2024-12-13 13:21:30 +00:00
Victor Stinner
6544f99463
[3.12] gh-127906: Backport test_cppext changes from the main branch (#127915) 2024-12-13 13:51:06 +01:00
Miss Islington (bot)
2916f838e6
[3.12] Fix typos in Lib/_pydecimal.py (GH-127700) (#127888)
Fix typos in `Lib/_pydecimal.py` (GH-127700)
(cherry picked from commit ed037d229f)

Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
2024-12-12 20:45:20 +00:00
Miss Islington (bot)
b0615a8a9a
[3.12] gh-123401: Fix http.cookies module to support obsolete RFC 850 date format (GH-123405) (#127829)
gh-123401: Fix http.cookies module to support obsolete RFC 850 date format (GH-123405)
(cherry picked from commit 359389ed51)

Co-authored-by: Nano <nanoapezlk@gmail.com>
Co-authored-by: Wulian <1055917385@qq.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2024-12-11 15:34:22 +00:00
Miss Islington (bot)
0964f9f184
[3.12] GH-117195: Avoid assertion error in object.__sizeof__ (GH-117220) (#127605)
GH-117195: Avoid assertion error in `object.__sizeof__` (GH-117220)
(cherry picked from commit 406ffb5293)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2024-12-11 12:21:07 +01:00
Nice Zombies
487a51a1b9
[3.12] gh-111609: end_offset is ignored in subclasses of SyntaxError (#127554)
* `end_offset` is ignored in subclasses of SyntaxError

* 📜🤖 Added by blurb_it.

* Add test

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2024-12-11 09:09:34 +00:00
Miss Islington (bot)
8b4e7f8ec0
[3.12] gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (GH-127590) (#127649)
gh-127552: Remove comment questioning 4-digit restriction for ‘Y’ in datetime.strptime patterns (GH-127590)

The code has required 4 digits for the year since its inclusion in the stdlib in 2002 (over 22 years ago as of this commit).
(cherry picked from commit 51cfa569e3)

Co-authored-by: Beomsoo Kim <beoms424@gmail.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
2024-12-10 09:20:54 +01:00
Miss Islington (bot)
e881dd1c46
[3.12] gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (GH-126776) (#127779)
gh-126775: make linecache.checkcache threadsafe and GC re-entrency safe (GH-126776)

(cherry picked from commit 2233c303e4)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Bartosz Sławecki <bartoszpiotrslawecki@gmail.com>
2024-12-10 08:02:22 +00:00
Miss Islington (bot)
fa935225a4
gh-127732: Add Windows Server 2025 detection to platform module (GH-127733)
(cherry picked from commit 5eb7fd4d0f)

Co-authored-by: Wulian <1055917385@qq.com>
2024-12-09 12:42:37 +00:00
Miss Islington (bot)
5f5624ddc8
[3.12] gh-127734: improve signature of urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ (GH-127735) (#127745)
gh-127734: improve signature of `urllib.request.HTTPPasswordMgrWithPriorAuth.__init__` (GH-127735)

improve signature of urllib.request.HTTPPasswordMgrWithPriorAuth.__init__
(cherry picked from commit a03efb533a)

Co-authored-by: Stephen Morton <git@tungol.org>
2024-12-08 12:16:03 -08:00