[Python-checkins] r65157 - in python/branches/tlee-ast-optimize: Demo/tkinter/guido/rmt.py Doc/glossary.rst Doc/library/itertools.rst Doc/library/logging.rst Doc/library/re.rst Doc/library/string.rst Doc/library/undoc.rst Doc/reference/compound_stmts.rst Doc/reference/datamodel.rst Lib/asyncore.py Lib/lib2to3 Lib/lib2to3/fixes/fix_import.py Lib/lib2to3/tests/test_fixers.py Lib/logging/config.py Lib/string.py Lib/stringold.py Lib/sunaudio.py Lib/test/pystone.py Lib/test/regrtest.py Lib/test/test_fileio.py Lib/test/test_grp.py Lib/test/test_itertools.py Lib/test/test_lib2to3.py Lib/test/test_locale.py Lib/test/test_logging.py Lib/test/test_ossaudiodev.py Lib/test/test_pwd.py Lib/test/test_py3kwarn.py Lib/test/test_random.py Lib/test/test_robotparser.py Lib/test/test_support.py Lib/test/test_types.py Lib/unittest.py Mac/IDLE/Makefile.in Misc/NEWS Modules/_json.c Modules/_localemodule.c PC/_subprocess.c Python/pystrtod.c Python/pythonrun.c
thomas.lee
python-checkins at python.org
Sun Jul 20 17:31:18 CEST 2008
Author: thomas.lee
Date: Sun Jul 20 17:31:08 2008
New Revision: 65157
Log:
Merged revisions 65090-65156 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r65091 | ronald.oussoren | 2008-07-18 15:48:03 +1000 (Fri, 18 Jul 2008) | 2 lines
Last bit of a fix for issue3381 (addon for my patch in r65061)
................
r65092 | vinay.sajip | 2008-07-18 18:59:06 +1000 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
................
r65093 | vinay.sajip | 2008-07-18 19:00:00 +1000 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
................
r65094 | vinay.sajip | 2008-07-18 19:00:35 +1000 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
................
r65095 | vinay.sajip | 2008-07-18 19:01:10 +1000 (Fri, 18 Jul 2008) | 1 line
Issue #3389: Allow resolving dotted names for handlers in logging configuration files. Thanks to Philip Jenvey for the patch.
................
r65097 | georg.brandl | 2008-07-18 20:20:59 +1000 (Fri, 18 Jul 2008) | 2 lines
Remove duplicate entry in __all__.
................
r65098 | georg.brandl | 2008-07-18 20:29:30 +1000 (Fri, 18 Jul 2008) | 2 lines
Correct attribute name.
................
r65099 | georg.brandl | 2008-07-18 21:15:06 +1000 (Fri, 18 Jul 2008) | 3 lines
Document the different meaning of precision for {:f} and {:g}.
Also document how inf and nan are formatted. #3404.
................
r65102 | benjamin.peterson | 2008-07-19 00:14:41 +1000 (Sat, 19 Jul 2008) | 1 line
backport test_fileio
................
r65104 | benjamin.peterson | 2008-07-19 00:26:35 +1000 (Sat, 19 Jul 2008) | 2 lines
now that test_lib2to3 actually works and isn't extremely slow, we don't need the lib2to3 resource
................
r65109 | georg.brandl | 2008-07-19 05:06:13 +1000 (Sat, 19 Jul 2008) | 2 lines
Replace all map(None, a) with list(a).
................
r65111 | georg.brandl | 2008-07-19 05:30:10 +1000 (Sat, 19 Jul 2008) | 2 lines
#3390: replace a remaining has_key().
................
r65112 | brett.cannon | 2008-07-19 05:30:22 +1000 (Sat, 19 Jul 2008) | 1 line
Deprecate the sunaudio module for removal in Python 3.0. The sunau module can provide similar functionality.
................
r65125 | eric.smith | 2008-07-19 10:24:05 +1000 (Sat, 19 Jul 2008) | 1 line
Fix issue 3411: default float format spec fails on negative numbers.
................
r65127 | raymond.hettinger | 2008-07-19 10:42:03 +1000 (Sat, 19 Jul 2008) | 1 line
Improve accuracy of gamma test function
................
r65128 | raymond.hettinger | 2008-07-19 10:43:00 +1000 (Sat, 19 Jul 2008) | 1 line
Add recipe to the itertools docs.
................
r65131 | georg.brandl | 2008-07-19 20:08:55 +1000 (Sat, 19 Jul 2008) | 2 lines
#3378: in case of no memory, don't leak even more memory. :)
................
r65133 | georg.brandl | 2008-07-19 22:39:10 +1000 (Sat, 19 Jul 2008) | 3 lines
#3302: fix segfaults when passing None for arguments that can't
be NULL for the C functions.
................
r65134 | georg.brandl | 2008-07-19 22:46:12 +1000 (Sat, 19 Jul 2008) | 2 lines
#3303: fix crash with invalid Py_DECREF in strcoll().
................
r65135 | georg.brandl | 2008-07-19 23:00:22 +1000 (Sat, 19 Jul 2008) | 3 lines
#3319: don't raise ZeroDivisionError if number of rounds is so
low that benchtime is zero.
................
r65136 | georg.brandl | 2008-07-19 23:09:42 +1000 (Sat, 19 Jul 2008) | 3 lines
#3323: mention that if inheriting from a class without __slots__,
the subclass will have a __dict__ available too.
................
r65139 | georg.brandl | 2008-07-19 23:48:44 +1000 (Sat, 19 Jul 2008) | 2 lines
Add ordering info for findall and finditer.
................
r65141 | benjamin.peterson | 2008-07-20 00:14:06 +1000 (Sun, 20 Jul 2008) | 9 lines
Merged revisions 65137 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r65137 | georg.brandl | 2008-07-19 08:32:57 -0500 (Sat, 19 Jul 2008) | 2 lines
#3334: correctly set prefix of imports.
........
................
r65147 | bob.ippolito | 2008-07-20 07:59:50 +1000 (Sun, 20 Jul 2008) | 1 line
#3322: bounds checking for _json.scanstring
................
r65149 | raymond.hettinger | 2008-07-20 09:21:57 +1000 (Sun, 20 Jul 2008) | 1 line
Fix compress() recipe in docs to use itertools.
................
r65150 | raymond.hettinger | 2008-07-20 09:58:47 +1000 (Sun, 20 Jul 2008) | 1 line
Clean-up itertools docs and recipes.
................
r65151 | gregory.p.smith | 2008-07-20 10:22:08 +1000 (Sun, 20 Jul 2008) | 9 lines
fix issue3120 - don't truncate handles on 64-bit Windows.
This is still messy, realistically PC/_subprocess.c should never cast pointers
to python numbers and back at all.
I don't have a 64-bit windows build environment because microsoft apparently
thinks that should cost money. Time to watch the buildbots. It builds and
passes tests on 32-bit windows.
................
r65152 | georg.brandl | 2008-07-20 17:29:58 +1000 (Sun, 20 Jul 2008) | 2 lines
Remove exception indexing in asyncore.
................
r65155 | georg.brandl | 2008-07-20 21:50:29 +1000 (Sun, 20 Jul 2008) | 2 lines
#926501: add info where to put the docstring.
................
Added:
python/branches/tlee-ast-optimize/Lib/test/test_fileio.py
- copied unchanged from r65155, /python/trunk/Lib/test/test_fileio.py
Modified:
python/branches/tlee-ast-optimize/ (props changed)
python/branches/tlee-ast-optimize/Demo/tkinter/guido/rmt.py
python/branches/tlee-ast-optimize/Doc/glossary.rst
python/branches/tlee-ast-optimize/Doc/library/itertools.rst
python/branches/tlee-ast-optimize/Doc/library/logging.rst
python/branches/tlee-ast-optimize/Doc/library/re.rst
python/branches/tlee-ast-optimize/Doc/library/string.rst
python/branches/tlee-ast-optimize/Doc/library/undoc.rst
python/branches/tlee-ast-optimize/Doc/reference/compound_stmts.rst
python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst
python/branches/tlee-ast-optimize/Lib/asyncore.py
python/branches/tlee-ast-optimize/Lib/lib2to3/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
python/branches/tlee-ast-optimize/Lib/logging/config.py
python/branches/tlee-ast-optimize/Lib/string.py
python/branches/tlee-ast-optimize/Lib/stringold.py
python/branches/tlee-ast-optimize/Lib/sunaudio.py
python/branches/tlee-ast-optimize/Lib/test/pystone.py
python/branches/tlee-ast-optimize/Lib/test/regrtest.py
python/branches/tlee-ast-optimize/Lib/test/test_grp.py
python/branches/tlee-ast-optimize/Lib/test/test_itertools.py
python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py
python/branches/tlee-ast-optimize/Lib/test/test_locale.py
python/branches/tlee-ast-optimize/Lib/test/test_logging.py
python/branches/tlee-ast-optimize/Lib/test/test_ossaudiodev.py
python/branches/tlee-ast-optimize/Lib/test/test_pwd.py
python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py
python/branches/tlee-ast-optimize/Lib/test/test_random.py
python/branches/tlee-ast-optimize/Lib/test/test_robotparser.py
python/branches/tlee-ast-optimize/Lib/test/test_support.py
python/branches/tlee-ast-optimize/Lib/test/test_types.py
python/branches/tlee-ast-optimize/Lib/unittest.py
python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in
python/branches/tlee-ast-optimize/Misc/NEWS
python/branches/tlee-ast-optimize/Modules/_json.c
python/branches/tlee-ast-optimize/Modules/_localemodule.c
python/branches/tlee-ast-optimize/PC/_subprocess.c
python/branches/tlee-ast-optimize/Python/pystrtod.c
python/branches/tlee-ast-optimize/Python/pythonrun.c
Modified: python/branches/tlee-ast-optimize/Demo/tkinter/guido/rmt.py
==============================================================================
--- python/branches/tlee-ast-optimize/Demo/tkinter/guido/rmt.py (original)
+++ python/branches/tlee-ast-optimize/Demo/tkinter/guido/rmt.py Sun Jul 20 17:31:08 2008
@@ -134,7 +134,7 @@
file_m_apps.add('command')
file_m_apps.delete(0, 'last')
names = root.winfo_interps()
- names = map(None, names) # convert tuple to list
+ names = list(names)
names.sort()
for name in names:
try:
Modified: python/branches/tlee-ast-optimize/Doc/glossary.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/glossary.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/glossary.rst Sun Jul 20 17:31:08 2008
@@ -123,6 +123,14 @@
of :class:`dict` much resembles that for :class:`list`, but the keys can
be any object with a :meth:`__hash__` function, not just integers starting
from zero. Called a hash in Perl.
+
+ docstring
+ A docstring ("documentation string") is a string literal that appears as
+ the first thing in a class or function suite. While ignored when the
+ suite is executed, it is recognized by the compiler and put into the
+ :attr:`__doc__` attribute of the class or function. Since it is available
+ via introspection, it is the canonical place for documentation of the
+ object.
duck-typing
Pythonic programming style that determines an object's type by inspection
Modified: python/branches/tlee-ast-optimize/Doc/library/itertools.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/itertools.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/itertools.rst Sun Jul 20 17:31:08 2008
@@ -35,18 +35,11 @@
Likewise, the functional tools are designed to work well with the high-speed
functions provided by the :mod:`operator` module.
-The module author welcomes suggestions for other basic building blocks to be
-added to future versions of the module.
-
Whether cast in pure python form or compiled code, tools that use iterators are
-more memory efficient (and faster) than their list based counterparts. Adopting
+more memory efficient (and often faster) than their list based counterparts. Adopting
the principles of just-in-time manufacturing, they create data when and where
needed instead of consuming memory with the computer equivalent of "inventory".
-The performance advantage of iterators becomes more acute as the number of
-elements increases -- at some point, lists grow large enough to severely impact
-memory cache performance and start running slowly.
-
.. seealso::
@@ -598,55 +591,35 @@
.. testcode::
- def take(n, seq):
- return list(islice(seq, n))
+ def take(n, iterable):
+ "Return first n items of the iterable as a list"
+ return list(islice(iterable, n))
- def enumerate(iterable):
- return izip(count(), iterable)
+ def enumerate(iterable, start=0):
+ return izip(count(start), iterable)
- def tabulate(function):
+ def tabulate(function, start=0):
"Return function(0), function(1), ..."
- return imap(function, count())
-
- def iteritems(mapping):
- return izip(mapping.iterkeys(), mapping.itervalues())
+ return imap(function, count(start))
def nth(iterable, n):
- "Returns the nth item or raise StopIteration"
- return islice(iterable, n, None).next()
+ "Returns the nth item or empty list"
+ return list(islice(iterable, n, n+1))
- def all(seq, pred=None):
- "Returns True if pred(x) is true for every element in the iterable"
- for elem in ifilterfalse(pred, seq):
- return False
- return True
-
- def any(seq, pred=None):
- "Returns True if pred(x) is true for at least one element in the iterable"
- for elem in ifilter(pred, seq):
- return True
- return False
-
- def no(seq, pred=None):
- "Returns True if pred(x) is false for every element in the iterable"
- for elem in ifilter(pred, seq):
- return False
- return True
-
- def quantify(seq, pred=None):
- "Count how many times the predicate is true in the sequence"
- return sum(imap(pred, seq))
+ def quantify(iterable, pred=bool):
+ "Count how many times the predicate is true"
+ return sum(imap(pred, iterable))
- def padnone(seq):
+ def padnone(iterable):
"""Returns the sequence elements and then returns None indefinitely.
Useful for emulating the behavior of the built-in map() function.
"""
- return chain(seq, repeat(None))
+ return chain(iterable, repeat(None))
- def ncycles(seq, n):
+ def ncycles(iterable, n):
"Returns the sequence elements n times"
- return chain.from_iterable(repeat(seq, n))
+ return chain.from_iterable(repeat(iterable, n))
def dotproduct(vec1, vec2):
return sum(imap(operator.mul, vec1, vec2))
@@ -698,6 +671,21 @@
def compress(data, selectors):
"compress('abcdef', [1,0,1,0,1,1]) --> a c e f"
- for d, s in izip(data, selectors):
- if s:
- yield d
+ decorated = izip(data, selectors)
+ filtered = ifilter(operator.itemgetter(1), decorated)
+ return imap(operator.itemgetter(0), filtered)
+
+ def combinations_with_replacement(iterable, r):
+ "combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC"
+ pool = tuple(iterable)
+ n = len(pool)
+ indices = [0] * r
+ yield tuple(pool[i] for i in indices)
+ while 1:
+ for i in reversed(range(r)):
+ if indices[i] != n - 1:
+ break
+ else:
+ return
+ indices[i:] = [indices[i] + 1] * (r - i)
+ yield tuple(pool[i] for i in indices)
Modified: python/branches/tlee-ast-optimize/Doc/library/logging.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/logging.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/logging.rst Sun Jul 20 17:31:08 2008
@@ -1674,7 +1674,7 @@
The system will save old log files by appending extensions to the filename.
The extensions are date-and-time based, using the strftime format
``%Y-%m-%d_%H-%M-%S`` or a leading portion thereof, depending on the
- rollover interval.
+ rollover interval.
If the *utc* argument is true, times in UTC will be used; otherwise
local time is used.
@@ -2351,6 +2351,10 @@
in the ``logging`` package's namespace). The ``level`` is interpreted as for
loggers, and ``NOTSET`` is taken to mean "log everything".
+.. versionchanged:: 2.6
+ Added support for resolving the handler's class as a dotted module and class
+ name.
+
The ``formatter`` entry indicates the key name of the formatter for this
handler. If blank, a default formatter (``logging._defaultFormatter``) is used.
If a name is specified, it must appear in the ``[formatters]`` section and have
Modified: python/branches/tlee-ast-optimize/Doc/library/re.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/re.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/re.rst Sun Jul 20 17:31:08 2008
@@ -575,10 +575,11 @@
.. function:: findall(pattern, string[, flags])
Return all non-overlapping matches of *pattern* in *string*, as a list of
- strings. If one or more groups are present in the pattern, return a list of
- groups; this will be a list of tuples if the pattern has more than one group.
- Empty matches are included in the result unless they touch the beginning of
- another match.
+ strings. The *string* is scanned left-to-right, and matches are returned in
+ the order found. If one or more groups are present in the pattern, return a
+ list of groups; this will be a list of tuples if the pattern has more than
+ one group. Empty matches are included in the result unless they touch the
+ beginning of another match.
.. versionadded:: 1.5.2
@@ -589,8 +590,10 @@
.. function:: finditer(pattern, string[, flags])
Return an :term:`iterator` yielding :class:`MatchObject` instances over all
- non-overlapping matches for the RE *pattern* in *string*. Empty matches are
- included in the result unless they touch the beginning of another match.
+ non-overlapping matches for the RE *pattern* in *string*. The *string* is
+ scanned left-to-right, and matches are returned in the order found. Empty
+ matches are included in the result unless they touch the beginning of another
+ match.
.. versionadded:: 2.2
Modified: python/branches/tlee-ast-optimize/Doc/library/string.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/string.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/string.rst Sun Jul 20 17:31:08 2008
@@ -387,10 +387,11 @@
character of ``'0'``.
The *precision* is a decimal number indicating how many digits should be
-displayed after the decimal point for a floating point value. For non-number
-types the field indicates the maximum field size - in other words, how many
-characters will be used from the field content. The *precision* is ignored for
-integer values.
+displayed after the decimal point for a floating point value formatted with
+``'f'`` and ``'F'``, or before and after the decimal point for a floating point
+value formatted with ``'g'`` or ``'G'``. For non-number types the field
+indicates the maximum field size - in other words, how many characters will be
+used from the field content. The *precision* is ignored for integer values.
Finally, the *type* determines how the data should be presented.
@@ -418,7 +419,7 @@
| | the current locale setting to insert the appropriate |
| | number separator characters. |
+---------+----------------------------------------------------------+
- | None | the same as ``'d'`` |
+ | None | The same as ``'d'``. |
+---------+----------------------------------------------------------+
The available presentation types for floating point and decimal values are:
@@ -439,10 +440,13 @@
+---------+----------------------------------------------------------+
| ``'g'`` | General format. This prints the number as a fixed-point |
| | number, unless the number is too large, in which case |
- | | it switches to ``'e'`` exponent notation. |
+ | | it switches to ``'e'`` exponent notation. Infinity and |
+ | | NaN values are formatted as ``inf``, ``-inf`` and |
+ | | ``nan``, respectively. |
+---------+----------------------------------------------------------+
| ``'G'`` | General format. Same as ``'g'`` except switches to |
- | | ``'E'`` if the number gets to large. |
+ | | ``'E'`` if the number gets to large. The representations |
+ | | of infinity and NaN are uppercased, too. |
+---------+----------------------------------------------------------+
| ``'n'`` | Number. This is the same as ``'g'``, except that it uses |
| | the current locale setting to insert the appropriate |
@@ -451,7 +455,7 @@
| ``'%'`` | Percentage. Multiplies the number by 100 and displays |
| | in fixed (``'f'``) format, followed by a percent sign. |
+---------+----------------------------------------------------------+
- | None | the same as ``'g'`` |
+ | None | The same as ``'g'``. |
+---------+----------------------------------------------------------+
Modified: python/branches/tlee-ast-optimize/Doc/library/undoc.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/undoc.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/undoc.rst Sun Jul 20 17:31:08 2008
@@ -60,6 +60,8 @@
:mod:`sunaudio`
--- Interpret Sun audio headers (may become obsolete or a tool/demo).
+ .. warning:: The :mod:`sunaudio` module has been removed in Python 3.0.
+
:mod:`toaiff`
--- Convert "arbitrary" sound files to AIFF files; should probably become a tool
or demo. Requires the external program :program:`sox`.
Modified: python/branches/tlee-ast-optimize/Doc/reference/compound_stmts.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/compound_stmts.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/reference/compound_stmts.rst Sun Jul 20 17:31:08 2008
@@ -422,7 +422,7 @@
when the function is called.
The function definition does not execute the function body; this gets executed
-only when the function is called.
+only when the function is called. [#]_
.. index::
statement: @
@@ -509,6 +509,7 @@
pair: name; binding
pair: execution; frame
single: inheritance
+ single: docstring
A class definition defines a class object (see section :ref:`types`):
@@ -523,10 +524,10 @@
then executed in a new execution frame (see section :ref:`naming`), using a
newly created local namespace and the original global namespace. (Usually, the
suite contains only function definitions.) When the class's suite finishes
-execution, its execution frame is discarded but its local namespace is saved. A
-class object is then created using the inheritance list for the base classes and
-the saved local namespace for the attribute dictionary. The class name is bound
-to this class object in the original local namespace.
+execution, its execution frame is discarded but its local namespace is
+saved. [#]_ A class object is then created using the inheritance list for the
+base classes and the saved local namespace for the attribute dictionary. The
+class name is bound to this class object in the original local namespace.
**Programmer's note:** Variables defined in the class definition are class
variables; they are shared by all instances. To create instance variables, they
@@ -551,3 +552,11 @@
.. [#] Currently, control "flows off the end" except in the case of an exception or the
execution of a :keyword:`return`, :keyword:`continue`, or :keyword:`break`
statement.
+
+.. [#] A string literal appearing as the first statement in the function body is
+ transformed into the function's ``__doc__`` attribute and therefore the
+ function's :term:`docstring`.
+
+.. [#] A string literal appearing as the first statement in the class body is
+ transformed into the namespace's ``__doc__`` item and therefore the class's
+ :term:`docstring`.
Modified: python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst Sun Jul 20 17:31:08 2008
@@ -1600,6 +1600,10 @@
Notes on using *__slots__*
+* When inheriting from a class without *__slots__*, the *__dict__* attribute of
+ that class will always be accessible, so a *__slots__* definition in the
+ subclass is meaningless.
+
* Without a *__dict__* variable, instances cannot be assigned new variables not
listed in the *__slots__* definition. Attempts to assign to an unlisted
variable name raises :exc:`AttributeError`. If dynamic assignment of new
Modified: python/branches/tlee-ast-optimize/Lib/asyncore.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/asyncore.py (original)
+++ python/branches/tlee-ast-optimize/Lib/asyncore.py Sun Jul 20 17:31:08 2008
@@ -129,7 +129,7 @@
try:
r, w, e = select.select(r, w, e, timeout)
except select.error, err:
- if err[0] != EINTR:
+ if err.args[0] != EINTR:
raise
else:
return
@@ -175,7 +175,7 @@
try:
r = pollster.poll(timeout)
except select.error, err:
- if err[0] != EINTR:
+ if err.args[0] != EINTR:
raise
r = []
for fd, flags in r:
@@ -231,7 +231,7 @@
try:
self.addr = sock.getpeername()
except socket.error, err:
- if err[0] == ENOTCONN:
+ if err.args[0] == ENOTCONN:
# To handle the case where we got an unconnected
# socket.
self.connected = False
@@ -339,7 +339,7 @@
conn, addr = self.socket.accept()
return conn, addr
except socket.error, why:
- if why[0] == EWOULDBLOCK:
+ if why.args[0] == EWOULDBLOCK:
pass
else:
raise
@@ -349,9 +349,9 @@
result = self.socket.send(data)
return result
except socket.error, why:
- if why[0] == EWOULDBLOCK:
+ if why.args[0] == EWOULDBLOCK:
return 0
- elif why[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
+ elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
self.handle_close()
return 0
else:
@@ -369,7 +369,7 @@
return data
except socket.error, why:
# winsock sometimes throws ENOTCONN
- if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
+ if why.args[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]:
self.handle_close()
return ''
else:
@@ -382,7 +382,7 @@
try:
self.socket.close()
except socket.error, why:
- if why[0] not in (ENOTCONN, EBADF):
+ if why.args[0] not in (ENOTCONN, EBADF):
raise
# cheap inheritance, used to pass all other attribute
@@ -549,7 +549,7 @@
try:
x.close()
except OSError, x:
- if x[0] == EBADF:
+ if x.args[0] == EBADF:
pass
elif not ignore_all:
raise
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py Sun Jul 20 17:31:08 2008
@@ -45,7 +45,7 @@
node.changed()
else:
new = FromImport('.', getattr(imp, 'content', None) or [imp])
- new.prefix = node.get_prefix()
+ new.set_prefix(node.get_prefix())
node = new
return node
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py Sun Jul 20 17:31:08 2008
@@ -3319,6 +3319,17 @@
a = "from . import foo.bar as bang"
self.check_both(b, a)
+ def test_prefix(self):
+ b = """
+ # prefix
+ import foo.bar
+ """
+ a = """
+ # prefix
+ from . import foo.bar
+ """
+ self.check_both(b, a)
+
if __name__ == "__main__":
import __main__
Modified: python/branches/tlee-ast-optimize/Lib/logging/config.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/logging/config.py (original)
+++ python/branches/tlee-ast-optimize/Lib/logging/config.py Sun Jul 20 17:31:08 2008
@@ -146,7 +146,10 @@
fmt = cp.get(sectname, "formatter")
else:
fmt = ""
- klass = eval(klass, vars(logging))
+ try:
+ klass = eval(klass, vars(logging))
+ except (AttributeError, NameError):
+ klass = _resolve(klass)
args = cp.get(sectname, "args")
args = eval(args, vars(logging))
h = apply(klass, args)
Modified: python/branches/tlee-ast-optimize/Lib/string.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/string.py (original)
+++ python/branches/tlee-ast-optimize/Lib/string.py Sun Jul 20 17:31:08 2008
@@ -68,7 +68,7 @@
raise ValueError, "maketrans arguments must have same length"
global _idmapL
if not _idmapL:
- _idmapL = map(None, _idmap)
+ _idmapL = list(_idmap)
L = _idmapL[:]
fromstr = map(ord, fromstr)
for i in range(len(fromstr)):
Modified: python/branches/tlee-ast-optimize/Lib/stringold.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/stringold.py (original)
+++ python/branches/tlee-ast-optimize/Lib/stringold.py Sun Jul 20 17:31:08 2008
@@ -391,7 +391,7 @@
raise ValueError, "maketrans arguments must have same length"
global _idmapL
if not _idmapL:
- _idmapL = map(None, _idmap)
+ _idmapL = list(_idmap)
L = _idmapL[:]
fromstr = map(ord, fromstr)
for i in range(len(fromstr)):
Modified: python/branches/tlee-ast-optimize/Lib/sunaudio.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/sunaudio.py (original)
+++ python/branches/tlee-ast-optimize/Lib/sunaudio.py Sun Jul 20 17:31:08 2008
@@ -1,4 +1,9 @@
"""Interpret sun audio headers."""
+from warnings import warnpy3k
+warnpy3k("the sunaudio module has been removed in Python 3.0; "
+ "use the sunau module instead", stacklevel=2)
+del warnpy3k
+
MAGIC = '.snd'
Modified: python/branches/tlee-ast-optimize/Lib/test/pystone.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/pystone.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/pystone.py Sun Jul 20 17:31:08 2008
@@ -128,7 +128,11 @@
IntLoc1 = Proc2(IntLoc1)
benchtime = clock() - starttime - nulltime
- return benchtime, (loops / benchtime)
+ if benchtime == 0.0:
+ loopsPerBenchtime = 0.0
+ else:
+ loopsPerBenchtime = (loops / benchtime)
+ return benchtime, loopsPerBenchtime
def Proc1(PtrParIn):
PtrParIn.PtrComp = NextRecord = PtrGlb.copy()
Modified: python/branches/tlee-ast-optimize/Lib/test/regrtest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/regrtest.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/regrtest.py Sun Jul 20 17:31:08 2008
@@ -167,8 +167,8 @@
from test import test_support
-RESOURCE_NAMES = ('audio', 'curses', 'lib2to3', 'largefile', 'network',
- 'bsddb', 'decimal', 'compiler', 'subprocess', 'urlfetch')
+RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
+ 'decimal', 'compiler', 'subprocess', 'urlfetch')
def usage(code, msg=''):
Modified: python/branches/tlee-ast-optimize/Lib/test/test_grp.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_grp.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_grp.py Sun Jul 20 17:31:08 2008
@@ -57,7 +57,7 @@
namei = 0
fakename = allnames[namei]
while fakename in bynames:
- chars = map(None, fakename)
+ chars = list(fakename)
for i in xrange(len(chars)):
if chars[i] == 'z':
chars[i] = 'A'
@@ -74,7 +74,7 @@
except IndexError:
# should never happen... if so, just forget it
break
- fakename = ''.join(map(None, chars))
+ fakename = ''.join(chars)
self.assertRaises(KeyError, grp.getgrnam, fakename)
Modified: python/branches/tlee-ast-optimize/Lib/test/test_itertools.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_itertools.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_itertools.py Sun Jul 20 17:31:08 2008
@@ -1185,52 +1185,32 @@
[22]
[25, 26, 27, 28]
->>> def take(n, seq):
-... return list(islice(seq, n))
+>>> def take(n, iterable):
+... "Return first n items of the iterable as a list"
+... return list(islice(iterable, n))
->>> def enumerate(iterable):
-... return izip(count(), iterable)
+>>> def enumerate(iterable, start=0):
+... return izip(count(start), iterable)
->>> def tabulate(function):
+>>> def tabulate(function, start=0):
... "Return function(0), function(1), ..."
-... return imap(function, count())
-
->>> def iteritems(mapping):
-... return izip(mapping.iterkeys(), mapping.itervalues())
+... return imap(function, count(start))
>>> def nth(iterable, n):
-... "Returns the nth item"
+... "Returns the nth item or empty list"
... return list(islice(iterable, n, n+1))
->>> def all(seq, pred=None):
-... "Returns True if pred(x) is true for every element in the iterable"
-... for elem in ifilterfalse(pred, seq):
-... return False
-... return True
-
->>> def any(seq, pred=None):
-... "Returns True if pred(x) is true for at least one element in the iterable"
-... for elem in ifilter(pred, seq):
-... return True
-... return False
-
->>> def no(seq, pred=None):
-... "Returns True if pred(x) is false for every element in the iterable"
-... for elem in ifilter(pred, seq):
-... return False
-... return True
-
->>> def quantify(seq, pred=None):
-... "Count how many times the predicate is true in the sequence"
-... return sum(imap(pred, seq))
+>>> def quantify(iterable, pred=bool):
+... "Count how many times the predicate is true"
+... return sum(imap(pred, iterable))
->>> def padnone(seq):
+>>> def padnone(iterable):
... "Returns the sequence elements and then returns None indefinitely"
-... return chain(seq, repeat(None))
+... return chain(iterable, repeat(None))
->>> def ncycles(seq, n):
-... "Returns the sequence elements n times"
-... return chain(*repeat(seq, n))
+>>> def ncycles(iterable, n):
+... "Returns the seqeuence elements n times"
+... return chain(*repeat(iterable, n))
>>> def dotproduct(vec1, vec2):
... return sum(imap(operator.mul, vec1, vec2))
@@ -1281,9 +1261,24 @@
>>> def compress(data, selectors):
... "compress('abcdef', [1,0,1,0,1,1]) --> a c e f"
-... for d, s in izip(data, selectors):
-... if s:
-... yield d
+... decorated = izip(data, selectors)
+... filtered = ifilter(operator.itemgetter(1), decorated)
+... return imap(operator.itemgetter(0), filtered)
+
+>>> def combinations_with_replacement(iterable, r):
+... "combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC"
+... pool = tuple(iterable)
+... n = len(pool)
+... indices = [0] * r
+... yield tuple(pool[i] for i in indices)
+... while 1:
+... for i in reversed(range(r)):
+... if indices[i] != n - 1:
+... break
+... else:
+... return
+... indices[i:] = [indices[i] + 1] * (r - i)
+... yield tuple(pool[i] for i in indices)
This is not part of the examples but it tests to make sure the definitions
perform as purported.
@@ -1300,24 +1295,6 @@
>>> nth('abcde', 3)
['d']
->>> all([2, 4, 6, 8], lambda x: x%2==0)
-True
-
->>> all([2, 3, 6, 8], lambda x: x%2==0)
-False
-
->>> any([2, 4, 6, 8], lambda x: x%2==0)
-True
-
->>> any([1, 3, 5, 9], lambda x: x%2==0,)
-False
-
->>> no([1, 3, 5, 9], lambda x: x%2==0)
-True
-
->>> no([1, 2, 5, 9], lambda x: x%2==0)
-False
-
>>> quantify(xrange(99), lambda x: x%2==0)
50
@@ -1362,6 +1339,9 @@
>>> list(compress('abcdef', [1,0,1,0,1,1]))
['a', 'c', 'e', 'f']
+>>> list(combinations_with_replacement('abc', 2))
+[('a', 'a'), ('a', 'b'), ('a', 'c'), ('b', 'b'), ('b', 'c'), ('c', 'c')]
+
"""
__test__ = {'libreftest' : libreftest}
Modified: python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py Sun Jul 20 17:31:08 2008
@@ -2,11 +2,7 @@
# because of running
from lib2to3.tests import test_fixers, test_pytree, test_util
import unittest
-from test.test_support import run_unittest, requires
-
-# Don't run lib2to3 tests by default since they take too long
-if __name__ != '__main__':
- requires('lib2to3')
+from test.test_support import run_unittest
def suite():
tests = unittest.TestSuite()
Modified: python/branches/tlee-ast-optimize/Lib/test/test_locale.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_locale.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_locale.py Sun Jul 20 17:31:08 2008
@@ -1,4 +1,4 @@
-from test.test_support import verbose, TestSkipped
+from test.test_support import verbose, TestSkipped, TestFailed
import locale
import sys
@@ -113,3 +113,12 @@
teststrop('\xed\x95\xa0', 'upper', '\xed\x95\xa0')
finally:
locale.setlocale(locale.LC_CTYPE, oldlocale)
+
+if hasattr(locale, "strcoll"):
+ # test crasher from bug #3303
+ try:
+ locale.strcoll(u"a", None)
+ except TypeError:
+ pass
+ else:
+ raise TestFailed("TypeError not raised")
Modified: python/branches/tlee-ast-optimize/Lib/test/test_logging.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_logging.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_logging.py Sun Jul 20 17:31:08 2008
@@ -584,6 +584,9 @@
datefmt=
"""
+ # config5 specifies a custom handler class to be loaded
+ config5 = config1.replace('class=StreamHandler', 'class=logging.StreamHandler')
+
def apply_config(self, conf):
try:
fn = tempfile.mktemp(".ini")
@@ -609,10 +612,10 @@
# Original logger output is empty.
self.assert_log_lines([])
- def test_config1_ok(self):
+ def test_config1_ok(self, config=config1):
# A config file defining a sub-parser as well.
with captured_stdout() as output:
- self.apply_config(self.config1)
+ self.apply_config(config)
logger = logging.getLogger("compiler.parser")
# Both will output a message
logger.info(self.next_message())
@@ -647,6 +650,8 @@
# Original logger output is empty
self.assert_log_lines([])
+ def test_config5_ok(self):
+ self.test_config1_ok(config=self.config5)
class LogRecordStreamHandler(StreamRequestHandler):
Modified: python/branches/tlee-ast-optimize/Lib/test/test_ossaudiodev.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_ossaudiodev.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_ossaudiodev.py Sun Jul 20 17:31:08 2008
@@ -6,7 +6,7 @@
import errno
import ossaudiodev
import sys
-import sunaudio
+import sunau
import time
import audioop
import unittest
@@ -22,15 +22,16 @@
AFMT_S16_NE = ossaudiodev.AFMT_S16_BE
-SND_FORMAT_MULAW_8 = 1
-
def read_sound_file(path):
- fp = open(path, 'rb')
- size, enc, rate, nchannels, extra = sunaudio.gethdr(fp)
- data = fp.read()
- fp.close()
+ with open(path, 'rb') as fp:
+ au = sunau.open(fp)
+ rate = au.getframerate()
+ nchannels = au.getnchannels()
+ encoding = au._encoding
+ fp.seek(0)
+ data = fp.read()
- if enc != SND_FORMAT_MULAW_8:
+ if encoding != sunau.AUDIO_FILE_ENCODING_MULAW_8:
raise RuntimeError("Expect .au file with 8-bit mu-law samples")
# Convert the data to 16-bit signed.
Modified: python/branches/tlee-ast-optimize/Lib/test/test_pwd.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_pwd.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_pwd.py Sun Jul 20 17:31:08 2008
@@ -62,7 +62,7 @@
namei = 0
fakename = allnames[namei]
while fakename in bynames:
- chars = map(None, fakename)
+ chars = list(fakename)
for i in xrange(len(chars)):
if chars[i] == 'z':
chars[i] = 'A'
@@ -79,7 +79,7 @@
except IndexError:
# should never happen... if so, just forget it
break
- fakename = ''.join(map(None, chars))
+ fakename = ''.join(chars)
self.assertRaises(KeyError, pwd.getpwnam, fakename)
Modified: python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py Sun Jul 20 17:31:08 2008
@@ -173,8 +173,9 @@
# test.testall not tested as it executes all unit tests as an
# import side-effect.
all_platforms = ('audiodev', 'imputil', 'mutex', 'user', 'new', 'rexec',
- 'Bastion', 'compiler', 'dircache', 'mimetools', 'fpformat',
- 'ihooks', 'mhlib', 'statvfs', 'htmllib', 'sgmllib', 'rfc822')
+ 'Bastion', 'compiler', 'dircache', 'mimetools',
+ 'fpformat', 'ihooks', 'mhlib', 'statvfs', 'htmllib',
+ 'sgmllib', 'rfc822', 'sunaudio')
inclusive_platforms = {'irix' : ('pure', 'AL', 'al', 'CD', 'cd', 'cddb',
'cdplayer', 'CL', 'cl', 'DEVICE', 'GL',
'gl', 'ERRNO', 'FILE', 'FL', 'flp', 'fl',
Modified: python/branches/tlee-ast-optimize/Lib/test/test_random.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_random.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_random.py Sun Jul 20 17:31:08 2008
@@ -5,7 +5,7 @@
import time
import pickle
import warnings
-from math import log, exp, sqrt, pi
+from math import log, exp, sqrt, pi, sum as msum
from test import test_support
class TestBasicOps(unittest.TestCase):
@@ -465,11 +465,9 @@
def gamma(z, cof=_gammacoeff, g=7):
z -= 1.0
- sum = cof[0]
- for i in xrange(1,len(cof)):
- sum += cof[i] / (z+i)
+ s = msum([cof[0]] + [cof[i] / (z+i) for i in range(1,len(cof))])
z += 0.5
- return (z+g)**z / exp(z+g) * sqrt(2*pi) * sum
+ return (z+g)**z / exp(z+g) * sqrt(2.0*pi) * s
class TestDistributions(unittest.TestCase):
def test_zeroinputs(self):
Modified: python/branches/tlee-ast-optimize/Lib/test/test_robotparser.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_robotparser.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_robotparser.py Sun Jul 20 17:31:08 2008
@@ -149,5 +149,5 @@
TestCase().run()
if __name__=='__main__':
- test_support.Verbose = 1
+ test_support.verbose = 1
test_main()
Modified: python/branches/tlee-ast-optimize/Lib/test/test_support.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_support.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_support.py Sun Jul 20 17:31:08 2008
@@ -20,7 +20,7 @@
"fcmp", "have_unicode", "is_jython", "TESTFN", "HOST", "FUZZ",
"findfile", "verify", "vereq", "sortdict", "check_syntax_error",
"open_urlresource", "WarningMessage", "catch_warning", "CleanImport",
- "EnvironmentVarGuard", "TransientResource", "captured_output",
+ "EnvironmentVarGuard", "captured_output",
"captured_stdout", "TransientResource", "transient_internet",
"run_with_locale", "set_memlimit", "bigmemtest", "bigaddrspacetest",
"BasicTestRunner", "run_unittest", "run_doctest", "threading_setup",
Modified: python/branches/tlee-ast-optimize/Lib/test/test_types.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_types.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_types.py Sun Jul 20 17:31:08 2008
@@ -570,6 +570,12 @@
test(0.01, '', '0.01')
test(0.01, 'g', '0.01')
+ # test for issue 3411
+ test(1.23, '1', '1.23')
+ test(-1.23, '1', '-1.23')
+ test(1.23, '1g', '1.23')
+ test(-1.23, '1g', '-1.23')
+
test( 1.0, ' g', ' 1')
test(-1.0, ' g', '-1')
test( 1.0, '+g', '+1')
Modified: python/branches/tlee-ast-optimize/Lib/unittest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/unittest.py (original)
+++ python/branches/tlee-ast-optimize/Lib/unittest.py Sun Jul 20 17:31:08 2008
@@ -160,7 +160,7 @@
return ''.join(traceback.format_exception(exctype, value, tb))
def _is_relevant_tb_level(self, tb):
- return tb.tb_frame.f_globals.has_key('__unittest')
+ return '__unittest' in tb.tb_frame.f_globals
def _count_relevant_tb_levels(self, tb):
length = 0
Modified: python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in
==============================================================================
--- python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in (original)
+++ python/branches/tlee-ast-optimize/Mac/IDLE/Makefile.in Sun Jul 20 17:31:08 2008
@@ -42,7 +42,7 @@
$(srcdir)/../Icons/PythonSource.icns \
$(srcdir)/../Icons/PythonCompiled.icns Info.plist
rm -fr IDLE.app
- $(RUNSHARED) arch -ppc -i386 $(BUILDPYTHON) $(BUNDLEBULDER) \
+ $(RUNSHARED) @ARCH_RUN_32BIT@ $(BUILDPYTHON) $(BUNDLEBULDER) \
--builddir=. \
--name=IDLE \
--link-exec \
Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS (original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS Sun Jul 20 17:31:08 2008
@@ -56,17 +56,28 @@
slice(None, 10, -1).indices(10) returns (9, 9, -1) instead of (9,
10, -1).
-- Issue #3219: Calling a function with repeated keyword arguments, f(a=2, a=23),
- would not cause a syntax error. This was a regression from 2.4 caused by the
- switch to the new compiler.
-
-- Issue #2862: Make int and float freelist management consistent with other
- freelists. Changes their CompactFreeList apis into ClearFreeList apis and
- calls them via gc.collect().
+- Issue #3219: Calling a function with repeated keyword arguments,
+ f(a=2, a=23), would not cause a syntax error. This was a regression
+ from 2.4 caused by the switch to the new compiler.
+
+- Issue #2862: Make int and float freelist management consistent with
+ other freelists. Changes their CompactFreeList apis into
+ ClearFreeList apis and calls them via gc.collect().
Library
-------
+- Issue #3303: Fix a crash in locale.strcoll() when calling it with
+ invalid arguments.
+
+- Issue #3302: Fix several crashes when calling locale's gettext functions
+ with None arguments.
+
+- Issue #3389: Allow resolving dotted names for handlers in logging
+ configuration files.
+
+- Deprecate the sunaudio module for removal in Python 3.0.
+
- Issue #3395: fix reference in test_multiprocessing to old debugInfo method
- Issue #3312: Fix two crashes in sqlite3.
@@ -76,7 +87,7 @@
- Issue #3125: Remove copy_reg in multiprocessing and replace it with
ForkingPickler.register() to resolve conflict with ctypes.
-- Issue #3090: Fixed ARCHFLAGS parsing on OS/X
+- Issue #3090: Fixed ARCHFLAGS parsing on OS/X
- Issue #3313: Fixed a crash when a failed dlopen() call does not set
a valid dlerror() message.
@@ -104,9 +115,9 @@
- Issue #1746: Correct handling of zipfile archive comments (previously
archives with comments over 4k were flagged as invalid). Allow writing
- Zip files with archives by setting the 'comment' attribute of a ZipFile.
+ Zip files with archives by setting the 'comment' attribute of a ZipFile.
-- Issue #449227: The rlcompleter module now adds "(" to callable objects
+- Issue #449227: The rlcompleter module now adds "(" to callable objects
when completed.
- Issue #3190: Pydoc now hides the automatic module attribute __package__ (the
@@ -130,6 +141,8 @@
up in the child process to prevent deadlock and report proper thread counts
if the new process uses the threading module.
+- Issue #3120: On 64-bit Windows the subprocess module was truncating handles.
+
Tests
-----
@@ -137,7 +150,6 @@
and is now better documented. Explicit unit tests for this context manager
have been added to test_warnings.
-
Build
-----
Modified: python/branches/tlee-ast-optimize/Modules/_json.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_json.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_json.c Sun Jul 20 17:31:08 2008
@@ -235,6 +235,10 @@
if (chunks == NULL) {
goto bail;
}
+ if (end < 0 || len <= end) {
+ PyErr_SetString(PyExc_ValueError, "end is out of bounds");
+ goto bail;
+ }
while (1) {
/* Find the end of the string or the next escape */
Py_UNICODE c = 0;
@@ -245,7 +249,7 @@
break;
}
else if (strict && c <= 0x1f) {
- raise_errmsg("Invalid control character at", pystr, begin);
+ raise_errmsg("Invalid control character at", pystr, next);
goto bail;
}
}
@@ -396,6 +400,10 @@
if (chunks == NULL) {
goto bail;
}
+ if (end < 0 || len <= end) {
+ PyErr_SetString(PyExc_ValueError, "end is out of bounds");
+ goto bail;
+ }
while (1) {
/* Find the end of the string or the next escape */
Py_UNICODE c = 0;
@@ -406,7 +414,7 @@
break;
}
else if (strict && c <= 0x1f) {
- raise_errmsg("Invalid control character at", pystr, begin);
+ raise_errmsg("Invalid control character at", pystr, next);
goto bail;
}
}
Modified: python/branches/tlee-ast-optimize/Modules/_localemodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_localemodule.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_localemodule.c Sun Jul 20 17:31:08 2008
@@ -301,7 +301,9 @@
if (!PyUnicode_Check(os2)) {
os2 = PyUnicode_FromObject(os2);
if (!os2) {
- Py_DECREF(os1);
+ if (rel1) {
+ Py_DECREF(os1);
+ }
return NULL;
}
rel2 = 1;
@@ -586,7 +588,7 @@
PyIntl_gettext(PyObject* self, PyObject *args)
{
char *in;
- if (!PyArg_ParseTuple(args, "z", &in))
+ if (!PyArg_ParseTuple(args, "s", &in))
return 0;
return PyString_FromString(gettext(in));
}
@@ -599,7 +601,7 @@
PyIntl_dgettext(PyObject* self, PyObject *args)
{
char *domain, *in;
- if (!PyArg_ParseTuple(args, "zz", &domain, &in))
+ if (!PyArg_ParseTuple(args, "zs", &domain, &in))
return 0;
return PyString_FromString(dgettext(domain, in));
}
@@ -613,7 +615,7 @@
{
char *domain, *msgid;
int category;
- if (!PyArg_ParseTuple(args, "zzi", &domain, &msgid, &category))
+ if (!PyArg_ParseTuple(args, "zsi", &domain, &msgid, &category))
return 0;
return PyString_FromString(dcgettext(domain,msgid,category));
}
@@ -643,9 +645,13 @@
static PyObject*
PyIntl_bindtextdomain(PyObject* self,PyObject*args)
{
- char *domain,*dirname;
- if (!PyArg_ParseTuple(args, "zz", &domain, &dirname))
+ char *domain, *dirname;
+ if (!PyArg_ParseTuple(args, "sz", &domain, &dirname))
return 0;
+ if (!strlen(domain)) {
+ PyErr_SetString(Error, "domain must be a non-empty string");
+ return 0;
+ }
dirname = bindtextdomain(domain, dirname);
if (!dirname) {
PyErr_SetFromErrno(PyExc_OSError);
Modified: python/branches/tlee-ast-optimize/PC/_subprocess.c
==============================================================================
--- python/branches/tlee-ast-optimize/PC/_subprocess.c (original)
+++ python/branches/tlee-ast-optimize/PC/_subprocess.c Sun Jul 20 17:31:08 2008
@@ -69,6 +69,14 @@
return (PyObject*) self;
}
+#if defined(MS_WIN32) && !defined(MS_WIN64)
+#define HANDLE_TO_PYNUM(handle) PyInt_FromLong((long) handle)
+#define PY_HANDLE_PARAM "l"
+#else
+#define HANDLE_TO_PYNUM(handle) PyLong_FromLongLong((long long) handle)
+#define PY_HANDLE_PARAM "L"
+#endif
+
static PyObject*
sp_handle_detach(sp_handle_object* self, PyObject* args)
{
@@ -82,7 +90,7 @@
self->handle = NULL;
/* note: return the current handle, as an integer */
- return PyInt_FromLong((long) handle);
+ return HANDLE_TO_PYNUM(handle);
}
static PyObject*
@@ -122,7 +130,7 @@
static PyObject*
sp_handle_as_int(sp_handle_object* self)
{
- return PyInt_FromLong((long) self->handle);
+ return HANDLE_TO_PYNUM(self->handle);
}
static PyNumberMethods sp_handle_as_number;
@@ -168,7 +176,7 @@
}
/* note: returns integer, not handle object */
- return PyInt_FromLong((long) handle);
+ return HANDLE_TO_PYNUM(handle);
}
static PyObject *
@@ -186,14 +194,16 @@
HANDLE target_handle;
BOOL result;
- long source_process_handle;
- long source_handle;
- long target_process_handle;
+ HANDLE source_process_handle;
+ HANDLE source_handle;
+ HANDLE target_process_handle;
int desired_access;
int inherit_handle;
int options = 0;
- if (! PyArg_ParseTuple(args, "lllii|i:DuplicateHandle",
+ if (! PyArg_ParseTuple(args,
+ PY_HANDLE_PARAM PY_HANDLE_PARAM PY_HANDLE_PARAM
+ "ii|i:DuplicateHandle",
&source_process_handle,
&source_handle,
&target_process_handle,
@@ -204,9 +214,9 @@
Py_BEGIN_ALLOW_THREADS
result = DuplicateHandle(
- (HANDLE) source_process_handle,
- (HANDLE) source_handle,
- (HANDLE) target_process_handle,
+ source_process_handle,
+ source_handle,
+ target_process_handle,
&target_handle,
desired_access,
inherit_handle,
@@ -436,13 +446,13 @@
{
BOOL result;
- long process;
+ HANDLE process;
int exit_code;
- if (! PyArg_ParseTuple(args, "li:TerminateProcess", &process,
- &exit_code))
+ if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM "i:TerminateProcess",
+ &process, &exit_code))
return NULL;
- result = TerminateProcess((HANDLE) process, exit_code);
+ result = TerminateProcess(process, exit_code);
if (! result)
return PyErr_SetFromWindowsErr(GetLastError());
@@ -457,11 +467,11 @@
DWORD exit_code;
BOOL result;
- long process;
- if (! PyArg_ParseTuple(args, "l:GetExitCodeProcess", &process))
+ HANDLE process;
+ if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM ":GetExitCodeProcess", &process))
return NULL;
- result = GetExitCodeProcess((HANDLE) process, &exit_code);
+ result = GetExitCodeProcess(process, &exit_code);
if (! result)
return PyErr_SetFromWindowsErr(GetLastError());
@@ -474,15 +484,15 @@
{
DWORD result;
- long handle;
+ HANDLE handle;
int milliseconds;
- if (! PyArg_ParseTuple(args, "li:WaitForSingleObject",
+ if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM "i:WaitForSingleObject",
&handle,
&milliseconds))
return NULL;
Py_BEGIN_ALLOW_THREADS
- result = WaitForSingleObject((HANDLE) handle, (DWORD) milliseconds);
+ result = WaitForSingleObject(handle, (DWORD) milliseconds);
Py_END_ALLOW_THREADS
if (result == WAIT_FAILED)
@@ -504,13 +514,14 @@
sp_GetModuleFileName(PyObject* self, PyObject* args)
{
BOOL result;
- long module;
+ HMODULE module;
TCHAR filename[MAX_PATH];
- if (! PyArg_ParseTuple(args, "l:GetModuleFileName", &module))
+ if (! PyArg_ParseTuple(args, PY_HANDLE_PARAM ":GetModuleFileName",
+ &module))
return NULL;
- result = GetModuleFileName((HMODULE)module, filename, MAX_PATH);
+ result = GetModuleFileName(module, filename, MAX_PATH);
filename[MAX_PATH-1] = '\0';
if (! result)
Modified: python/branches/tlee-ast-optimize/Python/pystrtod.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/pystrtod.c (original)
+++ python/branches/tlee-ast-optimize/Python/pystrtod.c Sun Jul 20 17:31:08 2008
@@ -302,6 +302,10 @@
/* search for the first non-digit character */
char *p = buffer;
+ if (*p == '-' || *p == '+')
+ /* Skip leading sign, if present. I think this could only
+ ever be '-', but it can't hurt to check for both. */
+ ++p;
while (*p && isdigit(Py_CHARMASK(*p)))
++p;
Modified: python/branches/tlee-ast-optimize/Python/pythonrun.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/pythonrun.c (original)
+++ python/branches/tlee-ast-optimize/Python/pythonrun.c Sun Jul 20 17:31:08 2008
@@ -1595,10 +1595,10 @@
case E_INTR:
if (!PyErr_Occurred())
PyErr_SetNone(PyExc_KeyboardInterrupt);
- return;
+ goto cleanup;
case E_NOMEM:
PyErr_NoMemory();
- return;
+ goto cleanup;
case E_EOF:
msg = "unexpected EOF while parsing";
break;
@@ -1643,10 +1643,6 @@
}
v = Py_BuildValue("(ziiz)", err->filename,
err->lineno, err->offset, err->text);
- if (err->text != NULL) {
- PyObject_FREE(err->text);
- err->text = NULL;
- }
w = NULL;
if (v != NULL)
w = Py_BuildValue("(sO)", msg, v);
@@ -1654,6 +1650,11 @@
Py_XDECREF(v);
PyErr_SetObject(errtype, w);
Py_XDECREF(w);
+cleanup:
+ if (err->text != NULL) {
+ PyObject_FREE(err->text);
+ err->text = NULL;
+ }
}
/* Print fatal error message and abort */
More information about the Python-checkins
mailing list