8000 MAINT: avoid modifying mutable default values · rth/numpy@2b7c1d3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b7c1d3

Browse files
committed
MAINT: avoid modifying mutable default values
1 parent a000144 commit 2b7c1d3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

numpy/distutils/command/config_compiler.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55

66
#XXX: Linker flags
77

8-
def show_fortran_compilers(_cache=[]):
9-
# Using cache to prevent infinite recursion
10-
if _cache: return
8+
def show_fortran_compilers(_cache=None):
9+
# Using cache to prevent infinite recursion.
10+
if _cache:
11+
return
12+
elif _cache is None:
13+
_cache = []
1114
_cache.append(1)
1215
from numpy.distutils.fcompiler import show_fcompilers
1316
import distutils.core

numpy/distutils/core.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ def _dict_append(d, **kws):
7171
else:
7272
raise TypeError(repr(type(dv)))
7373

74-
def _command_line_ok(_cache=[]):
74+
def _command_line_ok(_cache=None):
7575
""" Return True if command line does not contain any
7676
help or display requests.
7777
"""
7878
if _cache:
7979
return _cache[0]
80+
elif _cache is None:
81+
_cache = []
8082
ok = True
8183
display_opts = ['--'+n for n in Distribution.display_option_names]
8284
for o in Distribution.display_options:

0 commit comments

Comments
 (0)
0