Skip to content

Commit

Permalink
update to python 3.10.11
Browse files Browse the repository at this point in the history
  • Loading branch information
chcg committed Apr 7, 2023
1 parent a6fe84e commit 737832e
Show file tree
Hide file tree
Showing 84 changed files with 478 additions and 384 deletions.
13 changes: 10 additions & 3 deletions PythonLib/full/argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,18 @@ def _format_actions_usage(self, actions, groups):
except ValueError:
continue
else:
end = start + len(group._group_actions)
group_action_count = len(group._group_actions)
end = start + group_action_count
if actions[start:end] == group._group_actions:

suppressed_actions_count = 0
for action in group._group_actions:
group_actions.add(action)
if action.help is SUPPRESS:
suppressed_actions_count += 1

exposed_actions_count = group_action_count - suppressed_actions_count

if not group.required:
if start in inserts:
inserts[start] += ' ['
Expand All @@ -413,7 +421,7 @@ def _format_actions_usage(self, actions, groups):
inserts[end] += ']'
else:
inserts[end] = ']'
else:
elif exposed_actions_count > 1:
if start in inserts:
inserts[start] += ' ('
else:
Expand Down Expand Up @@ -487,7 +495,6 @@ def _format_actions_usage(self, actions, groups):
text = _re.sub(r'(%s) ' % open, r'\1', text)
text = _re.sub(r' (%s)' % close, r'\1', text)
text = _re.sub(r'%s *%s' % (open, close), r'', text)
text = _re.sub(r'\(([^|]*)\)', r'\1', text)
text = text.strip()

# return the text
Expand Down
17 changes: 9 additions & 8 deletions PythonLib/full/asyncio/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,17 @@ async def readuntil(self, separator=b'\n'):
async def read(self, n=-1):
"""Read up to `n` bytes from the stream.
If n is not provided, or set to -1, read until EOF and return all read
bytes. If the EOF was received and the internal buffer is empty, return
an empty bytes object.
If `n` is not provided or set to -1,
read until EOF, then return all read bytes.
If EOF was received and the internal buffer is empty,
return an empty bytes object.
If n is zero, return empty bytes object immediately.
If `n` is 0, return an empty bytes object immediately.
If n is positive, this function try to read `n` bytes, and may return
less or equal bytes than requested, but at least one byte. If EOF was
received before any byte is read, this function returns empty byte
object.
If `n` is positive, return at most `n` available bytes
as soon as at least 1 byte is available in the internal buffer.
If EOF is received before any byte is read, return an empty
bytes object.
Returned value is not limited with limit, configured at stream
creation.
Expand Down
7 changes: 4 additions & 3 deletions PythonLib/full/bdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,10 @@ def format_stack_entry(self, frame_lineno, lprefix=': '):
rv = frame.f_locals['__return__']
s += '->'
s += reprlib.repr(rv)
line = linecache.getline(filename, lineno, frame.f_globals)
if line:
s += lprefix + line.strip()
if lineno is not None:
line = linecache.getline(filename, lineno, frame.f_globals)
if line:
s += lprefix + line.strip()
return s

# The following methods can be called by clients to use
Expand Down
5 changes: 5 additions & 0 deletions PythonLib/full/concurrent/futures/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ def run(self):
if self.is_shutting_down():
self.flag_executor_shutting_down()

# When only canceled futures remain in pending_work_items, our
# next call to wait_result_broken_or_wakeup would hang forever.
# This makes sure we have some running futures or none at all.
self.add_call_item_to_queue()

# Since no new work items can be added, it is safe to shutdown
# this thread if there are no pending work items.
if not self.pending_work_items:
Expand Down
2 changes: 1 addition & 1 deletion PythonLib/full/dataclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,7 @@ def fields(class_or_instance):
try:
fields = getattr(class_or_instance, _FIELDS)
except AttributeError:
raise TypeError('must be called with a dataclass type or instance')
raise TypeError('must be called with a dataclass type or instance') from None

# Exclude pseudo-fields. Note that fields is sorted by insertion
# order, so the order of the tuple is as the fields were defined.
Expand Down
2 changes: 1 addition & 1 deletion PythonLib/full/ensurepip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__all__ = ["version", "bootstrap"]
_PACKAGE_NAMES = ('setuptools', 'pip')
_SETUPTOOLS_VERSION = "65.5.0"
_PIP_VERSION = "22.3.1"
_PIP_VERSION = "23.0.1"
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION, "py3"),
("pip", _PIP_VERSION, "py3"),
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion PythonLib/full/fileinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def isstdin(self):


def hook_compressed(filename, mode, *, encoding=None, errors=None):
if encoding is None: # EncodingWarning is emitted in FileInput() already.
if encoding is None and "b" not in mode: # EncodingWarning is emitted in FileInput() already.
encoding = "locale"
ext = os.path.splitext(filename)[1]
if ext == '.gz':
Expand Down
2 changes: 1 addition & 1 deletion PythonLib/full/html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def escape(s, quote=True):
return s


# see http://www.w3.org/TR/html5/syntax.html#tokenizing-character-references
# see https://html.spec.whatwg.org/multipage/parsing.html#numeric-character-reference-end-state

_invalid_charrefs = {
0x00: '\ufffd', # REPLACEMENT CHARACTER
Expand Down
1 change: 1 addition & 0 deletions PythonLib/full/http/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ def isclosed(self):
return self.fp is None

def read(self, amt=None):
"""Read and return the response body, or up to the next amt bytes."""
if self.fp is None:
return b""

Expand Down
25 changes: 11 additions & 14 deletions PythonLib/full/idlelib/dynoption.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,19 @@
OptionMenu widget modified to allow dynamic menu reconfiguration
and setting of highlightthickness
"""
import copy

from tkinter import OptionMenu, _setit, StringVar, Button

class DynOptionMenu(OptionMenu):
"""
unlike OptionMenu, our kwargs can include highlightthickness
"""Add SetMenu and highlightthickness to OptionMenu.
Highlightthickness adds space around menu button.
"""
def __init__(self, master, variable, value, *values, **kwargs):
# TODO copy value instead of whole dict
kwargsCopy=copy.copy(kwargs)
if 'highlightthickness' in list(kwargs.keys()):
del(kwargs['highlightthickness'])
highlightthickness = kwargs.pop('highlightthickness', None)
OptionMenu.__init__(self, master, variable, value, *values, **kwargs)
self.config(highlightthickness=kwargsCopy.get('highlightthickness'))
#self.menu=self['menu']
self.variable=variable
self.command=kwargs.get('command')
self['highlightthickness'] = highlightthickness
self.variable = variable
self.command = kwargs.get('command')

def SetMenu(self,valueList,value=None):
"""
Expand All @@ -38,14 +33,15 @@ def _dyn_option_menu(parent): # htest #
from tkinter import Toplevel # + StringVar, Button

top = Toplevel(parent)
top.title("Tets dynamic option menu")
top.title("Test dynamic option menu")
x, y = map(int, parent.geometry().split('+')[1:])
top.geometry("200x100+%d+%d" % (x + 250, y + 175))
top.focus_set()

var = StringVar(top)
var.set("Old option set") #Set the default value
dyn = DynOptionMenu(top,var, "old1","old2","old3","old4")
dyn = DynOptionMenu(top, var, "old1","old2","old3","old4",
highlightthickness=5)
dyn.pack()

def update():
Expand All @@ -54,5 +50,6 @@ def update():
button.pack()

if __name__ == '__main__':
# Only module without unittests because of intention to replace.
from idlelib.idle_test.htest import run
run(_dyn_option_menu)
13 changes: 2 additions & 11 deletions PythonLib/full/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,6 @@ def find_function(funcname, filename):
return funcname, filename, lineno
return None

def getsourcelines(obj):
lines, lineno = inspect.findsource(obj)
if inspect.isframe(obj) and obj.f_globals is obj.f_locals:
# must be a module frame: do not try to cut a block out of it
return lines, 1
elif inspect.ismodule(obj):
return lines, 1
return inspect.getblock(lines[lineno:]), lineno+1

def lasti2lineno(code, lasti):
linestarts = list(dis.findlinestarts(code))
linestarts.reverse()
Expand Down Expand Up @@ -1273,7 +1264,7 @@ def do_longlist(self, arg):
filename = self.curframe.f_code.co_filename
breaklist = self.get_file_breaks(filename)
try:
lines, lineno = getsourcelines(self.curframe)
lines, lineno = inspect.getsourcelines(self.curframe)
except OSError as err:
self.error(err)
return
Expand All @@ -1289,7 +1280,7 @@ def do_source(self, arg):
except:
return
try:
lines, lineno = getsourcelines(obj)
lines, lineno = inspect.getsourcelines(obj)
except (OSError, TypeError) as err:
self.error(err)
return
Expand Down
23 changes: 16 additions & 7 deletions PythonLib/full/plistlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,38 @@
Generate Plist example:
import datetime
import plistlib
pl = dict(
aString = "Doodah",
aList = ["A", "B", 12, 32.1, [1, 2, 3]],
aFloat = 0.1,
anInt = 728,
aDict = dict(
anotherString = "<hello & hi there!>",
aUnicodeValue = "M\xe4ssig, Ma\xdf",
aThirdString = "M\xe4ssig, Ma\xdf",
aTrueValue = True,
aFalseValue = False,
),
someData = b"<binary gunk>",
someMoreData = b"<lots of binary gunk>" * 10,
aDate = datetime.datetime.fromtimestamp(time.mktime(time.gmtime())),
aDate = datetime.datetime.now()
)
with open(fileName, 'wb') as fp:
dump(pl, fp)
print(plistlib.dumps(pl).decode())
Parse Plist example:
with open(fileName, 'rb') as fp:
pl = load(fp)
print(pl["aKey"])
import plistlib
plist = b'''<plist version="1.0">
<dict>
<key>foo</key>
<string>bar</string>
</dict>
</plist>'''
pl = plistlib.loads(plist)
print(pl["foo"])
"""
__all__ = [
"InvalidFileException", "FMT_XML", "FMT_BINARY", "load", "dump", "loads", "dumps", "UID"
Expand Down

0 comments on commit 737832e

Please sign in to comment.