Commit Graph

29582 Commits

Author SHA1 Message Date
Tian Gao 0fc58c66ba
gh-103693: Add convenience variable feature to `pdb` (#103694) 2023-05-03 15:04:50 +01:00
Petr Viktorin 524a7f77fd
gh-103968: Deprecate creating heap types whose metaclass has custom tp_new. (GH-103972)
(That's a mouthful of an edge case!)

Co-authored-by: Barney Gale <barney.gale@gmail.com>
2023-05-03 15:17:14 +02:00
Barry Warsaw 326997829d
gh-98040: Remove find_loader, find_module and other deprecated APIs (#98059)
* Remove deprecated classes from pkgutil
* Remove some other PEP 302 obsolescence
* Use find_spec instead of load_module
* Remove more tests of PEP 302 obsolete APIs
* Remove another bunch of tests using obsolete load_modules()
* Remove deleted names from __all__
* Remove obsolete footnote
* imp is removed
* Remove `imp` from generated stdlib names
* What's new and blurb
* Update zipimport documentation for the removed methods
* Fix some Windows tests
* Remove any test (or part of a test) that references `find_module()`.
* Use assertIsNone() / assertIsNotNone() consistently.
* Update Doc/reference/import.rst
* We don't need pkgutil._get_spec() any more either
*  test.test_importlib.fixtures.NullFinder
* ...BadLoaderFinder.find_module
* ...test_api.InvalidatingNullFinder.find_module
* ...test.test_zipimport test of z.find_module
* Suppress cross-references to find_loader and find_module
* Suppress cross-references to Finder
* Suppress cross-references to pkgutil.ImpImporter and pkgutil.ImpLoader

---------

Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
2023-05-03 04:55:22 -07:00
Tian Gao bcea36f8db
gh-103845: Remove line & instruction instrumentations before adding them back (GH-103851) 2023-05-03 10:51:47 +01:00
Paul Ganssle 65c4a2b326 GH-84976: Move Lib/datetime.py to Lib/_pydatetime
This breaks the tests, but we are keeping it as a separate commit so
that the move operation and editing of the moved files are separate, for
a cleaner history.
2023-05-03 03:09:45 -06:00
Tim Hoffmann fdb3ef8c0f
gh-82012: Deprecate bitwise inversion (~) of bool (#103487)
The bitwise inversion operator on bool returns the bitwise inversion of the
underlying int value; i.e. `~True == -2` such that `bool(~True) == True`.

It's a common pitfall that users mistake `~` as negation operator and actually
want `not`. Supporting `~` is an artifact of bool inheriting from int. Since there
is no real use-case for the current behavior, let's deprecate `~` on bool and
later raise an error. This removes a potential source errors for users.

Full reasoning: https://github.com/python/cpython/issues/82012#issuecomment-1258705971

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-05-03 00:00:42 -07:00
andrei kulakov af886ffa06
GH-89769: `pathlib.Path.glob()`: do not follow symlinks when checking for precise match (GH-29655)
Co-authored-by: Barney Gale <barney.gale@gmail.com>
2023-05-03 04:50:10 +01:00
Ethan Furman c7c3a60c88
gh-104049: do not expose on-disk location from SimpleHTTPRequestHandler (#104067)
Do not expose the local server's on-disk location from `SimpleHTTPRequestHandler` when generating a directory index. (unnecessary information disclosure)

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-05-03 03:42:00 +00:00
Juhi Chandalia 872cbc6132
GH-103963: Make dis display names of args for intrinsics opcodes (#104029) 2023-05-02 19:00:17 -07:00
Barney Gale 65a49c6553
GH-104102: Optimize `pathlib.Path.glob()` handling of `../` pattern segments (GH-104103)
These segments do not require a `stat()` call, as the selector's
`_select_from()` method is called after we've established that the
parent is a directory.
2023-05-02 23:16:04 +00:00
Barney Gale 8611e7bf5c
GH-103525: Improve exception message from `pathlib.PurePath()` (GH-103526)
Check that arguments are strings before calling `os.path.join()`.

Also improve performance of `PurePath(PurePath(...))` while we're in the
area: we now use the *unnormalized* string path of such arguments.

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
2023-05-02 19:08:19 +01:00
Dong-hee Na d81ca7ec02
gh-84436: Add integration C API tests for immortal objects (gh-103962) 2023-05-03 00:05:30 +09:00
Jurica Bradarić 87223f32ab
gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-02 13:38:46 +02:00
Thomas Grainger 9de0cf20fa
GH-103472: close response in HTTPConnection._tunnel (#103473)
Avoid a potential `ResourceWarning` in `http.client.HTTPConnection`
by closing the proxy / tunnel's CONNECT response explicitly.

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-05-02 03:59:42 +00:00
Pablo Galindo Salgado b1ca34d4d5
gh-104016: Skip test for deeply neste f-strings on wasi (#104071) 2023-05-01 23:55:41 +00:00
Kirill Podoprigora 605f8785db
gh-104057: Fix direct invocation of test_super (#104064) 2023-05-01 16:14:49 -06:00
Irit Katriel 80b714835d
gh-87092: Expose assembler to unit tests (#103988) 2023-05-01 22:29:30 +01:00
Itamar Ostricher a474e04388
gh-97696: asyncio eager tasks factory (#102853)
Co-authored-by: Jacob Bower <jbower@meta.com>
Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2023-05-01 15:10:13 -06:00
Kirill Podoprigora d448fcb032
gh-104057: Fix direct invocation of test_module (GH-104059) 2023-05-01 20:17:47 +00:00
John Belmonte 3ed8c88290
gh-104018: disallow "z" format specifier in %-format of byte strings (GH-104033)
PEP-0682 specified that %-formatting would not support the "z" specifier,
but it was unintentionally allowed for bytes. This PR makes use of the "z"
flag an error for %-formatting in a bytestring.

Issue: #104018

---------

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-05-01 20:47:14 +01:00
jx124 5078eedc5b
gh-104016: Fixed off by 1 error in f string tokenizer (#104047)
Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Co-authored-by: Ken Jin <kenjin@python.org>
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2023-05-01 19:15:47 +00:00
Franek Magiera 2d526cd32f
GH-103629: Update Unpack's repr in compliance with PEP 692 (#104048) 2023-05-01 17:58:50 +00:00
chgnrdv d5a97074d2
gh-103824: fix use-after-free error in Parser/tokenizer.c (#103993) 2023-05-01 15:26:43 +00:00
Nikita Sobolev 99aab61062 gh-104035: Do not ignore user-defined `__{get,set}state__` in slotted frozen dataclasses (#104041) 2023-05-01 09:19:06 -06:00
Kirill Podoprigora 4181d078fc
gh-104036: Fix direct invocation of test_typing (#104037)
Previously, `python -m test test_typing` worked, but `python Lib/test/test_typing.py` did not.
2023-05-01 13:42:59 +00:00
sunmy2019 59c27fa5cb
gh-102213: Optimize the performance of `__getattr__` (GH-103761)
Co-authored-by: Kirill <80244920+Eclips4@users.noreply.github.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Xiang Wang <34048878+wangxiang-hz@users.noreply.github.com>
2023-05-01 18:10:35 +08:00
Carey Metcalfe 487f55d580
gh-103895: Improve how invalid `Exception.__notes__` are displayed (#103897) 2023-05-01 08:32:04 +01:00
Shantanu 69bc86cb1a
Improve int test coverage (#104024)
Following discussion in https://discuss.python.org/t/bug-in-int-42/26360/5

This tests some of the things documented in https://github.com/python/cpython/pull/100436

Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-04-30 17:16:38 -07:00
Liam Gersten 74a2b79c62
gh-88773: Added teleport method to Turtle library (#103974)
Add a `teleport` method to `turtle` module turtle instances that acts a lot like `goto`, _but_ ensures the pen is up while warping to the new position to and can control shape filling behavior as part of the jump.

Based on an educator user feature request.

---------

Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
2023-04-30 13:17:36 -07:00
Nikita Sobolev 654d44b3a4
gh-104015: Fix direct invocation of `test_dataclasses` (#104017)
Previously, `python -m test test_dataclasses` passed, but `./python.exe Lib/test/test_dataclasses.py` failed
2023-04-30 17:16:55 +00:00
Alex Waygood 7d3931e94a
gh-104012: Ensure test_calendar.CalendarTestCase.test_deprecation_warning consistently passes (#104014) 2023-04-30 15:51:46 +00:00
Joshua Herman 9e011e7c77
gh-82054: allow test runner to split test_asyncio to execute in parallel by sharding. (#103927)
This runs test_asyncio sub-tests in parallel using sharding from Cinder. This suite is typically the longest-pole in runs because it is a test package with a lot of further sub-tests otherwise run serially. By breaking out the sub-tests as independent modules we can run a lot more in parallel.

After porting we can see the direct impact on a multicore system.

Without this change:
  Running make test is 5 min 26 seconds
With this change:
  Running make test takes 3 min 39 seconds

That'll vary based on system and parallelism. On a `-j 4` run similar to what CI and buildbot systems often do, it reduced the overall test suite completion latency by 10%.

The drawbacks are that this implementation is hacky and due to the sorting of the tests it obscures when the asyncio tests occur and involves changing CPython test infrastructure but, the wall time saved it is worth it, especially in low-core count CI runs as it pulls a long tail. The win for productivity and reserved CI resource usage is significant.

Future tests that deserve to be refactored into split up suites to benefit from are test_concurrent_futures and the way the _test_multiprocessing suite gets run for all start methods. As exposed by passing the -o flag to python -m test to get a list of the 10 longest running tests.

---------

Co-authored-by: Carl Meyer <carl@oddbird.net>
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google, LLC]
2023-04-29 18:26:24 -07:00
Oleg Iarygin 00e2c5960e
Remove non-existing tools from Sundry skiplist (#103991) 2023-04-29 12:11:15 -07:00
Itamar Ostricher 85c7bf5bce
gh-103793: Defer formatting task name (#103767)
The default task name is "Task-<counter>" (if no name is passed in during Task creation).
This is initialized in `Task.__init__` (C impl) using string formatting, which can be quite slow.
Actually using the task name in real world code is not very common, so this is wasted init.

Let's defer this string formatting to the first time the name is read (in `get_name` impl),
so we don't need to pay the string formatting cost if the task name is never read.

We don't change the order in which tasks are assigned numbers (if they are) --
the number is set on task creation, as a PyLong instead of a formatted string.

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-04-29 08:20:09 -07:00
Prince Roshan 84e7d0f0c7
gh-103636: issue warning for deprecated calendar constants (#103833)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
2023-04-29 01:16:46 -06:00
Barry Warsaw e1f14643dc
gh-98040: Remove just the `imp` module (#98573) 2023-04-28 16:17:58 -07:00
Tian Gao 79b9db9295
GH-103971: Forward-port test from GH-103980 (GH-103984) 2023-04-28 20:25:48 +00:00
Juhi Chandalia 81387fe36e
GH-103804: Add test for dis.disco (#103901) 2023-04-28 12:11:21 +01:00
Marek Marczykowski-Górecki 67d140dba7
gh-83925: Make asyncio.subprocess communicate similar to non-asyncio (#18650)
subprocess's communicate(None) closes stdin of the child process, after
sending no (extra) data. Make asyncio variant do the same.
This fixes issues with processes that waits for EOF on stdin before
continuing.
2023-04-27 17:30:26 -07:00
Paul Ganssle 0b7fd8ffc5
GH-103857: Deprecate utcnow and utcfromtimestamp (#103858)
Using `datetime.datetime.utcnow()` and `datetime.datetime.utcfromtimestamp()` will now raise a `DeprecationWarning`.

We also have removed our internal uses of these functions and documented the change.
2023-04-27 11:32:30 -06:00
Paul Ganssle a5308e188b
GH-90750: Use datetime.fromisocalendar in _strptime (#103802)
Use datetime.fromisocalendar in _strptime

This unifies the ISO → Gregorian conversion logic and improves handling
of invalid ISO weeks.
2023-04-27 10:27:27 -06:00
Irit Katriel 63842bd907
gh-103590: do not wrap a single exception raised from a try-except* (#103665) 2023-04-27 12:52:15 +01:00
Itayazolay 78942ecd9b
gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (#17425)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
2023-04-27 15:33:29 +05:30
Nikita Sobolev dff8e5dc8d
gh-103880: Fix `assertRaises` usage in `test_genericalias` (GH-103916) 2023-04-27 16:54:59 +08:00
Lysandros Nikolaou 9169a56fad
gh-103656: Transfer f-string buffers to parser to avoid use-after-free (GH-103896)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
2023-04-27 01:33:31 +00:00
Stefano Rivera 76632b836c
gh-62432: unittest runner: Exit code 5 if no tests were run (#102051)
As discussed in https://discuss.python.org/t/unittest-fail-if-zero-tests-were-discovered/21498/7

It is common for test runner misconfiguration to fail to find any tests,
This should be an error.

Fixes: #62432
2023-04-27 01:28:46 +00:00
Aidan Melen a3a5b4bb23
gh-60436: fix curses textbox backspace/del (#103783)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Michael Blahay <mblahay@gmail.com>
2023-04-26 22:54:07 +02:00
Erlend E. Aasland bb8aa7a2b4
gh-103489: Add get/set config methods to sqlite3.Connection (#103506) 2023-04-26 19:57:48 +00:00
Juhi Chandalia d45225bd66
GH-99944: Make dis display the value of oparg of KW_NAMES (#103856)
Co-authored-by: chilaxan <chilaxan@gmail.com>
2023-04-26 19:00:36 +01:00
Tian Gao 31acfd78a0
gh-103578: Fix pdb reading code with non-utf8 encoding (#103581)
`pdb` should use `io.open_code` to open code to avoid encoding issue.
2023-04-25 23:04:51 -06:00