Commit Graph

50084 Commits

Author SHA1 Message Date
Kevin Krakauer c9ecd3ee75
gh-102795: Fix use of poll in test_epoll's test_control_and_wait (#102796)
This test can fail unnecessarily. In the test we wait for events on two
file descriptors. This is done in a single call to select.epoll's poll()
function. However, it is valid for the OS to return only one event via
poll() and the next via a subsequent call to poll(). This rarely
happens, but it can cause the test to fail despite properly functioning
polling.

Instead, we poll a second time when necessary.
2023-05-04 14:38:20 +00:00
Christopher Chavez e2ef5015d1
Fix typo "involvin" → "involving" (#104166) 2023-05-04 13:03:52 +00:00
Lysandros Nikolaou ef0df5284f
gh-97556: Raise null bytes syntax error upon null in multiline string (GH-104136) 2023-05-04 14:26:23 +02:00
sunmy2019 83751bbd14
gh-104089: catch DeprecationWarning in `test_fstring` (#104137)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-05-04 11:20:20 +01:00
Petr Viktorin cd9a56c2b0
gh-103509: PEP 697 -- Limited C API for Extending Opaque Types (GH-103511)
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2023-05-04 09:56:53 +02:00
Yuxin Wu e95dd40aff
pydoc.safeimport: Use importlib.import_module instead of __import__ (GH-103118) 2023-05-03 16:26:39 -07:00
Nikita Sobolev d6e83fbf30
gh-97850: Deprecate `find_loader` and `get_loader` in `pkgutil` (GH-98520)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Brett Cannon <brett@python.org>
Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
2023-05-03 16:11:54 -07:00
Barney Gale da1980afcb
GH-104114: Fix `pathlib.WindowsPath.glob()` use of literal pattern segment case (GH-104116)
We now use `_WildcardSelector` to evaluate literal pattern segments, which
allows us to retrieve the real filesystem case.

This change is necessary in order to implement a *case_sensitive* argument
(see GH-81079) and a *follow_symlinks* argument (see GH-77609).
2023-05-03 17:28:44 +01:00
Paul Ganssle 38dc3f28dd
GH-103944: Remove last use of `utcfromtimestamp` (#103995)
* Remove last use of `utcfromtimestamp`

This was a weirdly valid use of `utcfromtimestamp` in the sense that the "timestamps" in TZif files are not epoch times, but actually something more properly thought of as "number of seconds since 1970 in the local time zone", so even though we didn't want UTC time, `utcfromtimestamp` was still a good way to get the thing we wanted. Since we're deprecating `utcfromtimestamp`, it's just as valid to use `timedelta` arithmetic here.

We may be able to avoid the question entirely by switching these tests over to using `ZoneInfo` in the future.

* Fix a few missing DeprecationWarnings in tests

In one test, we simply turn off DeprecationWarning rather than asserting about it, because whether the error condition happens before or after the warning seems to differ between the Python and C versions.
2023-05-03 11:17:27 -04:00
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 0a5cd984b2 GH-84976: Re-introduce `datetime.py` and fix reprs
Without the change to the reprs, pure-python classes would have a repr
of `datetime._pydatetime.time`, etc.
2023-05-03 03:09:45 -06: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 47770a1e91
GH-104104: Optimize `pathlib.Path.glob()` by avoiding repeated calls to `os.path.normcase()` (GH-104105)
Use `re.IGNORECASE` to implement case-insensitive matching. This
restores behaviour from before GH-31691.
2023-05-02 22:51:18 +01:00
Prince Roshan 1f5384434d
gh-103822: [Calendar] change return value to enum for day and month APIs (GH-103827) 2023-05-02 13:13:31 -07: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
Shantanu 82ba6ce303
Improve assert_type phrasing (#104081)
I'd like to make the fact that this does nothing at runtime
really obvious, since I suspect this is unintuitive for users who are
unfamiliar with static type checking.

I thought of this because of
https://discuss.python.org/t/add-arg-check-type-to-types/26384
wherein I'm skeptical that the user really did want `assert_type`.
2023-05-01 23:05:25 -07: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
Terry Jan Reedy 690df4c16c
gh-88496: IDLE - fix another test on macOS (#104075)
Needed for Catalina: test_sidebar add 'idletasks' and skip assert.
2023-05-02 02:53:16 +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
Irit Katriel a679c3d58d
gh-102799: replace sys.exc_info by sys.exception in inspect and traceback modules (#104032) 2023-05-01 18:19:47 +01: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
Terry Jan Reedy 4b27972f5f
gh-88496: Fix IDLE test hang on macOS (#104025)
Replace widget.update() with widget.update_idletasks in two places.
2023-04-30 21:36:27 -04: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
Pieter Eendebak f186557dc3
gh-103977: compile re expressions in platform.py only if required (#103981)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-04-30 08:36:19 -07: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