diff options
| -rw-r--r-- | Doc/library/bz2.rst | 2 | ||||
| -rw-r--r-- | Doc/library/hmac.rst | 8 | ||||
| -rw-r--r-- | Doc/library/lzma.rst | 2 | ||||
| -rw-r--r-- | Doc/library/multiprocessing.rst | 8 | ||||
| -rw-r--r-- | Lib/bz2.py | 12 | ||||
| -rw-r--r-- | Lib/ctypes/_endian.py | 2 | ||||
| -rw-r--r-- | Lib/idlelib/AutoComplete.py | 4 | ||||
| -rw-r--r-- | Lib/multiprocessing/connection.py | 12 | ||||
| -rw-r--r-- | Lib/test/test_audioop.py | 31 | ||||
| -rw-r--r-- | Misc/NEWS | 3 | ||||
| -rw-r--r-- | Objects/unicodeobject.c | 5 |
11 files changed, 53 insertions, 36 deletions
diff --git a/Doc/library/bz2.rst b/Doc/library/bz2.rst index dbf938a..7275e12 100644 --- a/Doc/library/bz2.rst +++ b/Doc/library/bz2.rst @@ -29,7 +29,7 @@ All of the classes in this module may safely be accessed from multiple threads. (De)compression of files ------------------------ -.. class:: BZ2File(filename=None, mode='r', buffering=None, compresslevel=9, fileobj=None) +.. class:: BZ2File(filename=None, mode='r', buffering=None, compresslevel=9, \*, fileobj=None) Open a bzip2-compressed file. diff --git a/Doc/library/hmac.rst b/Doc/library/hmac.rst index 0ca3eda..eff2724 100644 --- a/Doc/library/hmac.rst +++ b/Doc/library/hmac.rst @@ -24,14 +24,14 @@ This module implements the HMAC algorithm as described by :rfc:`2104`. An HMAC object has the following methods: -.. method:: hmac.update(msg) +.. method:: HMAC.update(msg) Update the hmac object with the bytes object *msg*. Repeated calls are equivalent to a single call with the concatenation of all the arguments: ``m.update(a); m.update(b)`` is equivalent to ``m.update(a + b)``. -.. method:: hmac.digest() +.. method:: HMAC.digest() Return the digest of the bytes passed to the :meth:`update` method so far. This bytes object will be the same length as the *digest_size* of the digest @@ -39,14 +39,14 @@ An HMAC object has the following methods: bytes. -.. method:: hmac.hexdigest() +.. method:: HMAC.hexdigest() Like :meth:`digest` except the digest is returned as a string twice the length containing only hexadecimal digits. This may be used to exchange the value safely in email or other non-binary environments. -.. method:: hmac.copy() +.. method:: HMAC.copy() Return a copy ("clone") of the hmac object. This can be used to efficiently compute the digests of strings that share a common initial substring. diff --git a/Doc/library/lzma.rst b/Doc/library/lzma.rst index 3941ec1..fc0a148 100644 --- a/Doc/library/lzma.rst +++ b/Doc/library/lzma.rst @@ -32,7 +32,7 @@ from multiple threads, it is necessary to protect it with a lock. Reading and writing compressed files ------------------------------------ -.. class:: LZMAFile(filename=None, mode="r", fileobj=None, format=None, check=-1, preset=None, filters=None) +.. class:: LZMAFile(filename=None, mode="r", \*, fileobj=None, format=None, check=-1, preset=None, filters=None) Open an LZMA-compressed file. diff --git a/Doc/library/multiprocessing.rst b/Doc/library/multiprocessing.rst index 7c94309..106ccd7 100644 --- a/Doc/library/multiprocessing.rst +++ b/Doc/library/multiprocessing.rst @@ -900,14 +900,6 @@ object -- see :ref:`multiprocessing-managers`. .. note:: - The :meth:`acquire` method of :class:`BoundedSemaphore`, :class:`Lock`, - :class:`RLock` and :class:`Semaphore` has a timeout parameter not supported - by the equivalents in :mod:`threading`. The signature is - ``acquire(block=True, timeout=None)`` with keyword parameters being - acceptable. If *block* is ``True`` and *timeout* is not ``None`` then it - specifies a timeout in seconds. If *block* is ``False`` then *timeout* is - ignored. - On Mac OS X, ``sem_timedwait`` is unsupported, so calling ``acquire()`` with a timeout will emulate that function's behavior using a sleeping loop. @@ -40,20 +40,24 @@ class BZ2File(io.BufferedIOBase): """ def __init__(self, filename=None, mode="r", buffering=None, - compresslevel=9, fileobj=None): + compresslevel=9, *, fileobj=None): """Open a bzip2-compressed file. If filename is given, open the named file. Otherwise, operate on the file object given by fileobj. Exactly one of these two parameters should be provided. - mode can be 'r' for reading (default), or 'w' for writing. + mode can be 'r' for reading (default), 'w' for (over)writing, or + 'a' for appending. buffering is ignored. Its use is deprecated. - If mode is 'w', compresslevel can be a number between 1 and 9 - specifying the level of compression: 1 produces the least + If mode is 'w' or 'a', compresslevel can be a number between 1 + and 9 specifying the level of compression: 1 produces the least compression, and 9 (default) produces the most compression. + + If mode is 'r', the input file may be the concatenation of + multiple compressed streams. """ # This lock must be recursive, so that BufferedIOBase's # readline(), readlines() and writelines() don't deadlock. diff --git a/Lib/ctypes/_endian.py b/Lib/ctypes/_endian.py index 721b0d1..dae65fc 100644 --- a/Lib/ctypes/_endian.py +++ b/Lib/ctypes/_endian.py @@ -1,7 +1,7 @@ import sys from ctypes import * -_array_type = type(c_int * 3) +_array_type = type(Array) def _other_endian(typ): """Return the type with the 'other' byte order. Simple types like diff --git a/Lib/idlelib/AutoComplete.py b/Lib/idlelib/AutoComplete.py index fa1733f..5190990 100644 --- a/Lib/idlelib/AutoComplete.py +++ b/Lib/idlelib/AutoComplete.py @@ -190,7 +190,7 @@ class AutoComplete: bigl = eval("dir()", namespace) bigl.sort() if "__all__" in bigl: - smalll = eval("__all__", namespace) + smalll = list(eval("__all__", namespace)) smalll.sort() else: smalll = [s for s in bigl if s[:1] != '_'] @@ -200,7 +200,7 @@ class AutoComplete: bigl = dir(entity) bigl.sort() if "__all__" in bigl: - smalll = entity.__all__ + smalll = list(entity.__all__) smalll.sort() else: smalll = [s for s in bigl if s[:1] != '_'] diff --git a/Lib/multiprocessing/connection.py b/Lib/multiprocessing/connection.py index c6c6113..615f55d 100644 --- a/Lib/multiprocessing/connection.py +++ b/Lib/multiprocessing/connection.py @@ -575,10 +575,14 @@ class SocketListener(object): ''' def __init__(self, address, family, backlog=1): self._socket = socket.socket(getattr(socket, family)) - self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self._socket.bind(address) - self._socket.listen(backlog) - self._address = self._socket.getsockname() + try: + self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + self._socket.bind(address) + self._socket.listen(backlog) + self._address = self._socket.getsockname() + except OSError: + self._socket.close() + raise self._family = family self._last_accepted = None diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index ff60a7d..c14e8b8 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -2,18 +2,19 @@ import audioop import unittest from test.support import run_unittest +endian = 'big' if audioop.getsample(b'\0\1', 2, 0) == 1 else 'little' def gendata1(): return b'\0\1\2' def gendata2(): - if audioop.getsample(b'\0\1', 2, 0) == 1: + if endian == 'big': return b'\0\0\0\1\0\2' else: return b'\0\0\1\0\2\0' def gendata4(): - if audioop.getsample(b'\0\0\0\1', 4, 0) == 1: + if endian == 'big': return b'\0\0\0\0\0\0\0\1\0\0\0\2' else: return b'\0\0\0\0\1\0\0\0\2\0\0\0' @@ -111,9 +112,16 @@ class TestAudioop(unittest.TestCase): # Cursory d = audioop.lin2alaw(data[0], 1) self.assertEqual(audioop.alaw2lin(d, 1), data[0]) - self.assertEqual(audioop.alaw2lin(d, 2), b'\x08\x00\x08\x01\x10\x02') - self.assertEqual(audioop.alaw2lin(d, 4), - b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02') + if endian == 'big': + self.assertEqual(audioop.alaw2lin(d, 2), + b'\x00\x08\x01\x08\x02\x10') + self.assertEqual(audioop.alaw2lin(d, 4), + b'\x00\x08\x00\x00\x01\x08\x00\x00\x02\x10\x00\x00') + else: + self.assertEqual(audioop.alaw2lin(d, 2), + b'\x08\x00\x08\x01\x10\x02') + self.assertEqual(audioop.alaw2lin(d, 4), + b'\x00\x00\x08\x00\x00\x00\x08\x01\x00\x00\x10\x02') def test_lin2ulaw(self): self.assertEqual(audioop.lin2ulaw(data[0], 1), b'\xff\xe7\xdb') @@ -124,9 +132,16 @@ class TestAudioop(unittest.TestCase): # Cursory d = audioop.lin2ulaw(data[0], 1) self.assertEqual(audioop.ulaw2lin(d, 1), data[0]) - self.assertEqual(audioop.ulaw2lin(d, 2), b'\x00\x00\x04\x01\x0c\x02') - self.assertEqual(audioop.ulaw2lin(d, 4), - b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02') + if endian == 'big': + self.assertEqual(audioop.ulaw2lin(d, 2), + b'\x00\x00\x01\x04\x02\x0c') + self.assertEqual(audioop.ulaw2lin(d, 4), + b'\x00\x00\x00\x00\x01\x04\x00\x00\x02\x0c\x00\x00') + else: + self.assertEqual(audioop.ulaw2lin(d, 2), + b'\x00\x00\x04\x01\x0c\x02') + self.assertEqual(audioop.ulaw2lin(d, 4), + b'\x00\x00\x00\x00\x00\x00\x04\x01\x00\x00\x0c\x02') def test_mul(self): data2 = [] @@ -470,6 +470,9 @@ Library - Issue #11805: package_data in setup.cfg should allow more than one value. +- Issue #13933: IDLE auto-complete did not work with some imported + module, like hashlib. (Patch by Roger Serwy) + - Issue #13901: Prevent test_distutils failures on OS X with --enable-shared. - Issue #13676: Handle strings with embedded zeros correctly in sqlite3. diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 67336bf..f13a1de 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1744,9 +1744,8 @@ PyObject * _PyUnicode_FromId(_Py_Identifier *id) { if (!id->object) { - id->object = PyUnicode_DecodeUTF8Stateful(id->string, - strlen(id->string), - NULL, NULL); + id->object = unicode_fromascii((unsigned char*)id->string, + strlen(id->string)); if (!id->object) return NULL; PyUnicode_InternInPlace(&id->object); |
