]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 67950,67962,67968-67969,68027,68075,68091,68093 via svnmerge from
authorGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:47:58 +0000 (23:47 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:47:58 +0000 (23:47 +0000)
svn+ssh://svn.python.org/python/branches/py3k

........
  r67950 | benjamin.peterson | 2008-12-27 18:00:44 +0100 (Sat, 27 Dec 2008) | 1 line

  fix 2.x isms in distutils test
........
  r67962 | georg.brandl | 2008-12-27 20:08:11 +0100 (Sat, 27 Dec 2008) | 2 lines

  #4697: clarify that the functions are Unix-only.
........
  r67968 | georg.brandl | 2008-12-28 00:12:09 +0100 (Sun, 28 Dec 2008) | 2 lines

  Remove confusing error message in bytes.translate.
........
  r67969 | georg.brandl | 2008-12-28 00:33:20 +0100 (Sun, 28 Dec 2008) | 5 lines

  Document bytes.translate().

  BTW, having str.maketrans() as a static method and
  string.maketrans() as a function that creates translation tables for bytes objects is not very consistent :)
........
  r68027 | benjamin.peterson | 2008-12-29 21:52:09 +0100 (Mon, 29 Dec 2008) | 1 line

  hexdigest() doesn't return bytes #4771
........
  r68075 | benjamin.peterson | 2008-12-30 19:05:46 +0100 (Tue, 30 Dec 2008) | 2 lines

  use $(RUNSHARED) to run plat-mac/regen
........
  r68091 | benjamin.peterson | 2008-12-31 04:43:28 +0100 (Wed, 31 Dec 2008) | 1 line

  #4788 qualify remove a bare except
........
  r68093 | benjamin.peterson | 2008-12-31 05:10:35 +0100 (Wed, 31 Dec 2008) | 1 line

  fix name usage
........

Doc/library/hashlib.rst
Doc/library/stdtypes.rst
Doc/library/subprocess.rst
Lib/ssl.py
Objects/bytesobject.c

index 2741265d1c35c12361c38de7fb0fc4316a4ff3b5..ad2bfa53d32dced80daa098433c79fbdc13edc3e 100644 (file)
@@ -64,7 +64,7 @@ spammish repetition'``::
 More condensed:
 
    >>> hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()
-   b'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
+   'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
 
 A generic :func:`new` constructor that takes the string name of the desired
 algorithm as its first parameter also exists to allow access to the above listed
@@ -76,7 +76,7 @@ Using :func:`new` with an algorithm provided by OpenSSL:
    >>> h = hashlib.new('ripemd160')
    >>> h.update(b"Nobody inspects the spammish repetition")
    >>> h.hexdigest()
-   b'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
+   'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
 
 The following values are provided as constant attributes of the hash objects
 returned by the constructors:
index 68e8dbafdb3aa586be632af0425c5ccbd22d4739..0ce1c15936a3029353b22cd1d4286f6b6004f371 100644 (file)
@@ -1086,13 +1086,12 @@ functions based on regular expressions.
 .. method:: str.translate(map)
 
    Return a copy of the *s* where all characters have been mapped through the
-   *map* which must be a dictionary of Unicode ordinals(integers) to Unicode
+   *map* which must be a dictionary of Unicode ordinals (integers) to Unicode
    ordinals, strings or ``None``.  Unmapped characters are left untouched.
    Characters mapped to ``None`` are deleted.
 
-   You can use :meth:`str.maketrans` to create a translation table.  For string
-   objects, set the *table* argument to ``None`` for translations that only
-   delete characters:
+   You can use :meth:`str.maketrans` to create a translation map from
+   character-to-character mappings in different formats.
 
    .. note::
 
@@ -1495,23 +1494,23 @@ The bytes and bytearray types have an additional class method:
    >>> bytes.fromhex('f0 f1f2  ')
    b'\xf0\xf1\xf2'
 
-.. XXX verify/document translate() semantics!
-
-   .. method:: bytes.translate(table[, delete])
+The translate method differs in semantics from the version available on strings:
+   
+.. method:: bytes.translate(table[, delete])
 
-   Return a copy of the bytes object where all bytes occurring in the optional
-   argument *delete* are removed, and the remaining bytes have been mapped
-   through the given translation table, which must be a bytes object of length
-   256.
+   Return a copy of the bytes or bytearray object where all bytes occurring in
+   the optional argument *delete* are removed, and the remaining bytes have been
+   mapped through the given translation table, which must be a bytes object of
+   length 256.
 
-   You can use the :func:`maketrans` helper function in the :mod:`string` module to
-   create a translation table.
+   You can use the :func:`string.maketrans` helper function to create a
+   translation table.
 
-   .. XXX a None table doesn't seem to be supported
-      Set the *table* argument to ``None`` for translations that only delete characters::
+   Set the *table* argument to ``None`` for translations that only delete
+   characters::
 
-         >>> 'read this short text'.translate(None, 'aeiou')
-         'rd ths shrt txt'
+      >>> b'read this short text'.translate(None, b'aeiou')
+      b'rd ths shrt txt'
 
 
 .. _types-set:
index 6aff816d9982c086ca27bac484f67329cabcda56..b8523e76d798c8722a0bd28bec83f4713c0d67b2 100644 (file)
@@ -173,6 +173,8 @@ This module also defines four shortcut functions:
       >>> subprocess.getstatusoutput('/bin/junk')
       (256, 'sh: /bin/junk: not found')
 
+   Availability: UNIX.
+
 
 .. function:: getoutput(cmd)
    Return output ``(stdout or stderr)`` of executing *cmd* in a shell.
@@ -184,6 +186,8 @@ This module also defines four shortcut functions:
       >>> subprocess.getoutput('ls /bin/ls')
       '/bin/ls'
 
+   Availability: UNIX.
+
 
 Exceptions
 ^^^^^^^^^^
index cd54437a0c5d2c0f2d2da281dc17642902055298..d3c1d32c72a3b2b723a6d41d46d0932f1e5b9ba4 100644 (file)
@@ -114,7 +114,7 @@ class SSLSocket(socket):
         # see if it's connected
         try:
             socket.getpeername(self)
-        except:
+        except socket_error:
             # no, no connection yet
             self._sslobj = None
         else:
index 76b7f522005c5c678f90b8e95989a083c3ca2f97..c75ebabe501c86c8bb163abb78e2f4e5c21477c7 100644 (file)
@@ -1884,11 +1884,6 @@ string_translate(PyBytesObject *self, PyObject *args)
                        del_table = PyBytes_AS_STRING(delobj);
                        dellen = PyBytes_GET_SIZE(delobj);
                }
-               else if (PyUnicode_Check(delobj)) {
-                       PyErr_SetString(PyExc_TypeError,
-                       "deletions are implemented differently for unicode");
-                       return NULL;
-               }
                else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen))
                        return NULL;
        }