Commit Graph

46669 Commits

Author SHA1 Message Date
Victor Stinner 532e063fc2
bpo-41718: regrtest saved_test_environment avoids imports (GH-24934)
Reduce the number of modules imported by libregrtest.

saved_test_environment no longer imports modules at startup, but try
to get them from sys.modules. If an module is missing, skip the test.
It also sets directly support.environment_altered.

runtest() now now two saved_test_environment instances: one before
importing the test module, one after importing it.

Remove imports from test.libregrtest.save_env:

* asyncio
* logging
* multiprocessing
* shutil
* sysconfig
* urllib.request
* warnings

When a test method imports a module (ex: warnings) and the test
has a side effect (ex: add a warnings filter), the side effect is not
detected, because the module was not imported when Python
enters the saved_test_environment context manager.
2021-03-22 23:52:13 +01:00
Pablo Galindo 96eeff5162
bpo-43555: Report the column offset for invalid line continuation character (GH-24939) 2021-03-22 17:28:11 +00:00
Pablo Galindo 123ff266cd
bpo-43591: Fix error location in interactive mode for errors at the end of the line (GH-24973)
Co-authored-by: Erlend Egeberg Aasland
2021-03-22 16:24:39 +00:00
Hai Shi 56f031ec52
bpo-35134: Add include/cpython/compile.h (GH-24922)
Move C API excluded from the limited C API from Include/compile.h
to a new Include/cpython/compile.h header file.
2021-03-22 09:32:11 +01:00
Sergey B Kirpichev 690aca7811
bpo-43420: Simple optimizations for Fraction's arithmetics (GH-24779)
bpo-43420: Implement standard transformations in + - * / that can often reduce the size of intermediate integers needed. For rationals with large components, this can yield dramatic speed improvements, but for small rationals can run 10-20% slower, due to increased fixed overheads in the longer-winded code. If those slowdowns turn out to be a problem, see the PR discussion for low-level implementation tricks that could cut other fixed overheads.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
2021-03-21 21:30:55 -05:00
Antoine Pitrou cdddc2b742
bpo-43422: Revert _decimal C API addition (GH-24960)
Stefan Krah requested the reversal of these (unreleased) changes, quoting him:
> The capsule API does not meet my testing standards, since I've focused
on the upstream mpdecimal in the last couple of months.
> Additionally, I'd like to refine the API, perhaps together with the
Arrow community.

Automerge-Triggered-By: GH:pitrou
2021-03-21 09:27:54 -07:00
Christian Heimes 77cde5042a
bpo-43577: Fix deadlock with SSLContext._msg_callback and sni_callback (GH-24957)
OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes <christian@python.org>
2021-03-21 16:13:09 +01:00
Ilya Stepin 20a5b7e986
bpo-43542: Add heif/heic formats in mimetypes (GH-24917)
* bpo-43542: Add heif/heic formats in mimetypes

Add HEIF and HEIC format to list of media types. It has IANA registration.

IANA: https://www.iana.org/assignments/media-types/image/heic
HEIF Github: https://github.com/nokiatech/heif

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2021-03-20 16:06:27 -07:00
Antoine Pitrou 2fd16ef406
bpo-43517: Fix false positive in detection of circular imports (#24895) 2021-03-20 20:07:44 +01:00
Christian Heimes f6c6b5821b
bpo-41561: Add workaround for Ubuntu's custom security level (GH-24915)
Ubuntu 20.04 comes with a patched OpenSSL 1.1.1. Default security level
2 blocks TLS 1.0 and 1.1 connections. Regular OpenSSL 1.1.1 builds allow
TLS 1.0 and 1.1 on security level 2.

See: 
See: https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1899878
See: https://bugs.launchpad.net/ubuntu/+source/openssl/+bug/1917625
Signed-off-by: Christian Heimes <christian@python.org>
2021-03-18 15:06:50 -07:00
Kodi Arfer 08ff4369af
bpo-43521: Allow ast.unparse with empty sets and NaN (GH-24897)
Automerge-Triggered-By: GH:pablogsal
2021-03-18 10:36:06 -07:00
Chris Burr e0b4aa0f5c
bpo-39342: Expose X509_V_FLAG_ALLOW_PROXY_CERTS in ssl module (GH-18011)
Exposes the `X509_V_FLAG_ALLOW_PROXY_CERTS` constant as `ssl.VERIFY_ALLOW_PROXY_CERTS` to allow for proxy certificate validation as described in: https://www.openssl.org/docs/man1.1.1/man7/proxy-certificates.html
2021-03-18 01:24:01 -07:00
Pablo Galindo 08fb8ac99a
bpo-42128: Add 'missing :' syntax error message to match statements (GH-24733) 2021-03-18 01:03:11 +00:00
Victor Stinner 9976834f80
bpo-35883: Py_DecodeLocale() escapes invalid Unicode characters (GH-24843)
Python no longer fails at startup with a fatal error if a command
line argument contains an invalid Unicode character.

The Py_DecodeLocale() function now escapes byte sequences which would
be decoded as Unicode characters outside the [U+0000; U+10ffff]
range.

Use MAX_UNICODE constant in unicodeobject.c.
2021-03-17 21:46:53 +01:00
tsukasa-au a8ef4572a6
bpo-43497: Emit SyntaxWarnings for assertions with tuple constants. (GH-24867)
* bpo-43497: Emit SyntaxWarnings for assertions with tuple constants.

Add a test that shows that a tuple constant (a tuple, where all of its
members are also compile-time constants) produces a SyntaxWarning. Then
fix this failure.

* Make SyntaxWarnings also work when "optimized".

* Split tests for SyntaxWarning to SyntaxError conversion

SyntaxWarnings emitted by the compiler when configured to be errors are
actually raised as SyntaxError exceptions.

Move these tests into their own method and add a test to ensure they are
raised. Previously we only tested that they were not raised for a
"valid" assertion statement.
2021-03-16 11:14:41 +00:00
Chavdar Yotov 0269ce87c9
bpo-41933: Clarify wording for s * n in Common Sequence Operations (GH-22570) 2021-03-15 23:50:49 +01:00
Gregory P. Smith 0ab152c6b5
bpo-43285 Make ftplib not trust the PASV response. (GH-24838)
bpo-43285: Make ftplib not trust the PASV response.

The IPv4 address value returned from the server in response to the PASV command
should not be trusted.  This prevents a malicious FTP server from using the
response to probe IPv4 address and port combinations on the client network.

Instead of using the returned address, we use the IP address we're
already connected to.  This is the strategy other ftp clients adopted,
and matches the only strategy available for the modern IPv6 EPSV command
where the server response must return a port number and nothing else.

For the rare user who _wants_ this ugly behavior, set a `trust_server_pasv_ipv4_address`
attribute on your `ftplib.FTP` instance to True.
2021-03-15 11:39:31 -07:00
Mark Shannon c5440937ef
Mark POP_TOP at end of expression statement as artificial, to conform to PEP 626. (GH-24860) 2021-03-15 14:24:25 +00:00
Jason R. Coombs 35d5068928
bpo-43428: Improve documentation for importlib.metadata changes. (GH-24858)
* bpo-43428: Sync with importlib_metadata 3.7.3 (16ac3a95)

* Add 'versionadded' for importlib.metadata.packages_distributions

* Add section in what's new for Python 3.10 highlighting most salient changes and relevant backport.
2021-03-14 22:20:49 -04:00
CAM Gerlach bd2fa3c416
bpo-29982: Add "ignore_cleanup_errors" param to tempfile.TemporaryDirectory() (GH-24793) 2021-03-14 11:06:56 -07:00
Mark Shannon d48848c83e
bpo-39316: Make sure that attribute accesses and stores, including method calls, conform to PEP 626. (GH-24859) 2021-03-14 18:01:30 +00:00
Pablo Galindo cd8dcbc851
bpo-43410: Fix crash in the parser when producing syntax errors when reading from stdin (GH-24763) 2021-03-14 04:38:40 +01:00
Kamil Turek 9923df9641
bpo-43245: Add keyword argument support to ChainMap.new_child() (GH-24788) 2021-03-13 19:15:44 -08:00
Jason R. Coombs f917efccf8
bpo-43428: Sync with importlib_metadata 3.7. (GH-24782)
* bpo-43428: Sync with importlib_metadata 3.7.2 (67234b6)

* Add blurb

* Reformat blurb to create separate paragraphs for each change included.
2021-03-13 11:31:45 -05:00
Géry Ogam b6884ad268
Update client.py (GH-24827) 2021-03-13 04:22:03 -08:00
Pandu E POLUAN 7591d9455e
bpo-27820: Fix AUTH LOGIN logic in smtplib.SMTP (GH-24118)
* Fix auth_login logic (bpo-27820)

* Also fix a longstanding bug in the SimSMTPChannel.found_terminator() method that causes inability to test
SMTP AUTH with initial_response_ok=False.
2021-03-12 15:25:49 -08:00
Antoine Pitrou ba251c2ae6
bpo-43356: Allow passing a signal number to interrupt_main() (GH-24755)
Also introduce a new C API ``PyErr_SetInterruptEx(int signum)``.
2021-03-11 23:35:45 +01:00
Chris Griffith b4fc44bb2d
bpo-43423 Fix IndexError in subprocess _communicate function (GH-24777)
Check to make sure stdout and stderr are not empty before selecting an item from them in Windows subprocess._communicate.

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2021-03-11 11:43:29 -08:00
Victor Stinner 1fa17e8cc6
bpo-43406: Fix test_signal.test_stress_modifying_handlers() (GH-24815)
Fix a race condition of test_stress_modifying_handlers() of
test_signal: only raise signals while we are in the
catch_unraisable_exception() context manager.
Moreover, don't check if we received at least one
signal if at least one signal got ignored.
2021-03-10 15:26:45 +01:00
Pablo Galindo b4f9089d4a
bpo-43439: Add audit hooks for gc functions (GH-24794) 2021-03-10 00:53:57 +00:00
Desmond Cheong 3abf6f0102
bpo-14678: Update zipimport to support importlib.invalidate_caches() (GH-24159)
Added an invalidate_caches() method to the zipimport.zipimporter class based on the implementation of importlib.FileFinder.invalidate_caches(). This was done by adding a get_files() method and an _archive_mtime attribute to zipimport.zipimporter to check for updates or cache invalidation whenever the cache of files and toc entry information in the zipimporter is accessed.
2021-03-08 12:06:02 -08:00
Mariusz Felisiak bbba28212c
bpo-43353: Document that logging.getLevelName() accepts string representation of logging level. (GH-24693)
[bpo-43353]()

Automerge-Triggered-By: GH:vsajip
2021-03-08 03:16:20 -08:00
Gregory P. Smith c25910a135
bpo-43332: Buffer proxy connection setup packets before sending. (GH-24780)
We now buffer the CONNECT request + tunnel HTTP headers into a single
send call.  This prevents the OS from generating multiple network
packets for connection setup when not necessary, improving efficiency.
2021-03-07 23:35:13 -08:00
Zackery Spytz 8aabfa8550
bpo-43405: Fix DeprecationWarnings in test_unicode (GH-24754)
DeprecationWarnings were being raised in the test_encode_decimal()
and test_transform_decimal() methods after 91a639a094.
2021-03-07 15:12:35 +09:00
Neil Schemenauer 87ec26b812
bpo-43372: Use _freeze_importlib for regen-frozen. (GH-24759)
This approach ensures the code matches the interpreter version.
Previously, PYTHON_FOR_REGEN was used to generate the code, which might
be wrong. The marshal format for code objects has changed with
bpo-42246, commit 877df851. Update the code and the expected code sizes
in ctypes test_frozentable.
2021-03-06 13:34:03 -08:00
Antoine Pitrou 68245b7a10
bpo-43406: Fix possible race condition where ``PyErr_CheckSignals`` tries to execute a non-Python signal handler (GH-24756)
We can receive signals (at the C level, in `trip_signal()` in signalmodule.c) while `signal.signal` is being called to modify the corresponding handler.  Later when `PyErr_CheckSignals()` is called to handle the given signal, the handler may be a non-callable object and would raise a cryptic asynchronous exception.
2021-03-05 10:32:50 +01:00
Jason R. Coombs 6714825414
bpo-42129: Add support for resources in namespaces (GH-24670)
* Unify behavior in ResourceReaderDefaultsTests and align with the behavior found in importlib_resources.
* Equip NamespaceLoader with a NamespaceReader.
* Apply changes from importlib_resources 5.0.4
2021-03-04 13:43:00 -05:00
Jason R. Coombs fbf75b9997
Revert "bpo-42405: fix C extensions build on Windows ARM64 (GH-23399)" (#24753)
This reverts commit cb7bc76409.
2021-03-04 13:41:49 -05:00
Kamil Turek b225d91f0a
bpo-43391: Remove the broken Python 2.4 link from the comment (GH-24736) 2021-03-04 10:24:42 -08:00
Adrian Vladu cb7bc76409
bpo-42405: fix C extensions build on Windows ARM64 (GH-23399)
The following changes are required:

      * add a new platform win-arm64
      * replace the emulated compiler executable paths
      * bump the linker base addressed as ARM64 requires more memory
        this change might not be needed (investigation required)

    On Windows 10 ARM64, VS compiler paths look like this:
    C:\Program Files (x86)\Microsoft Visual
    Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\HostX86\ARM64\cl.exe

    Note that the cl.exe for ARM64 is an x32 binary, which can run emulated
    on Windows 10 ARM64 (it has builtin emulation for x32).

    The rc.exe and mc.exe paths have to also be changed, as the initial
    discovery has to be fixed.

    Work in progress to remove the hardcoded bits and to change the path
    query fixes to the proper location.

Automerge-Triggered-By: GH:jaraco
2021-03-04 08:59:12 -08:00
Erlend Egeberg Aasland e161ec5dd7
bpo-43369: sqlite3_column_{text,blob} failures now raise MemoryError (GH-24723) 2021-03-04 11:50:25 +02:00
Pablo Galindo 0632b1012d
bpo-42128: Add __match_args__ to structseq-based classes (GH-24732) 2021-03-04 00:03:44 +00:00
Eric L 9c7927400c
bpo-40701: tempfile mixes str and bytes in an inconsistent manner (GH-20442)
The case of tempfile.tempdir variable being bytes is now handled consistently.
The getters return the right type and no more error of mixing str and bytes unless explicitly caused by the user.

Adds a regression test.

Expands the documentation to clarify the behavior.

Co-authored-by: Eric L <ewl+git@lavar.de>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2021-03-03 12:36:22 -08:00
Ethan Furman 44e580f448
bpo-43162: [Enum] update docs, renable doc tests (GH-24487)
* update docs, renable doc tests
* make deprecation warning active for two releases
2021-03-03 09:54:30 -08:00
Noor Michael 04f6fbb696
bpo-43295: Fix error handling of datetime.strptime format string '%z' (GH-24627)
Previously, `datetime.strptime` would match `'z'` with the format string `'%z'` (for UTC offsets), throwing an `IndexError` by erroneously trying to parse `'z'` as a timestamp. As a special case, `'%z'` matches the string `'Z'` which is equivalent to the offset `'+00:00'`, however this behavior is not defined for lowercase `'z'`.

This change ensures a `ValueError` is thrown when encountering the original example, as follows:

```
>>> from datetime import datetime
>>> datetime.strptime('z', '%z')
ValueError: time data 'z' does not match format '%z'
```

Automerge-Triggered-By: GH:pganssle
2021-03-03 08:58:57 -08:00
Mariusz Felisiak 3b4b2cf418
bpo-43368: Fix fetching empty bytes in sqlite3 (GH-24706)
Regression introduced in 47feb1feb2.
2021-03-03 16:16:24 +02:00
Nathan Beals 3a87e562ea
bpo-42994: Add MIME types for opus, AAC, 3gpp and 3gpp2 (#24287)
Co-authored-by: Nathan Beals <ndbeals@users.noreply.github.com>
2021-03-02 16:20:18 -08:00
Winson Luk 132131b404
bpo-42782: Fail fast for permission errors in shutil.move() (GH-24001)
* Fail fast in shutil.move() to avoid creating destination directories on failure.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2021-03-02 12:53:15 -08:00
Peter Donis b36349a647
bpo-43049: Use io.IncrementalNewlineDecoder for doctest newline conversion (GH-24359)
Followup to bpo-1812 and GH-17385.
2021-03-02 11:06:20 -06:00
Inada Naoki 5bfa945605
bpo-41282: distutils: Fix stacklevel for DeprecationWarning (GH-24657)
DeprecationWarning is emit for `import distutils`, not for `distutils` itself.
2021-03-02 11:49:10 +09:00