Python-checkins
Threads by month
- ----- 2025 -----
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
February 2009
- 22 participants
- 1387 discussions
Author: benjamin.peterson
Date: Sat Feb 28 20:20:42 2009
New Revision: 70074
Log:
Merged revisions 69975,69977,69982,69986,69989-69990,69995-69996,70001,70005,70009,70015,70019,70024,70027-70029,70037,70051,70053,70057,70063,70072 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r69975 | mark.dickinson | 2009-02-25 14:33:49 -0600 (Wed, 25 Feb 2009) | 10 lines
Merged revisions 69974 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69974 | mark.dickinson | 2009-02-25 20:29:50 +0000 (Wed, 25 Feb 2009) | 3 lines
Replace long with twodigits, to avoid depending
on sizeof(digit) < sizeof(long)
........
................
r69977 | tarek.ziade | 2009-02-25 16:31:38 -0600 (Wed, 25 Feb 2009) | 9 lines
Merged revisions 69976 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69976 | tarek.ziade | 2009-02-25 23:29:27 +0100 (Wed, 25 Feb 2009) | 1 line
Fixed #5316 : test failure in test_site
........
................
r69982 | raymond.hettinger | 2009-02-25 16:51:40 -0600 (Wed, 25 Feb 2009) | 1 line
Sync-up 3.1 docs with 2.7 for collections.Counter().
................
r69986 | raymond.hettinger | 2009-02-25 18:27:18 -0600 (Wed, 25 Feb 2009) | 1 line
Fix typo.
................
r69989 | benjamin.peterson | 2009-02-25 20:44:26 -0600 (Wed, 25 Feb 2009) | 36 lines
Blocked revisions 69937,69946,69952-69953,69955,69959,69981,69983 via svnmerge
........
r69937 | raymond.hettinger | 2009-02-24 06:23:23 -0600 (Tue, 24 Feb 2009) | 3 lines
Backport 69934: Register xrange() as a Sequence.
........
r69946 | brett.cannon | 2009-02-24 16:01:02 -0600 (Tue, 24 Feb 2009) | 2 lines
Expand upon test_site.test_s_option to try to debug its failure.
........
r69952 | raymond.hettinger | 2009-02-24 18:37:57 -0600 (Tue, 24 Feb 2009) | 1 line
Sync-up py3.1 doc updates for super().
........
r69953 | raymond.hettinger | 2009-02-24 18:39:47 -0600 (Tue, 24 Feb 2009) | 1 line
Restore Py2.x version of sample call to super().
........
r69955 | raymond.hettinger | 2009-02-24 18:52:37 -0600 (Tue, 24 Feb 2009) | 1 line
More markup and spelling fixes.
........
r69959 | raymond.hettinger | 2009-02-24 19:06:52 -0600 (Tue, 24 Feb 2009) | 1 line
Remove reference to zero argument form of super() in 2.x docs.
........
r69981 | raymond.hettinger | 2009-02-25 16:48:24 -0600 (Wed, 25 Feb 2009) | 1 line
Clarify Counter() docs.
........
r69983 | raymond.hettinger | 2009-02-25 18:05:24 -0600 (Wed, 25 Feb 2009) | 1 line
Fix typo.
........
................
r69990 | benjamin.peterson | 2009-02-25 21:38:59 -0600 (Wed, 25 Feb 2009) | 45 lines
Merged revisions 69803-69805,69840,69901,69905,69907,69924,69927,69987 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69803 | georg.brandl | 2009-02-20 01:48:21 -0600 (Fri, 20 Feb 2009) | 1 line
#5327: fix a broken link by joining it.
........
r69804 | georg.brandl | 2009-02-20 02:22:21 -0600 (Fri, 20 Feb 2009) | 1 line
At least separate imports from other statements.
........
r69805 | georg.brandl | 2009-02-20 02:45:47 -0600 (Fri, 20 Feb 2009) | 2 lines
Fix punctuation.
........
r69840 | georg.brandl | 2009-02-21 13:09:40 -0600 (Sat, 21 Feb 2009) | 1 line
#5338, #5339: two types in the API manual.
........
r69901 | georg.brandl | 2009-02-23 05:24:46 -0600 (Mon, 23 Feb 2009) | 2 lines
#5349: C++ pure virtuals can also have an implementation.
........
r69905 | georg.brandl | 2009-02-23 09:51:27 -0600 (Mon, 23 Feb 2009) | 2 lines
#5352: str.count() counts non-overlapping instances.
........
r69907 | georg.brandl | 2009-02-23 12:33:48 -0600 (Mon, 23 Feb 2009) | 1 line
Fix grammar.
........
r69924 | benjamin.peterson | 2009-02-23 20:45:35 -0600 (Mon, 23 Feb 2009) | 1 line
update README on running tests
........
r69927 | neil.schemenauer | 2009-02-23 22:23:25 -0600 (Mon, 23 Feb 2009) | 1 line
Fix call to os.waitpid, it does not take keyword args.
........
r69987 | benjamin.peterson | 2009-02-25 18:30:11 -0600 (Wed, 25 Feb 2009) | 1 line
fix str.format()'s first arg #5371
........
................
r69995 | benjamin.peterson | 2009-02-26 12:39:03 -0600 (Thu, 26 Feb 2009) | 8 lines
Blocked revisions 69994 via svnmerge
........
r69994 | georg.brandl | 2009-02-26 11:36:26 -0600 (Thu, 26 Feb 2009) | 1 line
Document that setting sys.py3kwarning wont do anything.
........
................
r69996 | benjamin.peterson | 2009-02-26 12:55:48 -0600 (Thu, 26 Feb 2009) | 14 lines
Merged revisions 69811,69947 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r69811 | collin.winter | 2009-02-20 13:30:41 -0600 (Fri, 20 Feb 2009) | 2 lines
Issue 5176: special-case string formatting in BINARY_MODULO implementation. This shows a modest (1-3%) speed-up in templating systems, for example.
........
r69947 | jeffrey.yasskin | 2009-02-24 16:48:34 -0600 (Tue, 24 Feb 2009) | 3 lines
Tools/scripts/analyze_dxp.py, a module with some helper functions to
analyze the output of sys.getdxp().
........
................
r70001 | benjamin.peterson | 2009-02-26 13:17:12 -0600 (Thu, 26 Feb 2009) | 8 lines
Blocked revisions 70000 via svnmerge
........
r70000 | benjamin.peterson | 2009-02-26 13:07:18 -0600 (Thu, 26 Feb 2009) | 1 line
remove deprecated symtable.Symbol methods
........
................
r70005 | tarek.ziade | 2009-02-26 17:47:00 -0600 (Thu, 26 Feb 2009) | 9 lines
Merged revisions 70003 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70003 | tarek.ziade | 2009-02-27 00:44:00 +0100 (Fri, 27 Feb 2009) | 1 line
removed unused import
........
................
r70009 | tarek.ziade | 2009-02-26 20:22:25 -0600 (Thu, 26 Feb 2009) | 9 lines
Merged revisions 70007 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70007 | tarek.ziade | 2009-02-27 03:14:35 +0100 (Fri, 27 Feb 2009) | 1 line
more info on long_description
........
................
r70015 | raymond.hettinger | 2009-02-27 01:47:32 -0600 (Fri, 27 Feb 2009) | 1 line
Give mapping views a usable repr.
................
r70019 | tarek.ziade | 2009-02-27 06:58:56 -0600 (Fri, 27 Feb 2009) | 9 lines
Merged revisions 70017 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70017 | tarek.ziade | 2009-02-27 13:53:34 +0100 (Fri, 27 Feb 2009) | 1 line
Issue #5052: make Distutils compatible with 2.3 again.
........
................
r70024 | georg.brandl | 2009-02-27 10:46:46 -0600 (Fri, 27 Feb 2009) | 1 line
#5357: fix incomprehensible paragraph in urlopen() doc.
................
r70027 | georg.brandl | 2009-02-27 11:03:38 -0600 (Fri, 27 Feb 2009) | 1 line
#5360: remove RO which has been kicked from 3k.
................
r70028 | georg.brandl | 2009-02-27 11:11:23 -0600 (Fri, 27 Feb 2009) | 1 line
#5360: replace PyObject_HEAD_INIT by PyVarObject_HEAD_INIT.
................
r70029 | georg.brandl | 2009-02-27 11:52:38 -0600 (Fri, 27 Feb 2009) | 1 line
another instance of #804543: use strdup() when saving the result of setlocale() because it could be overwritten by subsequent setlocale()s.
................
r70037 | benjamin.peterson | 2009-02-27 16:29:33 -0600 (Fri, 27 Feb 2009) | 15 lines
Blocked revisions 70011,70016 via svnmerge
........
r70011 | brett.cannon | 2009-02-26 21:38:28 -0600 (Thu, 26 Feb 2009) | 5 lines
Fix a bug where code was trying to index an int. Left over from the situation
from using str.rpartition to str.rindex.
Closes Issue5213.
........
r70016 | raymond.hettinger | 2009-02-27 02:09:47 -0600 (Fri, 27 Feb 2009) | 1 line
Give mapping views a usable repr.
........
................
r70051 | tarek.ziade | 2009-02-28 04:16:43 -0600 (Sat, 28 Feb 2009) | 9 lines
Merged revisions 70049 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70049 | tarek.ziade | 2009-02-28 11:08:02 +0100 (Sat, 28 Feb 2009) | 1 line
Issues #1533164 and #5378: Added quiet and force-optimize options to Distutils bdist_rpm command
........
................
r70053 | hirokazu.yamamoto | 2009-02-28 04:56:50 -0600 (Sat, 28 Feb 2009) | 10 lines
Merged revisions 70052 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70052 | hirokazu.yamamoto | 2009-02-28 19:31:54 +0900 | 2 lines
Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer
overrun.
........
................
r70057 | hirokazu.yamamoto | 2009-02-28 06:21:53 -0600 (Sat, 28 Feb 2009) | 10 lines
Merged revisions 70056 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70056 | hirokazu.yamamoto | 2009-02-28 21:13:07 +0900 | 2 lines
Issue #1733986: Fixed mmap crash in accessing elements of second map object
with same tagname but larger size than first map. (Windows)
........
................
r70063 | mark.dickinson | 2009-02-28 09:53:24 -0600 (Sat, 28 Feb 2009) | 9 lines
Merged revisions 70062 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70062 | mark.dickinson | 2009-02-28 15:50:40 +0000 (Sat, 28 Feb 2009) | 2 lines
Issue #5393: typo in cmath.cos and cmath.cosh docstring
........
................
r70072 | benjamin.peterson | 2009-02-28 13:06:54 -0600 (Sat, 28 Feb 2009) | 1 line
#4967 fix buggy read()
................
Added:
python/branches/io-c/Lib/distutils/tests/test_bdist_rpm.py
- copied unchanged from r70072, /python/branches/py3k/Lib/distutils/tests/test_bdist_rpm.py
python/branches/io-c/Tools/scripts/analyze_dxp.py
- copied unchanged from r70072, /python/branches/py3k/Tools/scripts/analyze_dxp.py
Modified:
python/branches/io-c/ (props changed)
python/branches/io-c/Doc/c-api/intro.rst
python/branches/io-c/Doc/c-api/veryhigh.rst
python/branches/io-c/Doc/distutils/setupscript.rst
python/branches/io-c/Doc/distutils/uploading.rst
python/branches/io-c/Doc/extending/newtypes.rst
python/branches/io-c/Doc/extending/windows.rst
python/branches/io-c/Doc/howto/webservers.rst
python/branches/io-c/Doc/library/2to3.rst
python/branches/io-c/Doc/library/abc.rst
python/branches/io-c/Doc/library/cgi.rst
python/branches/io-c/Doc/library/cgitb.rst
python/branches/io-c/Doc/library/collections.rst
python/branches/io-c/Doc/library/functions.rst
python/branches/io-c/Doc/library/stdtypes.rst
python/branches/io-c/Doc/library/urllib.request.rst
python/branches/io-c/Doc/library/xml.etree.elementtree.rst
python/branches/io-c/Doc/whatsnew/2.5.rst
python/branches/io-c/Lib/_abcoll.py
python/branches/io-c/Lib/distutils/README
python/branches/io-c/Lib/distutils/command/bdist_rpm.py
python/branches/io-c/Lib/distutils/command/build_ext.py
python/branches/io-c/Lib/distutils/command/install.py
python/branches/io-c/Lib/distutils/command/upload.py
python/branches/io-c/Lib/distutils/tests/test_build_ext.py
python/branches/io-c/Lib/distutils/tests/test_config.py
python/branches/io-c/Lib/distutils/tests/test_install.py
python/branches/io-c/Lib/distutils/tests/test_sdist.py
python/branches/io-c/Lib/socketserver.py
python/branches/io-c/Lib/test/test_mmap.py
python/branches/io-c/Lib/test/test_opcodes.py
python/branches/io-c/Misc/NEWS
python/branches/io-c/Modules/_ssl.c
python/branches/io-c/Modules/cmathmodule.c
python/branches/io-c/Modules/mmapmodule.c
python/branches/io-c/Modules/python.c
python/branches/io-c/Objects/longobject.c
python/branches/io-c/Python/ceval.c
python/branches/io-c/README
python/branches/io-c/Tools/scripts/README
Modified: python/branches/io-c/Doc/c-api/intro.rst
==============================================================================
--- python/branches/io-c/Doc/c-api/intro.rst (original)
+++ python/branches/io-c/Doc/c-api/intro.rst Sat Feb 28 20:20:42 2009
@@ -187,7 +187,7 @@
the caller is said to *borrow* the reference. Nothing needs to be done for a
borrowed reference.
-Conversely, when a calling function passes it a reference to an object, there
+Conversely, when a calling function passes in a reference to an object, there
are two possibilities: the function *steals* a reference to the object, or it
does not. *Stealing a reference* means that when you pass a reference to a
function, that function assumes that it now owns that reference, and you are not
Modified: python/branches/io-c/Doc/c-api/veryhigh.rst
==============================================================================
--- python/branches/io-c/Doc/c-api/veryhigh.rst (original)
+++ python/branches/io-c/Doc/c-api/veryhigh.rst Sat Feb 28 20:20:42 2009
@@ -16,7 +16,7 @@
:const:`Py_file_input`, and :const:`Py_single_input`. These are described
following the functions which accept them as parameters.
-Note also that several of these functions take :ctype:`FILE\*` parameters. On
+Note also that several of these functions take :ctype:`FILE\*` parameters. One
particular issue which needs to be handled carefully is that the :ctype:`FILE`
structure for different C libraries can be different and incompatible. Under
Windows (at least), it is possible for dynamically linked extensions to actually
Modified: python/branches/io-c/Doc/distutils/setupscript.rst
==============================================================================
--- python/branches/io-c/Doc/distutils/setupscript.rst (original)
+++ python/branches/io-c/Doc/distutils/setupscript.rst Sat Feb 28 20:20:42 2009
@@ -19,18 +19,18 @@
distributions. The Distutils' own setup script, shown here, is used to install
the package into Python 1.5.2.) ::
- #!/usr/bin/env python
+ #!/usr/bin/env python
- from distutils.core import setup
+ from distutils.core import setup
- setup(name='Distutils',
- version='1.0',
- description='Python Distribution Utilities',
- author='Greg Ward',
- author_email='gward(a)python.net',
- url='http://www.python.org/sigs/distutils-sig/',
- packages=['distutils', 'distutils.command'],
- )
+ setup(name='Distutils',
+ version='1.0',
+ description='Python Distribution Utilities',
+ author='Greg Ward',
+ author_email='gward(a)python.net',
+ url='http://www.python.org/sigs/distutils-sig/',
+ packages=['distutils', 'distutils.command'],
+ )
There are only two differences between this and the trivial one-file
distribution presented in section :ref:`distutils-simple-example`: more metadata, and the
@@ -53,8 +53,8 @@
:func:`os.listdir` to specify files, you should be careful to write portable
code instead of hardcoding path separators::
- glob.glob(os.path.join('mydir', 'subdir', '*.html'))
- os.listdir(os.path.join('mydir', 'subdir'))
+ glob.glob(os.path.join('mydir', 'subdir', '*.html'))
+ os.listdir(os.path.join('mydir', 'subdir'))
.. _listing-packages:
@@ -81,7 +81,7 @@
package at all) are in :file:`lib`, modules in the :mod:`foo` package are in
:file:`lib/foo`, and so forth. Then you would put ::
- package_dir = {'': 'lib'}
+ package_dir = {'': 'lib'}
in your setup script. The keys to this dictionary are package names, and an
empty package name stands for the root package. The values are directory names
@@ -92,7 +92,7 @@
:file:`lib`, the :mod:`foo.bar` package in :file:`lib/bar`, etc. This would be
written in the setup script as ::
- package_dir = {'foo': 'lib'}
+ package_dir = {'foo': 'lib'}
A ``package: dir`` entry in the :option:`package_dir` dictionary implicitly
applies to all packages below *package*, so the :mod:`foo.bar` case is
@@ -114,7 +114,7 @@
"root package" (i.e., no package at all). This simplest case was shown in
section :ref:`distutils-simple-example`; here is a slightly more involved example::
- py_modules = ['mod1', 'pkg.mod2']
+ py_modules = ['mod1', 'pkg.mod2']
This describes two modules, one of them in the "root" package, the other in the
:mod:`pkg` package. Again, the default package/directory layout implies that
@@ -144,17 +144,17 @@
implemented by :file:`foo.c`. If no additional instructions to the
compiler/linker are needed, describing this extension is quite simple::
- Extension('foo', ['foo.c'])
+ Extension('foo', ['foo.c'])
The :class:`Extension` class can be imported from :mod:`distutils.core` along
with :func:`setup`. Thus, the setup script for a module distribution that
contains only this one extension and nothing else might be::
- from distutils.core import setup, Extension
- setup(name='foo',
- version='1.0',
- ext_modules=[Extension('foo', ['foo.c'])],
- )
+ from distutils.core import setup, Extension
+ setup(name='foo',
+ version='1.0',
+ ext_modules=[Extension('foo', ['foo.c'])],
+ )
The :class:`Extension` class (actually, the underlying extension-building
machinery implemented by the :command:`build_ext` command) supports a great deal
@@ -168,11 +168,11 @@
The first argument to the :class:`Extension` constructor is always the name of
the extension, including any package names. For example, ::
- Extension('foo', ['src/foo1.c', 'src/foo2.c'])
+ Extension('foo', ['src/foo1.c', 'src/foo2.c'])
describes an extension that lives in the root package, while ::
- Extension('pkg.foo', ['src/foo1.c', 'src/foo2.c'])
+ Extension('pkg.foo', ['src/foo1.c', 'src/foo2.c'])
describes the same extension in the :mod:`pkg` package. The source files and
resulting object code are identical in both cases; the only difference is where
@@ -183,11 +183,11 @@
same base package), use the :option:`ext_package` keyword argument to
:func:`setup`. For example, ::
- setup(...,
- ext_package='pkg',
- ext_modules=[Extension('foo', ['foo.c']),
- Extension('subpkg.bar', ['bar.c'])],
- )
+ setup(...,
+ ext_package='pkg',
+ ext_modules=[Extension('foo', ['foo.c']),
+ Extension('subpkg.bar', ['bar.c'])],
+ )
will compile :file:`foo.c` to the extension :mod:`pkg.foo`, and :file:`bar.c` to
:mod:`pkg.subpkg.bar`.
@@ -212,15 +212,15 @@
This warning notwithstanding, options to SWIG can be currently passed like
this::
- setup(...,
- ext_modules=[Extension('_foo', ['foo.i'],
- swig_opts=['-modern', '-I../include'])],
- py_modules=['foo'],
- )
+ setup(...,
+ ext_modules=[Extension('_foo', ['foo.i'],
+ swig_opts=['-modern', '-I../include'])],
+ py_modules=['foo'],
+ )
Or on the commandline like this::
- > python setup.py build_ext --swig-opts="-modern -I../include"
+ > python setup.py build_ext --swig-opts="-modern -I../include"
On some platforms, you can include non-source files that are processed by the
compiler and included in your extension. Currently, this just means Windows
@@ -239,18 +239,18 @@
For example, if your extension requires header files in the :file:`include`
directory under your distribution root, use the ``include_dirs`` option::
- Extension('foo', ['foo.c'], include_dirs=['include'])
+ Extension('foo', ['foo.c'], include_dirs=['include'])
You can specify absolute directories there; if you know that your extension will
only be built on Unix systems with X11R6 installed to :file:`/usr`, you can get
away with ::
- Extension('foo', ['foo.c'], include_dirs=['/usr/include/X11'])
+ Extension('foo', ['foo.c'], include_dirs=['/usr/include/X11'])
You should avoid this sort of non-portable usage if you plan to distribute your
code: it's probably better to write C code like ::
- #include <X11/Xlib.h>
+ #include <X11/Xlib.h>
If you need to include header files from some other Python extension, you can
take advantage of the fact that header files are installed in a consistent way
@@ -262,17 +262,17 @@
included in the search path when building Python extensions, the best approach
is to write C code like ::
- #include <Numerical/arrayobject.h>
+ #include <Numerical/arrayobject.h>
If you must put the :file:`Numerical` include directory right into your header
search path, though, you can find that directory using the Distutils
:mod:`distutils.sysconfig` module::
- from distutils.sysconfig import get_python_inc
- incdir = os.path.join(get_python_inc(plat_specific=1), 'Numerical')
- setup(...,
- Extension(..., include_dirs=[incdir]),
- )
+ from distutils.sysconfig import get_python_inc
+ incdir = os.path.join(get_python_inc(plat_specific=1), 'Numerical')
+ setup(...,
+ Extension(..., include_dirs=[incdir]),
+ )
Even though this is quite portable---it will work on any Python installation,
regardless of platform---it's probably easier to just write your C code in the
@@ -288,17 +288,17 @@
For example::
- Extension(...,
- define_macros=[('NDEBUG', '1'),
- ('HAVE_STRFTIME', None)],
- undef_macros=['HAVE_FOO', 'HAVE_BAR'])
+ Extension(...,
+ define_macros=[('NDEBUG', '1'),
+ ('HAVE_STRFTIME', None)],
+ undef_macros=['HAVE_FOO', 'HAVE_BAR'])
is the equivalent of having this at the top of every C source file::
- #define NDEBUG 1
- #define HAVE_STRFTIME
- #undef HAVE_FOO
- #undef HAVE_BAR
+ #define NDEBUG 1
+ #define HAVE_STRFTIME
+ #undef HAVE_FOO
+ #undef HAVE_BAR
Library options
@@ -313,15 +313,15 @@
For example, if you need to link against libraries known to be in the standard
library search path on target systems ::
- Extension(...,
- libraries=['_gdbm', 'readline'])
+ Extension(...,
+ libraries=['gdbm', 'readline'])
If you need to link with libraries in a non-standard location, you'll have to
include the location in ``library_dirs``::
- Extension(...,
- library_dirs=['/usr/X11R6/lib'],
- libraries=['X11', 'Xt'])
+ Extension(...,
+ library_dirs=['/usr/X11R6/lib'],
+ libraries=['X11', 'Xt'])
(Again, this sort of non-portable construct should be avoided if you intend to
distribute your code.)
@@ -379,8 +379,8 @@
parentheses. Each qualifier may consist of a comparison operator and a version
number. The accepted comparison operators are::
- < > ==
- <= >= !=
+ < > ==
+ <= >= !=
These can be combined by using multiple qualifiers separated by commas (and
optional whitespace). In this case, all of the qualifiers must be matched; a
@@ -446,13 +446,13 @@
The :option:`scripts` option simply is a list of files to be handled in this
way. From the PyXML setup script::
- setup(...,
- scripts=['scripts/xmlproc_parse', 'scripts/xmlproc_val']
- )
+ setup(...,
+ scripts=['scripts/xmlproc_parse', 'scripts/xmlproc_val']
+ )
.. versionchanged:: 2.7
- All the scripts will also be added to the ``MANIFEST``
- file if no template is provided. See :ref:`manifest`.
+ All the scripts will also be added to the ``MANIFEST``
+ file if no template is provided. See :ref:`manifest`.
.. _distutils-installing-package-data:
@@ -478,28 +478,28 @@
For example, if a package should contain a subdirectory with several data files,
the files can be arranged like this in the source tree::
- setup.py
- src/
- mypkg/
- __init__.py
- module.py
- data/
- tables.dat
- spoons.dat
- forks.dat
+ setup.py
+ src/
+ mypkg/
+ __init__.py
+ module.py
+ data/
+ tables.dat
+ spoons.dat
+ forks.dat
The corresponding call to :func:`setup` might be::
- setup(...,
- packages=['mypkg'],
- package_dir={'mypkg': 'src/mypkg'},
- package_data={'mypkg': ['data/*.dat']},
- )
+ setup(...,
+ packages=['mypkg'],
+ package_dir={'mypkg': 'src/mypkg'},
+ package_data={'mypkg': ['data/*.dat']},
+ )
.. versionchanged:: 2.7
- All the files that match ``package_data`` will be added to the ``MANIFEST``
- file if no template is provided. See :ref:`manifest`.
+ All the files that match ``package_data`` will be added to the ``MANIFEST``
+ file if no template is provided. See :ref:`manifest`.
.. _distutils-additional-files:
@@ -514,11 +514,11 @@
:option:`data_files` specifies a sequence of (*directory*, *files*) pairs in the
following way::
- setup(...,
- data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
- ('config', ['cfg/data.cfg']),
- ('/etc/init.d', ['init-script'])]
- )
+ setup(...,
+ data_files=[('bitmaps', ['bm/b1.gif', 'bm/b2.gif']),
+ ('config', ['cfg/data.cfg']),
+ ('/etc/init.d', ['init-script'])]
+ )
Note that you can specify the directory names where the data files will be
installed, but you cannot rename the data files themselves.
@@ -539,8 +539,8 @@
directory.
.. versionchanged:: 2.7
- All the files that match ``data_files`` will be added to the ``MANIFEST``
- file if no template is provided. See :ref:`manifest`.
+ All the files that match ``data_files`` will be added to the ``MANIFEST``
+ file if no template is provided. See :ref:`manifest`.
@@ -575,7 +575,7 @@
| | description of the | | |
| | package | | |
+----------------------+---------------------------+-----------------+--------+
-| ``long_description`` | longer description of the | long string | |
+| ``long_description`` | longer description of the | long string | \(5) |
| | package | | |
+----------------------+---------------------------+-----------------+--------+
| ``download_url`` | location where the | URL | \(4) |
@@ -589,28 +589,32 @@
Notes:
(1)
- These fields are required.
+ These fields are required.
(2)
- It is recommended that versions take the form *major.minor[.patch[.sub]]*.
+ It is recommended that versions take the form *major.minor[.patch[.sub]]*.
(3)
- Either the author or the maintainer must be identified.
+ Either the author or the maintainer must be identified.
(4)
- These fields should not be used if your package is to be compatible with Python
- versions prior to 2.2.3 or 2.3. The list is available from the `PyPI website
- <http://pypi.python.org/pypi>`_.
+ These fields should not be used if your package is to be compatible with Python
+ versions prior to 2.2.3 or 2.3. The list is available from the `PyPI website
+ <http://pypi.python.org/pypi>`_.
+
+(5)
+ The ``long_description`` field is used by PyPI when you are registering a
+ package, to build its home page.
'short string'
- A single line of text, not more than 200 characters.
+ A single line of text, not more than 200 characters.
'long string'
- Multiple lines of plain text in reStructuredText format (see
- http://docutils.sf.net/).
+ Multiple lines of plain text in reStructuredText format (see
+ http://docutils.sf.net/).
'list of strings'
- See below.
+ See below.
Encoding the version information is an art in itself. Python packages generally
adhere to the version format *major.minor[.patch][sub]*. The major number is 0
@@ -624,44 +628,44 @@
(for final pre-release release testing). Some examples:
0.1.0
- the first, experimental release of a package
+ the first, experimental release of a package
1.0.1a2
- the second alpha release of the first patch version of 1.0
+ the second alpha release of the first patch version of 1.0
:option:`classifiers` are specified in a python list::
- setup(...,
- classifiers=[
- 'Development Status :: 4 - Beta',
- 'Environment :: Console',
- 'Environment :: Web Environment',
- 'Intended Audience :: End Users/Desktop',
- 'Intended Audience :: Developers',
- 'Intended Audience :: System Administrators',
- 'License :: OSI Approved :: Python Software Foundation License',
- 'Operating System :: MacOS :: MacOS X',
- 'Operating System :: Microsoft :: Windows',
- 'Operating System :: POSIX',
- 'Programming Language :: Python',
- 'Topic :: Communications :: Email',
- 'Topic :: Office/Business',
- 'Topic :: Software Development :: Bug Tracking',
- ],
- )
+ setup(...,
+ classifiers=[
+ 'Development Status :: 4 - Beta',
+ 'Environment :: Console',
+ 'Environment :: Web Environment',
+ 'Intended Audience :: End Users/Desktop',
+ 'Intended Audience :: Developers',
+ 'Intended Audience :: System Administrators',
+ 'License :: OSI Approved :: Python Software Foundation License',
+ 'Operating System :: MacOS :: MacOS X',
+ 'Operating System :: Microsoft :: Windows',
+ 'Operating System :: POSIX',
+ 'Programming Language :: Python',
+ 'Topic :: Communications :: Email',
+ 'Topic :: Office/Business',
+ 'Topic :: Software Development :: Bug Tracking',
+ ],
+ )
If you wish to include classifiers in your :file:`setup.py` file and also wish
to remain backwards-compatible with Python releases prior to 2.2.3, then you can
include the following code fragment in your :file:`setup.py` before the
:func:`setup` call. ::
- # patch distutils if it can't cope with the "classifiers" or
- # "download_url" keywords
- from sys import version
- if version < '2.2.3':
- from distutils.dist import DistributionMetadata
- DistributionMetadata.classifiers = None
- DistributionMetadata.download_url = None
+ # patch distutils if it can't cope with the "classifiers" or
+ # "download_url" keywords
+ from sys import version
+ if version < '2.2.3':
+ from distutils.dist import DistributionMetadata
+ DistributionMetadata.classifiers = None
+ DistributionMetadata.download_url = None
Debugging the setup script
@@ -683,5 +687,3 @@
to anything except an empty string, and distutils will now print detailed
information what it is doing, and prints the full traceback in case an exception
occurs.
-
-
Modified: python/branches/io-c/Doc/distutils/uploading.rst
==============================================================================
--- python/branches/io-c/Doc/distutils/uploading.rst (original)
+++ python/branches/io-c/Doc/distutils/uploading.rst Sat Feb 28 20:20:42 2009
@@ -41,3 +41,32 @@
*section* the name of the section in :file:`$HOME/.pypirc`, and
:option:`--show-response` (which displays the full response text from the PyPI
server for help in debugging upload problems).
+
+PyPI package display
+====================
+
+The ``long_description`` field plays a special role at PyPI. It is used by
+the server to display a home page for the registered package.
+
+If you use the `reStructuredText <http://docutils.sourceforge.net/rst.html>`_
+syntax for this field, PyPI will parse it and display an HTML output for
+the package home page.
+
+The ``long_description`` field can be attached to a text file located
+in the package::
+
+ from distutils.core import setup
+
+ setup(name='Distutils',
+ long_description=open('README.txt'))
+
+In that case, `README.txt` is a regular reStructuredText text file located
+in the root of the package besides `setup.py`.
+
+To prevent registering broken reStructuredText content, you can use the
+:program:`rst2html` program that is provided by the `docutils` package
+and check the ``long_description`` from the command line::
+
+ $ python setup.py --long-description | rst2html.py > output.html
+
+`docutils` will display a warning if there's something wrong with your syntax.
Modified: python/branches/io-c/Doc/extending/newtypes.rst
==============================================================================
--- python/branches/io-c/Doc/extending/newtypes.rst (original)
+++ python/branches/io-c/Doc/extending/newtypes.rst Sat Feb 28 20:20:42 2009
@@ -72,7 +72,7 @@
Moving on, we come to the crunch --- the type object. ::
static PyTypeObject noddy_NoddyType = {
- PyObject_HEAD_INIT(NULL)
+ PyVarObject_HEAD_INIT(NULL, 0)
"noddy.Noddy", /* tp_name */
sizeof(noddy_NoddyObject), /* tp_basicsize */
0, /* tp_itemsize */
@@ -103,11 +103,11 @@
This is so important that we're going to pick the top of it apart still
further::
- PyObject_HEAD_INIT(NULL)
+ PyVarObject_HEAD_INIT(NULL, 0)
This line is a bit of a wart; what we'd like to write is::
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
as the type of a type object is "type", but this isn't strictly conforming C and
some compilers complain. Fortunately, this member will be filled in for us by
@@ -1154,8 +1154,6 @@
+===========================+==============================================+
| :const:`READONLY` | Never writable. |
+---------------------------+----------------------------------------------+
-| :const:`RO` | Shorthand for :const:`READONLY`. |
-+---------------------------+----------------------------------------------+
| :const:`READ_RESTRICTED` | Not readable in restricted mode. |
+---------------------------+----------------------------------------------+
| :const:`WRITE_RESTRICTED` | Not writable in restricted mode. |
@@ -1165,7 +1163,6 @@
.. index::
single: READONLY
- single: RO
single: READ_RESTRICTED
single: WRITE_RESTRICTED
single: RESTRICTED
@@ -1430,7 +1427,7 @@
The statically-declared type object for instances is defined this way::
PyTypeObject PyInstance_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
0,
"module.instance",
Modified: python/branches/io-c/Doc/extending/windows.rst
==============================================================================
--- python/branches/io-c/Doc/extending/windows.rst (original)
+++ python/branches/io-c/Doc/extending/windows.rst Sat Feb 28 20:20:42 2009
@@ -169,11 +169,11 @@
If your module creates a new type, you may have trouble with this line::
- PyObject_HEAD_INIT(&PyType_Type)
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
Change it to::
- PyObject_HEAD_INIT(NULL)
+ PyVarObject_HEAD_INIT(NULL, 0)
and add the following to the module initialization function::
Modified: python/branches/io-c/Doc/howto/webservers.rst
==============================================================================
--- python/branches/io-c/Doc/howto/webservers.rst (original)
+++ python/branches/io-c/Doc/howto/webservers.rst Sat Feb 28 20:20:42 2009
@@ -99,7 +99,8 @@
# -*- coding: UTF-8 -*-
# enable debugging
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
print("Content-Type: text/plain;charset=utf-8")
print()
Modified: python/branches/io-c/Doc/library/2to3.rst
==============================================================================
--- python/branches/io-c/Doc/library/2to3.rst (original)
+++ python/branches/io-c/Doc/library/2to3.rst Sat Feb 28 20:20:42 2009
@@ -38,9 +38,9 @@
$ 2to3 example.py
A diff against the original source file is printed. 2to3 can also write the
-needed modifications right back to the source file. (Of course, a backup of the
-original is also be made unless :option:`-n` is also given.) Writing the
-changes back is enabled with the :option:`-w` flag::
+needed modifications right back to the source file. (A backup of the original
+file is made unless :option:`-n` is also given.) Writing the changes back is
+enabled with the :option:`-w` flag::
$ 2to3 -w example.py
Modified: python/branches/io-c/Doc/library/abc.rst
==============================================================================
--- python/branches/io-c/Doc/library/abc.rst (original)
+++ python/branches/io-c/Doc/library/abc.rst Sat Feb 28 20:20:42 2009
@@ -150,7 +150,7 @@
.. note::
- Unlike C++'s pure virtual functions, or Java abstract methods, these abstract
+ Unlike Java abstract methods, these abstract
methods may have an implementation. This implementation can be
called via the :func:`super` mechanism from the class that
overrides it. This could be useful as an end-point for a
Modified: python/branches/io-c/Doc/library/cgi.rst
==============================================================================
--- python/branches/io-c/Doc/library/cgi.rst (original)
+++ python/branches/io-c/Doc/library/cgi.rst Sat Feb 28 20:20:42 2009
@@ -65,16 +65,18 @@
Begin by writing ``import cgi``.
-When you write a new script, consider adding the line::
+When you write a new script, consider adding these lines::
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
This activates a special exception handler that will display detailed reports in
the Web browser if any errors occur. If you'd rather not show the guts of your
program to users of your script, you can have the reports saved to files
-instead, with a line like this::
+instead, with code like this::
- import cgitb; cgitb.enable(display=0, logdir="/tmp")
+ import cgitb
+ cgitb.enable(display=0, logdir="/tmp")
It's very helpful to use this feature during script development. The reports
produced by :mod:`cgitb` provide information that can save you a lot of time in
@@ -445,9 +447,10 @@
Fortunately, once you have managed to get your script to execute *some* code,
you can easily send tracebacks to the Web browser using the :mod:`cgitb` module.
-If you haven't done so already, just add the line::
+If you haven't done so already, just add the lines::
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
to the top of your script. Then try running it again; when a problem occurs,
you should see a detailed report that will likely make apparent the cause of the
Modified: python/branches/io-c/Doc/library/cgitb.rst
==============================================================================
--- python/branches/io-c/Doc/library/cgitb.rst (original)
+++ python/branches/io-c/Doc/library/cgitb.rst Sat Feb 28 20:20:42 2009
@@ -24,9 +24,10 @@
functions, to help you debug the problem. Optionally, you can save this
information to a file instead of sending it to the browser.
-To enable this feature, simply add one line to the top of your CGI script::
+To enable this feature, simply add this to the top of your CGI script::
- import cgitb; cgitb.enable()
+ import cgitb
+ cgitb.enable()
The options to the :func:`enable` function control whether the report is
displayed in the browser and whether the report is logged to a file for later
Modified: python/branches/io-c/Doc/library/collections.rst
==============================================================================
--- python/branches/io-c/Doc/library/collections.rst (original)
+++ python/branches/io-c/Doc/library/collections.rst Sat Feb 28 20:20:42 2009
@@ -236,13 +236,12 @@
c.most_common()[:-n:-1] # n least common elements
c += Counter() # remove zero and negative counts
-Several multiset mathematical operations are provided for combining
-:class:`Counter` objects. Multisets are like regular sets but are allowed to
-contain repeated elements (with counts of one or more). Addition and
-subtraction combine counters by adding or subtracting the counts of
-corresponding elements. Intersection and union return the minimum and maximum
-of corresponding counts. Each operation can accept inputs with signed counts,
-but the output excludes results with counts less than one.
+Several mathematical operations are provided for combining :class:`Counter`
+objects to produce multisets (counters that have counts greater than zero).
+Addition and subtraction combine counters by adding or subtracting the counts
+of corresponding elements. Intersection and union return the minimum and
+maximum of corresponding counts. Each operation can accept inputs with signed
+counts, but the output will exclude results with counts of zero or less.
>>> c = Counter(a=3, b=1)
>>> d = Counter(a=1, b=2)
Modified: python/branches/io-c/Doc/library/functions.rst
==============================================================================
--- python/branches/io-c/Doc/library/functions.rst (original)
+++ python/branches/io-c/Doc/library/functions.rst Sat Feb 28 20:20:42 2009
@@ -1067,7 +1067,7 @@
The second use case is to support cooperative multiple inheritance in a
dynamic execution environment. This use case is unique to Python and is
not found in statically compiled languages or languages that only support
- single inheritance. This makes in possible to implement "diamond diagrams"
+ single inheritance. This makes it possible to implement "diamond diagrams"
where multiple base classes implement the same method. Good design dictates
that this method have the same calling signature in every case (because the
order of calls is determined at runtime, because that order adapts
Modified: python/branches/io-c/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/io-c/Doc/library/stdtypes.rst (original)
+++ python/branches/io-c/Doc/library/stdtypes.rst Sat Feb 28 20:20:42 2009
@@ -793,9 +793,9 @@
.. method:: str.count(sub[, start[, end]])
- Return the number of occurrences of substring *sub* in the range [*start*,
- *end*]. Optional arguments *start* and *end* are interpreted as in slice
- notation.
+ Return the number of non-overlapping occurrences of substring *sub* in the
+ range [*start*, *end*]. Optional arguments *start* and *end* are
+ interpreted as in slice notation.
.. method:: str.encode([encoding[, errors]])
@@ -835,7 +835,7 @@
found.
-.. method:: str.format(format_string, *args, **kwargs)
+.. method:: str.format(*args, **kwargs)
Perform a string formatting operation. The *format_string* argument can
contain literal text or replacement fields delimited by braces ``{}``. Each
Modified: python/branches/io-c/Doc/library/urllib.request.rst
==============================================================================
--- python/branches/io-c/Doc/library/urllib.request.rst (original)
+++ python/branches/io-c/Doc/library/urllib.request.rst Sat Feb 28 20:20:42 2009
@@ -37,20 +37,20 @@
* :meth:`geturl` --- return the URL of the resource retrieved, commonly used to
determine if a redirect was followed
- * :meth:`info` --- return the meta-information of the page, such as headers, in
- the form of an ``http.client.HTTPMessage`` instance
- (see `Quick Reference to HTTP Headers <http://www.cs.tut.fi/~jkorpela/http.html>`_)
+ * :meth:`info` --- return the meta-information of the page, such as headers,
+ in the form of an ``http.client.HTTPMessage`` instance (see `Quick
+ Reference to HTTP Headers <http://www.cs.tut.fi/~jkorpela/http.html>`_)
Raises :exc:`URLError` on errors.
- Note that ``None`` may be returned if no handler handles the request (though the
- default installed global :class:`OpenerDirector` uses :class:`UnknownHandler` to
- ensure this never happens).
- The urlopen function from the previous version, Python 2.6 and earlier, of
- the module urllib has been discontinued as urlopen can return the
- file-object as the previous. The proxy handling, which in earlier was passed
- as a dict parameter to urlopen can be availed by the use of
- :class:`ProxyHandler` objects.
+ Note that ``None`` may be returned if no handler handles the request (though
+ the default installed global :class:`OpenerDirector` uses
+ :class:`UnknownHandler` to ensure this never happens).
+
+ The legacy ``urllib.urlopen`` function from Python 2.6 and earlier has been
+ discontinued; :func:`urlopen` corresponds to the old ``urllib2.urlopen``.
+ Proxy handling, which was done by passing a dictionary parameter to
+ ``urllib.urlopen``, can be obtained by using :class:`ProxyHandler` objects.
.. function:: install_opener(opener)
Modified: python/branches/io-c/Doc/library/xml.etree.elementtree.rst
==============================================================================
--- python/branches/io-c/Doc/library/xml.etree.elementtree.rst (original)
+++ python/branches/io-c/Doc/library/xml.etree.elementtree.rst Sat Feb 28 20:20:42 2009
@@ -529,5 +529,5 @@
.. [#] The encoding string included in XML output should conform to the
appropriate standards. For example, "UTF-8" is valid, but "UTF8" is
not. See http://www.w3.org/TR/2006/REC-xml11-20060816/#NT-EncodingDecl
- and http://www.iana.org/assignments/character-sets .
+ and http://www.iana.org/assignments/character-sets.
Modified: python/branches/io-c/Doc/whatsnew/2.5.rst
==============================================================================
--- python/branches/io-c/Doc/whatsnew/2.5.rst (original)
+++ python/branches/io-c/Doc/whatsnew/2.5.rst Sat Feb 28 20:20:42 2009
@@ -1761,8 +1761,8 @@
included.
The rest of this section will provide a brief overview of using ElementTree.
-Full documentation for ElementTree is available at http://effbot.org/zone
-/element-index.htm.
+Full documentation for ElementTree is available at
+http://effbot.org/zone/element-index.htm.
ElementTree represents an XML document as a tree of element nodes. The text
content of the document is stored as the :attr:`.text` and :attr:`.tail`
Modified: python/branches/io-c/Lib/_abcoll.py
==============================================================================
--- python/branches/io-c/Lib/_abcoll.py (original)
+++ python/branches/io-c/Lib/_abcoll.py Sat Feb 28 20:20:42 2009
@@ -392,6 +392,9 @@
def __len__(self):
return len(self._mapping)
+ def __repr__(self):
+ return '{0.__class__.__name__}({0._mapping!r})'.format(self)
+
class KeysView(MappingView, Set):
Modified: python/branches/io-c/Lib/distutils/README
==============================================================================
--- python/branches/io-c/Lib/distutils/README (original)
+++ python/branches/io-c/Lib/distutils/README Sat Feb 28 20:20:42 2009
@@ -8,4 +8,6 @@
http://www.python.org/sigs/distutils-sig/
+WARNING : Distutils must remain compatible with 2.3
+
$Id$
Modified: python/branches/io-c/Lib/distutils/command/bdist_rpm.py
==============================================================================
--- python/branches/io-c/Lib/distutils/command/bdist_rpm.py (original)
+++ python/branches/io-c/Lib/distutils/command/bdist_rpm.py Sat Feb 28 20:20:42 2009
@@ -122,10 +122,21 @@
# Allow a packager to explicitly force an architecture
('force-arch=', None,
"Force an architecture onto the RPM build process"),
- ]
+
+ ('quiet', 'q',
+ "Run the INSTALL phase of RPM building in quiet mode"),
+
+ # Forces the -O1 option when calling the install command,
+ # so the rpm contains all files needed for proper operation under
+ # SELinux. Some systems checks for this on build-time and will
+ # fail without this.
+ ('force-optimize', None,
+ "Forces the -O1 option when calling the install command"),
+
+ ]
boolean_options = ['keep-temp', 'use-rpm-opt-flags', 'rpm3-mode',
- 'no-autoreq']
+ 'no-autoreq', 'quiet', 'force-optimize']
negative_opt = {'no-keep-temp': 'keep-temp',
'no-rpm-opt-flags': 'use-rpm-opt-flags',
@@ -175,6 +186,8 @@
self.no_autoreq = 0
self.force_arch = None
+ self.quiet = 0
+ self.force_optimize = 1
def finalize_options(self):
self.set_undefined_options('bdist', ('bdist_base', 'bdist_base'))
@@ -311,6 +324,7 @@
if os.path.exists('/usr/bin/rpmbuild') or \
os.path.exists('/bin/rpmbuild'):
rpm_cmd = ['rpmbuild']
+
if self.source_only: # what kind of RPMs?
rpm_cmd.append('-bs')
elif self.binary_only:
@@ -322,6 +336,10 @@
'_topdir %s' % os.path.abspath(self.rpm_base)])
if not self.keep_temp:
rpm_cmd.append('--clean')
+
+ if self.quiet:
+ rpm_cmd.append('--quiet')
+
rpm_cmd.append(spec_path)
# Determine the binary rpm names that should be built out of this spec
# file
@@ -474,13 +492,19 @@
# that we open and interpolate into the spec file, but the defaults
# are just text that we drop in as-is. Hmmm.
+ # forcing -O1 if force-optimize
+ if self.force_optimize:
+ optimize = ' -O1'
+ else:
+ optimize = ''
+
+ install_cmd = ('%s install%s --root=$RPM_BUILD_ROOT '
+ '--record=INSTALLED_FILES') % (def_setup_call, optimize)
+
script_options = [
('prep', 'prep_script', "%setup -n %{name}-%{unmangled_version}"),
('build', 'build_script', def_build),
- ('install', 'install_script',
- ("%s install "
- "--root=$RPM_BUILD_ROOT "
- "--record=INSTALLED_FILES") % def_setup_call),
+ ('install', 'install_script', install_cmd),
('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
('verifyscript', 'verify_script', None),
('pre', 'pre_install', None),
Modified: python/branches/io-c/Lib/distutils/command/build_ext.py
==============================================================================
--- python/branches/io-c/Lib/distutils/command/build_ext.py (original)
+++ python/branches/io-c/Lib/distutils/command/build_ext.py Sat Feb 28 20:20:42 2009
@@ -7,7 +7,6 @@
__revision__ = "$Id$"
import sys, os, re
-from site import USER_BASE, USER_SITE
from distutils.core import Command
from distutils.errors import *
from distutils.sysconfig import customize_compiler, get_python_version
@@ -16,6 +15,14 @@
from distutils.util import get_platform
from distutils import log
+# this keeps compatibility from 2.3 to 2.5
+if sys.version < "2.6":
+ USER_BASE = None
+ HAS_USER_SITE = False
+else:
+ from site import USER_BASE
+ HAS_USER_SITE = True
+
if os.name == 'nt':
from distutils.msvccompiler import get_build_version
MSVC_VERSION = int(get_build_version())
@@ -91,11 +98,14 @@
"list of SWIG command line options"),
('swig=', None,
"path to the SWIG executable"),
- ('user', None,
- "add user include, library and rpath"),
]
- boolean_options = ['inplace', 'debug', 'force', 'swig-cpp', 'user']
+ boolean_options = ['inplace', 'debug', 'force', 'swig-cpp']
+
+ if HAS_USER_SITE:
+ user_options.append(('user', None,
+ "add user include, library and rpath"))
+ boolean_options.append('user')
help_options = [
('help-compiler', None,
Modified: python/branches/io-c/Lib/distutils/command/install.py
==============================================================================
--- python/branches/io-c/Lib/distutils/command/install.py (original)
+++ python/branches/io-c/Lib/distutils/command/install.py Sat Feb 28 20:20:42 2009
@@ -15,9 +15,16 @@
from distutils.util import convert_path, subst_vars, change_root
from distutils.util import get_platform
from distutils.errors import DistutilsOptionError
-from site import USER_BASE
-from site import USER_SITE
+# this keeps compatibility from 2.3 to 2.5
+if sys.version < "2.6":
+ USER_BASE = None
+ USER_SITE = None
+ HAS_USER_SITE = False
+else:
+ from site import USER_BASE
+ from site import USER_SITE
+ HAS_USER_SITE = True
if sys.version < "2.2":
WINDOWS_SCHEME = {
@@ -51,21 +58,7 @@
'scripts': '$base/bin',
'data' : '$base',
},
- 'unix_user': {
- 'purelib': '$usersite',
- 'platlib': '$usersite',
- 'headers': '$userbase/include/python$py_version_short/$dist_name',
- 'scripts': '$userbase/bin',
- 'data' : '$userbase',
- },
'nt': WINDOWS_SCHEME,
- 'nt_user': {
- 'purelib': '$usersite',
- 'platlib': '$usersite',
- 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
- 'scripts': '$userbase/Scripts',
- 'data' : '$userbase',
- },
'mac': {
'purelib': '$base/Lib/site-packages',
'platlib': '$base/Lib/site-packages',
@@ -73,13 +66,7 @@
'scripts': '$base/Scripts',
'data' : '$base',
},
- 'mac_user': {
- 'purelib': '$usersite',
- 'platlib': '$usersite',
- 'headers': '$userbase/$py_version_short/include/$dist_name',
- 'scripts': '$userbase/bin',
- 'data' : '$userbase',
- },
+
'os2': {
'purelib': '$base/Lib/site-packages',
'platlib': '$base/Lib/site-packages',
@@ -87,14 +74,41 @@
'scripts': '$base/Scripts',
'data' : '$base',
},
- 'os2_home': {
+ }
+
+# user site schemes
+if HAS_USER_SITE:
+ INSTALL_SCHEMES['nt_user'] = {
+ 'purelib': '$usersite',
+ 'platlib': '$usersite',
+ 'headers': '$userbase/Python$py_version_nodot/Include/$dist_name',
+ 'scripts': '$userbase/Scripts',
+ 'data' : '$userbase',
+ }
+
+ INSTALL_SCHEMES['unix_user'] = {
'purelib': '$usersite',
'platlib': '$usersite',
'headers': '$userbase/include/python$py_version_short/$dist_name',
'scripts': '$userbase/bin',
'data' : '$userbase',
- },
- }
+ }
+
+ INSTALL_SCHEMES['mac_user'] = {
+ 'purelib': '$usersite',
+ 'platlib': '$usersite',
+ 'headers': '$userbase/$py_version_short/include/$dist_name',
+ 'scripts': '$userbase/bin',
+ 'data' : '$userbase',
+ }
+
+ INSTALL_SCHEMES['os2_home'] = {
+ 'purelib': '$usersite',
+ 'platlib': '$usersite',
+ 'headers': '$userbase/include/python$py_version_short/$dist_name',
+ 'scripts': '$userbase/bin',
+ 'data' : '$userbase',
+ }
# The keys to an installation scheme; if any new types of files are to be
# installed, be sure to add an entry to every installation scheme above,
@@ -114,8 +128,6 @@
"(Unix only) prefix for platform-specific files"),
('home=', None,
"(Unix only) home directory to install under"),
- ('user', None,
- "install in user site-package '%s'" % USER_SITE),
# Or, just set the base director(y|ies)
('install-base=', None,
@@ -167,7 +179,13 @@
"filename in which to record list of installed files"),
]
- boolean_options = ['compile', 'force', 'skip-build', 'user']
+ boolean_options = ['compile', 'force', 'skip-build']
+
+ if HAS_USER_SITE:
+ user_options.append(('user', None,
+ "install in user site-package '%s'" % USER_SITE))
+ boolean_options.append('user')
+
negative_opt = {'no-compile' : 'compile'}
@@ -319,9 +337,12 @@
'prefix': prefix,
'sys_exec_prefix': exec_prefix,
'exec_prefix': exec_prefix,
- 'userbase': self.install_userbase,
- 'usersite': self.install_usersite,
}
+
+ if HAS_USER_SITE:
+ self.config_vars['userbase'] = self.install_userbase
+ self.config_vars['usersite'] = self.install_usersite
+
self.expand_basedirs()
self.dump_dirs("post-expand_basedirs()")
Modified: python/branches/io-c/Lib/distutils/command/upload.py
==============================================================================
--- python/branches/io-c/Lib/distutils/command/upload.py (original)
+++ python/branches/io-c/Lib/distutils/command/upload.py Sat Feb 28 20:20:42 2009
@@ -6,7 +6,7 @@
from distutils.core import PyPIRCCommand
from distutils.spawn import spawn
from distutils import log
-from hashlib import md5
+import sys
import os, io
import socket
import platform
@@ -15,6 +15,12 @@
import base64
import urllib.parse
+# this keeps compatibility for 2.3 and 2.4
+if sys.version < "2.5":
+ from md5 import md5
+else:
+ from hashlib import md5
+
class upload(PyPIRCCommand):
description = "upload binary package to PyPI"
Modified: python/branches/io-c/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/io-c/Lib/distutils/tests/test_build_ext.py (original)
+++ python/branches/io-c/Lib/distutils/tests/test_build_ext.py Sat Feb 28 20:20:42 2009
@@ -24,11 +24,17 @@
def setUp(self):
# Create a simple test environment
# Note that we're making changes to sys.path
- TempdirManager.setUp(self)
+ super(BuildExtTestCase, self).setUp()
self.tmp_dir = self.mkdtemp()
self.sys_path = sys.path[:]
sys.path.append(self.tmp_dir)
shutil.copy(_get_source_filename(), self.tmp_dir)
+ if sys.version > "2.6":
+ import site
+ self.old_user_base = site.USER_BASE
+ site.USER_BASE = self.mkdtemp()
+ from distutils.command import build_ext
+ build_ext.USER_BASE = site.USER_BASE
def test_build_ext(self):
global ALREADY_TESTED
@@ -76,7 +82,12 @@
# Get everything back to normal
support.unload('xx')
sys.path = self.sys_path
- TempdirManager.tearDown(self)
+ if sys.version > "2.6":
+ import site
+ site.USER_BASE = self.old_user_base
+ from distutils.command import build_ext
+ build_ext.USER_BASE = self.old_user_base
+ super(BuildExtTestCase, self).tearDown()
def test_solaris_enable_shared(self):
dist = Distribution({'name': 'xx'})
@@ -99,6 +110,37 @@
# make sur we get some lobrary dirs under solaris
self.assert_(len(cmd.library_dirs) > 0)
+ def test_user_site(self):
+ # site.USER_SITE was introduced in 2.6
+ if sys.version < '2.6':
+ return
+
+ import site
+ dist = Distribution({'name': 'xx'})
+ cmd = build_ext(dist)
+
+ # making sure the suer option is there
+ options = [name for name, short, lable in
+ cmd.user_options]
+ self.assert_('user' in options)
+
+ # setting a value
+ cmd.user = 1
+
+ # setting user based lib and include
+ lib = os.path.join(site.USER_BASE, 'lib')
+ incl = os.path.join(site.USER_BASE, 'include')
+ os.mkdir(lib)
+ os.mkdir(incl)
+
+ # let's run finalize
+ cmd.ensure_finalized()
+
+ # see if include_dirs and library_dirs
+ # were set
+ self.assert_(lib in cmd.library_dirs)
+ self.assert_(incl in cmd.include_dirs)
+
def test_suite():
src = _get_source_filename()
if not os.path.exists(src):
Modified: python/branches/io-c/Lib/distutils/tests/test_config.py
==============================================================================
--- python/branches/io-c/Lib/distutils/tests/test_config.py (original)
+++ python/branches/io-c/Lib/distutils/tests/test_config.py Sat Feb 28 20:20:42 2009
@@ -50,7 +50,7 @@
def setUp(self):
"""Patches the environment."""
- support.TempdirManager.setUp(self)
+ super(PyPIRCCommandTestCase, self).setUp()
if 'HOME' in os.environ:
self._old_home = os.environ['HOME']
@@ -78,7 +78,7 @@
else:
os.environ['HOME'] = self._old_home
set_threshold(self.old_threshold)
- support.TempdirManager.tearDown(self)
+ super(PyPIRCCommandTestCase, self).tearDown()
def test_server_registration(self):
# This test makes sure PyPIRCCommand knows how to:
Modified: python/branches/io-c/Lib/distutils/tests/test_install.py
==============================================================================
--- python/branches/io-c/Lib/distutils/tests/test_install.py (original)
+++ python/branches/io-c/Lib/distutils/tests/test_install.py Sat Feb 28 20:20:42 2009
@@ -1,9 +1,14 @@
"""Tests for distutils.command.install."""
import os
+import os.path
+import sys
import unittest
+import site
from distutils.command.install import install
+from distutils.command import install as install_module
+from distutils.command.install import INSTALL_SCHEMES
from distutils.core import Distribution
from distutils.tests import support
@@ -47,6 +52,65 @@
check_path(cmd.install_scripts, os.path.join(destination, "bin"))
check_path(cmd.install_data, destination)
+ def test_user_site(self):
+ # site.USER_SITE was introduced in 2.6
+ if sys.version < '2.6':
+ return
+
+ # preparing the environement for the test
+ self.old_user_base = site.USER_BASE
+ self.old_user_site = site.USER_SITE
+ self.tmpdir = self.mkdtemp()
+ self.user_base = os.path.join(self.tmpdir, 'B')
+ self.user_site = os.path.join(self.tmpdir, 'S')
+ site.USER_BASE = self.user_base
+ site.USER_SITE = self.user_site
+ install_module.USER_BASE = self.user_base
+ install_module.USER_SITE = self.user_site
+
+ def _expanduser(path):
+ return self.tmpdir
+ self.old_expand = os.path.expanduser
+ os.path.expanduser = _expanduser
+
+ try:
+ # this is the actual test
+ self._test_user_site()
+ finally:
+ site.USER_BASE = self.old_user_base
+ site.USER_SITE = self.old_user_site
+ install_module.USER_BASE = self.old_user_base
+ install_module.USER_SITE = self.old_user_site
+ os.path.expanduser = self.old_expand
+
+ def _test_user_site(self):
+ for key in ('nt_user', 'unix_user', 'os2_home'):
+ self.assert_(key in INSTALL_SCHEMES)
+
+ dist = Distribution({'name': 'xx'})
+ cmd = install(dist)
+
+ # making sure the user option is there
+ options = [name for name, short, lable in
+ cmd.user_options]
+ self.assert_('user' in options)
+
+ # setting a value
+ cmd.user = 1
+
+ # user base and site shouldn't be created yet
+ self.assert_(not os.path.exists(self.user_base))
+ self.assert_(not os.path.exists(self.user_site))
+
+ # let's run finalize
+ cmd.ensure_finalized()
+
+ # now they should
+ self.assert_(os.path.exists(self.user_base))
+ self.assert_(os.path.exists(self.user_site))
+
+ self.assert_('userbase' in cmd.config_vars)
+ self.assert_('usersite' in cmd.config_vars)
def test_suite():
return unittest.makeSuite(InstallTestCase)
Modified: python/branches/io-c/Lib/distutils/tests/test_sdist.py
==============================================================================
--- python/branches/io-c/Lib/distutils/tests/test_sdist.py (original)
+++ python/branches/io-c/Lib/distutils/tests/test_sdist.py Sat Feb 28 20:20:42 2009
@@ -37,10 +37,9 @@
class sdistTestCase(support.LoggingSilencer, PyPIRCCommandTestCase):
def setUp(self):
- support.LoggingSilencer.setUp(self)
# PyPIRCCommandTestCase creates a temp dir already
# and put it in self.tmp_dir
- PyPIRCCommandTestCase.setUp(self)
+ super(sdistTestCase, self).setUp()
# setting up an environment
self.old_path = os.getcwd()
os.mkdir(join(self.tmp_dir, 'somecode'))
@@ -54,8 +53,7 @@
def tearDown(self):
# back to normal
os.chdir(self.old_path)
- PyPIRCCommandTestCase.tearDown(self)
- support.LoggingSilencer.tearDown(self)
+ super(sdistTestCase, self).tearDown()
def get_cmd(self, metadata=None):
"""Returns a cmd"""
Modified: python/branches/io-c/Lib/socketserver.py
==============================================================================
--- python/branches/io-c/Lib/socketserver.py (original)
+++ python/branches/io-c/Lib/socketserver.py Sat Feb 28 20:20:42 2009
@@ -487,7 +487,7 @@
# libraries that expect to be able to wait for their own
# children.
try:
- pid, status = os.waitpid(0, options=0)
+ pid, status = os.waitpid(0, 0)
except os.error:
pid = None
if pid not in self.active_children: continue
Modified: python/branches/io-c/Lib/test/test_mmap.py
==============================================================================
--- python/branches/io-c/Lib/test/test_mmap.py (original)
+++ python/branches/io-c/Lib/test/test_mmap.py Sat Feb 28 20:20:42 2009
@@ -466,6 +466,72 @@
self.assert_(issubclass(mmap.error, EnvironmentError))
self.assert_("mmap.error" in str(mmap.error))
+ def test_io_methods(self):
+ data = b"0123456789"
+ open(TESTFN, "wb").write(b"x"*len(data))
+ f = open(TESTFN, "r+b")
+ m = mmap.mmap(f.fileno(), len(data))
+ f.close()
+ # Test write_byte()
+ for i in range(len(data)):
+ self.assertEquals(m.tell(), i)
+ m.write_byte(data[i:i+1])
+ self.assertEquals(m.tell(), i+1)
+ self.assertRaises(ValueError, m.write_byte, b"x")
+ self.assertEquals(m[:], data)
+ # Test read_byte()
+ m.seek(0)
+ for i in range(len(data)):
+ self.assertEquals(m.tell(), i)
+ # XXX: Disable this test for now because it's not clear
+ # which type of object m.read_byte returns. Currently, it
+ # returns 1-length str (unicode).
+ if 0:
+ self.assertEquals(m.read_byte(), data[i:i+1])
+ else:
+ m.read_byte()
+ self.assertEquals(m.tell(), i+1)
+ self.assertRaises(ValueError, m.read_byte)
+ # Test read()
+ m.seek(3)
+ self.assertEquals(m.read(3), b"345")
+ self.assertEquals(m.tell(), 6)
+ # Test write()
+ m.seek(3)
+ m.write(b"bar")
+ self.assertEquals(m.tell(), 6)
+ self.assertEquals(m[:], b"012bar6789")
+ m.seek(8)
+ self.assertRaises(ValueError, m.write, b"bar")
+
+ if os.name == 'nt':
+ def test_tagname(self):
+ data1 = b"0123456789"
+ data2 = b"abcdefghij"
+ assert len(data1) == len(data2)
+ # Test same tag
+ m1 = mmap.mmap(-1, len(data1), tagname="foo")
+ m1[:] = data1
+ m2 = mmap.mmap(-1, len(data2), tagname="foo")
+ m2[:] = data2
+ self.assertEquals(m1[:], data2)
+ self.assertEquals(m2[:], data2)
+ # Test differnt tag
+ m1 = mmap.mmap(-1, len(data1), tagname="foo")
+ m1[:] = data1
+ m2 = mmap.mmap(-1, len(data2), tagname="boo")
+ m2[:] = data2
+ self.assertEquals(m1[:], data1)
+ self.assertEquals(m2[:], data2)
+
+ def test_tagname_crash(self):
+ # Should not crash (Issue 1733986)
+ m = mmap.mmap(-1, 1000, tagname="foo")
+ try:
+ mmap.mmap(-1, 5000, tagname="foo")[:] # same tagname, but larger size
+ except:
+ pass
+
def test_main():
run_unittest(MmapTests)
Modified: python/branches/io-c/Lib/test/test_opcodes.py
==============================================================================
--- python/branches/io-c/Lib/test/test_opcodes.py (original)
+++ python/branches/io-c/Lib/test/test_opcodes.py Sat Feb 28 20:20:42 2009
@@ -98,6 +98,12 @@
g = eval('lambda a=1: None')
self.assertNotEquals(f, g)
+ def test_modulo_of_string_subclasses(self):
+ class MyString(str):
+ def __mod__(self, value):
+ return 42
+ self.assertEqual(MyString() % 3, 42)
+
def test_main():
run_unittest(OpcodeTest)
Modified: python/branches/io-c/Misc/NEWS
==============================================================================
--- python/branches/io-c/Misc/NEWS (original)
+++ python/branches/io-c/Misc/NEWS Sat Feb 28 20:20:42 2009
@@ -173,6 +173,22 @@
Library
-------
+- Issue #1733986: Fixed mmap crash in accessing elements of second map object
+ with same tagname but larger size than first map. (Windows)
+
+- Issue #5386: mmap.write_byte didn't check map size, so it could cause buffer
+ overrun.
+
+- Issue #1533164: Installed but not listed *.pyo was breaking Distutils
+ bdist_rpm command.
+
+- Issue #5378: added --quiet option to Distutils bdist_rpm command.
+
+- Issue #5052: make Distutils compatible with 2.3 again.
+
+- Issue #5316: Fixed buildbot failures introduced by multiple inheritance
+ in Distutils tests.
+
- Issue #5287: Add exception handling around findCaller() call to help out
IronPython.
Modified: python/branches/io-c/Modules/_ssl.c
==============================================================================
--- python/branches/io-c/Modules/_ssl.c (original)
+++ python/branches/io-c/Modules/_ssl.c Sat Feb 28 20:20:42 2009
@@ -1244,9 +1244,12 @@
static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
{
- PyObject *buf = NULL;
+ PyObject *dest = NULL;
+ Py_buffer buf;
int buf_passed = 0;
int count = -1;
+ char *mem;
+ /* XXX this should use Py_ssize_t */
int len = 1024;
int sockstate;
int err;
@@ -1260,19 +1263,22 @@
return NULL;
}
- if (!PyArg_ParseTuple(args, "|Oi:read", &buf, &count))
+ if (!PyArg_ParseTuple(args, "|Oi:read", &dest, &count))
return NULL;
- if ((buf == NULL) || (buf == Py_None)) {
- if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
+ if ((dest == NULL) || (dest == Py_None)) {
+ if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
- } else if (PyLong_Check(buf)) {
- len = PyLong_AS_LONG(buf);
- if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
+ mem = PyByteArray_AS_STRING(dest);
+ } else if (PyLong_Check(dest)) {
+ len = PyLong_AS_LONG(dest);
+ if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
+ mem = PyByteArray_AS_STRING(dest);
} else {
- if (!PyByteArray_Check(buf))
+ if (PyObject_GetBuffer(dest, &buf, PyBUF_CONTIG) < 0)
return NULL;
- len = PyByteArray_Size(buf);
+ mem = buf.buf;
+ len = buf.len;
if ((count > 0) && (count <= len))
len = count;
buf_passed = 1;
@@ -1293,18 +1299,11 @@
if (sockstate == SOCKET_HAS_TIMED_OUT) {
PyErr_SetString(PySSLErrorObject,
"The read operation timed out");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
PyErr_SetString(PySSLErrorObject,
"Underlying socket too large for select().");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- Py_DECREF(buf);
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
count = 0;
goto done;
@@ -1313,15 +1312,11 @@
do {
err = 0;
PySSL_BEGIN_ALLOW_THREADS
- count = SSL_read(self->ssl, PyByteArray_AsString(buf), len);
+ count = SSL_read(self->ssl, mem, len);
err = SSL_get_error(self->ssl, count);
PySSL_END_ALLOW_THREADS
- if(PyErr_CheckSignals()) {
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
- }
+ if (PyErr_CheckSignals())
+ goto error;
if (err == SSL_ERROR_WANT_READ) {
sockstate =
check_socket_and_wait_for_timeout(sock, 0);
@@ -1340,29 +1335,31 @@
if (sockstate == SOCKET_HAS_TIMED_OUT) {
PyErr_SetString(PySSLErrorObject,
"The read operation timed out");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_IS_NONBLOCKING) {
break;
}
} while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
if (count <= 0) {
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return PySSL_SetError(self, count, __FILE__, __LINE__);
+ PySSL_SetError(self, count, __FILE__, __LINE__);
+ goto error;
}
done:
if (!buf_passed) {
- PyObject *res = PyBytes_FromStringAndSize(
- PyByteArray_AS_STRING(buf), count);
- Py_DECREF(buf);
+ PyObject *res = PyBytes_FromStringAndSize(mem, count);
+ Py_DECREF(dest);
return res;
} else {
+ PyBuffer_Release(&buf);
return PyLong_FromLong(count);
}
+ error:
+ if (!buf_passed) {
+ Py_DECREF(dest);
+ } else {
+ PyBuffer_Release(&buf);
+ }
+ return NULL;
}
PyDoc_STRVAR(PySSL_SSLread_doc,
Modified: python/branches/io-c/Modules/cmathmodule.c
==============================================================================
--- python/branches/io-c/Modules/cmathmodule.c (original)
+++ python/branches/io-c/Modules/cmathmodule.c Sat Feb 28 20:20:42 2009
@@ -368,7 +368,7 @@
PyDoc_STRVAR(c_cos_doc,
"cos(x)\n"
-"n"
+"\n"
"Return the cosine of x.");
@@ -427,7 +427,7 @@
PyDoc_STRVAR(c_cosh_doc,
"cosh(x)\n"
-"n"
+"\n"
"Return the hyperbolic cosine of x.");
Modified: python/branches/io-c/Modules/mmapmodule.c
==============================================================================
--- python/branches/io-c/Modules/mmapmodule.c (original)
+++ python/branches/io-c/Modules/mmapmodule.c Sat Feb 28 20:20:42 2009
@@ -376,10 +376,17 @@
if (!is_writable(self))
return NULL;
- *(self->data+self->pos) = value;
- self->pos += 1;
- Py_INCREF(Py_None);
- return Py_None;
+
+ if (self->pos < self->size) {
+ *(self->data+self->pos) = value;
+ self->pos += 1;
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+ else {
+ PyErr_SetString(PyExc_ValueError, "write byte out of range");
+ return NULL;
+ }
}
static PyObject *
@@ -1290,7 +1297,7 @@
dwDesiredAccess,
off_hi,
off_lo,
- 0);
+ m_obj->size);
if (m_obj->data != NULL)
return (PyObject *)m_obj;
else
Modified: python/branches/io-c/Modules/python.c
==============================================================================
--- python/branches/io-c/Modules/python.c (original)
+++ python/branches/io-c/Modules/python.c Sat Feb 28 20:20:42 2009
@@ -37,7 +37,7 @@
fprintf(stderr, "out of memory\n");
return 1;
}
- oldloc = setlocale(LC_ALL, NULL);
+ oldloc = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "");
for (i = 0; i < argc; i++) {
#ifdef HAVE_BROKEN_MBSTOWCS
@@ -67,6 +67,7 @@
}
}
setlocale(LC_ALL, oldloc);
+ free(oldloc);
res = Py_Main(argc, argv_copy);
for (i = 0; i < argc; i++) {
PyMem_Free(argv_copy2[i]);
Modified: python/branches/io-c/Objects/longobject.c
==============================================================================
--- python/branches/io-c/Objects/longobject.c (original)
+++ python/branches/io-c/Objects/longobject.c Sat Feb 28 20:20:42 2009
@@ -1557,7 +1557,7 @@
digit powbase = base; /* powbase == base ** power */
int power = 1;
for (;;) {
- unsigned long newpow = powbase * (unsigned long)base;
+ twodigits newpow = powbase * (twodigits)base;
if (newpow >> PyLong_SHIFT) /* doesn't fit in a digit */
break;
powbase = (digit)newpow;
Modified: python/branches/io-c/Python/ceval.c
==============================================================================
--- python/branches/io-c/Python/ceval.c (original)
+++ python/branches/io-c/Python/ceval.c Sat Feb 28 20:20:42 2009
@@ -1446,7 +1446,10 @@
TARGET(BINARY_MODULO)
w = POP();
v = TOP();
- x = PyNumber_Remainder(v, w);
+ if (PyUnicode_CheckExact(v))
+ x = PyUnicode_Format(v, w);
+ else
+ x = PyNumber_Remainder(v, w);
Py_DECREF(v);
Py_DECREF(w);
SET_TOP(x);
Modified: python/branches/io-c/README
==============================================================================
--- python/branches/io-c/README (original)
+++ python/branches/io-c/README Sat Feb 28 20:20:42 2009
@@ -88,6 +88,33 @@
used, and backported versions of certain key Python 3.x features.
+Testing
+-------
+
+To test the interpreter, type "make test" in the top-level directory.
+This runs the test set twice (once with no compiled files, once with
+the compiled files left by the previous test run). The test set
+produces some output. You can generally ignore the messages about
+skipped tests due to optional features which can't be imported.
+If a message is printed about a failed test or a traceback or core
+dump is produced, something is wrong. On some Linux systems (those
+that are not yet using glibc 6), test_strftime fails due to a
+non-standard implementation of strftime() in the C library. Please
+ignore this, or upgrade to glibc version 6.
+
+By default, tests are prevented from overusing resources like disk space and
+memory. To enable these tests, run "make testall".
+
+IMPORTANT: If the tests fail and you decide to mail a bug report,
+*don't* include the output of "make test". It is useless. Run the
+failing test manually, as follows:
+
+ ./python Lib/test/regrtest.py -v test_whatever
+
+(substituting the top of the source tree for '.' if you built in a
+different directory). This runs the test in verbose mode.
+
+
Installing multiple versions
----------------------------
Modified: python/branches/io-c/Tools/scripts/README
==============================================================================
--- python/branches/io-c/Tools/scripts/README (original)
+++ python/branches/io-c/Tools/scripts/README Sat Feb 28 20:20:42 2009
@@ -4,6 +4,7 @@
See also the Demo/scripts directory!
+analyze_dxp.py Analyzes the result of sys.getdxp()
byext.py Print lines/words/chars stats of files by extension
byteyears.py Print product of a file's size and age
checkappend.py Search for multi-argument .append() calls
1
0

Feb. 28, 2009
Author: benjamin.peterson
Date: Sat Feb 28 20:15:55 2009
New Revision: 70073
Log:
Merged revisions 70072 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r70072 | benjamin.peterson | 2009-02-28 13:06:54 -0600 (Sat, 28 Feb 2009) | 1 line
#4967 fix buggy read()
........
Modified:
python/branches/release30-maint/ (props changed)
python/branches/release30-maint/Modules/_ssl.c
Modified: python/branches/release30-maint/Modules/_ssl.c
==============================================================================
--- python/branches/release30-maint/Modules/_ssl.c (original)
+++ python/branches/release30-maint/Modules/_ssl.c Sat Feb 28 20:15:55 2009
@@ -1244,9 +1244,12 @@
static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
{
- PyObject *buf = NULL;
+ PyObject *dest = NULL;
+ Py_buffer buf;
int buf_passed = 0;
int count = -1;
+ char *mem;
+ /* XXX this should use Py_ssize_t */
int len = 1024;
int sockstate;
int err;
@@ -1260,19 +1263,22 @@
return NULL;
}
- if (!PyArg_ParseTuple(args, "|Oi:read", &buf, &count))
+ if (!PyArg_ParseTuple(args, "|Oi:read", &dest, &count))
return NULL;
- if ((buf == NULL) || (buf == Py_None)) {
- if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
+ if ((dest == NULL) || (dest == Py_None)) {
+ if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
- } else if (PyLong_Check(buf)) {
- len = PyLong_AS_LONG(buf);
- if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
+ mem = PyByteArray_AS_STRING(dest);
+ } else if (PyLong_Check(dest)) {
+ len = PyLong_AS_LONG(dest);
+ if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
+ mem = PyByteArray_AS_STRING(dest);
} else {
- if (!PyByteArray_Check(buf))
+ if (PyObject_GetBuffer(dest, &buf, PyBUF_CONTIG) < 0)
return NULL;
- len = PyByteArray_Size(buf);
+ mem = buf.buf;
+ len = buf.len;
if ((count > 0) && (count <= len))
len = count;
buf_passed = 1;
@@ -1293,18 +1299,11 @@
if (sockstate == SOCKET_HAS_TIMED_OUT) {
PyErr_SetString(PySSLErrorObject,
"The read operation timed out");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
PyErr_SetString(PySSLErrorObject,
"Underlying socket too large for select().");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- Py_DECREF(buf);
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
count = 0;
goto done;
@@ -1313,15 +1312,11 @@
do {
err = 0;
PySSL_BEGIN_ALLOW_THREADS
- count = SSL_read(self->ssl, PyByteArray_AsString(buf), len);
+ count = SSL_read(self->ssl, mem, len);
err = SSL_get_error(self->ssl, count);
PySSL_END_ALLOW_THREADS
- if(PyErr_CheckSignals()) {
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
- }
+ if (PyErr_CheckSignals())
+ goto error;
if (err == SSL_ERROR_WANT_READ) {
sockstate =
check_socket_and_wait_for_timeout(sock, 0);
@@ -1340,29 +1335,31 @@
if (sockstate == SOCKET_HAS_TIMED_OUT) {
PyErr_SetString(PySSLErrorObject,
"The read operation timed out");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_IS_NONBLOCKING) {
break;
}
} while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
if (count <= 0) {
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return PySSL_SetError(self, count, __FILE__, __LINE__);
+ PySSL_SetError(self, count, __FILE__, __LINE__);
+ goto error;
}
done:
if (!buf_passed) {
- PyObject *res = PyBytes_FromStringAndSize(
- PyByteArray_AS_STRING(buf), count);
- Py_DECREF(buf);
+ PyObject *res = PyBytes_FromStringAndSize(mem, count);
+ Py_DECREF(dest);
return res;
} else {
+ PyBuffer_Release(&buf);
return PyLong_FromLong(count);
}
+ error:
+ if (!buf_passed) {
+ Py_DECREF(dest);
+ } else {
+ PyBuffer_Release(&buf);
+ }
+ return NULL;
}
PyDoc_STRVAR(PySSL_SSLread_doc,
1
0
Author: benjamin.peterson
Date: Sat Feb 28 20:06:54 2009
New Revision: 70072
Log:
#4967 fix buggy read()
Modified:
python/branches/py3k/Modules/_ssl.c
Modified: python/branches/py3k/Modules/_ssl.c
==============================================================================
--- python/branches/py3k/Modules/_ssl.c (original)
+++ python/branches/py3k/Modules/_ssl.c Sat Feb 28 20:06:54 2009
@@ -1244,9 +1244,12 @@
static PyObject *PySSL_SSLread(PySSLObject *self, PyObject *args)
{
- PyObject *buf = NULL;
+ PyObject *dest = NULL;
+ Py_buffer buf;
int buf_passed = 0;
int count = -1;
+ char *mem;
+ /* XXX this should use Py_ssize_t */
int len = 1024;
int sockstate;
int err;
@@ -1260,19 +1263,22 @@
return NULL;
}
- if (!PyArg_ParseTuple(args, "|Oi:read", &buf, &count))
+ if (!PyArg_ParseTuple(args, "|Oi:read", &dest, &count))
return NULL;
- if ((buf == NULL) || (buf == Py_None)) {
- if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
+ if ((dest == NULL) || (dest == Py_None)) {
+ if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
- } else if (PyLong_Check(buf)) {
- len = PyLong_AS_LONG(buf);
- if (!(buf = PyByteArray_FromStringAndSize((char *) 0, len)))
+ mem = PyByteArray_AS_STRING(dest);
+ } else if (PyLong_Check(dest)) {
+ len = PyLong_AS_LONG(dest);
+ if (!(dest = PyByteArray_FromStringAndSize((char *) 0, len)))
return NULL;
+ mem = PyByteArray_AS_STRING(dest);
} else {
- if (!PyByteArray_Check(buf))
+ if (PyObject_GetBuffer(dest, &buf, PyBUF_CONTIG) < 0)
return NULL;
- len = PyByteArray_Size(buf);
+ mem = buf.buf;
+ len = buf.len;
if ((count > 0) && (count <= len))
len = count;
buf_passed = 1;
@@ -1293,18 +1299,11 @@
if (sockstate == SOCKET_HAS_TIMED_OUT) {
PyErr_SetString(PySSLErrorObject,
"The read operation timed out");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_TOO_LARGE_FOR_SELECT) {
PyErr_SetString(PySSLErrorObject,
"Underlying socket too large for select().");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- Py_DECREF(buf);
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_HAS_BEEN_CLOSED) {
count = 0;
goto done;
@@ -1313,15 +1312,11 @@
do {
err = 0;
PySSL_BEGIN_ALLOW_THREADS
- count = SSL_read(self->ssl, PyByteArray_AsString(buf), len);
+ count = SSL_read(self->ssl, mem, len);
err = SSL_get_error(self->ssl, count);
PySSL_END_ALLOW_THREADS
- if(PyErr_CheckSignals()) {
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
- }
+ if (PyErr_CheckSignals())
+ goto error;
if (err == SSL_ERROR_WANT_READ) {
sockstate =
check_socket_and_wait_for_timeout(sock, 0);
@@ -1340,29 +1335,31 @@
if (sockstate == SOCKET_HAS_TIMED_OUT) {
PyErr_SetString(PySSLErrorObject,
"The read operation timed out");
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return NULL;
+ goto error;
} else if (sockstate == SOCKET_IS_NONBLOCKING) {
break;
}
} while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE);
if (count <= 0) {
- if (!buf_passed) {
- Py_DECREF(buf);
- }
- return PySSL_SetError(self, count, __FILE__, __LINE__);
+ PySSL_SetError(self, count, __FILE__, __LINE__);
+ goto error;
}
done:
if (!buf_passed) {
- PyObject *res = PyBytes_FromStringAndSize(
- PyByteArray_AS_STRING(buf), count);
- Py_DECREF(buf);
+ PyObject *res = PyBytes_FromStringAndSize(mem, count);
+ Py_DECREF(dest);
return res;
} else {
+ PyBuffer_Release(&buf);
return PyLong_FromLong(count);
}
+ error:
+ if (!buf_passed) {
+ Py_DECREF(dest);
+ } else {
+ PyBuffer_Release(&buf);
+ }
+ return NULL;
}
PyDoc_STRVAR(PySSL_SSLread_doc,
1
0

r70071 - in python/trunk: Doc/library/dis.rst Include/opcode.h Lib/compiler/pyassem.py Lib/compiler/pycodegen.py Lib/opcode.py Lib/test/test_dis.py Lib/test/test_peepholer.py Python/ceval.c Python/compile.c Python/import.c Python/peephole.c
by jeffrey.yasskin Feb. 28, 2009
by jeffrey.yasskin Feb. 28, 2009
Feb. 28, 2009
Author: jeffrey.yasskin
Date: Sat Feb 28 20:03:21 2009
New Revision: 70071
Log:
Backport r69961 to trunk, replacing JUMP_IF_{TRUE,FALSE} with
POP_JUMP_IF_{TRUE,FALSE} and JUMP_IF_{TRUE,FALSE}_OR_POP. This avoids executing
a POP_TOP on each conditional and sometimes allows the peephole optimizer to
skip a JUMP_ABSOLUTE entirely. It speeds up list comprehensions significantly.
Modified:
python/trunk/Doc/library/dis.rst
python/trunk/Include/opcode.h
python/trunk/Lib/compiler/pyassem.py
python/trunk/Lib/compiler/pycodegen.py
python/trunk/Lib/opcode.py
python/trunk/Lib/test/test_dis.py
python/trunk/Lib/test/test_peepholer.py
python/trunk/Python/ceval.c
python/trunk/Python/compile.c
python/trunk/Python/import.c
python/trunk/Python/peephole.c
Modified: python/trunk/Doc/library/dis.rst
==============================================================================
--- python/trunk/Doc/library/dis.rst (original)
+++ python/trunk/Doc/library/dis.rst Sat Feb 28 20:03:21 2009
@@ -664,16 +664,26 @@
Increments bytecode counter by *delta*.
-.. opcode:: JUMP_IF_TRUE (delta)
+.. opcode:: POP_JUMP_IF_TRUE (target)
- If TOS is true, increment the bytecode counter by *delta*. TOS is left on the
- stack.
+ If TOS is true, sets the bytecode counter to *target*. TOS is popped.
-.. opcode:: JUMP_IF_FALSE (delta)
+.. opcode:: POP_JUMP_IF_FALSE (target)
- If TOS is false, increment the bytecode counter by *delta*. TOS is not
- changed.
+ If TOS is false, sets the bytecode counter to *target*. TOS is popped.
+
+
+.. opcode:: JUMP_IF_TRUE_OR_POP (target)
+
+ If TOS is true, sets the bytecode counter to *target* and leaves TOS
+ on the stack. Otherwise (TOS is false), TOS is popped.
+
+
+.. opcode:: JUMP_IF_FALSE_OR_POP (target)
+
+ If TOS is false, sets the bytecode counter to *target* and leaves
+ TOS on the stack. Otherwise (TOS is true), TOS is popped.
.. opcode:: JUMP_ABSOLUTE (target)
Modified: python/trunk/Include/opcode.h
==============================================================================
--- python/trunk/Include/opcode.h (original)
+++ python/trunk/Include/opcode.h Sat Feb 28 20:03:21 2009
@@ -106,9 +106,12 @@
#define IMPORT_FROM 108 /* Index in name list */
#define JUMP_FORWARD 110 /* Number of bytes to skip */
-#define JUMP_IF_FALSE 111 /* "" */
-#define JUMP_IF_TRUE 112 /* "" */
-#define JUMP_ABSOLUTE 113 /* Target byte offset from beginning of code */
+#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning
+ of code */
+#define JUMP_IF_TRUE_OR_POP 112 /* "" */
+#define JUMP_ABSOLUTE 113 /* "" */
+#define POP_JUMP_IF_FALSE 114 /* "" */
+#define POP_JUMP_IF_TRUE 115 /* "" */
#define LOAD_GLOBAL 116 /* Index in name list */
Modified: python/trunk/Lib/compiler/pyassem.py
==============================================================================
--- python/trunk/Lib/compiler/pyassem.py (original)
+++ python/trunk/Lib/compiler/pyassem.py Sat Feb 28 20:03:21 2009
@@ -122,6 +122,9 @@
for b in remaining:
if __debug__ and b.next:
assert b is b.next[0].prev[0], (b, b.next)
+ # Make sure every block appears in dominators, even if no
+ # other block must precede it.
+ dominators.setdefault(b, set())
# preceeding blocks dominate following blocks
for c in b.get_followers():
while 1:
Modified: python/trunk/Lib/compiler/pycodegen.py
==============================================================================
--- python/trunk/Lib/compiler/pycodegen.py (original)
+++ python/trunk/Lib/compiler/pycodegen.py Sat Feb 28 20:03:21 2009
@@ -421,13 +421,11 @@
self.set_lineno(test)
self.visit(test)
nextTest = self.newBlock()
- self.emit('JUMP_IF_FALSE', nextTest)
+ self.emit('POP_JUMP_IF_FALSE', nextTest)
self.nextBlock()
- self.emit('POP_TOP')
self.visit(suite)
self.emit('JUMP_FORWARD', end)
self.startBlock(nextTest)
- self.emit('POP_TOP')
if node.else_:
self.visit(node.else_)
self.nextBlock(end)
@@ -446,15 +444,13 @@
self.set_lineno(node, force=True)
self.visit(node.test)
- self.emit('JUMP_IF_FALSE', else_ or after)
+ self.emit('POP_JUMP_IF_FALSE', else_ or after)
self.nextBlock()
- self.emit('POP_TOP')
self.visit(node.body)
self.emit('JUMP_ABSOLUTE', loop)
self.startBlock(else_) # or just the POPs if not else clause
- self.emit('POP_TOP')
self.emit('POP_BLOCK')
self.setups.pop()
if node.else_:
@@ -525,26 +521,23 @@
self.visit(child)
self.emit(jump, end)
self.nextBlock()
- self.emit('POP_TOP')
self.visit(node.nodes[-1])
self.nextBlock(end)
def visitAnd(self, node):
- self.visitTest(node, 'JUMP_IF_FALSE')
+ self.visitTest(node, 'JUMP_IF_FALSE_OR_POP')
def visitOr(self, node):
- self.visitTest(node, 'JUMP_IF_TRUE')
+ self.visitTest(node, 'JUMP_IF_TRUE_OR_POP')
def visitIfExp(self, node):
endblock = self.newBlock()
elseblock = self.newBlock()
self.visit(node.test)
- self.emit('JUMP_IF_FALSE', elseblock)
- self.emit('POP_TOP')
+ self.emit('POP_JUMP_IF_FALSE', elseblock)
self.visit(node.then)
self.emit('JUMP_FORWARD', endblock)
self.nextBlock(elseblock)
- self.emit('POP_TOP')
self.visit(node.else_)
self.nextBlock(endblock)
@@ -556,9 +549,8 @@
self.emit('DUP_TOP')
self.emit('ROT_THREE')
self.emit('COMPARE_OP', op)
- self.emit('JUMP_IF_FALSE', cleanup)
+ self.emit('JUMP_IF_FALSE_OR_POP', cleanup)
self.nextBlock()
- self.emit('POP_TOP')
# now do the last comparison
if node.ops:
op, code = node.ops[-1]
@@ -593,11 +585,7 @@
for start, cont, anchor in stack:
if cont:
- skip_one = self.newBlock()
- self.emit('JUMP_FORWARD', skip_one)
- self.startBlock(cont)
- self.emit('POP_TOP')
- self.nextBlock(skip_one)
+ self.nextBlock(cont)
self.emit('JUMP_ABSOLUTE', start)
self.startBlock(anchor)
@@ -617,9 +605,8 @@
def visitListCompIf(self, node, branch):
self.set_lineno(node, force=True)
self.visit(node.test)
- self.emit('JUMP_IF_FALSE', branch)
+ self.emit('POP_JUMP_IF_FALSE', branch)
self.newBlock()
- self.emit('POP_TOP')
def _makeClosure(self, gen, args):
frees = gen.scope.get_free_vars()
@@ -665,11 +652,7 @@
for start, cont, anchor, end in stack:
if cont:
- skip_one = self.newBlock()
- self.emit('JUMP_FORWARD', skip_one)
- self.startBlock(cont)
- self.emit('POP_TOP')
- self.nextBlock(skip_one)
+ self.nextBlock(cont)
self.emit('JUMP_ABSOLUTE', start)
self.startBlock(anchor)
self.emit('POP_BLOCK')
@@ -702,9 +685,8 @@
def visitGenExprIf(self, node, branch):
self.set_lineno(node, force=True)
self.visit(node.test)
- self.emit('JUMP_IF_FALSE', branch)
+ self.emit('POP_JUMP_IF_FALSE', branch)
self.newBlock()
- self.emit('POP_TOP')
# exception related
@@ -719,9 +701,8 @@
# is a sort of renaming op.
self.nextBlock()
self.visit(node.test)
- self.emit('JUMP_IF_TRUE', end)
+ self.emit('POP_JUMP_IF_TRUE', end)
self.nextBlock()
- self.emit('POP_TOP')
self.emit('LOAD_GLOBAL', 'AssertionError')
if node.fail:
self.visit(node.fail)
@@ -729,7 +710,6 @@
else:
self.emit('RAISE_VARARGS', 1)
self.nextBlock(end)
- self.emit('POP_TOP')
def visitRaise(self, node):
self.set_lineno(node)
@@ -772,9 +752,8 @@
self.visit(expr)
self.emit('COMPARE_OP', 'exception match')
next = self.newBlock()
- self.emit('JUMP_IF_FALSE', next)
+ self.emit('POP_JUMP_IF_FALSE', next)
self.nextBlock()
- self.emit('POP_TOP')
self.emit('POP_TOP')
if target:
self.visit(target)
@@ -787,8 +766,6 @@
self.nextBlock(next)
else:
self.nextBlock()
- if expr: # XXX
- self.emit('POP_TOP')
self.emit('END_FINALLY')
if node.else_:
self.nextBlock(lElse)
Modified: python/trunk/Lib/opcode.py
==============================================================================
--- python/trunk/Lib/opcode.py (original)
+++ python/trunk/Lib/opcode.py Sat Feb 28 20:03:21 2009
@@ -146,9 +146,11 @@
name_op('IMPORT_FROM', 108) # Index in name list
jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip
-jrel_op('JUMP_IF_FALSE', 111) # ""
-jrel_op('JUMP_IF_TRUE', 112) # ""
-jabs_op('JUMP_ABSOLUTE', 113) # Target byte offset from beginning of code
+jabs_op('JUMP_IF_FALSE_OR_POP', 111) # Target byte offset from beginning of code
+jabs_op('JUMP_IF_TRUE_OR_POP', 112) # ""
+jabs_op('JUMP_ABSOLUTE', 113) # ""
+jabs_op('POP_JUMP_IF_FALSE', 114) # ""
+jabs_op('POP_JUMP_IF_TRUE', 115) # ""
name_op('LOAD_GLOBAL', 116) # Index in name list
Modified: python/trunk/Lib/test/test_dis.py
==============================================================================
--- python/trunk/Lib/test/test_dis.py (original)
+++ python/trunk/Lib/test/test_dis.py Sat Feb 28 20:03:21 2009
@@ -54,25 +54,23 @@
dis_bug1333982 = """\
%-4d 0 LOAD_CONST 1 (0)
- 3 JUMP_IF_TRUE 33 (to 39)
- 6 POP_TOP
- 7 LOAD_GLOBAL 0 (AssertionError)
- 10 BUILD_LIST 0
- 13 LOAD_FAST 0 (x)
- 16 GET_ITER
- >> 17 FOR_ITER 12 (to 32)
- 20 STORE_FAST 1 (s)
- 23 LOAD_FAST 1 (s)
- 26 LIST_APPEND 2
- 29 JUMP_ABSOLUTE 17
-
- %-4d >> 32 LOAD_CONST 2 (1)
- 35 BINARY_ADD
- 36 RAISE_VARARGS 2
- >> 39 POP_TOP
+ 3 POP_JUMP_IF_TRUE 38
+ 6 LOAD_GLOBAL 0 (AssertionError)
+ 9 BUILD_LIST 0
+ 12 LOAD_FAST 0 (x)
+ 15 GET_ITER
+ >> 16 FOR_ITER 12 (to 31)
+ 19 STORE_FAST 1 (s)
+ 22 LOAD_FAST 1 (s)
+ 25 LIST_APPEND 2
+ 28 JUMP_ABSOLUTE 16
+
+ %-4d >> 31 LOAD_CONST 2 (1)
+ 34 BINARY_ADD
+ 35 RAISE_VARARGS 2
- %-4d 40 LOAD_CONST 0 (None)
- 43 RETURN_VALUE
+ %-4d >> 38 LOAD_CONST 0 (None)
+ 41 RETURN_VALUE
"""%(bug1333982.func_code.co_firstlineno + 1,
bug1333982.func_code.co_firstlineno + 2,
bug1333982.func_code.co_firstlineno + 3)
Modified: python/trunk/Lib/test/test_peepholer.py
==============================================================================
--- python/trunk/Lib/test/test_peepholer.py (original)
+++ python/trunk/Lib/test/test_peepholer.py Sat Feb 28 20:03:21 2009
@@ -19,15 +19,14 @@
class TestTranforms(unittest.TestCase):
def test_unot(self):
- # UNARY_NOT JUMP_IF_FALSE POP_TOP --> JUMP_IF_TRUE POP_TOP'
+ # UNARY_NOT POP_JUMP_IF_FALSE --> POP_JUMP_IF_TRUE
def unot(x):
if not x == 2:
del x
asm = disassemble(unot)
- for elem in ('UNARY_NOT', 'JUMP_IF_FALSE'):
+ for elem in ('UNARY_NOT', 'POP_JUMP_IF_FALSE'):
self.assert_(elem not in asm)
- for elem in ('JUMP_IF_TRUE', 'POP_TOP'):
- self.assert_(elem in asm)
+ self.assert_('POP_JUMP_IF_TRUE' in asm)
def test_elim_inversion_of_is_or_in(self):
for line, elem in (
@@ -56,13 +55,13 @@
self.assert_('LOAD_GLOBAL' not in disassemble(f))
def test_while_one(self):
- # Skip over: LOAD_CONST trueconst JUMP_IF_FALSE xx POP_TOP
+ # Skip over: LOAD_CONST trueconst POP_JUMP_IF_FALSE xx
def f():
while 1:
pass
return list
asm = disassemble(f)
- for elem in ('LOAD_CONST', 'JUMP_IF_FALSE'):
+ for elem in ('LOAD_CONST', 'POP_JUMP_IF_FALSE'):
self.assert_(elem not in asm)
for elem in ('JUMP_ABSOLUTE',):
self.assert_(elem in asm)
Modified: python/trunk/Python/ceval.c
==============================================================================
--- python/trunk/Python/ceval.c (original)
+++ python/trunk/Python/ceval.c Sat Feb 28 20:03:21 2009
@@ -764,8 +764,8 @@
/* OpCode prediction macros
Some opcodes tend to come in pairs thus making it possible to
predict the second code when the first is run. For example,
- COMPARE_OP is often followed by JUMP_IF_FALSE or JUMP_IF_TRUE. And,
- those opcodes are often followed by a POP_TOP.
+ GET_ITER is often followed by FOR_ITER. And FOR_ITER is often
+ followed by STORE_FAST or UNPACK_SEQUENCE.
Verifying the prediction costs a single high-speed test of a register
variable against a constant. If the pairing was good, then the
@@ -1110,7 +1110,6 @@
SETLOCAL(oparg, v);
goto fast_next_opcode;
- PREDICTED(POP_TOP);
case POP_TOP:
v = POP();
Py_DECREF(v);
@@ -2220,8 +2219,8 @@
Py_DECREF(w);
SET_TOP(x);
if (x == NULL) break;
- PREDICT(JUMP_IF_FALSE);
- PREDICT(JUMP_IF_TRUE);
+ PREDICT(POP_JUMP_IF_FALSE);
+ PREDICT(POP_JUMP_IF_TRUE);
continue;
case IMPORT_NAME:
@@ -2298,41 +2297,45 @@
JUMPBY(oparg);
goto fast_next_opcode;
- PREDICTED_WITH_ARG(JUMP_IF_FALSE);
- case JUMP_IF_FALSE:
- w = TOP();
+ PREDICTED_WITH_ARG(POP_JUMP_IF_FALSE);
+ case POP_JUMP_IF_FALSE:
+ w = POP();
if (w == Py_True) {
- PREDICT(POP_TOP);
+ Py_DECREF(w);
goto fast_next_opcode;
}
if (w == Py_False) {
- JUMPBY(oparg);
+ Py_DECREF(w);
+ JUMPTO(oparg);
goto fast_next_opcode;
}
err = PyObject_IsTrue(w);
+ Py_DECREF(w);
if (err > 0)
err = 0;
else if (err == 0)
- JUMPBY(oparg);
+ JUMPTO(oparg);
else
break;
continue;
- PREDICTED_WITH_ARG(JUMP_IF_TRUE);
- case JUMP_IF_TRUE:
- w = TOP();
+ PREDICTED_WITH_ARG(POP_JUMP_IF_TRUE);
+ case POP_JUMP_IF_TRUE:
+ w = POP();
if (w == Py_False) {
- PREDICT(POP_TOP);
+ Py_DECREF(w);
goto fast_next_opcode;
}
if (w == Py_True) {
- JUMPBY(oparg);
+ Py_DECREF(w);
+ JUMPTO(oparg);
goto fast_next_opcode;
}
err = PyObject_IsTrue(w);
+ Py_DECREF(w);
if (err > 0) {
err = 0;
- JUMPBY(oparg);
+ JUMPTO(oparg);
}
else if (err == 0)
;
@@ -2340,6 +2343,53 @@
break;
continue;
+ case JUMP_IF_FALSE_OR_POP:
+ w = TOP();
+ if (w == Py_True) {
+ STACKADJ(-1);
+ Py_DECREF(w);
+ goto fast_next_opcode;
+ }
+ if (w == Py_False) {
+ JUMPTO(oparg);
+ goto fast_next_opcode;
+ }
+ err = PyObject_IsTrue(w);
+ if (err > 0) {
+ STACKADJ(-1);
+ Py_DECREF(w);
+ err = 0;
+ }
+ else if (err == 0)
+ JUMPTO(oparg);
+ else
+ break;
+ continue;
+
+ case JUMP_IF_TRUE_OR_POP:
+ w = TOP();
+ if (w == Py_False) {
+ STACKADJ(-1);
+ Py_DECREF(w);
+ goto fast_next_opcode;
+ }
+ if (w == Py_True) {
+ JUMPTO(oparg);
+ goto fast_next_opcode;
+ }
+ err = PyObject_IsTrue(w);
+ if (err > 0) {
+ err = 0;
+ JUMPTO(oparg);
+ }
+ else if (err == 0) {
+ STACKADJ(-1);
+ Py_DECREF(w);
+ }
+ else
+ break;
+ continue;
+
PREDICTED_WITH_ARG(JUMP_ABSOLUTE);
case JUMP_ABSOLUTE:
JUMPTO(oparg);
Modified: python/trunk/Python/compile.c
==============================================================================
--- python/trunk/Python/compile.c (original)
+++ python/trunk/Python/compile.c Sat Feb 28 20:03:21 2009
@@ -836,11 +836,15 @@
return 1;
case JUMP_FORWARD:
- case JUMP_IF_FALSE:
- case JUMP_IF_TRUE:
+ case JUMP_IF_TRUE_OR_POP: /* -1 if jump not taken */
+ case JUMP_IF_FALSE_OR_POP: /* "" */
case JUMP_ABSOLUTE:
return 0;
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
+ return -1;
+
case LOAD_GLOBAL:
return 1;
@@ -1499,12 +1503,10 @@
if (next == NULL)
return 0;
VISIT(c, expr, e->v.IfExp.test);
- ADDOP_JREL(c, JUMP_IF_FALSE, next);
- ADDOP(c, POP_TOP);
+ ADDOP_JABS(c, POP_JUMP_IF_FALSE, next);
VISIT(c, expr, e->v.IfExp.body);
ADDOP_JREL(c, JUMP_FORWARD, end);
compiler_use_next_block(c, next);
- ADDOP(c, POP_TOP);
VISIT(c, expr, e->v.IfExp.orelse);
compiler_use_next_block(c, end);
return 1;
@@ -1597,9 +1599,6 @@
end = compiler_new_block(c);
if (end == NULL)
return 0;
- next = compiler_new_block(c);
- if (next == NULL)
- return 0;
constant = expr_constant(s->v.If.test);
/* constant = 0: "if 0"
@@ -1611,15 +1610,21 @@
} else if (constant == 1) {
VISIT_SEQ(c, stmt, s->v.If.body);
} else {
+ if (s->v.If.orelse) {
+ next = compiler_new_block(c);
+ if (next == NULL)
+ return 0;
+ }
+ else
+ next = end;
VISIT(c, expr, s->v.If.test);
- ADDOP_JREL(c, JUMP_IF_FALSE, next);
- ADDOP(c, POP_TOP);
+ ADDOP_JABS(c, POP_JUMP_IF_FALSE, next);
VISIT_SEQ(c, stmt, s->v.If.body);
ADDOP_JREL(c, JUMP_FORWARD, end);
- compiler_use_next_block(c, next);
- ADDOP(c, POP_TOP);
- if (s->v.If.orelse)
+ if (s->v.If.orelse) {
+ compiler_use_next_block(c, next);
VISIT_SEQ(c, stmt, s->v.If.orelse);
+ }
}
compiler_use_next_block(c, end);
return 1;
@@ -1693,8 +1698,7 @@
so we need to set an extra line number. */
c->u->u_lineno_set = false;
VISIT(c, expr, s->v.While.test);
- ADDOP_JREL(c, JUMP_IF_FALSE, anchor);
- ADDOP(c, POP_TOP);
+ ADDOP_JABS(c, POP_JUMP_IF_FALSE, anchor);
}
VISIT_SEQ(c, stmt, s->v.While.body);
ADDOP_JABS(c, JUMP_ABSOLUTE, loop);
@@ -1705,7 +1709,6 @@
if (constant == -1) {
compiler_use_next_block(c, anchor);
- ADDOP(c, POP_TOP);
ADDOP(c, POP_BLOCK);
}
compiler_pop_fblock(c, LOOP, loop);
@@ -1826,20 +1829,17 @@
[tb, val, exc] L1: DUP )
[tb, val, exc, exc] <evaluate E1> )
[tb, val, exc, exc, E1] COMPARE_OP EXC_MATCH ) only if E1
- [tb, val, exc, 1-or-0] JUMP_IF_FALSE L2 )
- [tb, val, exc, 1] POP )
+ [tb, val, exc, 1-or-0] POP_JUMP_IF_FALSE L2 )
[tb, val, exc] POP
[tb, val] <assign to V1> (or POP if no V1)
[tb] POP
[] <code for S1>
JUMP_FORWARD L0
- [tb, val, exc, 0] L2: POP
- [tb, val, exc] DUP
+ [tb, val, exc] L2: DUP
.............................etc.......................
- [tb, val, exc, 0] Ln+1: POP
- [tb, val, exc] END_FINALLY # re-raise exception
+ [tb, val, exc] Ln+1: END_FINALLY # re-raise exception
[] L0: <next statement>
@@ -1881,8 +1881,7 @@
ADDOP(c, DUP_TOP);
VISIT(c, expr, handler->v.ExceptHandler.type);
ADDOP_I(c, COMPARE_OP, PyCmp_EXC_MATCH);
- ADDOP_JREL(c, JUMP_IF_FALSE, except);
- ADDOP(c, POP_TOP);
+ ADDOP_JABS(c, POP_JUMP_IF_FALSE, except);
}
ADDOP(c, POP_TOP);
if (handler->v.ExceptHandler.name) {
@@ -1895,8 +1894,6 @@
VISIT_SEQ(c, stmt, handler->v.ExceptHandler.body);
ADDOP_JREL(c, JUMP_FORWARD, end);
compiler_use_next_block(c, except);
- if (handler->v.ExceptHandler.type)
- ADDOP(c, POP_TOP);
}
ADDOP(c, END_FINALLY);
compiler_use_next_block(c, orelse);
@@ -2084,8 +2081,7 @@
end = compiler_new_block(c);
if (end == NULL)
return 0;
- ADDOP_JREL(c, JUMP_IF_TRUE, end);
- ADDOP(c, POP_TOP);
+ ADDOP_JABS(c, POP_JUMP_IF_TRUE, end);
ADDOP_O(c, LOAD_GLOBAL, assertion_error, names);
if (s->v.Assert.msg) {
VISIT(c, expr, s->v.Assert.msg);
@@ -2095,7 +2091,6 @@
ADDOP_I(c, RAISE_VARARGS, 1);
}
compiler_use_next_block(c, end);
- ADDOP(c, POP_TOP);
return 1;
}
@@ -2473,9 +2468,9 @@
assert(e->kind == BoolOp_kind);
if (e->v.BoolOp.op == And)
- jumpi = JUMP_IF_FALSE;
+ jumpi = JUMP_IF_FALSE_OR_POP;
else
- jumpi = JUMP_IF_TRUE;
+ jumpi = JUMP_IF_TRUE_OR_POP;
end = compiler_new_block(c);
if (end == NULL)
return 0;
@@ -2484,8 +2479,7 @@
assert(n >= 0);
for (i = 0; i < n; ++i) {
VISIT(c, expr, (expr_ty)asdl_seq_GET(s, i));
- ADDOP_JREL(c, jumpi, end);
- ADDOP(c, POP_TOP)
+ ADDOP_JABS(c, jumpi, end);
}
VISIT(c, expr, (expr_ty)asdl_seq_GET(s, n));
compiler_use_next_block(c, end);
@@ -2543,9 +2537,8 @@
ADDOP_I(c, COMPARE_OP,
cmpop((cmpop_ty)(asdl_seq_GET(
e->v.Compare.ops, i - 1))));
- ADDOP_JREL(c, JUMP_IF_FALSE, cleanup);
+ ADDOP_JABS(c, JUMP_IF_FALSE_OR_POP, cleanup);
NEXT_BLOCK(c);
- ADDOP(c, POP_TOP);
if (i < (n - 1))
VISIT(c, expr,
(expr_ty)asdl_seq_GET(e->v.Compare.comparators, i));
@@ -2636,9 +2629,8 @@
for (i = 0; i < n; i++) {
expr_ty e = (expr_ty)asdl_seq_GET(l->ifs, i);
VISIT(c, expr, e);
- ADDOP_JREL(c, JUMP_IF_FALSE, if_cleanup);
+ ADDOP_JABS(c, POP_JUMP_IF_FALSE, if_cleanup);
NEXT_BLOCK(c);
- ADDOP(c, POP_TOP);
}
if (++gen_index < asdl_seq_LEN(generators))
@@ -2652,12 +2644,7 @@
compiler_use_next_block(c, skip);
}
- for (i = 0; i < n; i++) {
- ADDOP_I(c, JUMP_FORWARD, 1);
- if (i == 0)
- compiler_use_next_block(c, if_cleanup);
- ADDOP(c, POP_TOP);
- }
+ compiler_use_next_block(c, if_cleanup);
ADDOP_JABS(c, JUMP_ABSOLUTE, start);
compiler_use_next_block(c, anchor);
@@ -2720,10 +2707,9 @@
for (i = 0; i < n; i++) {
expr_ty e = (expr_ty)asdl_seq_GET(ge->ifs, i);
VISIT(c, expr, e);
- ADDOP_JREL(c, JUMP_IF_FALSE, if_cleanup);
+ ADDOP_JABS(c, POP_JUMP_IF_FALSE, if_cleanup);
NEXT_BLOCK(c);
- ADDOP(c, POP_TOP);
- }
+ }
if (++gen_index < asdl_seq_LEN(generators))
if (!compiler_genexp_generator(c, generators, gen_index, elt))
@@ -2737,13 +2723,7 @@
compiler_use_next_block(c, skip);
}
- for (i = 0; i < n; i++) {
- ADDOP_I(c, JUMP_FORWARD, 1);
- if (i == 0)
- compiler_use_next_block(c, if_cleanup);
-
- ADDOP(c, POP_TOP);
- }
+ compiler_use_next_block(c, if_cleanup);
ADDOP_JABS(c, JUMP_ABSOLUTE, start);
compiler_use_next_block(c, anchor);
ADDOP(c, POP_BLOCK);
Modified: python/trunk/Python/import.c
==============================================================================
--- python/trunk/Python/import.c (original)
+++ python/trunk/Python/import.c Sat Feb 28 20:03:21 2009
@@ -72,9 +72,11 @@
Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode)
Python 2.6a1: 62161 (WITH_CLEANUP optimization)
Python 2.7a0: 62171 (optimize list comprehensions/change LIST_APPEND)
+ Python 2.7a0: 62181 (optimize conditional branches:
+ introduce POP_JUMP_IF_FALSE and POP_JUMP_IF_TRUE)
.
*/
-#define MAGIC (62171 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (62181 | ((long)'\r'<<16) | ((long)'\n'<<24))
/* Magic word as global; note that _PyImport_Init() can change the
value of this global to accommodate for alterations of how the
Modified: python/trunk/Python/peephole.c
==============================================================================
--- python/trunk/Python/peephole.c (original)
+++ python/trunk/Python/peephole.c Sat Feb 28 20:03:21 2009
@@ -13,7 +13,12 @@
#define GETARG(arr, i) ((int)((arr[i+2]<<8) + arr[i+1]))
#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
-#define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP)
+#define CONDITIONAL_JUMP(op) (op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
+ || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP)
+#define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP \
+ || op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
+ || op==JUMP_IF_FALSE_OR_POP || op==JUMP_IF_TRUE_OR_POP)
+#define JUMPS_ON_TRUE(op) (op==POP_JUMP_IF_TRUE || op==JUMP_IF_TRUE_OR_POP)
#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3))
#define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255
#define CODESIZE(op) (HAS_ARG(op) ? 3 : 1)
@@ -245,8 +250,10 @@
switch (opcode) {
case FOR_ITER:
case JUMP_FORWARD:
- case JUMP_IF_FALSE:
- case JUMP_IF_TRUE:
+ case JUMP_IF_FALSE_OR_POP:
+ case JUMP_IF_TRUE_OR_POP:
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
case JUMP_ABSOLUTE:
case CONTINUE_LOOP:
case SETUP_LOOP:
@@ -338,29 +345,24 @@
assert(PyList_Check(consts));
for (i=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
+ reoptimize_current:
opcode = codestr[i];
lastlc = cumlc;
cumlc = 0;
switch (opcode) {
-
- /* Replace UNARY_NOT JUMP_IF_FALSE POP_TOP with
- with JUMP_IF_TRUE POP_TOP */
+ /* Replace UNARY_NOT POP_JUMP_IF_FALSE
+ with POP_JUMP_IF_TRUE */
case UNARY_NOT:
- if (codestr[i+1] != JUMP_IF_FALSE ||
- codestr[i+4] != POP_TOP ||
- !ISBASICBLOCK(blocks,i,5))
- continue;
- tgt = GETJUMPTGT(codestr, (i+1));
- if (codestr[tgt] != POP_TOP)
+ if (codestr[i+1] != POP_JUMP_IF_FALSE
+ || !ISBASICBLOCK(blocks,i,4))
continue;
- j = GETARG(codestr, i+1) + 1;
- codestr[i] = JUMP_IF_TRUE;
+ j = GETARG(codestr, i+1);
+ codestr[i] = POP_JUMP_IF_TRUE;
SETARG(codestr, i, j);
- codestr[i+3] = POP_TOP;
- codestr[i+4] = NOP;
- break;
+ codestr[i+3] = NOP;
+ goto reoptimize_current;
/* not a is b --> a is not b
not a in b --> a not in b
@@ -400,16 +402,16 @@
break;
/* Skip over LOAD_CONST trueconst
- JUMP_IF_FALSE xx POP_TOP */
+ POP_JUMP_IF_FALSE xx. This improves
+ "while 1" performance. */
case LOAD_CONST:
cumlc = lastlc + 1;
j = GETARG(codestr, i);
- if (codestr[i+3] != JUMP_IF_FALSE ||
- codestr[i+6] != POP_TOP ||
- !ISBASICBLOCK(blocks,i,7) ||
+ if (codestr[i+3] != POP_JUMP_IF_FALSE ||
+ !ISBASICBLOCK(blocks,i,6) ||
!PyObject_IsTrue(PyList_GET_ITEM(consts, j)))
continue;
- memset(codestr+i, NOP, 7);
+ memset(codestr+i, NOP, 6);
cumlc = 0;
break;
@@ -498,27 +500,49 @@
"if a or b:"
"a and b or c"
"(a and b) and c"
- x:JUMP_IF_FALSE y y:JUMP_IF_FALSE z --> x:JUMP_IF_FALSE z
- x:JUMP_IF_FALSE y y:JUMP_IF_TRUE z --> x:JUMP_IF_FALSE y+3
+ x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_FALSE_OR_POP z
+ --> x:JUMP_IF_FALSE_OR_POP z
+ x:JUMP_IF_FALSE_OR_POP y y:JUMP_IF_TRUE_OR_POP z
+ --> x:POP_JUMP_IF_FALSE y+3
where y+3 is the instruction following the second test.
*/
- case JUMP_IF_FALSE:
- case JUMP_IF_TRUE:
+ case JUMP_IF_FALSE_OR_POP:
+ case JUMP_IF_TRUE_OR_POP:
tgt = GETJUMPTGT(codestr, i);
j = codestr[tgt];
- if (j == JUMP_IF_FALSE || j == JUMP_IF_TRUE) {
- if (j == opcode) {
- tgttgt = GETJUMPTGT(codestr, tgt) - i - 3;
+ if (CONDITIONAL_JUMP(j)) {
+ /* NOTE: all possible jumps here are
+ absolute! */
+ if (JUMPS_ON_TRUE(j) == JUMPS_ON_TRUE(opcode)) {
+ /* The second jump will be
+ taken iff the first is. */
+ tgttgt = GETJUMPTGT(codestr, tgt);
+ /* The current opcode inherits
+ its target's stack behaviour */
+ codestr[i] = j;
SETARG(codestr, i, tgttgt);
+ goto reoptimize_current;
} else {
- tgt -= i;
- SETARG(codestr, i, tgt);
+ /* The second jump is not taken
+ if the first is (so jump past
+ it), and all conditional
+ jumps pop their argument when
+ they're not taken (so change
+ the first jump to pop its
+ argument when it's taken). */
+ if (JUMPS_ON_TRUE(opcode))
+ codestr[i] = POP_JUMP_IF_TRUE;
+ else
+ codestr[i] = POP_JUMP_IF_FALSE;
+ SETARG(codestr, i, (tgt + 3));
+ goto reoptimize_current;
}
- break;
}
- /* Intentional fallthrough */
+ /* Intentional fallthrough */
/* Replace jumps to unconditional jumps */
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
case FOR_ITER:
case JUMP_FORWARD:
case JUMP_ABSOLUTE:
@@ -591,14 +615,16 @@
case JUMP_ABSOLUTE:
case CONTINUE_LOOP:
+ case POP_JUMP_IF_FALSE:
+ case POP_JUMP_IF_TRUE:
+ case JUMP_IF_FALSE_OR_POP:
+ case JUMP_IF_TRUE_OR_POP:
j = addrmap[GETARG(codestr, i)];
SETARG(codestr, i, j);
break;
case FOR_ITER:
case JUMP_FORWARD:
- case JUMP_IF_FALSE:
- case JUMP_IF_TRUE:
case SETUP_LOOP:
case SETUP_EXCEPT:
case SETUP_FINALLY:
1
0
The Buildbot has detected a new failure of sparc solaris10 gcc 3.x.
Full details are available at:
http://www.python.org/dev/buildbot/all/sparc%20solaris10%20gcc%203.x/builds…
Buildbot URL: http://www.python.org/dev/buildbot/all/
Buildslave for this Build: loewis-sun
Build Reason:
Build Source Stamp: [branch branches/py3k] HEAD
Blamelist: hirokazu.yamamoto
BUILD FAILED: failed test
Excerpt from the test logfile:
1 test failed:
test_posix
======================================================================
ERROR: test_getcwd_long_pathnames (test.test_posix.PosixTester)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home2/buildbot/slave/3.x.loewis-sun/build/Lib/test/test_posix.py", line 252, in test_getcwd_long_pathnames
support.rmtree(base_path)
File "/home2/buildbot/slave/3.x.loewis-sun/build/Lib/test/support.py", line 98, in rmtree
shutil.rmtree(path)
File "/home2/buildbot/slave/3.x.loewis-sun/build/Lib/shutil.py", line 225, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File "/home2/buildbot/slave/3.x.loewis-sun/build/Lib/shutil.py", line 223, in rmtree
os.rmdir(path)
OSError: [Errno 22] Invalid argument: '/home2/buildbot/slave/3.x.loewis-sun/build/@test.getcwd/@test.getcwd'
sincerely,
-The Buildbot
1
0
The Buildbot has detected a new failure of x86 osx.5 2.6.
Full details are available at:
http://www.python.org/dev/buildbot/all/x86%20osx.5%202.6/builds/153
Buildbot URL: http://www.python.org/dev/buildbot/all/
Buildslave for this Build: heller-x86-osx5
Build Reason:
Build Source Stamp: [branch branches/release26-maint] HEAD
Blamelist: mark.dickinson
BUILD FAILED: failed test
Excerpt from the test logfile:
Traceback (most recent call last):
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/threading.py", line 522, in __bootstrap_inner
self.run()
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/test/test_ftplib.py", line 203, in run
asyncore.loop(timeout=0.1, count=1)
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 204, in loop
poll_fun(timeout, map)
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 141, in poll
read(obj)
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 78, in read
obj.handle_error()
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 74, in read
obj.handle_read_event()
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 413, in handle_read_event
self.handle_read()
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/test/test_ssl.py", line 408, in handle_read
self.send(data.lower())
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 519, in send
self.initiate_send()
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 506, in initiate_send
num_sent = dispatcher.send(self, self.out_buffer[:512])
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/asyncore.py", line 349, in send
result = self.socket.send(data)
File "/Users/buildbot/buildarea/2.6.heller-x86-osx5/build/Lib/socket.py", line 165, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
1 test failed:
test_ftplib
make: *** [buildbottest] Error 1
sincerely,
-The Buildbot
1
0
The Buildbot has detected a new failure of x86 XP-4 2.6.
Full details are available at:
http://www.python.org/dev/buildbot/all/x86%20XP-4%202.6/builds/118
Buildbot URL: http://www.python.org/dev/buildbot/all/
Buildslave for this Build: bolen-windows
Build Reason:
Build Source Stamp: [branch branches/release26-maint] HEAD
Blamelist: mark.dickinson
BUILD FAILED: failed test
Excerpt from the test logfile:
1 test failed:
a DOS box should flash briefly ...
sincerely,
-The Buildbot
1
0
The Buildbot has detected a new failure of sparc solaris10 gcc 3.0.
Full details are available at:
http://www.python.org/dev/buildbot/all/sparc%20solaris10%20gcc%203.0/builds…
Buildbot URL: http://www.python.org/dev/buildbot/all/
Buildslave for this Build: loewis-sun
Build Reason:
Build Source Stamp: [branch branches/release30-maint] HEAD
Blamelist: hirokazu.yamamoto
BUILD FAILED: failed test
Excerpt from the test logfile:
2 tests failed:
test_posix test_subprocess
======================================================================
ERROR: test_getcwd_long_pathnames (test.test_posix.PosixTester)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home2/buildbot/slave/3.0.loewis-sun/build/Lib/test/test_posix.py", line 252, in test_getcwd_long_pathnames
support.rmtree(base_path)
File "/home2/buildbot/slave/3.0.loewis-sun/build/Lib/test/support.py", line 98, in rmtree
shutil.rmtree(path)
File "/home2/buildbot/slave/3.0.loewis-sun/build/Lib/shutil.py", line 225, in rmtree
onerror(os.rmdir, path, sys.exc_info())
File "/home2/buildbot/slave/3.0.loewis-sun/build/Lib/shutil.py", line 223, in rmtree
os.rmdir(path)
OSError: [Errno 22] Invalid argument: '/home2/buildbot/slave/3.0.loewis-sun/build/@test.getcwd/@test.getcwd'
======================================================================
FAIL: test_executable (test.test_subprocess.ProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home2/buildbot/slave/3.0.loewis-sun/build/Lib/test/test_subprocess.py", line 115, in test_executable
self.assertEqual(p.returncode, 47)
AssertionError: -6 != 47
sincerely,
-The Buildbot
1
0

Feb. 28, 2009
Author: benjamin.peterson
Date: Sat Feb 28 18:06:42 2009
New Revision: 70070
Log:
give credit where credit is due
Modified:
python/branches/io-c/Doc/library/io.rst
python/branches/io-c/Lib/io.py
Modified: python/branches/io-c/Doc/library/io.rst
==============================================================================
--- python/branches/io-c/Doc/library/io.rst (original)
+++ python/branches/io-c/Doc/library/io.rst Sat Feb 28 18:06:42 2009
@@ -6,6 +6,8 @@
.. moduleauthor:: Guido van Rossum <guido(a)python.org>
.. moduleauthor:: Mike Verdone <mike.verdone(a)gmail.com>
.. moduleauthor:: Mark Russell <mark.russell(a)zen.co.uk>
+.. moduleauthor:: Antoine Pitrou <solipsis(a)pitrou.net>
+.. moduleauthor:: Amaury Forgeotdarc <amauryfa(a)gmail.com>
.. sectionauthor:: Benjamin Peterson <benjamin(a)python.org>
The :mod:`io` module provides the Python interfaces to stream handling. The
Modified: python/branches/io-c/Lib/io.py
==============================================================================
--- python/branches/io-c/Lib/io.py (original)
+++ python/branches/io-c/Lib/io.py Sat Feb 28 18:06:42 2009
@@ -45,7 +45,9 @@
__author__ = ("Guido van Rossum <guido(a)python.org>, "
"Mike Verdone <mike.verdone(a)gmail.com>, "
- "Mark Russell <mark.russell(a)zen.co.uk>")
+ "Mark Russell <mark.russell(a)zen.co.uk>, "
+ "Antoine Pitrou <solipsis(a)pitrou.net>, "
+ "Amaury Forgeotdarc <amauryfa(a)gmail.com>")
__all__ = ["BlockingIOError", "open", "IOBase", "RawIOBase", "FileIO",
"BytesIO", "StringIO", "BufferedIOBase",
1
0
Author: benjamin.peterson
Date: Sat Feb 28 18:01:17 2009
New Revision: 70069
Log:
document read1() in BufferedIOBase
Modified:
python/branches/io-c/Doc/library/io.rst
Modified: python/branches/io-c/Doc/library/io.rst
==============================================================================
--- python/branches/io-c/Doc/library/io.rst (original)
+++ python/branches/io-c/Doc/library/io.rst Sat Feb 28 18:01:17 2009
@@ -364,6 +364,11 @@
A :exc:`BlockingIOError` is raised if the underlying raw stream has no
data at the moment.
+ .. method:: read1([n])
+
+ Read and return up to *n* bytes, with at most one call to the underlying
+ raw stream's :meth:`~RawIOBase.read` method.
+
.. method:: readinto(b)
Read up to len(b) bytes into bytearray *b* and return the number of bytes
1
0