Commit 6698564e authored by Christian Heimes's avatar Christian Heimes

merge

parents cede1a50 f1056723
...@@ -124,7 +124,7 @@ The important points to remember are: ...@@ -124,7 +124,7 @@ The important points to remember are:
The object returned by ``super()`` also has a custom :meth:`__getattribute__` The object returned by ``super()`` also has a custom :meth:`__getattribute__`
method for invoking descriptors. The call ``super(B, obj).m()`` searches method for invoking descriptors. The call ``super(B, obj).m()`` searches
``obj.__class__.__mro__`` for the base class ``A`` immediately following ``B`` ``obj.__class__.__mro__`` for the base class ``A`` immediately following ``B``
and then returns ``A.__dict__['m'].__get__(obj, A)``. If not a descriptor, and then returns ``A.__dict__['m'].__get__(obj, B)``. If not a descriptor,
``m`` is returned unchanged. If not in the dictionary, ``m`` reverts to a ``m`` is returned unchanged. If not in the dictionary, ``m`` reverts to a
search using :meth:`object.__getattribute__`. search using :meth:`object.__getattribute__`.
......
...@@ -30,8 +30,8 @@ sampling rate or frame rate is the number of times per second the sound is ...@@ -30,8 +30,8 @@ sampling rate or frame rate is the number of times per second the sound is
sampled. The number of channels indicate if the audio is mono, stereo, or sampled. The number of channels indicate if the audio is mono, stereo, or
quadro. Each frame consists of one sample per channel. The sample size is the quadro. Each frame consists of one sample per channel. The sample size is the
size in bytes of each sample. Thus a frame consists of size in bytes of each sample. Thus a frame consists of
*nchannels*\**samplesize* bytes, and a second's worth of audio consists of *nchannels*\*\ *samplesize* bytes, and a second's worth of audio consists of
*nchannels*\**samplesize*\**framerate* bytes. *nchannels*\*\ *samplesize*\*\ *framerate* bytes.
For example, CD quality audio has a sample size of two bytes (16 bits), uses two For example, CD quality audio has a sample size of two bytes (16 bits), uses two
channels (stereo) and has a frame rate of 44,100 frames/second. This gives a channels (stereo) and has a frame rate of 44,100 frames/second. This gives a
......
...@@ -68,7 +68,7 @@ The available exception and functions in this module are: ...@@ -68,7 +68,7 @@ The available exception and functions in this module are:
Raises the :exc:`error` exception if any error occurs. Raises the :exc:`error` exception if any error occurs.
.. function:: compressobj([level]) .. function:: compressobj([level[, method[, wbits[, memlevel[, strategy]]]]])
Returns a compression object, to be used for compressing data streams that won't Returns a compression object, to be used for compressing data streams that won't
fit into memory at once. *level* is an integer from ``0`` to ``9`` controlling fit into memory at once. *level* is an integer from ``0`` to ``9`` controlling
...@@ -76,6 +76,21 @@ The available exception and functions in this module are: ...@@ -76,6 +76,21 @@ The available exception and functions in this module are:
``9`` is slowest and produces the most. ``0`` is no compression. The default ``9`` is slowest and produces the most. ``0`` is no compression. The default
value is ``6``. value is ``6``.
*method* is the compression algorithm. Currently, the only supported value is
``DEFLATED``.
*wbits* is the base two logarithm of the size of the window buffer. This
should be an integer from ``8`` to ``15``. Higher values give better
compression, but use more memory. The default is 15.
*memlevel* controls the amount of memory used for internal compression state.
Valid values range from ``1`` to ``9``. Higher values using more memory,
but are faster and produce smaller output. The default is 8.
*strategy* is used to tune the compression algorithm. Possible values are
``Z_DEFAULT_STRATEGY``, ``Z_FILTERED``, and ``Z_HUFFMAN_ONLY``. The default
is ``Z_DEFAULT_STRATEGY``.
.. function:: crc32(data[, value]) .. function:: crc32(data[, value])
......
...@@ -857,7 +857,7 @@ class StreamHandler(Handler): ...@@ -857,7 +857,7 @@ class StreamHandler(Handler):
try: try:
if (isinstance(msg, unicode) and if (isinstance(msg, unicode) and
getattr(stream, 'encoding', None)): getattr(stream, 'encoding', None)):
ufs = fs.decode(stream.encoding) ufs = u'%s\n'
try: try:
stream.write(ufs % msg) stream.write(ufs % msg)
except UnicodeEncodeError: except UnicodeEncodeError:
......
...@@ -611,6 +611,35 @@ class UTF7Test(ReadTest): ...@@ -611,6 +611,35 @@ class UTF7Test(ReadTest):
] ]
) )
def test_errors(self):
tests = [
('a\xffb', u'a\ufffdb'),
('a+IK', u'a\ufffd'),
('a+IK-b', u'a\ufffdb'),
('a+IK,b', u'a\ufffdb'),
('a+IKx', u'a\u20ac\ufffd'),
('a+IKx-b', u'a\u20ac\ufffdb'),
('a+IKwgr', u'a\u20ac\ufffd'),
('a+IKwgr-b', u'a\u20ac\ufffdb'),
('a+IKwgr,', u'a\u20ac\ufffd'),
('a+IKwgr,-b', u'a\u20ac\ufffd-b'),
('a+IKwgrB', u'a\u20ac\u20ac\ufffd'),
('a+IKwgrB-b', u'a\u20ac\u20ac\ufffdb'),
('a+/,+IKw-b', u'a\ufffd\u20acb'),
('a+//,+IKw-b', u'a\ufffd\u20acb'),
('a+///,+IKw-b', u'a\uffff\ufffd\u20acb'),
('a+////,+IKw-b', u'a\uffff\ufffd\u20acb'),
]
for raw, expected in tests:
self.assertRaises(UnicodeDecodeError, codecs.utf_7_decode,
raw, 'strict', True)
self.assertEqual(raw.decode('utf-7', 'replace'), expected)
def test_nonbmp(self):
self.assertEqual(u'\U000104A0'.encode(self.encoding), '+2AHcoA-')
self.assertEqual(u'\ud801\udca0'.encode(self.encoding), '+2AHcoA-')
self.assertEqual('+2AHcoA-'.decode(self.encoding), u'\U000104A0')
class UTF16ExTest(unittest.TestCase): class UTF16ExTest(unittest.TestCase):
def test_errors(self): def test_errors(self):
......
...@@ -1060,6 +1060,24 @@ class EncodingTest(BaseTest): ...@@ -1060,6 +1060,24 @@ class EncodingTest(BaseTest):
#Compare against what the data should be when encoded in CP-1251 #Compare against what the data should be when encoded in CP-1251
self.assertEqual(s, '\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n') self.assertEqual(s, '\xe4\xee \xf1\xe2\xe8\xe4\xe0\xed\xe8\xff\n')
def test_encoding_utf16_unicode(self):
# Issue #19267
log = logging.getLogger("test")
message = u'b\u0142\u0105d'
writer_class = codecs.getwriter('utf-16-le')
writer_class.encoding = 'utf-16-le'
stream = cStringIO.StringIO()
writer = writer_class(stream, 'strict')
handler = logging.StreamHandler(writer)
log.addHandler(handler)
try:
log.warning(message)
finally:
log.removeHandler(handler)
handler.close()
s = stream.getvalue()
self.assertEqual(s, 'b\x00B\x01\x05\x01d\x00\n\x00')
class WarningsTest(BaseTest): class WarningsTest(BaseTest):
......
from test.test_support import TESTFN, run_unittest from test.test_support import TESTFN, run_unittest
import unittest import unittest
from test import audiotests from test import audiotests
import sys
import wave import wave
...@@ -44,9 +45,13 @@ class WavePCM16Test(audiotests.AudioWriteTests, ...@@ -44,9 +45,13 @@ class WavePCM16Test(audiotests.AudioWriteTests,
EEDF1755 82061666 7FFF1446 80001296 499C0EB2 52BA0DB9 EFB70F5C CE400FBC \ EEDF1755 82061666 7FFF1446 80001296 499C0EB2 52BA0DB9 EFB70F5C CE400FBC \
E4B50CEB 63440A5A 08CA0A1F 2BBA0B0B 51460E47 8BCB113C B6F50EEA 44150A59 \ E4B50CEB 63440A5A 08CA0A1F 2BBA0B0B 51460E47 8BCB113C B6F50EEA 44150A59 \
""") """)
frames = audiotests.byteswap2(frames) if sys.byteorder != 'big':
frames = audiotests.byteswap2(frames)
@unittest.skipIf(sys.byteorder == 'big',
'24-bit wave files are supported only on little-endian '
'platforms')
class WavePCM24Test(audiotests.AudioWriteTests, class WavePCM24Test(audiotests.AudioWriteTests,
audiotests.AudioTestsWithSourceFile, audiotests.AudioTestsWithSourceFile,
unittest.TestCase): unittest.TestCase):
...@@ -73,7 +78,8 @@ class WavePCM24Test(audiotests.AudioWriteTests, ...@@ -73,7 +78,8 @@ class WavePCM24Test(audiotests.AudioWriteTests,
E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E \ E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E \
51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48 \ 51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48 \
""") """)
frames = audiotests.byteswap3(frames) if sys.byteorder != 'big':
frames = audiotests.byteswap3(frames)
class WavePCM32Test(audiotests.AudioWriteTests, class WavePCM32Test(audiotests.AudioWriteTests,
...@@ -102,7 +108,8 @@ class WavePCM32Test(audiotests.AudioWriteTests, ...@@ -102,7 +108,8 @@ class WavePCM32Test(audiotests.AudioWriteTests,
E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00 \ E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00 \
51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0 \ 51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0 \
""") """)
frames = audiotests.byteswap4(frames) if sys.byteorder != 'big':
frames = audiotests.byteswap4(frames)
def test_main(): def test_main():
......
...@@ -80,7 +80,7 @@ class Error(Exception): ...@@ -80,7 +80,7 @@ class Error(Exception):
WAVE_FORMAT_PCM = 0x0001 WAVE_FORMAT_PCM = 0x0001
_array_fmts = None, 'b', 'h', None, 'l' _array_fmts = None, 'b', 'h', None, 'i'
# Determine endian-ness # Determine endian-ness
import struct import struct
...@@ -238,6 +238,7 @@ class Wave_read: ...@@ -238,6 +238,7 @@ class Wave_read:
import array import array
chunk = self._data_chunk chunk = self._data_chunk
data = array.array(_array_fmts[self._sampwidth]) data = array.array(_array_fmts[self._sampwidth])
assert data.itemsize == self._sampwidth
nitems = nframes * self._nchannels nitems = nframes * self._nchannels
if nitems * self._sampwidth > chunk.chunksize - chunk.size_read: if nitems * self._sampwidth > chunk.chunksize - chunk.size_read:
nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth nitems = (chunk.chunksize - chunk.size_read) / self._sampwidth
...@@ -421,6 +422,7 @@ class Wave_write: ...@@ -421,6 +422,7 @@ class Wave_write:
if self._sampwidth > 1 and big_endian: if self._sampwidth > 1 and big_endian:
import array import array
data = array.array(_array_fmts[self._sampwidth], data) data = array.array(_array_fmts[self._sampwidth], data)
assert data.itemsize == self._sampwidth
data.byteswap() data.byteswap()
data.tofile(self._file) data.tofile(self._file)
self._datawritten = self._datawritten + len(data) * self._sampwidth self._datawritten = self._datawritten + len(data) * self._sampwidth
......
...@@ -155,6 +155,7 @@ target_cc_map = { ...@@ -155,6 +155,7 @@ target_cc_map = {
'10.6': ('gcc-4.2', 'g++-4.2'), '10.6': ('gcc-4.2', 'g++-4.2'),
'10.7': ('clang', 'clang++'), '10.7': ('clang', 'clang++'),
'10.8': ('clang', 'clang++'), '10.8': ('clang', 'clang++'),
'10.9': ('clang', 'clang++'),
} }
CC, CXX = target_cc_map[DEPTARGET] CC, CXX = target_cc_map[DEPTARGET]
......
...@@ -9,6 +9,8 @@ What's New in Python 2.7.6? ...@@ -9,6 +9,8 @@ What's New in Python 2.7.6?
Core and Builtins Core and Builtins
----------------- -----------------
- Issue #19279: UTF-7 decoder no more produces illegal unicode strings.
- Issue #18739: Fix an inconsistency between math.log(n) and math.log(long(n)); - Issue #18739: Fix an inconsistency between math.log(n) and math.log(long(n));
the results could be off from one another by a ulp or two. the results could be off from one another by a ulp or two.
...@@ -35,6 +37,8 @@ Core and Builtins ...@@ -35,6 +37,8 @@ Core and Builtins
Library Library
------- -------
- Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
- Issue #18458: Prevent crashes with newer versions of libedit. Its readline - Issue #18458: Prevent crashes with newer versions of libedit. Its readline
emulation has changed from 0-based indexing to 1-based like gnu readline. emulation has changed from 0-based indexing to 1-based like gnu readline.
Original patch by Ronald Oussoren. Original patch by Ronald Oussoren.
...@@ -228,7 +232,6 @@ Library ...@@ -228,7 +232,6 @@ Library
existing directory caused mkstemp and related APIs to fail instead of existing directory caused mkstemp and related APIs to fail instead of
retrying. Report and fix by Vlad Shcherbina. retrying. Report and fix by Vlad Shcherbina.
Tools/Demos Tools/Demos
----------- -----------
...@@ -370,6 +373,9 @@ Library ...@@ -370,6 +373,9 @@ Library
- Issue #17926: Fix dbm.__contains__ on 64-bit big-endian machines. - Issue #17926: Fix dbm.__contains__ on 64-bit big-endian machines.
- Issue #19267: Fix support of multibyte encoding (ex: UTF-16) in the logging
module.
- Issue #17918: When using SSLSocket.accept(), if the SSL handshake failed - Issue #17918: When using SSLSocket.accept(), if the SSL handshake failed
on the new socket, the socket would linger indefinitely. Thanks to on the new socket, the socket would linger indefinitely. Thanks to
Peter Saveliev for reporting. Peter Saveliev for reporting.
...@@ -3296,7 +3302,6 @@ Extension Modules ...@@ -3296,7 +3302,6 @@ Extension Modules
- Issue #7567: Don't call `setupterm' twice. - Issue #7567: Don't call `setupterm' twice.
Tools/Demos Tools/Demos
----------- -----------
...@@ -4534,7 +4539,6 @@ Core and Builtins ...@@ -4534,7 +4539,6 @@ Core and Builtins
- Issue #7466: Segmentation fault when the garbage collector is called in the - Issue #7466: Segmentation fault when the garbage collector is called in the
middle of populating a tuple. Patch by Florent Xicluna. middle of populating a tuple. Patch by Florent Xicluna.
Library Library
------- -------
...@@ -7008,7 +7012,6 @@ Build ...@@ -7008,7 +7012,6 @@ Build
- Issue #3215: Build sqlite3 as sqlite3.dll, not sqlite3.pyd. - Issue #3215: Build sqlite3 as sqlite3.dll, not sqlite3.pyd.
Documentation Documentation
------------- -------------
...@@ -7074,7 +7077,6 @@ Core and Builtins ...@@ -7074,7 +7077,6 @@ Core and Builtins
only available if asserts are left in the code, in cases where they only available if asserts are left in the code, in cases where they
can't be triggered from Python code. can't be triggered from Python code.
Extension Modules Extension Modules
----------------- -----------------
- Issue #1179: [CVE-2007-4965] Integer overflow in imageop module. - Issue #1179: [CVE-2007-4965] Integer overflow in imageop module.
...@@ -7382,7 +7384,6 @@ Build ...@@ -7382,7 +7384,6 @@ Build
NOTE: 64-bit and 4-way builds are only suppported on Mac OS X 10.5 (or later). NOTE: 64-bit and 4-way builds are only suppported on Mac OS X 10.5 (or later).
C API C API
----- -----
...@@ -8258,7 +8259,6 @@ Core and builtins ...@@ -8258,7 +8259,6 @@ Core and builtins
threading.enumerate() list after the join() for a brief period until threading.enumerate() list after the join() for a brief period until
it actually exited. it actually exited.
Library Library
------- -------
...@@ -9351,7 +9351,6 @@ Tools ...@@ -9351,7 +9351,6 @@ Tools
platform.python_implementation(); this will now be saved in the platform.python_implementation(); this will now be saved in the
benchmark pickle. benchmark pickle.
Documentation Documentation
------------- -------------
...@@ -9402,7 +9401,6 @@ Documentation ...@@ -9402,7 +9401,6 @@ Documentation
applied to a newly created list object and add notes that this isn't applied to a newly created list object and add notes that this isn't
a good idea. a good idea.
Tools/Demos Tools/Demos
----------- -----------
...@@ -9415,7 +9413,6 @@ Tools/Demos ...@@ -9415,7 +9413,6 @@ Tools/Demos
- Bug #1546372: Fixed small bugglet in pybench that caused a missing - Bug #1546372: Fixed small bugglet in pybench that caused a missing
file not to get reported properly. file not to get reported properly.
Build Build
----- -----
...@@ -9498,7 +9495,6 @@ Build ...@@ -9498,7 +9495,6 @@ Build
pybuildbot.identify to include some information about the build pybuildbot.identify to include some information about the build
environment. environment.
C API C API
----- -----
...@@ -9561,7 +9557,6 @@ C API ...@@ -9561,7 +9557,6 @@ C API
- Bug #1542693: remove semi-colon at end of PyImport_ImportModuleEx - Bug #1542693: remove semi-colon at end of PyImport_ImportModuleEx
macro so it can be used as an expression. macro so it can be used as an expression.
Windows Windows
------- -------
...@@ -9575,7 +9570,6 @@ Windows ...@@ -9575,7 +9570,6 @@ Windows
- Bug #1216: Restore support for Visual Studio 2002. - Bug #1216: Restore support for Visual Studio 2002.
Mac Mac
--- ---
......
...@@ -1671,6 +1671,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, ...@@ -1671,6 +1671,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
(base64buffer >> (base64bits-16)); (base64buffer >> (base64bits-16));
base64bits -= 16; base64bits -= 16;
base64buffer &= (1 << base64bits) - 1; /* clear high bits */ base64buffer &= (1 << base64bits) - 1; /* clear high bits */
assert(outCh <= 0xffff);
if (surrogate) { if (surrogate) {
/* expecting a second surrogate */ /* expecting a second surrogate */
if (outCh >= 0xDC00 && outCh <= 0xDFFF) { if (outCh >= 0xDC00 && outCh <= 0xDFFF) {
...@@ -1737,6 +1738,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s, ...@@ -1737,6 +1738,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
inShift = 1; inShift = 1;
shiftOutStart = p; shiftOutStart = p;
base64bits = 0; base64bits = 0;
base64buffer = 0;
} }
} }
else if (DECODE_DIRECT(ch)) { /* character decodes as itself */ else if (DECODE_DIRECT(ch)) { /* character decodes as itself */
......
...@@ -1389,6 +1389,8 @@ class PyBuildExt(build_ext): ...@@ -1389,6 +1389,8 @@ class PyBuildExt(build_ext):
zlib_h = zlib_inc[0] + '/zlib.h' zlib_h = zlib_inc[0] + '/zlib.h'
version = '"0.0.0"' version = '"0.0.0"'
version_req = '"1.1.3"' version_req = '"1.1.3"'
if host_platform == 'darwin' and is_macosx_sdk_path(zlib_h):
zlib_h = os.path.join(macosx_sdk_root(), zlib_h[1:])
fp = open(zlib_h) fp = open(zlib_h)
while 1: while 1:
line = fp.readline() line = fp.readline()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment