Skip to content

Commit dbd885f

Browse files
committed
updated to python 3.9.5
1 parent 657aed3 commit dbd885f

Some content is hidden

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

82 files changed

+522
-327
lines changed

PythonLib/full/ctypes/test/test_unicode.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ def test_buffers(self):
2626
self.assertEqual(buf[::2], 'a\xe4\xfc')
2727
self.assertEqual(buf[6:5:-1], "")
2828

29+
def test_embedded_null(self):
30+
class TestStruct(ctypes.Structure):
31+
_fields_ = [("unicode", ctypes.c_wchar_p)]
32+
t = TestStruct()
33+
# This would raise a ValueError:
34+
t.unicode = "foo\0bar\0\0"
35+
36+
2937
func = ctypes.CDLL(_ctypes_test.__file__)._testfunc_p_p
3038

3139
class StringTestCase(UnicodeTestCase):

PythonLib/full/dataclasses.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ def _get_field(cls, a_name, a_type):
696696
# In addition to checking for actual types here, also check for
697697
# string annotations. get_type_hints() won't always work for us
698698
# (see https://github.com/python/typing/issues/508 for example),
699-
# plus it's expensive and would require an eval for every stirng
699+
# plus it's expensive and would require an eval for every string
700700
# annotation. So, make a best effort to see if this is a ClassVar
701701
# or InitVar using regex's and checking that the thing referenced
702702
# is actually of the correct type.
@@ -836,7 +836,7 @@ def _process_class(cls, init, repr, eq, order, unsafe_hash, frozen):
836836
# Only process classes that have been processed by our
837837
# decorator. That is, they have a _FIELDS attribute.
838838
base_fields = getattr(b, _FIELDS, None)
839-
if base_fields:
839+
if base_fields is not None:
840840
has_dataclass_bases = True
841841
for f in base_fields.values():
842842
fields[f.name] = f
@@ -1271,7 +1271,7 @@ class C:
12711271
continue
12721272

12731273
if f.name not in changes:
1274-
if f._field_type is _FIELD_INITVAR:
1274+
if f._field_type is _FIELD_INITVAR and f.default is MISSING:
12751275
raise ValueError(f"InitVar {f.name!r} "
12761276
'must be specified with replace()')
12771277
changes[f.name] = getattr(obj, f.name)

PythonLib/full/ensurepip/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
__all__ = ["version", "bootstrap"]
1414

1515

16-
_SETUPTOOLS_VERSION = "49.2.1"
16+
_SETUPTOOLS_VERSION = "56.0.0"
1717

18-
_PIP_VERSION = "20.2.3"
18+
_PIP_VERSION = "21.1.1"
1919

2020
_PROJECTS = [
2121
("setuptools", _SETUPTOOLS_VERSION, "py3"),
22-
("pip", _PIP_VERSION, "py2.py3"),
22+
("pip", _PIP_VERSION, "py3"),
2323
]
2424

2525

PythonLib/full/ensurepip/_bundled/pip-20.2.3-py2.py3-none-any.whl renamed to PythonLib/full/ensurepip/_bundled/pip-21.1.1-py3-none-any.whl

1.43 MB
Binary file not shown.

PythonLib/full/ensurepip/_bundled/setuptools-49.2.1-py3-none-any.whl renamed to PythonLib/full/ensurepip/_bundled/setuptools-56.0.0-py3-none-any.whl

771 KB
Binary file not shown.

PythonLib/full/enum.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,24 @@ def __new__(cls, value):
669669
except Exception as e:
670670
exc = e
671671
result = None
672-
if isinstance(result, cls):
673-
return result
674-
else:
675-
ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
676-
if result is None and exc is None:
677-
raise ve_exc
678-
elif exc is None:
679-
exc = TypeError(
680-
'error in %s._missing_: returned %r instead of None or a valid member'
681-
% (cls.__name__, result)
682-
)
683-
exc.__context__ = ve_exc
684-
raise exc
672+
try:
673+
if isinstance(result, cls):
674+
return result
675+
else:
676+
ve_exc = ValueError("%r is not a valid %s" % (value, cls.__qualname__))
677+
if result is None and exc is None:
678+
raise ve_exc
679+
elif exc is None:
680+
exc = TypeError(
681+
'error in %s._missing_: returned %r instead of None or a valid member'
682+
% (cls.__name__, result)
683+
)
684+
exc.__context__ = ve_exc
685+
raise exc
686+
finally:
687+
# ensure all variables that could hold an exception are destroyed
688+
exc = None
689+
ve_exc = None
685690

686691
def _generate_next_value_(name, start, count, last_values):
687692
"""

PythonLib/full/idlelib/colorizer.py

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88

99
DEBUG = False
1010

11+
1112
def any(name, alternates):
1213
"Return a named group pattern matching list of alternates."
1314
return "(?P<%s>" % name + "|".join(alternates) + ")"
1415

16+
1517
def make_pat():
1618
kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
1719
builtinlist = [str(name) for name in dir(builtins)
18-
if not name.startswith('_') and \
19-
name not in keyword.kwlist]
20+
if not name.startswith('_') and
21+
name not in keyword.kwlist]
2022
builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
2123
comment = any("COMMENT", [r"#[^\n]*"])
2224
stringprefix = r"(?i:r|u|f|fr|rf|b|br|rb)?"
@@ -25,12 +27,14 @@ def make_pat():
2527
sq3string = stringprefix + r"'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
2628
dq3string = stringprefix + r'"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
2729
string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
28-
return kw + "|" + builtin + "|" + comment + "|" + string +\
29-
"|" + any("SYNC", [r"\n"])
30+
return (kw + "|" + builtin + "|" + comment + "|" + string +
31+
"|" + any("SYNC", [r"\n"]))
32+
3033

3134
prog = re.compile(make_pat(), re.S)
3235
idprog = re.compile(r"\s+(\w+)", re.S)
3336

37+
3438
def color_config(text):
3539
"""Set color options of Text widget.
3640
@@ -49,7 +53,7 @@ def color_config(text):
4953
selectforeground=select_colors['foreground'],
5054
selectbackground=select_colors['background'],
5155
inactiveselectbackground=select_colors['background'], # new in 8.5
52-
)
56+
)
5357

5458

5559
class ColorDelegator(Delegator):
@@ -120,14 +124,17 @@ def LoadTagDefs(self):
120124
"BUILTIN": idleConf.GetHighlight(theme, "builtin"),
121125
"STRING": idleConf.GetHighlight(theme, "string"),
122126
"DEFINITION": idleConf.GetHighlight(theme, "definition"),
123-
"SYNC": {'background':None,'foreground':None},
124-
"TODO": {'background':None,'foreground':None},
127+
"SYNC": {'background': None, 'foreground': None},
128+
"TODO": {'background': None, 'foreground': None},
125129
"ERROR": idleConf.GetHighlight(theme, "error"),
126-
# The following is used by ReplaceDialog:
130+
# "hit" is used by ReplaceDialog to mark matches. It shouldn't be changed by Colorizer, but
131+
# that currently isn't technically possible. This should be moved elsewhere in the future
132+
# when fixing the "hit" tag's visibility, or when the replace dialog is replaced with a
133+
# non-modal alternative.
127134
"hit": idleConf.GetHighlight(theme, "hit"),
128135
}
129136

130-
if DEBUG: print('tagdefs',self.tagdefs)
137+
if DEBUG: print('tagdefs', self.tagdefs)
131138

132139
def insert(self, index, chars, tags=None):
133140
"Insert chars into widget at index and mark for colorizing."
@@ -184,8 +191,8 @@ def toggle_colorize_event(self, event=None):
184191
if self.allow_colorizing and not self.colorizing:
185192
self.after_id = self.after(1, self.recolorize)
186193
if DEBUG:
187-
print("auto colorizing turned",\
188-
self.allow_colorizing and "on" or "off")
194+
print("auto colorizing turned",
195+
"on" if self.allow_colorizing else "off")
189196
return "break"
190197

191198
def recolorize(self):
@@ -232,10 +239,7 @@ def recolorize_main(self):
232239
head, tail = item
233240
self.tag_remove("SYNC", head, tail)
234241
item = self.tag_prevrange("SYNC", head)
235-
if item:
236-
head = item[1]
237-
else:
238-
head = "1.0"
242+
head = item[1] if item else "1.0"
239243

240244
chars = ""
241245
next = head
@@ -307,7 +311,7 @@ def _color_delegator(parent): # htest #
307311
"elif False: print(0)\n"
308312
"else: float(None)\n"
309313
"if iF + If + IF: 'keyword matching must respect case'\n"
310-
"if'': x or'' # valid string-keyword no-space combinations\n"
314+
"if'': x or'' # valid keyword-string no-space combinations\n"
311315
"async def f(): await g()\n"
312316
"# All valid prefixes for unicode and byte strings should be colored.\n"
313317
"'x', '''x''', \"x\", \"\"\"x\"\"\"\n"

PythonLib/full/idlelib/config_key.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from tkinter import Toplevel, Listbox, StringVar, TclError
55
from tkinter.ttk import Frame, Button, Checkbutton, Entry, Label, Scrollbar
66
from tkinter import messagebox
7+
from tkinter.simpledialog import _setup_dialog
78
import string
89
import sys
910

@@ -63,6 +64,7 @@ def __init__(self, parent, title, action, current_key_sequences,
6364
self.resizable(height=False, width=False)
6465
self.title(title)
6566
self.transient(parent)
67+
_setup_dialog(self)
6668
self.grab_set()
6769
self.protocol("WM_DELETE_WINDOW", self.cancel)
6870
self.parent = parent

PythonLib/full/idlelib/query.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from tkinter.ttk import Frame, Button, Entry, Label, Checkbutton
2929
from tkinter import filedialog
3030
from tkinter.font import Font
31+
from tkinter.simpledialog import _setup_dialog
3132

3233
class Query(Toplevel):
3334
"""Base class for getting verified answer from a user.
@@ -60,13 +61,8 @@ def __init__(self, parent, title, message, *, text0='', used_names={},
6061
if not _utest: # Otherwise fail when directly run unittest.
6162
self.grab_set()
6263

63-
windowingsystem = self.tk.call('tk', 'windowingsystem')
64-
if windowingsystem == 'aqua':
65-
try:
66-
self.tk.call('::tk::unsupported::MacWindowStyle', 'style',
67-
self._w, 'moveableModal', '')
68-
except:
69-
pass
64+
_setup_dialog(self)
65+
if self._windowingsystem == 'aqua':
7066
self.bind("<Command-.>", self.cancel)
7167
self.bind('<Key-Escape>', self.cancel)
7268
self.protocol("WM_DELETE_WINDOW", self.cancel)

PythonLib/full/idlelib/searchbase.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from tkinter import Toplevel
44
from tkinter.ttk import Frame, Entry, Label, Button, Checkbutton, Radiobutton
5+
from tkinter.simpledialog import _setup_dialog
56

67

78
class SearchDialogBase:
@@ -83,6 +84,7 @@ def create_widgets(self):
8384
top.protocol("WM_DELETE_WINDOW", self.close)
8485
top.wm_title(self.title)
8586
top.wm_iconname(self.icon)
87+
_setup_dialog(top)
8688
self.top = top
8789
self.frame = Frame(top, padding="5px")
8890
self.frame.grid(sticky="nwes")

0 commit comments

Comments
 (0)