mirror of
https://github.com/python/cpython
synced 2024-09-05 08:17:45 +00:00
bpo-46565: del
loop vars that are leaking into module namespaces (GH-30993)
This commit is contained in:
parent
6394e981ad
commit
0cbdd21311
|
@ -249,3 +249,4 @@
|
|||
|
||||
for excname in PYTHON3_IMPORTERROR_EXCEPTIONS:
|
||||
REVERSE_NAME_MAPPING[('builtins', excname)] = ('exceptions', 'ImportError')
|
||||
del excname
|
||||
|
|
|
@ -72,12 +72,14 @@ def get_non_text_content(msg):
|
|||
return msg.get_payload(decode=True)
|
||||
for maintype in 'audio image video application'.split():
|
||||
raw_data_manager.add_get_handler(maintype, get_non_text_content)
|
||||
del maintype
|
||||
|
||||
|
||||
def get_message_content(msg):
|
||||
return msg.get_payload(0)
|
||||
for subtype in 'rfc822 external-body'.split():
|
||||
raw_data_manager.add_get_handler('message/'+subtype, get_message_content)
|
||||
del subtype
|
||||
|
||||
|
||||
def get_and_fixup_unknown_message_content(msg):
|
||||
|
@ -246,3 +248,4 @@ def set_bytes_content(msg, data, maintype, subtype, cte='base64',
|
|||
_finalize_set(msg, disposition, filename, cid, params)
|
||||
for typ in (bytes, bytearray, memoryview):
|
||||
raw_data_manager.add_set_handler(typ, set_bytes_content)
|
||||
del typ
|
||||
|
|
|
@ -148,6 +148,7 @@ def header_encode(header_bytes, charset='iso-8859-1'):
|
|||
_QUOPRI_BODY_ENCODE_MAP = _QUOPRI_BODY_MAP[:]
|
||||
for c in b'\r\n':
|
||||
_QUOPRI_BODY_ENCODE_MAP[c] = chr(c)
|
||||
del c
|
||||
|
||||
def body_encode(body, maxlinelen=76, eol=NL):
|
||||
"""Encode with quoted-printable, wrapping at maxlinelen characters.
|
||||
|
|
|
@ -89,8 +89,7 @@ def _timegm(tt):
|
|||
DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
|
||||
MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
||||
MONTHS_LOWER = []
|
||||
for month in MONTHS: MONTHS_LOWER.append(month.lower())
|
||||
MONTHS_LOWER = [month.lower() for month in MONTHS]
|
||||
|
||||
def time2isoz(t=None):
|
||||
"""Return a string representing time in seconds since epoch, t.
|
||||
|
|
|
@ -156,6 +156,7 @@
|
|||
mod_dict = globals()
|
||||
for k, v in dis.COMPILER_FLAG_NAMES.items():
|
||||
mod_dict["CO_" + v] = k
|
||||
del k, v, mod_dict
|
||||
|
||||
# See Include/object.h
|
||||
TPFLAGS_IS_ABSTRACT = 1 << 20
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
for i in range(0x20):
|
||||
ESCAPE_DCT.setdefault(chr(i), '\\u{0:04x}'.format(i))
|
||||
#ESCAPE_DCT.setdefault(chr(i), '\\u%04x' % (i,))
|
||||
del i
|
||||
|
||||
INFINITY = float('inf')
|
||||
|
||||
|
|
|
@ -186,3 +186,4 @@ def report(self):
|
|||
if line:
|
||||
op, name = line.split()
|
||||
opmap[op] = getattr(token, name)
|
||||
del line, op, name
|
||||
|
|
|
@ -746,6 +746,7 @@ def getpreferredencoding(do_setlocale=True):
|
|||
for k, v in sorted(locale_encoding_alias.items()):
|
||||
k = k.replace('_', '')
|
||||
locale_encoding_alias.setdefault(k, v)
|
||||
del k, v
|
||||
|
||||
#
|
||||
# The locale_alias table maps lowercase alias names to C locale names
|
||||
|
|
|
@ -49,11 +49,11 @@ def reduce_array(a):
|
|||
reduction.register(array.array, reduce_array)
|
||||
|
||||
view_types = [type(getattr({}, name)()) for name in ('items','keys','values')]
|
||||
if view_types[0] is not list: # only needed in Py3.0
|
||||
def rebuild_as_list(obj):
|
||||
return list, (list(obj),)
|
||||
for view_type in view_types:
|
||||
reduction.register(view_type, rebuild_as_list)
|
||||
def rebuild_as_list(obj):
|
||||
return list, (list(obj),)
|
||||
for view_type in view_types:
|
||||
reduction.register(view_type, rebuild_as_list)
|
||||
del view_type, view_types
|
||||
|
||||
#
|
||||
# Type for identifying shared objects
|
||||
|
|
|
@ -427,6 +427,7 @@ def close(self):
|
|||
for name, signum in list(signal.__dict__.items()):
|
||||
if name[:3]=='SIG' and '_' not in name:
|
||||
_exitcode_to_name[-signum] = f'-{name}'
|
||||
del name, signum
|
||||
|
||||
# For debug and leak testing
|
||||
_dangling = WeakSet()
|
||||
|
|
|
@ -192,6 +192,7 @@ def is_python_build(check_home=False):
|
|||
scheme['headers'] = scheme['include']
|
||||
scheme['include'] = '{srcdir}/Include'
|
||||
scheme['platinclude'] = '{projectbase}/.'
|
||||
del scheme
|
||||
|
||||
|
||||
def _subst_vars(s, local_vars):
|
||||
|
|
|
@ -108,7 +108,7 @@ def istest(self, predicate, exp):
|
|||
self.assertFalse(other(obj), 'not %s(%s)' % (other.__name__, exp))
|
||||
|
||||
def test__all__(self):
|
||||
support.check__all__(self, inspect, not_exported=("k", "v", "mod_dict", "modulesbyfile"))
|
||||
support.check__all__(self, inspect, not_exported=("modulesbyfile",))
|
||||
|
||||
def generator_function_example(self):
|
||||
for i in range(2):
|
||||
|
|
|
@ -143,6 +143,7 @@ def _compile(expr):
|
|||
endpats[_prefix + '"'] = Double
|
||||
endpats[_prefix + "'''"] = Single3
|
||||
endpats[_prefix + '"""'] = Double3
|
||||
del _prefix
|
||||
|
||||
# A set of all of the single and triple quoted string prefixes,
|
||||
# including the opening quotes.
|
||||
|
@ -153,6 +154,7 @@ def _compile(expr):
|
|||
single_quoted.add(u)
|
||||
for u in (t + '"""', t + "'''"):
|
||||
triple_quoted.add(u)
|
||||
del t, u
|
||||
|
||||
tabsize = 8
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Remove loop variables that are leaking into modules' namespaces.
|
Loading…
Reference in a new issue