Skip to content

Commit 3701b41

Browse files
Fix merge
2 parents de9e661 + 03185f0 commit 3701b41

File tree

71 files changed

+2172
-702
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+2172
-702
lines changed

.coveragerc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[run]
2+
branch = True
3+
4+
[report]
5+
# Regexes for lines to exclude from consideration
6+
exclude_lines =
7+
# Don't complain if non-runnable code isn't run:
8+
if 0:
9+
if __name__ == .__main__.:
10+
11+
.*# pragma: no cover
12+
.*# pragma: no branch
13+
14+
# Additions for IDLE:
15+
.*# htest #
16+
if not (_htest or _utest):
17+
if not .*_utest:
18+
if .*_htest:
19+

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Doc/c-api/stable.rst @encukou
172172
**/*pathlib* @barneygale
173173

174174
# zipfile.Path
175-
**/*zipfile/*_path.py @jaraco
175+
**/*zipfile/_path/* @jaraco
176176

177177
# Argument Clinic
178178
/Tools/clinic/** @erlend-aasland @AlexWaygood

Doc/library/http.client.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ HTTPConnection Objects
390390
Returns a dictionary with the headers of the response received from
391391
the proxy server to the CONNECT request.
392392

393-
If the CONNECT request was not sent, the method returns an empty dictionary.
393+
If the CONNECT request was not sent, the method returns ``None``.
394394

395395
.. versionadded:: 3.12
396396

Doc/library/importlib.resources.rst

Lines changed: 0 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -94,159 +94,3 @@ for example, a package and its resources can be imported from a zip file using
9494
the file system is required.
9595

9696
.. versionadded:: 3.9
97-
98-
99-
Deprecated functions
100-
^^^^^^^^^^^^^^^^^^^^
101-
102-
An older, deprecated set of functions is still available, but is
103-
scheduled for removal in a future version of Python.
104-
The main drawback of these functions is that they do not support
105-
directories: they assume all resources are located directly within a *package*.
106-
107-
.. data:: Package
108-
109-
Whenever a function accepts a ``Package`` argument, you can pass in
110-
either a :class:`module object <types.ModuleType>` or a module name
111-
as a string. You can only pass module objects whose
112-
``__spec__.submodule_search_locations`` is not ``None``.
113-
114-
The ``Package`` type is defined as ``Union[str, ModuleType]``.
115-
116-
.. deprecated:: 3.12
117-
118-
119-
.. data:: Resource
120-
121-
For *resource* arguments of the functions below, you can pass in
122-
the name of a resource as a string or
123-
a :class:`path-like object <os.PathLike>`.
124-
125-
The ``Resource`` type is defined as ``Union[str, os.PathLike]``.
126-
127-
128-
.. function:: open_binary(package, resource)
129-
130-
Open for binary reading the *resource* within *package*.
131-
132-
*package* is either a name or a module object which conforms to the
133-
``Package`` requirements. *resource* is the name of the resource to open
134-
within *package*; it may not contain path separators and it may not have
135-
sub-resources (i.e. it cannot be a directory). This function returns a
136-
``typing.BinaryIO`` instance, a binary I/O stream open for reading.
137-
138-
.. deprecated:: 3.11
139-
140-
Calls to this function can be replaced by::
141-
142-
files(package).joinpath(resource).open('rb')
143-
144-
145-
.. function:: open_text(package, resource, encoding='utf-8', errors='strict')
146-
147-
Open for text reading the *resource* within *package*. By default, the
148-
resource is opened for reading as UTF-8.
149-
150-
*package* is either a name or a module object which conforms to the
151-
``Package`` requirements. *resource* is the name of the resource to open
152-
within *package*; it may not contain path separators and it may not have
153-
sub-resources (i.e. it cannot be a directory). *encoding* and *errors*
154-
have the same meaning as with built-in :func:`open`.
155-
156-
This function returns a ``typing.TextIO`` instance, a text I/O stream open
157-
for reading.
158-
159-
.. deprecated:: 3.11
160-
161-
Calls to this function can be replaced by::
162-
163-
files(package).joinpath(resource).open('r', encoding=encoding)
164-
165-
166-
.. function:: read_binary(package, resource)
167-
168-
Read and return the contents of the *resource* within *package* as
169-
``bytes``.
170-
171-
*package* is either a name or a module object which conforms to the
172-
``Package`` requirements. *resource* is the name of the resource to open
173-
within *package*; it may not contain path separators and it may not have
174-
sub-resources (i.e. it cannot be a directory). This function returns the
175-
contents of the resource as :class:`bytes`.
176-
177-
.. deprecated:: 3.11
178-
179-
Calls to this function can be replaced by::
180-
181-
files(package).joinpath(resource).read_bytes()
182-
183-
184-
.. function:: read_text(package, resource, encoding='utf-8', errors='strict')
185-
186-
Read and return the contents of *resource* within *package* as a ``str``.
187-
By default, the contents are read as strict UTF-8.
188-
189-
*package* is either a name or a module object which conforms to the
190-
``Package`` requirements. *resource* is the name of the resource to open
191-
within *package*; it may not contain path separators and it may not have
192-
sub-resources (i.e. it cannot be a directory). *encoding* and *errors*
193-
have the same meaning as with built-in :func:`open`. This function
194-
returns the contents of the resource as :class:`str`.
195-
196-
.. deprecated:: 3.11
197-
198-
Calls to this function can be replaced by::
199-
200-
files(package).joinpath(resource).read_text(encoding=encoding)
201-
202-
203-
.. function:: path(package, resource)
204-
205-
Return the path to the *resource* as an actual file system path. This
206-
function returns a context manager for use in a :keyword:`with` statement.
207-
The context manager provides a :class:`pathlib.Path` object.
208-
209-
Exiting the context manager cleans up any temporary file created when the
210-
resource needs to be extracted from e.g. a zip file.
211-
212-
*package* is either a name or a module object which conforms to the
213-
``Package`` requirements. *resource* is the name of the resource to open
214-
within *package*; it may not contain path separators and it may not have
215-
sub-resources (i.e. it cannot be a directory).
216-
217-
.. deprecated:: 3.11
218-
219-
Calls to this function can be replaced using :func:`as_file`::
220-
221-
as_file(files(package).joinpath(resource))
222-
223-
224-
.. function:: is_resource(package, name)
225-
226-
Return ``True`` if there is a resource named *name* in the package,
227-
otherwise ``False``.
228-
This function does not consider directories to be resources.
229-
*package* is either a name or a module object which conforms to the
230-
``Package`` requirements.
231-
232-
.. deprecated:: 3.11
233-
234-
Calls to this function can be replaced by::
235-
236-
files(package).joinpath(resource).is_file()
237-
238-
239-
.. function:: contents(package)
240-
241-
Return an iterable over the named items within the package. The iterable
242-
returns :class:`str` resources (e.g. files) and non-resources
243-
(e.g. directories). The iterable does not recurse into subdirectories.
244-
245-
*package* is either a name or a module object which conforms to the
246-
``Package`` requirements.
247-
248-
.. deprecated:: 3.11
249-
250-
Calls to this function can be replaced by::
251-
252-
(resource.name for resource in files(package).iterdir() if resource.is_file())

Doc/library/pathlib.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ Pure paths provide the following methods and properties:
432432

433433
.. attribute:: PurePath.suffix
434434

435-
The file extension of the final component, if any::
435+
The last dot-separated portion of the final component, if any::
436436

437437
>>> PurePosixPath('my/library/setup.py').suffix
438438
'.py'
@@ -441,10 +441,11 @@ Pure paths provide the following methods and properties:
441441
>>> PurePosixPath('my/library').suffix
442442
''
443443

444+
This is commonly called the file extension.
444445

445446
.. attribute:: PurePath.suffixes
446447

447-
A list of the path's file extensions::
448+
A list of the path's suffixes, often called file extensions::
448449

449450
>>> PurePosixPath('my/library.tar.gar').suffixes
450451
['.tar', '.gar']

Doc/library/stdtypes.rst

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3953,7 +3953,7 @@ copying.
39533953
>>> m = memoryview(bytearray(b'abc'))
39543954
>>> mm = m.toreadonly()
39553955
>>> mm.tolist()
3956-
[89, 98, 99]
3956+
[97, 98, 99]
39573957
>>> mm[0] = 42
39583958
Traceback (most recent call last):
39593959
File "<stdin>", line 1, in <module>
@@ -4009,6 +4009,7 @@ copying.
40094009
:mod:`struct` syntax. One of the formats must be a byte format
40104010
('B', 'b' or 'c'). The byte length of the result must be the same
40114011
as the original length.
4012+
Note that all byte lengths may depend on the operating system.
40124013

40134014
Cast 1D/long to 1D/unsigned bytes::
40144015

@@ -4039,8 +4040,8 @@ copying.
40394040
>>> x = memoryview(b)
40404041
>>> x[0] = b'a'
40414042
Traceback (most recent call last):
4042-
File "<stdin>", line 1, in <module>
4043-
ValueError: memoryview: invalid value for format "B"
4043+
...
4044+
TypeError: memoryview: invalid type for format 'B'
40444045
>>> y = x.cast('c')
40454046
>>> y[0] = b'a'
40464047
>>> b
@@ -4789,10 +4790,10 @@ An example of dictionary view usage::
47894790
>>> # set operations
47904791
>>> keys & {'eggs', 'bacon', 'salad'}
47914792
{'bacon'}
4792-
>>> keys ^ {'sausage', 'juice'}
4793-
{'juice', 'sausage', 'bacon', 'spam'}
4794-
>>> keys | ['juice', 'juice', 'juice']
4795-
{'juice', 'sausage', 'bacon', 'spam', 'eggs'}
4793+
>>> keys ^ {'sausage', 'juice'} == {'juice', 'sausage', 'bacon', 'spam'}
4794+
True
4795+
>>> keys | ['juice', 'juice', 'juice'] == {'bacon', 'spam', 'juice'}
4796+
True
47964797

47974798
>>> # get back a read-only proxy for the original dictionary
47984799
>>> values.mapping
@@ -4999,8 +5000,8 @@ exception to disallow mistakes like ``dict[str][str]``::
49995000

50005001
>>> dict[str][str]
50015002
Traceback (most recent call last):
5002-
File "<stdin>", line 1, in <module>
5003-
TypeError: There are no type variables left in dict[str]
5003+
...
5004+
TypeError: dict[str] is not a generic class
50045005

50055006
However, such expressions are valid when :ref:`type variables <generics>` are
50065007
used. The index must have as many elements as there are type variable items
@@ -5206,13 +5207,15 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
52065207
>>> isinstance("", int | str)
52075208
True
52085209

5209-
However, union objects containing :ref:`parameterized generics
5210-
<types-genericalias>` cannot be used::
5210+
However, :ref:`parameterized generics <types-genericalias>` in
5211+
union objects cannot be checked::
52115212

5212-
>>> isinstance(1, int | list[int])
5213+
>>> isinstance(1, int | list[int]) # short-circuit evaluation
5214+
True
5215+
>>> isinstance([1], int | list[int])
52135216
Traceback (most recent call last):
5214-
File "<stdin>", line 1, in <module>
5215-
TypeError: isinstance() argument 2 cannot contain a parameterized generic
5217+
...
5218+
TypeError: isinstance() argument 2 cannot be a parameterized generic
52165219

52175220
The user-exposed type for the union object can be accessed from
52185221
:data:`types.UnionType` and used for :func:`isinstance` checks. An object cannot be
@@ -5515,7 +5518,7 @@ types, where they are relevant. Some of these are not reported by the
55155518
definition order. Example::
55165519

55175520
>>> int.__subclasses__()
5518-
[<class 'bool'>]
5521+
[<class 'bool'>, <enum 'IntEnum'>, <flag 'IntFlag'>, <class 're._constants._NamedIntConstant'>]
55195522

55205523

55215524
.. _int_max_str_digits:
@@ -5551,15 +5554,15 @@ When an operation would exceed the limit, a :exc:`ValueError` is raised:
55515554
>>> _ = int('2' * 5432)
55525555
Traceback (most recent call last):
55535556
...
5554-
ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 5432 digits; use sys.set_int_max_str_digits() to increase the limit.
5557+
ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 5432 digits; use sys.set_int_max_str_digits() to increase the limit
55555558
>>> i = int('2' * 4300)
55565559
>>> len(str(i))
55575560
4300
55585561
>>> i_squared = i*i
55595562
>>> len(str(i_squared))
55605563
Traceback (most recent call last):
55615564
...
5562-
ValueError: Exceeds the limit (4300 digits) for integer string conversion: value has 8599 digits; use sys.set_int_max_str_digits() to increase the limit.
5565+
ValueError: Exceeds the limit (4300 digits) for integer string conversion; use sys.set_int_max_str_digits() to increase the limit
55635566
>>> len(hex(i_squared))
55645567
7144
55655568
>>> assert int(hex(i_squared), base=16) == i*i # Hexadecimal is unlimited.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy