Skip to content

Commit 1c67d9e

Browse files
committed
Merge remote-tracking branch 'upstream/3.13' into openssl-35_3.13
2 parents 1f065b5 + f81c8e8 commit 1c67d9e

42 files changed

Lines changed: 750 additions & 380 deletions

Some content is hidden

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

‎Doc/conf.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@
462462
# https://github.com/sphinx-doc/sphinx/issues/12359
463463
epub_use_index = False
464464

465+
# The default depth of 3 lists over a thousand entries, which makes the
466+
# table of contents hard to navigate in e-book readers
467+
epub_tocdepth = 2
468+
465469
# translation tag
466470
# ---------------
467471

‎Doc/library/turtle.rst‎

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,6 @@
1717

1818
--------------
1919

20-
Introduction
21-
============
22-
23-
Turtle graphics is an implementation of `the popular geometric drawing tools
24-
introduced in Logo <https://en.wikipedia.org/wiki/Turtle_
25-
(robot)>`_, developed by Wally Feurzeig, Seymour Papert and Cynthia Solomon
26-
in 1967.
27-
28-
29-
Get started
30-
===========
31-
32-
Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an ``import turtle``, give it the
33-
command ``turtle.forward(15)``, and it moves (on-screen!) 15 pixels in the
34-
direction it is facing, drawing a line as it moves. Give it the command
35-
``turtle.right(25)``, and it rotates in-place 25 degrees clockwise.
36-
3720
.. sidebar:: Turtle star
3821

3922
Turtle can draw intricate shapes using programs that repeat simple
@@ -42,21 +25,40 @@ direction it is facing, drawing a line as it moves. Give it the command
4225
.. image:: turtle-star.*
4326
:align: center
4427

45-
In Python, turtle graphics provides a representation of a physical "turtle"
46-
(a little robot with a pen) that draws on a sheet of paper on the floor.
28+
Imagine a robotic turtle starting at (0, 0) in the x-y plane.
29+
After an ``import turtle``, give it the command ``turtle.forward(15)``, and it
30+
moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as
31+
it moves. Give it the command ``turtle.right(25)``, and it rotates in-place 25
32+
degrees clockwise.
33+
34+
Turtle graphics is an implementation of `the drawing tools introduced in Logo
35+
<https://en.wikipedia.org/wiki/Turtle_(robot)>`_ in 1967. It was created as an
36+
educational tool, and its instant, visible feedback makes it an effective way
37+
for learners to encounter programming concepts. It is also a convenient way to
38+
produce simple graphical output without bringing in external libraries.
39+
40+
This document includes four main sections:
4741

48-
It's an effective and well-proven way for learners to encounter
49-
programming concepts and interaction with software, as it provides instant,
50-
visible feedback. It also provides convenient access to graphical output
51-
in general.
42+
* :ref:`turtle-tutorial` teaches the basics of turtle drawing.
43+
* :ref:`turtle-reference` describes the functions, methods and classes this
44+
module defines.
45+
* :ref:`turtle-howtos` details how to handle specific tasks.
46+
* :ref:`turtle-explanation` provides background on the object-oriented
47+
interface.
48+
49+
.. note::
5250

53-
Turtle drawing was originally created as an educational tool, to be used by
54-
teachers in the classroom. For the programmer who needs to produce some
55-
graphical output it can be a way to do that without the overhead of
56-
introducing more complex or external libraries into their work.
51+
Turtle graphics requires the :mod:`tkinter` optional module.
52+
The python.org installers for Windows and macOS include it, but some
53+
Linux distributions and other platforms may package it separately. If
54+
``import turtle`` fails with an error mentioning ``_tkinter``, look for
55+
documentation from your distributor (that is, whoever provided Python to you).
56+
Check this in advance if you're planning to use turtle graphics with a learner.
5757

5858

5959
.. _turtle-tutorial:
60+
.. _get-started:
61+
.. _get-started-as-quickly-as-possible:
6062

6163
Tutorial
6264
========
@@ -99,7 +101,8 @@ Notice how the turtle, represented by an arrow, points in different
99101
directions as you steer it.
100102

101103
Experiment with those commands, and also with ``backward()`` and
102-
``right()``.
104+
``right()``. Many commands also have terser aliases, such as ``fd()`` for
105+
:func:`forward`.
103106

104107

105108
Pen control
@@ -179,38 +182,16 @@ Finally, complete the filling::
179182
``end_fill()`` command.)
180183

181184

185+
.. _turtle-howtos:
182186
.. _turtle-how-to:
187+
.. _how-to:
183188

184-
How to...
185-
=========
189+
How-to guides
190+
=============
186191

187192
This section covers some typical turtle use-cases and approaches.
188193

189194

190-
Get started as quickly as possible
191-
----------------------------------
192-
193-
One of the joys of turtle graphics is the immediate, visual feedback that's
194-
available from simple commands - it's an excellent way to introduce children
195-
to programming ideas, with a minimum of overhead (not just children, of
196-
course).
197-
198-
The turtle module makes this possible by exposing all its basic functionality
199-
as functions, available with ``from turtle import *``. The :ref:`turtle
200-
graphics tutorial <turtle-tutorial>` covers this approach.
201-
202-
It's worth noting that many of the turtle commands also have even more terse
203-
equivalents, such as ``fd()`` for :func:`forward`. These are especially
204-
useful when working with learners for whom typing is not a skill.
205-
206-
.. _note:
207-
208-
You'll need to have the :mod:`Tk interface package <tkinter>` installed on
209-
your system for turtle graphics to work. Be warned that this is not
210-
always straightforward, so check this in advance if you're planning to
211-
use turtle graphics with a learner.
212-
213-
214195
Use the ``turtle`` module namespace
215196
-----------------------------------
216197

@@ -289,8 +270,11 @@ The turtle's screen can be customised, for example::
289270
t.screen.bgcolor("orange")
290271

291272

292-
Turtle graphics reference
293-
=========================
273+
.. _turtle-reference:
274+
.. _turtle-graphics-reference:
275+
276+
Reference
277+
=========
294278

295279
.. note::
296280

‎Doc/library/uuid.rst‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ which relays any information about the UUID's safety, using this enumeration:
4444

4545
.. class:: UUID(hex=None, bytes=None, bytes_le=None, fields=None, int=None, version=None, *, is_safe=SafeUUID.unknown)
4646

47-
Create a UUID from either a string of 32 hexadecimal digits, a string of 16
48-
bytes in big-endian order as the *bytes* argument, a string of 16 bytes in
49-
little-endian order as the *bytes_le* argument, a tuple of six integers
47+
Create a UUID from either a string of 32 hexadecimal digits, a 16-byte
48+
:class:`bytes` object in big-endian order as the *bytes* argument, a
49+
16-byte :class:`bytes` object in little-endian order as the *bytes_le*
50+
argument, a tuple of six integers
5051
(32-bit *time_low*, 16-bit *time_mid*, 16-bit *time_hi_version*,
5152
8-bit *clock_seq_hi_variant*, 8-bit *clock_seq_low*, 48-bit *node*) as the
5253
*fields* argument, or a single 128-bit integer as the *int* argument.
@@ -80,14 +81,14 @@ which relays any information about the UUID's safety, using this enumeration:
8081

8182
.. attribute:: UUID.bytes
8283

83-
The UUID as a 16-byte string (containing the six integer fields in big-endian
84-
byte order).
84+
The UUID as a 16-byte :class:`bytes` object (containing the six integer
85+
fields in big-endian byte order).
8586

8687

8788
.. attribute:: UUID.bytes_le
8889

89-
The UUID as a 16-byte string (with *time_low*, *time_mid*, and *time_hi_version*
90-
in little-endian byte order).
90+
The UUID as a 16-byte :class:`bytes` object (with *time_low*, *time_mid*,
91+
and *time_hi_version* in little-endian byte order).
9192

9293

9394
.. attribute:: UUID.fields
@@ -340,7 +341,7 @@ Here are some examples of typical usage of the :mod:`uuid` module::
340341
>>> x.bytes
341342
b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
342343

343-
>>> # make a UUID from a 16-byte string
344+
>>> # make a UUID from a 16-byte bytes object
344345
>>> uuid.UUID(bytes=x.bytes)
345346
UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
346347

‎Grammar/python.gram‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ compare_op_bitwise_or_pair[CmpopExprPair*]:
748748
| eq_bitwise_or
749749
| noteq_bitwise_or
750750
| lte_bitwise_or
751+
| invalid_noteq
751752
| lt_bitwise_or
752753
| gte_bitwise_or
753754
| gt_bitwise_or
@@ -1439,3 +1440,10 @@ invalid_type_params:
14391440
RAISE_SYNTAX_ERROR_STARTING_FROM(
14401441
token,
14411442
"Type parameter list cannot be empty")}
1443+
1444+
invalid_noteq:
1445+
| a='<' b='>' {
1446+
_PyPegen_tokens_are_adjacent(a, b)
1447+
? RAISE_SYNTAX_ERROR_KNOWN_RANGE(a, b, "invalid syntax. Maybe you meant '!=' instead of '<>'?")
1448+
: NULL
1449+
}

‎Lib/_pyrepl/unix_console.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ def prepare(self):
363363
raw.cc[termios.VMIN] = 1
364364
raw.cc[termios.VTIME] = 0
365365
self.__input_fd_set(raw)
366+
self.__rawtermstate = raw
366367

367368
# In macOS terminal we need to deactivate line wrap via ANSI escape code
368369
if self.is_apple_terminal:
@@ -599,7 +600,20 @@ def input_hook(self):
599600
except ImportError:
600601
return None
601602
if posix._is_inputhook_installed():
602-
return posix._inputhook
603+
return self.__run_input_hook
604+
605+
def __run_input_hook(self):
606+
import posix
607+
# gh-152907: input hooks expect cooked output, but pyrepl runs with
608+
# OPOST disabled. Restore the saved output flags around the hook
609+
# (only oflag; input must stay raw at the prompt).
610+
cooked = self.__rawtermstate.copy()
611+
cooked.oflag = self.__svtermstate.oflag
612+
self.__input_fd_set(cooked)
613+
try:
614+
return posix._inputhook()
615+
finally:
616+
self.__input_fd_set(self.__rawtermstate)
603617

604618
def __enable_bracketed_paste(self) -> None:
605619
os.write(self.output_fd, b"\x1b[?2004h")

‎Lib/idlelib/idle_test/test_outwin.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ def test_save_defaults_to_text(self):
4646
io = self.window.io
4747
self.assertEqual(io.defaultextension, '.txt')
4848
# Text files are offered before Python files.
49-
self.assertEqual(io.filetypes[0][0], 'Text files')
49+
self.assertEqual(io.save_filetypes[0][0], 'Text files')
50+
51+
def test_open_defaults_to_python(self):
52+
# gh-158067: File Open still lists Python files first.
53+
self.assertEqual(self.window.io.filetypes[0][0], 'Python files')
5054

5155
def test_window_title(self):
5256
self.assertEqual(self.window.top.title(), 'Output' + ' (%s)' % platform.python_version())

‎Lib/idlelib/iomenu.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,10 @@ def print_window(self, event):
386386
("All files", "*"),
387387
)
388388

389-
# Output windows (Shell, Output) are not Python source, so they list
390-
# text files first and default to ".txt" (gh-65339).
389+
save_filetypes = filetypes
390+
391+
# Output windows (Shell, Output) are not Python source, so they save
392+
# with text files listed first and default to ".txt" (gh-65339).
391393
text_filetypes = (
392394
("Text files", "*.txt", "TEXT"),
393395
("Python files", py_extensions, "TEXT"),
@@ -427,7 +429,7 @@ def asksavefile(self):
427429
if not self.savedialog:
428430
self.savedialog = filedialog.SaveAs(
429431
parent=self.text,
430-
filetypes=self.filetypes,
432+
filetypes=self.save_filetypes,
431433
defaultextension=self.defaultextension)
432434
filename = self.savedialog.show(initialdir=dir, initialfile=base)
433435
return filename

‎Lib/idlelib/outwin.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __init__(self, *args):
8080
self.text.bind("<<goto-file-line>>", self.goto_file_line)
8181
# Output is not Python source, so save it as text by default
8282
# (gh-65339).
83-
self.io.filetypes = self.io.text_filetypes
83+
self.io.save_filetypes = self.io.text_filetypes
8484
self.io.defaultextension = self.io.text_defaultextension
8585

8686
# Customize EditorWindow

‎Lib/idlelib/run.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def main(del_exitfunc=False):
164164
).start()
165165

166166
while True:
167+
request = None
167168
try:
168169
if exit_now:
169170
try:
@@ -174,9 +175,9 @@ def main(del_exitfunc=False):
174175
try:
175176
request = rpc.request_queue.get(block=True, timeout=0.05)
176177
except queue.Empty:
177-
request = None
178178
# Issue 32207: calling handle_tk_events here adds spurious
179179
# queue.Empty traceback to event handling exceptions.
180+
pass
180181
if request:
181182
seq, (method, args, kwargs) = request
182183
ret = method(*args, **kwargs)
@@ -186,6 +187,10 @@ def main(del_exitfunc=False):
186187
except KeyboardInterrupt:
187188
if quitting:
188189
exit_now = True
190+
elif request:
191+
# Interrupted while executing a request, as when debugging.
192+
print_exception()
193+
rpc.response_queue.put((seq, None))
189194
continue
190195
except SystemExit:
191196
capture_warnings(False)

‎Lib/idlelib/sidebar.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ def mkcmd(eventname):
453453
return "break"
454454

455455
def grid(self):
456-
self.canvas.grid(row=1, column=0, sticky=tk.NSEW, padx=2, pady=0)
456+
self.canvas.grid(row=1, column=0, sticky=tk.NSEW)
457457

458458
def change_callback(self):
459459
if self.is_shown:

0 commit comments

Comments
 (0)