Skip to content

Commit a786b02

Browse files
committed
Merged revisions 65910,65977,65980,65984,65986,66000,66011-66012,66014,66017,66020 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r65910 | benjamin.peterson | 2008-08-20 09:07:59 -0500 (Wed, 20 Aug 2008) | 1 line fix up the multiprocessing docs a little ........ r65977 | christian.heimes | 2008-08-22 14:47:25 -0500 (Fri, 22 Aug 2008) | 3 lines Silenced compiler warning Objects/stringlib/find.h:97: warning: 'stringlib_contains_obj' defined but not used Reviewed by Benjamin Peterson ........ r65980 | christian.heimes | 2008-08-22 15:10:27 -0500 (Fri, 22 Aug 2008) | 3 lines Fixed two format strings in the _collections module. For example Modules/_collectionsmodule.c:674: warning: format '%i' expects type 'int', but argument 2 has type 'Py_ssize_t' Reviewed by Benjamin Peterson ........ r65984 | christian.heimes | 2008-08-22 16:23:47 -0500 (Fri, 22 Aug 2008) | 1 line d is the correct format string ........ r65986 | mark.hammond | 2008-08-22 19:59:14 -0500 (Fri, 22 Aug 2008) | 2 lines Fix bug 3625: test issues on 64bit windows. r=pitrou ........ r66000 | benjamin.peterson | 2008-08-23 15:27:43 -0500 (Sat, 23 Aug 2008) | 5 lines #3643 add a few more checks to _testcapi to prevent segfaults Author: Victor Stinner Reviewer: Benjamin Peterson ........ r66011 | neal.norwitz | 2008-08-24 12:27:43 -0500 (Sun, 24 Aug 2008) | 1 line Ignore a couple more tests that report leaks inconsistently. ........ r66012 | neal.norwitz | 2008-08-24 12:29:53 -0500 (Sun, 24 Aug 2008) | 1 line Use the actual blacklist of leaky tests ........ r66014 | georg.brandl | 2008-08-24 13:11:07 -0500 (Sun, 24 Aug 2008) | 2 lines #3654: fix duplicate test method name. Review by Benjamin P. ........ r66017 | benjamin.peterson | 2008-08-24 16:55:03 -0500 (Sun, 24 Aug 2008) | 1 line remove note about unimplemented feature ........ r66020 | brett.cannon | 2008-08-24 18:15:19 -0500 (Sun, 24 Aug 2008) | 1 line Clarify that some attributes/methods are listed somewhat separately because they are not part of the threading API. ........
1 parent 2532967 commit a786b02

File tree

9 files changed

+66
-52
lines changed

9 files changed

+66
-52
lines changed

Doc/bugs.rst

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ Python is a mature programming language which has established a reputation for
88
stability. In order to maintain this reputation, the developers would like to
99
know of any deficiencies you find in Python.
1010

11-
If you find errors in the documentation, please use either the "Add a comment"
12-
or the "Suggest a change" features of the relevant page in the most recent
13-
online documentation at http://docs.python.org/.
14-
15-
All other bug reports should be submitted via the Python Bug Tracker
11+
Bug reports should be submitted via the Python Bug Tracker
1612
(http://bugs.python.org/). The bug tracker offers a Web form which allows
1713
pertinent information to be entered and submitted to the developers.
1814

Doc/library/multiprocessing.rst

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ The :mod:`multiprocessing` package mostly replicates the API of the
248248

249249
The constructor should always be called with keyword arguments. *group*
250250
should always be ``None``; it exists solely for compatibility with
251-
:class:`~threading.Thread`. *target* is the callable object to be invoked by
251+
:class:`threading.Thread`. *target* is the callable object to be invoked by
252252
the :meth:`run()` method. It defaults to ``None``, meaning nothing is
253253
called. *name* is the process name. By default, a unique name is constructed
254254
of the form 'Process-N\ :sub:`1`:N\ :sub:`2`:...:N\ :sub:`k`' where N\
@@ -290,13 +290,9 @@ The :mod:`multiprocessing` package mostly replicates the API of the
290290
A process cannot join itself because this would cause a deadlock. It is
291291
an error to attempt to join a process before it has been started.
292292

293-
.. attribute:: Process.name
293+
.. attribute:: name
294294

295-
Return the process's name.
296-
297-
.. attribute:: Process.name = name
298-
299-
Set the process's name.
295+
The process's name.
300296

301297
The name is a string used for identification purposes only. It has no
302298
semantics. Multiple processes may be given the same name. The initial
@@ -309,14 +305,10 @@ The :mod:`multiprocessing` package mostly replicates the API of the
309305
Roughly, a process object is alive from the moment the :meth:`start`
310306
method returns until the child process terminates.
311307

312-
.. attribute:: Process.daemon
313-
314-
Return the process's daemon flag., this is a boolean.
308+
.. attribute:: daemon
315309

316-
.. attribute:: Process.daemon = daemonic
317-
318-
Set the process's daemon flag to the Boolean value *daemonic*. This must
319-
be called before :meth:`start` is called.
310+
The process's daemon flag, a Boolean value. This must be called before
311+
:meth:`start` is called.
320312

321313
The initial value is inherited from the creating process.
322314

@@ -327,36 +319,33 @@ The :mod:`multiprocessing` package mostly replicates the API of the
327319
Otherwise a daemonic process would leave its children orphaned if it gets
328320
terminated when its parent process exits.
329321

330-
In addition process objects also support the following methods:
322+
In addition to the :class:`Threading.Thread` API, :class:`Process` objects
323+
also support the following attributes and methods:
331324

332-
.. attribute:: Process.pid
325+
.. attribute:: pid
333326

334327
Return the process ID. Before the process is spawned, this will be
335328
``None``.
336329

337-
.. attribute:: Process.exitcode
330+
.. attribute:: exitcode
338331

339-
Return the child's exit code. This will be ``None`` if the process has
340-
not yet terminated. A negative value *-N* indicates that the child was
341-
terminated by signal *N*.
332+
The child's exit code. This will be ``None`` if the process has not yet
333+
terminated. A negative value *-N* indicates that the child was terminated
334+
by signal *N*.
342335

343-
.. attribute:: Process.authkey
336+
.. attribute:: authkey
344337

345-
Return the process's authentication key (a byte string).
338+
The process's authentication key (a byte string).
346339

347340
When :mod:`multiprocessing` is initialized the main process is assigned a
348341
random string using :func:`os.random`.
349342

350343
When a :class:`Process` object is created, it will inherit the
351-
authentication key of its parent process, although this may be changed
352-
using :attr:`Process.authkey` below.
344+
authentication key of its parent process, although this may be changed by
345+
setting :attr:`authkey` to another byte string.
353346

354347
See :ref:`multiprocessing-auth-keys`.
355348

356-
.. attribute:: Process.authkey = authkey
357-
358-
Set the process's authentication key which must be a byte string.
359-
360349
.. method:: terminate()
361350

362351
Terminate the process. On Unix this is done using the ``SIGTERM`` signal;
@@ -375,8 +364,8 @@ The :mod:`multiprocessing` package mostly replicates the API of the
375364
cause other processes to deadlock.
376365

377366
Note that the :meth:`start`, :meth:`join`, :meth:`is_alive` and
378-
:meth:`get_exit_code` methods should only be called by the process that
379-
created the process object.
367+
:attr:`exit_code` methods should only be called by the process that created
368+
the process object.
380369

381370
Example usage of some of the methods of :class:`Process`::
382371

@@ -390,7 +379,7 @@ The :mod:`multiprocessing` package mostly replicates the API of the
390379
>>> p.terminate()
391380
>>> print p, p.is_alive()
392381
<Process(Process-1, stopped[SIGTERM])> False
393-
>>> p.get_exit_code() == -signal.SIGTERM
382+
>>> p.exitcode == -signal.SIGTERM
394383
True
395384

396385

@@ -1075,7 +1064,7 @@ their parent process exits. The manager classes are defined in the
10751064

10761065
*authkey* is the authentication key which will be used to check the validity
10771066
of incoming connections to the server process. If *authkey* is ``None`` then
1078-
``current_process().get_auth_key()``. Otherwise *authkey* is used and it
1067+
``current_process().authkey``. Otherwise *authkey* is used and it
10791068
must be a string.
10801069

10811070
.. method:: start()
@@ -1599,7 +1588,7 @@ authentication* using the :mod:`hmac` module.
15991588

16001589
If *authentication* is ``True`` or *authkey* is a string then digest
16011590
authentication is used. The key used for authentication will be either
1602-
*authkey* or ``current_process().get_auth_key()`` if *authkey* is ``None``.
1591+
*authkey* or ``current_process().authkey)`` if *authkey* is ``None``.
16031592
If authentication fails then :exc:`AuthenticationError` is raised. See
16041593
:ref:`multiprocessing-auth-keys`.
16051594

@@ -1632,7 +1621,7 @@ authentication* using the :mod:`hmac` module.
16321621
otherwise it must be *None*.
16331622

16341623
If *authkey* is ``None`` and *authenticate* is ``True`` then
1635-
``current_process().get_auth_key()`` is used as the authentication key. If
1624+
``current_process().authkey`` is used as the authentication key. If
16361625
*authkey* is ``None`` and *authentication* is ``False`` then no
16371626
authentication is done. If authentication fails then
16381627
:exc:`AuthenticationError` is raised. See :ref:`multiprocessing-auth-keys`.
@@ -1748,7 +1737,7 @@ authentication key. (Demonstrating that both ends are using the same key does
17481737
**not** involve sending the key over the connection.)
17491738

17501739
If authentication is requested but do authentication key is specified then the
1751-
return value of ``current_process().get_auth_key`` is used (see
1740+
return value of ``current_process().authkey`` is used (see
17521741
:class:`~multiprocessing.Process`). This value will automatically inherited by
17531742
any :class:`~multiprocessing.Process` object that the current process creates.
17541743
This means that (by default) all processes of a multi-process program will share

Lib/test/test_list.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ def test_basic(self):
1515
self.assertEqual(list(''), [])
1616
self.assertEqual(list('spam'), ['s', 'p', 'a', 'm'])
1717

18+
if sys.maxsize == 0x7fffffff:
19+
# This test can currently only work on 32-bit machines.
20+
# XXX If/when PySequence_Length() returns a ssize_t, it should be
21+
# XXX re-enabled.
22+
# Verify clearing of bug #556025.
23+
# This assumes that the max data size (sys.maxint) == max
24+
# address size this also assumes that the address size is at
25+
# least 4 bytes with 8 byte addresses, the bug is not well
26+
# tested
27+
#
28+
# Note: This test is expected to SEGV under Cygwin 1.3.12 or
29+
# earlier due to a newlib bug. See the following mailing list
30+
# thread for the details:
31+
32+
# http://sources.redhat.com/ml/newlib/2002/msg00369.html
33+
self.assertRaises(MemoryError, list, range(sys.maxsize // 2))
34+
1835
# This code used to segfault in Py2.4a3
1936
x = []
2037
x.extend(-y for y in x)

Lib/test/test_re.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ def test_special_escapes(self):
352352
self.assertEqual(re.search(r"\d\D\w\W\s\S",
353353
"1aa! a", re.UNICODE).group(0), "1aa! a")
354354

355-
def test_ignore_case(self):
356-
self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
357-
self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
358-
359355
def test_bigcharset(self):
360356
self.assertEqual(re.match("([\u2222\u2223])",
361357
"\u2222").group(1), "\u2222")
@@ -383,6 +379,8 @@ def test_non_consuming(self):
383379
self.assertEqual(re.match(r"(a)(?!\s(abc|a))", "a b").group(1), "a")
384380

385381
def test_ignore_case(self):
382+
self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
383+
self.assertEqual(re.match("abc", "ABC", re.I).group(0), "ABC")
386384
self.assertEqual(re.match(r"(a\s[^a])", "a b", re.I).group(1), "a b")
387385
self.assertEqual(re.match(r"(a\s[^a]*)", "a bb", re.I).group(1), "a bb")
388386
self.assertEqual(re.match(r"(a\s[abc])", "a b", re.I).group(1), "a b")

Misc/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ REFLOG="build/reflog.txt.out"
6767
# Note: test_XXX (none currently) really leak, but are disabled
6868
# so we don't send spam. Any test which really leaks should only
6969
# be listed here if there are also test cases under Lib/test/leakers.
70-
LEAKY_TESTS="test_(asynchat|cmd_line|popen2|socket|smtplib|sys|threadsignals|urllib2_localnet|httpservers)"
70+
LEAKY_TESTS="test_(asynchat|cmd_line|docxmlrpc|dumbdbm|file|ftplib|httpservers|imaplib|popen2|socket|smtplib|sys|telnetlib|threadedtempfile|threading|threadsignals|urllib2_localnet|xmlrpc)"
7171

7272
# These tests always fail, so skip them so we don't get false positives.
7373
_ALWAYS_SKIP=""

Modules/_collectionsmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,9 @@ deque_repr(PyObject *deque)
670670
return NULL;
671671
}
672672
if (((dequeobject *)deque)->maxlen != -1)
673-
result = PyUnicode_FromFormat("deque(%R, maxlen=%i)", aslist,
674-
((dequeobject *)deque)->maxlen);
673+
674+
result = PyUnicode_FromFormat("deque(%R, maxlen=%" PY_FORMAT_SIZE_T "d)",
675+
aslist, ((dequeobject *)deque)->maxlen);
675676
else
676677
result = PyUnicode_FromFormat("deque(%R)", aslist);
677678
Py_DECREF(aslist);

Modules/_testcapimodule.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -714,14 +714,17 @@ raise_exception(PyObject *self, PyObject *args)
714714
*/
715715
static PyThread_type_lock thread_done = NULL;
716716

717-
static void
717+
static int
718718
_make_call(void *callable)
719719
{
720720
PyObject *rc;
721+
int success;
721722
PyGILState_STATE s = PyGILState_Ensure();
722723
rc = PyObject_CallFunction((PyObject *)callable, "");
724+
success = (rc != NULL);
723725
Py_XDECREF(rc);
724726
PyGILState_Release(s);
727+
return success;
725728
}
726729

727730
/* Same thing, but releases `thread_done` when it returns. This variant
@@ -738,10 +741,17 @@ static PyObject *
738741
test_thread_state(PyObject *self, PyObject *args)
739742
{
740743
PyObject *fn;
744+
int success = 1;
741745

742746
if (!PyArg_ParseTuple(args, "O:test_thread_state", &fn))
743747
return NULL;
744748

749+
if (!PyCallable_Check(fn)) {
750+
PyErr_Format(PyExc_TypeError, "'%s' object is not callable",
751+
fn->ob_type->tp_name);
752+
return NULL;
753+
}
754+
745755
/* Ensure Python is set up for threading */
746756
PyEval_InitThreads();
747757
thread_done = PyThread_allocate_lock();
@@ -752,10 +762,10 @@ test_thread_state(PyObject *self, PyObject *args)
752762
/* Start a new thread with our callback. */
753763
PyThread_start_new_thread(_make_call_from_thread, fn);
754764
/* Make the callback with the thread lock held by this thread */
755-
_make_call(fn);
765+
success &= _make_call(fn);
756766
/* Do it all again, but this time with the thread-lock released */
757767
Py_BEGIN_ALLOW_THREADS
758-
_make_call(fn);
768+
success &= _make_call(fn);
759769
PyThread_acquire_lock(thread_done, 1); /* wait for thread to finish */
760770
Py_END_ALLOW_THREADS
761771

@@ -765,14 +775,16 @@ test_thread_state(PyObject *self, PyObject *args)
765775
*/
766776
Py_BEGIN_ALLOW_THREADS
767777
PyThread_start_new_thread(_make_call_from_thread, fn);
768-
_make_call(fn);
778+
success &= _make_call(fn);
769779
PyThread_acquire_lock(thread_done, 1); /* wait for thread to finish */
770780
Py_END_ALLOW_THREADS
771781

772782
/* Release lock we acquired above. This is required on HP-UX. */
773783
PyThread_release_lock(thread_done);
774784

775785
PyThread_free_lock(thread_done);
786+
if (!success)
787+
return NULL;
776788
Py_RETURN_NONE;
777789
}
778790
#endif

Objects/bytearrayobject.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ bytes_dealloc(PyByteArrayObject *self)
10261026
#define STRINGLIB_EMPTY nullbytes
10271027
#define STRINGLIB_CHECK_EXACT PyByteArray_CheckExact
10281028
#define STRINGLIB_MUTABLE 1
1029+
#define FROM_BYTEARRAY 1
10291030

10301031
#include "stringlib/fastsearch.h"
10311032
#include "stringlib/count.h"

Objects/stringlib/find.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ stringlib_rfind_slice(const STRINGLIB_CHAR* str, Py_ssize_t str_len,
9090
return stringlib_rfind(str + start, end - start, sub, sub_len, start);
9191
}
9292

93-
#ifdef STRINGLIB_WANT_CONTAINS_OBJ
93+
#ifdef STRINGLIB_WANT_CONTAINS_OBJ && !defined(FROM_BYTEARRAY)
9494

9595
Py_LOCAL_INLINE(int)
9696
stringlib_contains_obj(PyObject* str, PyObject* sub)

0 commit comments

Comments
 (0)