[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/master] 5367 - Fix python gotcha in __init__
commit aba290f8e3a1eaa38bfd580d350e0721911b49da
Author: aagbsn <aagbsn@xxxxxxxx>
Date: Sun Mar 11 22:01:28 2012 -0700
5367 - Fix python gotcha in __init__
Python default arguments are only parsed once, therefore the
list was shared between all instances.
See: http://www.ferg.org/projects/python_gotchas.html
---
lib/bridgedb/Server.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits