Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 7 additions & 14 deletions Lib/functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,7 @@ def __new__(*args, **keywords):

if hasattr(func, "func"):
args = func.args + args
tmpkw = func.keywords.copy()
tmpkw.update(keywords)
keywords = tmpkw
del tmpkw
keywords = {**func.keywords, **keywords}
func = func.func

self = super(partial, cls).__new__(cls)
Expand All @@ -302,9 +299,8 @@ def __call__(*args, **keywords):
if not args:
raise TypeError("descriptor '__call__' of partial needs an argument")
self, *args = args
newkeywords = self.keywords.copy()
newkeywords.update(keywords)
return self.func(*self.args, *args, **newkeywords)
keywords = {**self.keywords, **keywords}
return self.func(*self.args, *args, **keywords)

@recursive_repr()
def __repr__(self):
Expand Down Expand Up @@ -371,8 +367,7 @@ def __init__(self, func, *args, **keywords):
# it's also more efficient since only one function will be called
self.func = func.func
self.args = func.args + args
self.keywords = func.keywords.copy()
self.keywords.update(keywords)
self.keywords = {**func.keywords, **keywords}
else:
self.func = func
self.args = args
Expand All @@ -391,11 +386,9 @@ def __repr__(self):

def _make_unbound_method(self):
def _method(*args, **keywords):
call_keywords = self.keywords.copy()
call_keywords.update(keywords)
cls_or_self, *rest = args
call_args = (cls_or_self,) + self.args + tuple(rest)
return self.func(*call_args, **call_keywords)
cls_or_self, *args = args
keywords = {**self.keywords, **keywords}
return self.func(cls_or_self, *self.args, *args, **keywords)
_method.__isabstractmethod__ = self.__isabstractmethod__
_method._partialmethod = self
return _method
Expand Down
3 changes: 1 addition & 2 deletions Lib/idlelib/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def dumps(obj, protocol=None):


class CodePickler(pickle.Pickler):
dispatch_table = {types.CodeType: pickle_code}
dispatch_table.update(copyreg.dispatch_table)
dispatch_table = {types.CodeType: pickle_code, **copyreg.dispatch_table}


BUFSIZE = 8*1024
Expand Down
6 changes: 2 additions & 4 deletions Lib/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,7 @@ def _complete_expression(self, text, line, begidx, endidx):
# Collect globals and locals. It is usually not really sensible to also
# complete builtins, and they clutter the namespace quite heavily, so we
# leave them out.
ns = self.curframe.f_globals.copy()
ns.update(self.curframe_locals)
ns = {**self.curframe.f_globals, **self.curframe_locals}
if '.' in text:
# Walk an attribute chain up to the last part, similar to what
# rlcompleter does. This will bail if any of the parts are not
Expand Down Expand Up @@ -1377,8 +1376,7 @@ def do_interact(self, arg):
Start an interactive interpreter whose global namespace
contains all the (global and local) names found in the current scope.
"""
ns = self.curframe.f_globals.copy()
ns.update(self.curframe_locals)
ns = {**self.curframe.f_globals, **self.curframe_locals}
code.interact("*interactive*", local=ns)

def do_alias(self, arg):
Expand Down
3 changes: 1 addition & 2 deletions Lib/urllib/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ def remove_header(self, header_name):
self.unredirected_hdrs.pop(header_name, None)

def header_items(self):
hdrs = self.unredirected_hdrs.copy()
hdrs.update(self.headers)
hdrs = {**self.unredirected_hdrs, **self.headers}
return list(hdrs.items())

class OpenerDirector:
Expand Down
7 changes: 2 additions & 5 deletions Lib/xml/etree/ElementTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,8 @@ def __init__(self, tag, attrib={}, **extra):
if not isinstance(attrib, dict):
raise TypeError("attrib must be dict, not %s" % (
attrib.__class__.__name__,))
attrib = attrib.copy()
attrib.update(extra)
self.tag = tag
self.attrib = attrib
self.attrib = {**attrib, **extra}
self._children = []

def __repr__(self):
Expand Down Expand Up @@ -451,8 +449,7 @@ def SubElement(parent, tag, attrib={}, **extra):
additional attributes given as keyword arguments.

"""
attrib = attrib.copy()
attrib.update(extra)
attrib = {**attrib, **extra}
element = parent.makeelement(tag, attrib)
parent.append(element)
return element
Expand Down
3 changes: 1 addition & 2 deletions Lib/xml/sax/saxutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ def quoteattr(data, entities={}):
the optional entities parameter. The keys and values must all be
strings; each key will be replaced with its corresponding value.
"""
entities = entities.copy()
entities.update({'\n': '
', '\r': '
', '\t':'	'})
entities = {**entities, '\n': '
', '\r': '
', '\t':'	'}
data = escape(data, entities)
if '"' in data:
if "'" in data:
Expand Down