Skip to content

Commit 86a6dbc

Browse files
Merge branch 'main' into isolate-io/1-heap-types
2 parents 39e0a89 + 0729359 commit 86a6dbc

Some content is hidden

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

44 files changed

+444
-182
lines changed

Doc/c-api/function.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ There are a few functions specific to Python functions.
169169
before the modification to *func* takes place, so the prior state of *func*
170170
can be inspected. The runtime is permitted to optimize away the creation of
171171
function objects when possible. In such cases no event will be emitted.
172-
Although this creates the possitibility of an observable difference of
172+
Although this creates the possibility of an observable difference of
173173
runtime behavior depending on optimization decisions, it does not change
174174
the semantics of the Python code being executed.
175175

Doc/c-api/module.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,15 +388,15 @@ objects dynamically. Note that both ``PyModule_FromDefAndSpec`` and
388388
389389
.. c:function:: PyObject * PyModule_FromDefAndSpec(PyModuleDef *def, PyObject *spec)
390390
391-
Create a new module object, given the definition in *module* and the
391+
Create a new module object, given the definition in *def* and the
392392
ModuleSpec *spec*. This behaves like :c:func:`PyModule_FromDefAndSpec2`
393393
with *module_api_version* set to :const:`PYTHON_API_VERSION`.
394394
395395
.. versionadded:: 3.5
396396
397397
.. c:function:: PyObject * PyModule_FromDefAndSpec2(PyModuleDef *def, PyObject *spec, int module_api_version)
398398
399-
Create a new module object, given the definition in *module* and the
399+
Create a new module object, given the definition in *def* and the
400400
ModuleSpec *spec*, assuming the API version *module_api_version*.
401401
If that version does not match the version of the running interpreter,
402402
a :exc:`RuntimeWarning` is emitted.

Doc/library/argparse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ Sub-commands
18671867
...
18681868
>>> # create the top-level parser
18691869
>>> parser = argparse.ArgumentParser()
1870-
>>> subparsers = parser.add_subparsers()
1870+
>>> subparsers = parser.add_subparsers(required=True)
18711871
>>>
18721872
>>> # create the parser for the "foo" command
18731873
>>> parser_foo = subparsers.add_parser('foo')

Doc/library/asyncio-stream.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,20 @@ StreamReader
206206

207207
.. coroutinemethod:: read(n=-1)
208208

209-
Read up to *n* bytes. If *n* is not provided, or set to ``-1``,
210-
read until EOF and return all read bytes.
209+
Read up to *n* bytes from the stream.
211210

211+
If *n* is not provided or set to ``-1``,
212+
read until EOF, then return all read :class:`bytes`.
212213
If EOF was received and the internal buffer is empty,
213214
return an empty ``bytes`` object.
214215

216+
If *n* is ``0``, return an empty ``bytes`` object immediately.
217+
218+
If *n* is positive, return at most *n* available ``bytes``
219+
as soon as at least 1 byte is available in the internal buffer.
220+
If EOF is received before any byte is read, return an empty
221+
``bytes`` object.
222+
215223
.. coroutinemethod:: readline()
216224

217225
Read one line, where "line" is a sequence of bytes

Doc/library/csv.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ Reader objects have the following public attributes:
458458

459459
DictReader objects have the following public attribute:
460460

461-
.. attribute:: csvreader.fieldnames
461+
.. attribute:: DictReader.fieldnames
462462

463463
If not passed as a parameter when creating the object, this attribute is
464464
initialized upon first access or when the first record is read from the

Doc/library/enum.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -696,10 +696,9 @@ Data Types
696696

697697
.. attribute:: STRICT
698698

699-
Out-of-range values cause a :exc:`ValueError` to be raised. This is the
700-
default for :class:`Flag`::
699+
Out-of-range values cause a :exc:`ValueError` to be raised::
701700

702-
>>> from enum import Flag, STRICT
701+
>>> from enum import Flag, STRICT, auto
703702
>>> class StrictFlag(Flag, boundary=STRICT):
704703
... RED = auto()
705704
... GREEN = auto()
@@ -715,9 +714,9 @@ Data Types
715714
.. attribute:: CONFORM
716715

717716
Out-of-range values have invalid values removed, leaving a valid *Flag*
718-
value::
717+
value. This is the default for :class:`Flag`::
719718

720-
>>> from enum import Flag, CONFORM
719+
>>> from enum import Flag, CONFORM, auto
721720
>>> class ConformFlag(Flag, boundary=CONFORM):
722721
... RED = auto()
723722
... GREEN = auto()
@@ -731,7 +730,7 @@ Data Types
731730
Out-of-range values lose their *Flag* membership and revert to :class:`int`.
732731
This is the default for :class:`IntFlag`::
733732

734-
>>> from enum import Flag, EJECT
733+
>>> from enum import Flag, EJECT, auto
735734
>>> class EjectFlag(Flag, boundary=EJECT):
736735
... RED = auto()
737736
... GREEN = auto()
@@ -742,10 +741,10 @@ Data Types
742741

743742
.. attribute:: KEEP
744743

745-
Out-of-range values are kept, and the *Flag* membership is kept. This is
746-
used for some stdlib flags:
744+
Out-of-range values are kept, and the *Flag* membership is kept. This is
745+
used for some stdlib flags::
747746

748-
>>> from enum import Flag, KEEP
747+
>>> from enum import Flag, KEEP, auto
749748
>>> class KeepFlag(Flag, boundary=KEEP):
750749
... RED = auto()
751750
... GREEN = auto()

Doc/library/functions.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,6 +1635,9 @@ are always available. They are listed here in alphabetical order.
16351635
example: ``a[start:stop:step]`` or ``a[start:stop, i]``. See
16361636
:func:`itertools.islice` for an alternate version that returns an iterator.
16371637

1638+
.. versionchanged:: 3.12
1639+
Slice objects are now :term:`hashable` (provided :attr:`~slice.start`,
1640+
:attr:`~slice.stop`, and :attr:`~slice.step` are hashable).
16381641

16391642
.. function:: sorted(iterable, /, *, key=None, reverse=False)
16401643

Doc/library/plistlib.rst

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ Examples
159159

160160
Generating a plist::
161161

162+
import datetime
163+
import plistlib
164+
162165
pl = dict(
163166
aString = "Doodah",
164167
aList = ["A", "B", 12, 32.1, [1, 2, 3]],
@@ -172,13 +175,19 @@ Generating a plist::
172175
),
173176
someData = b"<binary gunk>",
174177
someMoreData = b"<lots of binary gunk>" * 10,
175-
aDate = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
178+
aDate = datetime.datetime.now()
176179
)
177-
with open(fileName, 'wb') as fp:
178-
dump(pl, fp)
180+
print(plistlib.dumps(pl).decode())
179181

180182
Parsing a plist::
181183

182-
with open(fileName, 'rb') as fp:
183-
pl = load(fp)
184-
print(pl["aKey"])
184+
import plistlib
185+
186+
plist = b"""<plist version="1.0">
187+
<dict>
188+
<key>foo</key>
189+
<string>bar</string>
190+
</dict>
191+
</plist>"""
192+
pl = plistlib.loads(plist)
193+
print(pl["foo"])

Doc/library/urllib.error.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
3131
of :exc:`IOError`.
3232

3333

34-
.. exception:: HTTPError
34+
.. exception:: HTTPError(url, code, msg, hdrs, fp)
3535

3636
Though being an exception (a subclass of :exc:`URLError`), an
3737
:exc:`HTTPError` can also function as a non-exceptional file-like return
3838
value (the same thing that :func:`~urllib.request.urlopen` returns). This
3939
is useful when handling exotic HTTP errors, such as requests for
4040
authentication.
4141

42+
.. attribute:: url
43+
44+
Contains the request URL.
45+
An alias for *filename* attribute.
46+
4247
.. attribute:: code
4348

4449
An HTTP status code as defined in :rfc:`2616`. This numeric value corresponds
@@ -48,14 +53,20 @@ The following exceptions are raised by :mod:`urllib.error` as appropriate:
4853
.. attribute:: reason
4954

5055
This is usually a string explaining the reason for this error.
56+
An alias for *msg* attribute.
5157

5258
.. attribute:: headers
5359

5460
The HTTP response headers for the HTTP request that caused the
5561
:exc:`HTTPError`.
62+
An alias for *hdrs* attribute.
5663

5764
.. versionadded:: 3.4
5865

66+
.. attribute:: fp
67+
68+
A file-like object where the HTTP error body can be read from.
69+
5970
.. exception:: ContentTooShortError(msg, content)
6071

6172
This exception is raised when the :func:`~urllib.request.urlretrieve`

Lib/asyncio/streams.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -649,16 +649,17 @@ async def readuntil(self, separator=b'\n'):
649649
async def read(self, n=-1):
650650
"""Read up to `n` bytes from the stream.
651651
652-
If n is not provided, or set to -1, read until EOF and return all read
653-
bytes. If the EOF was received and the internal buffer is empty, return
654-
an empty bytes object.
652+
If `n` is not provided or set to -1,
653+
read until EOF, then return all read bytes.
654+
If EOF was received and the internal buffer is empty,
655+
return an empty bytes object.
655656
656-
If n is zero, return empty bytes object immediately.
657+
If `n` is 0, return an empty bytes object immediately.
657658
658-
If n is positive, this function try to read `n` bytes, and may return
659-
less or equal bytes than requested, but at least one byte. If EOF was
660-
received before any byte is read, this function returns empty byte
661-
object.
659+
If `n` is positive, return at most `n` available bytes
660+
as soon as at least 1 byte is available in the internal buffer.
661+
If EOF is received before any byte is read, return an empty
662+
bytes object.
662663
663664
Returned value is not limited with limit, configured at stream
664665
creation.

0 commit comments

Comments
 (0)