Skip to content

Commit 861c41a

Browse files
authored
Merge pull request #502 from python/main
Sync Fork from Upstream Repo
2 parents fcb7a6d + f32c795 commit 861c41a

39 files changed

Lines changed: 391 additions & 249 deletions

Doc/library/numbers.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
The :mod:`numbers` module (:pep:`3141`) defines a hierarchy of numeric
1212
:term:`abstract base classes <abstract base class>` which progressively define
13-
more operations. None of the types defined in this module can be instantiated.
13+
more operations. None of the types defined in this module are intended to be instantiated.
1414

1515

1616
.. class:: Number

Doc/library/os.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4635,7 +4635,7 @@ operating system.
46354635

46364636
.. function:: sched_setparam(pid, param)
46374637

4638-
Set a scheduling parameters for the process with PID *pid*. A *pid* of 0 means
4638+
Set the scheduling parameters for the process with PID *pid*. A *pid* of 0 means
46394639
the calling process. *param* is a :class:`sched_param` instance.
46404640

46414641

Doc/library/statistics.rst

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -631,25 +631,25 @@ However, for reading convenience, most of the examples show sorted sequences.
631631
Return the intercept and slope of `simple linear regression
632632
<https://en.wikipedia.org/wiki/Simple_linear_regression>`_
633633
parameters estimated using ordinary least squares. Simple linear
634-
regression describes relationship between *regressor* and
635-
*dependent variable* in terms of linear function:
634+
regression describes the relationship between *regressor* and
635+
*dependent variable* in terms of this linear function:
636636

637637
*dependent_variable = intercept + slope \* regressor + noise*
638638

639639
where ``intercept`` and ``slope`` are the regression parameters that are
640-
estimated, and noise term is an unobserved random variable, for the
640+
estimated, and noise represents the
641641
variability of the data that was not explained by the linear regression
642-
(it is equal to the difference between prediction and the actual values
642+
(it is equal to the difference between predicted and actual values
643643
of dependent variable).
644644

645645
Both inputs must be of the same length (no less than two), and regressor
646-
needs not to be constant, otherwise :exc:`StatisticsError` is raised.
646+
needs not to be constant; otherwise :exc:`StatisticsError` is raised.
647647

648-
For example, if we took the data on the data on `release dates of the Monty
648+
For example, we can use the `release dates of the Monty
649649
Python films <https://en.wikipedia.org/wiki/Monty_Python#Films>`_, and used
650-
it to predict the cumulative number of Monty Python films produced, we could
651-
predict what would be the number of films they could have made till year
652-
2019, assuming that they kept the pace.
650+
it to predict the cumulative number of Monty Python films
651+
that would have been produced by 2019
652+
assuming that they kept the pace.
653653

654654
.. doctest::
655655

@@ -659,14 +659,6 @@ However, for reading convenience, most of the examples show sorted sequences.
659659
>>> round(intercept + slope * 2019)
660660
16
661661

662-
We could also use it to "predict" how many Monty Python films existed when
663-
Brian Cohen was born.
664-
665-
.. doctest::
666-
667-
>>> round(intercept + slope * 1)
668-
-610
669-
670662
.. versionadded:: 3.10
671663

672664

Doc/whatsnew/3.10.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ have been incorporated. Some of the most notable ones:
215215
216216
.. code-block:: python
217217
218-
>>> {x,y for x,y in range(100)}
218+
>>> {x,y for x,y in zip('abcd', '1234')}
219219
File "<stdin>", line 1
220-
{x,y for x,y in range(100)}
220+
{x,y for x,y in zip('abcd', '1234')}
221221
^
222222
SyntaxError: did you forget parentheses around the comprehension target?
223223

Include/opcode.h

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/ast.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,8 @@ class Param(expr_context):
640640
class _Precedence:
641641
"""Precedence table that originated from python grammar."""
642642

643-
TUPLE = auto()
643+
NAMED_EXPR = auto() # <target> := <expr1>
644+
TUPLE = auto() # <expr1>, <expr2>
644645
YIELD = auto() # 'yield', 'yield from'
645646
TEST = auto() # 'if'-'else', 'lambda'
646647
OR = auto() # 'or'
@@ -716,9 +717,9 @@ def fill(self, text=""):
716717
self.maybe_newline()
717718
self.write(" " * self._indent + text)
718719

719-
def write(self, text):
720-
"""Append a piece of text"""
721-
self._source.append(text)
720+
def write(self, *text):
721+
"""Add new source parts"""
722+
self._source.extend(text)
722723

723724
@contextmanager
724725
def buffered(self, buffer = None):
@@ -838,7 +839,7 @@ def visit_Expr(self, node):
838839
self.traverse(node.value)
839840

840841
def visit_NamedExpr(self, node):
841-
with self.require_parens(_Precedence.TUPLE, node):
842+
with self.require_parens(_Precedence.NAMED_EXPR, node):
842843
self.set_precedence(_Precedence.ATOM, node.target, node.value)
843844
self.traverse(node.target)
844845
self.write(" := ")
@@ -859,6 +860,7 @@ def visit_ImportFrom(self, node):
859860
def visit_Assign(self, node):
860861
self.fill()
861862
for target in node.targets:
863+
self.set_precedence(_Precedence.TUPLE, target)
862864
self.traverse(target)
863865
self.write(" = ")
864866
self.traverse(node.value)
@@ -1030,6 +1032,7 @@ def visit_AsyncFor(self, node):
10301032

10311033
def _for_helper(self, fill, node):
10321034
self.fill(fill)
1035+
self.set_precedence(_Precedence.TUPLE, node.target)
10331036
self.traverse(node.target)
10341037
self.write(" in ")
10351038
self.traverse(node.iter)
@@ -1315,7 +1318,7 @@ def write_item(item):
13151318
)
13161319

13171320
def visit_Tuple(self, node):
1318-
with self.delimit("(", ")"):
1321+
with self.require_parens(_Precedence.TUPLE, node):
13191322
self.items_view(self.traverse, node.elts)
13201323

13211324
unop = {"Invert": "~", "Not": "not", "UAdd": "+", "USub": "-"}
@@ -1566,8 +1569,11 @@ def visit_keyword(self, node):
15661569

15671570
def visit_Lambda(self, node):
15681571
with self.require_parens(_Precedence.TEST, node):
1569-
self.write("lambda ")
1570-
self.traverse(node.args)
1572+
self.write("lambda")
1573+
with self.buffered() as buffer:
1574+
self.traverse(node.args)
1575+
if buffer:
1576+
self.write(" ", *buffer)
15711577
self.write(": ")
15721578
self.set_precedence(_Precedence.TEST, node.body)
15731579
self.traverse(node.body)

Lib/bdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def dispatch_call(self, frame, arg):
119119
"""Invoke user function and return trace function for call event.
120120
121121
If the debugger stops on this function call, invoke
122-
self.user_call(). Raise BbdQuit if self.quitting is set.
122+
self.user_call(). Raise BdbQuit if self.quitting is set.
123123
Return self.trace_dispatch to continue tracing in this scope.
124124
"""
125125
# XXX 'arg' is no longer used

Lib/fractions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ def __bool__(a):
735735
# support for pickling, copy, and deepcopy
736736

737737
def __reduce__(self):
738-
return (self.__class__, (str(self),))
738+
return (self.__class__, (self._numerator, self._denominator))
739739

740740
def __copy__(self):
741741
if type(self) == Fraction:

Lib/gzip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def _add_read_data(self, data):
521521

522522
def _read_eof(self):
523523
# We've read to the end of the file
524-
# We check the that the computed CRC and size of the
524+
# We check that the computed CRC and size of the
525525
# uncompressed data matches the stored values. Note that the size
526526
# stored is the true file size mod 2**32.
527527
crc32, isize = struct.unpack("<II", self._read_exact(8))

Lib/importlib/_bootstrap_external.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ def _write_atomic(path, data, mode=0o666):
353353
# Python 3.10b1 3438 Safer line number table handling.
354354
# Python 3.10b1 3439 (Add ROT_N)
355355
# Python 3.11a1 3450 Use exception table for unwinding ("zero cost" exception handling)
356+
# Python 3.11a1 3451 (Add CALL_METHOD_KW)
356357

357358
#
358359
# MAGIC must change whenever the bytecode emitted by the compiler may no
@@ -362,7 +363,7 @@ def _write_atomic(path, data, mode=0o666):
362363
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
363364
# in PC/launcher.c must also be updated.
364365

365-
MAGIC_NUMBER = (3450).to_bytes(2, 'little') + b'\r\n'
366+
MAGIC_NUMBER = (3451).to_bytes(2, 'little') + b'\r\n'
366367
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
367368

368369
_PYCACHE = '__pycache__'

0 commit comments

Comments
 (0)