8000 Merge branch 'main' into test-socket · python/cpython@d3a9a81 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3a9a81

Browse files
Merge branch 'main' into test-socket
2 parents 58c0815 + 7dacb70 commit d3a9a81

File tree

114 files changed

+41850
-32932
lines changed

Some content is hidden

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

114 files changed

+41850
-32932
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Objects/clinic/*.h linguist-generated=true
4747
PC/clinic/*.h linguist-generated=true
4848
Python/clinic/*.h linguist-generated=true
4949
Python/frozen_modules/*.h linguist-generated=true
50+
Python/frozen_modules/MANIFEST linguist-generated=true
5051
Include/internal/pycore_ast.h linguist-generated=true
5152
Python/Python-ast.c linguist-generated=true
5253
Include/opcode.h linguist-generated=true

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,15 @@ Tools/msi/obj
121121
Tools/ssl/amd64
122122
Tools/ssl/win32
123123

124+
# TODO: Once we auto-regen frozem modules for Windows builds
125+
# we can drop the .h files from the repo and ignore them here.
126+
# At that point we will rely the frozen manifest file to identify
127+
# changed generated files. We'll drop the entry for it then.
128+
# See: Tools/scripts/freeze_modules.py.
129+
#Python/frozen_modules/*.h
130+
# The manifest can be generated at any time with "make regen-frozen".
131+
Python/frozen_modules/MANIFEST
132+
124133
# Two-trick pony for OSX and other case insensitive file systems:
125134
# Ignore ./python binary on Unix but still look into ./Python/ directory.
126135
/python

Doc/c-api/typeobj.rst

Lines changed: 132 additions & 132 deletions
Large diffs are not rendered by default.

Doc/library/calendar.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,13 @@ interpreted as prescribed by the ISO 8601 standard. Year 0 is 1 BC, year -1 is
279279

280280
This subclass of :class:`TextCalendar` can be passed a locale name in the
281281
constructor and will return month and weekday names in the specified locale.
282-
If this locale includes an encoding all strings containing month and weekday
283-
names will be returned as unicode.
284282

285283

286284
.. class:: LocaleHTMLCalendar(firstweekday=0, locale=None)
287285

288286
This subclass of :class:`HTMLCalendar` can be passed a locale name in the
289287
constructor and will return month and weekday names in the specified
290-
locale. If this locale includes an encoding all strings containing month and
291-
weekday names will be returned as unicode.
288+
locale.
292289

293290
.. note::
294291

Doc/library/configparser.rst

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,28 +1200,6 @@ ConfigParser Objects
12001200
names is stripped before :meth:`optionxform` is called.
12011201

12021202

1203-
.. method:: readfp(fp, filename=None)
1204-
1205-
.. deprecated:: 3.2
1206-
Use :meth:`read_file` instead.
1207-
1208-
.. versionchanged:: 3.2
1209-
:meth:`readfp` now iterates on *fp* instead of calling ``fp.readline()``.
1210-
1211-
For existing code calling :meth:`readfp` with arguments which don't
1212-
support iteration, the following generator may be used as a wrapper
1213-
around the file-like object::
1214-
1215-
def readline_generator(fp):
1216-
line = fp.readline()
1217-
while line:
1218-
yield line
1219-
line = fp.readline()
1220-
1221-
Instead of ``parser.readfp(fp)`` use
1222-
``parser.read_file(readline_generator(fp))``.
1223-
1224-
12251203
.. data:: MAX_INTERPOLATION_DEPTH
12261204

12271205
The maximum depth for recursive interpolation for :meth:`get` when the *raw*
@@ -1359,6 +1337,9 @@ Exceptions
13591337
The ``filename`` attribute and :meth:`__init__` argument were renamed to
13601338
``source`` for consistency.
13611339

1340+
.. versionchanged:: 3.11
1341+
The deprecated ``filename`` attribute was removed.
1342+
13621343

13631344
.. rubric:: Footnotes
13641345

Doc/library/dis.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,13 @@ details of bytecode instructions as :class:`Instruction` instances:
293293

294294
.. data:: argval
295295

296-
resolved arg value (if known), otherwise same as arg
296+
resolved arg value (if any), otherwise ``None``
297297

298298

299299
.. data:: argrepr
300300

301-
human readable description of operation argument
301+
human readable description of operation argument (if any),
302+
otherwise an empty string.
302303

303304

304305
.. data:: offset

Doc/library/sqlite3.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,22 @@ Connection Objects
460460
Registers *trace_callback* to be called for each SQL statement that is
461461
actually executed by the SQLite backend.
462462

463-
The only argument passed to the callback is the statement (as string) that
464-
is being executed. The return value of the callback is ignored. Note that
465-
the backend does not only run statements passed to the :meth:`Cursor.execute`
466-
methods. Other sources include the transaction management of the Python
467-
module and the execution of triggers defined in the current database.
463+
The only argument passed to the callback is the statement (as
464+
:class:`str`) that is being executed. The return value of the callback is
465+
ignored. Note that the backend does not only run statements passed to the
466+
:meth:`Cursor.execute` methods. Other sources include the
467+
:ref:`transaction management <sqlite3-controlling-transactions>` of the
468+
sqlite3 module and the execution of triggers defined in the current
469+
database.
468470

469471
Passing :const:`None` as *trace_callback* will disable the trace callback.
470472

473+
.. note::
474+
Exceptions raised in the trace callback are not propagated. As a
475+
development and debugging aid, use
476+
:meth:`~sqlite3.enable_callback_tracebacks` to enable printing
477+
tracebacks from exceptions raised in the trace callback.
478+
471479
.. versionadded:: 3.3
472480

473481

Doc/library/stdtypes.rst

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Notes:
352352
The numeric literals accepted include the digits ``0`` to ``9`` or any
353353
Unicode equivalent (code points with the ``Nd`` property).
354354

355-
See https://www.unicode.org/Public/13.0.0/ucd/extracted/DerivedNumericType.txt
355+
See https://www.unicode.org/Public/14.0.0/ucd/extracted/DerivedNumericType.txt
356356
for a complete list of code points with the ``Nd`` property.
357357

358358

@@ -499,7 +499,7 @@ class`. In addition, it provides a few more methods:
499499

500500
.. versionadded:: 3.10
501501

502-
.. method:: int.to_bytes(length, byteorder, *, signed=False)
502+
.. method:: int.to_bytes(length=1, byteorder='big', *, signed=False)
503503

504504
Return an array of bytes representing an integer.
505505

@@ -513,25 +513,31 @@ class`. In addition, it provides a few more methods:
513513
>>> x.to_bytes((x.bit_length() + 7) // 8, byteorder='little')
514514
b'\xe8\x03'
515515

516-
The integer is represented using *length* bytes. An :exc:`OverflowError`
517-
is raised if the integer is not representable with the given number of
518-
bytes.
516+
The integer is represented using *length* bytes, and defaults to 1. An
517+
:exc:`OverflowError` is raised if the integer is not representable with
518+
the given number of bytes.
519519

520520
The *byteorder* argument determines the byte order used to represent the
521-
integer. If *byteorder* is ``"big"``, the most significant byte is at the
522-
beginning of the byte array. If *byteorder* is ``"little"``, the most
523-
significant byte is at the end of the byte array. To request the native
524-
byte order of the host system, use :data:`sys.byteorder` as the byte order
525-
value.
521+
integer, and defaults to ``"big"``. If *byteorder* is
522+
``"big"``, the most significant byte is at the beginning of the byte
523+
array. If *byteorder* is ``"little"``, the most significant byte is at
524+
the end of the byte array.
526525

527526
The *signed* argument determines whether two's complement is used to
528527
represent the integer. If *signed* is ``False`` and a negative integer is
529528
given, an :exc:`OverflowError` is raised. The default value for *signed*
530529
is ``False``.
531530

531+
The default values can be used to conveniently turn an integer into a
532+
single byte object. However, when using the default arguments, don't try
533+
to convert a value greater than 255 or you'll get an :exc:`OverflowError`::
534+
535+
>>> (65).to_bytes()
536+
b'A'
537+
532538
Equivalent to::
533539

534-
def to_bytes(n, length, byteorder, signed=False):
540+
def to_bytes(n, length=1, byteorder='big', signed=False):
535541
if byteorder == 'little':
536542
order = range(length)
537543
elif byteorder == 'big':
@@ -542,8 +548,10 @@ class`. In addition, it provides a few more methods:
542548
return bytes((n >> i*8) & 0xff for i in order)
543549

544550
.. versionadded:: 3.2
551+
.. versionchanged:: 3.11
552+
Added default argument values for ``length`` and ``byteorder``.
545553

546-
.. classmethod:: int.from_bytes(bytes, byteorder, *, signed=False)
554+
.. classmethod:: int.from_bytes(bytes, byteorder='big', *, signed=False)
547555

548556
Return the integer represented by the given array of bytes.
549557

@@ -562,18 +570,18 @@ class`. In addition, it provides a few more methods:
562570
iterable producing bytes.
563571

564572
The *byteorder* argument determines the byte order used to represent the
565-
integer. If *byteorder* is ``"big"``, the most significant byte is at the
566-
beginning of the byte array. If *byteorder* is ``"little"``, the most
567-
significant byte is at the end of the byte array. To request the native
568-
byte order of the host system, use :data:`sys.byteorder` as the byte order
569-
value.
573+
integer, and defaults to ``"big"``. If *byteorder* is
574+
``"big"``, the most significant byte is at the beginning of the byte
575+
array. If *byteorder* is ``"little"``, the most significant byte is at
576+
the end of the byte array. To request the native byte order of the host
577+
system, use :data:`sys.byteorder` as the byte order value.
570578

571579
The *signed* argument indicates whether two's complement is used to
572580
represent the integer.
573581

574582
Equivalent to::
575583

576-
def from_bytes(bytes, byteorder, signed=False):
584+
def from_bytes(bytes, byteorder='big', signed=False):
577585
if byteorder == 'little':
578586
little_ordered = list(bytes)
579587
elif byteorder == 'big':
@@ -588,6 +596,8 @@ class`. In addition, it provides a few more methods:
588596
return n
589597

590598
.. versionadded:: 3.2
599+
.. versionchanged:: 3.11
600+
Added default argument value for ``byteorder``.
591601

592602
.. method:: int.as_integer_ratio()
593603

Doc/library/unicodedata.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
This module provides access to the Unicode Character Database (UCD) which
1919
defines character properties for all Unicode characters. The data contained in
20-
this database is compiled from the `UCD version 13.0.0
21-
<https://www.unicode.org/Public/13.0.0/ucd>`_.
20+
this database is compiled from the `UCD version 14.0.0
21+
<https://www.unicode.org/Public/14.0.0/ucd>`_.
2222

2323
The module uses the same names and symbols as defined by Unicode
2424
Standard Annex #44, `"Unicode Character Database"
@@ -175,6 +175,6 @@ Examples:
175175

176176
.. rubric:: Footnotes
177177

178-
.. [#] https://www.unicode.org/Public/13.0.0/ucd/NameAliases.txt
178+
.. [#] https://www.unicode.org/Public/14.0.0/ucd/NameAliases.txt
179179
180-
.. [#] https://www.unicode.org/Public/13.0.0/ucd/NamedSequences.txt
180+
.. [#] https://www.unicode.org/Public/14.0.0/ucd/NamedSequences.txt

Doc/reference/lexical_analysis.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,16 @@ The Unicode category codes mentioned above stand for:
316316
* *Nd* - decimal numbers
317317
* *Pc* - connector punctuations
318318
* *Other_ID_Start* - explicit list of characters in `PropList.txt
319-
<https://www.unicode.org/Public/13.0.0/ucd/PropList.txt>`_ to support backwards
319+
<https://www.unicode.org/Public/14.0.0/ucd/PropList.txt>`_ to support backwards
320320
compatibility
321321
* *Other_ID_Continue* - likewise
322322

323323
All identifiers are converted into the normal form NFKC while parsing; comparison
324324
of identifiers is based on NFKC.
325325

326326
A non-normative HTML file listing all valid identifier characters for Unicode
327-
4.1 can be found at
328-
https://www.unicode.org/Public/13.0.0/ucd/DerivedCoreProperties.txt
327+
14.0.0 can be found at
328+
https://www.unicode.org/Public/14.0.0/ucd/DerivedCoreProperties.txt
329329

330330

331331
.. _keywords:

Doc/using/cmdline.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,12 @@ Miscellaneous options
480480
objects and pyc files are desired as well as supressing the extra visual
481481
location indicators when the interpreter displays tracebacks. See also
482482
:envvar:`PYTHONNODEBUGRANGES`.
483+
* ``-X frozen_modules`` determines whether or not frozen modules are
484+
ignored by the import machinery. A value of "on" means they get
485+
imported and "off" means they are ignored. The default is "on"
486+
for non-debug builds (the normal case) and "off" for debug builds.
487+
Note that the "importlib_bootstrap" and "importlib_bootstrap_external"
488+
frozen modules are always used, even if this flag is set to "off".
483489

484490
It also allows passing arbitrary values and retrieving them through the
485491
:data:`sys._xoptions` dictionary.
@@ -518,6 +524,9 @@ Miscellaneous options
518524
.. versionadded:: 3.11
519525
The ``-X no_debug_ranges`` option.
520526

527+
.. versionadded:: 3.11
528+
The ``-X frozen_modules`` option.
529+
521530

522531
Options you shouldn't use
523532
~~~~~~~~~~~~~~~~~~~~~~~~~

Doc/whatsnew/3.10.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -932,6 +932,12 @@ bdb
932932
Add :meth:`~bdb.Breakpoint.clearBreakpoints` to reset all set breakpoints.
933933
(Contributed by Irit Katriel in :issue:`24160`.)
934934
935+
bisect
936+
------
937+
938+
Added the possibility of providing a *key* function to the APIs in the :mod:`bisect`
939+
module. (Contributed by Raymond Hettinger in :issue:`4356`.)
940+
935941
codecs
936942
------
937943
< 10000 /span>

Doc/whatsnew/3.11.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ time
239239
interval specified with nanosecond precision.
240240
(Contributed by Livius and Victor Stinner in :issue:`21302`.)
241241

242+
unicodedata
243+
-----------
244+
245+
* The Unicode database has been updated to version 14.0.0. (:issue:`45190`).
246+
242247

243248
Removed
244249
=======
@@ -284,6 +289,13 @@ Removed
284289
the ``l*gettext()`` functions.
285290
(Contributed by Dong-hee Na and Serhiy Storchaka in :issue:`44235`.)
286291

292+
* Remove from the :mod:`configparser` module:
293+
the :class:`SafeConfigParser` class,
294+
the :attr:`filename` property of the :class:`ParsingError` class,
295+
the :meth:`readfp` method of the :class:`ConfigParser` class,
296+
deprecated since Python 3.2.
297+
(Contributed by Hugo van Kemenade in :issue:`45173`.)
298+
287299

288300
Optimizations
289301
=============
@@ -340,6 +352,21 @@ Deprecated
340352
:class:`~unittest.IsolatedAsyncioTestCase` test methods (other than the
341353
default ``None`` value), is now deprecated.
342354

355+
* Deprecated the following :mod:`unittest` functions, scheduled for removal in
356+
Python 3.13:
357+
358+
* :func:`unittest.findTestCases`
359+
* :func:`unittest.makeSuite`
360+
* :func:`unittest.getTestCaseNames`
361+
362+
Use :class:`~unittest.TestLoader` method instead:
363+
364+
* :meth:`unittest.TestLoader.loadTestsFromModule`
365+
* :meth:`unittest.TestLoader.loadTestsFromTestCase`
366+
* :meth:`unittest.TestLoader.getTestCaseNames`
367+
368+
(Contributed by Erlend E. Aasland in :issue:`5846`.)
369+
343370

344371
Removed
345372
=======

Include/cpython/initconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ typedef struct PyConfig {
172172
int legacy_windows_stdio;
173173
#endif
174174
wchar_t *check_hash_pycs_mode;
175+
int use_frozen_modules;
175176

176177
/* --- Path configuration inputs ------------ */
177178
int pathconfig_warnings;

Include/cpython/pytime.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
111111
PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
112112
_PyTime_round_t round);
113113

114+
/* Convert timestamp to a number of nanoseconds (10^-9 seconds). */
115+
PyAPI_FUNC(_PyTime_t) _PyTime_AsNanoseconds(_PyTime_t t);
116+
114117
/* Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
115118
object. */
116119
PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t);

Include/internal/pycore_initconfig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ extern PyStatus _PyConfig_Copy(
155155
extern PyStatus _PyConfig_InitPathConfig(
156156
PyConfig *config,
157157
int compute_path_config);
158+
extern PyStatus _PyConfig_InitImportConfig(PyConfig *config);
158159
extern PyStatus _PyConfig_Read(PyConfig *config, int compute_path_config);
159160
extern PyStatus _PyConfig_Write(const PyConfig *config,
160161
struct pyruntimestate *runtime);

Include/internal/pycore_interp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,9 @@ struct _is {
246246
PyObject *builtins;
247247
// importlib module
248248
PyObject *importlib;
249+
// override for config->use_frozen_modules (for tests)
250+
// (-1: "off", 1: "on", 0: no override)
251+
int override_frozen_modules;
249252

250253
/* Used in Modules/_threadmodule.c. */
251254
long num_threads;

0 commit comments

Comments
 (0)
0