]> granicus.if.org Git - python/commitdiff
More codestring -> codebytes.
authorGeorg Brandl <georg@python.org>
Thu, 4 Jun 2009 09:42:55 +0000 (09:42 +0000)
committerGeorg Brandl <georg@python.org>
Thu, 4 Jun 2009 09:42:55 +0000 (09:42 +0000)
Lib/base64.py
Lib/distutils/command/upload.py
Lib/email/test/test_email.py
Lib/http/server.py
Lib/plistlib.py
Lib/smtplib.py
Lib/ssl.py
Lib/test/test_gettext.py
Lib/test/test_urllib2.py
Lib/urllib/request.py

index c1135a88e20edaddb21109ef2d67fb2c8750da81..73e980813d7b959aba9953e516bad4208c331abe 100755 (executable)
@@ -391,9 +391,9 @@ def main():
 def test():
     s0 = b"Aladdin:open sesame"
     print(repr(s0))
-    s1 = encodestring(s0)
+    s1 = encodebytes(s0)
     print(repr(s1))
-    s2 = decodestring(s1)
+    s2 = decodebytes(s1)
     print(repr(s2))
     assert s0 == s2
 
index 9249427a435340582171b29fcdf2e6b493b1053d..3b4a036718f70c79cf7889ec9a8960a1b0c5cf44 100644 (file)
@@ -127,7 +127,7 @@ class upload(PyPIRCCommand):
         user_pass = (self.username + ":" + self.password).encode('ascii')
         # The exact encoding of the authentication string is debated.
         # Anyway PyPI only accepts ascii for both username or password.
-        auth = "Basic " + base64.encodestring(user_pass).strip().decode('ascii')
+        auth = "Basic " + base64.encodebytes(user_pass).strip().decode('ascii')
 
         # Build up the MIME payload for the POST data
         boundary = '--------------GHSKFJDLGDS7543FJKLFHRE75642756743254'
index 4b5065f942b6dea86c71bab001b27500f1c44782..86e35375c3f2bc0607dd7a7283cdc904e9fd5c17 100644 (file)
@@ -944,7 +944,7 @@ class TestMIMEAudio(unittest.TestCase):
 
     def test_encoding(self):
         payload = self._au.get_payload()
-        self.assertEqual(base64.decodestring(payload), self._audiodata)
+        self.assertEqual(base64.decodebytes(payload), self._audiodata)
 
     def test_checkSetMinor(self):
         au = MIMEAudio(self._audiodata, 'fish')
@@ -984,7 +984,7 @@ class TestMIMEImage(unittest.TestCase):
 
     def test_encoding(self):
         payload = self._im.get_payload()
-        self.assertEqual(base64.decodestring(payload), self._imgdata)
+        self.assertEqual(base64.decodebytes(payload), self._imgdata)
 
     def test_checkSetMinor(self):
         im = MIMEImage(self._imgdata, 'fish')
index 193964ff0f581e74f2fb0efc0e5872ecdd039f69..2163e748e6d1c6c2eece8d9788f8cf6c522880fc 100644 (file)
@@ -985,7 +985,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
                 if authorization[0].lower() == "basic":
                     try:
                         authorization = authorization[1].encode('ascii')
-                        authorization = base64.decodestring(authorization).\
+                        authorization = base64.decodebytes(authorization).\
                                         decode('ascii')
                     except (binascii.Error, UnicodeError):
                         pass
index 2084b5f505ec015d07628a1c6d422090cd60b316..5460e2b5dfecf75f71c2f7519c20636f83367599 100644 (file)
@@ -316,7 +316,7 @@ class Plist(_InternalDict):
 
 
 def _encodeBase64(s, maxlinelength=76):
-    # copied from base64.encodestring(), with added maxlinelength argument
+    # copied from base64.encodebytes(), with added maxlinelength argument
     maxbinsize = (maxlinelength//4)*3
     pieces = []
     for i in range(0, len(s), maxbinsize):
@@ -335,7 +335,7 @@ class Data:
 
     @classmethod
     def fromBase64(cls, data):
-        # base64.decodestring just calls binascii.a2b_base64;
+        # base64.decodebytes just calls binascii.a2b_base64;
         # it seems overkill to use both base64 and binascii.
         return cls(binascii.a2b_base64(data))
 
index baed78107b1408e7d95fde6659b916ad4ba3eb66..b88adfe96e3f0ccc74da3aab47511dbf676a602d 100755 (executable)
@@ -540,7 +540,7 @@ class SMTP:
         """
 
         def encode_cram_md5(challenge, user, password):
-            challenge = base64.decodestring(challenge)
+            challenge = base64.decodebytes(challenge)
             response = user + " " + hmac.HMAC(password.encode('ascii'),
                                               challenge).hexdigest()
             return encode_base64(response.encode('ascii'), eol='')
index d3c1d32c72a3b2b723a6d41d46d0932f1e5b9ba4..6a6a1a33d67d5a96ad6b2e7b74355889025486cb 100644 (file)
@@ -413,7 +413,7 @@ def PEM_cert_to_DER_cert(pem_cert_string):
         raise ValueError("Invalid PEM encoding; must end with %s"
                          % PEM_FOOTER)
     d = pem_cert_string.strip()[len(PEM_HEADER):-len(PEM_FOOTER)]
-    return base64.decodestring(d.encode('ASCII', 'strict'))
+    return base64.decodebytes(d.encode('ASCII', 'strict'))
 
 def get_server_certificate(addr, ssl_version=PROTOCOL_SSLv3, ca_certs=None):
     """Retrieve the certificate from the server at the specified address,
index e26b30a8994c26dfb20ffb29eb51f31b0ef35351..0023941dd58b890b141ffef6f5102e1bfc52fa99 100644 (file)
@@ -65,13 +65,13 @@ class GettextBaseTest(unittest.TestCase):
         if not os.path.isdir(LOCALEDIR):
             os.makedirs(LOCALEDIR)
         fp = open(MOFILE, 'wb')
-        fp.write(base64.decodestring(GNU_MO_DATA))
+        fp.write(base64.decodebytes(GNU_MO_DATA))
         fp.close()
         fp = open(UMOFILE, 'wb')
-        fp.write(base64.decodestring(UMO_DATA))
+        fp.write(base64.decodebytes(UMO_DATA))
         fp.close()
         fp = open(MMOFILE, 'wb')
-        fp.write(base64.decodestring(MMO_DATA))
+        fp.write(base64.decodebytes(MMO_DATA))
         fp.close()
         self.env = support.EnvironmentVarGuard()
         self.env['LANGUAGE'] = 'xx'
index c8be4408591bf072c0b36037970661b62ad6813d..39ec498a9933245b735687e7a1345ebb0d1dec46 100644 (file)
@@ -1050,7 +1050,7 @@ class HandlerTests(unittest.TestCase):
         self.assertFalse(http_handler.requests[0].has_header(auth_header))
         userpass = bytes('%s:%s' % (user, password), "ascii")
         auth_hdr_value = ('Basic ' +
-            base64.encodestring(userpass).strip().decode())
+            base64.encodebytes(userpass).strip().decode())
         self.assertEqual(http_handler.requests[1].get_header(auth_header),
                          auth_hdr_value)
 
index 89ac22a8f12f95da055879f1ebb274c5257d5d33..bb67267639bf14059cde2dbcbc7945f5ab67cc8a 100644 (file)
@@ -1758,7 +1758,8 @@ class URLopener:
         msg.append('Content-type: %s' % type)
         if encoding == 'base64':
             import base64
-            data = base64.decodestring(data)
+            # XXX is this encoding/decoding ok?
+            data = base64.decodebytes(data.encode('ascii')).decode('latin1')
         else:
             data = unquote(data)
         msg.append('Content-Length: %d' % len(data))