[Python-checkins] r73211 - in python/branches/py3k/Lib: base64.py distutils/command/upload.py email/test/test_email.py http/server.py plistlib.py smtplib.py ssl.py test/test_gettext.py test/test_urllib2.py urllib/request.py

georg.brandl python-checkins at python.org
Thu Jun 4 11:42:55 CEST 2009


Author: georg.brandl
Date: Thu Jun 4 11:42:55 2009
New Revision: 73211
Log:
More codestring -> codebytes.
Modified:
 python/branches/py3k/Lib/base64.py
 python/branches/py3k/Lib/distutils/command/upload.py
 python/branches/py3k/Lib/email/test/test_email.py
 python/branches/py3k/Lib/http/server.py
 python/branches/py3k/Lib/plistlib.py
 python/branches/py3k/Lib/smtplib.py
 python/branches/py3k/Lib/ssl.py
 python/branches/py3k/Lib/test/test_gettext.py
 python/branches/py3k/Lib/test/test_urllib2.py
 python/branches/py3k/Lib/urllib/request.py
Modified: python/branches/py3k/Lib/base64.py
==============================================================================
--- python/branches/py3k/Lib/base64.py	(original)
+++ python/branches/py3k/Lib/base64.py	Thu Jun 4 11:42:55 2009
@@ -391,9 +391,9 @@
 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
 
Modified: python/branches/py3k/Lib/distutils/command/upload.py
==============================================================================
--- python/branches/py3k/Lib/distutils/command/upload.py	(original)
+++ python/branches/py3k/Lib/distutils/command/upload.py	Thu Jun 4 11:42:55 2009
@@ -127,7 +127,7 @@
 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'
Modified: python/branches/py3k/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k/Lib/email/test/test_email.py	(original)
+++ python/branches/py3k/Lib/email/test/test_email.py	Thu Jun 4 11:42:55 2009
@@ -944,7 +944,7 @@
 
 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 @@
 
 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')
Modified: python/branches/py3k/Lib/http/server.py
==============================================================================
--- python/branches/py3k/Lib/http/server.py	(original)
+++ python/branches/py3k/Lib/http/server.py	Thu Jun 4 11:42:55 2009
@@ -985,7 +985,7 @@
 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
Modified: python/branches/py3k/Lib/plistlib.py
==============================================================================
--- python/branches/py3k/Lib/plistlib.py	(original)
+++ python/branches/py3k/Lib/plistlib.py	Thu Jun 4 11:42:55 2009
@@ -316,7 +316,7 @@
 
 
 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 @@
 
 @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))
 
Modified: python/branches/py3k/Lib/smtplib.py
==============================================================================
--- python/branches/py3k/Lib/smtplib.py	(original)
+++ python/branches/py3k/Lib/smtplib.py	Thu Jun 4 11:42:55 2009
@@ -540,7 +540,7 @@
 """
 
 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='')
Modified: python/branches/py3k/Lib/ssl.py
==============================================================================
--- python/branches/py3k/Lib/ssl.py	(original)
+++ python/branches/py3k/Lib/ssl.py	Thu Jun 4 11:42:55 2009
@@ -413,7 +413,7 @@
 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,
Modified: python/branches/py3k/Lib/test/test_gettext.py
==============================================================================
--- python/branches/py3k/Lib/test/test_gettext.py	(original)
+++ python/branches/py3k/Lib/test/test_gettext.py	Thu Jun 4 11:42:55 2009
@@ -65,13 +65,13 @@
 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'
Modified: python/branches/py3k/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k/Lib/test/test_urllib2.py	(original)
+++ python/branches/py3k/Lib/test/test_urllib2.py	Thu Jun 4 11:42:55 2009
@@ -1050,7 +1050,7 @@
 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)
 
Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py	(original)
+++ python/branches/py3k/Lib/urllib/request.py	Thu Jun 4 11:42:55 2009
@@ -1758,7 +1758,8 @@
 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))


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /