python gotcha: mutable type in __init__()
In Server.py:53
http://www.ferg.org/projects/python_gotchas.html
init arguments are parsed only once, so the same list will be shared with all instance objects.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
- Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Link issues together to show that they're related.
Learn more.
Activity
-
Newest first Oldest first
-
Show all activity Show comments only Show history only
- Author
Simple fix:
diff --git a/lib/bridgedb/Server.py b/lib/bridgedb/Server.py index a1b837a..b67edf2 100644 --- a/lib/bridgedb/Server.py +++ b/lib/bridgedb/Server.py @@ -50,7 +50,7 @@ class WebResource(twisted.web.resource.Resource): def __init__(self, distributor, schedule, N=1, useForwardedHeader=False, includeFingerprints=True, useRecaptcha=False,recaptchaPrivKey='', recaptchaPubKey='', - domains=[]): + domains=None): """Create a new WebResource. distributor -- an IPBasedDistributor object schedule -- an IntervalSchedule object @@ -63,6 +63,9 @@ class WebResource(twisted.web.resource.Resource): self.nBridgesToGive = N self.useForwardedHeader = useForwardedHeader self.includeFingerprints = includeFingerprints + + # do not use mutable types as __init__ defaults! + if not domains: domains = [] self.domains = domains # recaptcha options
Trac:
Status: new to needs_review - Author
Trac:
Status: needs_review to closed
Resolution: N/A to fixed - Trac closed
closed
Please register or sign in to reply