summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/fetch2/__init__.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-08-17 12:12:16 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-19 18:05:44 +0100
commit715d857174ceca82b85d6c8c7df520047ba7fb0c (patch)
tree363aac81a06b013471f1dede8ba4c0dc7d8bbe92 /bitbake/lib/bb/fetch2/__init__.py
parent22a653d02880c35d3c9d04811c31aabdf1e69951 (diff)
downloadpoky-715d857174ceca82b85d6c8c7df520047ba7fb0c.tar.gz
bitbake: Fix default function parameter assignment to a list
With python you should not assign a list as the default value of a function parameter - because a list is mutable, the result will be that the first time a value is passed it will actually modify the default. Reference: http://docs.python-guide.org/en/latest/writing/gotchas/#mutable-default-arguments (Bitbake rev: 7859f7388f2e3f675d0e1527cfde18625f36f637) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/fetch2/__init__.py')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 7b4d130f5f..ec0c31ae21 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -777,7 +777,7 @@ def localpath(url, d):
777 fetcher = bb.fetch2.Fetch([url], d) 777 fetcher = bb.fetch2.Fetch([url], d)
778 return fetcher.localpath(url) 778 return fetcher.localpath(url)
779 779
780def runfetchcmd(cmd, d, quiet = False, cleanup = []): 780def runfetchcmd(cmd, d, quiet=False, cleanup=None):
781 """ 781 """
782 Run cmd returning the command output 782 Run cmd returning the command output
783 Raise an error if interrupted or cmd fails 783 Raise an error if interrupted or cmd fails
@@ -802,6 +802,9 @@ def runfetchcmd(cmd, d, quiet = False, cleanup = []):
802 'SSH_AUTH_SOCK', 'SSH_AGENT_PID', 802 'SSH_AUTH_SOCK', 'SSH_AGENT_PID',
803 'SOCKS5_USER', 'SOCKS5_PASSWD'] 803 'SOCKS5_USER', 'SOCKS5_PASSWD']
804 804
805 if not cleanup:
806 cleanup = []
807
805 for var in exportvars: 808 for var in exportvars:
806 val = d.getVar(var, True) 809 val = d.getVar(var, True)
807 if val: 810 if val:
@@ -1267,7 +1270,7 @@ class FetchData(object):
1267class FetchMethod(object): 1270class FetchMethod(object):
1268 """Base class for 'fetch'ing data""" 1271 """Base class for 'fetch'ing data"""
1269 1272
1270 def __init__(self, urls = []): 1273 def __init__(self, urls=None):
1271 self.urls = [] 1274 self.urls = []
1272 1275
1273 def supports(self, urldata, d): 1276 def supports(self, urldata, d):
@@ -1552,11 +1555,11 @@ class Fetch(object):
1552 1555
1553 return local 1556 return local
1554 1557
1555 def download(self, urls = []): 1558 def download(self, urls=None):
1556 """ 1559 """
1557 Fetch all urls 1560 Fetch all urls
1558 """ 1561 """
1559 if len(urls) == 0: 1562 if not urls:
1560 urls = self.urls 1563 urls = self.urls
1561 1564
1562 network = self.d.getVar("BB_NO_NETWORK", True) 1565 network = self.d.getVar("BB_NO_NETWORK", True)
@@ -1634,12 +1637,12 @@ class Fetch(object):
1634 finally: 1637 finally:
1635 bb.utils.unlockfile(lf) 1638 bb.utils.unlockfile(lf)
1636 1639
1637 def checkstatus(self, urls = []): 1640 def checkstatus(self, urls=None):
1638 """ 1641 """
1639 Check all urls exist upstream 1642 Check all urls exist upstream
1640 """ 1643 """
1641 1644
1642 if len(urls) == 0: 1645 if not urls:
1643 urls = self.urls 1646 urls = self.urls
1644 1647
1645 for u in urls: 1648 for u in urls:
@@ -1662,12 +1665,12 @@ class Fetch(object):
1662 if not ret: 1665 if not ret:
1663 raise FetchError("URL %s doesn't work" % u, u) 1666 raise FetchError("URL %s doesn't work" % u, u)
1664 1667
1665 def unpack(self, root, urls = []): 1668 def unpack(self, root, urls=None):
1666 """ 1669 """
1667 Check all urls exist upstream 1670 Check all urls exist upstream
1668 """ 1671 """
1669 1672
1670 if len(urls) == 0: 1673 if not urls:
1671 urls = self.urls 1674 urls = self.urls
1672 1675
1673 for u in urls: 1676 for u in urls:
@@ -1685,12 +1688,12 @@ class Fetch(object):
1685 if ud.lockfile: 1688 if ud.lockfile:
1686 bb.utils.unlockfile(lf) 1689 bb.utils.unlockfile(lf)
1687 1690
1688 def clean(self, urls = []): 1691 def clean(self, urls=None):
1689 """ 1692 """
1690 Clean files that the fetcher gets or places 1693 Clean files that the fetcher gets or places
1691 """ 1694 """
1692 1695
1693 if len(urls) == 0: 1696 if not urls:
1694 urls = self.urls 1697 urls = self.urls
1695 1698
1696 for url in urls: 1699 for url in urls: