Commit graph

24749 commits

Author SHA1 Message Date
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
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
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)
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)
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)
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)
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
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
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
Miss Islington (bot)
9f431dd0a5
bpo-44558: Match countOf is/== treatment to c (GH-27007)
(cherry picked from commit 6bd3ecfc27)

Co-authored-by: Rupert Tombs <rupert.tombs@gmail.com>
2021-07-07 06:50:41 -07:00
Miss Islington (bot)
1f8486fd50
bpo-44558: Make the implementation consistency of operator.indexOf (GH-27012)
(cherry picked from commit 09302405d2)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2021-07-05 02:51:46 -07:00
Miss Islington (bot)
22bcc0768e
bpo-41486: zlib uses an UINT32_MAX sliding window for the output buffer (GH-26143)
* zlib uses an UINT32_MAX sliding window for the output buffer

These funtions have an initial output buffer size parameter:
- zlib.decompress(data, /, wbits=MAX_WBITS, bufsize=DEF_BUF_SIZE)
- zlib.Decompress.flush([length])

If the initial size > UINT32_MAX, use an UINT32_MAX sliding window, instead of clamping to UINT32_MAX.
Speed up when (the initial size == the actual size).

This fixes a memory consumption and copying performance regression in earlier 3.10 beta releases if someone used an output buffer larger than 4GiB with zlib.decompress.

Reviewed-by: Gregory P. Smith
(cherry picked from commit a9a69bb3ea)

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
2021-07-04 18:32:56 -07:00
Miss Islington (bot)
68330b681a
bpo-44562: Remove invalid PyObject_GC_Del from error path of types.GenericAlias … (GH-27016)
(cherry picked from commit d33943a6c3)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2021-07-04 10:55:35 -07:00
Irit Katriel
33022f9e86
[3.10] bpo-34266: [pdb] handle ValueError from shlex.split() (GH-26656) (GH-27006)
(cherry picked from commit d968a638fc)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2021-07-03 17:28:46 +01:00
Miss Islington (bot)
0856134542
bpo-44553 : Implement GC methods for types.Union (GH-26993)
(cherry picked from commit 1097384ce9)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2021-07-03 06:33:16 -07:00
Irit Katriel
7a2d2ed133
[3.10] bpo-30256: [doc] Fix formatting error in news (GH-26994) (GH-26998) 2021-07-02 18:39:52 +01:00
Miss Islington (bot)
42c26282a1
bpo-34798: [doc] clearer presentation of pprint.PrettyPrinter constru… (GH-26967) (GH-26990)
(cherry picked from commit 943e77d42d)

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2021-07-02 11:07:50 +01:00
Miss Islington (bot)
3ec3e0f83c
bpo-30256: Add manager_owned keyword arg to AutoProxy (GH-16341) (#26987)
Co-authored-by: Jordan Speicher <jordan@jspeicher.com>
(cherry picked from commit 85b920498b)

Co-authored-by: finefoot <33361833+finefoot@users.noreply.github.com>
2021-07-01 21:15:47 -07:00
Miss Islington (bot)
6843a3b930
bpo-44535: Enable building with Visual Studio 2022 on Windows (GH-26962)
(cherry picked from commit d3a95c1b6e)

Co-authored-by: Steve Dower <steve.dower@python.org>
2021-06-30 12:24:42 -07:00
Steve Dower
a5764d3d96
bpo-41180: Replace marshal code.__new__ audit event with marshal.load[s] and marshal.dumps (GH-26970) 2021-06-30 18:52:25 +01:00
Miss Islington (bot)
2df13e1211
bpo-44523: Remove the pass-through for hash() in weakref proxy objects (GH-26950)
(cherry picked from commit e2fea101fd)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-06-29 16:19:06 -07:00
Miss Islington (bot)
08aa26e435
bpo-38062: [doc] clarify that atexit uses equality comparisons internally. (GH-26935) (GH-26956)
(cherry picked from commit 12803c59d5)

Co-authored-by: Jack DeVries <58614260+jdevries3133@users.noreply.github.com>
2021-06-29 18:52:27 +01:00
Miss Islington (bot)
dc10264eb8
bpo-40939: Remove documentation for PyParser_* & add porting notes (GH-26855) (GH-26898)
I tried to be relatively thorough and give lots of links.
One reason is that this wasn't deprecated very long; also it seems people running into this tend to not be familiar with similar APIs.

(cherry picked from commit 29987f7265)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2021-06-28 11:35:52 +02:00
Miss Islington (bot)
f4b31cdbc0
bpo-44464: Remove special exclusion for flake8 in the deprecation warnings. (GH-26807) (GH-26929)
Sync with importlib_metadata 4.6.
(cherry picked from commit efe7d08d17)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
2021-06-27 18:19:24 -04:00
Miss Islington (bot)
aeb63392e7
bpo-40620: Clarify tutorial controlflow.rst `range` examples (GH-26919) (GH-26927)
(cherry picked from commit 2f49c9debc)

Co-authored-by: jdevries3133 <58614260+jdevries3133@users.noreply.github.com>
2021-06-27 20:51:16 +01:00
Miss Islington (bot)
e1f3bd2bb5
bpo-44404: tkinter after support callable classes (GH-26812)
(cherry picked from commit e9c8f784fa)

Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
2021-06-27 01:02:02 -07:00
Miss Islington (bot)
3df23b5199
[3.10] bpo-44468: Never skip base classes in typing.get_type_hints(), even with invalid .__module__. (GH-26862) (GH-26920)
(cherry picked from commit 7569c0fe91)


Co-authored-by: will-ca <willchencontact@gmail.com>

Automerge-Triggered-By: GH:gvanrossum
2021-06-26 16:52:28 -07:00
Stéphane Bidoul
6cd369c48f
[3.10] Update vendored pip to 21.1.3 (GH-26912) (gh-26917) 2021-06-26 20:58:39 +01:00
Miss Islington (bot)
88970125e7
bpo-43977: Properly update the tp_flags of existing subclasses when their parents are registered (GH-26864)
(cherry picked from commit ca2009d72a)

Co-authored-by: Brandt Bucher <brandt@python.org>
2021-06-25 08:46:23 -07:00
Miss Islington (bot)
11f1a30cdb
bpo-44456: Improve the syntax error when mixing keyword and positional patterns (GH-26793)
(cherry picked from commit 0acc258fe6)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-06-24 08:34:28 -07:00
Victor Stinner
ece3841d3d
bpo-44441: _PyImport_Fini2() resets PyImport_Inittab (GH-26874) (GH-26877)
Py_RunMain() now resets PyImport_Inittab to its initial value at
exit. It must be possible to call PyImport_AppendInittab() or
PyImport_ExtendInittab() at each Python initialization.

(cherry picked from commit 489699ca05)
2021-06-23 17:47:38 +02:00
Miss Islington (bot)
88a3342314
bpo-41621: Document defaultdict's default_factory parameter (GH-21945)
It defaults to None and is positional only.
(cherry picked from commit d1ae57027f)

Co-authored-by: Dennis Sweeney <36520290+sweeneyde@users.noreply.github.com>
2021-06-23 10:58:20 -04:00
Miss Islington (bot)
38e021ab90
bpo-44482: Fix very unlikely resource leak in glob in non-CPython implementations (GH-26843) (GH-26872)
(cherry picked from commit 5c7940257e)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2021-06-23 13:28:08 +03:00
Miss Islington (bot)
7e6cad7e30
bpo-44483: Fix crash in union object with bad `__module__` (GH-26848) (GH-26852)
(cherry picked from commit adfa1ba398)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2021-06-23 12:38:49 +03:00
Miss Islington (bot)
01858fbe31
bpo-44439: BZ2File.write() / LZMAFile.write() handle buffer protocol correctly (GH-26764) (GH-26845)
No longer use len() to get the length of the input data. For some buffer protocol objects,
the length obtained by using len() is wrong.
(cherry picked from commit bc6c12c72a)

Co-authored-by: Ma Lin <animalize@users.noreply.github.com>
2021-06-22 16:59:53 +03:00
Miss Islington (bot)
cf739332bd
bpo-44458: Ensure BUFFER_BLOCK_SIZE symbol is statically allocated. (GH-26808) (GH-26844)
* bpo-44458: Ensure BUFFER_BLOCK_SIZE symbol is statically allocated.
(cherry picked from commit 92c2e91580)

Co-authored-by: Russell Keith-Magee <russell@keith-magee.com>
2021-06-22 00:10:23 -07:00
Miss Islington (bot)
c032a12cbb
bpo-44287: asyncio test_popen() uses longer timeout (GH-26832)
Fix asyncio test_popen() of test_windows_utils by using a longer
timeout. Use military grade battle-tested test.support.SHORT_TIMEOUT
timeout rather than a hardcoded timeout of 10 seconds: it's 30
seconds by default, but it is made longer on slow buildbots.

WaitForMultipleObjects() timeout argument is in milliseconds.
(cherry picked from commit be1cb3214d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-06-21 17:22:02 -07:00
Miss Islington (bot)
1e16217204
bpo-13814: Explain why generators are not context managers (GH-26835)
Put entry in Design FAQ after a question about a context manager for assignment.
Original patch by Aidan Lowe.
(cherry picked from commit 51f45d085d)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2021-06-21 18:02:43 -04:00
Miss Islington (bot)
20a1495b8a
bpo-44395: Fix MIMEPart.as_string to pass unixfrom properly (GH-26685)
(cherry picked from commit 30f7a77f35)

Co-authored-by: Dong-hee Na <donghee.na@python.org>
2021-06-21 07:27:26 -07:00
Miss Islington (bot)
6614eac843
bpo-44434: Don't call PyThread_exit_thread() explicitly (GH-26758) (GH-26824)
_thread.start_new_thread() no longer calls PyThread_exit_thread()
explicitly at the thread exit, the call was redundant.

On Linux with the glibc, pthread_cancel() loads dynamically the
libgcc_s.so.1 library. dlopen() can fail if there is no more
available file descriptor to open the file. In this case, the process
aborts with the error message:

"libgcc_s.so.1 must be installed for pthread_cancel to work"

pthread_cancel() unwinds back to the thread's wrapping function that
calls the thread entry point.

The unwind function is dynamically loaded from the libgcc_s library
since it is tightly coupled to the C compiler (GCC). The unwinder
depends on DWARF, the compiler generates DWARF, so the unwinder
belongs to the compiler.

Thanks Florian Weimer and Carlos O'Donell for their help on
investigating this issue.
(cherry picked from commit 45a78f906d)

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-06-21 14:29:17 +02:00
Victor Stinner
9b0bbb9143
bpo-44466: Faulthandler now detects the GC (GH-26823) (GH-26826)
The faulthandler module now detects if a fatal error occurs during a
garbage collector collection (only if all_threads is true).

(cherry picked from commit d19163912b)
2021-06-21 14:23:13 +02:00
Mark Shannon
7674c83d81
bpo-44297: Fix missing line number in generator expressions (GH-26821)
* Make sure that line number is set when entering comprehension scope in compiler.

(cherry picked from commit 82e5c28af7)
2021-06-21 11:47:16 +01:00