Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 27a4980

Browse filesBrowse files
committed
Merge branch 'main' into typewatch
* main: (38 commits) pythongh-92886: make test_ast pass with -O (assertions off) (pythonGH-98058) pythongh-92886: make test_coroutines pass with -O (assertions off) (pythonGH-98060) pythongh-57179: Add note on symlinks for os.walk (python#94799) pythongh-94808: Fix regex on exotic platforms (python#98036) pythongh-90085: Remove vestigial -t and -c timeit options (python#94941) pythonGH-83901: Improve Signature.bind error message for missing keyword-only params (python#95347) pythongh-61105: Add default param, note on using cookiejar subclass (python#95427) pythongh-96288: Add a sentence to `os.mkdir`'s docstring. (python#96271) pythongh-96073: fix backticks in NEWS entry (pythonGH-98056) pythongh-92886: [clinic.py] raise exception on invalid input instead of assertion (pythonGH-98051) pythongh-97997: Add col_offset field to tokenizer and use that for AST nodes (python#98000) pythonGH-88968: Reject socket that is already used as a transport (python#98010) pythongh-96346: Use double caching for re._compile() (python#96347) pythongh-91708: Revert params note in urllib.parse.urlparse table (python#96699) pythongh-96265: Fix some formatting in faq/design.rst (python#96924) pythongh-73196: Add namespace/scope clarification for inheritance section (python#92840) pythongh-97646: Change `.js` and `.mjs` files mimetype to conform to RFC 9239 (python#97934) pythongh-97923: Always run Ubuntu SSL tests with others in CI (python#97940) pythongh-97956: Mention `generate_global_objects.py` in `AC How-To` (python#97957) pythongh-96959: Update HTTP links which are redirected to HTTPS (python#98039) ...
2 parents 0de5aff + 27ce45d commit 27a4980
Copy full SHA for 27a4980

Some content is hidden

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

69 files changed

+1041
-342
lines changed

‎.github/workflows/build.yml

Copy file name to clipboardExpand all lines: .github/workflows/build.yml
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ jobs:
3131
runs-on: ubuntu-latest
3232
outputs:
3333
run_tests: ${{ steps.check.outputs.run_tests }}
34-
run_ssl_tests: ${{ steps.check.outputs.run_ssl_tests }}
3534
steps:
3635
- uses: actions/checkout@v3
3736
- name: Check for source changes
3837
id: check
3938
run: |
4039
if [ -z "$GITHUB_BASE_REF" ]; then
4140
echo '::set-output name=run_tests::true'
42-
echo '::set-output name=run_ssl_tests::true'
4341
else
4442
git fetch origin $GITHUB_BASE_REF --depth=1
4543
# git diff "origin/$GITHUB_BASE_REF..." (3 dots) may be more
@@ -56,7 +54,6 @@ jobs:
5654
#
5755
# https://github.com/python/core-workflow/issues/373
5856
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo '::set-output name=run_tests::true' || true
59-
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qE '(ssl|hashlib|hmac|^.github)' && echo '::set-output name=run_ssl_tests::true' || true
6057
fi
6158
6259
check_generated_files:
@@ -230,7 +227,7 @@ jobs:
230227
name: 'Ubuntu SSL tests with OpenSSL'
231228
runs-on: ubuntu-20.04
232229
needs: check_source
233-
if: needs.check_source.outputs.run_tests == 'true' && needs.check_source.outputs.run_ssl_tests == 'true'
230+
if: needs.check_source.outputs.run_tests == 'true'
234231
strategy:
235232
fail-fast: false
236233
matrix:

‎Doc/c-api/conversion.rst

Copy file name to clipboardExpand all lines: Doc/c-api/conversion.rst
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ not.
2828
The wrappers ensure that ``str[size-1]`` is always ``'\0'`` upon return. They
2929
never write more than *size* bytes (including the trailing ``'\0'``) into str.
3030
Both functions require that ``str != NULL``, ``size > 0``, ``format != NULL``
31-
and ``size < INT_MAX``.
31+
and ``size < INT_MAX``. Note that this means there is no equivalent to the C99
32+
``n = snprintf(NULL, 0, ...)`` which would determine the necessary buffer size.
3233
3334
The return value (*rv*) for these functions should be interpreted as follows:
3435

‎Doc/faq/design.rst

Copy file name to clipboardExpand all lines: Doc/faq/design.rst
+30-26Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ reference or call the method from a particular class. In C++, if you want to
129129
use a method from a base class which is overridden in a derived class, you have
130130
to use the ``::`` operator -- in Python you can write
131131
``baseclass.methodname(self, <argument list>)``. This is particularly useful
132-
for :meth:`__init__` methods, and in general in cases where a derived class
132+
for :meth:`~object.__init__` methods, and in general in cases where a derived class
133133
method wants to extend the base class method of the same name and thus has to
134134
call the base class method somehow.
135135

@@ -232,7 +232,8 @@ Similar methods exist for bytes and bytearray objects.
232232
How fast are exceptions?
233233
------------------------
234234

235-
A try/except block is extremely efficient if no exceptions are raised. Actually
235+
A :keyword:`try`/:keyword:`except` block is extremely efficient if no exceptions
236+
are raised. Actually
236237
catching an exception is expensive. In versions of Python prior to 2.0 it was
237238
common to use this idiom::
238239

@@ -352,7 +353,7 @@ will probably run out of file descriptors::
352353
c = f.read(1)
353354

354355
Indeed, using CPython's reference counting and destructor scheme, each new
355-
assignment to *f* closes the previous file. With a traditional GC, however,
356+
assignment to ``f`` closes the previous file. With a traditional GC, however,
356357
those file objects will only get collected (and closed) at varying and possibly
357358
long intervals.
358359

@@ -376,10 +377,10 @@ Python to work with it.)
376377

377378
Traditional GC also becomes a problem when Python is embedded into other
378379
applications. While in a standalone Python it's fine to replace the standard
379-
malloc() and free() with versions provided by the GC library, an application
380-
embedding Python may want to have its *own* substitute for malloc() and free(),
380+
``malloc()`` and ``free()`` with versions provided by the GC library, an application
381+
embedding Python may want to have its *own* substitute for ``malloc()`` and ``free()``,
381382
and may not want Python's. Right now, CPython works with anything that
382-
implements malloc() and free() properly.
383+
implements ``malloc()`` and ``free()`` properly.
383384

384385

385386
Why isn't all memory freed when CPython exits?
@@ -401,14 +402,15 @@ Why are there separate tuple and list data types?
401402

402403
Lists and tuples, while similar in many respects, are generally used in
403404
fundamentally different ways. Tuples can be thought of as being similar to
404-
Pascal records or C structs; they're small collections of related data which may
405+
Pascal ``records`` or C ``structs``; they're small collections of related data which may
405406
be of different types which are operated on as a group. For example, a
406407
Cartesian coordinate is appropriately represented as a tuple of two or three
407408
numbers.
408409

409410
Lists, on the other hand, are more like arrays in other languages. They tend to
410411
hold a varying number of objects all of which have the same type and which are
411-
operated on one-by-one. For example, ``os.listdir('.')`` returns a list of
412+
operated on one-by-one. For example, :func:`os.listdir('.') <os.listdir>`
413+
returns a list of
412414
strings representing the files in the current directory. Functions which
413415
operate on this output would generally not break if you added another file or
414416
two to the directory.
@@ -444,9 +446,9 @@ far) under most circumstances, and the implementation is simpler.
444446

445447
Dictionaries work by computing a hash code for each key stored in the dictionary
446448
using the :func:`hash` built-in function. The hash code varies widely depending
447-
on the key and a per-process seed; for example, "Python" could hash to
448-
-539294296 while "python", a string that differs by a single bit, could hash
449-
to 1142331976. The hash code is then used to calculate a location in an
449+
on the key and a per-process seed; for example, ``'Python'`` could hash to
450+
``-539294296`` while ``'python'``, a string that differs by a single bit, could hash
451+
to ``1142331976``. The hash code is then used to calculate a location in an
450452
internal array where the value will be stored. Assuming that you're storing
451453
keys that all have different hash values, this means that dictionaries take
452454
constant time -- O(1), in Big-O notation -- to retrieve a key.
@@ -497,7 +499,8 @@ Some unacceptable solutions that have been proposed:
497499

498500
There is a trick to get around this if you need to, but use it at your own risk:
499501
You can wrap a mutable structure inside a class instance which has both a
500-
:meth:`__eq__` and a :meth:`__hash__` method. You must then make sure that the
502+
:meth:`~object.__eq__` and a :meth:`~object.__hash__` method.
503+
You must then make sure that the
501504
hash value for all such wrapper objects that reside in a dictionary (or other
502505
hash based structure), remain fixed while the object is in the dictionary (or
503506
other structure). ::
@@ -528,7 +531,7 @@ is True``) then ``hash(o1) == hash(o2)`` (ie, ``o1.__hash__() == o2.__hash__()``
528531
regardless of whether the object is in a dictionary or not. If you fail to meet
529532
these restrictions dictionaries and other hash based structures will misbehave.
530533

531-
In the case of ListWrapper, whenever the wrapper object is in a dictionary the
534+
In the case of :class:`!ListWrapper`, whenever the wrapper object is in a dictionary the
532535
wrapped list must not change to avoid anomalies. Don't do this unless you are
533536
prepared to think hard about the requirements and the consequences of not
534537
meeting them correctly. Consider yourself warned.
@@ -581,9 +584,9 @@ exhaustive test suites that exercise every line of code in a module.
581584
An appropriate testing discipline can help build large complex applications in
582585
Python as well as having interface specifications would. In fact, it can be
583586
better because an interface specification cannot test certain properties of a
584-
program. For example, the :meth:`append` method is expected to add new elements
587+
program. For example, the :meth:`list.append` method is expected to add new elements
585588
to the end of some internal list; an interface specification cannot test that
586-
your :meth:`append` implementation will actually do this correctly, but it's
589+
your :meth:`list.append` implementation will actually do this correctly, but it's
587590
trivial to check this property in a test suite.
588591

589592
Writing test suites is very helpful, and you might want to design your code to
@@ -599,14 +602,14 @@ Why is there no goto?
599602
In the 1970s people realized that unrestricted goto could lead
600603
to messy "spaghetti" code that was hard to understand and revise.
601604
In a high-level language, it is also unneeded as long as there
602-
are ways to branch (in Python, with ``if`` statements and ``or``,
603-
``and``, and ``if-else`` expressions) and loop (with ``while``
604-
and ``for`` statements, possibly containing ``continue`` and ``break``).
605+
are ways to branch (in Python, with :keyword:`if` statements and :keyword:`or`,
606+
:keyword:`and`, and :keyword:`if`/:keyword:`else` expressions) and loop (with :keyword:`while`
607+
and :keyword:`for` statements, possibly containing :keyword:`continue` and :keyword:`break`).
605608

606609
One can also use exceptions to provide a "structured goto"
607610
that works even across
608611
function calls. Many feel that exceptions can conveniently emulate all
609-
reasonable uses of the "go" or "goto" constructs of C, Fortran, and other
612+
reasonable uses of the ``go`` or ``goto`` constructs of C, Fortran, and other
610613
languages. For example::
611614

612615
class label(Exception): pass # declare a label
@@ -620,7 +623,7 @@ languages. For example::
620623
...
621624

622625
This doesn't allow you to jump into the middle of a loop, but that's usually
623-
considered an abuse of goto anyway. Use sparingly.
626+
considered an abuse of ``goto`` anyway. Use sparingly.
624627

625628

626629
Why can't raw strings (r-strings) end with a backslash?
@@ -652,7 +655,7 @@ If you're trying to build a pathname for a DOS command, try e.g. one of ::
652655
Why doesn't Python have a "with" statement for attribute assignments?
653656
---------------------------------------------------------------------
654657

655-
Python has a 'with' statement that wraps the execution of a block, calling code
658+
Python has a :keyword:`with` statement that wraps the execution of a block, calling code
656659
on the entrance and exit from the block. Some languages have a construct that
657660
looks like this::
658661

@@ -679,13 +682,13 @@ For instance, take the following incomplete snippet::
679682
with a:
680683
print(x)
681684

682-
The snippet assumes that "a" must have a member attribute called "x". However,
685+
The snippet assumes that ``a`` must have a member attribute called ``x``. However,
683686
there is nothing in Python that tells the interpreter this. What should happen
684-
if "a" is, let us say, an integer? If there is a global variable named "x",
685-
will it be used inside the with block? As you see, the dynamic nature of Python
687+
if ``a`` is, let us say, an integer? If there is a global variable named ``x``,
688+
will it be used inside the :keyword:`with` block? As you see, the dynamic nature of Python
686689
makes such choices much harder.
687690

688-
The primary benefit of "with" and similar language features (reduction of code
691+
The primary benefit of :keyword:`with` and similar language features (reduction of code
689692
volume) can, however, easily be achieved in Python by assignment. Instead of::
690693

691694
function(args).mydict[index][index].a = 21
@@ -714,7 +717,8 @@ Why don't generators support the with statement?
714717
For technical reasons, a generator used directly as a context manager
715718
would not work correctly. When, as is most common, a generator is used as
716719
an iterator run to completion, no closing is needed. When it is, wrap
717-
it as "contextlib.closing(generator)" in the 'with' statement.
720+
it as :func:`contextlib.closing(generator) <contextlib.closing>`
721+
in the :keyword:`with` statement.
718722

719723

720724
Why are colons required for the if/while/def/class statements?

‎Doc/faq/library.rst

Copy file name to clipboardExpand all lines: Doc/faq/library.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ use ``p.read(n)``.
609609
substituted for standard input and output. You will have to use pseudo ttys
610610
("ptys") instead of pipes. Or you can use a Python interface to Don Libes'
611611
"expect" library. A Python extension that interfaces to expect is called
612-
"expy" and available from http://expectpy.sourceforge.net. A pure Python
612+
"expy" and available from https://expectpy.sourceforge.net. A pure Python
613613
solution that works like expect is `pexpect
614614
<https://pypi.org/project/pexpect/>`_.
615615

‎Doc/howto/clinic.rst

Copy file name to clipboardExpand all lines: Doc/howto/clinic.rst
+9-1Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,15 @@ Let's dive in!
539539
};
540540

541541

542-
16. Compile, then run the relevant portions of the regression-test suite.
542+
16. Argument Clinic may generate new instances of ``_Py_ID``. For example::
543+
544+
&_Py_ID(new_unique_py_id)
545+
546+
If it does, you'll have to run ``Tools/scripts/generate_global_objects.py``
547+
to regenerate the list of precompiled identifiers at this point.
548+
549+
550+
17. Compile, then run the relevant portions of the regression-test suite.
543551
This change should not introduce any new compile-time warnings or errors,
544552
and there should be no externally visible change to Python's behavior.
545553

‎Tools/scripts/diff.py renamed to ‎Doc/includes/diff.py

Copy file name to clipboardExpand all lines: Doc/includes/diff.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python3
21
""" Command line interface to difflib.py providing diffs in four formats:
32
43
* ndiff: lists every line and highlights interline changes.

‎Tools/scripts/ndiff.py renamed to ‎Doc/includes/ndiff.py

Copy file name to clipboardExpand all lines: Doc/includes/ndiff.py
+1-23Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
#! /usr/bin/env python3
2-
3-
# Module ndiff version 1.7.0
4-
# Released to the public domain 08-Dec-2000,
5-
# by Tim Peters (tim.one@home.com).
6-
7-
# Provided as-is; use at your own risk; no warranty; no promises; enjoy!
8-
9-
# ndiff.py is now simply a front-end to the difflib.ndiff() function.
10-
# Originally, it contained the difflib.SequenceMatcher class as well.
11-
# This completes the raiding of reusable code from this formerly
12-
# self-contained script.
13-
141
"""ndiff [-q] file1 file2
152
or
163
ndiff (-r1 | -r2) < ndiff_output > file1_or_file2
@@ -121,13 +108,4 @@ def restore(which):
121108
sys.stdout.writelines(restored)
122109

123110
if __name__ == '__main__':
124-
args = sys.argv[1:]
125-
if "-profile" in args:
126-
import profile, pstats
127-
args.remove("-profile")
128-
statf = "ndiff.pro"
129-
profile.run("main(args)", statf)
130-
stats = pstats.Stats(statf)
131-
stats.strip_dirs().sort_stats('time').print_stats()
132-
else:
133-
main(args)
111+
main(sys.argv[1:])

‎Doc/includes/tzinfo_examples.py

Copy file name to clipboardExpand all lines: Doc/includes/tzinfo_examples.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def first_sunday_on_or_after(dt):
7171
# DST start and end times. For a complete and up-to-date set of DST rules
7272
# and timezone definitions, visit the Olson Database (or try pytz):
7373
# http://www.twinsun.com/tz/tz-link.htm
74-
# http://sourceforge.net/projects/pytz/ (might not be up-to-date)
74+
# https://sourceforge.net/projects/pytz/ (might not be up-to-date)
7575
#
7676
# In the US, since 2007, DST starts at 2am (standard time) on the second
7777
# Sunday in March, which is the first Sunday on or after Mar 8.

‎Doc/library/csv.rst

Copy file name to clipboardExpand all lines: Doc/library/csv.rst
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ Dialects support the following attributes:
420420

421421
.. attribute:: Dialect.skipinitialspace
422422

423-
When :const:`True`, whitespace immediately following the *delimiter* is ignored.
423+
When :const:`True`, spaces immediately following the *delimiter* are ignored.
424424
The default is :const:`False`.
425425

426426

‎Doc/library/difflib.rst

Copy file name to clipboardExpand all lines: Doc/library/difflib.rst
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,6 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
145145
The arguments for this method are the same as those for the :meth:`make_file`
146146
method.
147147

148-
:file:`Tools/scripts/diff.py` is a command-line front-end to this class and
149-
contains a good example of its use.
150148

151149

152150
.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\n')
@@ -240,8 +238,6 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
240238
function :func:`IS_CHARACTER_JUNK`, which filters out whitespace characters (a
241239
blank or tab; it's a bad idea to include newline in this!).
242240

243-
:file:`Tools/scripts/ndiff.py` is a command-line front-end to this function.
244-
245241
>>> diff = ndiff('one\ntwo\nthree\n'.splitlines(keepends=True),
246242
... 'ore\ntree\nemu\n'.splitlines(keepends=True))
247243
>>> print(''.join(diff), end="")
@@ -759,7 +755,12 @@ A command-line interface to difflib
759755
-----------------------------------
760756

761757
This example shows how to use difflib to create a ``diff``-like utility.
762-
It is also contained in the Python source distribution, as
763-
:file:`Tools/scripts/diff.py`.
764758

765-
.. literalinclude:: ../../Tools/scripts/diff.py
759+
.. literalinclude:: ../includes/diff.py
760+
761+
ndiff example
762+
-------------
763+
764+
This example shows how to use :func:`difflib.ndiff`.
765+
766+
.. literalinclude:: ../includes/ndiff.py

‎Doc/library/dis.rst

Copy file name to clipboardExpand all lines: Doc/library/dis.rst
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ interpreter.
3030
Use 2 bytes for each instruction. Previously the number of bytes varied
3131
by instruction.
3232

33+
.. versionchanged:: 3.10
34+
The argument of jump, exception handling and loop instructions is now
35+
the instruction offset rather than the byte offset.
36+
3337
.. versionchanged:: 3.11
3438
Some instructions are accompanied by one or more inline cache entries,
3539
which take the form of :opcode:`CACHE` instructions. These instructions

‎Doc/library/functions.rst

Copy file name to clipboardExpand all lines: Doc/library/functions.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,8 @@ are always available. They are listed here in alphabetical order.
12541254

12551255
.. _open-newline-parameter:
12561256

1257-
*newline* controls how :term:`universal newlines` mode works (it only
1258-
applies to text mode). It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and
1257+
*newline* determines how to parse newline characters from the stream.
1258+
It can be ``None``, ``''``, ``'\n'``, ``'\r'``, and
12591259
``'\r\n'``. It works as follows:
12601260

12611261
* When reading input from the stream, if *newline* is ``None``, universal

‎Doc/library/functools.rst

Copy file name to clipboardExpand all lines: Doc/library/functools.rst
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ The :mod:`functools` module defines the following functions:
150150
arguments to the function must be hashable.
151151

152152
Distinct argument patterns may be considered to be distinct calls with
153-
separate cache entries. For example, `f(a=1, b=2)` and `f(b=2, a=1)`
153+
separate cache entries. For example, ``f(a=1, b=2)`` and ``f(b=2, a=1)``
154154
differ in their keyword argument order and may have two separate cache
155155
entries.
156156

@@ -197,7 +197,7 @@ The :mod:`functools` module defines the following functions:
197197
The cache keeps references to the arguments and return values until they age
198198
out of the cache or until the cache is cleared.
199199

200-
If a method is cached, the `self` instance argument is included in the
200+
If a method is cached, the ``self`` instance argument is included in the
201201
cache. See :ref:`faq-cache-method-calls`
202202

203203
An `LRU (least recently used) cache

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.