Add tests for "import", pkgutil.resolve_name() and unittest.mock.path()
for cases when "import a.b as x" and "from a import b as x" give
different results.
(cherry picked from commit c0eaa232f6)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
gh-118359: Improve docs for Bdb.user_call (GH-118368)
The `argument_list` parameter of bdb.Bdb.user_call has been useless for 25 years. It is retained for backwards compatibility, but it will always be None.
(cherry picked from commit 8e4fb5d260)
Co-authored-by: Tian Gao <gaogaotiantian@hotmail.com>
gh-117566: fix IPv6Address.is_loopback for IPv4-mapped loopbacks (GH-117567)
While properties like IPv6Address.is_private account for IPv4-mapped
IPv6 addresses, such as for example:
>>> ipaddress.ip_address("192.168.0.1").is_private
True
>>> ipaddress.ip_address("::ffff:192.168.0.1").is_private
True
...the same doesn't currently apply to the is_loopback property:
>>> ipaddress.ip_address("127.0.0.1").is_loopback
True
>>> ipaddress.ip_address("::ffff:127.0.0.1").is_loopback
False
At minimum, this inconsistency between different properties is
counter-intuitive. Moreover, ::ffff:127.0.0.0/104 is for all intents and
purposes a loopback address, and should be treated as such.
(cherry picked from commit fb7f79b4da)
Co-authored-by: Faidon Liambotis <paravoid@debian.org>
gh-118235: Skip RAISE_SYNTAX_ERROR rules in the grammar spec (GH-118237)
(cherry picked from commit ef940dec40)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-118207: Rename the COMMON_FIELDS macro in funcobject.h and undef it after use (GH-118208)
(cherry picked from commit 796b3fb280)
Co-authored-by: Itamar Oren <itamarost@gmail.com>
sqlite3.iterdump() depends on the row factory returning resulting rows
as tuples; it will fail with custom row factories like for example a
dict factory.
With this commit, we explicitly reset the row factory of the cursor used
by iterdump(), so we always get predictable results. This does not
affect the row factory of the parent connection.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
The behavior of fileno() after fclose() is undefined, but it is the only
practical way to check whether the file was closed.
Only test this on the known platforms (Linux, Windows, macOS), where we
already tested that it works.
(cherry picked from commit 546cbcfa0e)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* GH-113171: Fix "private" (non-global) IP address ranges (GH-113179)
The _private_networks variables, used by various is_private
implementations, were missing some ranges and at the same time had
overly strict ranges (where there are more specific ranges considered
globally reachable by the IANA registries).
This patch updates the ranges with what was missing or otherwise
incorrect.
100.64.0.0/10 is left alone, for now, as it's been made special in [1].
The _address_exclude_many() call returns 8 networks for IPv4, 121
networks for IPv6.
[1] https://github.com/python/cpython/issues/61602
* GH-65056: Improve the IP address' is_global/is_private documentation (GH-113186)
It wasn't clear what the semantics of is_global/is_private are and, when
one gets to the bottom of it, it's not quite so simple (hence the
exceptions listed).
(cherry picked from commit 2a4cbf17af)
(cherry picked from commit 40d75c2b7f)
---------
Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
* gh-59215: unittest: restore _top_level_dir at end of discovery (GH-15242)
(cherry picked from commit fc5f68e58e)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
gh-116741: Upgrade libexpat to 2.6.2 (GH-117296)
Upgrade libexpat to 2.6.2
(cherry picked from commit c9829eec08)
Co-authored-by: Seth Michael Larson <seth@python.org>
Filter out '?NNN' placeholders when looking for named params.
(cherry picked from commit 550483b7e6)
Co-authored-by: Erlend E. Aasland <erlend@python.org>
Co-authored-by: AN Long <aisk@users.noreply.github.com>
Docs: replace Harry Potter reference with Monty Python (GH-118130)
(cherry picked from commit 1446024124)
Co-authored-by: Clément Robert <cr52@protonmail.com>
gh-118100: Improve links in `ast.rst` (GH-118101)
(cherry picked from commit 2aa11cca11)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Follow GH-88035, update doc-string of epoch in timemodule.c
The epoch is `January 1st, 1970 on all platforms`, according to
current documentation.
(cherry picked from commit 7c6cc00211)
Co-authored-by: lit <litlighilit@foxmail.com>
gh-87969: Align docs and docstrings with implementation for ctypes' [w]string_at() (GH-25384)
The implementation uses 'ptr' for the name of the first parameter of
ctypes.string_at() and ctypes.wstring_at(). Align docs and docstrings
with the naming used in the implementation.
(cherry picked from commit 81a926bd20)
Co-authored-by: Shreyan Avigyan <shreyan.avigyan@gmail.com>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
gh-116935: Document that heap types need to support garbage collection (GH-118021)
(cherry picked from commit 5d54436574)
Co-authored-by: Savannah Ostrowski <savannahostrowski@gmail.com>
gh-117518: Clarify PyTuple_GetItem() borrowed reference in the doc (GH-117920)
(cherry picked from commit 4605a197bd)
Co-authored-by: Victor Stinner <vstinner@python.org>
gh-64588: Clarify the difference between mu and xbar in statistics docs (GH-117333)
Thanks Davin Potts for the clarification idea.
(cherry picked from commit fefd5d9711)
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Use "Contributed by" in a couple of occurrences of 3.12 whatsnew (GH-118070)
(cherry picked from commit 398abdd6fa)
Co-authored-by: Rafael Fontenelle <rffontenelle@users.noreply.github.com>