[Python-checkins] r67447 - in python/branches/tlee-ast-optimize: Doc/c-api/arg.rst Doc/conf.py Doc/howto/unicode.rst Doc/includes/mp_benchmarks.py Doc/includes/mp_distributing.py Doc/includes/mp_newtype.py Doc/includes/mp_pool.py Doc/includes/mp_synchronize.py Doc/includes/mp_webserver.py Doc/includes/mp_workers.py Doc/library/bdb.rst Doc/library/collections.rst Doc/library/ctypes.rst Doc/library/httplib.rst Doc/library/io.rst Doc/library/locale.rst Doc/library/multiprocessing.rst Doc/library/os.rst Doc/library/pdb.rst Doc/library/sqlite3.rst Doc/library/stringio.rst Doc/library/sys.rst Doc/reference/datamodel.rst Doc/tools/sphinxext/download.html Lib/asyncore.py Lib/distutils/msvc9compiler.py Lib/doctest.py Lib/httplib.py Lib/io.py Lib/lib-tk/turtle.py Lib/lib2to3 Lib/lib2to3/fixer_base.py Lib/lib2to3/fixer_util.py Lib/lib2to3/fixes/fix_dict.py Lib/lib2to3/fixes/fix_except.py Lib/lib2to3/fixes/fix_import.py Lib/lib2to3/fixes/fix_imports.py Lib/lib2to3/fixes/fix_imports2.py Lib/lib2to3/fixes/fix_metaclass.py Lib/lib2to3/fixes/fix_next.py Lib/lib2to3/fixes/fix_numliterals.py Lib/lib2to3/fixes/fix_renames.py Lib/lib2to3/fixes/fix_urllib.py Lib/lib2to3/pgen2/parse.py Lib/lib2to3/pytree.py Lib/lib2to3/refactor.py Lib/lib2to3/tests Lib/lib2to3/tests/data Lib/lib2to3/tests/data/fixers Lib/lib2to3/tests/data/fixers/myfixes Lib/lib2to3/tests/test_fixers.py Lib/lib2to3/tests/test_refactor.py Lib/multiprocessing/__init__.py Lib/multiprocessing/pool.py Lib/optparse.py Lib/test/test_bytes.py Lib/test/test_descr.py Lib/test/test_fileio.py Lib/test/test_httplib.py Lib/test/test_imageop.py Lib/test/test_io.py Lib/test/test_parser.py Lib/test/test_unicodedata.py Lib/test/test_xmlrpc.py Lib/uuid.py Lib/xmlrpclib.py Misc/NEWS Modules/Setup.dist Modules/_fileio.c Modules/_multiprocessing/semaphore.c Modules/imageop.c Modules/parsermodule.c Objects/bytearrayobject.c Objects/typeobject.c Objects/unicodeobject.c PC/VC6/pythoncore.dsp PC/VS7.1/pythoncore.vcproj PC/VS8.0/pythoncore.vcproj PC/os2vacpp/makefile PC/os2vacpp/makefile.omk PCbuild/pythoncore.vcproj Python/ast.c Python/pythonrun.c Tools/msi/msi.py Tools/scripts/svneol.py configure configure.in
thomas.lee
python-checkins at python.org
Sun Nov 30 09:29:54 CET 2008
Author: thomas.lee
Date: Sun Nov 30 09:29:52 2008
New Revision: 67447
Log:
Merged revisions 67189,67224-67227,67234,67243,67245-67246,67266,67277-67279,67283,67287,67289,67291,67295,67301-67303,67307,67318,67320,67326,67330,67332,67336,67342-67343,67348-67349,67353,67355,67359,67362,67364-67365,67367-67368,67370,67373,67376,67396,67398,67407,67411,67414,67419,67423-67424,67428,67432,67440-67442,67444-67445 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67189 | benjamin.peterson | 2008-11-12 08:56:06 +1100 (Wed, 12 Nov 2008) | 1 line
use correct name
................
r67224 | georg.brandl | 2008-11-15 19:10:04 +1100 (Sat, 15 Nov 2008) | 2 lines
#4324: fix getlocale() argument.
................
r67225 | brett.cannon | 2008-11-16 09:33:25 +1100 (Sun, 16 Nov 2008) | 1 line
Clarify the docs for the 'strict' argument to httplib.HTTPConnection.
................
r67226 | brett.cannon | 2008-11-16 09:40:44 +1100 (Sun, 16 Nov 2008) | 4 lines
The docs for httplib.HTTPConnection.putheader() have claimed for quite a while
that their could be an arbitrary number of values passed in. Turns out the code
did not match that. The code now matches the docs.
................
r67227 | georg.brandl | 2008-11-16 19:00:17 +1100 (Sun, 16 Nov 2008) | 2 lines
#4316: fix configure.in markup problem.
................
r67234 | benjamin.peterson | 2008-11-17 04:54:55 +1100 (Mon, 17 Nov 2008) | 1 line
run autoconf
................
r67243 | benjamin.peterson | 2008-11-18 08:39:05 +1100 (Tue, 18 Nov 2008) | 1 line
a few fixes on the download page
................
r67245 | benjamin.peterson | 2008-11-18 09:05:19 +1100 (Tue, 18 Nov 2008) | 1 line
improve __hash__ docs
................
r67246 | benjamin.peterson | 2008-11-18 09:39:09 +1100 (Tue, 18 Nov 2008) | 5 lines
when __getattr__ is a descriptor, call it correctly; fixes #4230
patch from Ziga Seilnacht
................
r67266 | amaury.forgeotdarc | 2008-11-19 09:19:37 +1100 (Wed, 19 Nov 2008) | 4 lines
#4317: Fix an Array Bounds Read in imageop.rgb2rgb8.
Will backport to 2.4.
................
r67277 | skip.montanaro | 2008-11-19 14:35:41 +1100 (Wed, 19 Nov 2008) | 1 line
patch from issue 1108
................
r67278 | georg.brandl | 2008-11-19 18:59:09 +1100 (Wed, 19 Nov 2008) | 2 lines
Try to fix problems with verbatim.
................
r67279 | martin.v.loewis | 2008-11-19 20:09:41 +1100 (Wed, 19 Nov 2008) | 2 lines
Issue #4116: Resolve member name conflict in ScrolledCanvas.__init__
................
r67283 | martin.v.loewis | 2008-11-20 00:51:44 +1100 (Thu, 20 Nov 2008) | 1 line
Issue #4289: Remove Cancel button from AdvancedDlg.
................
r67287 | josiah.carlson | 2008-11-20 05:26:12 +1100 (Thu, 20 Nov 2008) | 2 lines
Fix for issue 4332 in trunk.
................
r67289 | brett.cannon | 2008-11-20 07:29:39 +1100 (Thu, 20 Nov 2008) | 2 lines
Ignore .pyc and .pyo files.
................
r67291 | benjamin.peterson | 2008-11-20 08:49:09 +1100 (Thu, 20 Nov 2008) | 5 lines
make sure that bytearray methods return a new bytearray even if there is no change
Fixes #4348
Reviewed by Brett
................
r67295 | benjamin.peterson | 2008-11-20 15:05:12 +1100 (Thu, 20 Nov 2008) | 1 line
move useful sys.settrace information to the function's documentation from the debugger
................
r67301 | benjamin.peterson | 2008-11-21 08:25:31 +1100 (Fri, 21 Nov 2008) | 1 line
fix indentation and a sphinx warning
................
r67302 | benjamin.peterson | 2008-11-21 08:44:23 +1100 (Fri, 21 Nov 2008) | 1 line
oops! didn't mean to disable that test
................
r67303 | benjamin.peterson | 2008-11-21 09:06:22 +1100 (Fri, 21 Nov 2008) | 1 line
backport r67300
................
r67307 | amaury.forgeotdarc | 2008-11-21 10:34:31 +1100 (Fri, 21 Nov 2008) | 9 lines
Fixed issue #4233.
Changed semantic of _fileio.FileIO's close() method on file objects with closefd=False.
The file descriptor is still kept open but the file object behaves like a closed file.
The FileIO object also got a new readonly attribute closefd.
Approved by Barry
Backport of r67106 from the py3k branch
................
r67318 | amaury.forgeotdarc | 2008-11-22 09:05:48 +1100 (Sat, 22 Nov 2008) | 4 lines
#4363: Let uuid.uuid1() and uuid.uuid4() run even if the ctypes module is not present.
Will backport to 2.6
................
r67320 | benjamin.peterson | 2008-11-22 09:27:24 +1100 (Sat, 22 Nov 2008) | 4 lines
don't segfault when \N escapes are used and unicodedata fails to load
Fixes #4367
................
r67326 | benjamin.peterson | 2008-11-22 12:59:15 +1100 (Sat, 22 Nov 2008) | 1 line
backport r67325: make FileIO.mode always contain 'b'
................
r67330 | georg.brandl | 2008-11-22 19:34:14 +1100 (Sat, 22 Nov 2008) | 2 lines
#4364: fix attribute name on ctypes object.
................
r67332 | georg.brandl | 2008-11-22 19:45:33 +1100 (Sat, 22 Nov 2008) | 2 lines
Fix typo.
................
r67336 | georg.brandl | 2008-11-22 21:08:50 +1100 (Sat, 22 Nov 2008) | 2 lines
Fix error about "-*-" being mandatory in coding cookies.
................
r67342 | amaury.forgeotdarc | 2008-11-23 06:39:38 +1100 (Sun, 23 Nov 2008) | 3 lines
yuvconvert.c is a part of the "sv" module, an old IRIX thing
and certainly not useful for any Windows build.
................
r67343 | amaury.forgeotdarc | 2008-11-23 07:01:18 +1100 (Sun, 23 Nov 2008) | 5 lines
#3996: On Windows, PyOS_CheckStack is supposed to protect the interpreter from
stack overflow. But doing this, it always crashes when the stack is nearly full.
Reviewed by Martin von Loewis. Will backport to 2.6.
................
r67348 | benjamin.peterson | 2008-11-23 13:09:41 +1100 (Sun, 23 Nov 2008) | 1 line
raise a better error
................
r67349 | matthias.klose | 2008-11-24 00:37:03 +1100 (Mon, 24 Nov 2008) | 3 lines
- Modules/Setup.dist: Mention _functools in section "Modules that should
always be present (non UNIX dependent)"
................
r67353 | matthias.klose | 2008-11-24 00:54:42 +1100 (Mon, 24 Nov 2008) | 2 lines
- Fix typo in last checkin
................
r67355 | georg.brandl | 2008-11-24 06:17:25 +1100 (Mon, 24 Nov 2008) | 2 lines
#4392: fix parameter name.
................
r67359 | georg.brandl | 2008-11-24 08:57:30 +1100 (Mon, 24 Nov 2008) | 2 lines
#4399: fix typo.
................
r67362 | gregory.p.smith | 2008-11-24 11:41:43 +1100 (Mon, 24 Nov 2008) | 2 lines
Document PY_SSIZE_T_CLEAN for PyArg_ParseTuple.
................
r67364 | benjamin.peterson | 2008-11-24 12:16:29 +1100 (Mon, 24 Nov 2008) | 2 lines
replace reference to debugger-hooks
................
r67365 | benjamin.peterson | 2008-11-24 15:09:03 +1100 (Mon, 24 Nov 2008) | 1 line
#4396 make the parser module correctly validate the with syntax
................
r67367 | georg.brandl | 2008-11-25 03:16:07 +1100 (Tue, 25 Nov 2008) | 2 lines
Fix typo.
................
r67368 | georg.brandl | 2008-11-25 06:56:47 +1100 (Tue, 25 Nov 2008) | 2 lines
#4404: make clear what "path" is.
................
r67370 | jeremy.hylton | 2008-11-25 09:00:29 +1100 (Tue, 25 Nov 2008) | 8 lines
Add unittests that verify documented behavior of public methods in Transport
class.
These methods can be overridden. The tests verify that the overridden
methods are called, and that changes to the connection have a visible
effect on the request.
................
r67373 | benjamin.peterson | 2008-11-25 14:43:14 +1100 (Tue, 25 Nov 2008) | 2 lines
always check the return value of NEW_IDENTIFIER
................
r67376 | benjamin.peterson | 2008-11-25 15:07:45 +1100 (Tue, 25 Nov 2008) | 17 lines
Merged revisions 67183,67191,67371 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67183 | benjamin.peterson | 2008-11-10 21:51:33 -0600 (Mon, 10 Nov 2008) | 1 line
handle 'import x as y' in fix_imports; this still needs more work...
........
r67191 | benjamin.peterson | 2008-11-11 17:24:51 -0600 (Tue, 11 Nov 2008) | 1 line
super() is good
........
r67371 | benjamin.peterson | 2008-11-24 16:02:00 -0600 (Mon, 24 Nov 2008) | 1 line
don't blow up in the metaclass fixer when assignments in the class statement aren't simple
........
................
r67396 | matthias.klose | 2008-11-27 04:32:49 +1100 (Thu, 27 Nov 2008) | 2 lines
- Modules/Setup.dist: Mention _elementtree and _pickle.
................
r67398 | benjamin.peterson | 2008-11-27 04:39:17 +1100 (Thu, 27 Nov 2008) | 1 line
fix typo in sqlite3 docs
................
r67407 | matthias.klose | 2008-11-27 18:45:25 +1100 (Thu, 27 Nov 2008) | 2 lines
- Modules/Setup.dist: Update pyexpat
................
r67411 | matthias.klose | 2008-11-27 21:14:22 +1100 (Thu, 27 Nov 2008) | 2 lines
- Modules/Setup.dist: Update _elementtree, add _bisect, datetime
................
r67414 | christian.heimes | 2008-11-28 22:02:32 +1100 (Fri, 28 Nov 2008) | 1 line
Fixed issue ##3741: DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an exception
................
r67419 | jesse.noller | 2008-11-29 05:22:54 +1100 (Sat, 29 Nov 2008) | 2 lines
mp docs - fix issues 4012,3518,4193
................
r67423 | jesse.noller | 2008-11-29 05:59:35 +1100 (Sat, 29 Nov 2008) | 2 lines
issue4238: bsd support for cpu_count
................
r67424 | christian.heimes | 2008-11-29 06:33:33 +1100 (Sat, 29 Nov 2008) | 1 line
Retain copyright of processing examples. This was requested by a Debian maintainer during packaging of the multiprocessing package for 2.4/2.5
................
r67428 | benjamin.peterson | 2008-11-29 09:12:14 +1100 (Sat, 29 Nov 2008) | 57 lines
Merged revisions 67384,67386-67387,67389-67390,67392,67399-67400,67403-67405,67426 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67384 | benjamin.peterson | 2008-11-25 16:13:31 -0600 (Tue, 25 Nov 2008) | 4 lines
don't duplicate calls to start_tree()
RefactoringTool.pre_order values now holds a list of the fixers while pre_order_mapping holds the dict.
........
r67386 | benjamin.peterson | 2008-11-25 16:44:52 -0600 (Tue, 25 Nov 2008) | 1 line
#4423 fix_imports was still replacing usage of a module if attributes were being used
........
r67387 | benjamin.peterson | 2008-11-25 16:47:54 -0600 (Tue, 25 Nov 2008) | 1 line
fix broken test
........
r67389 | benjamin.peterson | 2008-11-25 17:13:17 -0600 (Tue, 25 Nov 2008) | 1 line
remove compatibility code; we only cater to 2.5+
........
r67390 | benjamin.peterson | 2008-11-25 22:03:36 -0600 (Tue, 25 Nov 2008) | 1 line
fix #3994; the usage of changed imports was fixed in nested cases
........
r67392 | benjamin.peterson | 2008-11-26 11:11:40 -0600 (Wed, 26 Nov 2008) | 1 line
simpilfy and comment fix_imports
........
r67399 | benjamin.peterson | 2008-11-26 11:47:03 -0600 (Wed, 26 Nov 2008) | 1 line
remove more compatibility code
........
r67400 | benjamin.peterson | 2008-11-26 12:07:41 -0600 (Wed, 26 Nov 2008) | 1 line
set svn:ignore
........
r67403 | benjamin.peterson | 2008-11-26 13:11:11 -0600 (Wed, 26 Nov 2008) | 1 line
wrap import
........
r67404 | benjamin.peterson | 2008-11-26 13:29:49 -0600 (Wed, 26 Nov 2008) | 1 line
build the fix_imports pattern in compile_pattern, so MAPPING can be changed and reflected in the pattern
........
r67405 | benjamin.peterson | 2008-11-26 14:01:24 -0600 (Wed, 26 Nov 2008) | 1 line
stop ugly messages about runtime errors being from printed
........
r67426 | benjamin.peterson | 2008-11-28 16:01:40 -0600 (Fri, 28 Nov 2008) | 5 lines
don't replace a module name if it is in the middle of a attribute lookup
This fix also stops module names from being replaced if they are not in an attribute lookup.
........
................
r67432 | benjamin.peterson | 2008-11-29 10:18:46 +1100 (Sat, 29 Nov 2008) | 1 line
SVN format 9 is the same it seems
................
r67440 | jeremy.hylton | 2008-11-29 10:42:59 +1100 (Sat, 29 Nov 2008) | 4 lines
Move definition int sval into branch of ifdef where it is used.
Otherwise, you get a warning about an undefined variable.
................
r67441 | jeremy.hylton | 2008-11-29 11:09:16 +1100 (Sat, 29 Nov 2008) | 2 lines
Reflow long lines.
................
r67442 | jeremy.hylton | 2008-11-29 12:09:35 +1100 (Sat, 29 Nov 2008) | 18 lines
Send HTTP headers and message body in a single send() call.
This change addresses part of issue 4336.
Change endheaders() to take an optional message_body argument
that is sent along with the headers. Change xmlrpclib and
httplib's other methods to use this new interface.
It is more efficient to make a single send() call, which should
get the entire client request into one packet (assuming it is
smaller than the MTU) and will avoid the long pause for delayed
ack following timeout.
Also:
- Add a comment about the buffer size for makefile().
- Extract _set_content_length() method and fix whitespace issues there.
................
r67444 | amaury.forgeotdarc | 2008-11-29 13:03:32 +1100 (Sat, 29 Nov 2008) | 2 lines
Fix a small typo in docstring
................
r67445 | benjamin.peterson | 2008-11-30 14:07:33 +1100 (Sun, 30 Nov 2008) | 1 line
StringIO.close() stops you from using the buffer, too
................
Modified:
python/branches/tlee-ast-optimize/ (props changed)
python/branches/tlee-ast-optimize/Doc/c-api/arg.rst
python/branches/tlee-ast-optimize/Doc/conf.py
python/branches/tlee-ast-optimize/Doc/howto/unicode.rst
python/branches/tlee-ast-optimize/Doc/includes/mp_benchmarks.py
python/branches/tlee-ast-optimize/Doc/includes/mp_distributing.py
python/branches/tlee-ast-optimize/Doc/includes/mp_newtype.py
python/branches/tlee-ast-optimize/Doc/includes/mp_pool.py
python/branches/tlee-ast-optimize/Doc/includes/mp_synchronize.py
python/branches/tlee-ast-optimize/Doc/includes/mp_webserver.py
python/branches/tlee-ast-optimize/Doc/includes/mp_workers.py
python/branches/tlee-ast-optimize/Doc/library/bdb.rst
python/branches/tlee-ast-optimize/Doc/library/collections.rst
python/branches/tlee-ast-optimize/Doc/library/ctypes.rst
python/branches/tlee-ast-optimize/Doc/library/httplib.rst
python/branches/tlee-ast-optimize/Doc/library/io.rst
python/branches/tlee-ast-optimize/Doc/library/locale.rst
python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst
python/branches/tlee-ast-optimize/Doc/library/os.rst
python/branches/tlee-ast-optimize/Doc/library/pdb.rst
python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst
python/branches/tlee-ast-optimize/Doc/library/stringio.rst
python/branches/tlee-ast-optimize/Doc/library/sys.rst
python/branches/tlee-ast-optimize/Doc/reference/datamodel.rst
python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html
python/branches/tlee-ast-optimize/Lib/asyncore.py
python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py
python/branches/tlee-ast-optimize/Lib/doctest.py
python/branches/tlee-ast-optimize/Lib/httplib.py
python/branches/tlee-ast-optimize/Lib/io.py
python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py
python/branches/tlee-ast-optimize/Lib/lib2to3/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_base.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_util.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_dict.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_except.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_import.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports2.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_next.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_numliterals.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_renames.py
python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_urllib.py
python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/parse.py
python/branches/tlee-ast-optimize/Lib/lib2to3/pytree.py
python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/data/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/data/fixers/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/data/fixers/myfixes/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_fixers.py
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_refactor.py
python/branches/tlee-ast-optimize/Lib/multiprocessing/__init__.py
python/branches/tlee-ast-optimize/Lib/multiprocessing/pool.py
python/branches/tlee-ast-optimize/Lib/optparse.py
python/branches/tlee-ast-optimize/Lib/test/test_bytes.py
python/branches/tlee-ast-optimize/Lib/test/test_descr.py
python/branches/tlee-ast-optimize/Lib/test/test_fileio.py
python/branches/tlee-ast-optimize/Lib/test/test_httplib.py
python/branches/tlee-ast-optimize/Lib/test/test_imageop.py
python/branches/tlee-ast-optimize/Lib/test/test_io.py
python/branches/tlee-ast-optimize/Lib/test/test_parser.py
python/branches/tlee-ast-optimize/Lib/test/test_unicodedata.py
python/branches/tlee-ast-optimize/Lib/test/test_xmlrpc.py
python/branches/tlee-ast-optimize/Lib/uuid.py
python/branches/tlee-ast-optimize/Lib/xmlrpclib.py
python/branches/tlee-ast-optimize/Misc/NEWS
python/branches/tlee-ast-optimize/Modules/Setup.dist
python/branches/tlee-ast-optimize/Modules/_fileio.c
python/branches/tlee-ast-optimize/Modules/_multiprocessing/semaphore.c
python/branches/tlee-ast-optimize/Modules/imageop.c
python/branches/tlee-ast-optimize/Modules/parsermodule.c
python/branches/tlee-ast-optimize/Objects/bytearrayobject.c
python/branches/tlee-ast-optimize/Objects/typeobject.c
python/branches/tlee-ast-optimize/Objects/unicodeobject.c
python/branches/tlee-ast-optimize/PC/VC6/pythoncore.dsp
python/branches/tlee-ast-optimize/PC/VS7.1/pythoncore.vcproj
python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj
python/branches/tlee-ast-optimize/PC/os2vacpp/makefile
python/branches/tlee-ast-optimize/PC/os2vacpp/makefile.omk
python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj
python/branches/tlee-ast-optimize/Python/ast.c
python/branches/tlee-ast-optimize/Python/pythonrun.c
python/branches/tlee-ast-optimize/Tools/msi/msi.py
python/branches/tlee-ast-optimize/Tools/scripts/svneol.py
python/branches/tlee-ast-optimize/configure
python/branches/tlee-ast-optimize/configure.in
Modified: python/branches/tlee-ast-optimize/Doc/c-api/arg.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/c-api/arg.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/c-api/arg.rst Sun Nov 30 09:29:52 2008
@@ -32,7 +32,7 @@
converted to C strings using the default encoding. If this conversion fails, a
:exc:`UnicodeError` is raised.
-``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int]
+``s#`` (string, Unicode or any read buffer compatible object) [const char \*, int (or :ctype:`Py_ssize_t`, see below)]
This variant on ``s`` stores into two C variables, the first one a pointer to a
character string, the second one its length. In this case the Python string may
contain embedded null bytes. Unicode objects pass back a pointer to the default
@@ -40,6 +40,11 @@
other read-buffer compatible objects pass back a reference to the raw internal
data representation.
+ Starting with Python 2.5 the type of the length argument can be
+ controlled by defining the macro :cmacro:`PY_SSIZE_T_CLEAN` before
+ including :file:`Python.h`. If the macro is defined, length is a
+ :ctype:`Py_ssize_t` rather than an int.
+
``s*`` (string, Unicode, or any buffer compatible object) [Py_buffer \*]
Similar to ``s#``, this code fills a Py_buffer structure provided by the caller.
The buffer gets locked, so that the caller can subsequently use the buffer even
Modified: python/branches/tlee-ast-optimize/Doc/conf.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/conf.py (original)
+++ python/branches/tlee-ast-optimize/Doc/conf.py Sun Nov 30 09:29:52 2008
@@ -138,6 +138,8 @@
\strong{Python Software Foundation}\\
Email: \email{docs at python.org}
}
+\let\Verbatim=\OriginalVerbatim
+\let\endVerbatim=\endOriginalVerbatim
'''
# Documents to append as an appendix to all manuals.
Modified: python/branches/tlee-ast-optimize/Doc/howto/unicode.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/howto/unicode.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/howto/unicode.rst Sun Nov 30 09:29:52 2008
@@ -410,9 +410,9 @@
The syntax is inspired by Emacs's notation for specifying variables local to a
file. Emacs supports many different variables, but Python only supports
-'coding'. The ``-*-`` symbols indicate that the comment is special; within
-them, you must supply the name ``coding`` and the name of your chosen encoding,
-separated by ``':'``.
+'coding'. The ``-*-`` symbols indicate to Emacs that the comment is special;
+they have no significance to Python but are a convention. Python looks for
+``coding: name`` or ``coding=name`` in the comment.
If you don't include such a comment, the default encoding used will be ASCII.
Versions of Python before 2.4 were Euro-centric and assumed Latin-1 as a default
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_benchmarks.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_benchmarks.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_benchmarks.py Sun Nov 30 09:29:52 2008
@@ -1,6 +1,9 @@
#
# Simple benchmarks for the multiprocessing package
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
import time, sys, multiprocessing, threading, Queue, gc
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_distributing.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_distributing.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_distributing.py Sun Nov 30 09:29:52 2008
@@ -3,6 +3,9 @@
#
# Depends on `multiprocessing` package -- tested with `processing-0.60`
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
__all__ = ['Cluster', 'Host', 'get_logger', 'current_process']
@@ -37,7 +40,6 @@
_logger = logging.getLogger('distributing')
_logger.propogate = 0
-util.fix_up_logger(_logger)
_formatter = logging.Formatter(util.DEFAULT_LOGGING_FORMAT)
_handler = logging.StreamHandler()
_handler.setFormatter(_formatter)
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_newtype.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_newtype.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_newtype.py Sun Nov 30 09:29:52 2008
@@ -2,6 +2,9 @@
# This module shows how to use arbitrary callables with a subclass of
# `BaseManager`.
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
from multiprocessing import freeze_support
from multiprocessing.managers import BaseManager, BaseProxy
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_pool.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_pool.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_pool.py Sun Nov 30 09:29:52 2008
@@ -1,6 +1,9 @@
#
# A test of `multiprocessing.Pool` class
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
import multiprocessing
import time
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_synchronize.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_synchronize.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_synchronize.py Sun Nov 30 09:29:52 2008
@@ -1,6 +1,9 @@
#
# A test file for the `multiprocessing` package
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
import time, sys, random
from Queue import Empty
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_webserver.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_webserver.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_webserver.py Sun Nov 30 09:29:52 2008
@@ -8,6 +8,9 @@
# Not sure if we should synchronize access to `socket.accept()` method by
# using a process-shared lock -- does not seem to be necessary.
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
import os
import sys
Modified: python/branches/tlee-ast-optimize/Doc/includes/mp_workers.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/includes/mp_workers.py (original)
+++ python/branches/tlee-ast-optimize/Doc/includes/mp_workers.py Sun Nov 30 09:29:52 2008
@@ -7,6 +7,9 @@
# in the original order then consider using `Pool.map()` or
# `Pool.imap()` (which will save on the amount of code needed anyway).
#
+# Copyright (c) 2006-2008, R Oudkerk
+# All rights reserved.
+#
import time
import random
Modified: python/branches/tlee-ast-optimize/Doc/library/bdb.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/bdb.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/bdb.rst Sun Nov 30 09:29:52 2008
@@ -107,8 +107,9 @@
The *arg* parameter depends on the previous event.
- For more information on trace functions, see :ref:`debugger-hooks`. For
- more information on code and frame objects, refer to :ref:`types`.
+ See the documentation for :func:`sys.settrace` for more information on the
+ trace function. For more information on code and frame objects, refer to
+ :ref:`types`.
.. method:: dispatch_line(frame)
Modified: python/branches/tlee-ast-optimize/Doc/library/collections.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/collections.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/collections.rst Sun Nov 30 09:29:52 2008
@@ -60,7 +60,7 @@
:class:`Iterable`, and ``__len__`` ``index``, and ``count``
:class:`Container`
-:class:`MutableSequnce` :class:`Sequence` ``__getitem__`` Inherited Sequence methods and
+:class:`MutableSequence` :class:`Sequence` ``__getitem__`` Inherited Sequence methods and
``__delitem__``, ``append``, ``reverse``, ``extend``, ``pop``,
``insert``, ``remove``, and ``__iadd__``
and ``__len__``
@@ -487,16 +487,16 @@
self-documenting code. They can be used wherever regular tuples are used, and
they add the ability to access fields by name instead of position index.
-.. function:: namedtuple(typename, fieldnames, [verbose])
+.. function:: namedtuple(typename, field_names, [verbose])
Returns a new tuple subclass named *typename*. The new subclass is used to
create tuple-like objects that have fields accessible by attribute lookup as
well as being indexable and iterable. Instances of the subclass also have a
- helpful docstring (with typename and fieldnames) and a helpful :meth:`__repr__`
+ helpful docstring (with typename and field_names) and a helpful :meth:`__repr__`
method which lists the tuple contents in a ``name=value`` format.
- The *fieldnames* are a single string with each fieldname separated by whitespace
- and/or commas, for example ``'x y'`` or ``'x, y'``. Alternatively, *fieldnames*
+ The *field_names* are a single string with each fieldname separated by whitespace
+ and/or commas, for example ``'x y'`` or ``'x, y'``. Alternatively, *field_names*
can be a sequence of strings such as ``['x', 'y']``.
Any valid Python identifier may be used for a fieldname except for names
Modified: python/branches/tlee-ast-optimize/Doc/library/ctypes.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/ctypes.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/ctypes.rst Sun Nov 30 09:29:52 2008
@@ -1370,7 +1370,7 @@
All these classes can be instantiated by calling them with at least one
argument, the pathname of the shared library. If you have an existing handle to
-an already loaded shard library, it can be passed as the ``handle`` named
+an already loaded shared library, it can be passed as the ``handle`` named
parameter, otherwise the underlying platforms ``dlopen`` or :meth:`LoadLibrary`
function is used to load the library into the process, and to get a handle to
it.
Modified: python/branches/tlee-ast-optimize/Doc/library/httplib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/httplib.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/httplib.rst Sun Nov 30 09:29:52 2008
@@ -40,7 +40,8 @@
server. It should be instantiated passing it a host and optional port
number. If no port number is passed, the port is extracted from the host
string if it has the form ``host:port``, else the default HTTP port (80) is
- used. When True, the optional parameter *strict* causes ``BadStatusLine`` to
+ used. When True, the optional parameter *strict* (which defaults to a false
+ value) causes ``BadStatusLine`` to
be raised if the status line can't be parsed as a valid HTTP/1.0 or 1.1
status line. If the optional *timeout* parameter is given, blocking
operations (like connection attempts) will timeout after that many seconds
Modified: python/branches/tlee-ast-optimize/Doc/library/io.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/io.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/io.rst Sun Nov 30 09:29:52 2008
@@ -214,8 +214,10 @@
.. method:: close()
- Flush and close this stream. This method has no effect if the file is
- already closed.
+ Flush and close this stream. This method has no effect if the file is
+ already closed. Once the file is closed, any operation on the file
+ (e.g. reading or writing) will raise an :exc:`IOError`. The internal
+ file descriptor isn't closed if *closefd* was False.
.. attribute:: closed
Modified: python/branches/tlee-ast-optimize/Doc/library/locale.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/locale.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/locale.rst Sun Nov 30 09:29:52 2008
@@ -492,7 +492,7 @@
Example::
>>> import locale
- >>> loc = locale.getlocale(locale.LC_ALL) # get current locale
+ >>> loc = locale.getlocale() # get current locale
>>> locale.setlocale(locale.LC_ALL, 'de_DE') # use German locale; name might vary with platform
>>> locale.strcoll('f\xe4n', 'foo') # compare a string containing an umlaut
>>> locale.setlocale(locale.LC_ALL, '') # use user's preferred locale
Modified: python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst Sun Nov 30 09:29:52 2008
@@ -26,6 +26,29 @@
import it will result in an :exc:`ImportError`. See
:issue:`3770` for additional information.
+.. note::
+
+ Functionality within this package requires that the ``__main__`` method be
+ importable by the children. This is covered in :ref:`multiprocessing-programming`
+ however it is worth pointing out here. This means that some examples, such
+ as the :class:`multiprocessing.Pool` examples will not work in the
+ interactive interpreter. For example::
+
+ >>> from multiprocessing import Pool
+ >>> p = Pool(5)
+ >>> def f(x):
+ ... return x*x
+ ...
+ >>> p.map(f, [1,2,3])
+ Process PoolWorker-1:
+ Process PoolWorker-2:
+ Traceback (most recent call last):
+ Traceback (most recent call last):
+ AttributeError: 'module' object has no attribute 'f'
+ AttributeError: 'module' object has no attribute 'f'
+ AttributeError: 'module' object has no attribute 'f'
+
+
The :class:`Process` class
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -34,17 +57,36 @@
follows the API of :class:`threading.Thread`. A trivial example of a
multiprocess program is ::
- from multiprocessing import Process
+ from multiprocessing import Process
- def f(name):
- print 'hello', name
+ def f(name):
+ print 'hello', name
- if __name__ == '__main__':
- p = Process(target=f, args=('bob',))
- p.start()
- p.join()
+ if __name__ == '__main__':
+ p = Process(target=f, args=('bob',))
+ p.start()
+ p.join()
-Here the function ``f`` is run in a child process.
+To show the individual process IDs involved, here is an expanded example::
+
+ from multiprocessing import Process
+ import os
+
+ def info(title):
+ print title
+ print 'module name:', __name__
+ print 'parent process:', os.getppid()
+ print 'process id:', os.getpid()
+
+ def f(name):
+ info('function f')
+ print 'hello', name
+
+ if __name__ == '__main__':
+ info('main line')
+ p = Process(target=f, args=('bob',))
+ p.start()
+ p.join()
For an explanation of why (on Windows) the ``if __name__ == '__main__'`` part is
necessary, see :ref:`multiprocessing-programming`.
@@ -234,7 +276,7 @@
if __name__ == '__main__':
pool = Pool(processes=4) # start 4 worker processes
- result = pool.applyAsync(f, [10]) # evaluate "f(10)" asynchronously
+ result = pool.apply_async(f, [10]) # evaluate "f(10)" asynchronously
print result.get(timeout=1) # prints "100" unless your computer is *very* slow
print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]"
@@ -307,7 +349,7 @@
semantics. Multiple processes may be given the same name. The initial
name is set by the constructor.
- .. method:: is_alive()
+ .. method:: is_alive
Return whether the process is alive.
@@ -816,6 +858,9 @@
acceptable. If *block* is ``True`` and *timeout* is not ``None`` then it
specifies a timeout in seconds. If *block* is ``False`` then *timeout* is
ignored.
+
+ Note that on OS/X ``sem_timedwait`` is unsupported, so timeout arguments
+ for these will be ignored.
.. note::
@@ -874,7 +919,7 @@
Note that *lock* is a keyword only argument.
- Note that an array of :data:`ctypes.c_char` has *value* and *rawvalue*
+ Note that an array of :data:`ctypes.c_char` has *value* and *raw*
attributes which allow one to use it to store and retrieve strings.
@@ -923,7 +968,7 @@
:func:`Value` instead to make sure that access is automatically synchronized
using a lock.
- Note that an array of :data:`ctypes.c_char` has ``value`` and ``rawvalue``
+ Note that an array of :data:`ctypes.c_char` has ``value`` and ``raw``
attributes which allow one to use it to store and retrieve strings -- see
documentation for :mod:`ctypes`.
@@ -1089,6 +1134,27 @@
A class method which creates a manager object referring to a pre-existing
server process which is using the given address and authentication key.
+ .. method:: get_server()
+
+ Returns a :class:`Server` object which represents the actual server under
+ the control of the Manager. The :class:`Server` object supports the
+ :meth:`serve_forever` method::
+
+ >>> from multiprocessing.managers import BaseManager
+ >>> m = BaseManager(address=('', 50000), authkey='abc'))
+ >>> server = m.get_server()
+ >>> s.serve_forever()
+
+ :class:`Server` additionally have an :attr:`address` attribute.
+
+ .. method:: connect()
+
+ Connect a local manager object to a remote manager process::
+
+ >>> from multiprocessing.managers import BaseManager
+ >>> m = BaseManager(address='127.0.0.1', authkey='abc))
+ >>> m.connect()
+
.. method:: shutdown()
Stop the process used by the manager. This is only available if
@@ -1267,19 +1333,20 @@
>>> queue = Queue.Queue()
>>> class QueueManager(BaseManager): pass
...
- >>> QueueManager.register('getQueue', callable=lambda:queue)
+ >>> QueueManager.register('get_queue', callable=lambda:queue)
>>> m = QueueManager(address=('', 50000), authkey='abracadabra')
- >>> m.serveForever()
+ >>> s = m.get_server()
+ >>> s.serveForever()
One client can access the server as follows::
>>> from multiprocessing.managers import BaseManager
>>> class QueueManager(BaseManager): pass
...
- >>> QueueManager.register('getQueue')
- >>> m = QueueManager.from_address(address=('foo.bar.org', 50000),
- >>> authkey='abracadabra')
- >>> queue = m.getQueue()
+ >>> QueueManager.register('get_queue')
+ >>> m = QueueManager(address=('foo.bar.org', 50000), authkey='abracadabra')
+ >>> m.connect()
+ >>> queue = m.get_queue()
>>> queue.put('hello')
Another client can also use it::
@@ -1293,6 +1360,27 @@
>>> queue.get()
'hello'
+Local processes can also access that queue, using the code from above on the
+client to access it remotely::
+
+ >>> from multiprocessing import Process, Queue
+ >>> from multiprocessing.managers import BaseManager
+ >>> class Worker(Process):
+ ... def __init__(self, q):
+ ... self.q = q
+ ... super(Worker, self).__init__()
+ ... def run(self):
+ ... self.q.put('local hello')
+ ...
+ >>> queue = Queue()
+ >>> w = Worker(queue)
+ >>> w.start()
+ >>> class QueueManager(BaseManager): pass
+ ...
+ >>> QueueManager.register('get_queue', callable=lambda: queue)
+ >>> m = QueueManager(address=('', 50000), authkey='abracadabra')
+ >>> s = m.get_server()
+ >>> s.serve_forever()
Proxy Objects
~~~~~~~~~~~~~
@@ -1507,7 +1595,7 @@
The class of the result returned by :meth:`Pool.apply_async` and
:meth:`Pool.map_async`.
- .. method:: get([timeout)
+ .. method:: get([timeout])
Return the result when it arrives. If *timeout* is not ``None`` and the
result does not arrive within *timeout* seconds then
@@ -1537,7 +1625,7 @@
if __name__ == '__main__':
pool = Pool(processes=4) # start 4 worker processes
- result = pool.applyAsync(f, (10,)) # evaluate "f(10)" asynchronously
+ result = pool.apply_async(f, (10,)) # evaluate "f(10)" asynchronously
print result.get(timeout=1) # prints "100" unless your computer is *very* slow
print pool.map(f, range(10)) # prints "[0, 1, 4,..., 81]"
@@ -1548,7 +1636,7 @@
print it.next(timeout=1) # prints "4" unless your computer is *very* slow
import time
- result = pool.applyAsync(time.sleep, (10,))
+ result = pool.apply_async(time.sleep, (10,))
print result.get(timeout=1) # raises TimeoutError
@@ -1782,7 +1870,7 @@
Below is an example session with logging turned on::
>>> import multiprocessing, logging
- >>> logger = multiprocessing.getLogger()
+ >>> logger = multiprocessing.get_logger()
>>> logger.setLevel(logging.INFO)
>>> logger.warning('doomed')
[WARNING/MainProcess] doomed
Modified: python/branches/tlee-ast-optimize/Doc/library/os.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/os.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/os.rst Sun Nov 30 09:29:52 2008
@@ -933,10 +933,10 @@
.. function:: listdir(path)
- Return a list containing the names of the entries in the directory. The list is
- in arbitrary order. It does not include the special entries ``'.'`` and
- ``'..'`` even if they are present in the directory. Availability:
- Unix, Windows.
+ Return a list containing the names of the entries in the directory given by
+ *path*. The list is in arbitrary order. It does not include the special
+ entries ``'.'`` and ``'..'`` even if they are present in the
+ directory. Availability: Unix, Windows.
.. versionchanged:: 2.3
On Windows NT/2k/XP and Unix, if *path* is a Unicode object, the result will be
Modified: python/branches/tlee-ast-optimize/Doc/library/pdb.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/pdb.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/pdb.rst Sun Nov 30 09:29:52 2008
@@ -351,68 +351,3 @@
q(uit)
Quit from the debugger. The program being executed is aborted.
-
-
-.. _debugger-hooks:
-
-How It Works
-============
-
-Some changes were made to the interpreter:
-
-* ``sys.settrace(func)`` sets the global trace function
-
-* there can also a local trace function (see later)
-
-Trace functions have three arguments: *frame*, *event*, and *arg*. *frame* is
-the current stack frame. *event* is a string: ``'call'``, ``'line'``,
-``'return'``, ``'exception'``, ``'c_call'``, ``'c_return'``, or
-``'c_exception'``. *arg* depends on the event type.
-
-The global trace function is invoked (with *event* set to ``'call'``) whenever a
-new local scope is entered; it should return a reference to the local trace
-function to be used that scope, or ``None`` if the scope shouldn't be traced.
-
-The local trace function should return a reference to itself (or to another
-function for further tracing in that scope), or ``None`` to turn off tracing in
-that scope.
-
-Instance methods are accepted (and very useful!) as trace functions.
-
-The events have the following meaning:
-
-``'call'``
- A function is called (or some other code block entered). The global trace
- function is called; *arg* is ``None``; the return value specifies the local
- trace function.
-
-``'line'``
- The interpreter is about to execute a new line of code (sometimes multiple line
- events on one line exist). The local trace function is called; *arg* is
- ``None``; the return value specifies the new local trace function.
-
-``'return'``
- A function (or other code block) is about to return. The local trace function
- is called; *arg* is the value that will be returned. The trace function's
- return value is ignored.
-
-``'exception'``
- An exception has occurred. The local trace function is called; *arg* is a
- triple ``(exception, value, traceback)``; the return value specifies the new
- local trace function.
-
-``'c_call'``
- A C function is about to be called. This may be an extension function or a
- builtin. *arg* is the C function object.
-
-``'c_return'``
- A C function has returned. *arg* is ``None``.
-
-``'c_exception'``
- A C function has thrown an exception. *arg* is ``None``.
-
-Note that as an exception is propagated down the chain of callers, an
-``'exception'`` event is generated at each level.
-
-For more information on code and frame objects, refer to :ref:`types`.
-
Modified: python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/sqlite3.rst Sun Nov 30 09:29:52 2008
@@ -223,8 +223,8 @@
.. attribute:: Connection.isolation_level
- Get or set the current isolation level. :const:`None` for autocommit mode or one of
- "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See section
+ Get or set the current isolation level. :const:`None` for autocommit mode or
+ one of "DEFERRED", "IMMEDIATE" or "EXCLUSIVE". See section
:ref:`sqlite3-controlling-transactions` for a more detailed explanation.
Modified: python/branches/tlee-ast-optimize/Doc/library/stringio.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/stringio.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/stringio.rst Sun Nov 30 09:29:52 2008
@@ -37,7 +37,8 @@
.. method:: StringIO.close()
- Free the memory buffer.
+ Free the memory buffer. Attempting to do further operations with a closed
+ :class:`StringIO` object will raise a :exc:`ValueError`.
Example usage::
Modified: python/branches/tlee-ast-optimize/Doc/library/sys.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/sys.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/sys.rst Sun Nov 30 09:29:52 2008
@@ -712,11 +712,60 @@
single: debugger
Set the system's trace function, which allows you to implement a Python
- source code debugger in Python. See section :ref:`debugger-hooks` in the
- chapter on the Python debugger. The function is thread-specific; for a
+ source code debugger in Python. The function is thread-specific; for a
debugger to support multiple threads, it must be registered using
:func:`settrace` for each thread being debugged.
+ Trace functions should have three arguments: *frame*, *event*, and
+ *arg*. *frame* is the current stack frame. *event* is a string: ``'call'``,
+ ``'line'``, ``'return'``, ``'exception'``, ``'c_call'``, ``'c_return'``, or
+ ``'c_exception'``. *arg* depends on the event type.
+
+ The trace function is invoked (with *event* set to ``'call'``) whenever a new
+ local scope is entered; it should return a reference to a local trace
+ function to be used that scope, or ``None`` if the scope shouldn't be traced.
+
+ The local trace function should return a reference to itself (or to another
+ function for further tracing in that scope), or ``None`` to turn off tracing
+ in that scope.
+
+ The events have the following meaning:
+
+ ``'call'``
+ A function is called (or some other code block entered). The
+ global trace function is called; *arg* is ``None``; the return value
+ specifies the local trace function.
+
+ ``'line'``
+ The interpreter is about to execute a new line of code (sometimes multiple
+ line events on one line exist). The local trace function is called; *arg*
+ is ``None``; the return value specifies the new local trace function.
+
+ ``'return'``
+ A function (or other code block) is about to return. The local trace
+ function is called; *arg* is the value that will be returned. The trace
+ function's return value is ignored.
+
+ ``'exception'``
+ An exception has occurred. The local trace function is called; *arg* is a
+ tuple ``(exception, value, traceback)``; the return value specifies the
+ new local trace function.
+
+ ``'c_call'``
+ A C function is about to be called. This may be an extension function or
+ a builtin. *arg* is the C function object.
+
+ ``'c_return'``
+ A C function has returned. *arg* is ``None``.
+
+ ``'c_exception'``
+ A C function has thrown an exception. *arg* is ``None``.
+
+ Note that as an exception is propagated down the chain of callers, an
+ ``'exception'`` event is generated at each level.
+
+ For more information on code and frame objects, refer to :ref:`types`.
+
.. note::
The :func:`settrace` function is intended only for implementing debuggers,
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 Nov 30 09:29:52 2008
@@ -1365,21 +1365,21 @@
object: dictionary
builtin: hash
- Called for the key object for dictionary operations, and by the built-in
- function :func:`hash`. Should return an integer usable as a hash value
- for dictionary operations. The only required property is that objects which
- compare equal have the same hash value; it is advised to somehow mix together
- (e.g., using exclusive or) the hash values for the components of the object that
- also play a part in comparison of objects.
+ Called by built-in function :func:`hash` and for operations on members of
+ hashed collections including :class:`set`, :class:`frozenset`, and
+ :class:`dict`. :meth:`__hash__` should return an integer. The only required
+ property is that objects which compare equal have the same hash value; it is
+ advised to somehow mix together (e.g. using exclusive or) the hash values for
+ the components of the object that also play a part in comparison of objects.
If a class does not define a :meth:`__cmp__` or :meth:`__eq__` method it
should not define a :meth:`__hash__` operation either; if it defines
:meth:`__cmp__` or :meth:`__eq__` but not :meth:`__hash__`, its instances
- will not be usable as dictionary keys. If a class defines mutable objects
+ will not be usable in hashed collections. If a class defines mutable objects
and implements a :meth:`__cmp__` or :meth:`__eq__` method, it should not
- implement :meth:`__hash__`, since the dictionary implementation requires that
- a key's hash value is immutable (if the object's hash value changes, it will
- be in the wrong hash bucket).
+ implement :meth:`__hash__`, since hashable collection implementations require
+ that a object's hash value is immutable (if the object's hash value changes,
+ it will be in the wrong hash bucket).
User-defined classes have :meth:`__cmp__` and :meth:`__hash__` methods
by default; with them, all objects compare unequal (except with themselves)
@@ -1389,13 +1389,13 @@
change the meaning of :meth:`__cmp__` or :meth:`__eq__` such that the hash
value returned is no longer appropriate (e.g. by switching to a value-based
concept of equality instead of the default identity based equality) can
- explicitly flag themselves as being unhashable by setting
- ``__hash__ = None`` in the class definition. Doing so means that not only
- will instances of the class raise an appropriate :exc:`TypeError` when
- a program attempts to retrieve their hash value, but they will also be
- correctly identified as unhashable when checking
- ``isinstance(obj, collections.Hashable)`` (unlike classes which define
- their own :meth:`__hash__` to explicitly raise :exc:`TypeError`).
+ explicitly flag themselves as being unhashable by setting ``__hash__ = None``
+ in the class definition. Doing so means that not only will instances of the
+ class raise an appropriate :exc:`TypeError` when a program attempts to
+ retrieve their hash value, but they will also be correctly identified as
+ unhashable when checking ``isinstance(obj, collections.Hashable)`` (unlike
+ classes which define their own :meth:`__hash__` to explicitly raise
+ :exc:`TypeError`).
.. versionchanged:: 2.5
:meth:`__hash__` may now also return a long integer object; the 32-bit
Modified: python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html (original)
+++ python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html Sun Nov 30 09:29:52 2008
@@ -14,7 +14,7 @@
<p>To download an archive containing all the documents for this version of
Python in one of various formats, follow one of links in this table. The numbers
-in the table are the size of the download files in Kilobytes.</p>
+in the table are the size of the download files in megabytes.</p>
<table class="docutils">
<tr><th>Format</th><th>Packed as .zip</th><th>Packed as .tar.bz2</th></tr>
@@ -54,7 +54,7 @@
<h2>Problems</h2>
<p>If you have comments or suggestions for the Python documentation, please send
-email to <a href="docs at python.org">docs at python.org</a>.</p>
+email to <a href="mailto:docs at python.org">docs at python.org</a>.</p>
{% endif %}
{% endblock %}
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 Nov 30 09:29:52 2008
@@ -615,6 +615,6 @@
fcntl.fcntl(fd, fcntl.F_SETFL, flags)
def set_file(self, fd):
- self._fileno = fd
self.socket = file_wrapper(fd)
+ self._fileno = self.socket.fileno()
self.add_channel()
Modified: python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py (original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/msvc9compiler.py Sun Nov 30 09:29:52 2008
@@ -316,7 +316,7 @@
self.__version = VERSION
self.__root = r"Software\Microsoft\VisualStudio"
# self.__macros = MACROS
- self.__path = []
+ self.__paths = []
# target platform (.plat_name is consistent with 'bdist')
self.plat_name = None
self.__arch = None # deprecated name
Modified: python/branches/tlee-ast-optimize/Lib/doctest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/doctest.py (original)
+++ python/branches/tlee-ast-optimize/Lib/doctest.py Sun Nov 30 09:29:52 2008
@@ -854,12 +854,12 @@
"""
if module is None:
return True
+ elif inspect.getmodule(object) is not None:
+ return module is inspect.getmodule(object)
elif inspect.isfunction(object):
return module.__dict__ is object.func_globals
elif inspect.isclass(object):
return module.__name__ == object.__module__
- elif inspect.getmodule(object) is not None:
- return module is inspect.getmodule(object)
elif hasattr(object, '__module__'):
return module.__name__ == object.__module__
elif isinstance(object, property):
Modified: python/branches/tlee-ast-optimize/Lib/httplib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/httplib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/httplib.py Sun Nov 30 09:29:52 2008
@@ -326,6 +326,11 @@
# See RFC 2616 sec 19.6 and RFC 1945 sec 6 for details.
def __init__(self, sock, debuglevel=0, strict=0, method=None):
+ # The buffer size is specified as zero, because the headers of
+ # the response are read with readline(). If the reads were
+ # buffered the readline() calls could consume some of the
+ # response, which make be read via a recv() on the underlying
+ # socket.
self.fp = sock.makefile('rb', 0)
self.debuglevel = debuglevel
self.strict = strict
@@ -729,7 +734,7 @@
"""
self._buffer.append(s)
- def _send_output(self):
+ def _send_output(self, message_body=None):
"""Send the currently buffered request and clear the buffer.
Appends an extra \\r\\n to the buffer.
@@ -737,6 +742,11 @@
self._buffer.extend(("", ""))
msg = "\r\n".join(self._buffer)
del self._buffer[:]
+ # If msg and message_body are sent in a single send() call,
+ # it will avoid performance problems caused by the interaction
+ # between delayed ack and the Nagle algorithim.
+ if message_body is not None:
+ msg += message_body
self.send(msg)
def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0):
@@ -846,7 +856,7 @@
# For HTTP/1.0, the server will assume "not chunked"
pass
- def putheader(self, header, value):
+ def putheader(self, header, *values):
"""Send a request header line to the server.
For example: h.putheader('Accept', 'text/html')
@@ -854,18 +864,23 @@
if self.__state != _CS_REQ_STARTED:
raise CannotSendHeader()
- str = '%s: %s' % (header, value)
+ str = '%s: %s' % (header, '\r\n\t'.join(values))
self._output(str)
- def endheaders(self):
- """Indicate that the last header line has been sent to the server."""
+ def endheaders(self, message_body=None):
+ """Indicate that the last header line has been sent to the server.
+ This method sends the request to the server. The optional
+ message_body argument can be used to pass message body
+ associated with the request. The message body will be sent in
+ the same packet as the message headers if possible. The
+ message_body should be a string.
+ """
if self.__state == _CS_REQ_STARTED:
self.__state = _CS_REQ_SENT
else:
raise CannotSendHeader()
-
- self._send_output()
+ self._send_output(message_body)
def request(self, method, url, body=None, headers={}):
"""Send a complete request to the server."""
@@ -879,6 +894,24 @@
# try one more time
self._send_request(method, url, body, headers)
+ def _set_content_length(self, body):
+ # Set the content-length based on the body.
+ thelen = None
+ try:
+ thelen = str(len(body))
+ except TypeError, te:
+ # If this is a file-like object, try to
+ # fstat its file descriptor
+ import os
+ try:
+ thelen = str(os.fstat(body.fileno()).st_size)
+ except (AttributeError, OSError):
+ # Don't send a length if this failed
+ if self.debuglevel > 0: print "Cannot stat!!"
+
+ if thelen is not None:
+ self.putheader('Content-Length', thelen)
+
def _send_request(self, method, url, body, headers):
# honour explicitly requested Host: and Accept-Encoding headers
header_names = dict.fromkeys([k.lower() for k in headers])
@@ -891,27 +924,15 @@
self.putrequest(method, url, **skips)
if body and ('content-length' not in header_names):
- thelen=None
- try:
- thelen=str(len(body))
- except TypeError, te:
- # If this is a file-like object, try to
- # fstat its file descriptor
- import os
- try:
- thelen = str(os.fstat(body.fileno()).st_size)
- except (AttributeError, OSError):
- # Don't send a length if this failed
- if self.debuglevel > 0: print "Cannot stat!!"
-
- if thelen is not None:
- self.putheader('Content-Length',thelen)
+ self._set_content_length(body)
for hdr, value in headers.iteritems():
self.putheader(hdr, value)
- self.endheaders()
-
- if body:
- self.send(body)
+ if isinstance(body, str):
+ self.endheaders(body)
+ else:
+ self.endheaders()
+ if body: # when body is a file rather than a string
+ self.send(body)
def getresponse(self):
"Get the response from the server."
@@ -989,6 +1010,7 @@
# set up delegation to flesh out interface
self.send = conn.send
self.putrequest = conn.putrequest
+ self.putheader = conn.putheader
self.endheaders = conn.endheaders
self.set_debuglevel = conn.set_debuglevel
@@ -1008,10 +1030,6 @@
"Provide a getfile, since the superclass' does not use this concept."
return self.file
- def putheader(self, header, *values):
- "The superclass allows only one value argument."
- self._conn.putheader(header, '\r\n\t'.join(values))
-
def getreply(self):
"""Compat definition since superclass does not define it.
Modified: python/branches/tlee-ast-optimize/Lib/io.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/io.py (original)
+++ python/branches/tlee-ast-optimize/Lib/io.py Sun Nov 30 09:29:52 2008
@@ -238,8 +238,6 @@
raise ValueError("invalid buffering size")
if buffering == 0:
if binary:
- raw._name = file
- raw._mode = mode
return raw
raise ValueError("can't have unbuffered text I/O")
if updating:
@@ -251,11 +249,8 @@
else:
raise ValueError("unknown mode: %r" % mode)
if binary:
- buffer.name = file
- buffer.mode = mode
return buffer
text = TextIOWrapper(buffer, encoding, errors, newline, line_buffering)
- text.name = file
text.mode = mode
return text
@@ -622,6 +617,10 @@
# that _fileio._FileIO inherits from io.RawIOBase (which would be hard
# to do since _fileio.c is written in C).
+ def __init__(self, name, mode="r", closefd=True):
+ _fileio._FileIO.__init__(self, name, mode, closefd)
+ self._name = name
+
def close(self):
_fileio._FileIO.close(self)
RawIOBase.close(self)
@@ -630,10 +629,6 @@
def name(self):
return self._name
- @property
- def mode(self):
- return self._mode
-
class BufferedIOBase(IOBase):
@@ -767,6 +762,14 @@
def closed(self):
return self.raw.closed
+ @property
+ def name(self):
+ return self.raw.name
+
+ @property
+ def mode(self):
+ return self.raw.mode
+
### Lower-level APIs ###
def fileno(self):
@@ -1473,6 +1476,10 @@
def closed(self):
return self.buffer.closed
+ @property
+ def name(self):
+ return self.buffer.name
+
def fileno(self):
return self.buffer.fileno()
Modified: python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py Sun Nov 30 09:29:52 2008
@@ -359,7 +359,7 @@
def __init__(self, master, width=500, height=350,
canvwidth=600, canvheight=500):
TK.Frame.__init__(self, master, width=width, height=height)
- self._root = self.winfo_toplevel()
+ self._rootwindow = self.winfo_toplevel()
self.width, self.height = width, height
self.canvwidth, self.canvheight = canvwidth, canvheight
self.bg = "white"
@@ -379,7 +379,7 @@
self.hscroll.grid(padx=1, in_ = self, pady=1, row=1,
column=0, rowspan=1, columnspan=1, sticky='news')
self.reset()
- self._root.bind('<Configure>', self.onResize)
+ self._rootwindow.bind('<Configure>', self.onResize)
def reset(self, canvwidth=None, canvheight=None, bg = None):
"""Ajust canvas and scrollbars according to given canvas size."""
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_base.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_base.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_base.py Sun Nov 30 09:29:52 2008
@@ -7,12 +7,6 @@
import logging
import itertools
-# Get a usable 'set' constructor
-try:
- set
-except NameError:
- from sets import Set as set
-
# Local imports
from .patcomp import PatternCompiler
from . import pygram
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_util.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_util.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixer_util.py Sun Nov 30 09:29:52 2008
@@ -153,30 +153,6 @@
and node.children[0].value == "["
and node.children[-1].value == "]")
-###########################################################
-### Common portability code. This allows fixers to do, eg,
-### "from .util import set" and forget about it.
-###########################################################
-
-try:
- any = any
-except NameError:
- def any(l):
- for o in l:
- if o:
- return True
- return False
-
-try:
- set = set
-except NameError:
- from sets import Set as set
-
-try:
- reversed = reversed
-except NameError:
- def reversed(l):
- return l[::-1]
###########################################################
### Misc
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_dict.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_dict.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_dict.py Sun Nov 30 09:29:52 2008
@@ -28,7 +28,7 @@
from .. import patcomp
from ..pgen2 import token
from .. import fixer_base
-from ..fixer_util import Name, Call, LParen, RParen, ArgList, Dot, set
+from ..fixer_util import Name, Call, LParen, RParen, ArgList, Dot
from .. import fixer_util
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_except.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_except.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_except.py Sun Nov 30 09:29:52 2008
@@ -25,7 +25,7 @@
from .. import pytree
from ..pgen2 import token
from .. import fixer_base
-from ..fixer_util import Assign, Attr, Name, is_tuple, is_list, reversed
+from ..fixer_util import Assign, Attr, Name, is_tuple, is_list
def find_excepts(nodes):
for i, n in enumerate(nodes):
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 Nov 30 09:29:52 2008
@@ -13,7 +13,7 @@
# Local imports
from .. import fixer_base
from os.path import dirname, join, exists, pathsep
-from ..fixer_util import FromImport
+from ..fixer_util import FromImport, syms
class FixImport(fixer_base.BaseFix):
@@ -26,11 +26,14 @@
def transform(self, node, results):
imp = results['imp']
- if unicode(imp).startswith('.'):
+ mod_name = unicode(imp.children[0] if imp.type == syms.dotted_as_name \
+ else imp)
+
+ if mod_name.startswith('.'):
# Already a new-style import
return
- if not probably_a_local_import(unicode(imp), self.filename):
+ if not probably_a_local_import(mod_name, self.filename):
# I guess this is a global import -- skip it!
return
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports.py Sun Nov 30 09:29:52 2008
@@ -1,9 +1,9 @@
"""Fix incompatible imports and module references."""
-# Author: Collin Winter
+# Authors: Collin Winter, Nick Edds
# Local imports
from .. import fixer_base
-from ..fixer_util import Name, attr_chain, any, set
+from ..fixer_util import Name, attr_chain
MAPPING = {'StringIO': 'io',
'cStringIO': 'io',
@@ -61,36 +61,49 @@
def build_pattern(mapping=MAPPING):
- mod_list = ' | '.join(["module='" + key + "'" for key in mapping.keys()])
- mod_name_list = ' | '.join(["module_name='" + key + "'" for key in mapping.keys()])
- yield """import_name< 'import' ((%s)
+ mod_list = ' | '.join(["module_name='%s'" % key for key in mapping])
+ bare_names = alternates(mapping.keys())
+
+ yield """name_import=import_name< 'import' ((%s)
| dotted_as_names< any* (%s) any* >) >
""" % (mod_list, mod_list)
yield """import_from< 'from' (%s) 'import' ['(']
( any | import_as_name< any 'as' any > |
import_as_names< any* >) [')'] >
- """ % mod_name_list
+ """ % mod_list
yield """import_name< 'import'
dotted_as_name< (%s) 'as' any > >
- """ % mod_name_list
- # Find usages of module members in code e.g. urllib.foo(bar)
- yield """power< (%s)
- trailer<'.' any > any* >
- """ % mod_name_list
- yield """bare_name=%s""" % alternates(mapping.keys())
+ """ % mod_list
+
+ # Find usages of module members in code e.g. thread.foo(bar)
+ yield "power< bare_with_attr=(%s) trailer<'.' any > any* >" % bare_names
+
class FixImports(fixer_base.BaseFix):
- PATTERN = "|".join(build_pattern())
+
order = "pre" # Pre-order tree traversal
+ # This is overridden in fix_imports2.
mapping = MAPPING
- # Don't match the node if it's within another match
+ def build_pattern(self):
+ return "|".join(build_pattern(self.mapping))
+
+ def compile_pattern(self):
+ # We override this, so MAPPING can be pragmatically altered and the
+ # changes will be reflected in PATTERN.
+ self.PATTERN = self.build_pattern()
+ super(FixImports, self).compile_pattern()
+
+ # Don't match the node if it's within another match.
def match(self, node):
match = super(FixImports, self).match
results = match(node)
if results:
- if any([match(obj) for obj in attr_chain(node, "parent")]):
+ # Module usage could be in the trailier of an attribute lookup, so
+ # we might have nested matches when "bare_with_attr" is present.
+ if "bare_with_attr" not in results and \
+ any([match(obj) for obj in attr_chain(node, "parent")]):
return False
return results
return False
@@ -100,20 +113,17 @@
self.replace = {}
def transform(self, node, results):
- import_mod = results.get("module")
- mod_name = results.get("module_name")
- bare_name = results.get("bare_name")
-
- if import_mod or mod_name:
- new_name = self.mapping[(import_mod or mod_name).value]
-
+ import_mod = results.get("module_name")
if import_mod:
- self.replace[import_mod.value] = new_name
+ new_name = self.mapping[(import_mod or mod_name).value]
+ if "name_import" in results:
+ # If it's not a "from x import x, y" or "import x as y" import,
+ # marked its usage to be replaced.
+ self.replace[import_mod.value] = new_name
import_mod.replace(Name(new_name, prefix=import_mod.get_prefix()))
- elif mod_name:
- mod_name.replace(Name(new_name, prefix=mod_name.get_prefix()))
- elif bare_name:
- bare_name = bare_name[0]
+ else:
+ # Replace usage of the module.
+ bare_name = results["bare_with_attr"][0]
new_name = self.replace.get(bare_name.value)
if new_name:
bare_name.replace(Name(new_name, prefix=bare_name.get_prefix()))
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports2.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports2.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_imports2.py Sun Nov 30 09:29:52 2008
@@ -10,7 +10,6 @@
class FixImports2(fix_imports.FixImports):
- PATTERN = "|".join((fix_imports.build_pattern(MAPPING)))
order = "post"
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_metaclass.py Sun Nov 30 09:29:52 2008
@@ -110,8 +110,11 @@
if simple_node.type == syms.simple_stmt and simple_node.children:
expr_node = simple_node.children[0]
if expr_node.type == syms.expr_stmt and expr_node.children:
- leaf_node = expr_node.children[0]
- if leaf_node.value == '__metaclass__':
+ # Check if the expr_node is a simple assignment.
+ left_node = expr_node.children[0]
+ if isinstance(left_node, Leaf) and \
+ left_node.value == '__metaclass__':
+ # We found a assignment to __metaclass__.
fixup_simple_stmt(node, i, simple_node)
remove_trailing_newline(simple_node)
yield (node, i, simple_node)
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_next.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_next.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_next.py Sun Nov 30 09:29:52 2008
@@ -9,7 +9,7 @@
from ..pgen2 import token
from ..pygram import python_symbols as syms
from .. import fixer_base
-from ..fixer_util import Name, Call, find_binding, any
+from ..fixer_util import Name, Call, find_binding
bind_warning = "Calls to builtin next() possibly shadowed by global binding"
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_numliterals.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_numliterals.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_numliterals.py Sun Nov 30 09:29:52 2008
@@ -6,7 +6,7 @@
# Local imports
from ..pgen2 import token
from .. import fixer_base
-from ..fixer_util import Number, set
+from ..fixer_util import Number
class FixNumliterals(fixer_base.BaseFix):
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_renames.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_renames.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_renames.py Sun Nov 30 09:29:52 2008
@@ -8,7 +8,7 @@
# Local imports
from .. import fixer_base
-from ..fixer_util import Name, attr_chain, any, set
+from ..fixer_util import Name, attr_chain
MAPPING = {"sys": {"maxint" : "maxsize"},
}
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_urllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_urllib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/fixes/fix_urllib.py Sun Nov 30 09:29:52 2008
@@ -7,7 +7,7 @@
# Local imports
from .fix_imports import alternates, FixImports
from .. import fixer_base
-from ..fixer_util import Name, Comma, FromImport, Newline, attr_chain, any, set
+from ..fixer_util import Name, Comma, FromImport, Newline, attr_chain
MAPPING = {'urllib': [
('urllib.request',
@@ -65,7 +65,9 @@
class FixUrllib(FixImports):
- PATTERN = "|".join(build_pattern())
+
+ def build_pattern(self):
+ return "|".join(build_pattern())
def transform_import(self, node, results):
"""Transform for the basic import case. Replaces the old
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/parse.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/parse.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/pgen2/parse.py Sun Nov 30 09:29:52 2008
@@ -10,12 +10,6 @@
"""
-# Get a usable 'set' constructor
-try:
- set
-except NameError:
- from sets import Set as set
-
# Local imports
from . import token
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/pytree.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/pytree.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/pytree.py Sun Nov 30 09:29:52 2008
@@ -11,6 +11,9 @@
__author__ = "Guido van Rossum <guido at python.org>"
+import sys
+from StringIO import StringIO
+
HUGE = 0x7FFFFFFF # maximum repeat count, default max
@@ -655,6 +658,11 @@
elif self.name == "bare_name":
yield self._bare_name_matches(nodes)
else:
+ # The reason for this is that hitting the recursion limit usually
+ # results in some ugly messages about how RuntimeErrors are being
+ # ignored.
+ save_stderr = sys.stderr
+ sys.stderr = StringIO()
try:
for count, r in self._recursive_matches(nodes, 0):
if self.name:
@@ -667,6 +675,8 @@
if self.name:
r[self.name] = nodes[:count]
yield count, r
+ finally:
+ sys.stderr = save_stderr
def _iterative_matches(self, nodes):
"""Helper to iteratively yield the matches."""
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py Sun Nov 30 09:29:52 2008
@@ -123,8 +123,8 @@
logger=self.logger)
self.pre_order, self.post_order = self.get_fixers()
- self.pre_order = get_headnode_dict(self.pre_order)
- self.post_order = get_headnode_dict(self.post_order)
+ self.pre_order_mapping = get_headnode_dict(self.pre_order)
+ self.post_order_mapping = get_headnode_dict(self.post_order)
self.files = [] # List of files that were or should be modified
@@ -290,13 +290,12 @@
# Two calls to chain are required because pre_order.values()
# will be a list of lists of fixers:
# [[<fixer ...>, <fixer ...>], [<fixer ...>]]
- all_fixers = chain(chain(*self.pre_order.values()),\
- chain(*self.post_order.values()))
+ all_fixers = chain(self.pre_order, self.post_order)
for fixer in all_fixers:
fixer.start_tree(tree, name)
- self.traverse_by(self.pre_order, tree.pre_order())
- self.traverse_by(self.post_order, tree.post_order())
+ self.traverse_by(self.pre_order_mapping, tree.pre_order())
+ self.traverse_by(self.post_order_mapping, tree.post_order())
for fixer in all_fixers:
fixer.finish_tree(tree, name)
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 Nov 30 09:29:52 2008
@@ -15,10 +15,7 @@
from operator import itemgetter
# Local imports
-from .. import pygram
-from .. import pytree
-from .. import refactor
-from .. import fixer_util
+from lib2to3 import pygram, pytree, refactor, fixer_util
class FixerTestCase(support.TestCase):
@@ -30,10 +27,9 @@
self.fixer_log = []
self.filename = "<string>"
- for order in (self.refactor.pre_order.values(),\
- self.refactor.post_order.values()):
- for fixer in chain(*order):
- fixer.log = self.fixer_log
+ for fixer in chain(self.refactor.pre_order,
+ self.refactor.post_order):
+ fixer.log = self.fixer_log
def _check(self, before, after):
before = support.reformat(before)
@@ -1488,6 +1484,44 @@
""" % (new, new)
self.check(b, a)
+ b = """
+ from %s import x
+ %s = 23
+ """ % (old, old)
+ a = """
+ from %s import x
+ %s = 23
+ """ % (new, old)
+ self.check(b, a)
+
+ s = """
+ def f():
+ %s.method()
+ """ % (old,)
+ self.unchanged(s)
+
+ # test nested usage
+ b = """
+ import %s
+ %s.bar(%s.foo)
+ """ % (old, old, old)
+ a = """
+ import %s
+ %s.bar(%s.foo)
+ """ % (new, new, new)
+ self.check(b, a)
+
+ b = """
+ import %s
+ x.%s
+ """ % (old, old)
+ a = """
+ import %s
+ x.%s
+ """ % (new, old)
+ self.check(b, a)
+
+
class Test_imports2(Test_imports):
fixer = "imports2"
@@ -2622,7 +2656,7 @@
def check(self, b, a):
self.unchanged("from future_builtins import map; " + b, a)
- FixerTestCase.check(self, b, a)
+ super(Test_map, self).check(b, a)
def test_prefix_preservation(self):
b = """x = map( f, 'abc' )"""
@@ -2729,7 +2763,7 @@
def check(self, b, a):
self.unchanged("from future_builtins import zip; " + b, a)
- FixerTestCase.check(self, b, a)
+ super(Test_zip, self).check(b, a)
def test_zip_basic(self):
b = """x = zip(a, b, c)"""
@@ -3274,7 +3308,7 @@
fixer = "import"
def setUp(self):
- FixerTestCase.setUp(self)
+ super(Test_import, self).setUp()
# Need to replace fix_import's exists method
# so we can check that it's doing the right thing
self.files_checked = []
@@ -3293,9 +3327,9 @@
def check_both(self, b, a):
self.always_exists = True
- FixerTestCase.check(self, b, a)
+ super(Test_import, self).check(b, a)
self.always_exists = False
- FixerTestCase.unchanged(self, b)
+ super(Test_import, self).unchanged(b)
def test_files_checked(self):
def p(path):
@@ -3372,6 +3406,11 @@
a = "from . import foo, bar"
self.check_both(b, a)
+ def test_import_as(self):
+ b = "import foo as x"
+ a = "from . import foo as x"
+ self.check_both(b, a)
+
def test_dotted_import(self):
b = "import foo.bar"
a = "from . import foo.bar"
@@ -3766,6 +3805,17 @@
"""
self.check(b, a)
+ b = """
+ class X:
+ __metaclass__ = Meta
+ save.py = 23
+ """
+ a = """
+ class X(metaclass=Meta):
+ save.py = 23
+ """
+ self.check(b, a)
+
class Test_getcwdu(FixerTestCase):
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_refactor.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_refactor.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_refactor.py Sun Nov 30 09:29:52 2008
@@ -161,7 +161,7 @@
self.assertEqual(len(rt.post_order), 0)
rt = self.rt(explicit=["myfixes.fix_explicit"])
- for fix in rt.post_order[None]:
+ for fix in rt.post_order:
if isinstance(fix, FixExplicit):
break
else:
Modified: python/branches/tlee-ast-optimize/Lib/multiprocessing/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/multiprocessing/__init__.py (original)
+++ python/branches/tlee-ast-optimize/Lib/multiprocessing/__init__.py Sun Nov 30 09:29:52 2008
@@ -113,7 +113,7 @@
num = int(os.environ['NUMBER_OF_PROCESSORS'])
except (ValueError, KeyError):
num = 0
- elif sys.platform == 'darwin':
+ elif 'bsd' in sys.platform or sys.platform == 'darwin':
try:
num = int(os.popen('sysctl -n hw.ncpu').read())
except ValueError:
Modified: python/branches/tlee-ast-optimize/Lib/multiprocessing/pool.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/multiprocessing/pool.py (original)
+++ python/branches/tlee-ast-optimize/Lib/multiprocessing/pool.py Sun Nov 30 09:29:52 2008
@@ -149,7 +149,7 @@
def imap(self, func, iterable, chunksize=1):
'''
- Equivalent of `itertool.imap()` -- can be MUCH slower than `Pool.map()`
+ Equivalent of `itertools.imap()` -- can be MUCH slower than `Pool.map()`
'''
assert self._state == RUN
if chunksize == 1:
Modified: python/branches/tlee-ast-optimize/Lib/optparse.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/optparse.py (original)
+++ python/branches/tlee-ast-optimize/Lib/optparse.py Sun Nov 30 09:29:52 2008
@@ -799,7 +799,7 @@
parser.print_version()
parser.exit()
else:
- raise RuntimeError, "unknown action %r" % self.action
+ raise ValueError("unknown action %r" % self.action)
return 1
Modified: python/branches/tlee-ast-optimize/Lib/test/test_bytes.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_bytes.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_bytes.py Sun Nov 30 09:29:52 2008
@@ -721,6 +721,16 @@
b.insert(0, Indexable(ord('A')))
self.assertEqual(b, b'A')
+ def test_copied(self):
+ # Issue 4348. Make sure that operations that don't mutate the array
+ # copy the bytes.
+ b = bytearray(b'abc')
+ self.assertFalse(b is b.replace(b'abc', b'cde', 0))
+
+ t = bytearray([i for i in range(256)])
+ x = bytearray(b'')
+ self.assertFalse(x is x.translate(t))
+
def test_partition_bytearray_doesnt_share_nullstring(self):
a, b, c = bytearray(b"x").partition(b"y")
self.assertEqual(b, b"")
Modified: python/branches/tlee-ast-optimize/Lib/test/test_descr.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_descr.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_descr.py Sun Nov 30 09:29:52 2008
@@ -4289,6 +4289,46 @@
c[1:2] = 3
self.assertEqual(c.value, 3)
+ def test_getattr_hooks(self):
+ # issue 4230
+
+ class Descriptor(object):
+ counter = 0
+ def __get__(self, obj, objtype=None):
+ def getter(name):
+ self.counter += 1
+ raise AttributeError(name)
+ return getter
+
+ descr = Descriptor()
+ class A(object):
+ __getattribute__ = descr
+ class B(object):
+ __getattr__ = descr
+ class C(object):
+ __getattribute__ = descr
+ __getattr__ = descr
+
+ self.assertRaises(AttributeError, getattr, A(), "attr")
+ self.assertEquals(descr.counter, 1)
+ self.assertRaises(AttributeError, getattr, B(), "attr")
+ self.assertEquals(descr.counter, 2)
+ self.assertRaises(AttributeError, getattr, C(), "attr")
+ self.assertEquals(descr.counter, 4)
+
+ import gc
+ class EvilGetattribute(object):
+ # This used to segfault
+ def __getattr__(self, name):
+ raise AttributeError(name)
+ def __getattribute__(self, name):
+ del EvilGetattribute.__getattr__
+ for i in range(5):
+ gc.collect()
+ raise AttributeError(name)
+
+ self.assertRaises(AttributeError, getattr, EvilGetattribute(), "attr")
+
class DictProxyTests(unittest.TestCase):
def setUp(self):
Modified: python/branches/tlee-ast-optimize/Lib/test/test_fileio.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_fileio.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_fileio.py Sun Nov 30 09:29:52 2008
@@ -50,7 +50,7 @@
# verify expected attributes exist
f = self.f
- self.assertEquals(f.mode, "w")
+ self.assertEquals(f.mode, "wb")
self.assertEquals(f.closed, False)
# verify the attributes are readonly
@@ -160,7 +160,7 @@
def testModeStrings(self):
# check invalid mode strings
- for mode in ("", "aU", "wU+", "rb", "rt"):
+ for mode in ("", "aU", "wU+", "rw", "rt"):
try:
f = _fileio._FileIO(TESTFN, mode)
except ValueError:
Modified: python/branches/tlee-ast-optimize/Lib/test/test_httplib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_httplib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_httplib.py Sun Nov 30 09:29:52 2008
@@ -107,19 +107,23 @@
for hp in ("www.python.org:abc", "www.python.org:"):
self.assertRaises(httplib.InvalidURL, httplib.HTTP, hp)
- for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b", 8000),
+ for hp, h, p in (("[fe80::207:e9ff:fe9b]:8000", "fe80::207:e9ff:fe9b",
+ 8000),
("www.python.org:80", "www.python.org", 80),
("www.python.org", "www.python.org", 80),
("[fe80::207:e9ff:fe9b]", "fe80::207:e9ff:fe9b", 80)):
http = httplib.HTTP(hp)
c = http._conn
- if h != c.host: self.fail("Host incorrectly parsed: %s != %s" % (h, c.host))
- if p != c.port: self.fail("Port incorrectly parsed: %s != %s" % (p, c.host))
+ if h != c.host:
+ self.fail("Host incorrectly parsed: %s != %s" % (h, c.host))
+ if p != c.port:
+ self.fail("Port incorrectly parsed: %s != %s" % (p, c.host))
def test_response_headers(self):
# test response with multiple message headers with the same field name.
text = ('HTTP/1.1 200 OK\r\n'
- 'Set-Cookie: Customer="WILE_E_COYOTE"; Version="1"; Path="/acme"\r\n'
+ 'Set-Cookie: Customer="WILE_E_COYOTE";'
+ ' Version="1"; Path="/acme"\r\n'
'Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1";'
' Path="/acme"\r\n'
'\r\n'
@@ -187,7 +191,8 @@
resp.close()
def test_negative_content_length(self):
- sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n')
+ sock = FakeSocket('HTTP/1.1 200 OK\r\n'
+ 'Content-Length: -1\r\n\r\nHello\r\n')
resp = httplib.HTTPResponse(sock, method="GET")
resp.begin()
self.assertEquals(resp.read(), 'Hello\r\n')
Modified: python/branches/tlee-ast-optimize/Lib/test/test_imageop.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_imageop.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_imageop.py Sun Nov 30 09:29:52 2008
@@ -15,6 +15,7 @@
_VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)
VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES
AAAAA = "A" * 1024
+MAX_LEN = 2**20
class InputValidationTests(unittest.TestCase):
@@ -26,7 +27,7 @@
strlen = abs(width * height)
if size:
strlen *= size
- if strlen < 1024:
+ if strlen < MAX_LEN:
data = "A" * strlen
else:
data = AAAAA
Modified: python/branches/tlee-ast-optimize/Lib/test/test_io.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_io.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_io.py Sun Nov 30 09:29:52 2008
@@ -272,6 +272,30 @@
self.assertRaises(ValueError, io.open, test_support.TESTFN, 'w',
closefd=False)
+ def testReadClosed(self):
+ with io.open(test_support.TESTFN, "w") as f:
+ f.write("egg\n")
+ with io.open(test_support.TESTFN, "r") as f:
+ file = io.open(f.fileno(), "r", closefd=False)
+ self.assertEqual(file.read(), "egg\n")
+ file.seek(0)
+ file.close()
+ self.assertRaises(ValueError, file.read)
+
+ def test_no_closefd_with_filename(self):
+ # can't use closefd in combination with a file name
+ self.assertRaises(ValueError,
+ io.open, test_support.TESTFN, "r", closefd=False)
+
+ def test_closefd_attr(self):
+ with io.open(test_support.TESTFN, "wb") as f:
+ f.write(b"egg\n")
+ with io.open(test_support.TESTFN, "r") as f:
+ self.assertEqual(f.buffer.raw.closefd, True)
+ file = io.open(f.fileno(), "r", closefd=False)
+ self.assertEqual(file.buffer.raw.closefd, False)
+
+
class MemorySeekTestMixin:
def testInit(self):
@@ -1225,6 +1249,9 @@
class MiscIOTest(unittest.TestCase):
+ def tearDown(self):
+ test_support.unlink(test_support.TESTFN)
+
def testImport__all__(self):
for name in io.__all__:
obj = getattr(io, name, None)
@@ -1237,6 +1264,34 @@
self.assert_(issubclass(obj, io.IOBase))
+ def test_attributes(self):
+ f = io.open(test_support.TESTFN, "wb", buffering=0)
+ self.assertEquals(f.mode, "wb")
+ f.close()
+
+ f = io.open(test_support.TESTFN, "U")
+ self.assertEquals(f.name, test_support.TESTFN)
+ self.assertEquals(f.buffer.name, test_support.TESTFN)
+ self.assertEquals(f.buffer.raw.name, test_support.TESTFN)
+ self.assertEquals(f.mode, "U")
+ self.assertEquals(f.buffer.mode, "rb")
+ self.assertEquals(f.buffer.raw.mode, "rb")
+ f.close()
+
+ f = io.open(test_support.TESTFN, "w+")
+ self.assertEquals(f.mode, "w+")
+ self.assertEquals(f.buffer.mode, "rb+") # Does it really matter?
+ self.assertEquals(f.buffer.raw.mode, "rb+")
+
+ g = io.open(f.fileno(), "wb", closefd=False)
+ self.assertEquals(g.mode, "wb")
+ self.assertEquals(g.raw.mode, "wb")
+ self.assertEquals(g.name, f.fileno())
+ self.assertEquals(g.raw.name, f.fileno())
+ f.close()
+ g.close()
+
+
def test_main():
test_support.run_unittest(IOTest, BytesIOTest, StringIOTest,
BufferedReaderTest, BufferedWriterTest,
Modified: python/branches/tlee-ast-optimize/Lib/test/test_parser.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_parser.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_parser.py Sun Nov 30 09:29:52 2008
@@ -196,6 +196,10 @@
def test_assert(self):
self.check_suite("assert alo < ahi and blo < bhi\n")
+ def test_with(self):
+ self.check_suite("with open('x'): pass\n")
+ self.check_suite("with open('x') as f: pass\n")
+
def test_position(self):
# An absolutely minimal test of position information. Better
# tests would be a big project.
Modified: python/branches/tlee-ast-optimize/Lib/test/test_unicodedata.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_unicodedata.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_unicodedata.py Sun Nov 30 09:29:52 2008
@@ -4,9 +4,13 @@
(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
-"""#"
-import unittest, test.test_support
+"""
+
+import sys
+import unittest
import hashlib
+import subprocess
+import test.test_support
encoding = 'utf-8'
@@ -196,6 +200,25 @@
class UnicodeMiscTest(UnicodeDatabaseTest):
+ def test_failed_import_during_compiling(self):
+ # Issue 4367
+ # Decoding \N escapes requires the unicodedata module. If it can't be
+ # imported, we shouldn't segfault.
+
+ # This program should raise a SyntaxError in the eval.
+ code = "import sys;" \
+ "sys.modules['unicodedata'] = None;" \
+ """eval("u'\N{SOFT HYPHEN}'")"""
+ args = [sys.executable, "-c", code]
+ # We use a subprocess because the unicodedata module may already have
+ # been loaded in this process.
+ popen = subprocess.Popen(args, stderr=subprocess.PIPE)
+ popen.wait()
+ self.assertEqual(popen.returncode, 1)
+ error = "SyntaxError: (unicode error) \N escapes not supported " \
+ "(can't load unicodedata module)"
+ self.assertTrue(error in popen.stderr.read())
+
def test_decimal_numeric_consistent(self):
# Test that decimal and numeric are consistent,
# i.e. if a character has a decimal value,
Modified: python/branches/tlee-ast-optimize/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_xmlrpc.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_xmlrpc.py Sun Nov 30 09:29:52 2008
@@ -9,6 +9,7 @@
import mimetools
import httplib
import socket
+import StringIO
import os
from test import test_support
@@ -639,9 +640,93 @@
os.remove("xmldata.txt")
os.remove(test_support.TESTFN)
+class FakeSocket:
+
+ def __init__(self):
+ self.data = StringIO.StringIO()
+
+ def send(self, buf):
+ self.data.write(buf)
+ return len(buf)
+
+ def sendall(self, buf):
+ self.data.write(buf)
+
+ def getvalue(self):
+ return self.data.getvalue()
+
+ def makefile(self, x, y):
+ raise RuntimeError
+
+class FakeTransport(xmlrpclib.Transport):
+ """A Transport instance that records instead of sending a request.
+
+ This class replaces the actual socket used by httplib with a
+ FakeSocket object that records the request. It doesn't provide a
+ response.
+ """
+
+ def make_connection(self, host):
+ conn = xmlrpclib.Transport.make_connection(self, host)
+ conn._conn.sock = self.fake_socket = FakeSocket()
+ return conn
+
+class TransportSubclassTestCase(unittest.TestCase):
+
+ def issue_request(self, transport_class):
+ """Return an HTTP request made via transport_class."""
+ transport = transport_class()
+ proxy = xmlrpclib.ServerProxy("http://example.com/",
+ transport=transport)
+ try:
+ proxy.pow(6, 8)
+ except RuntimeError:
+ return transport.fake_socket.getvalue()
+ return None
+
+ def test_custom_user_agent(self):
+ class TestTransport(FakeTransport):
+
+ def send_user_agent(self, conn):
+ xmlrpclib.Transport.send_user_agent(self, conn)
+ conn.putheader("X-Test", "test_custom_user_agent")
+
+ req = self.issue_request(TestTransport)
+ self.assert_("X-Test: test_custom_user_agent\r\n" in req)
+
+ def test_send_host(self):
+ class TestTransport(FakeTransport):
+
+ def send_host(self, conn, host):
+ xmlrpclib.Transport.send_host(self, conn, host)
+ conn.putheader("X-Test", "test_send_host")
+
+ req = self.issue_request(TestTransport)
+ self.assert_("X-Test: test_send_host\r\n" in req)
+
+ def test_send_request(self):
+ class TestTransport(FakeTransport):
+
+ def send_request(self, conn, url, body):
+ xmlrpclib.Transport.send_request(self, conn, url, body)
+ conn.putheader("X-Test", "test_send_request")
+
+ req = self.issue_request(TestTransport)
+ self.assert_("X-Test: test_send_request\r\n" in req)
+
+ def test_send_content(self):
+ class TestTransport(FakeTransport):
+
+ def send_content(self, conn, body):
+ conn.putheader("X-Test", "test_send_content")
+ xmlrpclib.Transport.send_content(self, conn, body)
+
+ req = self.issue_request(TestTransport)
+ self.assert_("X-Test: test_send_content\r\n" in req)
+
def test_main():
xmlrpc_tests = [XMLRPCTestCase, HelperTestCase, DateTimeTestCase,
- BinaryTestCase, FaultTestCase]
+ BinaryTestCase, FaultTestCase, TransportSubclassTestCase]
# The test cases against a SimpleXMLRPCServer raise a socket error
# 10035 (WSAEWOULDBLOCK) in the server thread handle_request call when
Modified: python/branches/tlee-ast-optimize/Lib/uuid.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/uuid.py (original)
+++ python/branches/tlee-ast-optimize/Lib/uuid.py Sun Nov 30 09:29:52 2008
@@ -479,8 +479,8 @@
# When the system provides a version-1 UUID generator, use it (but don't
# use UuidCreate here because its UUIDs don't conform to RFC 4122).
- _buffer = ctypes.create_string_buffer(16)
if _uuid_generate_time and node is clock_seq is None:
+ _buffer = ctypes.create_string_buffer(16)
_uuid_generate_time(_buffer)
return UUID(bytes=_buffer.raw)
@@ -516,8 +516,8 @@
"""Generate a random UUID."""
# When the system provides a version-4 UUID generator, use it.
- _buffer = ctypes.create_string_buffer(16)
if _uuid_generate_random:
+ _buffer = ctypes.create_string_buffer(16)
_uuid_generate_random(_buffer)
return UUID(bytes=_buffer.raw)
Modified: python/branches/tlee-ast-optimize/Lib/xmlrpclib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/xmlrpclib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/xmlrpclib.py Sun Nov 30 09:29:52 2008
@@ -1346,9 +1346,7 @@
def send_content(self, connection, request_body):
connection.putheader("Content-Type", "text/xml")
connection.putheader("Content-Length", str(len(request_body)))
- connection.endheaders()
- if request_body:
- connection.send(request_body)
+ connection.endheaders(request_body)
##
# Parse response.
Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS (original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS Sun Nov 30 09:29:52 2008
@@ -12,6 +12,25 @@
Core and Builtins
-----------------
+- Issue #3996: On Windows, the PyOS_CheckStack function would cause the
+ interpreter to abort ("Fatal Python error: Could not reset the stack!")
+ instead of throwing a MemoryError.
+
+- Issue #4367: Python would segfault during compiling when the unicodedata
+ module couldn't be imported and \N escapes were present.
+
+- Issue #4233: Changed semantic of ``_fileio.FileIO``'s ``close()``
+ method on file objects with closefd=False. The file descriptor is still
+ kept open but the file object behaves like a closed file. The ``FileIO``
+ object also got a new readonly attribute ``closefd``.
+
+- Issue #4348: Some bytearray methods returned that didn't cause any change to
+ the bytearray, returned the same bytearray instead of a copy.
+
+- Issue #4317: Fixed a crash in the imageop.rgb2rgb8() function.
+
+- Issue #4230: If ``__getattr__`` is a descriptor, it now functions correctly.
+
- Issue #4048: The parser module now correctly validates relative imports.
- Issue #4225: ``from __future__ import unicode_literals`` didn't work in an
@@ -38,6 +57,19 @@
Library
-------
+- Issue #3741: DISTUTILS_USE_SDK set causes msvc9compiler.py to raise an
+ exception.
+
+- Issue #4363: The uuid.uuid1() and uuid.uuid4() functions now work even if
+ the ctypes module is not present.
+
+- FileIO's mode attribute now always includes ``"b"``.
+
+- Issue #4116: Resolve member name conflict in ScrolledCanvas.__init__.
+
+- httplib.HTTPConnection.putheader() now accepts an arbitrary number of values
+ for any header, matching what the documentation has claimed for a while.
+
- Issue #3774: Fixed an error when create a Tkinter menu item without command
and then remove it.
@@ -57,6 +89,8 @@
Build
-----
+- Issue #4289: Remove Cancel button from AdvancedDlg.
+
- Issue #1656675: Register a drop handler for .py* files on Windows.
- Issue #4120: Exclude manifest from extension modules in VS2008.
@@ -75,6 +109,11 @@
- Issue #4122: On Windows, fix a compilation error when using the
Py_UNICODE_ISSPACE macro in an extension module.
+Extension Modules
+-----------------
+
+- Issue #4396: The parser module now correctly validates the with statement.
+
What's New in Python 2.6 final
==============================
Modified: python/branches/tlee-ast-optimize/Modules/Setup.dist
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/Setup.dist (original)
+++ python/branches/tlee-ast-optimize/Modules/Setup.dist Sun Nov 30 09:29:52 2008
@@ -179,6 +179,11 @@
#_collections _collectionsmodule.c # Container types
#itertools itertoolsmodule.c # Functions creating iterators for efficient looping
#strop stropmodule.c # String manipulations
+#_functools _functoolsmodule.c # Tools for working with functions and callable objects
+#_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator
+#_pickle _pickle.c # pickle accelerator
+#datetime datetimemodule.c # date/time type
+#_bisect _bisectmodule.c # Bisection algorithms
#unicodedata unicodedata.c # static Unicode character database
@@ -468,8 +473,7 @@
#
# More information on Expat can be found at www.libexpat.org.
#
-#EXPAT_DIR=/usr/local/src/expat-1.95.2
-#pyexpat pyexpat.c -DHAVE_EXPAT_H -I$(EXPAT_DIR)/lib -L$(EXPAT_DIR) -lexpat
+#pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI
# Hye-Shik Chang's CJKCodecs
Modified: python/branches/tlee-ast-optimize/Modules/_fileio.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_fileio.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_fileio.c Sun Nov 30 09:29:52 2008
@@ -61,10 +61,7 @@
fileio_close(PyFileIOObject *self)
{
if (!self->closefd) {
- if (PyErr_WarnEx(PyExc_RuntimeWarning,
- "Trying to close unclosable fd!", 3) < 0) {
- return NULL;
- }
+ self->fd = -1;
Py_RETURN_NONE;
}
errno = internal_close(self);
@@ -211,6 +208,8 @@
flags |= O_CREAT;
append = 1;
break;
+ case 'b':
+ break;
case '+':
if (plus)
goto bad_mode;
@@ -685,12 +684,12 @@
{
if (self->readable) {
if (self->writable)
- return "r+";
+ return "rb+";
else
- return "r";
+ return "rb";
}
else
- return "w";
+ return "wb";
}
static PyObject *
@@ -821,6 +820,12 @@
}
static PyObject *
+get_closefd(PyFileIOObject *self, void *closure)
+{
+ return PyBool_FromLong((long)(self->closefd));
+}
+
+static PyObject *
get_mode(PyFileIOObject *self, void *closure)
{
return PyString_FromString(mode_string(self));
@@ -828,6 +833,8 @@
static PyGetSetDef fileio_getsetlist[] = {
{"closed", (getter)get_closed, NULL, "True if the file is closed"},
+ {"closefd", (getter)get_closefd, NULL,
+ "True if the file descriptor will be closed"},
{"mode", (getter)get_mode, NULL, "String giving the file mode"},
{0},
};
Modified: python/branches/tlee-ast-optimize/Modules/_multiprocessing/semaphore.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_multiprocessing/semaphore.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_multiprocessing/semaphore.c Sun Nov 30 09:29:52 2008
@@ -512,7 +512,6 @@
static PyObject *
semlock_iszero(SemLockObject *self)
{
- int sval;
#if HAVE_BROKEN_SEM_GETVALUE
if (sem_trywait(self->handle) < 0) {
if (errno == EAGAIN)
@@ -524,6 +523,7 @@
Py_RETURN_FALSE;
}
#else
+ int sval;
if (SEM_GETVALUE(self->handle, &sval) < 0)
return mp_SetError(NULL, MP_STANDARD_ERROR);
return PyBool_FromLong((long)sval == 0);
Modified: python/branches/tlee-ast-optimize/Modules/imageop.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/imageop.c (original)
+++ python/branches/tlee-ast-optimize/Modules/imageop.c Sun Nov 30 09:29:52 2008
@@ -590,7 +590,7 @@
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- if ( !check_multiply_size(len*4, x, "x", y, "y", 4) )
+ if ( !check_multiply_size(len, x, "x", y, "y", 4) )
return 0;
nlen = x*y;
if ( !check_multiply(nlen, x, y) )
Modified: python/branches/tlee-ast-optimize/Modules/parsermodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/parsermodule.c (original)
+++ python/branches/tlee-ast-optimize/Modules/parsermodule.c Sun Nov 30 09:29:52 2008
@@ -1559,7 +1559,7 @@
/* compound_stmt:
- * if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef | decorated
+ * if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef | decorated
*/
static int
validate_compound_stmt(node *tree)
@@ -1577,6 +1577,7 @@
|| (ntype == while_stmt)
|| (ntype == for_stmt)
|| (ntype == try_stmt)
+ || (ntype == with_stmt)
|| (ntype == funcdef)
|| (ntype == classdef)
|| (ntype == decorated))
@@ -2617,6 +2618,38 @@
return ok;
}
+/* with_var
+with_var: 'as' expr
+ */
+static int
+validate_with_var(node *tree)
+{
+ int nch = NCH(tree);
+ int ok = (validate_ntype(tree, with_var)
+ && (nch == 2)
+ && validate_name(CHILD(tree, 0), "as")
+ && validate_expr(CHILD(tree, 1)));
+ return ok;
+}
+
+/* with_stmt
+ * 0 1 2 -2 -1
+with_stmt: 'with' test [ with_var ] ':' suite
+ */
+static int
+validate_with_stmt(node *tree)
+{
+ int nch = NCH(tree);
+ int ok = (validate_ntype(tree, with_stmt)
+ && ((nch == 4) || (nch == 5))
+ && validate_name(CHILD(tree, 0), "with")
+ && validate_test(CHILD(tree, 1))
+ && (nch == 4 || validate_with_var(CHILD(tree, 2)))
+ && validate_colon(RCHILD(tree, -2))
+ && validate_suite(RCHILD(tree, -1)));
+ return ok;
+}
+
/* funcdef:
*
* -5 -4 -3 -2 -1
@@ -2993,6 +3026,9 @@
case funcdef:
res = validate_funcdef(tree);
break;
+ case with_stmt:
+ res = validate_with_stmt(tree);
+ break;
case classdef:
res = validate_class(tree);
break;
Modified: python/branches/tlee-ast-optimize/Objects/bytearrayobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/bytearrayobject.c (original)
+++ python/branches/tlee-ast-optimize/Objects/bytearrayobject.c Sun Nov 30 09:29:52 2008
@@ -1423,7 +1423,7 @@
{
register char *input, *output;
register const char *table;
- register Py_ssize_t i, c, changed = 0;
+ register Py_ssize_t i, c;
PyObject *input_obj = (PyObject*)self;
const char *output_start;
Py_ssize_t inlen;
@@ -1469,14 +1469,8 @@
/* If no deletions are required, use faster code */
for (i = inlen; --i >= 0; ) {
c = Py_CHARMASK(*input++);
- if (Py_CHARMASK((*output++ = table[c])) != c)
- changed = 1;
+ *output++ = table[c];
}
- if (changed || !PyByteArray_CheckExact(input_obj))
- goto done;
- Py_DECREF(result);
- Py_INCREF(input_obj);
- result = input_obj;
goto done;
}
@@ -1491,13 +1485,6 @@
if (trans_table[c] != -1)
if (Py_CHARMASK(*output++ = (char)trans_table[c]) == c)
continue;
- changed = 1;
- }
- if (!changed && PyByteArray_CheckExact(input_obj)) {
- Py_DECREF(result);
- Py_INCREF(input_obj);
- result = input_obj;
- goto done;
}
/* Fix the size of the resulting string */
if (inlen > 0)
@@ -1526,15 +1513,10 @@
!memcmp(target+offset+1, pattern+1, length-2) )
-/* Bytes ops must return a string. */
-/* If the object is subclass of bytes, create a copy */
+/* Bytes ops must return a string, create a copy */
Py_LOCAL(PyByteArrayObject *)
return_self(PyByteArrayObject *self)
{
- if (PyByteArray_CheckExact(self)) {
- Py_INCREF(self);
- return (PyByteArrayObject *)self;
- }
return (PyByteArrayObject *)PyByteArray_FromStringAndSize(
PyByteArray_AS_STRING(self),
PyByteArray_GET_SIZE(self));
Modified: python/branches/tlee-ast-optimize/Objects/typeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/typeobject.c (original)
+++ python/branches/tlee-ast-optimize/Objects/typeobject.c Sun Nov 30 09:29:52 2008
@@ -5391,6 +5391,24 @@
}
static PyObject *
+call_attribute(PyObject *self, PyObject *attr, PyObject *name)
+{
+ PyObject *res, *descr = NULL;
+ descrgetfunc f = Py_TYPE(attr)->tp_descr_get;
+
+ if (f != NULL) {
+ descr = f(attr, self, (PyObject *)(Py_TYPE(self)));
+ if (descr == NULL)
+ return NULL;
+ else
+ attr = descr;
+ }
+ res = PyObject_CallFunctionObjArgs(attr, name, NULL);
+ Py_XDECREF(descr);
+ return res;
+}
+
+static PyObject *
slot_tp_getattr_hook(PyObject *self, PyObject *name)
{
PyTypeObject *tp = Py_TYPE(self);
@@ -5409,24 +5427,39 @@
if (getattribute_str == NULL)
return NULL;
}
+ /* speed hack: we could use lookup_maybe, but that would resolve the
+ method fully for each attribute lookup for classes with
+ __getattr__, even when the attribute is present. So we use
+ _PyType_Lookup and create the method only when needed, with
+ call_attribute. */
getattr = _PyType_Lookup(tp, getattr_str);
if (getattr == NULL) {
/* No __getattr__ hook: use a simpler dispatcher */
tp->tp_getattro = slot_tp_getattro;
return slot_tp_getattro(self, name);
}
+ Py_INCREF(getattr);
+ /* speed hack: we could use lookup_maybe, but that would resolve the
+ method fully for each attribute lookup for classes with
+ __getattr__, even when self has the default __getattribute__
+ method. So we use _PyType_Lookup and create the method only when
+ needed, with call_attribute. */
getattribute = _PyType_Lookup(tp, getattribute_str);
if (getattribute == NULL ||
(Py_TYPE(getattribute) == &PyWrapperDescr_Type &&
((PyWrapperDescrObject *)getattribute)->d_wrapped ==
(void *)PyObject_GenericGetAttr))
res = PyObject_GenericGetAttr(self, name);
- else
- res = PyObject_CallFunctionObjArgs(getattribute, self, name, NULL);
+ else {
+ Py_INCREF(getattribute);
+ res = call_attribute(self, getattribute, name);
+ Py_DECREF(getattribute);
+ }
if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) {
PyErr_Clear();
- res = PyObject_CallFunctionObjArgs(getattr, self, name, NULL);
+ res = call_attribute(self, getattr, name);
}
+ Py_DECREF(getattr);
return res;
}
Modified: python/branches/tlee-ast-optimize/Objects/unicodeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/unicodeobject.c (original)
+++ python/branches/tlee-ast-optimize/Objects/unicodeobject.c Sun Nov 30 09:29:52 2008
@@ -7680,7 +7680,7 @@
}
PyDoc_STRVAR(splitlines__doc__,
-"S.splitlines([keepends]]) -> list of strings\n\
+"S.splitlines([keepends]) -> list of strings\n\
\n\
Return a list of the lines in S, breaking at line boundaries.\n\
Line breaks are not included in the resulting list unless keepends\n\
Modified: python/branches/tlee-ast-optimize/PC/VC6/pythoncore.dsp
==============================================================================
--- python/branches/tlee-ast-optimize/PC/VC6/pythoncore.dsp (original)
+++ python/branches/tlee-ast-optimize/PC/VC6/pythoncore.dsp Sun Nov 30 09:29:52 2008
@@ -747,10 +747,6 @@
# End Source File
# Begin Source File
-SOURCE=..\..\Modules\yuvconvert.c
-# End Source File
-# Begin Source File
-
SOURCE=..\..\Modules\zipimport.c
# End Source File
# Begin Source File
Modified: python/branches/tlee-ast-optimize/PC/VS7.1/pythoncore.vcproj
==============================================================================
--- python/branches/tlee-ast-optimize/PC/VS7.1/pythoncore.vcproj (original)
+++ python/branches/tlee-ast-optimize/PC/VS7.1/pythoncore.vcproj Sun Nov 30 09:29:52 2008
@@ -821,9 +821,6 @@
RelativePath="..\..\Modules\xxsubtype.c">
</File>
<File
- RelativePath="..\..\Modules\yuvconvert.c">
- </File>
- <File
RelativePath="..\..\Modules\zipimport.c">
</File>
</Files>
Modified: python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj
==============================================================================
--- python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj (original)
+++ python/branches/tlee-ast-optimize/PC/VS8.0/pythoncore.vcproj Sun Nov 30 09:29:52 2008
@@ -1171,14 +1171,6 @@
>
</File>
<File
- RelativePath="..\..\Modules\yuv.h"
- >
- </File>
- <File
- RelativePath="..\..\Modules\yuvconvert.c"
- >
- </File>
- <File
RelativePath="..\..\Modules\zipimport.c"
>
</File>
Modified: python/branches/tlee-ast-optimize/PC/os2vacpp/makefile
==============================================================================
--- python/branches/tlee-ast-optimize/PC/os2vacpp/makefile (original)
+++ python/branches/tlee-ast-optimize/PC/os2vacpp/makefile Sun Nov 30 09:29:52 2008
@@ -203,8 +203,7 @@
$(PATHOBJ)\StropModule.obj \
$(PATHOBJ)\StructModule.obj \
$(PATHOBJ)\TimeModule.obj \
- $(PATHOBJ)\ThreadModule.obj \
- $(PATHOBJ)\YUVConvert.obj
+ $(PATHOBJ)\ThreadModule.obj
# Standalone Parser Generator Program (Shares Some of Python's Modules)
PGEN = \
@@ -1113,8 +1112,7 @@
$(PY_INCLUDE)\pyerrors.h $(PY_INCLUDE)\pyfpe.h $(PY_INCLUDE)\pystate.h \
$(PY_INCLUDE)\python.h $(PY_INCLUDE)\pythonrun.h $(PY_INCLUDE)\rangeobject.h \
$(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \
- $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h \
- $(PY_MODULES)\yuv.h
+ $(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h
syslogmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h \
$(PY_INCLUDE)\classobject.h $(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h \
@@ -1198,8 +1196,6 @@
$(PY_INCLUDE)\sliceobject.h $(PY_INCLUDE)\stringobject.h \
$(PY_INCLUDE)\sysmodule.h $(PY_INCLUDE)\traceback.h $(PY_INCLUDE)\tupleobject.h
-yuvconvert.obj: $(PY_MODULES)\yuv.h
-
zlibmodule.obj: $(PY_INCLUDE)\abstract.h $(PY_INCLUDE)\ceval.h $(PY_INCLUDE)\classobject.h \
$(PY_INCLUDE)\cobject.h $(PY_INCLUDE)\complexobject.h pyconfig.h \
$(PY_INCLUDE)\dictobject.h $(PY_INCLUDE)\fileobject.h $(PY_INCLUDE)\floatobject.h \
Modified: python/branches/tlee-ast-optimize/PC/os2vacpp/makefile.omk
==============================================================================
--- python/branches/tlee-ast-optimize/PC/os2vacpp/makefile.omk (original)
+++ python/branches/tlee-ast-optimize/PC/os2vacpp/makefile.omk Sun Nov 30 09:29:52 2008
@@ -164,8 +164,7 @@
StropModule.obj \
StructModule.obj \
TimeModule.obj \
- ThreadModule.obj \
- YUVConvert.obj
+ ThreadModule.obj
# Omitted Modules (and Description/Reason):
#
@@ -803,8 +802,7 @@
intrcheck.h listobject.h longobject.h methodobject.h modsupport.h \
moduleobject.h mymalloc.h myproto.h object.h objimpl.h pydebug.h \
pyerrors.h pyfpe.h pystate.h python.h pythonrun.h rangeobject.h \
- sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h \
- yuv.h
+ sliceobject.h stringobject.h sysmodule.h traceback.h tupleobject.h
syslogmodule.obj: abstract.h ceval.h classobject.h cobject.h \
complexobject.h pyconfig.h dictobject.h fileobject.h floatobject.h \
@@ -854,8 +852,6 @@
pythonrun.h rangeobject.h sliceobject.h stringobject.h sysmodule.h \
traceback.h tupleobject.h
-yuvconvert.obj: yuv.h
-
zlibmodule.obj: abstract.h ceval.h classobject.h cobject.h complexobject.h \
pyconfig.h dictobject.h fileobject.h floatobject.h funcobject.h \
import.h intobject.h intrcheck.h listobject.h longobject.h \
Modified: python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj
==============================================================================
--- python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj (original)
+++ python/branches/tlee-ast-optimize/PCbuild/pythoncore.vcproj Sun Nov 30 09:29:52 2008
@@ -1171,14 +1171,6 @@
>
</File>
<File
- RelativePath="..\Modules\yuv.h"
- >
- </File>
- <File
- RelativePath="..\Modules\yuvconvert.c"
- >
- </File>
- <File
RelativePath="..\Modules\zipimport.c"
>
</File>
Modified: python/branches/tlee-ast-optimize/Python/ast.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/ast.c (original)
+++ python/branches/tlee-ast-optimize/Python/ast.c Sun Nov 30 09:29:52 2008
@@ -47,7 +47,8 @@
static identifier
new_identifier(const char* n, PyArena *arena) {
PyObject* id = PyString_InternFromString(n);
- PyArena_AddPyObject(arena, id);
+ if (id != NULL)
+ PyArena_AddPyObject(arena, id);
return id;
}
@@ -604,6 +605,7 @@
*/
REQ(n, fplist);
for (i = 0; i < len; i++) {
+ PyObject *arg_id;
const node *fpdef_node = CHILD(n, 2*i);
const node *child;
expr_ty arg;
@@ -612,9 +614,12 @@
child = CHILD(fpdef_node, 0);
if (TYPE(child) == NAME) {
if (!forbidden_check(c, n, STR(child)))
- return NULL;
- arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child),
- child->n_col_offset, c->c_arena);
+ return NULL;
+ arg_id = NEW_IDENTIFIER(child);
+ if (!arg_id)
+ return NULL;
+ arg = Name(arg_id, Store, LINENO(child), child->n_col_offset,
+ c->c_arena);
}
else {
assert(TYPE(fpdef_node) == fpdef);
@@ -724,11 +729,14 @@
}
}
if (TYPE(CHILD(ch, 0)) == NAME) {
+ PyObject *id;
expr_ty name;
if (!forbidden_check(c, n, STR(CHILD(ch, 0))))
goto error;
- name = Name(NEW_IDENTIFIER(CHILD(ch, 0)),
- Param, LINENO(ch), ch->n_col_offset,
+ id = NEW_IDENTIFIER(CHILD(ch, 0));
+ if (!id)
+ goto error;
+ name = Name(id, Param, LINENO(ch), ch->n_col_offset,
c->c_arena);
if (!name)
goto error;
@@ -741,12 +749,16 @@
if (!forbidden_check(c, CHILD(n, i+1), STR(CHILD(n, i+1))))
goto error;
vararg = NEW_IDENTIFIER(CHILD(n, i+1));
+ if (!vararg)
+ goto error;
i += 3;
break;
case DOUBLESTAR:
if (!forbidden_check(c, CHILD(n, i+1), STR(CHILD(n, i+1))))
goto error;
kwarg = NEW_IDENTIFIER(CHILD(n, i+1));
+ if (!kwarg)
+ goto error;
i += 3;
break;
default:
@@ -1282,11 +1294,14 @@
node *ch = CHILD(n, 0);
switch (TYPE(ch)) {
- case NAME:
+ case NAME: {
/* All names start in Load context, but may later be
changed. */
- return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset,
- c->c_arena);
+ PyObject *name = NEW_IDENTIFIER(ch);
+ if (!name)
+ return NULL;
+ return Name(name, Load, LINENO(n), n->n_col_offset, c->c_arena);
+ }
case STRING: {
PyObject *str = parsestrplus(c, n);
if (!str) {
@@ -1294,13 +1309,14 @@
if (PyErr_ExceptionMatches(PyExc_UnicodeError)){
PyObject *type, *value, *tback, *errstr;
PyErr_Fetch(&type, &value, &tback);
- errstr = ((PyUnicodeErrorObject *)value)->reason;
+ errstr = PyObject_Str(value);
if (errstr) {
char *s = "";
char buf[128];
s = PyString_AsString(errstr);
PyOS_snprintf(buf, sizeof(buf), "(unicode error) %s", s);
ast_error(n, buf);
+ Py_DECREF(errstr);
} else {
ast_error(n, "(unicode error) unknown error");
}
@@ -1543,7 +1559,10 @@
return ast_for_call(c, CHILD(n, 1), left_expr);
}
else if (TYPE(CHILD(n, 0)) == DOT ) {
- return Attribute(left_expr, NEW_IDENTIFIER(CHILD(n, 1)), Load,
+ PyObject *attr_id = NEW_IDENTIFIER(CHILD(n, 1));
+ if (!attr_id)
+ return NULL;
+ return Attribute(left_expr, attr_id, Load,
LINENO(n), n->n_col_offset, c->c_arena);
}
else {
@@ -2317,7 +2336,7 @@
dotted_as_name: dotted_name ['as' NAME]
dotted_name: NAME ('.' NAME)*
*/
- PyObject *str;
+ PyObject *str, *name;
loop:
switch (TYPE(n)) {
@@ -2325,8 +2344,13 @@
str = NULL;
if (NCH(n) == 3) {
str = NEW_IDENTIFIER(CHILD(n, 2));
+ if (!str)
+ return NULL;
}
- return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena);
+ name = NEW_IDENTIFIER(CHILD(n, 0));
+ if (!name)
+ return NULL;
+ return alias(name, str, c->c_arena);
case dotted_as_name:
if (NCH(n) == 1) {
n = CHILD(n, 0);
@@ -2338,12 +2362,18 @@
return NULL;
assert(!a->asname);
a->asname = NEW_IDENTIFIER(CHILD(n, 2));
+ if (!a->asname)
+ return NULL;
return a;
}
break;
case dotted_name:
- if (NCH(n) == 1)
- return alias(NEW_IDENTIFIER(CHILD(n, 0)), NULL, c->c_arena);
+ if (NCH(n) == 1) {
+ name = NEW_IDENTIFIER(CHILD(n, 0));
+ if (!name)
+ return NULL;
+ return alias(name, NULL, c->c_arena);
+ }
else {
/* Create a string of the form "a.b.c" */
int i;
@@ -3022,6 +3052,7 @@
ast_for_classdef(struct compiling *c, const node *n, asdl_seq *decorator_seq)
{
/* classdef: 'class' NAME ['(' testlist ')'] ':' suite */
+ PyObject *classname;
asdl_seq *bases, *s;
REQ(n, classdef);
@@ -3033,16 +3064,22 @@
s = ast_for_suite(c, CHILD(n, 3));
if (!s)
return NULL;
- return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, decorator_seq,
- LINENO(n), n->n_col_offset, c->c_arena);
+ classname = NEW_IDENTIFIER(CHILD(n, 1));
+ if (!classname)
+ return NULL;
+ return ClassDef(classname, NULL, s, decorator_seq, LINENO(n),
+ n->n_col_offset, c->c_arena);
}
/* check for empty base list */
if (TYPE(CHILD(n,3)) == RPAR) {
s = ast_for_suite(c, CHILD(n,5));
if (!s)
- return NULL;
- return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, decorator_seq,
- LINENO(n), n->n_col_offset, c->c_arena);
+ return NULL;
+ classname = NEW_IDENTIFIER(CHILD(n, 1));
+ if (!classname)
+ return NULL;
+ return ClassDef(classname, NULL, s, decorator_seq, LINENO(n),
+ n->n_col_offset, c->c_arena);
}
/* else handle the base class list */
@@ -3053,7 +3090,10 @@
s = ast_for_suite(c, CHILD(n, 6));
if (!s)
return NULL;
- return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), bases, s, decorator_seq,
+ classname = NEW_IDENTIFIER(CHILD(n, 1));
+ if (!classname)
+ return NULL;
+ return ClassDef(classname, bases, s, decorator_seq,
LINENO(n), n->n_col_offset, c->c_arena);
}
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 Nov 30 09:29:52 2008
@@ -1797,7 +1797,7 @@
EXCEPTION_EXECUTE_HANDLER :
EXCEPTION_CONTINUE_SEARCH) {
int errcode = _resetstkoflw();
- if (errcode)
+ if (errcode == 0)
{
Py_FatalError("Could not reset the stack!");
}
Modified: python/branches/tlee-ast-optimize/Tools/msi/msi.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/msi/msi.py (original)
+++ python/branches/tlee-ast-optimize/Tools/msi/msi.py Sun Nov 30 09:29:52 2008
@@ -716,18 +716,15 @@
#####################################################################
# Advanced Dialog.
advanced = PyDialog(db, "AdvancedDlg", x, y, w, h, modal, title,
- "CompilePyc", "Next", "Cancel")
+ "CompilePyc", "Ok", "Ok")
advanced.title("Advanced Options for [ProductName]")
# A radio group with two options: allusers, justme
advanced.checkbox("CompilePyc", 135, 60, 230, 50, 3,
- "COMPILEALL", "Compile .py files to byte code after installation", "Next")
+ "COMPILEALL", "Compile .py files to byte code after installation", "Ok")
- c = advanced.next("Finish", "Cancel")
+ c = advanced.cancel("Ok", "CompilePyc", name="Ok") # Button just has location of cancel button.
c.event("EndDialog", "Return")
- c = advanced.cancel("Cancel", "CompilePyc")
- c.event("SpawnDialog", "CancelDlg")
-
#####################################################################
# Existing Directory dialog
dlg = Dialog(db, "ExistingDirectoryDlg", 50, 30, 200, 80, modal, title,
Modified: python/branches/tlee-ast-optimize/Tools/scripts/svneol.py
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/scripts/svneol.py (original)
+++ python/branches/tlee-ast-optimize/Tools/scripts/svneol.py Sun Nov 30 09:29:52 2008
@@ -39,9 +39,9 @@
format = int(open(os.path.join(root, ".svn", "format")).read().strip())
except IOError:
return []
- if format == 8:
- # In version 8, committed props are stored in prop-base,
- # local modifications in props
+ if format in (8, 9):
+ # In version 8 and 9, committed props are stored in prop-base, local
+ # modifications in props
return [os.path.join(root, ".svn", "prop-base", fn+".svn-base"),
os.path.join(root, ".svn", "props", fn+".svn-work")]
raise ValueError, "Unknown repository format"
Modified: python/branches/tlee-ast-optimize/configure
==============================================================================
--- python/branches/tlee-ast-optimize/configure (original)
+++ python/branches/tlee-ast-optimize/configure Sun Nov 30 09:29:52 2008
@@ -1,5 +1,5 @@
#! /bin/sh
-# From configure.in Revision: 66764 .
+# From configure.in Revision: 67227 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for python 2.7.
#
@@ -2090,7 +2090,7 @@
# Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
# _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
# Marc Recht
- NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6A-S)
+ NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S])
define_xopen_source=no;;
# On Solaris 2.6, sys/wait.h is inconsistent in the usage
# of union __?sigval. Reported by Stuart Bishop.
Modified: python/branches/tlee-ast-optimize/configure.in
==============================================================================
--- python/branches/tlee-ast-optimize/configure.in (original)
+++ python/branches/tlee-ast-optimize/configure.in Sun Nov 30 09:29:52 2008
@@ -261,7 +261,7 @@
# Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of
# _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by
# Marc Recht
- NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6[A-S])
+ NetBSD/1.5 | NetBSD/1.5.* | NetBSD/1.6 | NetBSD/1.6.* | NetBSD/1.6@<:@A-S@:>@)
define_xopen_source=no;;
# On Solaris 2.6, sys/wait.h is inconsistent in the usage
# of union __?sigval. Reported by Stuart Bishop.
More information about the Python-checkins
mailing list