aboutsummaryrefslogtreecommitdiffstats
path: root/testing/py3-oscrypto/0001-Fix-compatibility-with-Python-3.7.patch
blob: 136b791e7034a0f63d57846a8785a77397bee965 (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
From df9875ee0fd840facd744108aa9151da34d1fb4c Mon Sep 17 00:00:00 2001
From: wbond <will@wbond.net>
Date: Sat, 1 Sep 2018 07:07:40 -0400
Subject: [PATCH] Fix compatibility with Python 3.7

---
 oscrypto/_openssl/tls.py | 9 +++++++--
 oscrypto/_osx/tls.py     | 9 +++++++--
 oscrypto/_win/tls.py     | 9 +++++++--
 3 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/oscrypto/_openssl/tls.py b/oscrypto/_openssl/tls.py
index 0b5097c..57034dd 100644
--- a/oscrypto/_openssl/tls.py
+++ b/oscrypto/_openssl/tls.py
@@ -41,6 +41,11 @@ from ..trust_list import get_path
 if sys.version_info < (3,):
     range = xrange  # noqa
 
+if sys.version_info < (3, 7):
+    Pattern = re._pattern_type
+else:
+    Pattern = re.Pattern
+
 
 __all__ = [
     'TLSSession',
@@ -845,7 +850,7 @@ class TLSSocket(object):
             A byte string of the data read, including the marker
         """
 
-        if not isinstance(marker, byte_cls) and not isinstance(marker, re._pattern_type):
+        if not isinstance(marker, byte_cls) and not isinstance(marker, Pattern):
             raise TypeError(pretty_message(
                 '''
                 marker must be a byte string or compiled regex object, not %s
@@ -855,7 +860,7 @@ class TLSSocket(object):
 
         output = b''
 
-        is_regex = isinstance(marker, re._pattern_type)
+        is_regex = isinstance(marker, Pattern)
 
         while True:
             if len(self._decrypted_bytes) > 0:
diff --git a/oscrypto/_osx/tls.py b/oscrypto/_osx/tls.py
index da03ed1..796361c 100644
--- a/oscrypto/_osx/tls.py
+++ b/oscrypto/_osx/tls.py
@@ -62,6 +62,11 @@ from ..keys import parse_certificate
 if sys.version_info < (3,):
     range = xrange  # noqa
 
+if sys.version_info < (3, 7):
+    Pattern = re._pattern_type
+else:
+    Pattern = re.Pattern
+
 
 __all__ = [
     'TLSSession',
@@ -1116,7 +1121,7 @@ class TLSSocket(object):
             A byte string of the data read, including the marker
         """
 
-        if not isinstance(marker, byte_cls) and not isinstance(marker, re._pattern_type):
+        if not isinstance(marker, byte_cls) and not isinstance(marker, Pattern):
             raise TypeError(pretty_message(
                 '''
                 marker must be a byte string or compiled regex object, not %s
@@ -1126,7 +1131,7 @@ class TLSSocket(object):
 
         output = b''
 
-        is_regex = isinstance(marker, re._pattern_type)
+        is_regex = isinstance(marker, Pattern)
 
         while True:
             if len(self._decrypted_bytes) > 0:
diff --git a/oscrypto/_win/tls.py b/oscrypto/_win/tls.py
index 9a85555..0a8ff70 100644
--- a/oscrypto/_win/tls.py
+++ b/oscrypto/_win/tls.py
@@ -61,6 +61,11 @@ if sys.version_info < (3,):
 else:
     socket_error_cls = WindowsError
 
+if sys.version_info < (3, 7):
+    Pattern = re._pattern_type
+else:
+    Pattern = re.Pattern
+
 
 __all__ = [
     'TLSSession',
@@ -1180,7 +1185,7 @@ class TLSSocket(object):
             A byte string of the data read
         """
 
-        if not isinstance(marker, byte_cls) and not isinstance(marker, re._pattern_type):
+        if not isinstance(marker, byte_cls) and not isinstance(marker, Pattern):
             raise TypeError(pretty_message(
                 '''
                 marker must be a byte string or compiled regex object, not %s
@@ -1190,7 +1195,7 @@ class TLSSocket(object):
 
         output = b''
 
-        is_regex = isinstance(marker, re._pattern_type)
+        is_regex = isinstance(marker, Pattern)
 
         while True:
             if len(self._decrypted_bytes) > 0: