Skip to content

Commit 70c0e83

Browse files
Merge commit '3fa72d5c2e8188b5aca45e0c50349f9bdfda245f' into curses-term-attrs
2 parents b604fa3 + 3fa72d5 commit 70c0e83

7 files changed

Lines changed: 40 additions & 27 deletions

File tree

Doc/library/tkinter.messagebox.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Common message box styles and layouts include but are not limited to:
113113
.. function:: askretrycancel(title=None, message=None, **options)
114114

115115
Ask if operation should be retried. Shows buttons :data:`RETRY` and :data:`CANCEL`.
116-
Return ``True`` if the answer is yes and ``False`` otherwise.
116+
Return ``True`` if the answer is retry and ``False`` otherwise.
117117

118118
.. function:: askyesno(title=None, message=None, **options)
119119

Doc/library/tkinter.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,8 @@ cursor
770770
The standard X cursor names from :file:`cursorfont.h` can be used, without the
771771
``XC_`` prefix. For example to get a hand cursor (``XC_hand2``), use the
772772
string ``"hand2"``. You can also specify a bitmap and mask file of your own.
773+
On Windows a cursor file (:file:`.cur` or :file:`.ani`) may be used directly,
774+
giving its path preceded with an ``@``, as in ``"@C:/cursors/bart.ani"``.
773775
See page 179 of Ousterhout's book.
774776

775777
distance
@@ -883,6 +885,20 @@ they are denoted in Tk, which can be useful when referring to the Tk man pages.
883885
| %d | detail | %D | delta |
884886
+----+---------------------+----+---------------------+
885887

888+
The ``add`` parameter above only affects the bindings you make yourself.
889+
Every widget also inherits *class bindings*
890+
that implement its standard behavior --
891+
for example a :class:`Text` widget binds :kbd:`Control-t`
892+
to transpose two characters.
893+
These are described in the bindings section of the widget's Tk man page
894+
(such as :manpage:`text(3tk)` or :manpage:`entry(3tk)`).
895+
896+
Class bindings are processed separately from your own,
897+
so binding an event yourself does not replace the default; both run.
898+
To suppress an unwanted default binding,
899+
bind the event on the widget
900+
and return the string ``"break"`` from your callback.
901+
886902

887903
The index parameter
888904
^^^^^^^^^^^^^^^^^^^

Lib/test/test_curses.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,10 @@ def test_putwin(self):
11201120
def test_scr_dump(self):
11211121
# Test scr_dump(), scr_restore(), scr_init() and scr_set().
11221122
# scr_dump() writes the virtual screen to a named file; the other three
1123-
# functions load it back. The dumped image is internal curses state,
1124-
# not a window, so the round-trip is checked by comparing dump files
1125-
# rather than reading cells.
1123+
# load it back. The dump is opaque internal curses state -- on some
1124+
# platforms (such as macOS) it embeds raw pointers that change whenever
1125+
# the screen is reallocated -- so the round-trip is exercised
1126+
# functionally rather than by comparing dump bytes.
11261127
stdscr = self.stdscr
11271128
stdscr.erase()
11281129
stdscr.addstr(0, 0, 'screen dump test')
@@ -1131,27 +1132,14 @@ def test_scr_dump(self):
11311132
dump = os.path.join(d, 'dump')
11321133
self.assertIsNone(curses.scr_dump(dump))
11331134
with open(dump, 'rb') as f:
1134-
image = f.read()
1135-
self.assertTrue(image)
1136-
# The dump format embeds raw pointers on some platforms (such as
1137-
# macOS), so two dumps of the same screen are not always identical.
1138-
# Only compare dump files when the format proves deterministic.
1139-
dump2 = os.path.join(d, 'dump2')
1140-
curses.scr_dump(dump2)
1141-
with open(dump2, 'rb') as f:
1142-
deterministic = f.read() == image
1143-
# scr_restore() reloads that virtual screen, so dumping it again
1144-
# reproduces the original file even after the screen has changed.
1135+
self.assertTrue(f.read())
1136+
# scr_restore() reloads the saved virtual screen, even after the
1137+
# screen has changed.
11451138
stdscr.erase()
11461139
stdscr.addstr(0, 0, 'something else')
11471140
stdscr.refresh()
11481141
self.assertIsNone(curses.scr_restore(dump))
1149-
if deterministic:
1150-
restored = os.path.join(d, 'restored')
1151-
curses.scr_dump(restored)
1152-
with open(restored, 'rb') as f:
1153-
self.assertEqual(f.read(), image)
1154-
# scr_init() and scr_set() accept a dump file and return None.
1142+
# scr_init() and scr_set() also accept a dump file and return None.
11551143
self.assertIsNone(curses.scr_init(dump))
11561144
self.assertIsNone(curses.scr_set(dump))
11571145
# A bytes (path-like) filename is accepted too.

Lib/test/test_zoneinfo/test_zoneinfo.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,11 @@ def test_extreme_tzstr(self):
11421142
def test_invalid_tzstr(self):
11431143
invalid_tzstrs = [
11441144
"PST8PDT", # DST but no transition specified
1145+
# gh-152212: the std offset is required (POSIX TZ grammar)
1146+
"AAA",
1147+
"A",
1148+
"AA",
1149+
"B",
11451150
"+11", # Unquoted alphanumeric
11461151
"GMT,M3.2.0/2,M11.1.0/3", # Transition rule but no DST
11471152
"GMT0+11,M3.2.0/2,M11.1.0/3", # Unquoted alphanumeric in DST

Lib/tkinter/messagebox.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,24 +99,24 @@ def showerror(title=None, message=None, **options):
9999

100100

101101
def askquestion(title=None, message=None, **options):
102-
"Ask a question"
102+
"Ask a question; return the symbolic name of the selected button"
103103
return _show(title, message, QUESTION, YESNO, **options)
104104

105105

106106
def askokcancel(title=None, message=None, **options):
107-
"Ask if operation should proceed; return true if the answer is ok"
107+
"Ask if operation should proceed; return True if the answer is ok"
108108
s = _show(title, message, QUESTION, OKCANCEL, **options)
109109
return s == OK
110110

111111

112112
def askyesno(title=None, message=None, **options):
113-
"Ask a question; return true if the answer is yes"
113+
"Ask a question; return True if the answer is yes"
114114
s = _show(title, message, QUESTION, YESNO, **options)
115115
return s == YES
116116

117117

118118
def askyesnocancel(title=None, message=None, **options):
119-
"Ask a question; return true if the answer is yes, None if cancelled."
119+
"Ask a question; return True if the answer is yes, None if cancelled"
120120
s = _show(title, message, QUESTION, YESNOCANCEL, **options)
121121
# s might be a Tcl index object, so convert it to a string
122122
s = str(s)
@@ -126,7 +126,7 @@ def askyesnocancel(title=None, message=None, **options):
126126

127127

128128
def askretrycancel(title=None, message=None, **options):
129-
"Ask if operation should be retried; return true if the answer is yes"
129+
"Ask if operation should be retried; return True if the answer is retry"
130130
s = _show(title, message, WARNING, RETRYCANCEL, **options)
131131
return s == RETRY
132132

Lib/zoneinfo/_zoneinfo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,8 @@ def _parse_tz_str(tz_str):
672672
except ValueError as e:
673673
raise ValueError(f"Invalid STD offset in {tz_str}") from e
674674
else:
675-
std_offset = 0
675+
# The STD offset is required
676+
raise ValueError(f"Invalid STD offset in {tz_str}")
676677

677678
if dst_abbr is not None:
678679
if dst_offset := m.group("dstoff"):
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix the pure-Python :mod:`zoneinfo` parser accepting a POSIX TZ string with a
2+
``std`` abbreviation but no offset. This is invalid per POSIX and now
3+
raises :exc:`ValueError`, matching the C accelerator. Patch by tonghuaroot.

0 commit comments

Comments
 (0)