Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cc47b05

Browse files
committed
Merged revisions 61834,61841-61842,61851-61853,61863-61864,61869-61870,61874,61889 via svnmerge from
svn+ssh://[email protected]/python/trunk ........ r61834 | raymond.hettinger | 2008-03-24 07:07:49 +0100 (Mon, 24 Mar 2008) | 1 line Tighten documentation for Random.triangular. ........ r61841 | raymond.hettinger | 2008-03-24 09:17:39 +0100 (Mon, 24 Mar 2008) | 1 line Issue 2460: Make Ellipsis objects copyable. ........ r61842 | georg.brandl | 2008-03-24 10:34:34 +0100 (Mon, 24 Mar 2008) | 2 lines #1700821: add a note to audioop docs about signedness of sample formats. ........ r61851 | christian.heimes | 2008-03-24 20:57:42 +0100 (Mon, 24 Mar 2008) | 1 line Added quick hack for bzr ........ r61852 | christian.heimes | 2008-03-24 20:58:17 +0100 (Mon, 24 Mar 2008) | 1 line Added quick hack for bzr ........ r61853 | amaury.forgeotdarc | 2008-03-24 22:04:10 +0100 (Mon, 24 Mar 2008) | 4 lines Issue2469: Correct a typo I introduced at r61793: compilation error with UCS4 builds. All buildbots compile with UCS2... ........ r61863 | neal.norwitz | 2008-03-25 05:17:38 +0100 (Tue, 25 Mar 2008) | 2 lines Fix a bunch of UnboundLocalErrors when the tests fail. ........ r61864 | neal.norwitz | 2008-03-25 05:18:18 +0100 (Tue, 25 Mar 2008) | 2 lines Try to fix a bunch of compiler warnings on Win64. ........ r61869 | neal.norwitz | 2008-03-25 07:35:10 +0100 (Tue, 25 Mar 2008) | 3 lines Don't try to close a non-open file. Don't let file removal cause the test to fail. ........ r61870 | neal.norwitz | 2008-03-25 08:00:39 +0100 (Tue, 25 Mar 2008) | 7 lines Try to get this test to be more stable: * disable gc during the test run because we are spawning objects and there was an exception when calling Popen.__del__ * Always set an alarm handler so the process doesn't exit if the test fails (should probably add assertions on the value of hndl_called in more places) * Using a negative time causes Linux to treat it as zero, so disable that test. ........ r61874 | gregory.p.smith | 2008-03-25 08:31:28 +0100 (Tue, 25 Mar 2008) | 2 lines Use a 32-bit unsigned int here, a long is not needed. ........ r61889 | georg.brandl | 2008-03-25 12:59:51 +0100 (Tue, 25 Mar 2008) | 2 lines Move declarations to block start. ........
1 parent afbc266 commit cc47b05

12 files changed

Lines changed: 74 additions & 27 deletions

File tree

Doc/library/audioop.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ The module defines the following variables and functions:
136136

137137
Convert samples between 1-, 2- and 4-byte formats.
138138

139+
.. note::
140+
141+
In some audio formats, such as .WAV files, 16 and 32 bit samples are
142+
signed, but 8 bit samples are unsigned. So when converting to 8 bit wide
143+
samples for these formats, you need to also add 128 to the result::
144+
145+
new_frames = audioop.lin2lin(frames, old_width, 1)
146+
new_frames = audioop.bias(new_frames, 1, 128)
147+
148+
The same, in reverse, has to be applied when converting from 8 to 16 or 32
149+
bit width samples.
150+
139151

140152
.. function:: lin2ulaw(fragment, width)
141153

Doc/library/random.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ be found in any statistics text.
155155

156156
.. function:: triangular(low, high, mode)
157157

158-
Return a random floating point number *N* such that ``low <= N < high``
159-
and with the specified *mode* between those bounds.
158+
Return a random floating point number *N* such that ``low <= N < high`` and
159+
with the specified *mode* between those bounds. The *low* and *high* bounds
160+
default to zero and one. The *mode* argument defaults to the midpoint
161+
between the bounds, giving a symmetric distribution.
160162

161-
If *mode* is not specified or is ``None``, it defaults to the midpoint
162-
between the upper and lower bounds, producing a symmetric distribution.
163+
.. versionadded:: 2.6
163164

164-
The default values for *low* and *high* are zero and one.
165165

166166
.. function:: betavariate(alpha, beta)
167167

Lib/copy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def _copy_immutable(x):
101101
return x
102102
for t in (type(None), int, float, bool, str, tuple,
103103
frozenset, type, range,
104-
types.BuiltinFunctionType,
104+
types.BuiltinFunctionType, type(Ellipsis),
105105
types.FunctionType):
106106
d[t] = _copy_immutable
107107
t = getattr(types, "CodeType", None)
@@ -180,6 +180,7 @@ def deepcopy(x, memo=None, _nil=[]):
180180
def _deepcopy_atomic(x, memo):
181181
return x
182182
d[type(None)] = _deepcopy_atomic
183+
d[type(Ellipsis)] = _deepcopy_atomic
183184
d[int] = _deepcopy_atomic
184185
d[float] = _deepcopy_atomic
185186
d[bool] = _deepcopy_atomic

Lib/test/test_deque.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,27 @@ def test_maxlen(self):
6464
self.assertEqual(list(d), [7, 8, 9])
6565
d = deque(range(200), maxlen=10)
6666
d.append(d)
67+
fo = open(test_support.TESTFN, "w")
68+
try:
69+
fo.write(str(d))
70+
fo.close()
71+
fo = open(test_support.TESTFN, "r")
72+
self.assertEqual(fo.read(), repr(d))
73+
finally:
74+
fo.close()
75+
test_support.unlink(test_support.TESTFN)
76+
6777
d = deque(range(10), maxlen=None)
6878
self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])')
79+
fo = open(test_support.TESTFN, "w")
80+
try:
81+
fo.write(str(d))
82+
fo.close()
83+
fo = open(test_support.TESTFN, "r")
84+
self.assertEqual(fo.read(), repr(d))
85+
finally:
86+
fo.close()
87+
test_support.unlink(test_support.TESTFN)
6988

7089
def test_comparisons(self):
7190
d = deque('xabc'); d.popleft()
@@ -265,13 +284,13 @@ def test_print(self):
265284
d.append(d)
266285
try:
267286
fo = open(test_support.TESTFN, "w")
268-
fo.write(str(d))
287+
print(d, file=fo, end='')
269288
fo.close()
270289
fo = open(test_support.TESTFN, "r")
271290
self.assertEqual(fo.read(), repr(d))
272291
finally:
273292
fo.close()
274-
os.remove(test_support.TESTFN)
293+
test_support.unlink(test_support.TESTFN)
275294

276295
def test_init(self):
277296
self.assertRaises(TypeError, deque, 'abc', 2, 3);

Lib/test/test_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def test_cyclical_print(self):
295295
self.assertEqual(fo.read(), repr(s))
296296
finally:
297297
fo.close()
298-
os.remove(test_support.TESTFN)
298+
test_support.unlink(test_support.TESTFN)
299299

300300
def test_do_not_rehash_dict_keys(self):
301301
n = 10
@@ -679,7 +679,7 @@ def test_print(self):
679679
self.assertEqual(fo.read(), repr(self.set))
680680
finally:
681681
fo.close()
682-
os.remove(test_support.TESTFN)
682+
test_support.unlink(test_support.TESTFN)
683683

684684
def test_length(self):
685685
self.assertEqual(len(self.set), self.length)

Lib/test/test_signal.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import unittest
22
from test import test_support
33
from contextlib import closing, nested
4+
import gc
45
import pickle
56
import select
67
import signal
@@ -30,6 +31,14 @@ def exit_subprocess():
3031
class InterProcessSignalTests(unittest.TestCase):
3132
MAX_DURATION = 20 # Entire test should last at most 20 sec.
3233

34+
def setUp(self):
35+
self.using_gc = gc.isenabled()
36+
gc.disable()
37+
38+
def tearDown(self):
39+
if self.using_gc:
40+
gc.enable()
41+
3342
def handlerA(self, *args):
3443
self.a_called = True
3544
if test_support.verbose:
@@ -263,8 +272,10 @@ def setUp(self):
263272
self.hndl_called = False
264273
self.hndl_count = 0
265274
self.itimer = None
275+
self.old_alarm = signal.signal(signal.SIGALRM, self.sig_alrm)
266276

267277
def tearDown(self):
278+
signal.signal(signal.SIGALRM, self.old_alarm)
268279
if self.itimer is not None: # test_itimer_exc doesn't change this attr
269280
# just ensure that itimer is stopped
270281
signal.setitimer(self.itimer, 0)
@@ -303,13 +314,13 @@ def test_itimer_exc(self):
303314
# XXX I'm assuming -1 is an invalid itimer, but maybe some platform
304315
# defines it ?
305316
self.assertRaises(signal.ItimerError, signal.setitimer, -1, 0)
306-
# negative time
307-
self.assertRaises(signal.ItimerError, signal.setitimer,
308-
signal.ITIMER_REAL, -1)
317+
# Negative times are treated as zero on some platforms.
318+
if 0:
319+
self.assertRaises(signal.ItimerError,
320+
signal.setitimer, signal.ITIMER_REAL, -1)
309321

310322
def test_itimer_real(self):
311323
self.itimer = signal.ITIMER_REAL
312-
signal.signal(signal.SIGALRM, self.sig_alrm)
313324
signal.setitimer(self.itimer, 1.0)
314325
if test_support.verbose:
315326
print("\ncall pause()...")

Modules/binascii.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,13 +784,15 @@ PyDoc_STRVAR(doc_crc32,
784784
static PyObject *
785785
binascii_crc32(PyObject *self, PyObject *args)
786786
{
787-
uLong crc32val = 0; /* crc32(0L, Z_NULL, 0) */
787+
unsigned int crc32val = 0; /* crc32(0L, Z_NULL, 0) */
788788
Byte *buf;
789789
Py_ssize_t len;
790+
int signed_val;
791+
790792
if (!PyArg_ParseTuple(args, "s#|I:crc32", &buf, &len, &crc32val))
791793
return NULL;
792-
crc32val = crc32(crc32val, buf, len);
793-
return PyLong_FromUnsignedLong(crc32val & 0xffffffffU);
794+
signed_val = crc32(crc32val, buf, len);
795+
return PyLong_FromUnsignedLong(signed_val & 0xffffffffU);
794796
}
795797
#else /* USE_ZLIB_CRC32 */
796798
/* Crc - 32 BIT ANSI X3.66 CRC checksum files

Modules/zlibmodule.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ PyDoc_STRVAR(adler32__doc__,
915915
static PyObject *
916916
PyZlib_adler32(PyObject *self, PyObject *args)
917917
{
918-
uLong adler32val = 1; /* adler32(0L, Z_NULL, 0) */
918+
unsigned int adler32val = 1; /* adler32(0L, Z_NULL, 0) */
919919
Byte *buf;
920920
int len;
921921

@@ -934,13 +934,14 @@ PyDoc_STRVAR(crc32__doc__,
934934
static PyObject *
935935
PyZlib_crc32(PyObject *self, PyObject *args)
936936
{
937-
uLong crc32val = 0; /* crc32(0L, Z_NULL, 0) */
937+
unsigned int crc32val = 0; /* crc32(0L, Z_NULL, 0) */
938938
Byte *buf;
939-
int len;
939+
int len, signed_val;
940+
940941
if (!PyArg_ParseTuple(args, "s#|I:crc32", &buf, &len, &crc32val))
941942
return NULL;
942-
crc32val = crc32(crc32val, buf, len);
943-
return PyLong_FromUnsignedLong(crc32val & 0xffffffffU);
943+
signed_val = crc32(crc32val, buf, len);
944+
return PyLong_FromUnsignedLong(signed_val & 0xffffffffU);
944945
}
945946

946947

Objects/unicodeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,7 @@ PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *s,
32043204
/* UCS-4 character. Either store directly, or as
32053205
surrogate pair. */
32063206
#ifdef Py_UNICODE_WIDE
3207-
*p++ = (Py_UNIC0DE) x;
3207+
*p++ = (Py_UNICODE) x;
32083208
#else
32093209
x -= 0x10000L;
32103210
*p++ = 0xD800 + (Py_UNICODE) (x >> 10);
@@ -7384,7 +7384,7 @@ unicode_repeat(PyUnicodeObject *str, Py_ssize_t len)
73847384
done = str->length;
73857385
}
73867386
while (done < nchars) {
7387-
int n = (done <= nchars-done) ? done : nchars-done;
7387+
Py_ssize_t n = (done <= nchars-done) ? done : nchars-done;
73887388
Py_UNICODE_COPY(p+done, p, n);
73897389
done += n;
73907390
}

PC/_winreg.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ countStrings(wchar_t *data, int len)
703703
static BOOL
704704
Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
705705
{
706+
Py_ssize_t i,j;
706707
switch (typ) {
707708
case REG_DWORD:
708709
if (value != Py_None && !PyLong_Check(value))

0 commit comments

Comments
 (0)