File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
+ from six .moves import copyreg
2
3
3
4
if sys .version_info [0 ] == 2 :
4
5
from urlparse import urlparse
12
13
if urlparse ('s3://bucket/key?key=value' ).query != 'key=value' :
13
14
from urlparse import uses_query
14
15
uses_query .append ('s3' )
16
+
17
+
18
+ # Undo what Twisted's perspective broker adds to pickle register
19
+ # to prevent bugs like Twisted#7989 while serializing requests
20
+ import twisted .persisted .styles # NOQA
21
+ # Remove only entries with twisted serializers for non-twisted types.
22
+ for k , v in frozenset (copyreg .dispatch_table .items ()):
23
+ if not getattr (k , '__module__' , '' ).startswith ('twisted' ) \
24
+ and getattr (v , '__module__' , '' ).startswith ('twisted' ):
25
+ copyreg .dispatch_table .pop (k )
Original file line number Diff line number Diff line change @@ -31,6 +31,8 @@ def test_serialize(self):
31
31
self .assertEqual (q .pop (), {'a' : 'dict' })
32
32
33
33
def test_nonserializable_object (self ):
34
+ # Trigger Twisted bug #7989
35
+ import twisted .persisted .styles # NOQA
34
36
q = self .queue ()
35
37
self .assertRaises (ValueError , q .push , lambda x : x )
36
38
@@ -109,6 +111,8 @@ def test_serialize(self):
109
111
self .assertEqual (q .pop (), 'a' )
110
112
111
113
def test_nonserializable_object (self ):
114
+ # Trigger Twisted bug #7989
115
+ import twisted .persisted .styles # NOQA
112
116
q = self .queue ()
113
117
self .assertRaises (ValueError , q .push , lambda x : x )
114
118
You can’t perform that action at this time.
0 commit comments