Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6698564e
Commit
6698564e
authored
Oct 19, 2013
by
Christian Heimes
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
cede1a50
f1056723
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
92 additions
and
22 deletions
+92
-22
Doc/howto/descriptor.rst
Doc/howto/descriptor.rst
+1
-1
Doc/library/aifc.rst
Doc/library/aifc.rst
+2
-2
Doc/library/zlib.rst
Doc/library/zlib.rst
+16
-1
Lib/logging/__init__.py
Lib/logging/__init__.py
+1
-1
Lib/test/test_codecs.py
Lib/test/test_codecs.py
+29
-0
Lib/test/test_logging.py
Lib/test/test_logging.py
+18
-0
Lib/test/test_wave.py
Lib/test/test_wave.py
+10
-3
Lib/wave.py
Lib/wave.py
+3
-1
Mac/BuildScript/build-installer.py
Mac/BuildScript/build-installer.py
+1
-0
Misc/NEWS
Misc/NEWS
+7
-13
Objects/unicodeobject.c
Objects/unicodeobject.c
+2
-0
setup.py
setup.py
+2
-0
No files found.
Doc/howto/descriptor.rst
View file @
6698564e
...
...
@@ -124,7 +124,7 @@ The important points to remember are:
The object returned by ``super()`` also has a custom :meth:`__getattribute__`
method for invoking descriptors. The call ``super(B, obj).m()`` searches
``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
search using :meth:`object.__getattribute__`.
...
...
Doc/library/aifc.rst
View file @
6698564e
...
...
@@ -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
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
*nchannels*\**samplesize* bytes, and a second's worth of audio consists of
*nchannels*\*
*samplesize*\*
*framerate* bytes.
*nchannels*\*
\
*samplesize* bytes, and a second's worth of audio consists of
*nchannels*\*
\ *samplesize*\*\
*framerate* bytes.
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
...
...
Doc/library/zlib.rst
View file @
6698564e
...
...
@@ -68,7 +68,7 @@ The available exception and functions in this module are:
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
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:
``9`` is slowest and produces the most. ``0`` is no compression. The default
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])
...
...
Lib/logging/__init__.py
View file @
6698564e
...
...
@@ -857,7 +857,7 @@ class StreamHandler(Handler):
try
:
if
(
isinstance
(
msg
,
unicode
)
and
getattr
(
stream
,
'encoding'
,
None
)):
ufs
=
fs
.
decode
(
stream
.
encoding
)
ufs
=
u'%s
\
n
'
try
:
stream
.
write
(
ufs
%
msg
)
except
UnicodeEncodeError
:
...
...
Lib/test/test_codecs.py
View file @
6698564e
...
...
@@ -611,6 +611,35 @@ class UTF7Test(ReadTest):
]
)
def
test_errors
(
self
):
tests
=
[
(
'a
\
xff
b'
,
u'a
\
ufffd
b'
),
(
'a+IK'
,
u'a
\
ufffd
'
),
(
'a+IK-b'
,
u'a
\
ufffd
b'
),
(
'a+IK,b'
,
u'a
\
ufffd
b'
),
(
'a+IKx'
,
u'a
\
u20ac
\
ufffd
'
),
(
'a+IKx-b'
,
u'a
\
u20ac
\
ufffd
b'
),
(
'a+IKwgr'
,
u'a
\
u20ac
\
ufffd
'
),
(
'a+IKwgr-b'
,
u'a
\
u20ac
\
ufffd
b'
),
(
'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
\
ufffd
b'
),
(
'a+/,+IKw-b'
,
u'a
\
ufffd
\
u20ac
b'
),
(
'a+//,+IKw-b'
,
u'a
\
ufffd
\
u20ac
b'
),
(
'a+///,+IKw-b'
,
u'a
\
uffff
\
ufffd
\
u20ac
b'
),
(
'a+////,+IKw-b'
,
u'a
\
uffff
\
ufffd
\
u20ac
b'
),
]
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
):
def
test_errors
(
self
):
...
...
Lib/test/test_logging.py
View file @
6698564e
...
...
@@ -1060,6 +1060,24 @@ class EncodingTest(BaseTest):
#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
')
def test_encoding_utf16_unicode(self):
# Issue #19267
log = logging.getLogger("
test
")
message = u'b
\
u0142
\
u0105
d'
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
\
x00
B
\
x01
\
x05
\
x01
d
\
x00
\
n
\
x00
')
class WarningsTest(BaseTest):
...
...
Lib/test/test_wave.py
View file @
6698564e
from
test.test_support
import
TESTFN
,
run_unittest
import
unittest
from
test
import
audiotests
import
sys
import
wave
...
...
@@ -44,9 +45,13 @@ class WavePCM16Test(audiotests.AudioWriteTests,
EEDF1755 82061666 7FFF1446 80001296 499C0EB2 52BA0DB9 EFB70F5C CE400FBC
\
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
,
audiotests
.
AudioTestsWithSourceFile
,
unittest
.
TestCase
):
...
...
@@ -73,7 +78,8 @@ class WavePCM24Test(audiotests.AudioWriteTests,
E4B49C0CEA2D 6344A80A5A7C 08C8FE0A1FFE 2BB9860B0A0E
\
51486F0E44E1 8BCC64113B05 B6F4EC0EEB36 4413170A5B48
\
"""
)
frames
=
audiotests
.
byteswap3
(
frames
)
if
sys
.
byteorder
!=
'big'
:
frames
=
audiotests
.
byteswap3
(
frames
)
class
WavePCM32Test
(
audiotests
.
AudioWriteTests
,
...
...
@@ -102,7 +108,8 @@ class WavePCM32Test(audiotests.AudioWriteTests,
E4B49CC00CEA2D90 6344A8800A5A7CA0 08C8FE800A1FFEE0 2BB986C00B0A0E00
\
51486F800E44E190 8BCC6480113B0580 B6F4EC000EEB3630 441317800A5B48A0
\
"""
)
frames
=
audiotests
.
byteswap4
(
frames
)
if
sys
.
byteorder
!=
'big'
:
frames
=
audiotests
.
byteswap4
(
frames
)
def
test_main
():
...
...
Lib/wave.py
View file @
6698564e
...
...
@@ -80,7 +80,7 @@ class Error(Exception):
WAVE_FORMAT_PCM
=
0x0001
_array_fmts
=
None
,
'b'
,
'h'
,
None
,
'
l
'
_array_fmts
=
None
,
'b'
,
'h'
,
None
,
'
i
'
# Determine endian-ness
import
struct
...
...
@@ -238,6 +238,7 @@ class Wave_read:
import
array
chunk
=
self
.
_data_chunk
data
=
array
.
array
(
_array_fmts
[
self
.
_sampwidth
])
assert
data
.
itemsize
==
self
.
_sampwidth
nitems
=
nframes
*
self
.
_nchannels
if
nitems
*
self
.
_sampwidth
>
chunk
.
chunksize
-
chunk
.
size_read
:
nitems
=
(
chunk
.
chunksize
-
chunk
.
size_read
)
/
self
.
_sampwidth
...
...
@@ -421,6 +422,7 @@ class Wave_write:
if
self
.
_sampwidth
>
1
and
big_endian
:
import
array
data
=
array
.
array
(
_array_fmts
[
self
.
_sampwidth
],
data
)
assert
data
.
itemsize
==
self
.
_sampwidth
data
.
byteswap
()
data
.
tofile
(
self
.
_file
)
self
.
_datawritten
=
self
.
_datawritten
+
len
(
data
)
*
self
.
_sampwidth
...
...
Mac/BuildScript/build-installer.py
View file @
6698564e
...
...
@@ -155,6 +155,7 @@ target_cc_map = {
'10.6'
:
(
'gcc-4.2'
,
'g++-4.2'
),
'10.7'
:
(
'clang'
,
'clang++'
),
'10.8'
:
(
'clang'
,
'clang++'
),
'10.9'
:
(
'clang'
,
'clang++'
),
}
CC
,
CXX
=
target_cc_map
[
DEPTARGET
]
...
...
Misc/NEWS
View file @
6698564e
...
...
@@ -9,6 +9,8 @@ What's New in Python 2.7.6?
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));
the results could be off from one another by a ulp or two.
...
...
@@ -35,6 +37,8 @@ Core and Builtins
Library
-------
- Issue #19276: Fixed the wave module on 64-bit big-endian platforms.
- Issue #18458: Prevent crashes with newer versions of libedit. Its readline
emulation has changed from 0-based indexing to 1-based like gnu readline.
Original patch by Ronald Oussoren.
...
...
@@ -228,7 +232,6 @@ Library
existing
directory
caused
mkstemp
and
related
APIs
to
fail
instead
of
retrying
.
Report
and
fix
by
Vlad
Shcherbina
.
Tools
/
Demos
-----------
...
...
@@ -370,6 +373,9 @@ Library
- 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
on the new socket, the socket would linger indefinitely. Thanks to
Peter Saveliev for reporting.
...
...
@@ -3296,7 +3302,6 @@ Extension Modules
- Issue #7567: Don'
t
call
`
setupterm
' twice.
Tools/Demos
-----------
...
...
@@ -4534,7 +4539,6 @@ Core and Builtins
-
Issue
#
7466
:
Segmentation
fault
when
the
garbage
collector
is
called
in
the
middle
of
populating
a
tuple
.
Patch
by
Florent
Xicluna
.
Library
-------
...
...
@@ -7008,7 +7012,6 @@ Build
- Issue #3215: Build sqlite3 as sqlite3.dll, not sqlite3.pyd.
Documentation
-------------
...
...
@@ -7074,7 +7077,6 @@ Core and Builtins
only
available
if
asserts
are
left
in
the
code
,
in
cases
where
they
can
't be triggered from Python code.
Extension Modules
-----------------
- Issue #1179: [CVE-2007-4965] Integer overflow in imageop module.
...
...
@@ -7382,7 +7384,6 @@ Build
NOTE
:
64
-
bit
and
4
-
way
builds
are
only
suppported
on
Mac
OS
X
10.5
(
or
later
).
C
API
-----
...
...
@@ -8258,7 +8259,6 @@ Core and builtins
threading.enumerate() list after the join() for a brief period until
it actually exited.
Library
-------
...
...
@@ -9351,7 +9351,6 @@ Tools
platform.python_implementation(); this will now be saved in the
benchmark pickle.
Documentation
-------------
...
...
@@ -9402,7 +9401,6 @@ Documentation
applied to a newly created list object and add notes that this isn't
a good idea.
Tools/Demos
-----------
...
...
@@ -9415,7 +9413,6 @@ Tools/Demos
- Bug #1546372: Fixed small bugglet in pybench that caused a missing
file not to get reported properly.
Build
-----
...
...
@@ -9498,7 +9495,6 @@ Build
pybuildbot.identify to include some information about the build
environment.
C API
-----
...
...
@@ -9561,7 +9557,6 @@ C API
- Bug #1542693: remove semi-colon at end of PyImport_ImportModuleEx
macro so it can be used as an expression.
Windows
-------
...
...
@@ -9575,7 +9570,6 @@ Windows
- Bug #1216: Restore support for Visual Studio 2002.
Mac
---
...
...
Objects/unicodeobject.c
View file @
6698564e
...
...
@@ -1671,6 +1671,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
(
base64buffer
>>
(
base64bits
-
16
));
base64bits
-=
16
;
base64buffer
&=
(
1
<<
base64bits
)
-
1
;
/* clear high bits */
assert
(
outCh
<=
0xffff
);
if
(
surrogate
)
{
/* expecting a second surrogate */
if
(
outCh
>=
0xDC00
&&
outCh
<=
0xDFFF
)
{
...
...
@@ -1737,6 +1738,7 @@ PyObject *PyUnicode_DecodeUTF7Stateful(const char *s,
inShift
=
1
;
shiftOutStart
=
p
;
base64bits
=
0
;
base64buffer
=
0
;
}
}
else
if
(
DECODE_DIRECT
(
ch
))
{
/* character decodes as itself */
...
...
setup.py
View file @
6698564e
...
...
@@ -1389,6 +1389,8 @@ class PyBuildExt(build_ext):
zlib_h
=
zlib_inc
[
0
]
+
'/zlib.h'
version
=
'"0.0.0"'
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
)
while
1
:
line
=
fp
.
readline
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment