Commit graph

26974 commits

Author SHA1 Message Date
Miss Islington (bot)
03dc951316
gh-95280: Fix test_get_ciphers on systems without RSA key exchange (GH-95282) (GH-95323)
(cherry picked from commit 565403038b)

Co-authored-by: Christian Heimes <christian@python.org>
2022-07-29 17:20:06 +02:00
Łukasz Langa
017080f0fa
[3.9] gh-94208: Add more TLS version/protocol checks for FreeBSD (GH-94347) (GH-95312)
Three test cases were failing on FreeBSD with latest OpenSSL.
(cherry picked from commit 1bc86c2625)

Co-authored-by: Christian Heimes <christian@python.org>
2022-07-27 23:43:02 +02:00
Miss Islington (bot)
cd0a59f1fa
gh-94821: Fix autobind of empty unix domain address (GH-94826) (GH-94875)
When binding a unix socket to an empty address on Linux, the socket is
automatically bound to an available address in the abstract namespace.

    >>> s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
    >>> s.bind("")
    >>> s.getsockname()
    b'\x0075499'

Since python 3.9, the socket is bound to the one address:

    >>> s.getsockname()
    b'\x00'

And trying to bind multiple sockets will fail with:

    Traceback (most recent call last):
      File "/home/nsoffer/src/cpython/Lib/test/test_socket.py", line 5553, in testAutobind
        s2.bind("")
    OSError: [Errno 98] Address already in use

Added 2 tests:
- Auto binding empty address on Linux
- Failing to bind an empty address on other platforms

Fixes f6b3a07b7d (bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
(cherry picked from commit c22f134211)

Co-authored-by: Nir Soffer <nsoffer@redhat.com>
2022-07-26 12:07:41 +02:00
Miss Islington (bot)
defaa2b19a
gh-87389: Fix an open redirection vulnerability in http.server. (GH-93879) (GH-94093)
Fix an open redirection vulnerability in the `http.server` module when
an URI path starts with `//` that could produce a 301 Location header
with a misleading target.  Vulnerability discovered, and logic fix
proposed, by Hamza Avvan (@hamzaavvan).

Test and comments authored by Gregory P. Smith [Google].
(cherry picked from commit 4abab6b603)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-06-22 10:42:02 +02:00
Miss Islington (bot)
893adbf001
gh-91810: Fix regression with writing an XML declaration with encoding='unicode' (GH-93426) (GH-93791)
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.
(cherry picked from commit d7db9dc3cc)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-06-16 12:16:30 +02:00
Miss Islington (bot)
95c9c2b9cb
gh-93065: Fix HAMT to iterate correctly over 7-level deep trees (GH-93066) (#93147)
Also while there, clarify a few things about why we reduce the hash to 32 bits.

Co-authored-by: Eli Libman <eli@hyro.ai>
Co-authored-by: Yury Selivanov <yury@edgedb.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>

(cherry picked from commit c1f5c903a7)
2022-05-24 10:52:49 +02:00
Jelle Zijlstra
f82b32410b
[3.9] gh-92112: Fix crash triggered by an evil custom mro() (GH-92113) (GH-92372)
(cherry picked from commit 85354ed78c)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
2022-05-16 18:47:35 +02:00
Marek Suscak
518b238967
[3.9] bpo-34480: fix bug where match variable is used prior to being defined (GH-17643) (GH-32256)
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2022-05-16 18:19:04 +02:00
Miss Islington (bot)
1699a5ee13
Check result of utc_to_seconds and skip fold probe in pure Python (GH-91582) (GH-92748)
The `utc_to_seconds` call can fail, here's a minimal reproducer on
Linux:

TZ=UTC python -c "from datetime import *; datetime.fromtimestamp(253402300799 + 1)"

The old behavior still raised an error in a similar way, but only
because subsequent calculations happened to fail as well. Better to fail
fast.

This also refactors the tests to split out the `fromtimestamp` and
`utcfromtimestamp` tests, and to get us closer to the actual desired
limits of the functions. As part of this, we also changed the way we
detect platforms where the same limits don't necessarily apply (e.g.
Windows).

As part of refactoring the tests to hit this condition explicitly (even
though the user-facing behvior doesn't change in any way we plan to
guarantee), I noticed that there was a difference in the places that
`datetime.utcfromtimestamp` fails in the C and pure Python versions, which
was fixed by skipping the "probe for fold" logic for UTC specifically —
since UTC doesn't have any folds or gaps, we were never going to find a
fold value anyway. This should prevent some failures in the pure python
`utcfromtimestamp` method on timestamps close to 0001-01-01.

There are two separate news entries for this because one is a
potentially user-facing change, the other is an internal code
correctness change that, if anything, changes some error messages. The
two happen to be coupled because of the test refactoring, but they are
probably best thought of as independent changes.

Fixes GH-91581
(cherry picked from commit 83c0247d47)

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2022-05-16 17:33:01 +02:00
Dennis Sweeney
801f77119d
[3.9] gh-92311: Let frame_setlineno jump over listcomps (#92740) 2022-05-12 17:41:34 -04:00
Miss Islington (bot)
bfc88d3418
[3.9] gh-91810: ElementTree: Use text file's encoding by default in XML declaration (GH-91903) (GH-92665)
ElementTree method write() and function tostring() now use the text file's
encoding ("UTF-8" if not available) instead of locale encoding in XML
declaration when encoding="unicode" is specified.
(cherry picked from commit 707839b0fe)


Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

Automerge-Triggered-By: GH:serhiy-storchaka
2022-05-11 10:40:05 -07:00
Itai Steinherz
1fb25a96ae
bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858)
* [3.9] bpo-46785: Fix race condition between os.stat() and unlink on Windows (GH-31858).
(cherry picked from commit 39e6b8ae6a)

Co-authored-by: Itai Steinherz <itaisteinherz@gmail.com>
2022-05-09 23:42:59 +01:00
Miss Islington (bot)
8e523c1151
[3.10] gh-90622: Do not spawn ProcessPool workers on demand via fork method. (GH-91598) (GH-92497) (#92499)
Do not spawn ProcessPool workers on demand when they spawn via fork.

This avoids potential deadlocks in the child processes due to forking from
a multithreaded process..
(cherry picked from commit ebb37fc3fd)

Co-authored-by: Gregory P. Smith <greg@krypto.org>
(cherry picked from commit b795376a62)

Co-authored-by: Gregory P. Smith <greg@krypto.org>

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2022-05-08 11:22:36 -07:00
Miss Islington (bot)
4ede781045
bpo-29890: Test IPv*Interface construction with tuple argument (GH-30862)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit b295a92c50)

Co-authored-by: Humbled Drugman <humbled.drugman@gmail.com>
2022-05-03 11:18:42 -07:00
Miss Islington (bot)
020f5c47d8
bpo-46415: Use f-string for ValueError in ipaddress.ip_{address,network,interface} helper functions (GH-30642)
`IPv*Network` and `IPv*Interface` constructors accept a 2-tuple of
(address description, netmask) as the address parameter.
When the tuple-based address is used errors are not propagated
correctly through the `ipaddress.ip_*` helper because of the %-formatting now expecting several arguments:

	In [7]: ipaddress.ip_network(("192.168.100.0", "fooo"))
        ...
	TypeError: not all arguments converted during string formatting

Compared to:

	In [8]: ipaddress.IPv4Network(("192.168.100.0", "foo"))
        ...
	NetmaskValueError: 'foo' is not a valid netmask

Use an f-string to make sure the error is always properly formatted.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 52dc9c3066)

Co-authored-by: Thomas Cellerier <thomascellerier@gmail.com>
2022-05-03 05:34:50 -07:00
Miss Islington (bot)
7e55730e3f
gh-92106: Add test that subscription works on arbitrary TypedDicts (GH-92176)
(cherry picked from commit 81fb3548be)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-02 18:05:49 -07:00
Miss Islington (bot)
206f416bd0
bpo-36819: Fix crashes in built-in encoders with weird error handlers (GH-28593)
If the error handler returns position less or equal than the starting
position of non-encodable characters, most of built-in encoders didn't
properly re-size the output buffer. This led to out-of-bounds writes,
and segfaults.
(cherry picked from commit 18b07d773e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-02 02:59:40 -07:00
Miss Islington (bot)
3d0a5f73f5
bpo-43323: Fix UnicodeEncodeError in the email module (GH-32137)
It was raised if the charset itself contains characters not encodable
in UTF-8 (in particular \udcxx characters representing non-decodable
bytes in the source).
(cherry picked from commit e91dee87ed)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-30 05:31:37 -07:00
Miss Islington (bot)
fa87c362e1
gh-91832: Add 'required' attr to argparse.Action repr (GH-91841)
GH- Adding 'required' to names in Lib.argparse.Action

gh-91832:
Added 'required' to the list `names` in `Lib.argparse.Action`.
Changed constant strings that test the Action object.

Automerge-Triggered-By: GH:merwok
(cherry picked from commit 4ed3900041)

Co-authored-by: Abhigyan Bose <abhigyandeepbose@gmail.com>
2022-04-28 08:19:07 -07:00
Serhiy Storchaka
993bb1632b
[3.9] gh-91810: Expand ElementTree.write() tests to use non-ASCII data (GH-91989). (GH-91994)
(cherry picked from commit f60b4c3d74)
2022-04-27 20:14:05 +03:00
Miss Islington (bot)
f4252dfb8e
gh-91914: Fix test_curses on non-UTF-8 locale (GH-91919)
(cherry picked from commit f41c16bf51)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-25 22:51:27 -07:00
Miss Islington (bot)
653a66668d
gh-91916: Fix test_runpy on non-UTF-8 locale (GH-91920)
If use a non-builtin codec, partially implemented in Python
(e.g. ISO-8859-15), a new RecursionError (with empty error message)
can be raised while handle a RecursionError.

Testing for error message was needed to distinguish
a recursion error from arbitrary RuntimeError. After introducing
RecursionError, it became unnecessary.
(cherry picked from commit a568585069)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-25 22:45:24 -07:00
Miss Islington (bot)
4165702ee8
RE: Add more tests for inline flag "x" and re.VERBOSE (GH-91854)
(cherry picked from commit 6b45076bd6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-23 03:16:50 -07:00
Miss Islington (bot)
537dabc869
[3.9] gh-91575: Update case-insensitive matching in re to the latest Unicode version (GH-91580). (GH-91661) (GH-91837)
(cherry picked from commit 1c2fcebf3c)
(cherry picked from commit 1748816e80)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-22 22:02:56 +03:00
Miss Islington (bot)
76ff68666f
[3.9] gh-91700: Validate the group number in conditional expression in RE (GH-91702) (GH-91831) (GH-91836)
In expression (?(group)...) an appropriate re.error is now
raised if the group number refers to not defined group.

Previously it raised RuntimeError: invalid SRE code.
(cherry picked from commit 48ec61a89a)
(cherry picked from commit 080781cd49)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-22 22:02:20 +03:00
Miss Islington (bot)
97d14e1dfb
[3.9] gh-90568: Fix exception type for \N with a named sequence in RE (GH-91665) (GH-91830) (GH-91834)
re.error is now raised instead of TypeError.
(cherry picked from commit 6ccfa31421)
(cherry picked from commit 9c18d783c3)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-22 21:34:31 +03:00
Miss Islington (bot)
63af7b3b11
Add more tests for group names and refs in RE (GH-91695)
(cherry picked from commit 74070085da)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-04-19 07:35:21 -07:00
Gregory P. Smith
2a43afdba9
[3.9] [3.10] gh-91607: Fix several test_concurrent_futures tests to actually test what they claim (GH-91600) (GH-91612) (#91617)
* Fix test_concurrent_futures to actually test what it says.

Many ProcessPoolExecutor based tests were ignoring the mp_context
and using the default instead.  This meant we lacked proper test
coverage of all of them.

Also removes the old _prime_executor() worker delay seeding code
as it appears to have no point and causes 20-30 seconds extra
latency on this already long test.  It also interfered with some
of the refactoring to fix the above to not needlessly create their
own executor when setUp has already created an appropriate one.

* Don't import the name from multiprocessing directly to avoid confusion.

(cherry picked from commit 7fa3a5a219)
(cherry picked from commit 9a458934f7)
2022-04-16 22:47:41 -07:00
Miss Islington (bot)
0ab5e83ff7
gh-87497: Document that urllib.request sends headers in camel case (GH-24661)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 325d6f5035)

Co-authored-by: Alix Lourme <alix.lourme@gmail.com>
2022-04-13 19:45:56 -07:00
Steve Dower
80c115385c
bpo-47103: Copy pgort140.dll into output directory when building PGInstrument on Windows (GH-32083) 2022-04-08 01:02:58 +01:00
Ken Jin
1ab53511e9
Fix whitespace/indentation issues in test_sys (GH-32369) (GH-32373)
(cherry picked from commit da922409ac)
2022-04-07 01:11:07 +08:00
Miss Islington (bot)
5b4bc61d89
bpo-46484:Add test for Calendar.iterweekdays (GH-30825)
(cherry picked from commit 48269ea9fd)

Co-authored-by: 180909 <734461790@qq.com>
2022-04-04 10:41:50 -07:00
Miss Islington (bot)
490ccbd6e0
bpo-47205: Skip error check of sched_get/setaffinity on FreeBSD (GH-32285)
(cherry picked from commit b82cdd1dac)

Co-authored-by: Christian Heimes <christian@python.org>
2022-04-03 08:30:39 -07:00
Jeremy Kloth
306a93b481
[3.9] bpo-47089: Avoid test_compileall failures on Windows (GH-32037). (GH-32240)
* [3.9] bpo-47089: Avoid test_compileall failures on Windows (GH-32037).
(cherry picked from commit 76b8a075b8)

Co-authored-by: Jeremy Kloth <jeremy.kloth@gmail.com>
2022-04-02 03:40:27 +02:00
Miss Islington (bot)
ec3589f59d
bpo-47101: list only activated algorithms in hashlib.algorithms_available (GH-32076)
(cherry picked from commit 48e2010d92)

Co-authored-by: Christian Heimes <christian@python.org>
2022-03-23 13:58:02 -07:00
Miss Islington (bot)
3c6019035f
bpo-2604: Make doctest.DocTestCase reset globs in teardown (GH-31932)
Co-authored-by: Piet Delport
Co-authored-by: Hugo Lopes Tavares
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
(cherry picked from commit 7ba7eae508)

Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
2022-03-22 14:27:26 -07:00
Jeremy Kloth
8db7610d1a
bpo-44336: Prevent tests hanging on child process handles on Windows (GH-26578)
Replace the child process `typeperf.exe` with a daemon thread that reads the performance counters directly.  This prevents the issues that arise from inherited handles in grandchild processes (see issue37531 for discussion).

We only use the load tracker when running tests in multiprocess mode. This prevents inadvertent interactions with tests expecting a single threaded environment.  Displaying load is really only helpful for buildbots running in multiprocess mode anyway..

Co-authored-by: Jeremy Kloth <jeremy.kloth@gmail.com>
2022-03-22 17:21:35 +00:00
Andrew Svetlov
f47984b560
[3.9] bpo-45997: Fix asyncio.Semaphore re-acquiring order (GH-31910) (GH-32049)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>.
(cherry picked from commit 32e77154dd)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-22 17:16:27 +02:00
Gregory P. Smith
58a7e13037
bpo-38256: Fix binascii.crc32 large input. (GH-32000) (GH-32013) (GH-32015)
Inputs >= 4GiB to `binascii.crc32(...)` when compiled to use the zlib
crc32 implementation (the norm on POSIX) no longer return the wrong
result.

(cherry picked from commit 4c989e19c8)
2022-03-20 23:34:45 -07:00
Miss Islington (bot)
e207d721fc
[3.9] bpo-40296: Fix supporting generic aliases in pydoc (GH-30253). (GH-31976) (GH-31981)
(cherry picked from commit cd44afc573)
(cherry picked from commit a5b7678a67)
2022-03-19 17:12:48 +02:00
Miss Islington (bot)
cbcd2e36d6
bpo-39394: Improve warning message in the re module (GH-31988)
A warning about inline flags not at the start of the regular
expression now contains the position of the flag.
(cherry picked from commit 4142961b9f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-03-19 07:09:59 -07:00
Serhiy Storchaka
4d2099f455
[3.9] bpo-14156: Make argparse.FileType work correctly for binary file modes when argument is '-' (GH-13165) (GH-31979)
Also made modes containing 'a' or 'x' act the same as a mode containing 'w' when argument is '-'
(so 'a'/'x' return sys.stdout like 'w', and 'ab'/'xb' return sys.stdout.buffer like 'wb').
(cherry picked from commit eafec26ae5)

Co-authored-by: MojoVampire <shadowranger+github@gmail.com>
2022-03-18 17:02:44 +02:00
Miss Islington (bot)
1cab44d865
[3.9] bpo-46421: Fix unittest filename evaluation when called as a module (GH-30654) (GH-31970)
(cherry picked from commit a0db11b10f)

Co-authored-by: Bader Zaidan <bader@zaidan.pw>
2022-03-17 20:24:59 -07:00
Jelle Zijlstra
e808c9d5c7
[3.9] bpo-42782: fix broken shutil test (GH-31971)
We were using os_helper, which doesn't exist on 3.9. This wasn't
caught because the test is only run as root. I confirmed that when
run as root, the test previously failed and now passes.
2022-03-17 19:45:40 -07:00
Miss Islington (bot)
4e9bb27eae
bpo-47038: Increase a test timeout for slow CI machines (GH-31951)
(cherry picked from commit a7c5414832)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-16 18:19:18 -07:00
Miss Islington (bot)
0412e3ae03
bpo-47038: Rewrite missed asyncio.wait_for test to use IsolatedAnsyncioTestCase (GH-31946)
(cherry picked from commit 3dd9bfac04)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-16 16:44:22 -07:00
Andrew Svetlov
3244659521
[3.9] bpo-47038: Rewrite asyncio.wait_for test to use IsolatedAsyncioTestCase (GH-31942). (GH-31944)
(cherry picked from commit dd0082c627)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-03-16 22:45:39 +02:00
Miss Islington (bot)
0b0609d0d1
[3.10] bpo-45382: test.pythoninfo logs more Windows versions (GH-30891) (GH-30894)
Add the following info to test.pythoninfo:

* windows.ver: output of the shell "ver" command
* windows.version and windows.version_caption: output of the
  "wmic os get Caption,Version /value" command.

(cherry picked from commit b0898f4aa9)

* bpo-45382: test.pythoninfo: set wmic.exe encoding to OEM (GH-30890)

(cherry picked from commit cef0a5458f)
(cherry picked from commit 4a57fa296b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-03-16 11:13:55 +01:00
Miss Islington (bot)
32ae9ab55f
bpo-20392: Fix inconsistency with uppercase file extensions in mimetypes.guess_type (GH-30229)
(cherry picked from commit 5dd7ec52b8)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-03-15 08:50:01 -07:00
Miss Islington (bot)
64a68c39cb
bpo-43253: Don't call shutdown() for invalid socket handles (GH-31892)
(cherry picked from commit 70155412f1)

Co-authored-by: Maximilian Hils <git@maximilianhils.com>
2022-03-15 08:23:47 -07:00