Commit Graph

12279 Commits

Author SHA1 Message Date
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
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
Hugo van Kemenade 5b05b013ff
gh-101100: Fix Sphinx warnings in `curses` and `curses.ascii` modules (#103457)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
2023-05-02 23:09:04 -06: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
Shantanu 587f2f0180
gh-65022: Fix description of tuple return value in copyreg (#103892) 2023-05-02 11:13:47 -07:00
Rafael Fontenelle 68ed2a2a3f
GH-103484: Fix redirected permanently URLs (#104001)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Oleg Iarygin <dralife@yandex.ru>
2023-05-02 09:34:44 +03: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
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
Ben Faulhaber 93107aa2a4
Adjust expression from `==` to `!=` in alignment with the meaning of the paragraph. (GH-104021) 2023-05-01 06:47:34 +01: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
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
Jelle Zijlstra ed29f524cf
Various small fixes to dis docs (#103923)
- Fix description of MAKE_CELL, which appeared to be inverted from the
  actual behavior
- Fix stray ".:" (sphinx-contrib/sphinx-lint#63)
- Fix inconsistent indentation
- Add some missing code blocks
- Slight style improvements
2023-04-29 00:02:21 -07:00
Barry Warsaw e1f14643dc
gh-98040: Remove just the `imp` module (#98573) 2023-04-28 16:17:58 -07:00
Olga Matoula 83aa496f81
gh-101100: Add reference doc for __post_init__ (#103818)
Signed-off-by: Olga Matoula <olgamatoula@gmail.com>
2023-04-28 13:10:26 -06:00
Raymond Hettinger c3453fbb11
Update itertool recipe: polynomial_from_roots() (GH-103973) 2023-04-28 12:25:50 -05:00
Erlend E. Aasland 30216b69a2
gh-100021: Document that sqlite3's executemany() discards resulting rows (#103939) 2023-04-28 10:02:23 +02: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
Erlend E. Aasland 2cf945bec6
Docs: fix dunders with too many underscores (#103955) 2023-04-27 23:17:43 +02:00
Adam Turner 44b5c21f41
GH-103903: Test the minimum Sphinx version in CI (#103904) 2023-04-27 19:27:38 +01: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
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
Franek Magiera dc3f97549a
gh-103629: Update typing.Unpack docs in compliance with PEP 692 (#103894) 2023-04-26 16:39:39 -06:00
Michael Blahay 44010d0f12
gh-48241: Clarify URL needs to be encoded when provided to urlopen and Request (#103855)
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-04-26 22:52:23 +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
Erlend E. Aasland 222c63fc6b
gh-103015: Add entrypoint keyword param to sqlite3.Connection.load_extension (#103073) 2023-04-26 21:22:03 +02:00
Owain Davies 28a05f4cc2
gh-101879: docs - italicize argument in smtplib.SMPT() description (#101886) 2023-04-26 21:00:19 +02:00
July Tikhonov 37e37553b0
gh-91441: Clarify the docs of asyncio.loop.subprocess_exec() (#91442)
Clarify the docs of asyncio.loop.subprocess_exec()

Clarify the documentation of stdin, stdout and stderr arguments of
asyncio.loop.subprocess_exec().

Co-authored-by: Carol Willing <carolcode@willingconsulting.com>
2023-04-26 12:57:19 -06:00
Carol Willing 1c0a9c5a1c
gh-101786: Clarify docs that asyncio.Server.sockets is a socket-like TransportSocket (#103877)
Clarify that asyncio.Server.sockets is a socket-like TransportSocket
2023-04-26 06:32:24 -06:00
Alex Waygood cef542ca57
gh-103721: Improve cross-references for generic-alias docs (#103838)
Cc. @adriangb

The "stub documentation" in `types.rst` does already link to the
in-depth docs in `stdtypes.rst`, but the link isn't obvious for new
users. It deserves to be made more prominent.

- Issue: https://github.com/python/cpython/issues/103721
2023-04-25 10:24:49 -06:00
Samuel Sloniker 32bea69b89
gh-51574: Make tempfile.mkdtemp() always return absolute paths (#94612)
Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
2023-04-25 16:05:59 +00:00
Olga Matoula 0f23eda4b9
gh-103810: Fix broken references in dataclasses (#103811)
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
2023-04-25 01:26:18 +02:00
jb2170 d94b3a6f45
gh-103673: Add missing ForkingUnixStreamServer and ForkingUnixDatagramServer socketservers (#103674)
sockserver gains ForkingUnixStreamServer and ForkingUnixDatagramServer classes for consistency with all of the others. Ironically these existed but were buried in our test suite.

Addresses #103673 

<!-- gh-issue-number: gh-103673 -->
* Issue: gh-103673
<!-- /gh-issue-number -->

---------

Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2023-04-24 22:35:52 +00:00
Carl Meyer 0dc8b50d33
gh-87729: add LOAD_SUPER_ATTR instruction for faster super() (#103497)
This speeds up `super()` (by around 85%, for a simple one-level
`super().meth()` microbenchmark) by avoiding allocation of a new
single-use `super()` object on each use.
2023-04-24 22:22:14 +00:00
Łukasz Langa 22bed58e53
gh-103791: Make contextlib.suppress also act on exceptions within an ExceptionGroup (#103792)
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
2023-04-24 22:17:02 +00:00
Hugo van Kemenade 79ae019164
gh-101100: Fix Sphinx warnings in `argparse` module (#103289)
Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM>
Co-authored-by: Ezio Melotti <ezio.melotti@gmail.com>
2023-04-24 15:36:32 -06:00
William Andrea 2aa22f72fb
gh-99032: datetime docs: Encoding is no longer relevant (#93365)
This removes a section of the `strftime` and `strptime` documentation that refers to a bygone era when `strftime` would return an encoded byte string.

---------

Co-authored-by: Paul Ganssle <1377457+pganssle@users.noreply.github.com>
2023-04-24 12:54:16 -06:00
Howie Zhao 5b404d6cad
gh-94300: Update datetime.strptime documentation (#95318)
The new wording better reflects the cases where `datetime.strptime` differs from` time.strptime`.

---------

Co-authored-by: Paul Ganssle <git@m.ganssle.io>
2023-04-24 12:35:15 -06:00
Furkan Onder 0421ed44a9
GH-65022: Fix description of copyreg.pickle function (#102656)
Fix description of copyreg.pickle function
2023-04-24 11:26:40 -06:00
Allan Lago 7ef614c1ad
gh-91687: modernize dataclass example typing (#103773)
modernize dataclass example typing `list` rather than `List` and comment as to that line being the alluded too error.
2023-04-24 10:16:23 -07:00
Jaime Alonso Lorenzo d2745fe850
gh-103765: Fix 'Warning: py:class reference target not found: ModuleSpec' (GH-103769) 2023-04-24 10:51:45 -06:00
Joshua Herman 68f5836582
gh-87452: Improve the Popen.returncode docs
Clarifies that it remains None until a method checking the child process status has been called and noticed it has terminated.
2023-04-24 09:46:12 -07:00
Richard Hajek 385d8d2b64
Removed unnecessary escaping of asterisks (#103714)
Removed unnecessary escaping of asterisks, as visible both on GitHub and in https://docs.python.org/3/library/decimal.html#decimal.localcontext

Co-authored-by: Łukasz Langa <lukasz@langa.pl>
2023-04-24 16:31:41 +00:00
Stanley 59c522f965
gh-44123: Add note on relative path for os.exec* (GH-93826)
Co-authored-by: Steve Dower <steve.dower@python.org>
2023-04-24 14:52:31 +01:00
Petr Viktorin af53046995
gh-102950: Implement PEP 706 – Filter for tarfile.extractall (#102953) 2023-04-24 10:58:06 +02:00
James Hilton-Balfe 730bbddfdf
gh-101688: Implement types.get_original_bases (#101827)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2023-04-23 20:24:30 +01:00
Randy 7bf94568a9
gh-68654: Clarify subdirectories used by pkgutil.extend_path (#103701)
Clarify sub directories used by pkgutil.extend_path in the docs and the docstring
2023-04-22 17:33:50 -06:00
Hugo van Kemenade 8cb2b0f953
Revert "Avoid error lexing multiprocessing docs code block on Pygments 2.15.0" (#103616)
This reverts commit ace51dcdb7.
2023-04-22 15:41:58 -06:00
Eddie Elizondo ea2c001650
gh-84436: Implement Immortal Objects (gh-19474)
This is the implementation of PEP683

Motivation:

The PR introduces the ability to immortalize instances in CPython which bypasses reference counting. Tagging objects as immortal allows up to skip certain operations when we know that the object will be around for the entire execution of the runtime.

Note that this by itself will bring a performance regression to the runtime due to the extra reference count checks. However, this brings the ability of having truly immutable objects that are useful in other contexts such as immutable data sharing between sub-interpreters.
2023-04-22 13:39:37 -06:00
Eric Wieser 3d2a46845b
gh-83791: Raise TypeError for len(memoryview_0d) (#18463)
Changes the behaviour of `len` on a zero-dimensional `memoryview` to raise `TypeError`. Previously, `len` would return `1`.
2023-04-22 17:32:47 +01:00
Rafael Fontenelle caed49448d
GH-103484: Fix broken links reported by linkcheck (#103608)
* Doc: Fix broken links reported by linkcheck

* Apply suggestions from code review

- Remove extra diff line in faq/library.rst (merwok)
- Use HTTPS to link Unicode 15.0.0 to solve a redirect (hugovk)
- Use wayback machine link for openssl 1.1.0 instead of linking 1.1.1, "as this text mentions a feature from 1.1.0" (hugovk)

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Doc: Make mark-up code as literal

* Doc: Alphabetize items in linkcheck_ignore

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>

* Doc: Improve comment in sphinx conf

Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>

---------

Co-authored-by: Éric <merwok@netwok.org>
Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2023-04-22 08:24:47 -06:00