Skip to content

Commit 683ad33

Browse files
authored
Avoid leaking "name" variable in AbstractSandbox (#4280)
2 parents e92ad19 + 2b339b9 commit 683ad33

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

newsfragments/4280.misc.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid leaking loop variable ``name`` in ``AbstractSandbox`` -- by :user:`Avasam`

setuptools/sandbox.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ def wrap(self, src, dst, *args, **kw):
309309

310310
return wrap
311311

312-
for name in ["rename", "link", "symlink"]:
313-
if hasattr(_os, name):
314-
locals()[name] = _mk_dual_path_wrapper(name)
312+
for __name in ["rename", "link", "symlink"]:
313+
if hasattr(_os, __name):
314+
locals()[__name] = _mk_dual_path_wrapper(__name)
315315

316316
def _mk_single_path_wrapper(name: str, original=None): # type: ignore[misc] # https://github.com/pypa/setuptools/pull/4099
317317
original = original or getattr(_os, name)
@@ -326,7 +326,7 @@ def wrap(self, path, *args, **kw):
326326
if _file:
327327
_file = _mk_single_path_wrapper('file', _file)
328328
_open = _mk_single_path_wrapper('open', _open)
329-
for name in [
329+
for __name in [
330330
"stat",
331331
"listdir",
332332
"chdir",
@@ -347,8 +347,8 @@ def wrap(self, path, *args, **kw):
347347
"pathconf",
348348
"access",
349349
]:
350-
if hasattr(_os, name):
351-
locals()[name] = _mk_single_path_wrapper(name)
350+
if hasattr(_os, __name):
351+
locals()[__name] = _mk_single_path_wrapper(__name)
352352

353353
def _mk_single_with_return(name: str): # type: ignore[misc] # https://github.com/pypa/setuptools/pull/4099
354354
original = getattr(_os, name)
@@ -361,9 +361,9 @@ def wrap(self, path, *args, **kw):
361361

362362
return wrap
363363

364-
for name in ['readlink', 'tempnam']:
365-
if hasattr(_os, name):
366-
locals()[name] = _mk_single_with_return(name)
364+
for __name in ['readlink', 'tempnam']:
365+
if hasattr(_os, __name):
366+
locals()[__name] = _mk_single_with_return(__name)
367367

368368
def _mk_query(name: str): # type: ignore[misc] # https://github.com/pypa/setuptools/pull/4099
369369
original = getattr(_os, name)
@@ -376,9 +376,9 @@ def wrap(self, *args, **kw):
376376

377377
return wrap
378378

379-
for name in ['getcwd', 'tmpnam']:
380-
if hasattr(_os, name):
381-
locals()[name] = _mk_query(name)
379+
for __name in ['getcwd', 'tmpnam']:
380+
if hasattr(_os, __name):
381+
locals()[__name] = _mk_query(__name)
382382

383383
def _validate_path(self, path):
384384
"""Called to remap or validate any path, whether input or output"""

0 commit comments

Comments
 (0)