Commit Graph

107870 Commits

Author SHA1 Message Date
Erik Welch f210e7f15e bpo-42073: allow classmethod to wrap other classmethod-like descriptors.
bpo-19072 (#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 #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__`.
2020-10-18 16:41:50 -05:00
Anthony Sottile 7c949020ef
bpo-40492: Fix --outfile with relative path when the program changes it working dir (GH-19910)
(cherry picked from commit 3c0ac18504)
2020-10-19 00:16:22 +03:00
Miss Skeleton (bot) e5c7ac7a22
3.9 whatsnew: fix bpo issue for AST change (GH-22742) (GH-22749)
(cherry picked from commit 67f04878de)

Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2020-10-18 20:16:54 +03:00
Miss Skeleton (bot) a055ced9d4
bpo-41966: Fix pickling pure datetime.time subclasses (GH-22731) (GH-22747)
(cherry picked from commit c304c9a7ef)

Co-authored-by: scaramallion <scaramallion@users.noreply.github.com>
2020-10-18 18:32:56 +03:00
Miss Skeleton (bot) 6a2aa4994e
bpo-42065: Fix incorrectly formatted _codecs.charmap_decode error message (GH-19940)
(cherry picked from commit 3635388f52)

Co-authored-by: Max Bernstein <tekknolagi@users.noreply.github.com>
2020-10-18 09:00:18 +03:00
Miss Skeleton (bot) 0fbddb14dc
bpo-40341: Remove some "discouraged solutions" in Doc/faq/programming.rst (GH-22726) (GH-22727)
(cherry picked from commit a22a19f354)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2020-10-16 13:27:59 -07:00
Miss Skeleton (bot) dff9161821
bpo-42011: Update documentation of logging.Filter.filter() (GH-22692) (GH-22725)
(cherry picked from commit e9959c7118)
2020-10-16 18:21:49 +01:00
Xie Yanbo b30934e9af
[3.9] Fix incorrect parameter name (GH-22613) (GH-22628)
Automerge-Triggered-By: @Mariatta
(cherry picked from commit a42759351b)

Co-authored-by: Xie Yanbo <xieyanbo@gmail.com>
2020-10-15 22:55:28 +05:30
Miss Skeleton (bot) 78723b378b
Minor clarification (GH-22708) (GH-22709) 2020-10-15 00:09:33 -07:00
Miss Skeleton (bot) d197b2bb3e
bpo-41984: GC track all user classes (GH-22701/GH-22702)
(cherry picked from commit c13b847a6f)
2020-10-14 20:38:25 -07:00
Miss Skeleton (bot) f07448bef4
bpo-41894: Fix UnicodeDecodeError while loading native module (GH-22466)
When running in a non-UTF-8 locale, if an error occurs while importing a
native Python module (say because a dependent share library is missing),
the error message string returned may contain non-ASCII code points
causing a UnicodeDecodeError.

PyUnicode_DecodeFSDefault is used for buffers which may contain
filesystem  paths. For consistency with os.strerror(),
PyUnicode_DecodeLocale is used for buffers which contain system error
messages. While the shortname parameter is always encoded in ASCII
according to PEP 489, it is left decoded using PyUnicode_FromString to
minimize the changes and since it should not affect the decoding (albeit
_potentially_ slower).

In dynload_hpux, since the error buffer contains a message generated
from a static ASCII string and the module filesystem path,
PyUnicode_DecodeFSDefault is used instead of PyUnicode_DecodeLocale as
is used elsewhere.

* bpo-41894: Fix bugs in dynload error msg handling

For both dynload_aix and dynload_hpux, properly handle the possibility
that decoding strings may return NULL and when such an error happens,
properly decrement any previously decoded strings and return early.

In addition, in dynload_aix, ensure that we pass the decoded string
*object* pathname_ob to PyErr_SetImportError instead of the original
pathname buffer.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 2d2af320d9)

Co-authored-by: Kevin Adler <kadler@us.ibm.com>
2020-10-14 19:25:45 -07:00
Miss Skeleton (bot) 69f040c000
Update timings for the final release (GH-22697) (GH-22698) 2020-10-14 10:29:10 -07:00
Miss Skeleton (bot) 391a544f2a
bpo-41993: Fix possible issues in remove_module() (GH-22631) (GH-22647)
* PyMapping_HasKey() is not safe because it silences all exceptions and can return incorrect result.
* Informative exceptions from PyMapping_DelItem() are overridden with RuntimeError and
  the original exception raised before calling remove_module() is lost.
* There is a race condition between PyMapping_HasKey() and PyMapping_DelItem().
(cherry picked from commit 8287aadb75)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-14 12:09:44 +03:00
Miss Skeleton (bot) 881a13cad5
bpo-41939: always enable test_site.test_license_exists_at_url (GH-22688)
(cherry picked from commit 6a48518e8d)

Co-authored-by: Ned Deily <nad@python.org>
2020-10-13 18:59:41 -07:00
Miss Skeleton (bot) 270a2fbc55
Improve recipe readability (GH-22685) (GH-22686) 2020-10-13 17:19:05 -07:00
Miss Skeleton (bot) 5f0007f0f8
Add recipe for a version of random() with a larger population (GH-22664) (GH-22684) 2020-10-13 12:38:13 -07:00
Miss Skeleton (bot) afe86066e7
bpo-41995: Fix null ptr deref in tracemalloc_copy_trace() (GH-22660)
Fix a null pointer dereference in tracemalloc_copy_trace()
of _tracemalloc.
(cherry picked from commit 66c28f50c7)

Co-authored-by: Yunlongs <lylgood@foxmail.com>
2020-10-13 00:09:08 -07:00
Miss Skeleton (bot) 15ef19f7d7
Fix typo in "Context manager types" section in typing.rst (GH-22676)
Fix typo in the "Context manager types" section in `typing.rst`.

Automerge-Triggered-By: @gvanrossum
(cherry picked from commit ba06a70c82)

Co-authored-by: Saiyang Gou <gousaiyang@163.com>
2020-10-12 16:55:24 -07:00
Saiyang Gou 1c217652b6
[3.9] bpo-39481: Fix duplicate SimpleQueue type in test_genericalias.py (GH-22619) (#22624)
There are two different `SimpleQueue` types imported (from `multiprocessing.queues` and `queue`) in `Lib/test/test_genericalias.py`, the second one shadowing the first one, making the first one not actually tested. Fix by using different names.

Automerge-Triggered-By: @gvanrossum.
(cherry picked from commit b2c0a43699)

Co-authored-by: Saiyang Gou <gousaiyang@163.com>
2020-10-12 16:52:03 -07:00
Miss Skeleton (bot) 8a12503b45
bpo-42015: Reorder dereferencing calls in meth_dealloc, to make sure m_self is kept alive long enough (GH-22670)
(cherry picked from commit 04b8631d84)

Co-authored-by: Yannick Jadoul <yannick.jadoul@belgacom.net>
2020-10-12 14:29:01 -07:00
Miss Skeleton (bot) 85d59644d9
[doc] Fix typo in the graphlib docs (GH-22661) (GH-22669)
Automerge-Triggered-By: @pablogsal
(cherry picked from commit abe244c458)

Co-authored-by: linchiwei123 <40888469+linchiwei123@users.noreply.github.com>

Co-authored-by: linchiwei123 <40888469+linchiwei123@users.noreply.github.com>
2020-10-12 21:27:05 +01:00
Miss Skeleton (bot) 372a9e2135
Fix typo (GH-22582)
/af/of/s

Automerge-Triggered-By: @Mariatta
(cherry picked from commit 8197a93208)

Co-authored-by: Gaurav Kamath <st0le@users.noreply.github.com>
2020-10-12 06:53:10 -07:00
Victor Stinner f5393dc2a0
bpo-41739: Fix test_logging.test_race_between_set_target_and_flush() (GH-22655) (GH-22656)
The test now waits until all threads complete to avoid leaking
running threads.

Also, use regular threads rather than daemon threads.

(cherry picked from commit 13ff396c01)
2020-10-12 05:30:48 +01:00
Miss Skeleton (bot) 4af6729219
bpo-41971: Fix test failure in test.test_tools.test_c_analyzer when mutating global state (GH-22652) (GH-22653)
(cherry picked from commit 47ecfd8030)

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

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-10-11 21:54:35 +01:00
Miss Skeleton (bot) f1c70cf9e8
Fix typo in typing.rst (GH-22625)
(cherry picked from commit 0ff8a3b374)

Co-authored-by: abdo <abd.nh25@gmail.com>
2020-10-11 01:06:48 -07:00
Miss Skeleton (bot) ebc5a6b59e
bpo-41986: Add Py_FileSystemDefaultEncodeErrors and Py_UTF8Mode back to limited API (GH-22621)
(cherry picked from commit 637a09b0d6)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-10 07:32:09 -07:00
Karthikeyan Singaravelan 20bdeedfb4
[3.9] bpo-41371: Handle lzma lib import error in test_zoneinfo.py (GH-21734) (GH-22039)
(cherry picked from commit 5f0769a)

Co-authored-by: Nathan M <nathanmaynes@gmail.com>
2020-10-10 10:09:09 +05:30
Miss Skeleton (bot) 1f75fc7a9d
bpo-41831: Restore str implementation of __str__ in tkinter.EventType (GH-22355)
(cherry picked from commit eb38c6b7aa)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-09 13:20:48 -07:00
Miss Skeleton (bot) 43c3eafa1b
bpo-41831: Add tests for tkinter.Event.__repr__ (GH-22354) (GH-22617)
(cherry picked from commit f25323a307)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-09 22:56:19 +03:00
Batuhan Taskaya 42157b9eaa
[3.9] bpo-41979: Accept star-unpacking on with-item targets (GH-22611) (GH-22612)
Co-authored-by: Batuhan Taskaya <batuhanosmantaskaya@gmail.com>

Automerge-Triggered-By: @pablogsal
2020-10-09 03:31:07 -07:00
Karthikeyan Singaravelan c6f41e62f5
[3.9] bpo-41970: Avoid test failure in test_lib2to3 if the module is already imported (GH-22595) (GH-22609)
(cherry picked from commit 4a9f82f50d)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-10-09 11:08:42 +01:00
Miss Skeleton (bot) 3da210b69f
Fix the attribute names in the docstring of GenericAlias (GH-22594)
(cherry picked from commit 77f0a23e7a)

Co-authored-by: Mikhail Golubev <qsolo825@gmail.com>
2020-10-08 15:02:26 -07:00
Miss Skeleton (bot) 089c38677d
bpo-41557: Update Windows installer to use SQLite 3.33.0 (GH-21960)
(cherry picked from commit bfe6e03cd6)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2020-10-08 12:02:33 -07:00
Miss Skeleton (bot) a4ac5fadf5
bpo-41976: Fix the fallback to gcc of ctypes.util.find_library when using gcc>9 (GH-22598)
(cherry picked from commit 27ac19cca2)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-10-08 11:55:24 -07:00
Miss Skeleton (bot) 15e091f63f
bpo-41306: Allow scale value to not be rounded (GH-21715)
This fixes the test failure with Tk 6.8.10 which is caused by changes to how Tk rounds the `from`, `to` and `tickinterval` arguments. This PR uses `noconv` if the patchlevel is greater than or equal to 8.6.10 (credit to Serhiy for this idea as it is much simpler than what I previously proposed).

Going into more detail for those who want it, the Tk change was made in [commit 591f68c](591f68cb38) and means that the arguments listed above are rounded relative to the value of `from`. However, when rounding the `from` argument ([line 623](591f68cb38/generic/tkScale.cGH-L623)), it is rounded relative to itself (i.e. rounding `0`) and therefore the assigned value for `from` is always what is given (no matter what values of `from` and `resolution`).

Automerge-Triggered-By: @pablogsal
(cherry picked from commit aecf036738)

Co-authored-by: E-Paine <63801254+E-Paine@users.noreply.github.com>
2020-10-08 09:50:36 -07:00
Miss Skeleton (bot) 5b1fdcacfc
bpo-41376: Fix the documentation of `site.getusersitepackages()` (GH-21602)
`site.getusersitepackages()` returns the location of the user-specific site-packages directory
even when the user-specific site-packages is disabled.

```
$ python -s -m site
sys.path = [
    '/home/user/conda/lib/python37.zip',
    '/home/user/conda/lib/python3.7',
    '/home/user/conda/lib/python3.7/lib-dynload',
    '/home/user/conda/lib/python3.7/site-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.7/site-packages' (doesn't exist)
ENABLE_USER_SITE: False
```

It was not practical to prevent the function from returning None if user-specific site-packages are disabled, since there are other uses of the function which are relying on this behaviour (e.g. `python -m site`).
(cherry picked from commit 35f041dd01)

Co-authored-by: Phil Elson <pelson.pub@gmail.com>
2020-10-08 00:00:28 -07:00
Miss Skeleton (bot) b664a1df4e
bpo-41944: No longer call eval() on content received via HTTP in the CJK codec tests (GH-22566)
(cherry picked from commit 2ef5caa58f)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2020-10-06 05:37:36 -07:00
Miss Skeleton (bot) 4aad1e5770
bpo-41584: clarify when the reflected method of a binary arithemtic operator is called (GH-22505)
(cherry picked from commit d02d824e05)

Co-authored-by: Brett Cannon <brett@python.org>
2020-10-05 10:05:50 -07:00
Miss Skeleton (bot) 10b4136bfa
bpo-41939: Fix test_site.test_license_exists_at_url() (GH-22559) (#22567)
Call urllib.request.urlcleanup() to reset the global
urllib.request._opener.
(cherry picked from commit 1fce240d6c)

Co-authored-by: Victor Stinner <vstinner@python.org>
2020-10-05 18:49:41 +02:00
Łukasz Langa 1691435fe7
Post 3.9.0 2020-10-05 18:07:40 +02:00
Łukasz Langa 79dd0dbc32 Python 3.9.0
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEE4/8oOcBIslwITevpsmmV4xAlBWgFAl97Nt8ACgkQsmmV4xAl
 BWhFGA//cXN7hkXzURCN2z7GCHaAUm/jnJ+7xta8oVlSjpJT0OjJsxojnc+XpQau
 2bCW2o3uxhiM6qr7N2Vtj7ar2+4x8eTN08i+6phpFcLn8WzfsYQYA7Vc5RDsb8nr
 ty8JBu+xdHsP3RIfBViCotCXOhfEJZwqQnvMeGuwmHPd5w2s1GCbnPuILnWZEDtF
 tpOxJZjEUjd2gEyXKB1q5fCfMJvb73vKBcxVeMM6nbsI9egp6CeIAJC0B2xiBGGw
 8nzfvGiqMcHhBfCwKw3mER5FQQPbVyYbHSDPUm8lgdel/hMZ3dIkg686/bOQXzri
 H3xyb46PGCZNG8I5J1gQD0mcyYfXzYBNUvzlN6xRlyxanPEvX3wH+KeliRqfTQZb
 /GU9fPqrdznvMS7UoXM4R17+qHOtc/CNX53vqMX0aKioq9FZDsfRHPtvAC6zDKtP
 0ibkGU510FUf7Yt5Sh4kSB12RNNXjhBgzVSDmVcite00FYF9vKHxn0WrzTx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'v3.9.0' into 3.9

Python 3.9.0
2020-10-05 18:05:58 +02:00
Łukasz Langa 9cf6752276
Python 3.9.0 2020-10-05 17:07:58 +02:00
Miss Skeleton (bot) 75dd70e1ce
bpo-41774: Tweak new programming FAQ entry (GH-22562)
Remove mention of space in "remove multiple items from list".
(cherry picked from commit 060937da98)

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2020-10-05 07:53:26 -07:00
Miss Skeleton (bot) b6d37e15cf
bpo-41557: Update macOS installer to use SQLite 3.33.0 (GH-21959) (GH-22560)
(cherry picked from commit 9a7642667a)

Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
2020-10-05 05:01:51 -04:00
Miss Skeleton (bot) d5719247ba
bpo-41892: Clarify that an example in the ElementTree docs explicitly avoids modifying an XML tree while iterating over it. (GH-22464) (GH-22554)
(cherry picked from commit 40db798692)

Co-authored-by: scoder <stefan_ml@behnel.de>

Co-authored-by: scoder <stefan_ml@behnel.de>
2020-10-04 19:56:56 -04:00
Serhiy Storchaka 7aa22ba923
[3.9] bpo-41909: Enable previously disabled recursion checks. (GH-22536) (GH-22550)
Enable recursion checks which were disabled when get __bases__ of
non-type objects in issubclass() and isinstance() and when intern
strings. It fixes a stack overflow when getting __bases__ leads
to infinite recursion.

Originally recursion checks was disabled for PyDict_GetItem() which
silences all errors including the one raised in case of detected
recursion and can return incorrect result. But now the code uses
PyDict_GetItemWithError() and PyDict_SetDefault() instead.
(cherry picked from commit 9ece9cd65c)
2020-10-05 01:27:38 +03:00
Miss Skeleton (bot) f3a6b7fc0b
Typo fix (GH-22496)
Multiple typo fixes in code comments

Automerge-Triggered-By: @Mariatta
(cherry picked from commit 619f98045d)

Co-authored-by: Manan Kumar Garg <62146744+MananKGarg@users.noreply.github.com>
2020-10-04 14:51:38 -07:00
Miss Islington (bot) e8165e79f5
bpo-37062: Enum: add extended AutoNumber example (GH-22349) (GH-22370)
(cherry picked from commit 62e40d8450)

Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
2020-10-04 19:19:18 +02:00
Miss Islington (bot) c549527ae2
bpo-41819: Fix compiler warning in init_dump_ascii_wstr() (GH-22332)
Fix the compiler warning:

format specifies type `wint_t` (aka `int`) but the argument has type `unsigned int`
(cherry picked from commit c322948892)

Co-authored-by: Samuel Marks <807580+SamuelMarks@users.noreply.github.com>
2020-10-04 19:17:27 +02:00
Pablo Galindo 168a8383c8
[3.9] bpo-41490: Bump vendored pip to version 20.2.3 (GH-22527). (GH-22544)
(cherry picked from commit 2cc6dc9896)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2020-10-04 19:12:34 +02:00