Commit graph

26933 commits

Author SHA1 Message Date
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
Jason R. Coombs
177be52517
[3.9] bpo-47004: Sync with importlib_metadata 4.11.3. (GH-31854). (GH-31859)
(cherry picked from commit b1e2868607)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2022-03-13 17:30:07 -04:00
Jelle Zijlstra
f7f7838b41
[3.9] bpo-46198: rename duplicate tests and remove unused code (GH-30297) (GH-31797)
(cherry picked from commit 6c83c8e6b5)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-03-10 13:18:27 -08:00
Miss Islington (bot)
0663ca17f5
bpo-44439: _ZipWriteFile.write() handle buffer protocol correctly (GH-29468)
Co-authored-by: Marco Ribeiro <marcoffee@users.noreply.github.com>
(cherry picked from commit 36dd7396fc)

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
2022-03-08 02:04:54 -08:00
Miss Islington (bot)
852d9b77ab
[3.9] bpo-43292: Fix file leak in ET.iterparse() when not exhausted (GH-31696) (GH-31720)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 496c428de3)

Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
2022-03-07 13:48:53 +02:00
Victor Stinner
6a14330318
bpo-46913: Fix test_ctypes, test_hashlib, test_faulthandler on UBSan (GH-31675) (GH-31676)
* bpo-46913: Fix test_faulthandler.test_sigfpe() on UBSAN (GH-31662)

Disable undefined behavior sanitizer (UBSAN) on
faulthandler_sigfpe().

(cherry picked from commit 4173d677a1)

* bpo-46913: Fix test_faulthandler.test_read_null() on UBSan (GH31672)

Disable undefined behavior sanitizer (UBSan) on
faulthandler._read_null().

(cherry picked from commit 65b92ccdec)

* bpo-46913: test_hashlib skips _sha3 tests on UBSan (GH-31673)

If Python is built with UBSan, test_hashlib skips tests on the _sha3
extension which currently has undefined behaviors.

This change allows to run test_hashlib to check for new UBSan regression,
but the known _sha3 undefined behavior must be fixed.

(cherry picked from commit 6d0d7d2b8c)

* bpo-46913: Skip test_ctypes.test_shorts() on UBSan (GH-31674)

If Python is built with UBSan, test_ctypes now skips test_shorts().
This change allows to run test_ctypes to check for new UBSan regression,
but the known test_shorts() undefined behavior must be fixed.

(cherry picked from commit ad1b04451d)
(cherry picked from commit 7b5b429ada)
2022-03-04 01:31:54 +01:00
Victor Stinner
359bc392ba
[3.10] bpo-46633: Skip tests on ASAN and/or MSAN builds (GH-31632) (GH-31634) (GH-31644)
* Refactor sanitiser skip tests into test.support (GH-30889)

* Refactor sanitizer skip tests into test.support

(cherry picked from commit b1cb843050)

* Add skips to crashing tests under sanitizers instead of manually skipping them (GH-30897)

(cherry picked from commit a27505345e)

* bpo-46633: Skip tests on ASAN and/or MSAN builds (GH-31632)

Skip tests on ASAN and/or MSAN builds:

* multiprocessing tests
* test___all__
* test_concurrent_futures
* test_decimal
* test_peg_generator
* test_tools

(cherry picked from commit 9204bb72a2)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
(cherry picked from commit 93264452d9)
2022-03-02 18:12:26 +01:00
Miss Islington (bot)
4560c7e605
bpo-46756: Fix authorization check in urllib.request (GH-31353)
Fix a bug in urllib.request.HTTPPasswordMgr.find_user_password() and
urllib.request.HTTPPasswordMgrWithPriorAuth.is_authenticated() which
allowed to bypass authorization. For example, access to URI "example.org/foobar"
was allowed if the user was authorized for URI "example.org/foo".
(cherry picked from commit e2e72567a1)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-02-25 03:56:16 -08:00
Miss Islington (bot)
f3bb8fe4e8
Inherit asyncio proactor datagram transport from asyncio.DatagramTransport (GH-31512)
(cherry picked from commit cff4d5c5d2)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-22 16:08:43 -08:00
Miss Islington (bot)
29e8c43b32
bpo-46827: pass sock.type to getaddrinfo in sock_connect (GH-31499)
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: Andrew Svetlov <andrew.svetlov@gmail.com>
(cherry picked from commit 8fb94893e4)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
2022-02-22 13:10:04 -08:00
Miss Islington (bot)
336a916f75
bpo-46811: Make test suite support Expat >=2.4.5 (GH-31453) (GH-31469)
Curly brackets were never allowed in namespace URIs
according to RFC 3986, and so-called namespace-validating
XML parsers have the right to reject them a invalid URIs.

libexpat >=2.4.5 has become strcter in that regard due to
related security issues; with ET.XML instantiating a
namespace-aware parser under the hood, this test has no
future in CPython.

References:
- https://datatracker.ietf.org/doc/html/rfc3968
- https://www.w3.org/TR/xml-names/

Also, test_minidom.py: Support Expat >=2.4.5
(cherry picked from commit 2cae93832f)

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>

Co-authored-by: Sebastian Pipping <sebastian@pipping.org>
2022-02-21 17:16:23 +01:00
Andrew Svetlov
a6116a980c
[3.9] bpo-46672: fix NameError in asyncio.gather if type check fails (GH-31187) (GH-31441)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-02-20 14:39:21 +02:00
Miss Islington (bot)
c11f41b2c9
Fix mistake in barry_as_FLUFL test (GH-31392)
Use assertEqual(), not assertTrue(lineno, 2)
(cherry picked from commit 5f1c205dce)

Co-authored-by: Patrick Reader <_@pxeger.com>
2022-02-17 18:08:28 -08:00
Miss Islington (bot)
29ae7d3996
bpo-46333: Honor module parameter in ForwardRef (GH-30536)
The `module` parameter carries semantic information about the forward ref.
Forward refs are different if they refer to different module even if they
have the same name. This affects the `__eq__`, `__repr__` and `__hash__` methods.

Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
(cherry picked from commit 6e7b813195)

Co-authored-by: aha79 <34090357+aha79@users.noreply.github.com>
2022-02-16 19:53:31 -08:00
Miss Islington (bot)
a657bff349
bpo-46762: Fix an assert failure in f-strings where > or < is the last character if the f-string is missing a trailing right brace. (GH-31365)
(cherry picked from commit ffd9f8ff84)

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2022-02-16 03:18:16 -08:00
Dennis Sweeney
c31b8a97a8
bpo-46615: Don't crash when set operations mutate the sets (GH-31120) (GH-31312)
Ensure strong references are acquired whenever using `set_next()`. Added randomized test cases for `__eq__` methods that sometimes mutate sets when called.

(cherry picked from commit 4a66615ba7)
2022-02-13 12:29:42 +02:00
Jacob Walls
cc6d8f8828
[3.9] bpo-45948: Remove constructor discrepancy in C version of ElementTree.XMLParser (GH-31152) (GH-31299)
Both implementations accept target=None now.

(cherry picked from commit 168fd6453b)
2022-02-13 02:16:31 +02:00
Andrew Svetlov
a65be6e077
[3.9] Fix warning: asyncio.events._event_loop_policy was modified by test_asyncio (GH-31253). (GH-31256)
(cherry picked from commit 012e77eb5c)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
2022-02-10 15:32:05 +02:00
Miss Islington (bot)
b0517a1217
bpo-45863: tarfile: don't zero out header fields unnecessarily (GH-29693)
Numeric fields of type float, notably mtime, can't be represented
exactly in the ustar header, so the pax header is used. But it is
helpful to set them to the nearest int (i.e. second rather than
nanosecond precision mtimes) in the ustar header as well, for the
benefit of unarchivers that don't understand the pax header.

Add test for tarfile.TarInfo.create_pax_header to confirm correct
behaviour.
(cherry picked from commit bf2d44ffb0)

Co-authored-by: Joshua Root <jmr@macports.org>
2022-02-09 09:35:56 -08:00
Miss Islington (bot)
bde3765a3f
bpo-46685: cover TypeError of ForwardRef(1) in test_typing (GH-31223)
(cherry picked from commit d2d1d49eac)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-02-09 07:12:32 -08:00
Miss Islington (bot)
0d74efc54f
bpo-46648: Rewrite test_urllib2.test_issue16464() with a local HTTP server (GH-31186)
Re-enable test_issue16464() of test_urllib2, move it to urllib2_localnet
and use the local HTTP server rather than an external HTTP server.
(cherry picked from commit 8e98175a03)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-02-07 05:14:06 -08:00
Miss Islington (bot)
1b8a34ae65
bpo-46648: Skip test_urllib2.test_issue16464() (GH-31161)
POST requests to http://www.example.com/ fail randomly.
(cherry picked from commit 1578de2fcd)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-02-06 06:30:18 -08:00
Miss Islington (bot)
ee3d050e85
Optimize images by IMGbot (GH-21348)
Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
(cherry picked from commit ba650af7d6)

Co-authored-by: Manish Kumar  <manishprivet@protonmail.com>
2022-02-03 23:15:17 -08:00
Miss Islington (bot)
3c6173ca67
bpo-46616: Ensures test_importlib.test_windows cleans up registry keys after completion (GH-31086)
(cherry picked from commit 89a0a90c2e)

Co-authored-by: Steve Dower <steve.dower@python.org>
2022-02-02 12:23:49 -08:00
Petr Viktorin
8d239bfdcc
[3.9] bpo-45703: Invalidate _NamespacePath cache on importlib.invalidate_cache (GH-29384) (GH-30922) (GH-31076)
Consider the following directory structure:

    .
    └── PATH1
        └── namespace
            └── sub1
                └── __init__.py

And both PATH1 and PATH2 in sys path:

    $ PYTHONPATH=PATH1:PATH2 python3.11
    >>> import namespace
    >>> import namespace.sub1
    >>> namespace.__path__
    _NamespacePath(['.../PATH1/namespace'])
    >>> ...

While this interpreter still runs, PATH2/namespace/sub2 is created:

    .
    ├── PATH1
    │   └── namespace
    │       └── sub1
    │           └── __init__.py
    └── PATH2
        └── namespace
            └── sub2
                └── __init__.py

The newly created module cannot be imported:

    >>> ...
    >>> namespace.__path__
    _NamespacePath(['.../PATH1/namespace'])
    >>> import namespace.sub2
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ModuleNotFoundError: No module named 'namespace.sub2'

Calling importlib.invalidate_caches() now newly allows to import it:

    >>> import importlib
    >>> importlib.invalidate_caches()
    >>> namespace.__path__
    _NamespacePath(['.../PATH1/namespace'])
    >>> import namespace.sub2
    >>> namespace.__path__
    _NamespacePath(['.../PATH1/namespace', '.../PATH2/namespace'])

This was not previously possible.








Co-Authored-By: Miro Hrončok <miro@hroncok.cz>

Automerge-Triggered-By: GH:encukou
2022-02-02 05:50:43 -08:00
Miss Islington (bot)
0371e5d7f1
bpo-44359: Fix test_ftplib unhandled thread exceptions (GH-31069)
test_ftplib now silently ignores socket errors to prevent logging
unhandled threading exceptions.
(cherry picked from commit 0611eafc70)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-02-01 18:16:58 -08:00
Miss Islington (bot)
2e9f77f9d4
[3.9] bpo-44031: fix test_tabnanny failure in non-ascii CWD (GH-31014) (GH-31048)
(cherry picked from commit 108e66b6d2)


Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>

Automerge-Triggered-By: GH:iritkatriel
2022-02-01 03:31:49 -08:00
Miss Islington (bot)
2532b7c820
[3.9] bpo-46482: add a test for typing.Annotation.__new__ (GH-30821) (GH-31045)
(cherry picked from commit 4c0612ad00)


Co-authored-by: Nikita Sobolev <mail@sobolevn.me>

Automerge-Triggered-By: GH:Fidget-Spinner
2022-02-01 02:25:25 -08:00
Miss Islington (bot)
ce5c637f5a
bpo-46530: add "thread_time" to test_time.test_get_clock_info (GH-30913)
(cherry picked from commit c27a33132b)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-01-28 08:56:26 -08:00
Miss Islington (bot)
8cd82461f9
bpo-46542: test_json uses support.infinite_recursion() (GH-30972)
Fix test_json tests checking for RecursionError: modify these tests
to use support.infinite_recursion().
(cherry picked from commit e7a6285f1b)

Co-authored-by: Victor Stinner <vstinner@python.org>
2022-01-27 17:04:56 -08:00
Miss Islington (bot)
37577033ba
bpo-46539: Pass status of special typeforms to forward references (GH-30926)
Previously this didn't matter because there weren't any valid code paths
that could trigger a type check with a special form, but after the bug
fix for `Annotated` wrapping special forms it's now possible to annotate
something like `Annotated['ClassVar[int]', (3, 4)]`. This change would
also be needed for proposed future changes, such as allowing `ClassVar`
and `Final` to nest each other in dataclasses.
(cherry picked from commit ced50051bb)

Co-authored-by: Gregory Beauregard <greg@greg.red>
2022-01-27 08:47:35 -08:00
Miss Islington (bot)
8e98ccc4c3
bpo-44734: Fix floating point precision in test_turtle (GH-30910)
(cherry picked from commit aa78287bc6)

Co-authored-by: Karolina Surma <33810531+befeleme@users.noreply.github.com>
2022-01-27 06:23:52 -08:00
Miss Islington (bot)
1440dd3438
bpo-23556: [doc] Fix inaccuracy in documentation for raise without args. Improve tests for context in nested except handlers. (GH-29236)
(cherry picked from commit 08c0ed2d9c)

Co-authored-by: Kinshuk Dua <kinshukdua@gmail.com>
2022-01-27 02:50:43 -08:00
Miss Islington (bot)
29eefcc9c6
bpo-46529: increase coverage of typing.Union.__repr__ method (GH-30911)
(cherry picked from commit d0c690b5f8)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-01-26 02:40:40 -08:00
Miss Islington (bot)
f9ff0bf515
bpo-41682: fixed flaky test test_sendfile_close_peer_in_the_middle_of_receiving (GH-30845) (#30861)
(cherry picked from commit 1c705fda8f)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2022-01-25 18:40:34 +01:00
Miss Islington (bot)
b0b8388a1c
bpo-46491: Allow Annotated on outside of Final/ClassVar (GH-30864)
We treat Annotated type arg as class-level annotation. This exempts it from checks against Final and ClassVar in order to allow using them in any nesting order.

Automerge-Triggered-By: GH:gvanrossum
(cherry picked from commit e1abffca45)

Co-authored-by: Gregory Beauregard <greg@greg.red>
2022-01-25 06:39:12 -08:00
Miss Islington (bot)
c314e3e829
bpo-46503: Prevent an assert from firing when parsing some invalid \N sequences in f-strings. (GH-30865) (30867)
* bpo-46503: Prevent an assert from firing.  Also fix one nearby tiny PEP-7 nit.

* Added blurb.
(cherry picked from commit 0daf72194b)

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>

Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
2022-01-24 22:08:42 -05:00
Serhiy Storchaka
3f1ea163ea
[3.9] bpo-46426: Improve tests for the dir_fd argument (GH-30668) (GH-30757)
Ensure that directory file descriptors refer to directories different
from the current directory, and that src_dir_fd and dst_dir_fd refer
to different directories.

Add context manager open_dir_fd() in test.support.os_helper.
(cherry picked from commit 54610bb448)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-01-24 12:14:42 +02:00
Miss Islington (bot)
94d6434ba7
[3.9] bpo-21987: Fix TarFile.getmember getting a dir with a trailing slash (GH-30283) (GH-30738)
(cherry picked from commit cfadcc31ea)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
2022-01-23 19:54:13 +02:00
Miss Islington (bot)
ba932d9024
bpo-41682: Skip unstable test_asyncio sendfile test on Windows (GH-30801)
(cherry picked from commit 1ded8ed8e8)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-01-22 16:20:49 -08:00
Kumar Aditya
6ed874f8c5
[3.9] bpo-46469: Make asyncio generic classes return GenericAlias (GH-30777) (GH-30785)
Automerge-Triggered-By: GH:asvetlov
2022-01-22 04:52:24 -08:00
Miss Islington (bot)
3c4a3745b9
bpo-46425: fix direct invocation of asyncio tests (GH-30725)
(cherry picked from commit 5a5340044c)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-01-22 03:54:07 -08:00