Commit graph

110217 commits

Author SHA1 Message Date
Miss Islington (bot)
85b58292cf
bpo-44633: Fix parameter substitution of the union type with wrong types. (GH-27218) (GH-27224)
A TypeError is now raised instead of returning NotImplemented.
(cherry picked from commit 3ea5332a43)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-07-18 14:59:25 +03:00
Miss Islington (bot)
03aad3049d
[3.10] bpo-44654: Refactor and clean up the union type implementation (GH-27196) (GH-27219)
(cherry picked from commit 0fd27375ca)
2021-07-18 00:10:21 +03:00
Serhiy Storchaka
2d055ce132
[3.10] bpo-44490: Add __parameters__ and __getitem__ to types.Union (GH-26980) (GH-27207)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>.
(cherry picked from commit c45fa1a5d9)

Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2021-07-17 22:14:57 +03:00
Miss Islington (bot)
e22e8641dd
Replace @ilevkivskyi with @Fidget-Spinner as typing code owner (GH-27210) (#27212)
(cherry picked from commit 311ee83adb)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-17 11:46:25 +02:00
Miss Islington (bot)
480f29f913
bpo-41249: Fix postponed annotations for TypedDict (GH-27017) (#27204)
This fixes TypedDict to work with get_type_hints and postponed evaluation of annotations across modules.

This is done by adding the module name to ForwardRef at the time the object is created and using that to resolve the globals during the evaluation.

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
(cherry picked from commit 889036f7ef)

Co-authored-by: Germán Méndez Bravo <german.mb@gmail.com>
2021-07-17 10:48:17 +02:00
Miss Islington (bot)
efda9054b9
bpo-44655: Include the name of the type in unset __slots__ attribute errors (GH-27199) (GH-27201)
(cherry picked from commit f783428a23)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-07-17 01:01:53 +01:00
Miss Islington (bot)
a0b1d401db
bpo-44655: Don't include suggestions for attributes that are the same as the missing one (GH-27197) (GH-27198)
(cherry picked from commit 6714dec5e1)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-07-16 22:16:08 +01:00
Miss Islington (bot)
42a5514cca
Revert "bpo-44645: Check for interrupts on any potentially backwards edge. (GH-27167)" (GH-27194) (#27195)
This reverts commit 000e70ad52.
(cherry picked from commit c90c591e51)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-07-16 19:29:32 +02:00
Miss Islington (bot)
93d36a5bce
bpo-44647: Add a permanent Unicode-valued env var to regrtest (GH-27187) (#27191)
(cherry picked from commit 7915c96ffd)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-16 15:55:26 +02:00
Serhiy Storchaka
80844d1ebc
[3.10] bpo-44652: Preserve natural order of args in the union type. (GH-27185) (GH-27190)
(cherry picked from commit 0cd2d51aad)

Automerge-Triggered-By: GH:ambv
2021-07-16 06:42:04 -07:00
Miss Islington (bot)
948e39a866
bpo-40897:Give priority to using the current class constructor in inspect.signature (GH-27177) (#27189)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 6aab5f9bf3)

Co-authored-by: Weipeng Hong <hongweichen8888@sina.com>
2021-07-16 15:25:57 +02:00
Serhiy Storchaka
c3007ab3c6
[3.10] bpo-44636: Collapse union of equal types (GH-27178) (GH-27181)
The result of `int | int` is now `int`.

Fix comparison of the union type with non-hashable objects.
`int | str == {}` no longer raises a TypeError.
(cherry picked from commit d9f923280f)
2021-07-16 14:48:20 +03:00
Mark Shannon
37686f78cc
bpo-44626: Merge basic blocks earlier to enable better handling of exit blocks without line numbers (GH-27138) (GH-27182)
(cherry picked from commit a86f7dae0a)
2021-07-16 11:49:10 +01:00
Mark Shannon
0e349ea554
[3.10] bpo-44645: Check for interrupts on any potentially backwards edge. (GH-27167) (GH-27183)
(cherry picked from commit 000e70ad52)

Co-authored-by: Mark Shannon <mark@hotpy.org>
2021-07-16 11:48:46 +01:00
Miss Islington (bot)
705988056e
bpo-44646: Fix the hash of the union type. (GH-27179) (#27180)
It no longer depends on the order of arguments.
hash(int | str) == hash(str | int)

Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
(cherry picked from commit aeaa553d65)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-07-16 11:02:59 +02:00
Miss Islington (bot)
6aa59c68dc
bpo-44184: Apply GH-26274 to the non-GC-type branch of subtype_dealloc (GH-27165) (GH-27174)
The non-GC-type branch of subtype_dealloc is using the type of an object after freeing in the same unsafe way as GH-26274 fixes. (I believe the old news entry covers this change well enough.)

https://bugs.python.org/issue44184
(cherry picked from commit 074e7659f2)

Co-authored-by: T. Wouters <thomas@python.org>
2021-07-16 01:18:16 +02:00
Miss Islington (bot)
356bdff1e9
bpo-44647: Fix test_httpservers failing on Unicode characters in os.environ on Windows (GH-27161) (#27169)
GH-23638 introduced a new test for Accept: headers in CGI HTTP servers. This test serializes all of os.environ on the server side. For non-UTF8 locales this can fail for some Unicode characters found in environment variables. This change fixes the HTTP_ACCEPT test.
(cherry picked from commit 82b218f36c)

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2021-07-15 22:09:26 +02:00
Mark Shannon
47695e3c88
bpo-44622: Set line number of END_ASYNC_FOR to match that of iterator. (GH-27160) (GH-27163)
(cherry picked from commit f333ab0f2e)
2021-07-15 16:54:38 +02:00
Miss Islington (bot)
2ce8af3cbc
bpo-42073: allow classmethod to wrap other classmethod-like descriptors (GH-27115) (GH-27162)
Patch by Erik Welch.

bpo-19072 (GH-8405) allows `classmethod` to wrap other descriptors, but this does
not work when the wrapped descriptor mimics classmethod.  The current PR fixes
this.

In Python 3.8 and before, one could create a callable descriptor such that this
works as expected (see Lib/test/test_decorators.py for examples):
```python
class A:
    @myclassmethod
    def f1(cls):
        return cls

    @classmethod
    @myclassmethod
    def f2(cls):
        return cls
```
In Python 3.8 and before, `A.f2()` return `A`. Currently in Python 3.9, it
returns `type(A)`.  This PR make `A.f2()` return `A` again.

As of GH-8405, classmethod calls `obj.__get__(type)` if `obj` has `__get__`.
This allows one to chain `@classmethod` and `@property` together.  When
using classmethod-like descriptors, it's the second argument to `__get__`--the
owner or the type--that is important, but this argument is currently missing.
Since it is None, the "owner" argument is assumed to be the type of the first
argument, which, in this case, is wrong (we want `A`, not `type(A)`).

This PR updates classmethod to call `obj.__get__(type, type)` if `obj` has
`__get__`.

Co-authored-by: Erik Welch <erik.n.welch@gmail.com>
(cherry picked from commit b83861f026)
2021-07-15 15:42:11 +02:00
Miss Islington (bot)
3026d1381e
Fix osx_framework_user include to match distutils (GH-27093) (GH-27159)
(cherry picked from commit 28544609cb)

Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
2021-07-15 12:10:57 +02:00
Miss Islington (bot)
cc1a47c849
bpo-44632: Fix support of TypeVar in the union type (GH-27139) (GH-27143)
int | TypeVar('T') returns now an instance of types.Union
instead of typing.Union.
(cherry picked from commit a158b20019)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-07-15 10:25:22 +03:00
Serhiy Storchaka
6dec525582
[3.10] bpo-44635: Convert None to NoneType in the union type constructor (GH-27136). (GH-27142)
(cherry picked from commit b81cac0560)
2021-07-15 10:15:14 +03:00
Miss Islington (bot)
016af14d93
[3.10] bpo-44589: raise a SyntaxError when mapping patterns have duplicate literal keys (GH-27131) (GH-27157)
(cherry picked from commit 2693132292)


Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>

Automerge-Triggered-By: GH:brandtbucher
2021-07-14 18:00:35 -07:00
Miss Islington (bot)
ff7af2203c
bpo-34932: Add socket.TCP_KEEPALIVE for macOS (GH-25079)
(cherry picked from commit d59d7374a3)

Co-authored-by: Shane Harvey <shnhrv@gmail.com>
2021-07-14 16:15:31 -07:00
Erlend Egeberg Aasland
02e4c0cad3
[3.10] Fix docstring typo in sqlite3.Connection.executescript/sqlite3.Cursor.executescript (GH-27147) (GH-27151)
Both `executescript` methods contain the same docstring typo:
_"Executes a multiple SQL statements at once."_ => _"Executes multiple SQL statements at once."_

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2021-07-15 00:02:01 +01:00
Miss Islington (bot)
3048b8bd2a
bpo-44639: fix typo in sqlite.rst (transation => transaction) (GH-27145) (GH-27148)
To my understanding, this is supposed to say "transaction".

See the relevant source:

a158b20019/Modules/_sqlite/connection.cGH-L1434-L1467
(cherry picked from commit 1ca27f2647)

Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>

Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
2021-07-14 23:22:50 +01:00
Pablo Galindo Salgado
03c85d49ed
[3.10] Add release highlights for the 3.10 what's new document (GH-27150) (GH-27152)
(cherry picked from commit 2b47af6398)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-07-14 23:22:12 +01:00
Mark Shannon
794ff7d505
bpo-44616: Mark all clean up instructions at end of named exception block as artificial (GH-27109) (GH-27135)
(cherry picked from commit e5862f79c1)
2021-07-14 11:43:56 +01:00
Miss Islington (bot)
7e1d6308a3
bpo-44608: Fix memory leak in _tkinter._flatten() (GH-27107)
if it is called with a sequence or set, but not list or tuple.
(cherry picked from commit f572cbf1fa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-07-13 22:40:10 -07:00
Miss Islington (bot)
b42eee78e7
bpo-44606: Fix __instancecheck__ and __subclasscheck__ for the union type. (GH-27120)
* Fix issubclass() for None.
  E.g. issubclass(type(None), int | None) returns now True.
* Fix issubclass() for virtual subclasses.
  E.g. issubclass(dict, int | collections.abc.Mapping) returns now True.
* Fix crash in isinstance() if the check for one of items raises exception.
(cherry picked from commit 81989058de)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-07-13 21:55:45 -07:00
Miss Islington (bot)
bb260c2a21
[3.10] bpo-44630: Fix assertion errors in csv module (GH-27127) (GH-27129)
Fix incorrect handling of exceptions when interpreting dialect objects in
the csv module. Not clearing exceptions between calls to
PyObject_GetAttrString() causes assertion failures in pydebug mode (or with
assertions enabled).

Add a minimal test that would've caught this (passing None as dialect, or
any object that isn't a csv.Dialect subclass, which the csv module allows
and caters to, even though it is not documented.) In pydebug mode, the test
triggers the assertion failure in the old code.

Contributed-By: T. Wouters [Google]
(cherry picked from commit 0093876328)


Co-authored-by: T. Wouters <thomas@python.org>

Automerge-Triggered-By: GH:gpshead
2021-07-13 16:18:28 -07:00
Miss Islington (bot)
425756abdc
bpo-44572: On Windows, disconnect STDIN in platform._syscmd_ver() to prevent erroneous STDIN consumption (GH-27092) (GH-27124)
(cherry picked from commit 0ee0a740e1)

Co-authored-by: Konstantin-Glukhov <glukhov.k@gmail.com>
2021-07-13 20:48:23 +01:00
Miss Islington (bot)
9b369c952c
bpo-43126: Expand docs on io.IOBase.readlines() method (GH-27061) (GH-27113)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
(cherry picked from commit 3b5b99da4b)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
2021-07-13 16:41:12 +02:00
Miss Islington (bot)
1cc6769e41
bpo-38741: Definition of multiple ']' in header configparser (GH-17129) (#27110)
Co-authored-by: Jason Killen <jason.killen@windsorcircle.com>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
(cherry picked from commit 2924bb1a56)

Co-authored-by: jsnklln <jsnklln@gmail.com>
2021-07-13 16:35:30 +02:00
Miss Islington (bot)
f514addfbc
bpo-44514: Add doctest testcleanup for configparser and bz2 (GH-26909) (GH-27112)
Add testcleanup section to configparser and bz2 documentation which
removes temporary files created in the filesystem when 'make doctest'
is run.
(cherry picked from commit 48a5aa7f12)

Co-authored-by: Kevin Follstad <kfollstad@gmail.com>
2021-07-13 16:34:10 +02:00
Miss Islington (bot)
4a0f1df952
bpo-44472: Fix ltrace functionality when exceptions are raised (GH-26822) (GH-26830)
(cherry picked from commit 06cda808f1)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-07-13 09:43:26 +01:00
Miss Islington (bot)
7223ce3b3f
bpo-44613: Make importlib.metadata non-provisional (GH-27101) (#27106)
* importlib.metadata is no longer provisional as of 3.10
* Add NEWS entry
(cherry picked from commit f6954cdfc5)

Co-authored-by: Barry Warsaw <barry@python.org>

Co-authored-by: Barry Warsaw <barry@python.org>
2021-07-12 17:40:51 -07:00
Ethan Furman
92abe4c44f
[Enum] add news entry for enum module reversion (GH-27099) 2021-07-12 11:07:03 -07:00
Miss Islington (bot)
721d4796be
bpo-42194: Add "New in version: 3.9" to argparse.BooleanOptionalAction (GH-23026) (#27097)
(cherry picked from commit da2e673c53)

Co-authored-by: David Sanders <shang.xiao.sanders@gmail.com>
2021-07-12 17:43:16 +02:00
Miss Islington (bot)
443db64f49
bpo-26329: update os.path.normpath documentation (GH-20138) (GH-27094)
(cherry picked from commit 66c5853406)

Co-authored-by: Furkan Onder <furkanonder@protonmail.com>
2021-07-12 17:07:46 +02:00
Miss Islington (bot)
42da46ed52
bpo-29753: revert 0d7ad9f (GH-19850) (GH-27085)
This reverts commit 0d7ad9fb38 as it has a regression.

See https://github.com/python/cpython/pull/19850GH-issuecomment-869410686
(cherry picked from commit e14d5ae544)

Co-authored-by: Filipe Laíns <lains@archlinux.org>
2021-07-11 10:47:06 -07:00
Miss Islington (bot)
1577259cc5
bpo-43219: shutil.copyfile, raise a less confusing exception instead of IsADirectoryError (GH-27049)
Fixes the misleading IsADirectoryError to be FileNotFoundError.
(cherry picked from commit 248173cc04)

Co-authored-by: andrei kulakov <andrei.avk@gmail.com>
2021-07-09 21:07:35 -07:00
Pablo Galindo
bff66d0c3f
Post 3.10.0b4 2021-07-10 02:27:16 +01:00
Pablo Galindo
2ba4b20854
Python 3.10.0b4 2021-07-10 01:51:07 +01:00
Miss Islington (bot)
2a722d4fab
bpo-44317: Improve tokenizer errors with more informative locations (GH-26555) (GH-27079)
(cherry picked from commit f24777c2b3)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
2021-07-10 01:47:33 +01:00
Batuhan Taskaya
2f7636887e
[3.10] bpo-43897: ast validation for pattern matching nodes (GH-27074)
(cherry picked from commit 8dcb7d9808)

Co-authored-by: Batuhan Taskaya <batuhan@python.org>
2021-07-10 01:16:15 +01:00
Miss Islington (bot)
662ace1093
Doc: Fix wrong exception used in example. (GH-26572)
(cherry picked from commit 15f0fc571c)

Co-authored-by: Julien Palard <julien@palard.fr>
2021-07-08 21:51:26 -07:00
Mark Shannon
9f2c63b258
bpo-44570: Fix line tracing for forward jumps to duplicated tails (GH-27067) 2021-07-08 19:21:22 +01:00
Pablo Galindo
61eb9b5dfd
[3.10] bpo-44446: support lineno being None in traceback.FrameSummary (GH-26781) (GH-27072)
As of 088a15c49d, lineno is None instead
of -1 if there is no line number.

Signed-off-by: Filipe Laíns <lains@riseup.net>.
(cherry picked from commit 91a8f8c16c)

Co-authored-by: Filipe Laíns <lains@riseup.net>

Co-authored-by: Filipe Laíns <lains@riseup.net>
2021-07-08 17:47:12 +01:00
Miss Islington (bot)
08697ac5d1
bpo-44582: Accelerate mimetypes.init on Windows with a native accelerator (GH-27059)
(cherry picked from commit bbf2fb6c7a)

Co-authored-by: Steve Dower <steve.dower@python.org>
2021-07-08 09:13:06 -07:00