]> git.ipfire.org Git - thirdparty/Python/cpython.git/log
thirdparty/Python/cpython.git
4 years agobpo-43921: also accept EOF in post-handshake auth test (GH-25574)
Christian Heimes [Sat, 24 Apr 2021 13:08:13 +0000 (15:08 +0200)] 
bpo-43921: also accept EOF in post-handshake auth test (GH-25574)

4 years agobpo-41282: Consistent message and filter warning in setup.py (GH-25571)
Christian Heimes [Sat, 24 Apr 2021 07:55:15 +0000 (09:55 +0200)] 
bpo-41282: Consistent message and filter warning in setup.py (GH-25571)

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-37322: Fix ResourceWarning and exception handling in test (GH-25553)
Christian Heimes [Sat, 24 Apr 2021 07:17:54 +0000 (09:17 +0200)] 
bpo-37322: Fix ResourceWarning and exception handling in test (GH-25553)

Revert 73ea546, increase logging, and improve stability of test.

Handle all OSErrors in a single block. OSError also takes care of
SSLError and socket's connection errors.

Partly reverts commit fb7e750. The
threaded connection handler must not raise an unhandled exception.

4 years agobpo-31870: Fix test_get_server_certificate_timeout on Windows (GH-25570)
Christian Heimes [Sat, 24 Apr 2021 05:54:08 +0000 (07:54 +0200)] 
bpo-31870: Fix test_get_server_certificate_timeout on Windows (GH-25570)

Some OS do not support millisecond granularity in select(). Use 100ms
timeout and a server callback with sleep to emulate a slow server.

4 years agobpo-31870: Add a timeout parameter to ssl.get_server_certificate() (GH-22270)
Zackery Spytz [Sat, 24 Apr 2021 04:46:01 +0000 (22:46 -0600)] 
bpo-31870: Add a timeout parameter to ssl.get_server_certificate() (GH-22270)

4 years agobpo-38659: [Enum] do not check '_inverted_' during simple test (GH-25566)
Ethan Furman [Sat, 24 Apr 2021 02:08:22 +0000 (19:08 -0700)] 
bpo-38659: [Enum] do not check '_inverted_' during simple test (GH-25566)

Depending on usage, it's possible for Flag members to have the _inverted_ attribute when they are testing, while the Flag being testing against will not have that attribute on its members -- so skip that comparison.

4 years agoRestrict GITHUB_TOKEN permissions for the 'stale' workflow (GH-25564)
Brett Cannon [Fri, 23 Apr 2021 22:18:50 +0000 (15:18 -0700)] 
Restrict GITHUB_TOKEN permissions for the 'stale' workflow (GH-25564)

It should only need write-level permissions to pull requests.

4 years agobpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection (GH-1927)
Segev Finer [Fri, 23 Apr 2021 22:00:27 +0000 (01:00 +0300)] 
bpo-30555: Fix WindowsConsoleIO fails in the presence of fd redirection (GH-1927)

This works by not caching the handle and instead getting the handle from
the file descriptor each time, so that if the actual handle changes by
fd redirection closing/opening the console handle beneath our feet, we
will keep working correctly.

4 years agobop-43652: Update Tcl and Tk to 8.6.11 in Windows installer (GH-25170)
Terry Jan Reedy [Fri, 23 Apr 2021 21:40:42 +0000 (17:40 -0400)] 
bop-43652: Update Tcl and Tk to 8.6.11 in Windows installer (GH-25170)

4 years agoSilence find_module() DeprecationWarning on Windows tests (GH-25563)
Brett Cannon [Fri, 23 Apr 2021 21:40:18 +0000 (14:40 -0700)] 
Silence find_module() DeprecationWarning on Windows tests (GH-25563)

4 years agobpo-43907: add missing memoize call in pure python pickling of bytearray (GH-25501)
Carl Friedrich Bolz-Tereick [Fri, 23 Apr 2021 21:27:14 +0000 (23:27 +0200)] 
bpo-43907: add missing memoize call in pure python pickling of bytearray (GH-25501)

4 years agobpo-39950: add `pathlib.Path.hardlink_to()` method that supersedes `link_to()` (GH...
Barney Gale [Fri, 23 Apr 2021 20:48:52 +0000 (21:48 +0100)] 
bpo-39950: add `pathlib.Path.hardlink_to()` method that supersedes `link_to()` (GH-18909)

The argument order of `link_to()` is reversed compared to what one may expect, so:

    a.link_to(b)

Might be expected to create *a* as a link to *b*, in fact it creates *b* as a link to *a*, making it function more like a "link from". This doesn't match `symlink_to()` nor the documentation and doesn't seem to be the original author's intent.

This PR deprecates `link_to()` and introduces `hardlink_to()`, which has the same argument order as `symlink_to()`.

4 years agobpo-43921: ignore failing test_wrong_cert_tls13 on Windows (GH-25561)
Christian Heimes [Fri, 23 Apr 2021 18:03:25 +0000 (20:03 +0200)] 
bpo-43921: ignore failing test_wrong_cert_tls13 on Windows (GH-25561)

test_wrong_cert_tls13 sometimes fails on some Windows buildbots. Turn
failing test case into skipped test case until we have more time to
investigate.

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-43538: Add extra arguments to os.startfile (GH-25538)
Steve Dower [Fri, 23 Apr 2021 17:03:17 +0000 (18:03 +0100)] 
bpo-43538: Add extra arguments to os.startfile (GH-25538)

4 years agobpo-43607: Fix urllib handling of Windows paths with \\?\ prefix (GH-25539)
Steve Dower [Fri, 23 Apr 2021 17:02:47 +0000 (18:02 +0100)] 
bpo-43607: Fix urllib handling of Windows paths with \\?\ prefix (GH-25539)

4 years agobpo-35114: Make ssl.RAND_status() return a bool (GH-20063)
Zackery Spytz [Fri, 23 Apr 2021 16:07:37 +0000 (10:07 -0600)] 
bpo-35114: Make ssl.RAND_status() return a bool (GH-20063)

4 years agobpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)
Pablo Galindo [Fri, 23 Apr 2021 13:27:05 +0000 (14:27 +0100)] 
bpo-43914: Highlight invalid ranges in SyntaxErrors (#25525)

To improve the user experience understanding what part of the error messages associated with SyntaxErrors is wrong, we can highlight the whole error range and not only place the caret at the first character. In this way:

>>> foo(x, z for z in range(10), t, w)
  File "<stdin>", line 1
    foo(x, z for z in range(10), t, w)
           ^
SyntaxError: Generator expression must be parenthesized

becomes

>>> foo(x, z for z in range(10), t, w)
  File "<stdin>", line 1
    foo(x, z for z in range(10), t, w)
           ^^^^^^^^^^^^^^^^^^^^
SyntaxError: Generator expression must be parenthesized

4 years agobpo-43868: Remove PyOS_ReadlineFunctionPointer from the stable ABI list (GH-25442)
Petr Viktorin [Fri, 23 Apr 2021 12:23:38 +0000 (14:23 +0200)] 
bpo-43868: Remove PyOS_ReadlineFunctionPointer from the stable ABI list (GH-25442)

The inclusion of PyOS_ReadlineFunctionPointer in python3dll.c was a mistake.

According to PEP 384:
> functions expecting FILE* are not part of the ABI, to avoid depending
> on a specific version of the Microsoft C runtime DLL on Windows.

https://bugs.python.org/issue43868

4 years agobpo-38820: Test with OpenSSL 3.0.0-alpha15 (GH-25537)
Christian Heimes [Fri, 23 Apr 2021 12:19:21 +0000 (14:19 +0200)] 
bpo-38820: Test with OpenSSL 3.0.0-alpha15 (GH-25537)

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-43795: PEP-652: Clean up the stable ABI/limited API (GH-25482)
Petr Viktorin [Fri, 23 Apr 2021 12:17:58 +0000 (14:17 +0200)] 
bpo-43795: PEP-652: Clean up the stable ABI/limited API (GH-25482)

- `_Py_EncodeLocaleRaw`, which is private by name, undocumented,
  and wasn't exported in `python3.dll`, is moved to a private header.
- `_Py_HashSecret_Initialized`, again private by name, undocumented,
  and not exported in `python3.dll`, is excluded with `Py_LIMITED_API`.
- `PyMarshal_*` and `PyMember_*One` functions, declared in private headers and
  not exported in `python3.dll`, are removed from `Doc/data/stable_abi.dat`.
- `PyMem_Calloc` which *was* exported in `python3dll.c`, is moved to public
  headers where it joins its other `PyMem_*` friends.

Only the last change is documented in the blurb; others are not user-visible.
(Nothing uses `Doc/data/stable_abi.dat` yet.)

https://bugs.python.org/issue43795

4 years agobpo-43795: PEP-652: Simplify headers for easier static analysis (GH-25483)
Petr Viktorin [Fri, 23 Apr 2021 12:14:00 +0000 (14:14 +0200)] 
bpo-43795: PEP-652: Simplify headers for easier static analysis (GH-25483)

As part of the PEP-652 implementation, I'll tighten the CI check
for functions/data defined with `Py_LIMITED_API`.

Discussion in https://discuss.python.org/t/pep-652-maintaining-the-stable-abi/6986
suggests that parsing C headers is OK (though personally I'd rather generate it...),
but writing a full C parser is a monumental task and adding an existing one as a
dependency brings too many vendoring/bootstraping issues.

So, for the check I'll use a "simple" regex on preprocessor output, and adapt
the few trivial places where the regex won't work.

- Keep declarations in the limited API to one item per line
- Make it possible to override `_Py_NO_RETURN`, so the annotation can be
  removed from preprocessor output.

https://bugs.python.org/issue43795

4 years agobpo-41282: (PEP 632) Deprecate distutils.sysconfig (partial implementation of the...
Lumír 'Frenzy' Balhar [Fri, 23 Apr 2021 12:02:41 +0000 (14:02 +0200)] 
bpo-41282: (PEP 632) Deprecate distutils.sysconfig (partial implementation of the PEP) (GH-23142)

This change:
* merges `distutils.sysconfig` into `sysconfig` while keeping the original functionality and
* marks `distutils.sysconfig` as deprecated

https://bugs.python.org/issue41282

4 years agobpo-43920: Make load_verify_locations(cadata) error message consistent (GH-25554)
Christian Heimes [Fri, 23 Apr 2021 11:51:40 +0000 (13:51 +0200)] 
bpo-43920: Make load_verify_locations(cadata) error message consistent (GH-25554)

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-43852: Improve tuple creation in sqlite3 (GH-25421)
Erlend Egeberg Aasland [Fri, 23 Apr 2021 11:21:08 +0000 (13:21 +0200)] 
bpo-43852: Improve tuple creation in sqlite3 (GH-25421)

4 years agobpo-37363: Add audit events to the `http.client` module (GH-21321)
Saiyang Gou [Fri, 23 Apr 2021 10:19:08 +0000 (03:19 -0700)] 
bpo-37363: Add audit events to the `http.client` module (GH-21321)

Add audit events to the `http.client` module

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
4 years agobpo-37751: Document codecs.lookup() change in What's New in Python 3.9 (GH-23096)
Hai Shi [Fri, 23 Apr 2021 09:10:43 +0000 (17:10 +0800)] 
bpo-37751: Document codecs.lookup() change in What's New in Python 3.9 (GH-23096)

4 years agoAdd more tests. Fix code excerpt. (GH-25549)
Raymond Hettinger [Fri, 23 Apr 2021 03:02:46 +0000 (20:02 -0700)] 
Add more tests.  Fix code excerpt. (GH-25549)

4 years agoReformat idlelib colorizer (GH-25479)
E-Paine [Fri, 23 Apr 2021 01:21:53 +0000 (02:21 +0100)] 
Reformat idlelib colorizer (GH-25479)

Also replace if-then and and-or with conditional expressions.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
4 years agobpo-43917: Fix pure python equivalent for classmethod (GH-25544)
Raymond Hettinger [Fri, 23 Apr 2021 00:53:36 +0000 (17:53 -0700)] 
bpo-43917: Fix pure python equivalent for classmethod (GH-25544)

Reported by Yahor Harunovich.

4 years agobpo-39572: Address typo in CHANGELOG. (GH-24999)
Simon Charette [Fri, 23 Apr 2021 00:35:11 +0000 (20:35 -0400)] 
bpo-39572: Address typo in CHANGELOG. (GH-24999)

4 years agobpo-38222: Check specifically for a drive, not just a colon (GH-25540)
Steve Dower [Thu, 22 Apr 2021 23:30:37 +0000 (00:30 +0100)] 
bpo-38222: Check specifically for a drive, not just a colon (GH-25540)

4 years agobpo-35306: Avoid raising OSError from pathlib.Path.exists when passed an invalid...
Steve Dower [Thu, 22 Apr 2021 20:04:44 +0000 (21:04 +0100)] 
bpo-35306: Avoid raising OSError from pathlib.Path.exists when passed an invalid filename (GH-25529)

4 years agobpo-43915: Add PCbuild/blurb.bat to simplify Windows contributors (GH-25528)
Steve Dower [Thu, 22 Apr 2021 19:45:47 +0000 (20:45 +0100)] 
bpo-43915: Add PCbuild/blurb.bat to simplify Windows contributors (GH-25528)

4 years agobpo-38822: Fixed os.stat failing on inaccessible directories. (GH-25527)
Steve Dower [Thu, 22 Apr 2021 19:45:02 +0000 (20:45 +0100)] 
bpo-38822: Fixed os.stat failing on inaccessible directories. (GH-25527)

It would just fail if the path was inaccessible and had a trailing slash. It should fall back to the parent directory's metadata.

4 years agobpo-43284: Update platform.win32_ver to use _syscmd_ver instead of sys.getwindowsvers...
Shreyan Avigyan [Thu, 22 Apr 2021 16:43:37 +0000 (22:13 +0530)] 
bpo-43284: Update platform.win32_ver to use _syscmd_ver instead of sys.getwindowsversion() (GH-25500)

The sys module uses the kernel32.dll version number, which can vary from the "actual" Windows version.
Since the best option for getting the version is WMI (which is expensive), we switch back to launching cmd.exe (which is also expensive, but a lot less code on our part).
sys.getwindowsversion() is not updated to avoid launching executables from that module.

4 years agobpo-43475: Fix worst case collision behavior for NaN instances (GH-25493)
Raymond Hettinger [Thu, 22 Apr 2021 15:34:57 +0000 (08:34 -0700)] 
bpo-43475:  Fix worst case collision behavior for NaN instances (GH-25493)

4 years agoFix typo in the documentation (GH-24703)
Alperen Serkan Aksöz [Thu, 22 Apr 2021 14:36:05 +0000 (17:36 +0300)] 
Fix typo in the documentation (GH-24703)

Missing multiply symbol added

Automerge-Triggered-By: GH:merwok
4 years agobpo-28724: Doc: Move socket.send_fds and socket.recv_fds docs to right section (GH...
Saiyang Gou [Thu, 22 Apr 2021 04:08:46 +0000 (21:08 -0700)] 
bpo-28724: Doc: Move socket.send_fds and socket.recv_fds docs to right section (GH-22608)

4 years agobpo-38659: Properly re-intialize module variables in test_enum (GH-25516)
Ammar Askar [Thu, 22 Apr 2021 03:22:58 +0000 (23:22 -0400)] 
bpo-38659: Properly re-intialize module variables in test_enum (GH-25516)

Previously TestIntEnumConvert and TestStrEnumConvert would end up
converting the module level variables from their regular int form
to a `test.test_enum.X` instance after _convert would run. This
meant that after a single test ran, the next set of _convert
functions would be operating on the enum instances rather than
ints. This would cause some tests such as the one involving format
to fail when running under a mode that repeatedly runs test such
as the refleak finder.

4 years agobpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 (GH...
Steve Dower [Wed, 21 Apr 2021 23:18:20 +0000 (00:18 +0100)] 
bpo-26227: Fixes decoding of host names on Windows from ANSI instead of UTF-8 (GH-25510)

4 years agobpo-40137: Add pycore_moduleobject.h internal header (GH-25507)
Victor Stinner [Wed, 21 Apr 2021 22:52:52 +0000 (00:52 +0200)] 
bpo-40137: Add pycore_moduleobject.h internal header (GH-25507)

Add pycore_moduleobject.h internal header file with static inline
functions to access module members:

* _PyModule_GetDict()
* _PyModule_GetDef()
* _PyModule_GetState()

These functions don't check at runtime if their argument has a valid
type and can be inlined even if Python is not built with LTO.

_PyType_GetModuleByDef() uses _PyModule_GetDef().

Replace PyModule_GetState() with _PyModule_GetState() in the
extension modules, considered as performance sensitive:

* _abc
* _functools
* _operator
* _pickle
* _queue
* _random
* _sre
* _struct
* _thread
* _winapi
* array
* posix

The following extensions are now built with the Py_BUILD_CORE_MODULE
macro defined, to be able to use the internal pycore_moduleobject.h
header: _abc, array, _operator, _queue, _sre, _struct.

4 years agobpo-43756: Add new audit event for new arguments added to glob.glob (GH-25239)
Saiyang Gou [Wed, 21 Apr 2021 22:42:55 +0000 (15:42 -0700)] 
bpo-43756: Add new audit event for new arguments added to glob.glob (GH-25239)

4 years agobpo-43472: Ensure PyInterpreterState_New audit events are raised when called through...
Steve Dower [Wed, 21 Apr 2021 22:34:29 +0000 (23:34 +0100)] 
bpo-43472: Ensure PyInterpreterState_New audit events are raised when called through _xxsubinterpreters module (GH-25506)

4 years agobpo-40137: Move state lookups out of the critical path (GH-25492)
Raymond Hettinger [Wed, 21 Apr 2021 22:22:22 +0000 (15:22 -0700)] 
bpo-40137: Move state lookups out of the critical path (GH-25492)

4 years agobpo-40137: Optimize _PyType_GetModuleByDef() loop (GH-25505)
Victor Stinner [Wed, 21 Apr 2021 22:10:16 +0000 (00:10 +0200)] 
bpo-40137: Optimize _PyType_GetModuleByDef() loop (GH-25505)

PyType_Ready() now ensures that a type MRO cannot be empty.

_PyType_GetModuleByDef() no longer checks "i < PyTuple_GET_SIZE(mro)"
at the first loop iteration to optimize the most common case, when
the argument is the defining class.

4 years agobpo-40137: _PyType_GetModuleByDef() doesn't check tp_flags (GH-25504)
Victor Stinner [Wed, 21 Apr 2021 21:36:26 +0000 (23:36 +0200)] 
bpo-40137: _PyType_GetModuleByDef() doesn't check tp_flags (GH-25504)

_PyType_GetModuleByDef() no longer checks if types are heap types.

_PyType_GetModuleByDef() must only be called on a heap type created
by PyType_FromModuleAndSpec() or on its subclasses.
type_ready_mro() ensures that a static type cannot inherit from a
heap type.

4 years agodoc: Sync some missing 3.10 changes with the What's New (GH-25503)
Batuhan Taskaya [Wed, 21 Apr 2021 20:44:27 +0000 (23:44 +0300)] 
doc: Sync some missing 3.10 changes with the What's New (GH-25503)

Automerge-Triggered-By: GH:isidentical
4 years agoFix typo in whatsnew/3.10.rst (GH-25498)
JunWei Song [Wed, 21 Apr 2021 17:34:05 +0000 (01:34 +0800)] 
Fix typo in whatsnew/3.10.rst (GH-25498)

4 years agobpo-38659: [Enum] add _simple_enum decorator (GH-25497)
Ethan Furman [Wed, 21 Apr 2021 17:20:44 +0000 (10:20 -0700)] 
bpo-38659: [Enum] add _simple_enum decorator (GH-25497)

add:

* `_simple_enum` decorator to transform a normal class into an enum
* `_test_simple_enum` function to compare
* `_old_convert_` to enable checking `_convert_` generated enums

`_simple_enum` takes a normal class and converts it into an enum:

    @simple_enum(Enum)
    class Color:
        RED = 1
        GREEN = 2
        BLUE = 3

`_old_convert_` works much like` _convert_` does, using the original logic:

    # in a test file
    import socket, enum
    CheckedAddressFamily = enum._old_convert_(
            enum.IntEnum, 'AddressFamily', 'socket',
            lambda C: C.isupper() and C.startswith('AF_'),
            source=_socket,
            )

`_test_simple_enum` takes a traditional enum and a simple enum and
compares the two:

    # in the REPL or the same module as Color
    class CheckedColor(Enum):
        RED = 1
        GREEN = 2
        BLUE = 3

    _test_simple_enum(CheckedColor, Color)

    _test_simple_enum(CheckedAddressFamily, socket.AddressFamily)

Any important differences will raise a TypeError

4 years agobpo-43859: Improve the error message for IndentationError exceptions (GH-25431)
Pablo Galindo [Wed, 21 Apr 2021 14:28:21 +0000 (15:28 +0100)] 
bpo-43859: Improve the error message for IndentationError exceptions (GH-25431)

4 years agobpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490)
Pablo Galindo [Wed, 21 Apr 2021 11:41:19 +0000 (12:41 +0100)] 
bpo-38605: Revert making 'from __future__ import annotations' the default (GH-25490)

This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.

4 years agoUpdate Sphinx directive for super from function to class (GH-25489)
Géry Ogam [Tue, 20 Apr 2021 18:58:02 +0000 (20:58 +0200)] 
Update Sphinx directive for super from function to class (GH-25489)

4 years agobpo-43888: Reduce coverage collection timeout to 1h40m in GHA (GH-25471)
Sviatoslav Sydorenko [Tue, 20 Apr 2021 17:22:26 +0000 (19:22 +0200)] 
bpo-43888: Reduce coverage collection timeout to 1h40m in GHA (GH-25471)

Ref:

Signed-off-by: Sviatoslav Sydorenko <webknjaz@redhat.com>
4 years agodocs: clarify what patterns Path.glob accepts (GH-25486)
Ned Batchelder [Tue, 20 Apr 2021 16:45:45 +0000 (12:45 -0400)] 
docs: clarify what patterns Path.glob accepts (GH-25486)

Automerge-Triggered-By: GH:Yhg1s
4 years agobpo-43799: Also define SSLv3_method() (GH-25481)
Christian Heimes [Tue, 20 Apr 2021 16:10:10 +0000 (18:10 +0200)] 
bpo-43799: Also define SSLv3_method() (GH-25481)

Signed-off-by: Christian Heimes <christian@python.org>
4 years agoDocument that random.gauss is normal distribution (GH-24935)
Joonas Paalasmaa [Tue, 20 Apr 2021 14:33:54 +0000 (17:33 +0300)] 
Document that random.gauss is normal distribution (GH-24935)

4 years agoImprove the error message for choices(population, 10) (GH-25267)
Raymond Hettinger [Tue, 20 Apr 2021 03:29:48 +0000 (20:29 -0700)] 
Improve the error message for choices(population, 10) (GH-25267)

4 years agoRevert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)
Ethan Furman [Tue, 20 Apr 2021 02:12:24 +0000 (19:12 -0700)] 
Revert "bpo-38659: [Enum] add _simple_enum decorator (GH-25285)" (GH-25476)

This reverts commit dbac8f40e81eb0a29dc833e6409a1abf47467da6.

4 years agobpo-38659: [Enum] add _simple_enum decorator (GH-25285)
Ethan Furman [Tue, 20 Apr 2021 01:04:53 +0000 (18:04 -0700)] 
bpo-38659: [Enum] add _simple_enum decorator (GH-25285)

add:

_simple_enum decorator to transform a normal class into an enum
_test_simple_enum function to compare
_old_convert_ to enable checking _convert_ generated enums
_simple_enum takes a normal class and converts it into an enum:

@simple_enum(Enum)
class Color:
    RED = 1
    GREEN = 2
    BLUE = 3

_old_convert_ works much like _convert_ does, using the original logic:

# in a test file
import socket, enum
CheckedAddressFamily = enum._old_convert_(
        enum.IntEnum, 'AddressFamily', 'socket',
        lambda C: C.isupper() and C.startswith('AF_'),
        source=_socket,
        )

test_simple_enum takes a traditional enum and a simple enum and
compares the two:

# in the REPL or the same module as Color
class CheckedColor(Enum):
    RED = 1
    GREEN = 2
    BLUE = 3

_test_simple_enum(CheckedColor, Color)

_test_simple_enum(CheckedAddressFamily, socket.AddressFamily)

Any important differences will raise a TypeError

4 years agobpo-25460: Surround suggestions by quotes (GH-25473)
Pablo Galindo [Mon, 19 Apr 2021 22:35:53 +0000 (23:35 +0100)] 
bpo-25460: Surround suggestions by quotes (GH-25473)

4 years agoAdd doctests (GH-25474)
Raymond Hettinger [Mon, 19 Apr 2021 21:12:36 +0000 (14:12 -0700)] 
Add doctests (GH-25474)

4 years agobpo-43837: Reverse order of precedence table to show tightly binding operators first...
Ammar Askar [Mon, 19 Apr 2021 15:22:03 +0000 (11:22 -0400)] 
bpo-43837: Reverse order of precedence table to show tightly binding operators first (GH-25469)

4 years agobpo-40849: Expose X509_V_FLAG_PARTIAL_CHAIN ssl flag (GH-20463)
l0x [Mon, 19 Apr 2021 11:51:18 +0000 (13:51 +0200)] 
bpo-40849: Expose X509_V_FLAG_PARTIAL_CHAIN ssl flag (GH-20463)

This short PR exposes an openssl flag that  wasn't exposed. I've also updated to doc to reflect the change. It's heavily inspired by 990fcaac3c428569697f62a80fd95ab4d4b93151.

4 years agobpo-43669: More test_ssl cleanups (GH-25470)
Christian Heimes [Mon, 19 Apr 2021 06:31:29 +0000 (08:31 +0200)] 
bpo-43669: More test_ssl cleanups (GH-25470)

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-43880: Show DeprecationWarnings for deprecated ssl module features (GH-25455)
Christian Heimes [Mon, 19 Apr 2021 05:27:10 +0000 (07:27 +0200)] 
bpo-43880: Show DeprecationWarnings for deprecated ssl module features (GH-25455)

* ssl.OP_NO_SSLv2
* ssl.OP_NO_SSLv3
* ssl.OP_NO_TLSv1
* ssl.OP_NO_TLSv1_1
* ssl.OP_NO_TLSv1_2
* ssl.OP_NO_TLSv1_3
* ssl.PROTOCOL_SSLv2
* ssl.PROTOCOL_SSLv3
* ssl.PROTOCOL_SSLv23 (alias for PROTOCOL_TLS)
* ssl.PROTOCOL_TLS
* ssl.PROTOCOL_TLSv1
* ssl.PROTOCOL_TLSv1_1
* ssl.PROTOCOL_TLSv1_2
* ssl.TLSVersion.SSLv3
* ssl.TLSVersion.TLSv1
* ssl.TLSVersion.TLSv1_1
* ssl.wrap_socket()
* ssl.RAND_pseudo_bytes()
* ssl.RAND_egd() (already removed since it's not supported by OpenSSL 1.1.1)
* ssl.SSLContext() without a protocol argument
* ssl.match_hostname()
* hashlib.pbkdf2_hmac() (pure Python implementation, fast OpenSSL
  function will stay)

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-42854: Use SSL_read/write_ex() (GH-25468)
Christian Heimes [Mon, 19 Apr 2021 04:55:30 +0000 (06:55 +0200)] 
bpo-42854: Use SSL_read/write_ex() (GH-25468)

The ssl module now uses ``SSL_read_ex`` and ``SSL_write_ex``
internally. The functions support reading and writing of data larger
than 2 GB. Writing zero-length data no longer fails with a protocol
violation error.

Signed-off-by: Christian Heimes <christian@python.org>
4 years agobpo-36076: Add SNI support to ssl.get_server_certificate. (GH-16820)
juhovh [Sun, 18 Apr 2021 11:11:48 +0000 (21:11 +1000)] 
bpo-36076: Add SNI support to ssl.get_server_certificate. (GH-16820)

Many servers in the cloud environment require SNI to be used during the
SSL/TLS handshake, therefore it is not possible to fetch their certificates
using the ssl.get_server_certificate interface.

This change adds an additional optional hostname argument that can be used to
set the SNI. Note that it is intentionally a separate argument instead of
using the host part of the addr tuple, because one might want to explicitly
fetch the default certificate or fetch a certificate from a specific IP
address with the specified SNI hostname. A separate argument also works better
for backwards compatibility.

Automerge-Triggered-By: GH:tiran
4 years agobpo-43641: Stop stating that TLS 1.2 is the most modern version in docs (GH-25041)
Illia Volochii [Sun, 18 Apr 2021 07:10:53 +0000 (10:10 +0300)] 
bpo-43641: Stop stating that TLS 1.2 is the most modern version in docs (GH-25041)

Automerge-Triggered-By: GH:tiran
4 years agobpo-43362: Fix invalid free and return check in _sha3 module (GH-25463)
Christian Heimes [Sun, 18 Apr 2021 06:39:39 +0000 (08:39 +0200)] 
bpo-43362: Fix invalid free and return check in _sha3 module (GH-25463)

Commit 93d50a6a8d0c5d332c11aef267e66573a09765ac / GH-21855 changed the
order of variable definitions, which introduced a potential invalid free
bug. Py_buffer object is now initialized earlier and the result of
Keccak initialize is verified.

Co-authored-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: Christian Heimes <christian@python.org>
Co-authored-by: Alex Henrie <alexhenrie24@gmail.com>
4 years agoFix type group capture in the PEG highlight tool (GH-25464)
Pablo Galindo [Sat, 17 Apr 2021 23:18:13 +0000 (00:18 +0100)] 
Fix type group capture in the PEG highlight tool (GH-25464)

4 years agobpo-38530: Cover more error paths in error suggestion functions (GH-25462)
Pablo Galindo [Sat, 17 Apr 2021 22:28:45 +0000 (23:28 +0100)] 
bpo-38530: Cover more error paths in error suggestion functions (GH-25462)

4 years agoSmall changes to the section about SyntaxErrors in the 3.10 What's New document ...
Pablo Galindo [Sat, 17 Apr 2021 21:41:46 +0000 (22:41 +0100)] 
Small changes to the section about SyntaxErrors in the 3.10 What's New document (GH-25461)

4 years agobpo-37630: Do not skip the sha3 tests in case of missing builtin sha3 module (GH...
stratakis [Sat, 17 Apr 2021 21:27:07 +0000 (23:27 +0200)] 
bpo-37630: Do not skip the sha3 tests in case of missing builtin sha3 module (GH-20986)

Since we can use now the sha3 and shake algorithms from OpenSSL, we shouldn't
skip the tests in case the builtin algorithm was not compiled or removed.

4 years agobpo-38530: Include builtins in NameError suggestions (GH-25460)
Pablo Galindo [Sat, 17 Apr 2021 21:26:54 +0000 (22:26 +0100)] 
bpo-38530: Include builtins in NameError suggestions (GH-25460)

4 years agobpo-42333: Port _ssl extension to multiphase initialization (PEP 489) (GH-23253)
Christian Heimes [Sat, 17 Apr 2021 18:06:38 +0000 (20:06 +0200)] 
bpo-42333: Port _ssl extension to multiphase initialization (PEP 489) (GH-23253)

- Introduce sslmodule_slots
- Introduce sslmodulestate
- Use sslmodulestate
- Get rid of PyState_FindModule
- Move new structs and helpers to header file
- Use macros to access state
- Keep a strong ref to socket type

4 years agoFix typo in a dataclasses comment. (GH-25454)
Eric V. Smith [Sat, 17 Apr 2021 13:53:24 +0000 (09:53 -0400)] 
Fix typo in a dataclasses comment. (GH-25454)

4 years agobpo-43669: Remove OpenSSL 0.9 to 1.1.0 specific documentation (GH-25453)
Christian Heimes [Sat, 17 Apr 2021 13:49:50 +0000 (15:49 +0200)] 
bpo-43669: Remove OpenSSL 0.9 to 1.1.0 specific documentation (GH-25453)

4 years agoFix a typo in subprocess documentation (GH-25426)
andrei kulakov [Sat, 17 Apr 2021 09:59:18 +0000 (05:59 -0400)] 
Fix a typo in subprocess documentation (GH-25426)

Fix a typo per conversation with vstinner on IRC: in posix => on posix.

4 years agobpo-43669: PEP 644: Require OpenSSL 1.1.1 or newer (GH-23014)
Christian Heimes [Sat, 17 Apr 2021 09:36:35 +0000 (11:36 +0200)] 
bpo-43669: PEP 644: Require OpenSSL 1.1.1 or newer (GH-23014)

- Remove HAVE_X509_VERIFY_PARAM_SET1_HOST check
- Update hashopenssl to require OpenSSL 1.1.1
- multissltests only OpenSSL > 1.1.0
- ALPN is always supported
- SNI is always supported
- Remove deprecated NPN code. Python wrappers are no-op.
- ECDH is always supported
- Remove OPENSSL_VERSION_1_1 macro
- Remove locking callbacks
- Drop PY_OPENSSL_1_1_API macro
- Drop HAVE_SSL_CTX_CLEAR_OPTIONS macro
- SSL_CTRL_GET_MAX_PROTO_VERSION is always defined now
- security level is always available now
- get_num_tickets is available with TLS 1.3
- X509_V_ERR MISMATCH is always available now
- Always set SSL_MODE_RELEASE_BUFFERS
- X509_V_FLAG_TRUSTED_FIRST is always available
- get_ciphers is always supported
- SSL_CTX_set_keylog_callback is always available
- Update Modules/Setup with static link example
- Mention PEP in whatsnew
- Drop 1.0.2 and 1.1.0 from GHA tests

4 years agobpo-43522: Fix SSLContext.hostname_checks_common_name (GH-24899)
Christian Heimes [Sat, 17 Apr 2021 08:07:19 +0000 (10:07 +0200)] 
bpo-43522: Fix SSLContext.hostname_checks_common_name (GH-24899)

Fix problem with ssl.SSLContext.hostname_checks_common_name. OpenSSL does not
copy hostflags from *struct SSL_CTX* to *struct SSL*.

Signed-off-by: Christian Heimes <christian@python.org>
4 years agoFix typo in exceptions.rst (GH-25434)
Ikko Ashimine [Sat, 17 Apr 2021 06:32:53 +0000 (15:32 +0900)] 
Fix typo in exceptions.rst (GH-25434)

attemps -> attempts

4 years agobpo-43856: Add a versionadded directive to the importlib.metadata docs (GH-25445)
Zackery Spytz [Fri, 16 Apr 2021 23:13:38 +0000 (17:13 -0600)] 
bpo-43856: Add a versionadded directive to the importlib.metadata docs (GH-25445)

Use a versionadded directive to generate the text "New in version
3.8." (to match with the documentation of other modules).

Automerge-Triggered-By: GH:jaraco
4 years agobpo-43867: multiprocessing Server catchs SystemExit (GH-25441)
Victor Stinner [Fri, 16 Apr 2021 17:42:34 +0000 (19:42 +0200)] 
bpo-43867: multiprocessing Server catchs SystemExit (GH-25441)

The multiprocessing Server class now explicitly catchs SystemExit and
closes the client connection in this case. It happens when the
Server.serve_client() method reachs the end of file (EOF).

4 years agobpo-43862: Enhance -W cmdline option documentation (GH-25439)
Victor Stinner [Fri, 16 Apr 2021 17:12:14 +0000 (19:12 +0200)] 
bpo-43862: Enhance -W cmdline option documentation (GH-25439)

The -W format is "action:message:category:module:lineno".

Update also the Python manual page.

4 years agobpo-38530: Match exactly AttributeError and NameError when offering suggestions ...
Pablo Galindo [Fri, 16 Apr 2021 16:12:03 +0000 (17:12 +0100)] 
bpo-38530: Match exactly AttributeError and NameError when offering suggestions (GH-25443)

4 years agobpo-38530: Properly extend UnboundLocalError from NameError (GH-25444)
Pablo Galindo [Fri, 16 Apr 2021 15:38:55 +0000 (16:38 +0100)] 
bpo-38530: Properly extend UnboundLocalError from NameError (GH-25444)

4 years agobpo-43843: libregrtest uses threading.excepthook (GH-25400)
Victor Stinner [Fri, 16 Apr 2021 12:33:10 +0000 (14:33 +0200)] 
bpo-43843: libregrtest uses threading.excepthook (GH-25400)

test.libregrtest now marks a test as ENV_CHANGED (altered the
execution environment) if a thread raises an exception but does not
catch it. It sets a hook on threading.excepthook. Use
--fail-env-changed option to mark the test as failed.

libregrtest regrtest_unraisable_hook() explicitly flushs
sys.stdout, sys.stderr and sys.__stderr__.

4 years agobpo-43842: Fix race condition in test_logging SMTP test (GH-25436)
Victor Stinner [Fri, 16 Apr 2021 12:32:01 +0000 (14:32 +0200)] 
bpo-43842: Fix race condition in test_logging SMTP test (GH-25436)

Fix a race condition in the SMTP test of test_logging. Don't close a
file descriptor (socket) from a different thread while
asyncore.loop() is polling the file descriptor.

4 years agobpo-43844: Fix PendingDeprecationWarning in test_lib2to3 (GH-25407)
Victor Stinner [Fri, 16 Apr 2021 09:27:00 +0000 (11:27 +0200)] 
bpo-43844: Fix PendingDeprecationWarning in test_lib2to3 (GH-25407)

4 years agobpo-41282: Fix distutils.utils.byte_compile() DeprecationWarning (GH-25406)
Victor Stinner [Fri, 16 Apr 2021 09:26:40 +0000 (11:26 +0200)] 
bpo-41282: Fix distutils.utils.byte_compile() DeprecationWarning (GH-25406)

* byte_compile() of distutils.utils no longer logs a
  DeprecationWarning
* test_distutils no longer logs a DeprecationWarning

4 years agobpo-40443: Remove unused imports (GH-25429)
Victor Stinner [Fri, 16 Apr 2021 09:26:06 +0000 (11:26 +0200)] 
bpo-40443: Remove unused imports (GH-25429)

* pyclbr no longer uses copy
* typing no longer uses ast

Issue discovered by pyflakes.

4 years agobpo-41323: compiler: Reuse tuple in constant tuple folding (GH-25419)
Inada Naoki [Fri, 16 Apr 2021 05:01:04 +0000 (14:01 +0900)] 
bpo-41323: compiler: Reuse tuple in constant tuple folding (GH-25419)

4 years agoImprove the section with SyntaxError message improvements to the What's New of 3...
Pablo Galindo [Fri, 16 Apr 2021 00:28:48 +0000 (01:28 +0100)] 
Improve the section with SyntaxError message improvements to the What's New of 3.10 (GH-25428)

4 years agobpo-43823: Fix location of one of the errors for invalid dictionary literals (GH...
Pablo Galindo [Thu, 15 Apr 2021 23:45:42 +0000 (00:45 +0100)] 
bpo-43823: Fix location of one of the errors for invalid dictionary literals (GH-25427)

4 years agobpo-43822: Improve syntax errors for missing commas (GH-25377)
Pablo Galindo [Thu, 15 Apr 2021 20:38:45 +0000 (21:38 +0100)] 
bpo-43822: Improve syntax errors for missing commas (GH-25377)

4 years agoUpdate ACKS (GH-25423)
Ethan Furman [Thu, 15 Apr 2021 14:55:46 +0000 (07:55 -0700)] 
Update ACKS (GH-25423)

* Add Arseny Boykov
* Add Matthias Urlichs

4 years agobpo-43744: [Enum] fix ``_is_private`` (GH-25349)
Ethan Furman [Thu, 15 Apr 2021 13:58:33 +0000 (06:58 -0700)] 
bpo-43744: [Enum] fix ``_is_private`` (GH-25349)

``_is_private`` now returns ``False`` instead of raising an exception when enum name matches beginning of class name
as used in a private variable

4 years ago[Enum] fix doc string (GH-25376)
Ethan Furman [Thu, 15 Apr 2021 13:49:54 +0000 (06:49 -0700)] 
[Enum] fix doc string (GH-25376)

4 years agobpo-43846: Use less stack for large literals and calls (GH-25403)
Mark Shannon [Thu, 15 Apr 2021 13:28:56 +0000 (14:28 +0100)] 
bpo-43846: Use less stack for large literals and calls (GH-25403)

* Modify compiler to reduce stack consumption for large expressions.

* Add more tests for stack usage.

* Add NEWS item.

* Raise SystemError for truly excessive stack use.

4 years agobpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)
Pablo Galindo [Thu, 15 Apr 2021 13:06:39 +0000 (14:06 +0100)] 
bpo-43823: Improve syntax errors for invalid dictionary literals (GH-25378)