[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [tor-bugs] #5367 [BridgeDB]: python gotcha: mutable type in __init__()
#5367: python gotcha: mutable type in __init__()
----------------------+-----------------------------------------------------
Reporter: aagbsn | Owner: aagbsn
Type: defect | Status: needs_review
Priority: normal | Milestone:
Component: BridgeDB | Version:
Keywords: | Parent:
Points: | Actualpoints:
----------------------+-----------------------------------------------------
Changes (by aagbsn):
* status: new => needs_review
Comment:
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
}}}
https://gitweb.torproject.org/user/aagbsn/bridgedb.git/commit/aba290f8e3a1eaa38bfd580d350e0721911b49da
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/5367#comment:1>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs