Kaydet (Commit) e52e3786 authored tarafından Alexandre Vassalotti's avatar Alexandre Vassalotti

Merged revisions 73995,74002,74005,74007-74008,74011,74019-74023 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r73995 | vinay.sajip | 2009-07-13 07:21:05 -0400 (Mon, 13 Jul 2009) | 1 line

  Issue #6314: logging: Extra checks on the "level" argument in more places.
........
  r74002 | marc-andre.lemburg | 2009-07-13 16:23:49 -0400 (Mon, 13 Jul 2009) | 6 lines

  Use a new global DEV_NULL instead of hard-coding /dev/null into the system
  command helper functions.

  See #6479 for some motivation.
........
  r74005 | marc-andre.lemburg | 2009-07-13 17:28:33 -0400 (Mon, 13 Jul 2009) | 6 lines

  Use a different VER command output parser to address the localization
  issues mentioned in #3410.

  Prepare for Windows 7 (still commented out).
........
  r74007 | michael.foord | 2009-07-14 13:58:12 -0400 (Tue, 14 Jul 2009) | 1 line

  Move TestRunner initialisation into unittest.TestProgram.runTests. Fixes issue 6418.
........
  r74008 | benjamin.peterson | 2009-07-14 20:46:42 -0400 (Tue, 14 Jul 2009) | 1 line

  update year
........
  r74011 | ezio.melotti | 2009-07-15 13:07:04 -0400 (Wed, 15 Jul 2009) | 1 line

  methods' names pep8ification
........
  r74019 | amaury.forgeotdarc | 2009-07-15 17:29:27 -0400 (Wed, 15 Jul 2009) | 2 lines

  #6076 Add a title to the IDLE Preferences window.
........
  r74020 | georg.brandl | 2009-07-16 03:18:07 -0400 (Thu, 16 Jul 2009) | 1 line

  #5910: fix kqueue for calls with more than one event.
........
  r74021 | georg.brandl | 2009-07-16 03:33:04 -0400 (Thu, 16 Jul 2009) | 1 line

  #6486: start with built in functions rather than "built in objects".
........
  r74022 | georg.brandl | 2009-07-16 03:38:35 -0400 (Thu, 16 Jul 2009) | 1 line

  #6481: fix typo in os.system() replacement.
........
  r74023 | jesse.noller | 2009-07-16 10:23:04 -0400 (Thu, 16 Jul 2009) | 1 line

  Issue 6433: multiprocessing.pool.map hangs on empty list
........
üst cf7128cc
...@@ -4,7 +4,7 @@ Copyright ...@@ -4,7 +4,7 @@ Copyright
Python and this documentation is: Python and this documentation is:
Copyright © 2001-2008 Python Software Foundation. All rights reserved. Copyright © 2001-2009 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved. Copyright © 2000 BeOpen.com. All rights reserved.
......
...@@ -43,8 +43,9 @@ browse the table of contents (in front of the manual), or look for a specific ...@@ -43,8 +43,9 @@ browse the table of contents (in front of the manual), or look for a specific
function, module or term in the index (in the back). And finally, if you enjoy function, module or term in the index (in the back). And finally, if you enjoy
learning about random subjects, you choose a random page number (see module learning about random subjects, you choose a random page number (see module
:mod:`random`) and read a section or two. Regardless of the order in which you :mod:`random`) and read a section or two. Regardless of the order in which you
read the sections of this manual, it helps to start with chapter :ref:`builtin`, read the sections of this manual, it helps to start with chapter
as the remainder of the manual assumes familiarity with this material. :ref:`built-in-funcs`, as the remainder of the manual assumes familiarity with
this material.
Let the show begin! Let the show begin!
...@@ -420,7 +420,7 @@ Replacing :func:`os.system` ...@@ -420,7 +420,7 @@ Replacing :func:`os.system`
sts = os.system("mycmd" + " myarg") sts = os.system("mycmd" + " myarg")
==> ==>
p = Popen("mycmd" + " myarg", shell=True) p = Popen("mycmd" + " myarg", shell=True)
sts = os.waitpid(p.pid, 0) sts = os.waitpid(p.pid, 0)[1]
Notes: Notes:
......
...@@ -30,6 +30,7 @@ class ConfigDialog(Toplevel): ...@@ -30,6 +30,7 @@ class ConfigDialog(Toplevel):
self.wm_withdraw() self.wm_withdraw()
self.configure(borderwidth=5) self.configure(borderwidth=5)
self.title('IDLE Preferences')
self.geometry("+%d+%d" % (parent.winfo_rootx()+20, self.geometry("+%d+%d" % (parent.winfo_rootx()+20,
parent.winfo_rooty()+30)) parent.winfo_rooty()+30))
#Theme Elements. Each theme element key is its display name. #Theme Elements. Each theme element key is its display name.
......
...@@ -208,6 +208,8 @@ class Pool(object): ...@@ -208,6 +208,8 @@ class Pool(object):
chunksize, extra = divmod(len(iterable), len(self._pool) * 4) chunksize, extra = divmod(len(iterable), len(self._pool) * 4)
if extra: if extra:
chunksize += 1 chunksize += 1
if len(iterable) == 0:
chunksize = 0
task_batches = Pool._get_tasks(func, iterable, chunksize) task_batches = Pool._get_tasks(func, iterable, chunksize)
result = MapResult(self._cache, chunksize, len(iterable), callback) result = MapResult(self._cache, chunksize, len(iterable), callback)
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
# #
# <see CVS and SVN checkin messages for history> # <see CVS and SVN checkin messages for history>
# #
# 1.0.7 - added DEV_NULL
# 1.0.6 - added linux_distribution() # 1.0.6 - added linux_distribution()
# 1.0.5 - fixed Java support to allow running the module on Jython # 1.0.5 - fixed Java support to allow running the module on Jython
# 1.0.4 - added IronPython support # 1.0.4 - added IronPython support
...@@ -89,7 +90,7 @@ ...@@ -89,7 +90,7 @@
__copyright__ = """ __copyright__ = """
Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com Copyright (c) 1999-2000, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2008, eGenix.com Software GmbH; mailto:info@egenix.com Copyright (c) 2000-2009, eGenix.com Software GmbH; mailto:info@egenix.com
Permission to use, copy, modify, and distribute this software and its Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee or royalty is hereby granted, documentation for any purpose and without fee or royalty is hereby granted,
...@@ -108,10 +109,25 @@ __copyright__ = """ ...@@ -108,10 +109,25 @@ __copyright__ = """
""" """
__version__ = '1.0.6' __version__ = '1.0.7'
import sys, os, re import sys, os, re
### Globals & Constants
# Determine the platform's /dev/null device
try:
DEV_NULL = os.devnull
except AttributeError:
# os.devnull was added in Python 2.4, so emulate it for earlier
# Python versions
if sys.platform in ('dos','win32','win16','os2'):
# Use the old CP/M NUL as device name
DEV_NULL = 'NUL'
else:
# Standard Unix uses /dev/null
DEV_NULL = '/dev/null'
### Platform specific APIs ### Platform specific APIs
_libc_search = re.compile(r'(__libc_init)' _libc_search = re.compile(r'(__libc_init)'
...@@ -446,7 +462,16 @@ def _norm_version(version, build=''): ...@@ -446,7 +462,16 @@ def _norm_version(version, build=''):
_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) ' _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
'.*' '.*'
'Version ([\d.]+))', re.ASCII) '\[.* ([\d.]+)\])')
# Examples of VER command output:
#
# Windows 2000: Microsoft Windows 2000 [Version 5.00.2195]
# Windows XP: Microsoft Windows XP [Version 5.1.2600]
# Windows Vista: Microsoft Windows [Version 6.0.6002]
#
# Note that the "Version" string gets localized on different
# Windows versions.
def _syscmd_ver(system='', release='', version='', def _syscmd_ver(system='', release='', version='',
...@@ -578,6 +603,7 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -578,6 +603,7 @@ def win32_ver(release='',version='',csd='',ptype=''):
version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF) version = '%i.%i.%i' % (maj,min,buildno & 0xFFFF)
if csd[:13] == 'Service Pack ': if csd[:13] == 'Service Pack ':
csd = 'SP' + csd[13:] csd = 'SP' + csd[13:]
if plat == VER_PLATFORM_WIN32_WINDOWS: if plat == VER_PLATFORM_WIN32_WINDOWS:
regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion' regkey = 'SOFTWARE\\Microsoft\\Windows\\CurrentVersion'
# Try to guess the release name # Try to guess the release name
...@@ -592,6 +618,7 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -592,6 +618,7 @@ def win32_ver(release='',version='',csd='',ptype=''):
release = 'postMe' release = 'postMe'
elif maj == 5: elif maj == 5:
release = '2000' release = '2000'
elif plat == VER_PLATFORM_WIN32_NT: elif plat == VER_PLATFORM_WIN32_NT:
regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion' regkey = 'SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion'
if maj <= 4: if maj <= 4:
...@@ -620,8 +647,12 @@ def win32_ver(release='',version='',csd='',ptype=''): ...@@ -620,8 +647,12 @@ def win32_ver(release='',version='',csd='',ptype=''):
release = 'Vista' release = 'Vista'
else: else:
release = '2008Server' release = '2008Server'
#elif min == 1:
# # Windows 7 release candidate uses version 6.1.7100
# release = '7RC'
else: else:
release = 'post2008Server' release = 'post2008Server'
else: else:
if not release: if not release:
# E.g. Win3.1 with win32s # E.g. Win3.1 with win32s
...@@ -902,7 +933,7 @@ def _syscmd_uname(option,default=''): ...@@ -902,7 +933,7 @@ def _syscmd_uname(option,default=''):
# XXX Others too ? # XXX Others too ?
return default return default
try: try:
f = os.popen('uname %s 2> /dev/null' % option) f = os.popen('uname %s 2> %s' % (option, DEV_NULL))
except (AttributeError,os.error): except (AttributeError,os.error):
return default return default
output = f.read().strip() output = f.read().strip()
...@@ -927,7 +958,7 @@ def _syscmd_file(target,default=''): ...@@ -927,7 +958,7 @@ def _syscmd_file(target,default=''):
return default return default
target = _follow_symlinks(target) target = _follow_symlinks(target)
try: try:
f = os.popen('file "%s" 2> /dev/null' % target) f = os.popen('file "%s" 2> %s' % (target, DEV_NULL))
except (AttributeError,os.error): except (AttributeError,os.error):
return default return default
output = f.read().strip() output = f.read().strip()
......
...@@ -163,6 +163,22 @@ class TestKQueue(unittest.TestCase): ...@@ -163,6 +163,22 @@ class TestKQueue(unittest.TestCase):
server.close() server.close()
serverSocket.close() serverSocket.close()
def testPair(self):
kq = select.kqueue()
a, b = socket.socketpair()
a.send(b'foo')
event1 = select.kevent(a, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
event2 = select.kevent(b, select.KQ_FILTER_READ, select.KQ_EV_ADD | select.KQ_EV_ENABLE)
r = kq.control([event1, event2], 1, 1)
self.assertTrue(r)
self.assertFalse(r[0].flags & select.KQ_EV_ERROR)
self.assertEquals(b.recv(r[0].data), b'foo')
a.close()
b.close()
kq.close()
def test_main(): def test_main():
support.run_unittest(TestKQueue) support.run_unittest(TestKQueue)
......
...@@ -990,6 +990,12 @@ class _TestPool(BaseTestCase): ...@@ -990,6 +990,12 @@ class _TestPool(BaseTestCase):
self.assertEqual(pmap(sqr, list(range(100)), chunksize=20), self.assertEqual(pmap(sqr, list(range(100)), chunksize=20),
list(map(sqr, list(range(100))))) list(map(sqr, list(range(100)))))
def test_map_chunksize(self):
try:
self.pool.map_async(sqr, [], chunksize=1).get(timeout=TIMEOUT1)
except multiprocessing.TimeoutError:
self.fail("pool.map_async with chunksize stalled on null list")
def test_async(self): def test_async(self):
res = self.pool.apply_async(sqr, (7, TIMEOUT1,)) res = self.pool.apply_async(sqr, (7, TIMEOUT1,))
get = TimingWrapper(res.get) get = TimingWrapper(res.get)
......
...@@ -3303,15 +3303,6 @@ class Test_TestProgram(TestCase): ...@@ -3303,15 +3303,6 @@ class Test_TestProgram(TestCase):
self.assertEqual(runner.test, test) self.assertEqual(runner.test, test)
self.assertEqual(program.verbosity, 2) self.assertEqual(program.verbosity, 2)
def testTestProgram_testRunnerArgument(self):
program = object.__new__(TestProgram)
program.parseArgs = lambda _: None
program.runTests = lambda: None
program.__init__(testRunner=None)
self.assertEqual(program.testRunner, unittest.TextTestRunner)
class FooBar(unittest.TestCase): class FooBar(unittest.TestCase):
def testPass(self): def testPass(self):
assert True assert True
......
...@@ -1684,8 +1684,6 @@ class TestProgram(object): ...@@ -1684,8 +1684,6 @@ class TestProgram(object):
argv=None, testRunner=None, argv=None, testRunner=None,
testLoader=defaultTestLoader, exit=True, testLoader=defaultTestLoader, exit=True,
verbosity=1): verbosity=1):
if testRunner is None:
testRunner = TextTestRunner
if isinstance(module, str): if isinstance(module, str):
self.module = __import__(module) self.module = __import__(module)
for part in module.split('.')[1:]: for part in module.split('.')[1:]:
...@@ -1775,6 +1773,8 @@ class TestProgram(object): ...@@ -1775,6 +1773,8 @@ class TestProgram(object):
self.test = loader.discover(start_dir, pattern, top_level_dir) self.test = loader.discover(start_dir, pattern, top_level_dir)
def runTests(self): def runTests(self):
if self.testRunner is None:
self.testRunner = TextTestRunner
if isinstance(self.testRunner, type): if isinstance(self.testRunner, type):
try: try:
testRunner = self.testRunner(verbosity=self.verbosity) testRunner = self.testRunner(verbosity=self.verbosity)
......
...@@ -197,6 +197,7 @@ Walter D ...@@ -197,6 +197,7 @@ Walter D
Hans Eckardt Hans Eckardt
Grant Edwards Grant Edwards
John Ehresman John Ehresman
Eric Eisner
Andrew Eland Andrew Eland
Lance Ellinghaus Lance Ellinghaus
David Ely David Ely
......
...@@ -908,6 +908,13 @@ Library ...@@ -908,6 +908,13 @@ Library
It's `distutils.util.get_compiler_versions`. Added deprecation warnings It's `distutils.util.get_compiler_versions`. Added deprecation warnings
for the obsolete get_versions() functions. for the obsolete get_versions() functions.
- Issue #6433: fixed issues with multiprocessing.pool.map hanging on empty list
- Issue #6314: logging: Extra checks on the "level" argument in more places.
- Issue #2622: Fixed an ImportError when importing email.messsage from a
standalone application built with py2exe or py2app.
- Issue #6459: distutils.command.build_ext.get_export_symbols now uses the - Issue #6459: distutils.command.build_ext.get_export_symbols now uses the
"PyInit" prefix, rather than "init". "PyInit" prefix, rather than "init".
...@@ -920,6 +927,10 @@ Library ...@@ -920,6 +927,10 @@ Library
- Issue #6403: Fixed package path usage in build_ext. - Issue #6403: Fixed package path usage in build_ext.
- Issues #5155, 5313, 5331: multiprocessing.Process._bootstrap was
unconditionally calling "os.close(sys.stdin.fileno())" resulting in file
descriptor errors
- Issue #6365: Distutils build_ext inplace mode was copying the compiled - Issue #6365: Distutils build_ext inplace mode was copying the compiled
extension in a subdirectory if the extension name had dots. extension in a subdirectory if the extension name had dots.
......
...@@ -1492,7 +1492,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) ...@@ -1492,7 +1492,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
if (nevents < 0) { if (nevents < 0) {
PyErr_Format(PyExc_ValueError, PyErr_Format(PyExc_ValueError,
"Length of eventlist must be 0 or positive, got %d", "Length of eventlist must be 0 or positive, got %d",
nchanges); nevents);
return NULL; return NULL;
} }
...@@ -1550,6 +1550,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) ...@@ -1550,6 +1550,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
PyErr_NoMemory(); PyErr_NoMemory();
return NULL; return NULL;
} }
i = 0;
while ((ei = PyIter_Next(it)) != NULL) { while ((ei = PyIter_Next(it)) != NULL) {
if (!kqueue_event_Check(ei)) { if (!kqueue_event_Check(ei)) {
Py_DECREF(ei); Py_DECREF(ei);
...@@ -1558,7 +1559,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) ...@@ -1558,7 +1559,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
"select.kevent objects"); "select.kevent objects");
goto error; goto error;
} else { } else {
chl[i] = ((kqueue_event_Object *)ei)->e; chl[i++] = ((kqueue_event_Object *)ei)->e;
} }
Py_DECREF(ei); Py_DECREF(ei);
} }
...@@ -1589,7 +1590,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args) ...@@ -1589,7 +1590,7 @@ kqueue_queue_control(kqueue_queue_Object *self, PyObject *args)
goto error; goto error;
} }
for (i=0; i < gotevents; i++) { for (i = 0; i < gotevents; i++) {
kqueue_event_Object *ch; kqueue_event_Object *ch;
ch = PyObject_New(kqueue_event_Object, &kqueue_event_Type); ch = PyObject_New(kqueue_event_Object, &kqueue_event_Type);
......
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