File: py3.9-use-base64.encodebytes-not-base64.encodestring.patch

package info (click to toggle)
python-wsme 0.10.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 680 kB
  • sloc: python: 6,091; makefile: 24; javascript: 8
file content (89 lines) | stat: -rw-r--r-- 3,655 bytes parent folder | download
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
Description: Use encodebytes not encodestring
 The base64.encodestring() alias is gone in Python 3.9.
Author: Thomas Goirand <zigo@debian.org>
Forwarded: no
Last-Update: 2020-10-14

Index: python-wsme/wsme/tests/test_restjson.py
===================================================================
--- python-wsme.orig/wsme/tests/test_restjson.py
+++ python-wsme/wsme/tests/test_restjson.py
@@ -35,7 +35,7 @@ def prepare_value(value, datatype):
     if datatype == decimal.Decimal:
         return str(value)
     if datatype == wsme.types.binary:
-        return base64.encodestring(value).decode('ascii')
+        return base64.encodebytes(value).decode('ascii')
     if datatype == wsme.types.bytes:
         return value.decode('ascii')
     return value
@@ -46,7 +46,7 @@ def prepare_result(value, datatype):
     if value is None:
         return None
     if datatype == wsme.types.binary:
-        return base64.decodestring(value.encode('ascii'))
+        return base64.decodebytes(value.encode('ascii'))
     if isusertype(datatype):
         datatype = datatype.basetype
     if isinstance(datatype, list):
Index: python-wsme/wsme/tests/test_restxml.py
===================================================================
--- python-wsme.orig/wsme/tests/test_restxml.py
+++ python-wsme/wsme/tests/test_restxml.py
@@ -30,7 +30,7 @@ def dumpxml(key, obj, datatype=None):
             node.append(dumpxml('key', item[0], key_type))
             node.append(dumpxml('value', item[1], value_type))
     elif datatype == wsme.types.binary:
-        el.text = base64.encodestring(obj).decode('ascii')
+        el.text = base64.encodebytes(obj).decode('ascii')
     elif isinstance(obj, wsme.types.bytes):
         el.text = obj.decode('ascii')
     elif isinstance(obj, wsme.types.text):
@@ -96,7 +96,7 @@ def loadxml(el, datatype):
         return d
     else:
         if datatype == wsme.types.binary:
-            return base64.decodestring(el.text.encode('ascii'))
+            return base64.decodebytes(el.text.encode('ascii'))
         if isusertype(datatype):
             datatype = datatype.basetype
         if datatype == datetime.date:
Index: python-wsme/wsme/tests/test_types.py
===================================================================
--- python-wsme.orig/wsme/tests/test_types.py
+++ python-wsme/wsme/tests/test_types.py
@@ -464,13 +464,13 @@ Value: 'v3'. Value should be one of: v.,
     def test_binary_to_base(self):
         import base64
         assert types.binary.tobasetype(None) is None
-        expected = base64.encodestring(six.b('abcdef'))
+        expected = base64.encodebytes(six.b('abcdef'))
         assert types.binary.tobasetype(six.b('abcdef')) == expected
 
     def test_binary_from_base(self):
         import base64
         assert types.binary.frombasetype(None) is None
-        encoded = base64.encodestring(six.b('abcdef'))
+        encoded = base64.encodebytes(six.b('abcdef'))
         assert types.binary.frombasetype(encoded) == six.b('abcdef')
 
     def test_wsattr_weakref_datatype(self):
Index: python-wsme/wsme/types.py
===================================================================
--- python-wsme.orig/wsme/types.py
+++ python-wsme/wsme/types.py
@@ -128,12 +128,12 @@ class BinaryType(UserType):
     def tobasetype(self, value):
         if value is None:
             return None
-        return base64.encodestring(value)
+        return base64.encodebytes(value)
 
     def frombasetype(self, value):
         if value is None:
             return None
-        return base64.decodestring(value)
+        return base64.decodebytes(value)
 
 
 #: The binary almost-native type