Make default argument non-mutable

Calling `Env()` without the `ldpaths` parameter after a call with the `ldpaths` parameter, keeps the list from the first call because the argument is mutable. This is probably not what was intended. This commit fixes this issue and also reverts a change to two lines introduced in 091e74d618, which was probably a workaround for this issue.
This commit is contained in:
Luflosi
2019-06-22 16:46:19 +02:00
parent f6051f73f5
commit 7709cdb12b

View File

@@ -177,8 +177,8 @@ def first_successful_compile(cc, *cflags, src=None):
class Env:
def __init__(self, cc, cppflags, cflags, ldflags, ldpaths=[]):
self.cc, self.cppflags, self.cflags, self.ldflags, self.ldpaths = cc, cppflags, cflags, ldflags, ldpaths
def __init__(self, cc, cppflags, cflags, ldflags, ldpaths=None):
self.cc, self.cppflags, self.cflags, self.ldflags, self.ldpaths = cc, cppflags, cflags, ldflags, [] if ldpaths is None else ldpaths
def copy(self):
return Env(self.cc, list(self.cppflags), list(self.cflags), list(self.ldflags), list(self.ldpaths))
@@ -242,8 +242,7 @@ def init_env(
cppflags.append('-DWITH_PROFILER')
cflags.append('-g3')
ldflags.append('-lprofiler')
ldpaths = []
return Env(cc, cppflags, cflags, ldflags, ldpaths=ldpaths)
return Env(cc, cppflags, cflags, ldflags)
def kitty_env():