summaryrefslogtreecommitdiff
path: root/security/py-gnutls/files/patch-2to3
blob: ab5564904aeed98975240978ad37b83dd20f58c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
--- gnutls/connection.py.orig	2017-01-26 09:15:54 UTC
+++ gnutls/connection.py
@@ -388,7 +388,7 @@ class ServerSession(Session):
         data_length = c_size_t(256)
         data = create_string_buffer(data_length.value)
         hostname_type = c_uint()
-        for i in xrange(2**16):
+        for i in range(2**16):
             try:
                 gnutls_server_name_get(self._c_object, data, byref(data_length), byref(hostname_type), i)
             except RequestedDataNotAvailable:
@@ -407,7 +407,7 @@ class ServerSessionFactory(object):
 
     def __init__(self, socket, context, session_class=ServerSession):
         if not issubclass(session_class, ServerSession):
-            raise TypeError, "session_class must be a subclass of ServerSession"
+            raise TypeError("session_class must be a subclass of ServerSession")
         self.socket = socket
         self.context = context
         self.session_class = session_class
--- gnutls/constants.py.orig	2016-03-08 13:28:28 UTC
+++ gnutls/constants.py
@@ -31,7 +31,7 @@ class GNUTLSConstant(int):
 
 ## Generate all exported constants
 code = '\n'.join(["%s = GNUTLSConstant('%s')" % (name, name) for name in __all__])
-exec code in locals(), globals()
+exec(code, locals(), globals())
 del code, name
 
 del constants
--- gnutls/interfaces/twisted/__init__.py.orig	2016-03-08 13:28:28 UTC
+++ gnutls/interfaces/twisted/__init__.py
@@ -41,7 +41,7 @@ class RecurrentCall(object):
             self.now, self.next = self.next, self.next + self.period
         result = self.func(*self.args, **self.kwargs)
         if result is KeepRunning:
-            delay = max(self.next-time(), 0)
+            delay = max(self.__next__-time(), 0)
             self.callid = reactor.callLater(delay, self)
     def cancel(self):
         if self.callid is not None:
@@ -77,7 +77,7 @@ class TLSMixin:
             return tcp.Connection.doRead(self)
         except (OperationWouldBlock, OperationInterrupted):
             return
-        except GNUTLSError, e:
+        except GNUTLSError as e:
             return e
 
     def writeSomeData(self, data):
@@ -87,7 +87,7 @@ class TLSMixin:
             return self.writeSomeData(data)
         except OperationWouldBlock:
             return 0
-        except GNUTLSError, e:
+        except GNUTLSError as e:
             return e
 
     def _sendCloseReason(self, reason):
@@ -117,11 +117,11 @@ class TLSMixin:
         self.stopWriting()
         try:
             self._sendCloseAlert(SHUT_WR)
-        except OperationWouldBlock, e:
+        except OperationWouldBlock as e:
             if self.socket.interrupted_while_writing:
                 self.startWriting()
                 return
-        except Exception, e:
+        except Exception as e:
             return e
         del self.doWrite
 
@@ -153,7 +153,7 @@ class TLSClient(TLSMixin, tcp.Client):
             return
         try:
             self.context.credentials.verify_callback(self.socket.peer_certificate)
-        except Exception, e:
+        except Exception as e:
             self.loseConnection(e)
             return
         else:
@@ -166,7 +166,7 @@ class TLSClient(TLSMixin, tcp.Client):
             return
         try:
             session.verify_peer()
-        except Exception, e:
+        except Exception as e:
             preverify_status = e
         else:
             preverify_status = CertificateOK
@@ -184,7 +184,7 @@ class TLSClient(TLSMixin, tcp.Client):
             if self.socket.interrupted_while_writing:
                 self.startWriting()
             return
-        except GNUTLSError, e:
+        except GNUTLSError as e:
             del self.doRead
             self.failIfNotConnected(err = e)
             return
@@ -195,11 +195,11 @@ class TLSClient(TLSMixin, tcp.Client):
         
         try:
             self._verifyPeer()
-        except GNUTLSError, e:
+        except GNUTLSError as e:
             self.closeTLSSession(e)
             self.failIfNotConnected(err = e)
             return
-        except Exception, e:
+        except Exception as e:
             self.closeTLSSession(e)
             self.failIfNotConnected(err = error.getConnectError(str(e)))
             return
@@ -258,7 +258,7 @@ class TLSServer(TLSMixin, tcp.Server):
             return
         try:
             self.context.credentials.verify_callback(self.socket.peer_certificate)
-        except Exception, e:
+        except Exception as e:
             self.loseConnection(e)
             return
         else:
@@ -271,7 +271,7 @@ class TLSServer(TLSMixin, tcp.Server):
             return
         try:
             session.verify_peer()
-        except Exception, e:
+        except Exception as e:
             preverify_status = e
         else:
             preverify_status = CertificateOK
@@ -289,7 +289,7 @@ class TLSServer(TLSMixin, tcp.Server):
             if self.socket.interrupted_while_writing:
                 self.startWriting()
             return
-        except GNUTLSError, e:
+        except GNUTLSError as e:
             del self.doRead
             return e
         
@@ -300,7 +300,7 @@ class TLSServer(TLSMixin, tcp.Server):
         
         try:
             self._verifyPeer()
-        except Exception, e:
+        except Exception as e:
             self.loseConnection(e)
             return
         
--- gnutls/validators.py.orig	2016-03-08 13:28:28 UTC
+++ gnutls/validators.py
@@ -76,7 +76,7 @@ class TypeValidator(Validator):
 class MultiTypeValidator(TypeValidator):
     @staticmethod
     def can_validate(obj):
-        return isinstance(obj, tuple) and not filter(lambda x: not isclass(x), obj)
+        return isinstance(obj, tuple) and not [x for x in obj if not isclass(x)]
 
 class OneOfValidator(Validator):
     def __init__(self, typ):
@@ -94,7 +94,7 @@ class ListOfValidator(Validator):
     def __init__(self, typ):
         self.type = typ.type
     def check(self, value):
-        return isinstance(value, (tuple, list)) and not filter(lambda x: not isinstance(x, self.type), value)
+        return isinstance(value, (tuple, list)) and not [x for x in value if not isinstance(x, self.type)]
     @staticmethod
     def can_validate(obj):
         return isinstance(obj, list_of)
@@ -109,7 +109,7 @@ class ComplexValidator(Validator):
         return bool(sum(t.check(value) for t in self.type))
     @staticmethod
     def can_validate(obj):
-        return isinstance(obj, tuple) and not filter(lambda x: Validator.get(x) is None, obj)
+        return isinstance(obj, tuple) and not [x for x in obj if Validator.get(x) is None]
     @property
     def name(self):
         return self.join_names([x.name for x in self.type])
@@ -135,7 +135,7 @@ class one_of(object):
 
 class list_of(object):
     def __init__(self, *args):
-        if filter(lambda x: not isclass(x), args):
+        if [x for x in args if not isclass(x)]:
             raise TypeError("list_of arguments must be types")
         if len(args) == 1:
             self.type = args[0]
@@ -163,9 +163,9 @@ def preserve_signature(func):
         if constants:
             ## import the required GNUTLSConstants used as function default arguments
             code = "from gnutls.constants import %s\n" % ', '.join(c.name for c in constants)
-            exec code in locals(), locals()
+            exec(code, locals(), locals())
         code = "def %s(%s): return wrapper(%s)\nnew_wrapper = %s\n" % (func.__name__, signature, parameters, func.__name__)
-        exec code in locals(), locals()
+        exec(code, locals(), locals())
         new_wrapper.__name__ = func.__name__
         new_wrapper.__doc__ = func.__doc__
         new_wrapper.__module__ = func.__module__