[Python-checkins] r68157 - in python/branches/py3k-issue1717: Doc/Makefile Doc/README.txt Doc/c-api/arg.rst Doc/c-api/exceptions.rst Doc/distutils/apiref.rst Doc/distutils/setupscript.rst Doc/extending/extending.rst Doc/howto/functional.rst Doc/howto/unicode.rst Doc/includes/noddy.c Doc/includes/noddy2.c Doc/includes/noddy3.c Doc/includes/noddy4.c Doc/library/dis.rst Doc/library/email.mime.rst Doc/library/functions.rst Doc/library/hashlib.rst Doc/library/json.rst Doc/library/logging.rst Doc/library/math.rst Doc/library/multiprocessing.rst Doc/library/optparse.rst Doc/library/pydoc.rst Doc/library/shutil.rst Doc/library/signal.rst Doc/library/stdtypes.rst Doc/library/subprocess.rst Doc/library/unittest.rst Doc/library/webbrowser.rst Doc/library/winsound.rst Doc/library/xml.etree.elementtree.rst Doc/library/zipfile.rst Doc/license.rst Doc/tools/sphinx-web.py Doc/tools/sphinxext/download.html Doc/tools/sphinxext/pyspecific.py Doc/tutorial/controlflow.rst Doc/using/unix.rst Doc/whatsnew/2.6.rst Include/pymacconfig.h Include/unicodeobject.h LICENSE Lib/dis.py Lib/distutils/ccompiler.py Lib/distutils/command/register.py Lib/distutils/config.py Lib/distutils/dist.py Lib/distutils/msvc9compiler.py Lib/distutils/tests/test_config.py Lib/distutils/tests/test_dist.py Lib/distutils/tests/test_msvc9compiler.py Lib/distutils/tests/test_register.py Lib/distutils/util.py Lib/idlelib/IOBinding.py Lib/idlelib/NEWS.txt Lib/idlelib/configDialog.py Lib/io.py Lib/lib2to3/main.py Lib/pickle.py Lib/pydoc.py Lib/re.py Lib/ssl.py Lib/test/pickletester.py Lib/test/test_array.py Lib/test/test_bytes.py Lib/test/test_deque.py Lib/test/test_dict.py Lib/test/test_file.py Lib/test/test_fileio.py Lib/test/test_generators.py Lib/test/test_hash.py Lib/test/test_io.py Lib/test/test_set.py Lib/test/test_unittest.py Lib/test/test_urllib2.py Lib/test/test_zipfile.py Lib/tkinter/colorchooser.py Lib/tkinter/filedialog.py Lib/tkinter/scrolledtext.py Lib/unittest.py Lib/zipfile.py Mac/BuildScript/build-installer.py Mac/BuildScript/resources/Welcome.rtf Mac/IDLE/IDLE.app/Contents/Info.plist Mac/IDLE/IDLE.app/Contents/MacOS/IDLE Mac/Makefile.in Mac/PythonLauncher/Info.plist.in Mac/PythonLauncher/Makefile.in Mac/Tools/bundlebuilder.py Mac/Tools/fixapplepython23.py Makefile.pre.in Misc/NEWS Misc/developers.txt Modules/_collectionsmodule.c Modules/_fileio.c Modules/_pickle.c Modules/_testcapimodule.c Modules/main.c Modules/mathmodule.c Modules/posixmodule.c Objects/bytearrayobject.c Objects/bytesobject.c Objects/dictobject.c Objects/object.c Objects/setobject.c Objects/unicodeobject.c Python/compile.c Python/getargs.c Tools/pybench/Lists.py setup.py
mark.dickinson
python-checkins at python.org
Fri Jan 2 15:30:43 CET 2009
Author: mark.dickinson
Date: Fri Jan 2 15:30:39 2009
New Revision: 68157
Log:
Merged revisions 67881,67884,67886-67887,67903,67910,67925,67929,67931,67933,67937-67942,67945,67947-67950,67956,67959,67962,67964,67966,67968-67969,67972,67974,67981,67983,68008,68012,68015,68017,68020,68022,68027,68036,68058-68059,68062,68064,68074-68075,68083,68090-68091,68093-68094,68101,68103,68113,68129,68132,68136-68140,68143,68152 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
................
r67881 | benjamin.peterson | 2008-12-20 22:50:25 +0000 (Sat, 20 Dec 2008) | 1 line
unpy3kize this; it require 2.x only Mac modules
................
r67884 | benjamin.peterson | 2008-12-20 23:06:29 +0000 (Sat, 20 Dec 2008) | 1 line
don't build bsddb anymore
................
r67886 | benjamin.peterson | 2008-12-21 00:06:59 +0000 (Sun, 21 Dec 2008) | 93 lines
Merged revisions 67654,67676-67677,67681,67692,67725,67761,67784-67785,67787-67788,67802,67848-67850,67862-67864,67880,67882 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67654 | georg.brandl | 2008-12-07 16:42:09 -0600 (Sun, 07 Dec 2008) | 2 lines
#4457: rewrite __import__() documentation.
........
r67676 | benjamin.peterson | 2008-12-08 20:03:03 -0600 (Mon, 08 Dec 2008) | 1 line
specify how things are copied
........
r67677 | benjamin.peterson | 2008-12-08 20:05:11 -0600 (Mon, 08 Dec 2008) | 1 line
revert unrelated change to installer script
........
r67681 | jeremy.hylton | 2008-12-09 15:03:10 -0600 (Tue, 09 Dec 2008) | 2 lines
Add simple unittests for Request
........
r67692 | amaury.forgeotdarc | 2008-12-10 18:03:42 -0600 (Wed, 10 Dec 2008) | 2 lines
#1030250: correctly pass the dry_run option to the mkpath() function.
........
r67725 | benjamin.peterson | 2008-12-12 22:02:20 -0600 (Fri, 12 Dec 2008) | 1 line
fix incorrect example
........
r67761 | benjamin.peterson | 2008-12-14 11:26:04 -0600 (Sun, 14 Dec 2008) | 1 line
fix missing bracket
........
r67784 | georg.brandl | 2008-12-15 02:33:58 -0600 (Mon, 15 Dec 2008) | 2 lines
#4446: document "platforms" argument for setup().
........
r67785 | georg.brandl | 2008-12-15 02:36:11 -0600 (Mon, 15 Dec 2008) | 2 lines
#4611: fix typo.
........
r67787 | georg.brandl | 2008-12-15 02:58:59 -0600 (Mon, 15 Dec 2008) | 2 lines
#4578: fix has_key() usage in compiler package.
........
r67788 | georg.brandl | 2008-12-15 03:07:39 -0600 (Mon, 15 Dec 2008) | 2 lines
#4568: remove limitation in varargs callback example.
........
r67802 | amaury.forgeotdarc | 2008-12-15 16:29:14 -0600 (Mon, 15 Dec 2008) | 4 lines
#3632: the "pyo" macro from gdbinit can now run when the GIL is released.
Patch by haypo.
........
r67848 | benjamin.peterson | 2008-12-18 20:28:56 -0600 (Thu, 18 Dec 2008) | 1 line
fix typo
........
r67849 | benjamin.peterson | 2008-12-18 20:31:35 -0600 (Thu, 18 Dec 2008) | 1 line
_call_method -> _callmethod and _get_value to _getvalue
........
r67850 | raymond.hettinger | 2008-12-19 03:06:07 -0600 (Fri, 19 Dec 2008) | 9 lines
Fix-up and clean-up docs for int.bit_length().
* Replace dramatic footnote with in-line comment about possible round-off errors in logarithms of large numbers.
* Add comments to the pure python code equivalent.
* replace floor() with int() in the mathematical equivalent so the type is correct (should be an int, not a float).
* add abs() to the mathematical equivalent so that it matches the previous line that it is supposed to be equivalent to.
* make one combined example with a negative input.
........
r67862 | benjamin.peterson | 2008-12-19 20:48:02 -0600 (Fri, 19 Dec 2008) | 1 line
copy sentence from docstring
........
r67863 | benjamin.peterson | 2008-12-19 20:51:26 -0600 (Fri, 19 Dec 2008) | 1 line
add headings
........
r67864 | benjamin.peterson | 2008-12-19 20:57:19 -0600 (Fri, 19 Dec 2008) | 1 line
beef up docstring
........
r67880 | benjamin.peterson | 2008-12-20 16:49:24 -0600 (Sat, 20 Dec 2008) | 1 line
remove redundant sentence
........
r67882 | benjamin.peterson | 2008-12-20 16:59:49 -0600 (Sat, 20 Dec 2008) | 1 line
add some recent releases to the list
........
................
r67887 | benjamin.peterson | 2008-12-21 00:16:13 +0000 (Sun, 21 Dec 2008) | 9 lines
Merged revisions 67885 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67885 | benjamin.peterson | 2008-12-20 17:48:54 -0600 (Sat, 20 Dec 2008) | 1 line
silence annoying DeprecationWarning
........
................
r67903 | benjamin.peterson | 2008-12-22 20:19:52 +0000 (Mon, 22 Dec 2008) | 8 lines
Blocked revisions 67902 via svnmerge
........
r67902 | benjamin.peterson | 2008-12-22 14:16:25 -0600 (Mon, 22 Dec 2008) | 1 line
add py3k warnings to frame.f_exc_*
........
................
r67910 | skip.montanaro | 2008-12-23 03:51:14 +0000 (Tue, 23 Dec 2008) | 11 lines
Merged revisions 67908 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67908 | skip.montanaro | 2008-12-22 21:30:15 -0600 (Mon, 22 Dec 2008) | 4 lines
As a result of a regression that snuck into 2.5.3 add a test case that
ensures that when you try to read from a file opened for writing an IOError
is raised.
........
................
r67925 | benjamin.peterson | 2008-12-24 16:27:25 +0000 (Wed, 24 Dec 2008) | 1 line
return the module object from PyMODINIT_FUNC
................
r67929 | benjamin.peterson | 2008-12-27 02:58:34 +0000 (Sat, 27 Dec 2008) | 1 line
string -> bytes in error message #4745
................
r67931 | hirokazu.yamamoto | 2008-12-27 04:21:44 +0000 (Sat, 27 Dec 2008) | 2 lines
Issue #4740: Use HIGHEST_PROTOCOL in pickle test. This enables test for protocol 3
(== HIGHEST_PROTOCOL in 3.x)
................
r67933 | alexandre.vassalotti | 2008-12-27 06:43:58 +0000 (Sat, 27 Dec 2008) | 12 lines
Merged revisions 67932 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67932 | alexandre.vassalotti | 2008-12-27 01:36:10 -0500 (Sat, 27 Dec 2008) | 5 lines
Remove unnecessary casts related to unicode_decode_call_errorhandler.
Make the _PyUnicode_Resize macro a static function.
These changes are needed to avoid breaking strict aliasing rules.
........
................
r67937 | alexandre.vassalotti | 2008-12-27 07:32:41 +0000 (Sat, 27 Dec 2008) | 3 lines
Update copy of PyUnicode_EncodeRawUnicodeEscape in _pickle.
Add astral character test case.
................
r67938 | alexandre.vassalotti | 2008-12-27 09:09:15 +0000 (Sat, 27 Dec 2008) | 3 lines
Fix wrong bytes type conversion in PyUnicode_AsUnicodeEscapeString.
Fix wrong bytes type conversion in PyUnicode_AsUnicodeDecodeString.
................
r67939 | alexandre.vassalotti | 2008-12-27 09:16:49 +0000 (Sat, 27 Dec 2008) | 6 lines
Optimize built-in unicode codecs by avoiding unnecessary copying.
The approach used is similiar to what is currently used in the version
of unicodeobject.c in Python 2.x. The only difference is we use
_PyBytes_Resize instead of _PyString_Resize.
................
r67940 | alexandre.vassalotti | 2008-12-27 09:30:39 +0000 (Sat, 27 Dec 2008) | 4 lines
Fix issue #4374: Pickle tests fail w/o _pickle extension.
Add an initialization check to mimic the interface of _pickle.
................
r67941 | alexandre.vassalotti | 2008-12-27 09:49:09 +0000 (Sat, 27 Dec 2008) | 2 lines
Fix bogus assertion.
................
r67942 | alexandre.vassalotti | 2008-12-27 09:59:15 +0000 (Sat, 27 Dec 2008) | 14 lines
Blocked revisions 67934-67935 via svnmerge
........
r67934 | alexandre.vassalotti | 2008-12-27 02:08:47 -0500 (Sat, 27 Dec 2008) | 4 lines
Fix issue #4730: cPickle corrupts high-unicode strings.
Update outdated copy of PyUnicode_EncodeRawUnicodeEscape.
Add a test case.
........
r67935 | alexandre.vassalotti | 2008-12-27 02:13:01 -0500 (Sat, 27 Dec 2008) | 2 lines
Add Misc/NEWS entry for r67934.
........
................
r67945 | hirokazu.yamamoto | 2008-12-27 14:58:17 +0000 (Sat, 27 Dec 2008) | 1 line
Fixed incompatible pointer warning.
................
r67947 | antoine.pitrou | 2008-12-27 15:50:40 +0000 (Sat, 27 Dec 2008) | 10 lines
Merged revisions 67946 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67946 | antoine.pitrou | 2008-12-27 16:43:12 +0100 (sam., 27 déc. 2008) | 4 lines
Issue #4756: zipfile.is_zipfile() now supports file-like objects.
Patch by Gabriel Genellina.
........
................
r67948 | benjamin.peterson | 2008-12-27 16:00:54 +0000 (Sat, 27 Dec 2008) | 93 lines
Merged revisions 67889-67892,67895,67898,67904-67907,67912,67918,67920-67921,67923-67924,67926-67927,67930,67943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r67889 | benjamin.peterson | 2008-12-20 19:04:32 -0600 (Sat, 20 Dec 2008) | 1 line
sphinx.web is long gone
................
r67890 | benjamin.peterson | 2008-12-20 19:12:26 -0600 (Sat, 20 Dec 2008) | 1 line
update readme
................
r67891 | benjamin.peterson | 2008-12-20 19:14:47 -0600 (Sat, 20 Dec 2008) | 1 line
there are way too many places which need to have the current version added
................
r67892 | benjamin.peterson | 2008-12-20 19:29:32 -0600 (Sat, 20 Dec 2008) | 9 lines
Merged revisions 67809 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r67809 | benjamin.peterson | 2008-12-15 21:54:45 -0600 (Mon, 15 Dec 2008) | 1 line
fix logic error
........
................
r67895 | neal.norwitz | 2008-12-21 08:28:32 -0600 (Sun, 21 Dec 2008) | 2 lines
Add Tarek for work on distutils.
................
r67898 | benjamin.peterson | 2008-12-21 15:00:53 -0600 (Sun, 21 Dec 2008) | 1 line
compute DISTVERSION with patchlevel.py
................
r67904 | benjamin.peterson | 2008-12-22 14:44:58 -0600 (Mon, 22 Dec 2008) | 1 line
less attitude
................
r67905 | benjamin.peterson | 2008-12-22 14:51:15 -0600 (Mon, 22 Dec 2008) | 1 line
fix #4720: the format to PyArg_ParseTupleAndKeywords can now start with '|'
................
r67906 | benjamin.peterson | 2008-12-22 14:52:53 -0600 (Mon, 22 Dec 2008) | 1 line
add NEWS note
................
r67907 | benjamin.peterson | 2008-12-22 16:12:19 -0600 (Mon, 22 Dec 2008) | 1 line
silence compiler warning
................
r67912 | georg.brandl | 2008-12-23 06:37:21 -0600 (Tue, 23 Dec 2008) | 2 lines
Fix missing "svn" command.
................
r67918 | georg.brandl | 2008-12-23 09:44:25 -0600 (Tue, 23 Dec 2008) | 2 lines
Markup fix.
................
r67920 | benjamin.peterson | 2008-12-23 14:09:28 -0600 (Tue, 23 Dec 2008) | 1 line
use a global variable, so the compiler doesn't optimize the assignment out
................
r67921 | benjamin.peterson | 2008-12-23 14:12:33 -0600 (Tue, 23 Dec 2008) | 1 line
make global static
................
r67923 | benjamin.peterson | 2008-12-24 09:10:27 -0600 (Wed, 24 Dec 2008) | 1 line
#4736 BufferRWPair.closed shouldn't try to call another property as a function
................
r67924 | benjamin.peterson | 2008-12-24 10:10:05 -0600 (Wed, 24 Dec 2008) | 1 line
pretend exceptions don't exist a while longer
................
r67926 | tarek.ziade | 2008-12-24 13:10:05 -0600 (Wed, 24 Dec 2008) | 1 line
fixed #4400 : distutils .pypirc default generated file was broken.
................
r67927 | benjamin.peterson | 2008-12-26 17:26:30 -0600 (Fri, 26 Dec 2008) | 1 line
python version is included in file name now
................
r67930 | hirokazu.yamamoto | 2008-12-26 22:19:48 -0600 (Fri, 26 Dec 2008) | 2 lines
Issue #4740: Use HIGHEST_PROTOCOL in pickle test.
(There is no behavior difference in 2.x because HIGHEST_PROTOCOL == 2)
................
r67943 | alexandre.vassalotti | 2008-12-27 04:02:59 -0600 (Sat, 27 Dec 2008) | 2 lines
Fix bogus unicode tests in pickletester.
................
................
r67949 | benjamin.peterson | 2008-12-27 16:58:50 +0000 (Sat, 27 Dec 2008) | 1 line
fix syntax
................
r67950 | benjamin.peterson | 2008-12-27 17:00:44 +0000 (Sat, 27 Dec 2008) | 1 line
fix 2.x isms in distutils test
................
r67956 | benjamin.peterson | 2008-12-27 18:35:25 +0000 (Sat, 27 Dec 2008) | 1 line
fix svnmerge properties
................
r67959 | benjamin.peterson | 2008-12-27 19:03:36 +0000 (Sat, 27 Dec 2008) | 9 lines
Merged revisions 67954 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67954 | benjamin.peterson | 2008-12-27 12:24:11 -0600 (Sat, 27 Dec 2008) | 1 line
#4748 lambda generators shouldn't return values
........
................
r67962 | georg.brandl | 2008-12-27 19:08:11 +0000 (Sat, 27 Dec 2008) | 2 lines
#4697: clarify that the functions are Unix-only.
................
r67964 | alexandre.vassalotti | 2008-12-27 19:46:35 +0000 (Sat, 27 Dec 2008) | 2 lines
Revert unwanted function name change introduced by r67939.
................
r67966 | antoine.pitrou | 2008-12-27 20:39:28 +0000 (Sat, 27 Dec 2008) | 9 lines
Merged revisions 67965 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67965 | antoine.pitrou | 2008-12-27 21:34:52 +0100 (sam., 27 déc. 2008) | 3 lines
Issue #4677: add two list comprehension tests to pybench.
........
................
r67968 | georg.brandl | 2008-12-27 23:12:09 +0000 (Sat, 27 Dec 2008) | 2 lines
Remove confusing error message in bytes.translate.
................
r67969 | georg.brandl | 2008-12-27 23:33:20 +0000 (Sat, 27 Dec 2008) | 5 lines
Document bytes.translate().
BTW, having str.maketrans() as a static method and
string.maketrans() as a function that creates translation tables for bytes objects is not very consistent :)
................
r67972 | alexandre.vassalotti | 2008-12-28 02:13:22 +0000 (Sun, 28 Dec 2008) | 13 lines
Merged revisions 67970-67971 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67970 | alexandre.vassalotti | 2008-12-27 20:52:58 -0500 (Sat, 27 Dec 2008) | 2 lines
Fix name mangling of PyUnicode_ClearFreeList.
........
r67971 | alexandre.vassalotti | 2008-12-27 21:10:35 -0500 (Sat, 27 Dec 2008) | 2 lines
Sort UCS-2/UCS-4 name mangling list.
........
................
r67974 | georg.brandl | 2008-12-28 11:44:14 +0000 (Sun, 28 Dec 2008) | 4 lines
#4759: allow None as first argument of bytearray.translate(), for consistency with bytes.translate().
Also fix segfault for bytearray.translate(x, None) -- will backport this part to 3.0 and 2.6.
................
r67981 | antoine.pitrou | 2008-12-28 14:29:00 +0000 (Sun, 28 Dec 2008) | 9 lines
Merged revisions 67979 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67979 | antoine.pitrou | 2008-12-28 15:09:36 +0100 (dim., 28 déc. 2008) | 3 lines
Issue #4444: Allow assertRaises() to be used as a context handler.
........
................
r67983 | benjamin.peterson | 2008-12-28 15:44:55 +0000 (Sun, 28 Dec 2008) | 12 lines
Blocked revisions 67976 via svnmerge
........
r67976 | georg.brandl | 2008-12-28 05:54:53 -0600 (Sun, 28 Dec 2008) | 7 lines
Backport r67974:
#4759: allow None as first argument of bytearray.translate(), for consistency with bytes.translate().
Also fix segfault for bytearray.translate(x, None) -- will backport this part to 3.0 and 2.6.
........
................
r68008 | martin.v.loewis | 2008-12-29 16:03:04 +0000 (Mon, 29 Dec 2008) | 9 lines
Merged revisions 68006 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68006 | martin.v.loewis | 2008-12-29 16:51:01 +0100 (Mo, 29 Dez 2008) | 2 lines
Issue #3248: Allow placing ScrolledText in a PanedWindow.
........
................
r68012 | martin.v.loewis | 2008-12-29 16:27:13 +0000 (Mon, 29 Dec 2008) | 9 lines
Merged revisions 68010 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68010 | martin.v.loewis | 2008-12-29 17:22:25 +0100 (Mo, 29 Dez 2008) | 2 lines
Issue #3767: Convert Tk object to string in tkColorChooser.
........
................
r68015 | benjamin.peterson | 2008-12-29 17:50:07 +0000 (Mon, 29 Dec 2008) | 8 lines
Blocked revisions 68014 via svnmerge
........
r68014 | benjamin.peterson | 2008-12-29 11:47:42 -0600 (Mon, 29 Dec 2008) | 1 line
#4764 set IOError.filename when trying to open a directory on POSIX platforms
........
................
r68017 | benjamin.peterson | 2008-12-29 18:02:28 +0000 (Mon, 29 Dec 2008) | 9 lines
Merged revisions 68016 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68016 | benjamin.peterson | 2008-12-29 11:56:58 -0600 (Mon, 29 Dec 2008) | 1 line
#4764 in io.open, set IOError.filename when trying to open a directory on POSIX platforms
........
................
r68020 | martin.v.loewis | 2008-12-29 18:21:47 +0000 (Mon, 29 Dec 2008) | 9 lines
Merged revisions 68018 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68018 | martin.v.loewis | 2008-12-29 19:17:34 +0100 (Mo, 29 Dez 2008) | 2 lines
Issue #1040026: Fix os.times result on systems where HZ is incorrect.
........
................
r68022 | martin.v.loewis | 2008-12-29 18:43:40 +0000 (Mon, 29 Dec 2008) | 5 lines
Issue #4323: Always encode source as UTF-8 without asking
the user (unless a different encoding is declared); remove
user configuration of source encoding; all according to
PEP 3120.
................
r68027 | benjamin.peterson | 2008-12-29 20:52:09 +0000 (Mon, 29 Dec 2008) | 1 line
hexdigest() doesn't return bytes #4771
................
r68036 | tarek.ziade | 2008-12-29 22:38:38 +0000 (Mon, 29 Dec 2008) | 9 lines
Merged revisions 68033 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68033 | tarek.ziade | 2008-12-29 23:23:53 +0100 (Mon, 29 Dec 2008) | 1 line
fixed #4646 : distutils was choking on empty options arg in the setup function.
........
................
r68058 | nick.coghlan | 2008-12-30 07:29:12 +0000 (Tue, 30 Dec 2008) | 9 lines
Recorded merge of revisions 68051 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68051 | nick.coghlan | 2008-12-30 11:18:48 +1000 (Tue, 30 Dec 2008) | 1 line
Issue #4701: implicitly call PyType_Ready from PyObject_Hash
........
................
r68059 | vinay.sajip | 2008-12-30 07:32:59 +0000 (Tue, 30 Dec 2008) | 1 line
Minor documentation change relating to NullHandler.
................
r68062 | ronald.oussoren | 2008-12-30 12:59:02 +0000 (Tue, 30 Dec 2008) | 12 lines
Make it possible to install a framework build of Python 3.x on OSX.
This the build machinery on OSX to re-enable building (and installing)
PythonLauncher.app and IDLE.app.
This needs ports of fixes to Lib/distutils/util.py and Include/pymacconfig.h
to be fully functiontional, to be fully functional.
I also have a patch for Makefile.pre.in that I'll post on bugs.python.org
for review.
................
r68064 | ronald.oussoren | 2008-12-30 14:16:51 +0000 (Tue, 30 Dec 2008) | 11 lines
Py3k: update OSX installer-generator
This update makes sure that the installer won't write files
in /usr/local/bin by default. The installer also won't
replace /Library/Frameworks/Python.framework/Version/Current.
Both to ensure that the installer doens't break an existing
install of python 2.x.
................
r68074 | benjamin.peterson | 2008-12-30 17:56:45 +0000 (Tue, 30 Dec 2008) | 18 lines
Merged revisions 67982,67988,67990 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67982 | benjamin.peterson | 2008-12-28 09:37:31 -0600 (Sun, 28 Dec 2008) | 1 line
fix WORD_BIGEDIAN declaration in Universal builds; fixes #4060 and #4728
........
r67988 | ronald.oussoren | 2008-12-28 13:40:56 -0600 (Sun, 28 Dec 2008) | 1 line
Issue4064: architecture string for universal builds on OSX
........
r67990 | ronald.oussoren | 2008-12-28 13:50:40 -0600 (Sun, 28 Dec 2008) | 3 lines
Update the fix for issue4064 to deal correctly with all three variants of
universal builds that are presented by the configure script.
........
................
r68075 | benjamin.peterson | 2008-12-30 18:05:46 +0000 (Tue, 30 Dec 2008) | 2 lines
use $(RUNSHARED) to run plat-mac/regen
................
r68083 | tarek.ziade | 2008-12-30 23:09:20 +0000 (Tue, 30 Dec 2008) | 9 lines
Merged revisions 68081 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68081 | tarek.ziade | 2008-12-31 00:03:41 +0100 (Wed, 31 Dec 2008) | 1 line
Fixed #4702: Throwing DistutilsPlatformError instead of IOError under win32 if MSVC is not found
........
................
r68090 | benjamin.peterson | 2008-12-31 03:41:35 +0000 (Wed, 31 Dec 2008) | 8 lines
Blocked revisions 68089 via svnmerge
........
r68089 | benjamin.peterson | 2008-12-30 21:37:51 -0600 (Tue, 30 Dec 2008) | 1 line
#4788 qualify some bare except clauses
........
................
r68091 | benjamin.peterson | 2008-12-31 03:43:28 +0000 (Wed, 31 Dec 2008) | 1 line
#4788 qualify remove a bare except
................
r68093 | benjamin.peterson | 2008-12-31 04:10:35 +0000 (Wed, 31 Dec 2008) | 1 line
fix name usage
................
r68094 | benjamin.peterson | 2008-12-31 04:13:40 +0000 (Wed, 31 Dec 2008) | 8 lines
Blocked revisions 68092 via svnmerge
........
r68092 | benjamin.peterson | 2008-12-30 22:08:55 -0600 (Tue, 30 Dec 2008) | 1 line
fix name collision issues
........
................
r68101 | hirokazu.yamamoto | 2008-12-31 06:05:46 +0000 (Wed, 31 Dec 2008) | 13 lines
Merged revisions 68097,68099 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68097 | hirokazu.yamamoto | 2008-12-31 14:24:37 +0900 | 1 line
Fixed compile error on windows.
........
r68099 | hirokazu.yamamoto | 2008-12-31 14:47:19 +0900 | 1 line
Just inserted blank line.
........
................
r68103 | benjamin.peterson | 2008-12-31 14:51:07 +0000 (Wed, 31 Dec 2008) | 1 line
#4406 Directory has to inherit from commondialog.Dialog
................
r68113 | benjamin.peterson | 2009-01-01 00:23:30 +0000 (Thu, 01 Jan 2009) | 53 lines
Merged revisions 67952,67957-67958,67960-67961,67963,67973,67978,67995,68030,68057,68061 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67952 | georg.brandl | 2008-12-27 11:42:40 -0600 (Sat, 27 Dec 2008) | 2 lines
#4752: actually use custom handler in example.
........
r67957 | georg.brandl | 2008-12-27 12:49:19 -0600 (Sat, 27 Dec 2008) | 2 lines
#4754: improve winsound documentation.
........
r67958 | georg.brandl | 2008-12-27 13:02:59 -0600 (Sat, 27 Dec 2008) | 2 lines
#4682: 'b' is actually unsigned char.
........
r67960 | georg.brandl | 2008-12-27 13:04:44 -0600 (Sat, 27 Dec 2008) | 2 lines
#4695: fix backslashery.
........
r67961 | georg.brandl | 2008-12-27 13:06:04 -0600 (Sat, 27 Dec 2008) | 2 lines
Use :samp: role.
........
r67963 | georg.brandl | 2008-12-27 13:11:15 -0600 (Sat, 27 Dec 2008) | 2 lines
#4671: document that pydoc imports modules.
........
r67973 | alexandre.vassalotti | 2008-12-27 20:58:22 -0600 (Sat, 27 Dec 2008) | 2 lines
Document Py_VaBuildValue.
........
r67978 | georg.brandl | 2008-12-28 05:58:49 -0600 (Sun, 28 Dec 2008) | 2 lines
#4731: clarify message about missing module prerequisites.
........
r67995 | benjamin.peterson | 2008-12-28 15:16:07 -0600 (Sun, 28 Dec 2008) | 1 line
#4763 PyErr_ExceptionMatches won't blow up with NULL arguments
........
r68030 | benjamin.peterson | 2008-12-29 15:38:14 -0600 (Mon, 29 Dec 2008) | 1 line
fix French
........
r68057 | vinay.sajip | 2008-12-30 01:01:25 -0600 (Tue, 30 Dec 2008) | 1 line
Minor documentation change relating to NullHandler.
........
r68061 | georg.brandl | 2008-12-30 04:15:49 -0600 (Tue, 30 Dec 2008) | 2 lines
#4778: attributes can't be called.
........
................
r68129 | benjamin.peterson | 2009-01-01 15:05:06 +0000 (Thu, 01 Jan 2009) | 46 lines
Merged revisions 68116-68119,68121,68123-68127 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68116 | georg.brandl | 2009-01-01 05:46:51 -0600 (Thu, 01 Jan 2009) | 2 lines
#4100: note that element children are not necessarily present on "start" events.
........
r68117 | georg.brandl | 2009-01-01 05:53:55 -0600 (Thu, 01 Jan 2009) | 2 lines
#4156: make clear that "protocol" is to be replaced with the protocol name.
........
r68118 | georg.brandl | 2009-01-01 06:00:19 -0600 (Thu, 01 Jan 2009) | 2 lines
#4185: clarify escape behavior of replacement strings.
........
r68119 | georg.brandl | 2009-01-01 06:09:40 -0600 (Thu, 01 Jan 2009) | 3 lines
#4222: document dis.findlabels() and dis.findlinestarts() and
put them into dis.__all__.
........
r68121 | georg.brandl | 2009-01-01 06:43:33 -0600 (Thu, 01 Jan 2009) | 2 lines
Point to types module in new module deprecation notice.
........
r68123 | georg.brandl | 2009-01-01 06:52:29 -0600 (Thu, 01 Jan 2009) | 2 lines
#4784: ... on three counts ...
........
r68124 | georg.brandl | 2009-01-01 06:53:19 -0600 (Thu, 01 Jan 2009) | 2 lines
#4782: Fix markup error that hid load() and loads().
........
r68125 | georg.brandl | 2009-01-01 07:02:09 -0600 (Thu, 01 Jan 2009) | 2 lines
#4776: add data_files and package_dir arguments.
........
r68126 | georg.brandl | 2009-01-01 07:05:13 -0600 (Thu, 01 Jan 2009) | 2 lines
Handlers are in the `logging.handlers` module.
........
r68127 | georg.brandl | 2009-01-01 07:14:49 -0600 (Thu, 01 Jan 2009) | 2 lines
#4767: Use correct submodules for all MIME classes.
........
................
r68132 | antoine.pitrou | 2009-01-01 15:35:33 +0000 (Thu, 01 Jan 2009) | 9 lines
Merged revisions 68128 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68128 | antoine.pitrou | 2009-01-01 15:11:22 +0100 (jeu., 01 janv. 2009) | 3 lines
Issue #3680: Reference cycles created through a dict, set or deque iterator did not get collected.
........
................
r68136 | georg.brandl | 2009-01-01 15:49:47 +0000 (Thu, 01 Jan 2009) | 12 lines
Blocked revisions 67967,67980 via svnmerge
........
r67967 | benjamin.peterson | 2008-12-27 23:18:58 +0100 (Sat, 27 Dec 2008) | 1 line
fix markup
........
r67980 | antoine.pitrou | 2008-12-28 15:24:29 +0100 (Sun, 28 Dec 2008) | 1 line
wrong version number in doc changes committed in r67979
........
................
r68137 | georg.brandl | 2009-01-01 15:53:14 +0000 (Thu, 01 Jan 2009) | 10 lines
Merged revisions 67953 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r67953 | georg.brandl | 2008-12-27 19:20:04 +0100 (Sat, 27 Dec 2008) | 3 lines
Patch #4739 by David Laban: add symbols to pydoc help topics,
so that ``help('@')`` works as expected.
........
................
r68138 | georg.brandl | 2009-01-01 15:55:56 +0000 (Thu, 01 Jan 2009) | 9 lines
Blocked revisions 67955 via svnmerge
........
r67955 | georg.brandl | 2008-12-27 19:27:53 +0100 (Sat, 27 Dec 2008) | 3 lines
Follow-up to r67746 in order to restore backwards-compatibility for
those who (monkey-)patch TextWrapper.wordsep_re with a custom RE.
........
................
r68139 | hirokazu.yamamoto | 2009-01-01 16:03:45 +0000 (Thu, 01 Jan 2009) | 10 lines
Merged revisions 68134 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r68134 | hirokazu.yamamoto | 2009-01-02 00:45:39 +0900 | 2 lines
Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
file with `str' filename on Windows.
........
................
r68140 | hirokazu.yamamoto | 2009-01-01 16:09:52 +0000 (Thu, 01 Jan 2009) | 1 line
News fix. On py3k, `str' is unicode. should use `bytes'.
................
r68143 | amaury.forgeotdarc | 2009-01-01 23:05:36 +0000 (Thu, 01 Jan 2009) | 7 lines
#4747: on Windows, starting a module with a non-ascii filename would print a useless "SyntaxError: None"
when the script contains a "# coding:" declaration.
The Python API expects char* to be utf-8 encoded. wcstombs should be avoided here.
Reviewed by Benjamin. Will backport to 3.0
................
r68152 | ronald.oussoren | 2009-01-02 11:48:29 +0000 (Fri, 02 Jan 2009) | 2 lines
Fix for issue 3433
................
Added:
python/branches/py3k-issue1717/Lib/distutils/tests/test_msvc9compiler.py
- copied unchanged from r68152, /python/branches/py3k/Lib/distutils/tests/test_msvc9compiler.py
python/branches/py3k-issue1717/Lib/distutils/tests/test_register.py
- copied unchanged from r68152, /python/branches/py3k/Lib/distutils/tests/test_register.py
python/branches/py3k-issue1717/Mac/Tools/bundlebuilder.py
- copied unchanged from r68152, /python/branches/py3k/Mac/Tools/bundlebuilder.py
Removed:
python/branches/py3k-issue1717/Doc/tools/sphinx-web.py
Modified:
python/branches/py3k-issue1717/ (props changed)
python/branches/py3k-issue1717/Doc/Makefile
python/branches/py3k-issue1717/Doc/README.txt
python/branches/py3k-issue1717/Doc/c-api/arg.rst
python/branches/py3k-issue1717/Doc/c-api/exceptions.rst
python/branches/py3k-issue1717/Doc/distutils/apiref.rst
python/branches/py3k-issue1717/Doc/distutils/setupscript.rst
python/branches/py3k-issue1717/Doc/extending/extending.rst
python/branches/py3k-issue1717/Doc/howto/functional.rst
python/branches/py3k-issue1717/Doc/howto/unicode.rst
python/branches/py3k-issue1717/Doc/includes/noddy.c
python/branches/py3k-issue1717/Doc/includes/noddy2.c
python/branches/py3k-issue1717/Doc/includes/noddy3.c
python/branches/py3k-issue1717/Doc/includes/noddy4.c
python/branches/py3k-issue1717/Doc/library/dis.rst
python/branches/py3k-issue1717/Doc/library/email.mime.rst
python/branches/py3k-issue1717/Doc/library/functions.rst
python/branches/py3k-issue1717/Doc/library/hashlib.rst
python/branches/py3k-issue1717/Doc/library/json.rst
python/branches/py3k-issue1717/Doc/library/logging.rst
python/branches/py3k-issue1717/Doc/library/math.rst
python/branches/py3k-issue1717/Doc/library/multiprocessing.rst
python/branches/py3k-issue1717/Doc/library/optparse.rst
python/branches/py3k-issue1717/Doc/library/pydoc.rst
python/branches/py3k-issue1717/Doc/library/shutil.rst
python/branches/py3k-issue1717/Doc/library/signal.rst
python/branches/py3k-issue1717/Doc/library/stdtypes.rst
python/branches/py3k-issue1717/Doc/library/subprocess.rst
python/branches/py3k-issue1717/Doc/library/unittest.rst
python/branches/py3k-issue1717/Doc/library/webbrowser.rst
python/branches/py3k-issue1717/Doc/library/winsound.rst
python/branches/py3k-issue1717/Doc/library/xml.etree.elementtree.rst
python/branches/py3k-issue1717/Doc/library/zipfile.rst
python/branches/py3k-issue1717/Doc/license.rst
python/branches/py3k-issue1717/Doc/tools/sphinxext/download.html
python/branches/py3k-issue1717/Doc/tools/sphinxext/pyspecific.py
python/branches/py3k-issue1717/Doc/tutorial/controlflow.rst
python/branches/py3k-issue1717/Doc/using/unix.rst
python/branches/py3k-issue1717/Doc/whatsnew/2.6.rst
python/branches/py3k-issue1717/Include/pymacconfig.h
python/branches/py3k-issue1717/Include/unicodeobject.h
python/branches/py3k-issue1717/LICENSE
python/branches/py3k-issue1717/Lib/dis.py
python/branches/py3k-issue1717/Lib/distutils/ccompiler.py
python/branches/py3k-issue1717/Lib/distutils/command/register.py
python/branches/py3k-issue1717/Lib/distutils/config.py
python/branches/py3k-issue1717/Lib/distutils/dist.py
python/branches/py3k-issue1717/Lib/distutils/msvc9compiler.py
python/branches/py3k-issue1717/Lib/distutils/tests/test_config.py
python/branches/py3k-issue1717/Lib/distutils/tests/test_dist.py
python/branches/py3k-issue1717/Lib/distutils/util.py
python/branches/py3k-issue1717/Lib/idlelib/IOBinding.py
python/branches/py3k-issue1717/Lib/idlelib/NEWS.txt
python/branches/py3k-issue1717/Lib/idlelib/configDialog.py
python/branches/py3k-issue1717/Lib/io.py
python/branches/py3k-issue1717/Lib/lib2to3/main.py
python/branches/py3k-issue1717/Lib/pickle.py
python/branches/py3k-issue1717/Lib/pydoc.py
python/branches/py3k-issue1717/Lib/re.py
python/branches/py3k-issue1717/Lib/ssl.py
python/branches/py3k-issue1717/Lib/test/pickletester.py
python/branches/py3k-issue1717/Lib/test/test_array.py
python/branches/py3k-issue1717/Lib/test/test_bytes.py
python/branches/py3k-issue1717/Lib/test/test_deque.py
python/branches/py3k-issue1717/Lib/test/test_dict.py
python/branches/py3k-issue1717/Lib/test/test_file.py
python/branches/py3k-issue1717/Lib/test/test_fileio.py
python/branches/py3k-issue1717/Lib/test/test_generators.py
python/branches/py3k-issue1717/Lib/test/test_hash.py
python/branches/py3k-issue1717/Lib/test/test_io.py
python/branches/py3k-issue1717/Lib/test/test_set.py
python/branches/py3k-issue1717/Lib/test/test_unittest.py
python/branches/py3k-issue1717/Lib/test/test_urllib2.py
python/branches/py3k-issue1717/Lib/test/test_zipfile.py
python/branches/py3k-issue1717/Lib/tkinter/colorchooser.py
python/branches/py3k-issue1717/Lib/tkinter/filedialog.py
python/branches/py3k-issue1717/Lib/tkinter/scrolledtext.py
python/branches/py3k-issue1717/Lib/unittest.py
python/branches/py3k-issue1717/Lib/zipfile.py
python/branches/py3k-issue1717/Mac/BuildScript/build-installer.py
python/branches/py3k-issue1717/Mac/BuildScript/resources/Welcome.rtf
python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/Info.plist
python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/MacOS/IDLE
python/branches/py3k-issue1717/Mac/Makefile.in
python/branches/py3k-issue1717/Mac/PythonLauncher/Info.plist.in
python/branches/py3k-issue1717/Mac/PythonLauncher/Makefile.in
python/branches/py3k-issue1717/Mac/Tools/fixapplepython23.py
python/branches/py3k-issue1717/Makefile.pre.in
python/branches/py3k-issue1717/Misc/NEWS
python/branches/py3k-issue1717/Misc/developers.txt
python/branches/py3k-issue1717/Modules/_collectionsmodule.c
python/branches/py3k-issue1717/Modules/_fileio.c
python/branches/py3k-issue1717/Modules/_pickle.c
python/branches/py3k-issue1717/Modules/_testcapimodule.c
python/branches/py3k-issue1717/Modules/main.c
python/branches/py3k-issue1717/Modules/mathmodule.c
python/branches/py3k-issue1717/Modules/posixmodule.c
python/branches/py3k-issue1717/Objects/bytearrayobject.c
python/branches/py3k-issue1717/Objects/bytesobject.c
python/branches/py3k-issue1717/Objects/dictobject.c
python/branches/py3k-issue1717/Objects/object.c
python/branches/py3k-issue1717/Objects/setobject.c
python/branches/py3k-issue1717/Objects/unicodeobject.c
python/branches/py3k-issue1717/Python/compile.c
python/branches/py3k-issue1717/Python/getargs.c
python/branches/py3k-issue1717/Tools/pybench/Lists.py
python/branches/py3k-issue1717/setup.py
Modified: python/branches/py3k-issue1717/Doc/Makefile
==============================================================================
--- python/branches/py3k-issue1717/Doc/Makefile (original)
+++ python/branches/py3k-issue1717/Doc/Makefile Fri Jan 2 15:30:39 2009
@@ -9,7 +9,7 @@
SPHINXOPTS =
PAPER =
SOURCES =
-DISTVERSION =
+DISTVERSION = $(shell $(PYTHON) tools/sphinxext/patchlevel.py)
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
$(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
@@ -111,33 +111,33 @@
# archive the HTML
make html
- cp -pPR build/html dist/python$(DISTVERSION)-docs-html
- tar -C dist -cf dist/python$(DISTVERSION)-docs-html.tar python$(DISTVERSION)-docs-html
- bzip2 -9 -k dist/python$(DISTVERSION)-docs-html.tar
- (cd dist; zip -q -r -9 python$(DISTVERSION)-docs-html.zip python$(DISTVERSION)-docs-html)
- rm -r dist/python$(DISTVERSION)-docs-html
- rm dist/python$(DISTVERSION)-docs-html.tar
+ cp -pPR build/html dist/python-$(DISTVERSION)-docs-html
+ tar -C dist -cf dist/python-$(DISTVERSION)-docs-html.tar python-$(DISTVERSION)-docs-html
+ bzip2 -9 -k dist/python-$(DISTVERSION)-docs-html.tar
+ (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-html.zip python-$(DISTVERSION)-docs-html)
+ rm -r dist/python-$(DISTVERSION)-docs-html
+ rm dist/python-$(DISTVERSION)-docs-html.tar
# archive the text build
make text
- cp -pPR build/text dist/python$(DISTVERSION)-docs-text
- tar -C dist -cf dist/python$(DISTVERSION)-docs-text.tar python$(DISTVERSION)-docs-text
- bzip2 -9 -k dist/python$(DISTVERSION)-docs-text.tar
- (cd dist; zip -q -r -9 python$(DISTVERSION)-docs-text.zip python$(DISTVERSION)-docs-text)
- rm -r dist/python$(DISTVERSION)-docs-text
- rm dist/python$(DISTVERSION)-docs-text.tar
+ cp -pPR build/text dist/python-$(DISTVERSION)-docs-text
+ tar -C dist -cf dist/python-$(DISTVERSION)-docs-text.tar python-$(DISTVERSION)-docs-text
+ bzip2 -9 -k dist/python-$(DISTVERSION)-docs-text.tar
+ (cd dist; zip -q -r -9 python-$(DISTVERSION)-docs-text.zip python-$(DISTVERSION)-docs-text)
+ rm -r dist/python-$(DISTVERSION)-docs-text
+ rm dist/python-$(DISTVERSION)-docs-text.tar
# archive the A4 latex
-rm -r build/latex
make latex PAPER=a4
(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
- cp build/latex/docs-pdf.zip dist/python$(DISTVERSION)-docs-pdf-a4.zip
- cp build/latex/docs-pdf.tar.bz2 dist/python$(DISTVERSION)-docs-pdf-a4.tar.bz2
+ cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-a4.zip
+ cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-a4.tar.bz2
# archive the letter latex
rm -r build/latex
make latex PAPER=letter
(cd build/latex; make clean && make all-pdf && make FMT=pdf zip bz2)
- cp build/latex/docs-pdf.zip dist/python$(DISTVERSION)-docs-pdf-letter.zip
- cp build/latex/docs-pdf.tar.bz2 dist/python$(DISTVERSION)-docs-pdf-letter.tar.bz2
+ cp build/latex/docs-pdf.zip dist/python-$(DISTVERSION)-docs-pdf-letter.zip
+ cp build/latex/docs-pdf.tar.bz2 dist/python-$(DISTVERSION)-docs-pdf-letter.tar.bz2
Modified: python/branches/py3k-issue1717/Doc/README.txt
==============================================================================
--- python/branches/py3k-issue1717/Doc/README.txt (original)
+++ python/branches/py3k-issue1717/Doc/README.txt Fri Jan 2 15:30:39 2009
@@ -81,8 +81,7 @@
svn co http://svn.python.org/projects/doctools/trunk/sphinx tools/sphinx
-Then, you need to install Docutils 0.4 (the SVN snapshot won't work), either
-by checking it out via ::
+Then, you need to install Docutils, either by checking it out via ::
svn co http://svn.python.org/projects/external/docutils-0.4/docutils tools/docutils
@@ -99,19 +98,18 @@
python tools/sphinx-build.py -b<builder> . build/<outputdirectory>
-where `<builder>` is one of html, web or htmlhelp (for explanations see the make
-targets above).
+where `<builder>` is one of html, text, latex, or htmlhelp (for explanations see
+the make targets above).
Contributing
============
-For bugs in the content, the online version at http://docs.python.org/ has a
-"suggest change" facility that can be used to correct errors in the source text
-and submit them as a patch to the maintainers.
+Bugs in the content should be reported to the Python bug tracker at
+http://bugs.python.org.
-Bugs in the toolset should be reported in the Python bug tracker at
-http://bugs.python.org/.
+Bugs in the toolset should be reported in the Sphinx bug tracker at
+http://www.bitbucket.org/birkenfeld/sphinx/issues/.
You can also send a mail to the Python Documentation Team at docs at python.org,
and we will process your request as soon as possible.
Modified: python/branches/py3k-issue1717/Doc/c-api/arg.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/c-api/arg.rst (original)
+++ python/branches/py3k-issue1717/Doc/c-api/arg.rst Fri Jan 2 15:30:39 2009
@@ -164,8 +164,9 @@
them. Instead, the implementation assumes that the string object uses the
encoding passed in as parameter.
-``b`` (integer) [char]
- Convert a Python integer to a tiny int, stored in a C :ctype:`char`.
+``b`` (integer) [unsigned char]
+ Convert a nonnegative Python integer to an unsigned tiny int, stored in a C
+ :ctype:`unsigned char`.
``B`` (integer) [unsigned char]
Convert a Python integer to a tiny int without overflow checking, stored in a C
@@ -305,8 +306,8 @@
``;``
The list of format units ends here; the string after the semicolon is used as
- the error message *instead* of the default error message. Clearly, ``:`` and
- ``;`` mutually exclude each other.
+ the error message *instead* of the default error message. ``:`` and ``;``
+ mutually exclude each other.
Note that any Python object references which are provided to the caller are
*borrowed* references; do not decrement their reference count!
@@ -552,3 +553,8 @@
If there is an error in the format string, the :exc:`SystemError` exception is
set and *NULL* returned.
+
+.. cfunction:: PyObject* Py_VaBuildValue(const char *format, va_list vargs)
+
+ Identical to :cfunc:`Py_BuildValue`, except that it accepts a va_list
+ rather than a variable number of arguments.
Modified: python/branches/py3k-issue1717/Doc/c-api/exceptions.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/c-api/exceptions.rst (original)
+++ python/branches/py3k-issue1717/Doc/c-api/exceptions.rst Fri Jan 2 15:30:39 2009
@@ -67,11 +67,10 @@
.. cfunction:: int PyErr_GivenExceptionMatches(PyObject *given, PyObject *exc)
- Return true if the *given* exception matches the exception in *exc*. If *exc*
- is a class object, this also returns true when *given* is an instance of a
- subclass. If *exc* is a tuple, all exceptions in the tuple (and recursively in
- subtuples) are searched for a match. If *given* is *NULL*, a memory access
- violation will occur.
+ Return true if the *given* exception matches the exception in *exc*. If
+ *exc* is a class object, this also returns true when *given* is an instance
+ of a subclass. If *exc* is a tuple, all exceptions in the tuple (and
+ recursively in subtuples) are searched for a match.
.. cfunction:: void PyErr_NormalizeException(PyObject**exc, PyObject**val, PyObject**tb)
Modified: python/branches/py3k-issue1717/Doc/distutils/apiref.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/distutils/apiref.rst (original)
+++ python/branches/py3k-issue1717/Doc/distutils/apiref.rst Fri Jan 2 15:30:39 2009
@@ -88,9 +88,9 @@
| *options* | default options for the setup | a string |
| | script | |
+--------------------+--------------------------------+-------------------------------------------------------------+
- | *license* | The license for the package | |
+ | *license* | The license for the package | a string |
+--------------------+--------------------------------+-------------------------------------------------------------+
- | *keywords* | Descriptive meta-data. See | |
+ | *keywords* | Descriptive meta-data, see | |
| | :pep:`314` | |
+--------------------+--------------------------------+-------------------------------------------------------------+
| *platforms* | | |
@@ -98,6 +98,13 @@
| *cmdclass* | A mapping of command names to | a dictionary |
| | :class:`Command` subclasses | |
+--------------------+--------------------------------+-------------------------------------------------------------+
+ | *data_files* | A list of data files to | a list |
+ | | install | |
+ +--------------------+--------------------------------+-------------------------------------------------------------+
+ | *package_dir* | A mapping of package to | a dictionary |
+ | | directory names | |
+ +--------------------+--------------------------------+-------------------------------------------------------------+
+
.. function:: run_setup(script_name[, script_args=None, stop_after='run'])
@@ -1100,6 +1107,24 @@
For non-POSIX platforms, currently just returns ``sys.platform``.
+ For MacOS X systems the OS version reflects the minimal version on which
+ binaries will run (that is, the value of ``MACOSX_DEPLOYMENT_TARGET``
+ during the build of Python), not the OS version of the current system.
+
+ For universal binary builds on MacOS X the architecture value reflects
+ the univeral binary status instead of the architecture of the current
+ processor. For 32-bit universal binaries the architecture is ``fat``,
+ for 64-bit universal binaries the architecture is ``fat64``, and
+ for 4-way universal binaries the architecture is ``universal``.
+
+ Examples of returned values on MacOS X:
+
+ * ``macosx-10.3-ppc``
+
+ * ``macosx-10.3-fat``
+
+ * ``macosx-10.5-universal``
+
.. % XXX isn't this also provided by some other non-distutils module?
Modified: python/branches/py3k-issue1717/Doc/distutils/setupscript.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/distutils/setupscript.rst (original)
+++ python/branches/py3k-issue1717/Doc/distutils/setupscript.rst Fri Jan 2 15:30:39 2009
@@ -561,6 +561,8 @@
+----------------------+---------------------------+-----------------+--------+
| ``classifiers`` | a list of classifiers | list of strings | \(4) |
+----------------------+---------------------------+-----------------+--------+
+| ``platforms`` | a list of platforms | list of strings | |
++----------------------+---------------------------+-----------------+--------+
Notes:
Modified: python/branches/py3k-issue1717/Doc/extending/extending.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/extending/extending.rst (original)
+++ python/branches/py3k-issue1717/Doc/extending/extending.rst Fri Jan 2 15:30:39 2009
@@ -326,8 +326,8 @@
return PyModule_Create(&spammodule);
}
-Note that PyMODINIT_FUNC declares the function as ``void`` return type,
-declares any special linkage declarations required by the platform, and for C++
+Note that PyMODINIT_FUNC declares the function as ``PyObject *`` return type,
+declares any special linkage declarations required by the platform, and for C++
declares the function as ``extern "C"``.
When the Python program imports module :mod:`spam` for the first time,
@@ -882,7 +882,7 @@
The advantage of borrowing over owning a reference is that you don't need to
take care of disposing of the reference on all possible paths through the code
--- in other words, with a borrowed reference you don't run the risk of leaking
-when a premature exit is taken. The disadvantage of borrowing over leaking is
+when a premature exit is taken. The disadvantage of borrowing over owning is
that there are some subtle situations where in seemingly correct code a borrowed
reference can be used after the owner from which it was borrowed has in fact
disposed of it.
Modified: python/branches/py3k-issue1717/Doc/howto/functional.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/howto/functional.rst (original)
+++ python/branches/py3k-issue1717/Doc/howto/functional.rst Fri Jan 2 15:30:39 2009
@@ -677,11 +677,10 @@
if line.strip() == '':
print('Blank line at line #%i' % i)
-
-``sorted(iterable, [key=None], [reverse=False)`` collects all the
-elements of the iterable into a list, sorts the list, and returns the sorted
-result. The ``key`` and ``reverse`` arguments are passed through to
-the constructed list's ``.sort()`` method. ::
+``sorted(iterable, [key=None], [reverse=False])`` collects all the elements of
+the iterable into a list, sorts the list, and returns the sorted result. The
+``key``, and ``reverse`` arguments are passed through to the constructed list's
+``.sort()`` method. ::
>>> import random
>>> # Generate 8 random numbers between [0, 10000)
Modified: python/branches/py3k-issue1717/Doc/howto/unicode.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/howto/unicode.rst (original)
+++ python/branches/py3k-issue1717/Doc/howto/unicode.rst Fri Jan 2 15:30:39 2009
@@ -32,7 +32,7 @@
looking at Apple ][ BASIC programs, published in French-language publications in
the mid-1980s, that had lines like these::
- PRINT "FICHER EST COMPLETE."
+ PRINT "FICHIER EST COMPLETE."
PRINT "CARACTERE NON ACCEPTE."
Those messages should contain accents, and they just look wrong to someone who
Modified: python/branches/py3k-issue1717/Doc/includes/noddy.c
==============================================================================
--- python/branches/py3k-issue1717/Doc/includes/noddy.c (original)
+++ python/branches/py3k-issue1717/Doc/includes/noddy.c Fri Jan 2 15:30:39 2009
@@ -52,4 +52,5 @@
Py_INCREF(&noddy_NoddyType);
PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
+ return m;
}
Modified: python/branches/py3k-issue1717/Doc/includes/noddy2.c
==============================================================================
--- python/branches/py3k-issue1717/Doc/includes/noddy2.c (original)
+++ python/branches/py3k-issue1717/Doc/includes/noddy2.c Fri Jan 2 15:30:39 2009
@@ -186,4 +186,5 @@
Py_INCREF(&NoddyType);
PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+ return m;
}
Modified: python/branches/py3k-issue1717/Doc/includes/noddy3.c
==============================================================================
--- python/branches/py3k-issue1717/Doc/includes/noddy3.c (original)
+++ python/branches/py3k-issue1717/Doc/includes/noddy3.c Fri Jan 2 15:30:39 2009
@@ -239,4 +239,5 @@
Py_INCREF(&NoddyType);
PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+ return m;
}
Modified: python/branches/py3k-issue1717/Doc/includes/noddy4.c
==============================================================================
--- python/branches/py3k-issue1717/Doc/includes/noddy4.c (original)
+++ python/branches/py3k-issue1717/Doc/includes/noddy4.c Fri Jan 2 15:30:39 2009
@@ -221,4 +221,5 @@
Py_INCREF(&NoddyType);
PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+ return m;
}
Modified: python/branches/py3k-issue1717/Doc/library/dis.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/dis.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/dis.rst Fri Jan 2 15:30:39 2009
@@ -64,10 +64,23 @@
.. function:: disco(code[, lasti])
- A synonym for disassemble. It is more convenient to type, and kept for
- compatibility with earlier Python releases.
+ A synonym for :func:`disassemble`. It is more convenient to type, and kept
+ for compatibility with earlier Python releases.
+.. function:: findlinestarts(code)
+
+ This generator function uses the ``co_firstlineno`` and ``co_lnotab``
+ attributes of the code object *code* to find the offsets which are starts of
+ lines in the source code. They are generated as ``(offset, lineno)`` pairs.
+
+
+.. function:: findlabels(code)
+
+ Detect all offsets in the code object *code* which are jump targets, and
+ return a list of these offsets.
+
+
.. data:: opname
Sequence of operation names, indexable using the bytecode.
Modified: python/branches/py3k-issue1717/Doc/library/email.mime.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/email.mime.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/email.mime.rst Fri Jan 2 15:30:39 2009
@@ -19,6 +19,7 @@
Here are the classes:
+.. currentmodule:: email.mime.base
.. class:: MIMEBase(_maintype, _subtype, **_params)
@@ -39,6 +40,8 @@
:mailheader:`MIME-Version` header (always set to ``1.0``).
+.. currentmodule:: email.mime.nonmultipart
+
.. class:: MIMENonMultipart()
Module: :mod:`email.mime.nonmultipart`
@@ -50,6 +53,8 @@
:exc:`MultipartConversionError` exception is raised.
+.. currentmodule:: email.mime.multipart
+
.. class:: MIMEMultipart([subtype[, boundary[, _subparts[, _params]]]])
Module: :mod:`email.mime.multipart`
@@ -73,6 +78,8 @@
dictionary.
+.. currentmodule:: email.mime.application
+
.. class:: MIMEApplication(_data[, _subtype[, _encoder[, **_params]]])
Module: :mod:`email.mime.application`
@@ -93,6 +100,8 @@
*_params* are passed straight through to the base class constructor.
+.. currentmodule:: email.mime.audio
+
.. class:: MIMEAudio(_audiodata[, _subtype[, _encoder[, **_params]]])
Module: :mod:`email.mime.audio`
@@ -116,6 +125,8 @@
*_params* are passed straight through to the base class constructor.
+.. currentmodule:: email.mime.image
+
.. class:: MIMEImage(_imagedata[, _subtype[, _encoder[, **_params]]])
Module: :mod:`email.mime.image`
@@ -139,6 +150,8 @@
*_params* are passed straight through to the :class:`MIMEBase` constructor.
+.. currentmodule:: email.mime.message
+
.. class:: MIMEMessage(_msg[, _subtype])
Module: :mod:`email.mime.message`
@@ -152,6 +165,8 @@
:mimetype:`rfc822`.
+.. currentmodule:: email.mime.text
+
.. class:: MIMEText(_text[, _subtype[, _charset]])
Module: :mod:`email.mime.text`
Modified: python/branches/py3k-issue1717/Doc/library/functions.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/functions.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/functions.rst Fri Jan 2 15:30:39 2009
@@ -1172,47 +1172,64 @@
This is an advanced function that is not needed in everyday Python
programming.
- The function is invoked by the :keyword:`import` statement. It mainly exists
- so that you can replace it with another function that has a compatible
- interface, in order to change the semantics of the :keyword:`import`
- statement. See the built-in module :mod:`imp`, which defines some useful
- operations out of which you can build your own :func:`__import__` function.
-
- For example, the statement ``import spam`` results in the following call:
- ``__import__('spam', globals(), locals(), [], -1)``; the statement
- ``from spam.ham import eggs`` results in ``__import__('spam.ham', globals(),
- locals(), ['eggs'], -1)``. Note that even though ``locals()`` and ``['eggs']``
- are passed in as arguments, the :func:`__import__` function does not set the
- local variable named ``eggs``; this is done by subsequent code that is generated
- for the import statement. (In fact, the standard implementation does not use
- its *locals* argument at all, and uses its *globals* only to determine the
- package context of the :keyword:`import` statement.)
+ This function is invoked by the :keyword:`import` statement. It can be
+ replaced (by importing the :mod:`builtins` module and assigning to
+ ``builtins.__import__``) in order to change semantics of the
+ :keyword:`import` statement, but nowadays it is usually simpler to use import
+ hooks (see :pep:`302`). Direct use of :func:`__import__` is rare, except in
+ cases where you want to import a module whose name is only known at runtime.
+
+ The function imports the module *name*, potentially using the given *globals*
+ and *locals* to determine how to interpret the name in a package context.
+ The *fromlist* gives the names of objects or submodules that should be
+ imported from the module given by *name*. The standard implementation does
+ not use its *locals* argument at all, and uses its *globals* only to
+ determine the package context of the :keyword:`import` statement.
+
+ *level* specifies whether to use absolute or relative imports. The default
+ is ``-1`` which indicates both absolute and relative imports will be
+ attempted. ``0`` means only perform absolute imports. Positive values for
+ *level* indicate the number of parent directories to search relative to the
+ directory of the module calling :func:`__import__`.
When the *name* variable is of the form ``package.module``, normally, the
top-level package (the name up till the first dot) is returned, *not* the
module named by *name*. However, when a non-empty *fromlist* argument is
- given, the module named by *name* is returned. This is done for
- compatibility with the :term:`bytecode` generated for the different kinds of import
- statement; when using ``import spam.ham.eggs``, the top-level package
- :mod:`spam` must be placed in the importing namespace, but when using ``from
- spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the
- ``eggs`` variable. As a workaround for this behavior, use :func:`getattr` to
- extract the desired components. For example, you could define the following
- helper::
-
- def my_import(name):
- mod = __import__(name)
- components = name.split('.')
- for comp in components[1:]:
- mod = getattr(mod, comp)
- return mod
-
- *level* specifies whether to use absolute or relative imports. The default is
- ``-1`` which indicates both absolute and relative imports will be attempted.
- ``0`` means only perform absolute imports. Positive values for *level* indicate
- the number of parent directories to search relative to the directory of the
- module calling :func:`__import__`.
+ given, the module named by *name* is returned.
+ For example, the statement ``import spam`` results in bytecode resembling the
+ following code::
+
+ spam = __import__('spam', globals(), locals(), [], -1)
+
+ The statement ``import spam.ham`` results in this call::
+
+ spam = __import__('spam.ham', globals(), locals(), [], -1)
+
+ Note how :func:`__import__` returns the toplevel module here because this is
+ the object that is bound to a name by the :keyword:`import` statement.
+
+ On the other hand, the statement ``from spam.ham import eggs, sausage as
+ saus`` results in ::
+
+ _temp = __import__('spam.ham', globals(), locals(), ['eggs', 'sausage'], -1)
+ eggs = _temp.eggs
+ saus = _temp.sausage
+
+ Here, the ``spam.ham`` module is returned from :func:`__import__`. From this
+ object, the names to import are retrieved and assigned to their respective
+ names.
+
+ If you simply want to import a module (potentially within a package) by name,
+ you can get it from :data:`sys.modules`::
+
+ >>> import sys
+ >>> name = 'foo.bar.baz'
+ >>> __import__(name)
+ <module 'foo' from ...>
+ >>> baz = sys.modules[name]
+ >>> baz
+ <module 'foo.bar.baz' from ...>
.. rubric:: Footnotes
Modified: python/branches/py3k-issue1717/Doc/library/hashlib.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/hashlib.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/hashlib.rst Fri Jan 2 15:30:39 2009
@@ -64,7 +64,7 @@
More condensed:
>>> hashlib.sha224(b"Nobody inspects the spammish repetition").hexdigest()
- b'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
+ 'a4337bc45a8fc544c03f52dc550cd6e1e87021bc896588bd79e901e2'
A generic :func:`new` constructor that takes the string name of the desired
algorithm as its first parameter also exists to allow access to the above listed
@@ -76,7 +76,7 @@
>>> h = hashlib.new('ripemd160')
>>> h.update(b"Nobody inspects the spammish repetition")
>>> h.hexdigest()
- b'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
+ 'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
The following values are provided as constant attributes of the hash objects
returned by the constructors:
Modified: python/branches/py3k-issue1717/Doc/library/json.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/json.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/json.rst Fri Jan 2 15:30:39 2009
@@ -165,7 +165,7 @@
:func:`dump`.
-.. function load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
+.. function:: load(fp[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
Deserialize *fp* (a ``.read()``-supporting file-like object containing a JSON
document) to a Python object.
@@ -201,7 +201,7 @@
class.
-.. function loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
+.. function:: loads(s[, encoding[, cls[, object_hook[, parse_float[, parse_int[, parse_constant[, **kw]]]]]]])
Deserialize *s* (a :class:`str` or :class:`unicode` instance containing a JSON
document) to a Python object.
Modified: python/branches/py3k-issue1717/Doc/library/logging.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/logging.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/logging.rst Fri Jan 2 15:30:39 2009
@@ -566,10 +566,10 @@
The :class:`NullHandler` class was not present in previous versions.
-The :class:`StreamHandler` and :class:`FileHandler` classes are defined in the
-core logging package. The other handlers are defined in a sub- module,
-:mod:`logging.handlers`. (There is also another sub-module,
-:mod:`logging.config`, for configuration functionality.)
+The :class:`NullHandler`, :class:`StreamHandler` and :class:`FileHandler`
+classes are defined in the core logging package. The other handlers are
+defined in a sub- module, :mod:`logging.handlers`. (There is also another
+sub-module, :mod:`logging.config`, for configuration functionality.)
Logged messages are formatted for presentation through instances of the
:class:`Formatter` class. They are initialized with a format string suitable for
@@ -1534,6 +1534,8 @@
StreamHandler
^^^^^^^^^^^^^
+.. module:: logging.handlers
+
The :class:`StreamHandler` class, located in the core :mod:`logging` package,
sends logging output to streams such as *sys.stdout*, *sys.stderr* or any
file-like object (or, more precisely, any object which supports :meth:`write`
@@ -2035,6 +2037,8 @@
Formatter Objects
-----------------
+.. currentmodule:: logging
+
:class:`Formatter`\ s have the following attributes and methods. They are
responsible for converting a :class:`LogRecord` to (usually) a string which can
be interpreted by either a human or an external system. The base
Modified: python/branches/py3k-issue1717/Doc/library/math.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/math.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/math.rst Fri Jan 2 15:30:39 2009
@@ -21,8 +21,9 @@
The following functions are provided by this module. Except when explicitly
noted otherwise, all return values are floats.
-Number-theoretic and representation functions:
+Number-theoretic and representation functions
+---------------------------------------------
.. function:: ceil(x)
@@ -110,8 +111,8 @@
.. function:: modf(x)
- Return the fractional and integer parts of *x*. Both results carry the sign of
- *x*, and both are floats.
+ Return the fractional and integer parts of *x*. Both results carry the sign
+ of *x* and are floats.
.. function:: trunc(x)
@@ -131,7 +132,9 @@
platform C double type), in which case any float *x* with ``abs(x) >= 2**52``
necessarily has no fractional bits.
-Power and logarithmic functions:
+
+Power and logarithmic functions
+-------------------------------
.. function:: exp(x)
@@ -169,7 +172,8 @@
Return the square root of *x*.
-Trigonometric functions:
+Trigonometric functions
+-----------------------
.. function:: acos(x)
@@ -217,7 +221,8 @@
Return the tangent of *x* radians.
-Angular conversion:
+Angular conversion
+------------------
.. function:: degrees(x)
@@ -229,7 +234,8 @@
Converts angle *x* from degrees to radians.
-Hyperbolic functions:
+Hyperbolic functions
+--------------------
.. function:: acosh(x)
@@ -262,9 +268,8 @@
Return the hyperbolic tangent of *x*.
-
-The module also defines two mathematical constants:
-
+Constants
+=========
.. data:: pi
Modified: python/branches/py3k-issue1717/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/multiprocessing.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/multiprocessing.rst Fri Jan 2 15:30:39 2009
@@ -356,7 +356,7 @@
.. attribute:: daemon
- The process's daemon flag, a Boolean value. This must be called before
+ The process's daemon flag, a Boolean value. This must be set before
:meth:`start` is called.
The initial value is inherited from the creating process.
@@ -1436,13 +1436,13 @@
Proxy objects are instances of subclasses of :class:`BaseProxy`.
- .. method:: _call_method(methodname[, args[, kwds]])
+ .. method:: _callmethod(methodname[, args[, kwds]])
Call and return the result of a method of the proxy's referent.
If ``proxy`` is a proxy whose referent is ``obj`` then the expression ::
- proxy._call_method(methodname, args, kwds)
+ proxy._callmethod(methodname, args, kwds)
will evaluate the expression ::
@@ -1455,26 +1455,26 @@
argument of :meth:`BaseManager.register`.
If an exception is raised by the call, then then is re-raised by
- :meth:`_call_method`. If some other exception is raised in the manager's
+ :meth:`_callmethod`. If some other exception is raised in the manager's
process then this is converted into a :exc:`RemoteError` exception and is
- raised by :meth:`_call_method`.
+ raised by :meth:`_callmethod`.
Note in particular that an exception will be raised if *methodname* has
not been *exposed*
- An example of the usage of :meth:`_call_method`::
+ An example of the usage of :meth:`_callmethod`::
>>> l = manager.list(range(10))
- >>> l._call_method('__len__')
+ >>> l._callmethod('__len__')
10
- >>> l._call_method('__getslice__', (2, 7)) # equiv to `l[2:7]`
+ >>> l._callmethod('__getslice__', (2, 7)) # equiv to `l[2:7]`
[2, 3, 4, 5, 6]
- >>> l._call_method('__getitem__', (20,)) # equiv to `l[20]`
+ >>> l._callmethod('__getitem__', (20,)) # equiv to `l[20]`
Traceback (most recent call last):
...
IndexError: list index out of range
- .. method:: _get_value()
+ .. method:: _getvalue()
Return a copy of the referent.
@@ -1808,9 +1808,9 @@
filesystem.
* An ``'AF_PIPE'`` address is a string of the form
- ``r'\\\\.\\pipe\\PipeName'``. To use :func:`Client` to connect to a named
+ :samp:`r'\\\\.\\pipe\\{PipeName}'`. To use :func:`Client` to connect to a named
pipe on a remote computer called ServerName* one should use an address of the
- form ``r'\\\\ServerName\\pipe\\PipeName'`` instead.
+ form :samp:`r'\\\\{ServerName}\\pipe\\{PipeName}'`` instead.
Note that any string beginning with two backslashes is assumed by default to be
an ``'AF_PIPE'`` address rather than an ``'AF_UNIX'`` address.
Modified: python/branches/py3k-issue1717/Doc/library/optparse.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/optparse.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/optparse.rst Fri Jan 2 15:30:39 2009
@@ -1625,36 +1625,33 @@
Nevertheless, here's a stab at a callback for an option with variable
arguments::
- def vararg_callback(option, opt_str, value, parser):
- assert value is None
- done = 0
- value = []
- rargs = parser.rargs
- while rargs:
- arg = rargs[0]
-
- # Stop if we hit an arg like "--foo", "-a", "-fx", "--file=f",
- # etc. Note that this also stops on "-3" or "-3.0", so if
- # your option takes numeric values, you will need to handle
- # this.
- if ((arg[:2] == "--" and len(arg) > 2) or
- (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-")):
- break
- else:
- value.append(arg)
- del rargs[0]
+ def vararg_callback(option, opt_str, value, parser):
+ assert value is None
+ value = []
+
+ def floatable(str):
+ try:
+ float(str)
+ return True
+ except ValueError:
+ return False
+
+ for arg in parser.rargs:
+ # stop on --foo like options
+ if arg[:2] == "--" and len(arg) > 2:
+ break
+ # stop on -a, but not on -3 or -3.0
+ if arg[:1] == "-" and len(arg) > 1 and not floatable(arg):
+ break
+ value.append(arg)
- setattr(parser.values, option.dest, value)
+ del parser.rargs[:len(value)]
+ setattr(parser.values, option.dest, value))
[...]
parser.add_option("-c", "--callback", dest="vararg_attr",
action="callback", callback=vararg_callback)
-The main weakness with this particular implementation is that negative numbers
-in the arguments following ``"-c"`` will be interpreted as further options
-(probably causing an error), rather than as arguments to ``"-c"``. Fixing this
-is left as an exercise for the reader.
-
.. _optparse-extending-optparse:
Modified: python/branches/py3k-issue1717/Doc/library/pydoc.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/pydoc.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/pydoc.rst Fri Jan 2 15:30:39 2009
@@ -34,6 +34,13 @@
Unix), and refers to an existing Python source file, then documentation is
produced for that file.
+.. note::
+
+ In order to find objects and their documentation, :mod:`pydoc` imports the
+ module(s) to be documented. Therefore, any code on module level will be
+ executed on that occasion. Use an ``if __name__ == '__main__':`` guard to
+ only execute code when a file is invoked as a script and not just imported.
+
Specifying a :option:`-w` flag before the argument will cause HTML documentation
to be written out to a file in the current directory, instead of displaying text
on the console.
Modified: python/branches/py3k-issue1717/Doc/library/shutil.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/shutil.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/shutil.rst Fri Jan 2 15:30:39 2009
@@ -139,7 +139,7 @@
Recursively move a file or directory to another location.
If the destination is on the current filesystem, then simply use rename.
- Otherwise, copy src to the dst and then remove src.
+ Otherwise, copy src (with :func:`copy2`) to the dst and then remove src.
.. exception:: Error
Modified: python/branches/py3k-issue1717/Doc/library/signal.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/signal.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/signal.rst Fri Jan 2 15:30:39 2009
@@ -52,10 +52,10 @@
.. data:: SIG_DFL
- This is one of two standard signal handling options; it will simply perform the
- default function for the signal. For example, on most systems the default
- action for :const:`SIGQUIT` is to dump core and exit, while the default action
- for :const:`SIGCLD` is to simply ignore it.
+ This is one of two standard signal handling options; it will simply perform
+ the default function for the signal. For example, on most systems the
+ default action for :const:`SIGQUIT` is to dump core and exit, while the
+ default action for :const:`SIGCHLD` is to simply ignore it.
.. data:: SIG_IGN
Modified: python/branches/py3k-issue1717/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/stdtypes.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/stdtypes.rst Fri Jan 2 15:30:39 2009
@@ -442,7 +442,7 @@
Equivalent to::
def bit_length(self):
- s = bin(self) # binary representation: bin(-37) --> '-0b100101'
+ s = bin(x) # binary representation: bin(-37) --> '-0b100101'
s = s.lstrip('-0b') # remove leading zeros and minus sign
return len(s) # len('100101') --> 6
@@ -1116,13 +1116,12 @@
.. method:: str.translate(map)
Return a copy of the *s* where all characters have been mapped through the
- *map* which must be a dictionary of Unicode ordinals(integers) to Unicode
+ *map* which must be a dictionary of Unicode ordinals (integers) to Unicode
ordinals, strings or ``None``. Unmapped characters are left untouched.
Characters mapped to ``None`` are deleted.
- You can use :meth:`str.maketrans` to create a translation table. For string
- objects, set the *table* argument to ``None`` for translations that only
- delete characters:
+ You can use :meth:`str.maketrans` to create a translation map from
+ character-to-character mappings in different formats.
.. note::
@@ -1525,23 +1524,23 @@
>>> bytes.fromhex('f0 f1f2 ')
b'\xf0\xf1\xf2'
-.. XXX verify/document translate() semantics!
-
- .. method:: bytes.translate(table[, delete])
+The translate method differs in semantics from the version available on strings:
+
+.. method:: bytes.translate(table[, delete])
- Return a copy of the bytes object where all bytes occurring in the optional
- argument *delete* are removed, and the remaining bytes have been mapped
- through the given translation table, which must be a bytes object of length
- 256.
+ Return a copy of the bytes or bytearray object where all bytes occurring in
+ the optional argument *delete* are removed, and the remaining bytes have been
+ mapped through the given translation table, which must be a bytes object of
+ length 256.
- You can use the :func:`maketrans` helper function in the :mod:`string` module to
- create a translation table.
+ You can use the :func:`string.maketrans` helper function to create a
+ translation table.
- .. XXX a None table doesn't seem to be supported
- Set the *table* argument to ``None`` for translations that only delete characters::
+ Set the *table* argument to ``None`` for translations that only delete
+ characters::
- >>> 'read this short text'.translate(None, 'aeiou')
- 'rd ths shrt txt'
+ >>> b'read this short text'.translate(None, b'aeiou')
+ b'rd ths shrt txt'
.. _types-set:
Modified: python/branches/py3k-issue1717/Doc/library/subprocess.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/subprocess.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/subprocess.rst Fri Jan 2 15:30:39 2009
@@ -197,6 +197,8 @@
>>> subprocess.getstatusoutput('/bin/junk')
(256, 'sh: /bin/junk: not found')
+ Availability: UNIX.
+
.. function:: getoutput(cmd)
Return output (stdout and stderr) of executing *cmd* in a shell.
@@ -208,6 +210,8 @@
>>> subprocess.getoutput('ls /bin/ls')
'/bin/ls'
+ Availability: UNIX.
+
Exceptions
^^^^^^^^^^
Modified: python/branches/py3k-issue1717/Doc/library/unittest.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/unittest.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/unittest.rst Fri Jan 2 15:30:39 2009
@@ -610,8 +610,8 @@
equal, the test will fail with the explanation given by *msg*, or :const:`None`.
-.. method:: TestCase.assertRaises(exception, callable, ...)
- TestCase.failUnlessRaises(exception, callable, ...)
+.. method:: TestCase.assertRaises(exception[, callable, ...])
+ TestCase.failUnlessRaises(exception[, callable, ...])
Test that an exception is raised when *callable* is called with any positional
or keyword arguments that are also passed to :meth:`assertRaises`. The test
@@ -619,6 +619,11 @@
fails if no exception is raised. To catch any of a group of exceptions, a tuple
containing the exception classes may be passed as *exception*.
+ If *callable* is omitted or None, returns a context manager so that the code
+ under test can be written inline rather than as a function::
+
+ with self.failUnlessRaises(some_error_class):
+ do_something()
.. method:: TestCase.failIf(expr[, msg])
TestCase.assertFalse(expr[, msg])
Modified: python/branches/py3k-issue1717/Doc/library/webbrowser.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/webbrowser.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/webbrowser.rst Fri Jan 2 15:30:39 2009
@@ -167,7 +167,7 @@
Browser Controller Objects
--------------------------
-Browser controllers provide two methods which parallel two of the module-level
+Browser controllers provide these methods which parallel two of the module-level
convenience functions:
Modified: python/branches/py3k-issue1717/Doc/library/winsound.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/winsound.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/winsound.rst Fri Jan 2 15:30:39 2009
@@ -26,8 +26,9 @@
Call the underlying :cfunc:`PlaySound` function from the Platform API. The
*sound* parameter may be a filename, audio data as a string, or ``None``. Its
interpretation depends on the value of *flags*, which can be a bitwise ORed
- combination of the constants described below. If the system indicates an error,
- :exc:`RuntimeError` is raised.
+ combination of the constants described below. If the *sound* parameter is
+ ``None``, any currently playing waveform sound is stopped. If the system
+ indicates an error, :exc:`RuntimeError` is raised.
.. function:: MessageBeep([type=MB_OK])
@@ -102,6 +103,10 @@
Stop playing all instances of the specified sound.
+ .. note::
+
+ This flag is not supported on modern Windows platforms.
+
.. data:: SND_ASYNC
Modified: python/branches/py3k-issue1717/Doc/library/xml.etree.elementtree.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/xml.etree.elementtree.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/xml.etree.elementtree.rst Fri Jan 2 15:30:39 2009
@@ -94,6 +94,16 @@
*events* is a list of events to report back. If omitted, only "end" events are
reported. Returns an :term:`iterator` providing ``(event, elem)`` pairs.
+ .. note::
+
+ :func:`iterparse` only guarantees that it has seen the ">"
+ character of a starting tag when it emits a "start" event, so the
+ attributes are defined, but the contents of the text and tail attributes
+ are undefined at that point. The same applies to the element children;
+ they may or may not be present.
+
+ If you need a fully populated element, look for "end" events instead.
+
.. function:: parse(source[, parser])
Modified: python/branches/py3k-issue1717/Doc/library/zipfile.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/library/zipfile.rst (original)
+++ python/branches/py3k-issue1717/Doc/library/zipfile.rst Fri Jan 2 15:30:39 2009
@@ -64,9 +64,11 @@
.. function:: is_zipfile(filename)
Returns ``True`` if *filename* is a valid ZIP file based on its magic number,
- otherwise returns ``False``. This module does not currently handle ZIP files
- which have appended comments.
+ otherwise returns ``False``. *filename* may be a file or file-like object too.
+ This module does not currently handle ZIP files which have appended comments.
+ .. versionchanged:: 2.7
+ Support for file and file-like objects.
.. data:: ZIP_STORED
Modified: python/branches/py3k-issue1717/Doc/license.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/license.rst (original)
+++ python/branches/py3k-issue1717/Doc/license.rst Fri Jan 2 15:30:39 2009
@@ -31,6 +31,7 @@
Source Definition). Historically, most, but not all, Python releases have also
been GPL-compatible; the table below summarizes the various releases.
+<<<<<<< .working
+----------------+--------------+------------+------------+-----------------+
| Release | Derived from | Year | Owner | GPL compatible? |
+================+==============+============+============+=================+
@@ -90,9 +91,12 @@
+----------------+--------------+------------+------------+-----------------+
| 2.6 | 2.5 | 2008 | PSF | yes |
+----------------+--------------+------------+------------+-----------------+
+| 2.6.1 | 2.6 | 2008 | PSF | yes |
++----------------+--------------+------------+------------+-----------------+
| 3.0 | 2.6 | 2008 | PSF | yes |
+----------------+--------------+------------+------------+-----------------+
+
.. note::
GPL-compatible doesn't mean that we're distributing Python under the GPL. All
Deleted: python/branches/py3k-issue1717/Doc/tools/sphinx-web.py
==============================================================================
--- python/branches/py3k-issue1717/Doc/tools/sphinx-web.py Fri Jan 2 15:30:39 2009
+++ (empty file)
@@ -1,14 +0,0 @@
-# -*- coding: utf-8 -*-
-"""
- Sphinx - Python documentation webserver
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- :copyright: 2007 by Georg Brandl.
- :license: Python license.
-"""
-
-import sys
-
-if __name__ == '__main__':
- from sphinx.web import main
- sys.exit(main(sys.argv))
Modified: python/branches/py3k-issue1717/Doc/tools/sphinxext/download.html
==============================================================================
--- python/branches/py3k-issue1717/Doc/tools/sphinxext/download.html (original)
+++ python/branches/py3k-issue1717/Doc/tools/sphinxext/download.html Fri Jan 2 15:30:39 2009
@@ -19,20 +19,20 @@
<table class="docutils">
<tr><th>Format</th><th>Packed as .zip</th><th>Packed as .tar.bz2</th></tr>
<tr><td>PDF (US-Letter paper size)</td>
- <td><a href="{{ dlbase }}/python-docs-pdf-letter.zip">Download</a> (ca. 8 MB)</td>
- <td><a href="{{ dlbase }}/python-docs-pdf-letter.tar.bz2">Download</a> (ca. 8 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.zip">Download</a> (ca. 8 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-letter.tar.bz2">Download</a> (ca. 8 MB)</td>
</tr>
<tr><td>PDF (A4 paper size)</td>
- <td><a href="{{ dlbase }}/python-docs-pdf-a4.zip">Download</a> (ca. 8 MB)</td>
- <td><a href="{{ dlbase }}/python-docs-pdf-a4.tar.bz2">Download</a> (ca. 8 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.zip">Download</a> (ca. 8 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-pdf-a4.tar.bz2">Download</a> (ca. 8 MB)</td>
</tr>
<tr><td>HTML</td>
- <td><a href="{{ dlbase }}/python-docs-html.zip">Download</a> (ca. 6 MB)</td>
- <td><a href="{{ dlbase }}/python-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-html.zip">Download</a> (ca. 6 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-html.tar.bz2">Download</a> (ca. 4 MB)</td>
</tr>
<tr><td>Plain Text</td>
<td><a href="{{ dlbase }}/python-docs-text.zip">Download</a> (ca. 2 MB)</td>
- <td><a href="{{ dlbase }}/python-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
+ <td><a href="{{ dlbase }}/python-{{ release }}-docs-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
</tr>
</table>
Modified: python/branches/py3k-issue1717/Doc/tools/sphinxext/pyspecific.py
==============================================================================
--- python/branches/py3k-issue1717/Doc/tools/sphinxext/pyspecific.py (original)
+++ python/branches/py3k-issue1717/Doc/tools/sphinxext/pyspecific.py Fri Jan 2 15:30:39 2009
@@ -45,7 +45,11 @@
from pprint import pformat
from docutils.io import StringOutput
from docutils.utils import new_document
-from sphinx.builder import Builder
+
+try:
+ from sphinx.builders import Builder
+except ImportError:
+ from sphinx.builder import Builder
try:
from sphinx.writers.text import TextWriter
Modified: python/branches/py3k-issue1717/Doc/tutorial/controlflow.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/tutorial/controlflow.rst (original)
+++ python/branches/py3k-issue1717/Doc/tutorial/controlflow.rst Fri Jan 2 15:30:39 2009
@@ -200,42 +200,20 @@
... pass # Busy-wait for keyboard interrupt (Ctrl+C)
...
-This is commonly used for creating minimal classes such as exceptions, or
-for ignoring unwanted exceptions::
+This is commonly used for creating minimal classes::
- >>> class ParserError(Exception):
+ >>> class MyEmptyClass:
... pass
- ...
- >>> try:
- ... import audioop
- ... except ImportError:
- ... pass
- ...
+ ...
Another place :keyword:`pass` can be used is as a place-holder for a function or
-conditional body when you are working on new code, allowing you to keep
-thinking at a more abstract level. However, as :keyword:`pass` is silently
-ignored, a better choice may be to raise a :exc:`NotImplementedError`
-exception::
+conditional body when you are working on new code, allowing you to keep thinking
+at a more abstract level. The :keyword:`pass` is silently ignored::
>>> def initlog(*args):
- ... raise NotImplementedError # Open logfile if not already open
- ... if not logfp:
- ... raise NotImplementedError # Set up dummy log back-end
- ... raise NotImplementedError('Call log initialization handler')
+ ... pass # Remember to implement this!
...
-If :keyword:`pass` were used here and you later ran tests, they may fail
-without indicating why. Using :exc:`NotImplementedError` causes this code
-to raise an exception, telling you exactly where the incomplete code
-is. Note the two calling styles of the exceptions above.
-The first style, with no message but with an accompanying comment,
-lets you easily leave the comment when you remove the exception,
-which ideally would be a good description for
-the block of code the exception is a placeholder for. However, the
-third example, providing a message for the exception, will produce
-a more useful traceback.
-
.. _tut-functions:
Defining Functions
Modified: python/branches/py3k-issue1717/Doc/using/unix.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/using/unix.rst (original)
+++ python/branches/py3k-issue1717/Doc/using/unix.rst Fri Jan 2 15:30:39 2009
@@ -140,8 +140,8 @@
Vim and Emacs are excellent editors which support Python very well. For more
information on how to code in python in these editors, look at:
-http://www.vim.org/scripts/script.php?script_id=790
-http://sourceforge.net/projects/python-mode
+* http://www.vim.org/scripts/script.php?script_id=790
+* http://sourceforge.net/projects/python-mode
Geany is an excellent IDE with support for a lot of languages. For more
information, read: http://geany.uvena.de/
Modified: python/branches/py3k-issue1717/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/py3k-issue1717/Doc/whatsnew/2.6.rst (original)
+++ python/branches/py3k-issue1717/Doc/whatsnew/2.6.rst Fri Jan 2 15:30:39 2009
@@ -738,7 +738,7 @@
Curly brackets can be escaped by doubling them::
- >>> format("Empty dict: {{}}")
+ >>> "Empty dict: {{}}".format()
"Empty dict: {}"
Field names can be integers indicating positional arguments, such as
Modified: python/branches/py3k-issue1717/Include/pymacconfig.h
==============================================================================
--- python/branches/py3k-issue1717/Include/pymacconfig.h (original)
+++ python/branches/py3k-issue1717/Include/pymacconfig.h Fri Jan 2 15:30:39 2009
@@ -15,6 +15,8 @@
# undef SIZEOF_SIZE_T
# undef SIZEOF_TIME_T
# undef SIZEOF_VOID_P
+# undef SIZEOF__BOOL
+# undef WORDS_BIGENDIAN
# undef VA_LIST_IS_ARRAY
# if defined(__LP64__) && defined(__x86_64__)
@@ -28,12 +30,19 @@
# undef SIZEOF_LONG
# ifdef __LP64__
+# define SIZEOF__BOOL 1
+# define SIZEOF__BOOL 1
# define SIZEOF_LONG 8
# define SIZEOF_PTHREAD_T 8
# define SIZEOF_SIZE_T 8
# define SIZEOF_TIME_T 8
# define SIZEOF_VOID_P 8
# else
+# ifdef __ppc__
+# define SIZEOF__BOOL 4
+# else
+# define SIZEOF__BOOL 1
+# endif
# define SIZEOF_LONG 4
# define SIZEOF_PTHREAD_T 4
# define SIZEOF_SIZE_T 4
@@ -54,6 +63,11 @@
# endif
+#ifdef __BIG_ENDIAN__
+#define WORDS_BIGENDIAN 1
+#endif /* __BIG_ENDIAN */
+
+
#endif /* defined(_APPLE__) */
#endif /* PYMACCONFIG_H */
Modified: python/branches/py3k-issue1717/Include/unicodeobject.h
==============================================================================
--- python/branches/py3k-issue1717/Include/unicodeobject.h (original)
+++ python/branches/py3k-issue1717/Include/unicodeobject.h Fri Jan 2 15:30:39 2009
@@ -152,6 +152,7 @@
# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode
# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString
# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar
+# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
# define PyUnicode_Compare PyUnicodeUCS2_Compare
# define PyUnicode_Concat PyUnicodeUCS2_Concat
# define PyUnicode_Append PyUnicodeUCS2_Append
@@ -185,13 +186,13 @@
# define PyUnicode_Find PyUnicodeUCS2_Find
# define PyUnicode_Format PyUnicodeUCS2_Format
# define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject
+# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat
+# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV
# define PyUnicode_FromObject PyUnicodeUCS2_FromObject
# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal
-# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode
# define PyUnicode_FromString PyUnicodeUCS2_FromString
# define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize
-# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV
-# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat
+# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode
# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS2_GetMax
@@ -213,7 +214,6 @@
# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString
# define _PyUnicode_Fini _PyUnicodeUCS2_Fini
# define _PyUnicode_Init _PyUnicodeUCS2_Init
-# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
# define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha
# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit
# define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit
@@ -250,6 +250,7 @@
# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode
# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString
# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar
+# define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist
# define PyUnicode_Compare PyUnicodeUCS4_Compare
# define PyUnicode_Concat PyUnicodeUCS4_Concat
# define PyUnicode_Append PyUnicodeUCS4_Append
@@ -283,13 +284,13 @@
# define PyUnicode_Find PyUnicodeUCS4_Find
# define PyUnicode_Format PyUnicodeUCS4_Format
# define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject
+# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
+# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV
# define PyUnicode_FromObject PyUnicodeUCS4_FromObject
# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal
-# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode
# define PyUnicode_FromString PyUnicodeUCS4_FromString
# define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize
-# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV
-# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat
+# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode
# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar
# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding
# define PyUnicode_GetMax PyUnicodeUCS4_GetMax
@@ -311,7 +312,6 @@
# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString
# define _PyUnicode_Fini _PyUnicodeUCS4_Fini
# define _PyUnicode_Init _PyUnicodeUCS4_Init
-# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
# define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha
# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit
# define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit
Modified: python/branches/py3k-issue1717/LICENSE
==============================================================================
--- python/branches/py3k-issue1717/LICENSE (original)
+++ python/branches/py3k-issue1717/LICENSE Fri Jan 2 15:30:39 2009
@@ -55,7 +55,10 @@
2.4.4 2.4.3 2006 PSF yes
2.5 2.4 2006 PSF yes
2.5.1 2.5 2007 PSF yes
+ 2.5.2 2.5.1 2008 PSF yes
+ 2.5.3 2.5.2 2008 PSF yes
2.6 2.5 2008 PSF yes
+ 2.6.1 2.6 2008 PSF yes
3.0 2.6 2008 PSF yes
Footnotes:
Modified: python/branches/py3k-issue1717/Lib/dis.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/dis.py (original)
+++ python/branches/py3k-issue1717/Lib/dis.py Fri Jan 2 15:30:39 2009
@@ -6,7 +6,8 @@
from opcode import *
from opcode import __all__ as _opcodes_all
-__all__ = ["dis","disassemble","distb","disco"] + _opcodes_all
+__all__ = ["dis", "disassemble", "distb", "disco",
+ "findlinestarts", "findlabels"] + _opcodes_all
del _opcodes_all
def dis(x=None):
Modified: python/branches/py3k-issue1717/Lib/distutils/ccompiler.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/ccompiler.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/ccompiler.py Fri Jan 2 15:30:39 2009
@@ -984,8 +984,8 @@
def move_file(self, src, dst):
return move_file(src, dst, dry_run=self.dry_run)
- def mkpath(self, name, mode=0o777):
- mkpath(name, mode, self.dry_run)
+ def mkpath (self, name, mode=0o777):
+ mkpath(name, mode, dry_run=self.dry_run)
# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
Modified: python/branches/py3k-issue1717/Lib/distutils/command/register.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/command/register.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/command/register.py Fri Jan 2 15:30:39 2009
@@ -143,12 +143,13 @@
# get the user's login info
choices = '1 2 3 4'.split()
while choice not in choices:
- print('''We need to know who you are, so please choose either:
+ self.announce('''\
+We need to know who you are, so please choose either:
1. use your existing login,
2. register as a new user,
3. have the server generate a new password for you (and email it to you), or
4. quit
-Your selection [default 1]: ''', end=' ')
+Your selection [default 1]: ''', log.INFO)
choice = input()
if not choice:
choice = '1'
@@ -169,12 +170,16 @@
# send the info to the server and report the result
code, result = self.post_to_server(self.build_post_data('submit'),
auth)
- print('Server response (%s): %s'%(code, result))
+ self.announce('Server response (%s): %s' % (code, result),
+ log.INFO)
# possibly save the login
if not self.has_config and code == 200:
- print('I can store your PyPI login so future submissions will be faster.')
- print('(the login will be stored in %s)' % self._get_rc_file())
+ self.announce(('I can store your PyPI login so future '
+ 'submissions will be faster.'), log.INFO)
+ self.announce('(the login will be stored in %s)' % \
+ self._get_rc_file(), log.INFO)
+
choice = 'X'
while choice.lower() not in 'yn':
choice = input('Save your login (y/N)?')
Modified: python/branches/py3k-issue1717/Lib/distutils/config.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/config.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/config.py Fri Jan 2 15:30:39 2009
@@ -10,8 +10,8 @@
from distutils.cmd import Command
DEFAULT_PYPIRC = """\
-[pypirc]
-servers =
+[distutils]
+index-servers =
pypi
[pypi]
Modified: python/branches/py3k-issue1717/Lib/distutils/dist.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/dist.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/dist.py Fri Jan 2 15:30:39 2009
@@ -228,7 +228,7 @@
# command options will override any supplied redundantly
# through the general options dictionary.
options = attrs.get('options')
- if options:
+ if options is not None:
del attrs['options']
for (command, cmd_options) in options.items():
opt_dict = self.get_option_dict(command)
Modified: python/branches/py3k-issue1717/Lib/distutils/msvc9compiler.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/msvc9compiler.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/msvc9compiler.py Fri Jan 2 15:30:39 2009
@@ -247,7 +247,7 @@
result = {}
if vcvarsall is None:
- raise IOError("Unable to find vcvarsall.bat")
+ raise DistutilsPlatformError("Unable to find vcvarsall.bat")
log.debug("Calling 'vcvarsall.bat %s' (version=%s)", arch, version)
popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch),
stdout=subprocess.PIPE,
@@ -255,7 +255,7 @@
stdout, stderr = popen.communicate()
if popen.wait() != 0:
- raise IOError(stderr.decode("mbcs"))
+ raise DistutilsPlatformError(stderr.decode("mbcs"))
stdout = stdout.decode("mbcs")
for line in stdout.split("\n"):
Modified: python/branches/py3k-issue1717/Lib/distutils/tests/test_config.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/tests/test_config.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/tests/test_config.py Fri Jan 2 15:30:39 2009
@@ -5,6 +5,8 @@
from distutils.core import PyPIRCCommand
from distutils.core import Distribution
+from distutils.log import set_threshold
+from distutils.log import WARN
from distutils.tests import support
@@ -32,6 +34,17 @@
password:secret
"""
+WANTED = """\
+[distutils]
+index-servers =
+ pypi
+
+[pypi]
+username:tarek
+password:xxx
+"""
+
+
class PyPIRCCommandTestCase(support.TempdirManager, unittest.TestCase):
def setUp(self):
@@ -53,6 +66,7 @@
finalize_options = initialize_options
self._cmd = command
+ self.old_threshold = set_threshold(WARN)
def tearDown(self):
"""Removes the patch."""
@@ -62,6 +76,7 @@
os.environ['HOME'] = self._old_home
if os.path.exists(self.rc):
os.remove(self.rc)
+ set_threshold(self.old_threshold)
def test_server_registration(self):
# This test makes sure PyPIRCCommand knows how to:
@@ -96,6 +111,20 @@
('server', 'server-login'), ('username', 'tarek')]
self.assertEquals(config, waited)
+ def test_server_empty_registration(self):
+
+ cmd = self._cmd(self.dist)
+ rc = cmd._get_rc_file()
+ self.assert_(not os.path.exists(rc))
+
+ cmd._store_pypirc('tarek', 'xxx')
+
+ self.assert_(os.path.exists(rc))
+ content = open(rc).read()
+
+ self.assertEquals(content, WANTED)
+
+
def test_suite():
return unittest.makeSuite(PyPIRCCommandTestCase)
Modified: python/branches/py3k-issue1717/Lib/distutils/tests/test_dist.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/tests/test_dist.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/tests/test_dist.py Fri Jan 2 15:30:39 2009
@@ -6,6 +6,7 @@
import io
import sys
import unittest
+import warnings
from test.support import TESTFN
@@ -96,6 +97,29 @@
os.unlink(TESTFN)
+ def test_empty_options(self):
+ # an empty options dictionary should not stay in the
+ # list of attributes
+ klass = distutils.dist.Distribution
+
+ # catching warnings
+ warns = []
+ def _warn(msg):
+ warns.append(msg)
+
+ old_warn = warnings.warn
+ warnings.warn = _warn
+ try:
+ dist = klass(attrs={'author': 'xxx',
+ 'name': 'xxx',
+ 'version': 'xxx',
+ 'url': 'xxxx',
+ 'options': {}})
+ finally:
+ warnings.warn = old_warn
+
+ self.assertEquals(len(warns), 0)
+
class MetadataTestCase(unittest.TestCase):
def test_simple_metadata(self):
Modified: python/branches/py3k-issue1717/Lib/distutils/util.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/distutils/util.py (original)
+++ python/branches/py3k-issue1717/Lib/distutils/util.py Fri Jan 2 15:30:39 2009
@@ -99,7 +99,11 @@
if not macver:
macver = cfgvars.get('MACOSX_DEPLOYMENT_TARGET')
- if not macver:
+ if 1:
+ # Always calculate the release of the running machine,
+ # needed to determine if we can build fat binaries or not.
+
+ macrelease = macver
# Get the system version. Reading this plist is a documented
# way to get the system version (see the documentation for
# the Gestalt Manager)
@@ -115,16 +119,18 @@
r'<string>(.*?)</string>', f.read())
f.close()
if m is not None:
- macver = '.'.join(m.group(1).split('.')[:2])
+ macrelease = '.'.join(m.group(1).split('.')[:2])
# else: fall back to the default behaviour
+ if not macver:
+ macver = macrelease
+
if macver:
from distutils.sysconfig import get_config_vars
release = macver
osname = "macosx"
-
- if (release + '.') >= '10.4.' and \
+ if (macrelease + '.') >= '10.4.' and \
'-arch' in get_config_vars().get('CFLAGS', '').strip():
# The universal build will build fat binaries, but not on
# systems before 10.4
@@ -133,9 +139,13 @@
# 'universal' instead of 'fat'.
machine = 'fat'
+ cflags = get_config_vars().get('CFLAGS')
- if '-arch x86_64' in get_config_vars().get('CFLAGS'):
- machine = 'universal'
+ if '-arch x86_64' in cflags:
+ if '-arch i386' in cflags:
+ machine = 'universal'
+ else:
+ machine = 'fat64'
elif machine in ('PowerPC', 'Power_Macintosh'):
# Pick a sane name for the PPC architecture.
Modified: python/branches/py3k-issue1717/Lib/idlelib/IOBinding.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/idlelib/IOBinding.py (original)
+++ python/branches/py3k-issue1717/Lib/idlelib/IOBinding.py Fri Jan 2 15:30:39 2009
@@ -64,52 +64,6 @@
coding_re = re.compile("coding[:=]\s*([-\w_.]+)")
-class EncodingMessage(SimpleDialog):
- "Inform user that an encoding declaration is needed."
- def __init__(self, master, enc):
- self.should_edit = False
-
- self.root = top = Toplevel(master)
- top.bind("<Return>", self.return_event)
- top.bind("<Escape>", self.do_ok)
- top.protocol("WM_DELETE_WINDOW", self.wm_delete_window)
- top.wm_title("I/O Warning")
- top.wm_iconname("I/O Warning")
- self.top = top
-
- l1 = Label(top,
- text="Non-ASCII found, yet no encoding declared. Add a line like")
- l1.pack(side=TOP, anchor=W)
- l2 = Entry(top, font="courier")
- l2.insert(0, "# -*- coding: %s -*-" % enc)
- # For some reason, the text is not selectable anymore if the
- # widget is disabled.
- # l2['state'] = DISABLED
- l2.pack(side=TOP, anchor = W, fill=X)
- l3 = Label(top, text="to your file\n"
- "Choose OK to save this file as %s\n"
- "Edit your general options to silence this warning" % enc)
- l3.pack(side=TOP, anchor = W)
-
- buttons = Frame(top)
- buttons.pack(side=TOP, fill=X)
- # Both return and cancel mean the same thing: do nothing
- self.default = self.cancel = 0
- b1 = Button(buttons, text="Ok", default="active",
- command=self.do_ok)
- b1.pack(side=LEFT, fill=BOTH, expand=1)
- b2 = Button(buttons, text="Edit my file",
- command=self.do_edit)
- b2.pack(side=LEFT, fill=BOTH, expand=1)
-
- self._set_transient(master)
-
- def do_ok(self):
- self.done(0)
-
- def do_edit(self):
- self.done(1)
-
def coding_spec(data):
"""Return the encoding declaration according to PEP 263.
@@ -409,6 +363,9 @@
# This is either plain ASCII, or Tk was returning mixed-encoding
# text to us. Don't try to guess further.
return chars
+ # Preserve a BOM that might have been present on opening
+ if self.fileencoding == 'BOM':
+ return BOM_UTF8 + chars.encode("utf-8")
# See whether there is anything non-ASCII in it.
# If not, no need to figure out the encoding.
try:
@@ -423,61 +380,22 @@
except LookupError as msg:
failed = msg
enc = None
+ else:
+ if not enc:
+ # PEP 3120: default source encoding is UTF-8
+ enc = 'utf-8'
if enc:
try:
return chars.encode(enc)
except UnicodeError:
failed = "Invalid encoding '%s'" % enc
- if failed:
- tkMessageBox.showerror(
- "I/O Error",
- "%s.\nSaving as UTF-8" % failed,
- master = self.text)
- # If there was a UTF-8 signature, use that. This should not fail
- if self.fileencoding == 'BOM' or failed:
- return BOM_UTF8 + chars.encode("utf-8")
- # Try the original file encoding next, if any
- if self.fileencoding:
- try:
- return chars.encode(self.fileencoding)
- except UnicodeError:
- tkMessageBox.showerror(
- "I/O Error",
- "Cannot save this as '%s' anymore. Saving as UTF-8" \
- % self.fileencoding,
- master = self.text)
- return BOM_UTF8 + chars.encode("utf-8")
- # Nothing was declared, and we had not determined an encoding
- # on loading. Recommend an encoding line.
- config_encoding = idleConf.GetOption("main","EditorWindow",
- "encoding")
- if config_encoding == 'utf-8':
- # User has requested that we save files as UTF-8
- return BOM_UTF8 + chars.encode("utf-8")
- ask_user = True
- try:
- chars = chars.encode(encoding)
- enc = encoding
- if config_encoding == 'locale':
- ask_user = False
- except UnicodeError:
- chars = BOM_UTF8 + chars.encode("utf-8")
- enc = "utf-8"
- if not ask_user:
- return chars
- dialog = EncodingMessage(self.editwin.top, enc)
- dialog.go()
- if dialog.num == 1:
- # User asked us to edit the file
- encline = "# -*- coding: %s -*-\n" % enc
- firstline = self.text.get("1.0", "2.0")
- if firstline.startswith("#!"):
- # Insert encoding after #! line
- self.text.insert("2.0", encline)
- else:
- self.text.insert("1.0", encline)
- return self.encode(self.text.get("1.0", "end-1c"))
- return chars
+ tkMessageBox.showerror(
+ "I/O Error",
+ "%s.\nSaving as UTF-8" % failed,
+ master = self.text)
+ # Fallback: save as UTF-8, with BOM - ignoring the incorrect
+ # declared encoding
+ return BOM_UTF8 + chars.encode("utf-8")
def fixlastline(self):
c = self.text.get("end-2c")
Modified: python/branches/py3k-issue1717/Lib/idlelib/NEWS.txt
==============================================================================
--- python/branches/py3k-issue1717/Lib/idlelib/NEWS.txt (original)
+++ python/branches/py3k-issue1717/Lib/idlelib/NEWS.txt Fri Jan 2 15:30:39 2009
@@ -1,3 +1,14 @@
+What's New in IDLE 3.1a1?
+=========================
+
+*Release date: XX-XXX-XXXX*
+
+- Issue #4323: Always encode source as UTF-8 without asking
+ the user (unless a different encoding is declared); remove
+ user configuration of source encoding; all according to
+ PEP 3120.
+
+
What's New in IDLE 3.0a3?
=========================
Modified: python/branches/py3k-issue1717/Lib/idlelib/configDialog.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/idlelib/configDialog.py (original)
+++ python/branches/py3k-issue1717/Lib/idlelib/configDialog.py Fri Jan 2 15:30:39 2009
@@ -336,7 +336,6 @@
text=' Autosave Preferences ')
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
frameParaSize=Frame(frame,borderwidth=2,relief=GROOVE)
- frameEncoding=Frame(frame,borderwidth=2,relief=GROOVE)
frameHelp=LabelFrame(frame,borderwidth=2,relief=GROOVE,
text=' Additional Help Sources ')
#frameRun
@@ -365,14 +364,6 @@
' width (in characters)')
entryParaWidth=Entry(frameParaSize,textvariable=self.paraWidth,
width=3)
- #frameEncoding
- labelEncodingTitle=Label(frameEncoding,text="Default Source Encoding")
- radioEncLocale=Radiobutton(frameEncoding,variable=self.encoding,
- value="locale",text="Locale-defined")
- radioEncUTF8=Radiobutton(frameEncoding,variable=self.encoding,
- value="utf-8",text="UTF-8")
- radioEncNone=Radiobutton(frameEncoding,variable=self.encoding,
- value="none",text="None")
#frameHelp
frameHelpList=Frame(frameHelp)
frameHelpListButtons=Frame(frameHelpList)
@@ -394,7 +385,6 @@
frameSave.pack(side=TOP,padx=5,pady=5,fill=X)
frameWinSize.pack(side=TOP,padx=5,pady=5,fill=X)
frameParaSize.pack(side=TOP,padx=5,pady=5,fill=X)
- frameEncoding.pack(side=TOP,padx=5,pady=5,fill=X)
frameHelp.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
#frameRun
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
@@ -413,11 +403,6 @@
#paragraphFormatWidth
labelParaWidthTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
entryParaWidth.pack(side=RIGHT,anchor=E,padx=10,pady=5)
- #frameEncoding
- labelEncodingTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
- radioEncNone.pack(side=RIGHT,anchor=E,pady=5)
- radioEncUTF8.pack(side=RIGHT,anchor=E,pady=5)
- radioEncLocale.pack(side=RIGHT,anchor=E,pady=5)
#frameHelp
frameHelpListButtons.pack(side=RIGHT,padx=5,pady=5,fill=Y)
frameHelpList.pack(side=TOP,padx=5,pady=5,expand=TRUE,fill=BOTH)
Modified: python/branches/py3k-issue1717/Lib/io.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/io.py (original)
+++ python/branches/py3k-issue1717/Lib/io.py Fri Jan 2 15:30:39 2009
@@ -1157,7 +1157,7 @@
@property
def closed(self):
- return self.writer.closed()
+ return self.writer.closed
class BufferedRandom(BufferedWriter, BufferedReader):
Modified: python/branches/py3k-issue1717/Lib/lib2to3/main.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/lib2to3/main.py (original)
+++ python/branches/py3k-issue1717/Lib/lib2to3/main.py Fri Jan 2 15:30:39 2009
@@ -40,7 +40,8 @@
# Actually write the new file
super(StdoutRefactoringTool, self).write_file(new_text,
filename, old_text)
- shutil.copymode(filename, backup)
+ if not self.nobackups:
+ shutil.copymode(filename, backup)
def print_output(self, lines):
for line in lines:
Modified: python/branches/py3k-issue1717/Lib/pickle.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/pickle.py (original)
+++ python/branches/py3k-issue1717/Lib/pickle.py Fri Jan 2 15:30:39 2009
@@ -222,6 +222,11 @@
def dump(self, obj):
"""Write a pickled representation of obj to the open file."""
+ # Check whether Pickler was initialized correctly. This is
+ # only needed to mimic the behavior of _pickle.Pickler.dump().
+ if not hasattr(self, "write"):
+ raise PicklingError("Pickler.__init__() was not called by "
+ "%s.__init__()" % (self.__class__.__name__,))
if self.proto >= 2:
self.write(PROTO + bytes([self.proto]))
self.save(obj)
@@ -789,6 +794,11 @@
Return the reconstituted object hierarchy specified in the file.
"""
+ # Check whether Unpickler was initialized correctly. This is
+ # only needed to mimic the behavior of _pickle.Unpickler.dump().
+ if not hasattr(self, "read"):
+ raise UnpicklingError("Unpickler.__init__() was not called by "
+ "%s.__init__()" % (self.__class__.__name__,))
self.mark = object() # any new unique object
self.stack = []
self.append = self.stack.append
Modified: python/branches/py3k-issue1717/Lib/pydoc.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/pydoc.py (original)
+++ python/branches/py3k-issue1717/Lib/pydoc.py Fri Jan 2 15:30:39 2009
@@ -1568,6 +1568,42 @@
'with': ('with', 'CONTEXTMANAGERS EXCEPTIONS yield'),
'yield': ('yield', ''),
}
+ # Either add symbols to this dictionary or to the symbols dictionary
+ # directly: Whichever is easier. They are merged later.
+ _symbols_inverse = {
+ 'STRINGS' : ("'", "'''", "r'", "b'", '"""', '"', 'r"', 'b"'),
+ 'OPERATORS' : ('+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&',
+ '|', '^', '~', '<', '>', '<=', '>=', '==', '!=', '<>'),
+ 'COMPARISON' : ('<', '>', '<=', '>=', '==', '!=', '<>'),
+ 'UNARY' : ('-', '~'),
+ 'AUGMENTEDASSIGNMENT' : ('+=', '-=', '*=', '/=', '%=', '&=', '|=',
+ '^=', '<<=', '>>=', '**=', '//='),
+ 'BITWISE' : ('<<', '>>', '&', '|', '^', '~'),
+ 'COMPLEX' : ('j', 'J')
+ }
+ symbols = {
+ '%': 'OPERATORS FORMATTING',
+ '**': 'POWER',
+ ',': 'TUPLES LISTS FUNCTIONS',
+ '.': 'ATTRIBUTES FLOAT MODULES OBJECTS',
+ '...': 'ELLIPSIS',
+ ':': 'SLICINGS DICTIONARYLITERALS',
+ '@': 'def class',
+ '\\': 'STRINGS',
+ '_': 'PRIVATENAMES',
+ '__': 'PRIVATENAMES SPECIALMETHODS',
+ '`': 'BACKQUOTES',
+ '(': 'TUPLES FUNCTIONS CALLS',
+ ')': 'TUPLES FUNCTIONS CALLS',
+ '[': 'LISTS SUBSCRIPTS SLICINGS',
+ ']': 'LISTS SUBSCRIPTS SLICINGS'
+ }
+ for topic, symbols_ in _symbols_inverse.items():
+ for symbol in symbols_:
+ topics = symbols.get(symbol, topic)
+ if topic not in topics:
+ topics = topics + ' ' + topic
+ symbols[symbol] = topics
topics = {
'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
@@ -1705,10 +1741,12 @@
if type(request) is type(''):
if request == 'help': self.intro()
elif request == 'keywords': self.listkeywords()
+ elif request == 'symbols': self.listsymbols()
elif request == 'topics': self.listtopics()
elif request == 'modules': self.listmodules()
elif request[:8] == 'modules ':
self.listmodules(request.split()[1])
+ elif request in self.symbols: self.showsymbol(request)
elif request in self.keywords: self.showtopic(request)
elif request in self.topics: self.showtopic(request)
elif request: doc(request, 'Help on %s:')
@@ -1753,6 +1791,14 @@
''')
self.list(self.keywords.keys())
+ def listsymbols(self):
+ self.output.write('''
+Here is a list of the punctuation symbols which Python assigns special meaning
+to. Enter any symbol to get more help.
+
+''')
+ self.list(self.symbols.keys())
+
def listtopics(self):
self.output.write('''
Here is a list of available topics. Enter any topic name to get more help.
@@ -1760,7 +1806,7 @@
''')
self.list(self.topics.keys())
- def showtopic(self, topic):
+ def showtopic(self, topic, more_xrefs=''):
try:
import pydoc_topics
except ImportError:
@@ -1774,7 +1820,7 @@
self.output.write('no documentation found for %s\n' % repr(topic))
return
if type(target) is type(''):
- return self.showtopic(target)
+ return self.showtopic(target, more_xrefs)
label, xrefs = target
try:
@@ -1783,6 +1829,8 @@
self.output.write('no documentation found for %s\n' % repr(topic))
return
pager(doc.strip() + '\n')
+ if more_xrefs:
+ xrefs = (xrefs or '') + ' ' + more_xrefs
if xrefs:
import io, formatter
buffer = io.StringIO()
@@ -1790,6 +1838,11 @@
'Related help topics: ' + ', '.join(xrefs.split()) + '\n')
self.output.write('\n%s\n' % buffer.getvalue())
+ def showsymbol(self, symbol):
+ target = self.symbols[symbol]
+ topic, _, xrefs = target.partition(' ')
+ self.showtopic(topic, xrefs)
+
def listmodules(self, key=''):
if key:
self.output.write('''
Modified: python/branches/py3k-issue1717/Lib/re.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/re.py (original)
+++ python/branches/py3k-issue1717/Lib/re.py Fri Jan 2 15:30:39 2009
@@ -160,7 +160,8 @@
"""Return the string obtained by replacing the leftmost
non-overlapping occurrences of the pattern in string by the
replacement repl. repl can be either a string or a callable;
- if a callable, it's passed the match object and must return
+ if a string, backslash escapes in it are processed. If it is
+ a callable, it's passed the match object and must return
a replacement string to be used."""
return _compile(pattern, 0).sub(repl, string, count)
@@ -170,7 +171,8 @@
non-overlapping occurrences of the pattern in the source
string by the replacement repl. number is the number of
substitutions that were made. repl can be either a string or a
- callable; if a callable, it's passed the match object and must
+ callable; if a string, backslash escapes in it are processed.
+ If it is a callable, it's passed the match object and must
return a replacement string to be used."""
return _compile(pattern, 0).subn(repl, string, count)
Modified: python/branches/py3k-issue1717/Lib/ssl.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/ssl.py (original)
+++ python/branches/py3k-issue1717/Lib/ssl.py Fri Jan 2 15:30:39 2009
@@ -114,7 +114,7 @@
# see if it's connected
try:
socket.getpeername(self)
- except:
+ except socket_error:
# no, no connection yet
self._sslobj = None
else:
Modified: python/branches/py3k-issue1717/Lib/test/pickletester.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/pickletester.py (original)
+++ python/branches/py3k-issue1717/Lib/test/pickletester.py Fri Jan 2 15:30:39 2009
@@ -484,13 +484,21 @@
self.assertRaises(ValueError, self.loads, buf)
def test_unicode(self):
- endcases = ['', '<\\u>', '<\\\u1234>', '<\n>', '<\\>']
+ endcases = ['', '<\\u>', '<\\\u1234>', '<\n>',
+ '<\\>', '<\\\U00012345>']
for proto in protocols:
for u in endcases:
p = self.dumps(u, proto)
u2 = self.loads(p)
self.assertEqual(u2, u)
+ def test_unicode_high_plane(self):
+ t = '\U00012345'
+ for proto in protocols:
+ p = self.dumps(t, proto)
+ t2 = self.loads(p)
+ self.assertEqual(t2, t)
+
def test_bytes(self):
for proto in protocols:
for u in b'', b'xyz', b'xyz'*100:
Modified: python/branches/py3k-issue1717/Lib/test/test_array.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_array.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_array.py Fri Jan 2 15:30:39 2009
@@ -7,7 +7,7 @@
from test import support
from weakref import proxy
import array, io, math
-from pickle import loads, dumps
+from pickle import loads, dumps, HIGHEST_PROTOCOL
import operator
class ArraySubclass(array.array):
@@ -98,7 +98,7 @@
self.assertEqual(a, b)
def test_pickle(self):
- for protocol in (0, 1, 2):
+ for protocol in range(HIGHEST_PROTOCOL + 1):
a = array.array(self.typecode, self.example)
b = loads(dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
@@ -113,7 +113,7 @@
self.assertEqual(type(a), type(b))
def test_pickle_for_empty_array(self):
- for protocol in (0, 1, 2):
+ for protocol in range(HIGHEST_PROTOCOL + 1):
a = array.array(self.typecode)
b = loads(dumps(a, protocol))
self.assertNotEqual(id(a), id(b))
Modified: python/branches/py3k-issue1717/Lib/test/test_bytes.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_bytes.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_bytes.py Fri Jan 2 15:30:39 2009
@@ -888,11 +888,21 @@
def test_translate(self):
b = b'hello'
+ ba = bytearray(b)
rosetta = bytearray(range(0, 256))
rosetta[ord('o')] = ord('e')
c = b.translate(rosetta, b'l')
self.assertEqual(b, b'hello')
self.assertEqual(c, b'hee')
+ c = ba.translate(rosetta, b'l')
+ self.assertEqual(ba, b'hello')
+ self.assertEqual(c, b'hee')
+ c = b.translate(None, b'e')
+ self.assertEqual(c, b'hllo')
+ c = ba.translate(None, b'e')
+ self.assertEqual(c, b'hllo')
+ self.assertRaises(TypeError, b.translate, None, None)
+ self.assertRaises(TypeError, ba.translate, None, None)
def test_split_bytearray(self):
self.assertEqual(b'a b'.split(memoryview(b' ')), [b'a', b'b'])
Modified: python/branches/py3k-issue1717/Lib/test/test_deque.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_deque.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_deque.py Fri Jan 2 15:30:39 2009
@@ -1,7 +1,8 @@
from collections import deque
import unittest
from test import support, seq_tests
-from weakref import proxy
+import gc
+import weakref
import copy
import pickle
from io import StringIO
@@ -374,7 +375,7 @@
def test_pickle(self):
d = deque(range(200))
- for i in (0, 1, 2):
+ for i in range(pickle.HIGHEST_PROTOCOL + 1):
s = pickle.dumps(d, i)
e = pickle.loads(s)
self.assertNotEqual(id(d), id(e))
@@ -383,7 +384,7 @@
## def test_pickle_recursive(self):
## d = deque('abc')
## d.append(d)
-## for i in (0, 1, 2):
+## for i in range(pickle.HIGHEST_PROTOCOL + 1):
## e = pickle.loads(pickle.dumps(d, i))
## self.assertNotEqual(id(d), id(e))
## self.assertEqual(id(e), id(e[-1]))
@@ -419,6 +420,22 @@
d.append(1)
gc.collect()
+ def test_container_iterator(self):
+ # Bug #3680: tp_traverse was not implemented for deque iterator objects
+ class C(object):
+ pass
+ for i in range(2):
+ obj = C()
+ ref = weakref.ref(obj)
+ if i == 0:
+ container = deque([obj, 1])
+ else:
+ container = reversed(deque([obj, 1]))
+ obj.x = iter(container)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
+
class TestVariousIteratorArgs(unittest.TestCase):
def test_constructor(self):
@@ -529,7 +546,7 @@
def test_weakref(self):
d = deque('gallahad')
- p = proxy(d)
+ p = weakref.proxy(d)
self.assertEqual(str(p), str(d))
d = None
self.assertRaises(ReferenceError, str, p)
Modified: python/branches/py3k-issue1717/Lib/test/test_dict.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_dict.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_dict.py Fri Jan 2 15:30:39 2009
@@ -2,6 +2,7 @@
from test import support
import sys, collections, random, string
+import gc, weakref
class DictTest(unittest.TestCase):
@@ -648,6 +649,21 @@
pass
d = {}
+ def test_container_iterator(self):
+ # Bug #3680: tp_traverse was not implemented for dictiter and
+ # dictview objects.
+ class C(object):
+ pass
+ views = (dict.items, dict.values, dict.keys)
+ for v in views:
+ obj = C()
+ ref = weakref.ref(obj)
+ container = {obj: 1}
+ obj.v = v(container)
+ obj.x = iter(obj.v)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
from test import mapping_tests
Modified: python/branches/py3k-issue1717/Lib/test/test_file.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_file.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_file.py Fri Jan 2 15:30:39 2009
@@ -123,6 +123,8 @@
except:
self.assertEquals(self.f.__exit__(*sys.exc_info()), None)
+ def testReadWhenWriting(self):
+ self.assertRaises(IOError, self.f.read)
class OtherFileTests(unittest.TestCase):
Modified: python/branches/py3k-issue1717/Lib/test/test_fileio.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_fileio.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_fileio.py Fri Jan 2 15:30:39 2009
@@ -108,6 +108,7 @@
_fileio._FileIO('.', 'r')
except IOError as e:
self.assertNotEqual(e.errno, 0)
+ self.assertEqual(e.filename, ".")
else:
self.fail("Should have raised IOError")
Modified: python/branches/py3k-issue1717/Lib/test/test_generators.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_generators.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_generators.py Fri Jan 2 15:30:39 2009
@@ -928,6 +928,16 @@
'f'
>>> repr(g) # doctest: +ELLIPSIS
'<generator object f at ...>'
+
+Lambdas shouldn't have their usual return behavior.
+
+>>> x = lambda: (yield 1)
+>>> list(x())
+[1]
+
+>>> x = lambda: ((yield 1), (yield 2))
+>>> list(x())
+[1, 2]
"""
# conjoin is a simple backtracking generator, named in honor of Icon's
Modified: python/branches/py3k-issue1717/Lib/test/test_hash.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_hash.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_hash.py Fri Jan 2 15:30:39 2009
@@ -97,9 +97,30 @@
self.assertFalse(isinstance(obj, Hashable), repr(obj))
+# Issue #4701: Check that some builtin types are correctly hashable
+class DefaultIterSeq(object):
+ seq = range(10)
+ def __len__(self):
+ return len(self.seq)
+ def __getitem__(self, index):
+ return self.seq[index]
+
+class HashBuiltinsTestCase(unittest.TestCase):
+ hashes_to_check = [range(10),
+ enumerate(range(10)),
+ iter(DefaultIterSeq()),
+ iter(lambda: 0, 0),
+ ]
+
+ def test_hashes(self):
+ _default_hash = object.__hash__
+ for obj in self.hashes_to_check:
+ self.assertEqual(hash(obj), _default_hash(obj))
+
def test_main():
support.run_unittest(HashEqualityTestCase,
- HashInheritanceTestCase)
+ HashInheritanceTestCase,
+ HashBuiltinsTestCase)
if __name__ == "__main__":
Modified: python/branches/py3k-issue1717/Lib/test/test_io.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_io.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_io.py Fri Jan 2 15:30:39 2009
@@ -553,8 +553,9 @@
r = MockRawIO(())
w = MockRawIO()
pair = io.BufferedRWPair(r, w)
+ self.assertFalse(pair.closed)
- # XXX need implementation
+ # XXX More Tests
class BufferedRandomTest(unittest.TestCase):
Modified: python/branches/py3k-issue1717/Lib/test/test_set.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_set.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_set.py Fri Jan 2 15:30:39 2009
@@ -1,6 +1,7 @@
import unittest
from test import support
-from weakref import proxy
+import gc
+import weakref
import operator
import copy
import pickle
@@ -219,7 +220,7 @@
self.failIf(set('cbs').issuperset('a'))
def test_pickling(self):
- for i in (0, 1, 2):
+ for i in range(pickle.HIGHEST_PROTOCOL + 1):
p = pickle.dumps(self.s, i)
dup = pickle.loads(p)
self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup))
@@ -323,6 +324,18 @@
self.assertEqual(sum(elem.hash_count for elem in d), n)
self.assertEqual(d3, dict.fromkeys(d, 123))
+ def test_container_iterator(self):
+ # Bug #3680: tp_traverse was not implemented for set iterator object
+ class C(object):
+ pass
+ obj = C()
+ ref = weakref.ref(obj)
+ container = set([obj, 1])
+ obj.x = iter(container)
+ del obj, container
+ gc.collect()
+ self.assert_(ref() is None, "Cycle was not collected")
+
class TestSet(TestJointOps):
thetype = set
basetype = set
@@ -546,7 +559,7 @@
def test_weakref(self):
s = self.thetype('gallahad')
- p = proxy(s)
+ p = weakref.proxy(s)
self.assertEqual(str(p), str(s))
s = None
self.assertRaises(ReferenceError, str, p)
Modified: python/branches/py3k-issue1717/Lib/test/test_unittest.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_unittest.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_unittest.py Fri Jan 2 15:30:39 2009
@@ -2294,6 +2294,43 @@
self.assertRaises(AssertionError,
self.failIfAlmostEqual, 0, .1+.1j, places=0)
+ def test_assertRaises(self):
+ def _raise(e):
+ raise e
+ self.assertRaises(KeyError, _raise, KeyError)
+ self.assertRaises(KeyError, _raise, KeyError("key"))
+ try:
+ self.assertRaises(KeyError, lambda: None)
+ except AssertionError as e:
+ self.assert_("KeyError not raised" in str(e), str(e))
+ else:
+ self.fail("assertRaises() didn't fail")
+ try:
+ self.assertRaises(KeyError, _raise, ValueError)
+ except ValueError:
+ pass
+ else:
+ self.fail("assertRaises() didn't let exception pass through")
+ with self.assertRaises(KeyError):
+ raise KeyError
+ with self.assertRaises(KeyError):
+ raise KeyError("key")
+ try:
+ with self.assertRaises(KeyError):
+ pass
+ except AssertionError as e:
+ self.assert_("KeyError not raised" in str(e), str(e))
+ else:
+ self.fail("assertRaises() didn't fail")
+ try:
+ with self.assertRaises(KeyError):
+ raise ValueError
+ except ValueError:
+ pass
+ else:
+ self.fail("assertRaises() didn't let exception pass through")
+
+
######################################################################
## Main
######################################################################
Modified: python/branches/py3k-issue1717/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_urllib2.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_urllib2.py Fri Jan 2 15:30:39 2009
@@ -1104,6 +1104,51 @@
else:
self.assert_(False)
+class RequestTests(unittest.TestCase):
+
+ def setUp(self):
+ self.get = Request("http://www.python.org/~jeremy/")
+ self.post = Request("http://www.python.org/~jeremy/",
+ "data",
+ headers={"X-Test": "test"})
+
+ def test_method(self):
+ self.assertEqual("POST", self.post.get_method())
+ self.assertEqual("GET", self.get.get_method())
+
+ def test_add_data(self):
+ self.assert_(not self.get.has_data())
+ self.assertEqual("GET", self.get.get_method())
+ self.get.add_data("spam")
+ self.assert_(self.get.has_data())
+ self.assertEqual("POST", self.get.get_method())
+
+ def test_get_full_url(self):
+ self.assertEqual("http://www.python.org/~jeremy/",
+ self.get.get_full_url())
+
+ def test_selector(self):
+ self.assertEqual("/~jeremy/", self.get.get_selector())
+ req = Request("http://www.python.org/")
+ self.assertEqual("/", req.get_selector())
+
+ def test_get_type(self):
+ self.assertEqual("http", self.get.get_type())
+
+ def test_get_host(self):
+ self.assertEqual("www.python.org", self.get.get_host())
+
+ def test_get_host_unquote(self):
+ req = Request("http://www.%70ython.org/")
+ self.assertEqual("www.python.org", req.get_host())
+
+ def test_proxy(self):
+ self.assert_(not self.get.has_proxy())
+ self.get.set_proxy("www.perl.org", "http")
+ self.assert_(self.get.has_proxy())
+ self.assertEqual("www.python.org", self.get.get_origin_req_host())
+ self.assertEqual("www.perl.org", self.get.get_host())
+
def test_main(verbose=None):
from test import test_urllib2
@@ -1112,7 +1157,8 @@
tests = (TrivialTests,
OpenerDirectorTests,
HandlerTests,
- MiscTests)
+ MiscTests,
+ RequestTests)
support.run_unittest(*tests)
if __name__ == "__main__":
Modified: python/branches/py3k-issue1717/Lib/test/test_zipfile.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/test/test_zipfile.py (original)
+++ python/branches/py3k-issue1717/Lib/test/test_zipfile.py Fri Jan 2 15:30:39 2009
@@ -621,20 +621,49 @@
def testIsZipErroneousFile(self):
# This test checks that the is_zipfile function correctly identifies
# a file that is not a zip file
- fp = open(TESTFN, "w")
- fp.write("this is not a legal zip file\n")
- fp.close()
+
+ # - passing a filename
+ with open(TESTFN, "w") as fp:
+ fp.write("this is not a legal zip file\n")
chk = zipfile.is_zipfile(TESTFN)
- self.assert_(chk is False)
+ self.assert_(not chk)
+ # - passing a file object
+ with open(TESTFN, "rb") as fp:
+ chk = zipfile.is_zipfile(fp)
+ self.assert_(not chk)
+ # - passing a file-like object
+ fp = io.BytesIO()
+ fp.write(b"this is not a legal zip file\n")
+ chk = zipfile.is_zipfile(fp)
+ self.assert_(not chk)
+ fp.seek(0,0)
+ chk = zipfile.is_zipfile(fp)
+ self.assert_(not chk)
def testIsZipValidFile(self):
# This test checks that the is_zipfile function correctly identifies
# a file that is a zip file
+
+ # - passing a filename
zipf = zipfile.ZipFile(TESTFN, mode="w")
zipf.writestr("foo.txt", b"O, for a Muse of Fire!")
zipf.close()
chk = zipfile.is_zipfile(TESTFN)
- self.assert_(chk is True)
+ self.assert_(chk)
+ # - passing a file object
+ with open(TESTFN, "rb") as fp:
+ chk = zipfile.is_zipfile(fp)
+ self.assert_(chk)
+ fp.seek(0,0)
+ zip_contents = fp.read()
+ # - passing a file-like object
+ fp = io.BytesIO()
+ fp.write(zip_contents)
+ chk = zipfile.is_zipfile(fp)
+ self.assert_(chk)
+ fp.seek(0,0)
+ chk = zipfile.is_zipfile(fp)
+ self.assert_(chk)
def testNonExistentFileRaisesIOError(self):
# make sure we don't raise an AttributeError when a partially-constructed
Modified: python/branches/py3k-issue1717/Lib/tkinter/colorchooser.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/tkinter/colorchooser.py (original)
+++ python/branches/py3k-issue1717/Lib/tkinter/colorchooser.py Fri Jan 2 15:30:39 2009
@@ -34,19 +34,22 @@
try:
# make sure initialcolor is a tk color string
color = self.options["initialcolor"]
- if type(color) == type(()):
+ if isinstance(color, tuple):
# assume an RGB triplet
self.options["initialcolor"] = "#%02x%02x%02x" % color
except KeyError:
pass
def _fixresult(self, widget, result):
+ # result can be somethings: an empty tuple, an empty string or
+ # a Tcl_Obj, so this somewhat weird check handles that
+ if not result or not str(result):
+ return None, None # canceled
+
# to simplify application code, the color chooser returns
# an RGB tuple together with the Tk color string
- if not result:
- return None, None # canceled
r, g, b = widget.winfo_rgb(result)
- return (r/256, g/256, b/256), result
+ return (r/256, g/256, b/256), str(result)
#
@@ -66,5 +69,4 @@
# test stuff
if __name__ == "__main__":
-
print("color", askcolor())
Modified: python/branches/py3k-issue1717/Lib/tkinter/filedialog.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/tkinter/filedialog.py (original)
+++ python/branches/py3k-issue1717/Lib/tkinter/filedialog.py Fri Jan 2 15:30:39 2009
@@ -350,7 +350,7 @@
# the directory dialog has its own _fix routines.
-class Directory(Dialog):
+class Directory(commondialog.Dialog):
"Ask for a directory"
command = "tk_chooseDirectory"
Modified: python/branches/py3k-issue1717/Lib/tkinter/scrolledtext.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/tkinter/scrolledtext.py (original)
+++ python/branches/py3k-issue1717/Lib/tkinter/scrolledtext.py Fri Jan 2 15:30:39 2009
@@ -1,42 +1,52 @@
-# A ScrolledText widget feels like a text widget but also has a
-# vertical scroll bar on its right. (Later, options may be added to
-# add a horizontal bar as well, to make the bars disappear
-# automatically when not needed, to move them to the other side of the
-# window, etc.)
-#
-# Configuration options are passed to the Text widget.
-# A Frame widget is inserted between the master and the text, to hold
-# the Scrollbar widget.
-# Most methods calls are inherited from the Text widget; Pack methods
-# are redirected to the Frame widget however.
+"""A ScrolledText widget feels like a text widget but also has a
+vertical scroll bar on its right. (Later, options may be added to
+add a horizontal bar as well, to make the bars disappear
+automatically when not needed, to move them to the other side of the
+window, etc.)
-from tkinter import *
-from tkinter import _cnfmerge
+Configuration options are passed to the Text widget.
+A Frame widget is inserted between the master and the text, to hold
+the Scrollbar widget.
+Most methods calls are inherited from the Text widget; Pack, Grid and
+Place methods are redirected to the Frame widget however.
+"""
-class ScrolledText(Text):
- def __init__(self, master=None, cnf=None, **kw):
- if cnf is None:
- cnf = {}
- if kw:
- cnf = _cnfmerge((cnf, kw))
- fcnf = {k:v for k,v in cnf.items() if isinstance(k,type) or k=='name'}
- for k in fcnf.keys():
- del cnf[k]
+__all__ = ['ScrolledText']
+
+from tkinter import Frame, Text, Scrollbar, Pack, Grid, Place
+from tkinter.constants import RIGHT, LEFT, Y, BOTH
- self.frame = Frame(master, **fcnf)
- self.vbar = Scrollbar(self.frame, name='vbar')
+class ScrolledText(Text):
+ def __init__(self, master=None, **kw):
+ self.frame = Frame(master)
+ self.vbar = Scrollbar(self.frame)
self.vbar.pack(side=RIGHT, fill=Y)
- cnf['name'] = 'text'
- Text.__init__(self, self.frame, **cnf)
- self.pack(side=LEFT, fill=BOTH, expand=1)
- self['yscrollcommand'] = self.vbar.set
+
+ kw.update({'yscrollcommand': self.vbar.set})
+ Text.__init__(self, self.frame, **kw)
+ self.pack(side=LEFT, fill=BOTH, expand=True)
self.vbar['command'] = self.yview
# Copy geometry methods of self.frame -- hack!
- methods = Pack.__dict__.keys()
- methods = methods + Grid.__dict__.keys()
- methods = methods + Place.__dict__.keys()
+ methods = vars(Pack).keys() + vars(Grid).keys() + vars(Place).keys()
for m in methods:
if m[0] != '_' and m != 'config' and m != 'configure':
setattr(self, m, getattr(self.frame, m))
+
+ def __str__(self):
+ return str(self.frame)
+
+
+def example():
+ import __main__
+ from tkinter.constants import END
+
+ stext = ScrolledText(bg='white', height=10)
+ stext.insert(END, __main__.__doc__)
+ stext.pack(fill=BOTH, side=LEFT, expand=True)
+ stext.focus_set()
+ stext.mainloop()
+
+if __name__ == "__main__":
+ example()
Modified: python/branches/py3k-issue1717/Lib/unittest.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/unittest.py (original)
+++ python/branches/py3k-issue1717/Lib/unittest.py Fri Jan 2 15:30:39 2009
@@ -149,6 +149,36 @@
(_strclass(self.__class__), self.testsRun, len(self.errors),
len(self.failures))
+class AssertRaisesContext:
+ def __init__(self, expected, test_case, callable_obj=None):
+ self.expected = expected
+ self.failureException = test_case.failureException
+ if callable_obj is not None:
+ try:
+ self.obj_name = callable_obj.__name__
+ except AttributeError:
+ self.obj_name = str(callable_obj)
+ else:
+ self.obj_name = None
+ def __enter__(self):
+ pass
+ def __exit__(self, exc_type, exc_value, traceback):
+ if exc_type is None:
+ try:
+ exc_name = self.expected.__name__
+ except AttributeError:
+ exc_name = str(self.expected)
+ if self.obj_name:
+ raise self.failureException("{0} not raised by {1}"
+ .format(exc_name, self.obj_name))
+ else:
+ raise self.failureException("{0} not raised"
+ .format(exc_name))
+ if issubclass(exc_type, self.expected):
+ return True
+ # Let unexpected exceptions skip through
+ return False
+
class TestCase:
"""A class whose instances are single test cases.
@@ -299,23 +329,25 @@
"""Fail the test unless the expression is true."""
if not expr: raise self.failureException(msg)
- def failUnlessRaises(self, excClass, callableObj, *args, **kwargs):
+ def failUnlessRaises(self, excClass, callableObj=None, *args, **kwargs):
"""Fail unless an exception of class excClass is thrown
by callableObj when invoked with arguments args and keyword
arguments kwargs. If a different type of exception is
thrown, it will not be caught, and the test case will be
deemed to have suffered an error, exactly as for an
unexpected exception.
+
+ If called with callableObj omitted or None, will return a
+ context object used like this::
+
+ with self.failUnlessRaises(some_error_class):
+ do_something()
"""
- try:
+ context = AssertRaisesContext(excClass, self, callableObj)
+ if callableObj is None:
+ return context
+ with context:
callableObj(*args, **kwargs)
- except excClass:
- return
- else:
- excName = str(getattr(excClass, '__name__', excClass))
- objName = str(getattr(callableObj, '__name__', callableObj))
- raise self.failureException("%s not raised by %s" % (excName,
- objName))
def failUnlessEqual(self, first, second, msg=None):
"""Fail if the two objects are unequal as determined by the '=='
Modified: python/branches/py3k-issue1717/Lib/zipfile.py
==============================================================================
--- python/branches/py3k-issue1717/Lib/zipfile.py (original)
+++ python/branches/py3k-issue1717/Lib/zipfile.py Fri Jan 2 15:30:39 2009
@@ -130,18 +130,30 @@
_CD64_DIRECTORY_SIZE = 8
_CD64_OFFSET_START_CENTDIR = 9
-def is_zipfile(filename):
- """Quickly see if file is a ZIP file by checking the magic number."""
+def _check_zipfile(fp):
try:
- fpin = io.open(filename, "rb")
- endrec = _EndRecData(fpin)
- fpin.close()
- if endrec:
- return True # file has correct magic number
+ if _EndRecData(fp):
+ return True # file has correct magic number
except IOError:
pass
return False
+def is_zipfile(filename):
+ """Quickly see if a file is a ZIP file by checking the magic number.
+
+ The filename argument may be a file or file-like object too.
+ """
+ result = False
+ try:
+ if hasattr(filename, "read"):
+ result = _check_zipfile(fp=filename)
+ else:
+ with open(filename, "rb") as fp:
+ result = _check_zipfile(fp)
+ except IOError:
+ pass
+ return result
+
def _EndRecData64(fpin, offset, endrec):
"""
Read the ZIP64 end-of-archive records and use that to update endrec
Modified: python/branches/py3k-issue1717/Mac/BuildScript/build-installer.py
==============================================================================
--- python/branches/py3k-issue1717/Mac/BuildScript/build-installer.py (original)
+++ python/branches/py3k-issue1717/Mac/BuildScript/build-installer.py Fri Jan 2 15:30:39 2009
@@ -9,8 +9,7 @@
Usage: see USAGE variable in the script.
"""
-import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd
-import urllib.request
+import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd
import grp
INCLUDE_TIMESTAMP = 1
@@ -55,7 +54,7 @@
if 'PY_VERSION' in ln:
return ln.split()[-1][1:-1]
- raise RuntimeError("Cannot find full version??")
+ raise RuntimeError, "Cannot find full version??"
# The directory we'll use to create the build (will be erased and recreated)
WORKDIR = "/tmp/_py"
@@ -170,17 +169,6 @@
getVersion(),
),
),
- dict(
- name="Sleepycat DB 4.7.25",
- url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
- #name="Sleepycat DB 4.3.29",
- #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz",
- buildDir="build_unix",
- configure="../dist/configure",
- configure_pre=[
- '--includedir=/usr/local/include/db4',
- ]
- ),
]
@@ -196,6 +184,7 @@
wrappers for lots of Mac OS X API's.
""",
postflight="scripts/postflight.framework",
+ selected='selected',
),
dict(
name="PythonApplications",
@@ -209,6 +198,7 @@
It also installs a number of examples and demos.
""",
required=False,
+ selected='selected',
),
dict(
name="PythonUnixTools",
@@ -220,6 +210,7 @@
is not necessary to use MacPython.
""",
required=False,
+ selected='unselected',
),
dict(
name="PythonDocumentation",
@@ -234,6 +225,7 @@
""",
postflight="scripts/postflight.documentation",
required=False,
+ selected='selected',
),
dict(
name="PythonProfileChanges",
@@ -251,6 +243,7 @@
topdir="/Library/Frameworks/Python.framework",
source="/empty-dir",
required=False,
+ selected='unselected',
),
dict(
name="PythonSystemFixes",
@@ -264,6 +257,7 @@
topdir="/Library/Frameworks/Python.framework",
source="/empty-dir",
required=False,
+ selected='unselected',
)
]
@@ -292,7 +286,7 @@
xit = fd.close()
if xit is not None:
sys.stdout.write(data)
- raise RuntimeError("command failed: %s"%(commandline,))
+ raise RuntimeError, "command failed: %s"%(commandline,)
if VERBOSE:
sys.stdout.write(data); sys.stdout.flush()
@@ -303,7 +297,7 @@
xit = fd.close()
if xit is not None:
sys.stdout.write(data)
- raise RuntimeError("command failed: %s"%(commandline,))
+ raise RuntimeError, "command failed: %s"%(commandline,)
return data
@@ -336,17 +330,17 @@
try:
options, args = getopt.getopt(args, '?hb',
[ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir='])
- except getopt.error as msg:
- print(msg)
+ except getopt.error, msg:
+ print msg
sys.exit(1)
if args:
- print("Additional arguments")
+ print "Additional arguments"
sys.exit(1)
for k, v in options:
if k in ('-h', '-?'):
- print(USAGE)
+ print USAGE
sys.exit(0)
elif k in ('-d', '--build-dir'):
@@ -362,19 +356,19 @@
SRCDIR=v
else:
- raise NotImplementedError(k)
+ raise NotImplementedError, k
SRCDIR=os.path.abspath(SRCDIR)
WORKDIR=os.path.abspath(WORKDIR)
SDKPATH=os.path.abspath(SDKPATH)
DEPSRC=os.path.abspath(DEPSRC)
- print("Settings:")
- print(" * Source directory:", SRCDIR)
- print(" * Build directory: ", WORKDIR)
- print(" * SDK location: ", SDKPATH)
- print(" * third-party source:", DEPSRC)
- print("")
+ print "Settings:"
+ print " * Source directory:", SRCDIR
+ print " * Build directory: ", WORKDIR
+ print " * SDK location: ", SDKPATH
+ print " * third-party source:", DEPSRC
+ print ""
@@ -419,7 +413,7 @@
xit = fp.close()
if xit is not None:
sys.stdout.write(data)
- raise RuntimeError("Cannot extract %s"%(archiveName,))
+ raise RuntimeError, "Cannot extract %s"%(archiveName,)
return os.path.join(builddir, retval)
@@ -441,9 +435,9 @@
pass
else:
if KNOWNSIZES.get(url) == size:
- print("Using existing file for", url)
+ print "Using existing file for", url
return
- fpIn = urllib.request.urlopen(url)
+ fpIn = urllib2.urlopen(url)
fpOut = open(fname, 'wb')
block = fpIn.read(10240)
try:
@@ -480,14 +474,14 @@
if os.path.exists(sourceArchive):
- print("Using local copy of %s"%(name,))
+ print "Using local copy of %s"%(name,)
else:
- print("Downloading %s"%(name,))
+ print "Downloading %s"%(name,)
downloadURL(url, sourceArchive)
- print("Archive for %s stored as %s"%(name, sourceArchive))
+ print "Archive for %s stored as %s"%(name, sourceArchive)
- print("Extracting archive for %s"%(name,))
+ print "Extracting archive for %s"%(name,)
buildDir=os.path.join(WORKDIR, '_bld')
if not os.path.exists(buildDir):
os.mkdir(buildDir)
@@ -550,14 +544,14 @@
configure_args.insert(0, configure)
configure_args = [ shellQuote(a) for a in configure_args ]
- print("Running configure for %s"%(name,))
+ print "Running configure for %s"%(name,)
runCommand(' '.join(configure_args) + ' 2>&1')
- print("Running install for %s"%(name,))
+ print "Running install for %s"%(name,)
runCommand('{ ' + install + ' ;} 2>&1')
- print("Done %s"%(name,))
- print("")
+ print "Done %s"%(name,)
+ print ""
os.chdir(curdir)
@@ -565,9 +559,9 @@
"""
Build our dependencies into $WORKDIR/libraries/usr/local
"""
- print("")
- print("Building required libraries")
- print("")
+ print ""
+ print "Building required libraries"
+ print ""
universal = os.path.join(WORKDIR, 'libraries')
os.mkdir(universal)
os.makedirs(os.path.join(universal, 'usr', 'local', 'lib'))
@@ -581,7 +575,7 @@
def buildPythonDocs():
# This stores the documentation as Resources/English.lproj/Docuentation
# inside the framwork. pydoc and IDLE will pick it up there.
- print("Install python documentation")
+ print "Install python documentation"
rootDir = os.path.join(WORKDIR, '_root')
version = getVersion()
docdir = os.path.join(rootDir, 'pydocs')
@@ -590,13 +584,13 @@
name = 'html-%s.tar.bz2'%(getFullVersion(),)
sourceArchive = os.path.join(DEPSRC, name)
if os.path.exists(sourceArchive):
- print("Using local copy of %s"%(name,))
+ print "Using local copy of %s"%(name,)
else:
print "Downloading %s"%(novername,)
downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%(
getFullVersion(), novername), sourceArchive)
- print("Archive for %s stored as %s"%(name, sourceArchive))
+ print "Archive for %s stored as %s"%(name, sourceArchive)
extractArchive(os.path.dirname(docdir), sourceArchive)
@@ -607,7 +601,7 @@
def buildPython():
- print("Building a universal python")
+ print "Building a universal python"
buildDir = os.path.join(WORKDIR, '_bld', 'python')
rootDir = os.path.join(WORKDIR, '_root')
@@ -630,24 +624,24 @@
# several paths.
version = getVersion()
- print("Running configure...")
+ print "Running configure..."
runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%(
shellQuote(os.path.join(SRCDIR, 'configure')),
shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1],
shellQuote(WORKDIR)[1:-1]))
- print("Running make")
+ print "Running make"
runCommand("make")
- print("Running make frameworkinstall")
+ print "Running make frameworkinstall"
runCommand("make frameworkinstall DESTDIR=%s"%(
shellQuote(rootDir)))
- print("Running make frameworkinstallextras")
+ print "Running make frameworkinstallextras"
runCommand("make frameworkinstallextras DESTDIR=%s"%(
shellQuote(rootDir)))
- print("Copying required shared libraries")
+ print "Copying required shared libraries"
if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
runCommand("mv %s/* %s"%(
shellQuote(os.path.join(
@@ -658,10 +652,12 @@
'Python.framework', 'Versions', getVersion(),
'lib'))))
- print("Fix file modes")
+ print "Fix file modes"
frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
gid = grp.getgrnam('admin').gr_gid
+
+
for dirpath, dirnames, filenames in os.walk(frmDir):
for dn in dirnames:
os.chmod(os.path.join(dirpath, dn), 0775)
@@ -708,6 +704,11 @@
os.chdir(curdir)
+ # Remove the 'Current' link, that way we don't accidently mess with an already installed
+ # version of python
+ os.unlink(os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework', 'Versions', 'Current'))
+
+
def patchFile(inPath, outPath):
@@ -747,7 +748,7 @@
readme = textwrap.dedent(recipe['readme'])
isRequired = recipe.get('required', True)
- print("- building package %s"%(pkgname,))
+ print "- building package %s"%(pkgname,)
# Substitute some variables
textvars = dict(
@@ -842,7 +843,7 @@
IFPkgFlagPackageList=[
dict(
IFPkgFlagPackageLocation='%s-%s.pkg'%(item['name'], getVersion()),
- IFPkgFlagPackageSelection='selected'
+ IFPkgFlagPackageSelection=item['selected'],
)
for item in PKG_RECIPES
],
@@ -1050,9 +1051,9 @@
shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt'))
fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
- print("# BUILD INFO", file=fp)
- print("# Date:", time.ctime(), file=fp)
- print("# By:", pwd.getpwuid(os.getuid()).pw_gecos, file=fp)
+ print >> fp, "# BUILD INFO"
+ print >> fp, "# Date:", time.ctime()
+ print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos
fp.close()
# Custom icon for the DMG, shown when the DMG is mounted.
Modified: python/branches/py3k-issue1717/Mac/BuildScript/resources/Welcome.rtf
==============================================================================
--- python/branches/py3k-issue1717/Mac/BuildScript/resources/Welcome.rtf (original)
+++ python/branches/py3k-issue1717/Mac/BuildScript/resources/Welcome.rtf Fri Jan 2 15:30:39 2009
@@ -1,18 +1,20 @@
-{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
-{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;}
+{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\fs24 \cf0 This package will install
-\f1\b MacPython $FULL_VERSION
-\f0\b0 for
-\f1\b Mac OS X $MACOSX_DEPLOYMENT_TARGET
-\f0\b0 .\
+\b MacPython $FULL_VERSION
+\b0 for
+\b Mac OS X $MACOSX_DEPLOYMENT_TARGET
+\b0 .\
\
MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, an applet builder), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more).\
\
See the ReadMe file for more information.\
\
-\
-This package will by default update your shell profile to ensure that this version of Python is on the search path of your shell. Please deselect the "Shell profile updater" package on the package customization screen if you want to avoid this modification. }
\ No newline at end of file
+
+\b NOTE:
+\b0 This package will by default update not your shell profile, and will also not install\
+files in /usr/local. }
\ No newline at end of file
Modified: python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/Info.plist
==============================================================================
--- python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/Info.plist (original)
+++ python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/Info.plist Fri Jan 2 15:30:39 2009
@@ -36,7 +36,7 @@
<key>CFBundleExecutable</key>
<string>IDLE</string>
<key>CFBundleGetInfoString</key>
- <string>2.6.0, © 001-2006 Python Software Foundation</string>
+ <string>%version%, © 2001-2008 Python Software Foundation</string>
<key>CFBundleIconFile</key>
<string>IDLE.icns</string>
<key>CFBundleIdentifier</key>
@@ -48,10 +48,10 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
- <string>2.6.0</string>
+ <string>%version%</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
- <string>2.6.0</string>
+ <string>%version%</string>
</dict>
</plist>
Modified: python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/MacOS/IDLE
==============================================================================
--- python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/MacOS/IDLE (original)
+++ python/branches/py3k-issue1717/Mac/IDLE/IDLE.app/Contents/MacOS/IDLE Fri Jan 2 15:30:39 2009
@@ -1,4 +1,4 @@
-#!/Library/Frameworks/Python.framework/Versions/3.0/Resources/Python.app/Contents/MacOS/Python
+#!%prefix%/Resources/Python.app/Contents/MacOS/Python3
import sys, os
execdir = os.path.dirname(sys.argv[0])
Modified: python/branches/py3k-issue1717/Mac/Makefile.in
==============================================================================
--- python/branches/py3k-issue1717/Mac/Makefile.in (original)
+++ python/branches/py3k-issue1717/Mac/Makefile.in Fri Jan 2 15:30:39 2009
@@ -216,8 +216,10 @@
install_IDLE:
test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
- cp -PR IDLE/IDLE.app "$(DESTDIR)$(PYTHONAPPSDIR)"
+ /bin/cp -PR "$(srcdir)/IDLE/IDLE.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
ln -sf $(INSTALLED_PYTHONAPP) "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/Python"
+ sed -e "s!%prefix%!$(prefix)!g" -e 's!%exe%!$(PYTHONFRAMEWORK)!g' < "$(srcdir)/IDLE/IDLE.app/Contents/MacOS/IDLE" > "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/MacOS/IDLE"
+ sed "s!%version%!`$(RUNSHARED) $(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`!g" < "$(srcdir)/IDLE/IDLE.app/Contents/Info.plist" > "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app/Contents/Info.plist"
touch "$(DESTDIR)$(PYTHONAPPSDIR)/IDLE.app"
$(INSTALLED_PYTHONAPP): install_Python
Modified: python/branches/py3k-issue1717/Mac/PythonLauncher/Info.plist.in
==============================================================================
--- python/branches/py3k-issue1717/Mac/PythonLauncher/Info.plist.in (original)
+++ python/branches/py3k-issue1717/Mac/PythonLauncher/Info.plist.in Fri Jan 2 15:30:39 2009
@@ -40,7 +40,7 @@
<key>CFBundleExecutable</key>
<string>PythonLauncher</string>
<key>CFBundleGetInfoString</key>
- <string>%VERSION%, © 001-2006 Python Software Foundation</string>
+ <string>%VERSION%, © 2001-2008 Python Software Foundation</string>
<key>CFBundleIconFile</key>
<string>PythonLauncher.icns</string>
<key>CFBundleIdentifier</key>
Modified: python/branches/py3k-issue1717/Mac/PythonLauncher/Makefile.in
==============================================================================
--- python/branches/py3k-issue1717/Mac/PythonLauncher/Makefile.in (original)
+++ python/branches/py3k-issue1717/Mac/PythonLauncher/Makefile.in Fri Jan 2 15:30:39 2009
@@ -19,13 +19,63 @@
MACOSX_DEPLOYMENT_TARGET=@CONFIGURE_MACOSX_DEPLOYMENT_TARGET@
@EXPORT_MACOSX_DEPLOYMENT_TARGET at export MACOSX_DEPLOYMENT_TARGET
-BUNDLEBULDER=$(srcdir)/../../Lib/plat-mac/bundlebuilder.py
+BUNDLEBULDER=$(srcdir)/../Tools/bundlebuilder.py
PYTHONAPPSDIR=/Applications/$(PYTHONFRAMEWORK) $(VERSION)
OBJECTS=FileSettings.o MyAppDelegate.o MyDocument.o PreferencesWindowController.o doscript.o main.o
-install:
+install: Python\ Launcher.app
test -d "$(DESTDIR)$(PYTHONAPPSDIR)" || mkdir -p "$(DESTDIR)$(PYTHONAPPSDIR)"
-test -d "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app" && rm -r "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
- cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
+ /bin/cp -r "Python Launcher.app" "$(DESTDIR)$(PYTHONAPPSDIR)"
touch "$(DESTDIR)$(PYTHONAPPSDIR)/Python Launcher.app"
+
+
+clean:
+ rm -f *.o "Python Launcher"
+ rm -rf "Python Launcher.app"
+
+Python\ Launcher.app: Info.plist \
+ Python\ Launcher $(srcdir)/../Icons/PythonLauncher.icns \
+ $(srcdir)/../Icons/PythonSource.icns \
+ $(srcdir)/../Icons/PythonCompiled.icns \
+ $(srcdir)/factorySettings.plist
+ rm -fr "Python Launcher.app"
+ $(RUNSHARED) $(BUILDPYTHON) $(BUNDLEBULDER) \
+ --builddir=. \
+ --name="Python Launcher" \
+ --executable="Python Launcher" \
+ --iconfile=$(srcdir)/../Icons/PythonLauncher.icns \
+ --bundle-id=org.python.PythonLauncher \
+ --resource=$(srcdir)/../Icons/PythonSource.icns \
+ --resource=$(srcdir)/../Icons/PythonCompiled.icns \
+ --resource=$(srcdir)/English.lproj \
+ --resource=$(srcdir)/factorySettings.plist \
+ --plist Info.plist \
+ build
+ find "Python Launcher.app" -name '.svn' -print0 | xargs -0 rm -r
+
+
+FileSettings.o: $(srcdir)/FileSettings.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/FileSettings.m
+
+MyAppDelegate.o: $(srcdir)/MyAppDelegate.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyAppDelegate.m
+
+MyDocument.o: $(srcdir)/MyDocument.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/MyDocument.m
+
+PreferencesWindowController.o: $(srcdir)/PreferencesWindowController.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/PreferencesWindowController.m
+
+doscript.o: $(srcdir)/doscript.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/doscript.m
+
+main.o: $(srcdir)/main.m
+ $(CC) $(CFLAGS) -o $@ -c $(srcdir)/main.m
+
+Python\ Launcher: $(OBJECTS)
+ $(CC) $(LDFLAGS) -o "Python Launcher" $(OBJECTS) -framework AppKit -framework Carbon
+
+Info.plist: $(srcdir)/Info.plist.in
+ sed 's/%VERSION%/'"`$(RUNSHARED) $(BUILDPYTHON) -c 'import platform; print(platform.python_version())'`"'/g' < $(srcdir)/Info.plist.in > Info.plist
Modified: python/branches/py3k-issue1717/Mac/Tools/fixapplepython23.py
==============================================================================
--- python/branches/py3k-issue1717/Mac/Tools/fixapplepython23.py (original)
+++ python/branches/py3k-issue1717/Mac/Tools/fixapplepython23.py Fri Jan 2 15:30:39 2009
@@ -14,7 +14,7 @@
"""
import sys
import os
-import gestalt as _gestalt
+import platform
MAKEFILE='/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/config/Makefile'
CHANGES=((
@@ -99,11 +99,12 @@
print("fixapplypython23: no fix is needed on MacOSX on Intel")
sys.exit(0)
- if gestalt.gestalt('sysv') < 0x1030:
+ osver = platform.mac_ver()
+ if osver != '10.3' and os.ver < '10.3.':
print('fixapplepython23: no fix needed on MacOSX < 10.3')
sys.exit(0)
- if gestalt.gestalt('sysv') >= 0x1040:
+ if osver >= '10.4':
print('fixapplepython23: no fix needed on MacOSX >= 10.4')
sys.exit(0)
Modified: python/branches/py3k-issue1717/Makefile.pre.in
==============================================================================
--- python/branches/py3k-issue1717/Makefile.pre.in (original)
+++ python/branches/py3k-issue1717/Makefile.pre.in Fri Jan 2 15:30:39 2009
@@ -899,7 +899,7 @@
export PYTHONPATH; PYTHONPATH="`pwd`/Lib"; \
export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
export EXE; EXE="$(BUILDEXE)"; \
- cd $(srcdir)/Lib/$(PLATDIR); ./regen
+ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
# Install the include files
INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
Modified: python/branches/py3k-issue1717/Misc/NEWS
==============================================================================
--- python/branches/py3k-issue1717/Misc/NEWS (original)
+++ python/branches/py3k-issue1717/Misc/NEWS Fri Jan 2 15:30:39 2009
@@ -19,6 +19,24 @@
The tp_compare slot is reserved for future usage. A type definition
with an assigned tp_compare slot will raise a TypeError.
+- Issue #4747: When the terminal does not use utf-8, executing a script with
+ non-ascii characters in its name could fail with a "SyntaxError: None" error.
+
+- Issue #4797: IOError.filename was not set when _fileio.FileIO failed to open
+ file with `bytes' filename on Windows.
+
+- Issue #3680: Reference cycles created through a dict, set or deque iterator
+ did not get collected.
+
+- Issue #4701: PyObject_Hash now implicitly calls PyType_Ready on types
+ where the tp_hash and tp_dict slots are both NULL.
+
+- Issue #4759: None is now allowed as the first argument of
+ bytearray.translate(). It was always allowed for bytes.translate().
+
+- Added test case to ensure attempts to read from a file opened for writing
+ fail.
+
- Issue #3106: Speedup some comparisons (str/str and int/int).
- Issue #2183: Simplify and optimize bytecode for list, dict and set
@@ -60,9 +78,30 @@
- Issue #4569: Interpreter crash when mutating a memoryview with an item size
larger than 1.
+- Issue #4748: Lambda generators no longer return a value.
+
Library
-------
+- Issue #4702: Throwing a DistutilsPlatformError instead of IOError in case
+ no MSVC compiler is found under Windows. Original patch by Philip Jenvey.
+
+- Issue #4646: distutils was choking on empty options arg in the setup
+ function. Original patch by Thomas Heller.
+
+- Issue #3767: Convert Tk object to string in tkColorChooser.
+
+- Issue #3248: Allow placing ScrolledText in a PanedWindow.
+
+- Issue #4444: Allow assertRaises() to be used as a context handler, so that
+ the code under test can be written inline if more practical.
+
+- Issue #4739: Add pydoc help topics for symbols, so that e.g. help('@')
+ works as expected in the interactive environment.
+
+- Issue #4756: zipfile.is_zipfile() now supports file-like objects. Patch by
+ Gabriel Genellina.
+
- Issue #4574: reading an UTF16-encoded text file crashes if \r on 64-char
boundary.
@@ -135,9 +174,16 @@
support unusual filenames (such as those containing semi-colons) in
Content-Disposition headers.
+Tools/Demos
+-----------
+
+- Issue #4677: add two list comprehension tests to pybench.
+
Extension Modules
-----------------
+- Issue #1040026: Fix os.times result on systems where HZ is incorrect.
+
- Issues #3167, #3682: Fix test_math failures for log, log10 on Solaris,
OpenBSD.
Modified: python/branches/py3k-issue1717/Misc/developers.txt
==============================================================================
--- python/branches/py3k-issue1717/Misc/developers.txt (original)
+++ python/branches/py3k-issue1717/Misc/developers.txt Fri Jan 2 15:30:39 2009
@@ -17,6 +17,9 @@
Permissions History
-------------------
+- Tarek Ziadé as given SVN access on Decmeber 21 2008 by NCN,
+ for maintenance of distutils.
+
- Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
for contributions to the Windows build.
Modified: python/branches/py3k-issue1717/Modules/_collectionsmodule.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/_collectionsmodule.c (original)
+++ python/branches/py3k-issue1717/Modules/_collectionsmodule.c Fri Jan 2 15:30:39 2009
@@ -900,7 +900,7 @@
{
dequeiterobject *it;
- it = PyObject_New(dequeiterobject, &dequeiter_type);
+ it = PyObject_GC_New(dequeiterobject, &dequeiter_type);
if (it == NULL)
return NULL;
it->b = deque->leftblock;
@@ -909,14 +909,22 @@
it->deque = deque;
it->state = deque->state;
it->counter = deque->len;
+ _PyObject_GC_TRACK(it);
return (PyObject *)it;
}
+static int
+dequeiter_traverse(dequeiterobject *dio, visitproc visit, void *arg)
+{
+ Py_VISIT(dio->deque);
+ return 0;
+}
+
static void
dequeiter_dealloc(dequeiterobject *dio)
{
Py_XDECREF(dio->deque);
- Py_TYPE(dio)->tp_free(dio);
+ PyObject_GC_Del(dio);
}
static PyObject *
@@ -981,9 +989,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dequeiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -1002,7 +1010,7 @@
{
dequeiterobject *it;
- it = PyObject_New(dequeiterobject, &dequereviter_type);
+ it = PyObject_GC_New(dequeiterobject, &dequereviter_type);
if (it == NULL)
return NULL;
it->b = deque->rightblock;
@@ -1011,6 +1019,7 @@
it->deque = deque;
it->state = deque->state;
it->counter = deque->len;
+ _PyObject_GC_TRACK(it);
return (PyObject *)it;
}
@@ -1063,9 +1072,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dequeiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
Modified: python/branches/py3k-issue1717/Modules/_fileio.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/_fileio.c (original)
+++ python/branches/py3k-issue1717/Modules/_fileio.c Fri Jan 2 15:30:39 2009
@@ -116,7 +116,7 @@
directories, so we need a check. */
static int
-dircheck(PyFileIOObject* self)
+dircheck(PyFileIOObject* self, char *name)
{
#if defined(HAVE_FSTAT) && defined(S_IFDIR) && defined(EISDIR)
struct stat buf;
@@ -128,8 +128,8 @@
if (internal_close(self))
return -1;
- exc = PyObject_CallFunction(PyExc_IOError, "(is)",
- EISDIR, msg);
+ exc = PyObject_CallFunction(PyExc_IOError, "(iss)",
+ EISDIR, msg, name);
PyErr_SetObject(PyExc_IOError, exc);
Py_XDECREF(exc);
return -1;
@@ -284,13 +284,14 @@
Py_END_ALLOW_THREADS
if (self->fd < 0) {
#ifdef MS_WINDOWS
- PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
-#else
- PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
+ if (widename != NULL)
+ PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
+ else
#endif
+ PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
goto error;
}
- if(dircheck(self) < 0)
+ if(dircheck(self, name) < 0)
goto error;
}
Modified: python/branches/py3k-issue1717/Modules/_pickle.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/_pickle.c (original)
+++ python/branches/py3k-issue1717/Modules/_pickle.c Fri Jan 2 15:30:39 2009
@@ -1109,16 +1109,21 @@
static const char *hexdigits = "0123456789abcdef";
#ifdef Py_UNICODE_WIDE
- repr = PyBytes_FromStringAndSize(NULL, 10 * size);
+ const Py_ssize_t expandsize = 10;
#else
- repr = PyBytes_FromStringAndSize(NULL, 6 * size);
+ const Py_ssize_t expandsize = 6;
#endif
+
+ if (size > PY_SSIZE_T_MAX / expandsize)
+ return PyErr_NoMemory();
+
+ repr = PyByteArray_FromStringAndSize(NULL, expandsize * size);
if (repr == NULL)
return NULL;
if (size == 0)
goto done;
- p = q = PyBytes_AS_STRING(repr);
+ p = q = PyByteArray_AS_STRING(repr);
while (size-- > 0) {
Py_UNICODE ch = *s++;
#ifdef Py_UNICODE_WIDE
@@ -1136,6 +1141,32 @@
*p++ = hexdigits[ch & 15];
}
else
+#else
+ /* Map UTF-16 surrogate pairs to '\U00xxxxxx' */
+ if (ch >= 0xD800 && ch < 0xDC00) {
+ Py_UNICODE ch2;
+ Py_UCS4 ucs;
+
+ ch2 = *s++;
+ size--;
+ if (ch2 >= 0xDC00 && ch2 <= 0xDFFF) {
+ ucs = (((ch & 0x03FF) << 10) | (ch2 & 0x03FF)) + 0x00010000;
+ *p++ = '\\';
+ *p++ = 'U';
+ *p++ = hexdigits[(ucs >> 28) & 0xf];
+ *p++ = hexdigits[(ucs >> 24) & 0xf];
+ *p++ = hexdigits[(ucs >> 20) & 0xf];
+ *p++ = hexdigits[(ucs >> 16) & 0xf];
+ *p++ = hexdigits[(ucs >> 12) & 0xf];
+ *p++ = hexdigits[(ucs >> 8) & 0xf];
+ *p++ = hexdigits[(ucs >> 4) & 0xf];
+ *p++ = hexdigits[ucs & 0xf];
+ continue;
+ }
+ /* Fall through: isolated surrogates are copied as-is */
+ s--;
+ size++;
+ }
#endif
/* Map 16-bit characters to '\uxxxx' */
if (ch >= 256 || ch == '\\' || ch == '\n') {
@@ -1146,14 +1177,14 @@
*p++ = hexdigits[(ch >> 4) & 0xf];
*p++ = hexdigits[ch & 15];
}
- /* Copy everything else as-is */
+ /* Copy everything else as-is */
else
*p++ = (char) ch;
}
size = p - q;
done:
- result = PyBytes_FromStringAndSize(PyBytes_AS_STRING(repr), size);
+ result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(repr), size);
Py_DECREF(repr);
return result;
}
Modified: python/branches/py3k-issue1717/Modules/_testcapimodule.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/_testcapimodule.c (original)
+++ python/branches/py3k-issue1717/Modules/_testcapimodule.c Fri Jan 2 15:30:39 2009
@@ -175,6 +175,105 @@
}
+/* Issue #4701: Check that PyObject_Hash implicitly calls
+ * PyType_Ready if it hasn't already been called
+ */
+static PyTypeObject _HashInheritanceTester_Type = {
+ PyVarObject_HEAD_INIT(NULL, 0)
+ "hashinheritancetester", /* Name of this type */
+ sizeof(PyObject), /* Basic object size */
+ 0, /* Item size for varobject */
+ (destructor)PyObject_Del, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ PyType_GenericNew, /* tp_new */
+};
+
+static PyObject*
+test_lazy_hash_inheritance(PyObject* self)
+{
+ PyTypeObject *type;
+ PyObject *obj;
+ long hash;
+
+ type = &_HashInheritanceTester_Type;
+ obj = PyObject_New(PyObject, type);
+ if (obj == NULL) {
+ PyErr_Clear();
+ PyErr_SetString(
+ TestError,
+ "test_lazy_hash_inheritance: failed to create object");
+ return NULL;
+ }
+
+ if (type->tp_dict != NULL) {
+ PyErr_SetString(
+ TestError,
+ "test_lazy_hash_inheritance: type initialised too soon");
+ Py_DECREF(obj);
+ return NULL;
+ }
+
+ hash = PyObject_Hash(obj);
+ if ((hash == -1) && PyErr_Occurred()) {
+ PyErr_Clear();
+ PyErr_SetString(
+ TestError,
+ "test_lazy_hash_inheritance: could not hash object");
+ Py_DECREF(obj);
+ return NULL;
+ }
+
+ if (type->tp_dict == NULL) {
+ PyErr_SetString(
+ TestError,
+ "test_lazy_hash_inheritance: type not initialised by hash()");
+ Py_DECREF(obj);
+ return NULL;
+ }
+
+ if (type->tp_hash != PyType_Type.tp_hash) {
+ PyErr_SetString(
+ TestError,
+ "test_lazy_hash_inheritance: unexpected hash function");
+ Py_DECREF(obj);
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+
/* Tests of PyLong_{As, From}{Unsigned,}Long(), and (#ifdef HAVE_LONG_LONG)
PyLong_{As, From}{Unsigned,}LongLong().
@@ -508,6 +607,8 @@
Py_RETURN_NONE;
}
+static volatile int x;
+
/* Test the u and u# codes for PyArg_ParseTuple. May leak memory in case
of an error.
*/
@@ -522,7 +623,6 @@
/* issue4122: Undefined reference to _Py_ascii_whitespace on Windows */
/* Just use the macro and check that it compiles */
x = Py_UNICODE_ISSPACE(25);
- x = x;
tuple = PyTuple_New(1);
if (tuple == NULL)
@@ -608,6 +708,32 @@
}
static PyObject *
+test_empty_argparse(PyObject *self)
+{
+ /* Test that formats can begin with '|'. See issue #4720. */
+ PyObject *tuple, *dict = NULL;
+ static char *kwlist[] = {NULL};
+ int result;
+ tuple = PyTuple_New(0);
+ if (!tuple)
+ return NULL;
+ if ((result = PyArg_ParseTuple(tuple, "|:test_empty_argparse")) < 0)
+ goto done;
+ dict = PyDict_New();
+ if (!dict)
+ goto done;
+ result = PyArg_ParseTupleAndKeywords(tuple, dict, "|:test_empty_argparse", kwlist);
+ done:
+ Py_DECREF(tuple);
+ Py_XDECREF(dict);
+ if (result < 0)
+ return NULL;
+ else {
+ Py_RETURN_NONE;
+ }
+}
+
+static PyObject *
codec_incrementalencoder(PyObject *self, PyObject *args)
{
const char *encoding, *errors = NULL;
@@ -1009,9 +1135,11 @@
{"test_config", (PyCFunction)test_config, METH_NOARGS},
{"test_list_api", (PyCFunction)test_list_api, METH_NOARGS},
{"test_dict_iteration", (PyCFunction)test_dict_iteration,METH_NOARGS},
+ {"test_lazy_hash_inheritance", (PyCFunction)test_lazy_hash_inheritance,METH_NOARGS},
{"test_long_api", (PyCFunction)test_long_api, METH_NOARGS},
{"test_long_numbits", (PyCFunction)test_long_numbits, METH_NOARGS},
{"test_k_code", (PyCFunction)test_k_code, METH_NOARGS},
+ {"test_empty_argparse", (PyCFunction)test_empty_argparse,METH_NOARGS},
{"test_null_strings", (PyCFunction)test_null_strings, METH_NOARGS},
{"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS},
{"test_with_docstring", (PyCFunction)test_with_docstring, METH_NOARGS,
@@ -1211,6 +1339,8 @@
if (m == NULL)
return NULL;
+ Py_TYPE(&_HashInheritanceTester_Type)=&PyType_Type;
+
Py_TYPE(&test_structmembersType)=&PyType_Type;
Py_INCREF(&test_structmembersType);
PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType);
Modified: python/branches/py3k-issue1717/Modules/main.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/main.c (original)
+++ python/branches/py3k-issue1717/Modules/main.c Fri Jan 2 15:30:39 2009
@@ -600,18 +600,21 @@
}
if (sts==-1) {
- char cfilename[PATH_MAX];
+ PyObject *filenameObj = NULL;
char *p_cfilename = "<stdin>";
if (filename) {
- size_t r = wcstombs(cfilename, filename, PATH_MAX);
- p_cfilename = cfilename;
- if (r == (size_t)-1 || r >= PATH_MAX)
+ filenameObj = PyUnicode_FromWideChar(
+ filename, wcslen(filename));
+ if (filenameObj != NULL)
+ p_cfilename = _PyUnicode_AsString(filenameObj);
+ else
p_cfilename = "<decoding error>";
}
sts = PyRun_AnyFileExFlags(
fp,
p_cfilename,
filename != NULL, &cf) != 0;
+ Py_XDECREF(filenameObj);
}
}
Modified: python/branches/py3k-issue1717/Modules/mathmodule.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/mathmodule.c (original)
+++ python/branches/py3k-issue1717/Modules/mathmodule.c Fri Jan 2 15:30:39 2009
@@ -685,7 +685,10 @@
return NULL;
}
-PyDoc_STRVAR(math_factorial_doc, "Return n!");
+PyDoc_STRVAR(math_factorial_doc,
+"factorial(x) -> Integral\n"
+"\n"
+"Find x!. Raise a ValueError if x is negative or non-integral.");
static PyObject *
math_trunc(PyObject *self, PyObject *number)
@@ -837,7 +840,7 @@
"modf(x)\n"
"\n"
"Return the fractional and integer parts of x. Both results carry the sign\n"
-"of x. The integer part is returned as a real.");
+"of x and are floats.");
/* A decent logarithm is easy to compute even for huge longs, but libm can't
do that by itself -- loghelper can. func is log or log10, and name is
Modified: python/branches/py3k-issue1717/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k-issue1717/Modules/posixmodule.c (original)
+++ python/branches/py3k-issue1717/Modules/posixmodule.c Fri Jan 2 15:30:39 2009
@@ -4494,10 +4494,6 @@
#ifdef HAVE_TIMES
-#ifndef HZ
-#define HZ 60 /* Universal constant :-) */
-#endif /* HZ */
-
#if defined(PYCC_VACPP) && defined(PYOS_OS2)
static long
system_uptime(void)
@@ -4523,6 +4519,8 @@
(double)system_uptime() / 1000);
}
#else /* not OS2 */
+#define NEED_TICKS_PER_SECOND
+static long ticks_per_second = -1;
static PyObject *
posix_times(PyObject *self, PyObject *noargs)
{
@@ -4533,11 +4531,11 @@
if (c == (clock_t) -1)
return posix_error();
return Py_BuildValue("ddddd",
- (double)t.tms_utime / HZ,
- (double)t.tms_stime / HZ,
- (double)t.tms_cutime / HZ,
- (double)t.tms_cstime / HZ,
- (double)c / HZ);
+ (double)t.tms_utime / ticks_per_second,
+ (double)t.tms_stime / ticks_per_second,
+ (double)t.tms_cutime / ticks_per_second,
+ (double)t.tms_cstime / ticks_per_second,
+ (double)c / ticks_per_second);
}
#endif /* not OS2 */
#endif /* HAVE_TIMES */
@@ -7409,6 +7407,15 @@
statvfs_result_desc.name = MODNAME ".statvfs_result";
PyStructSequence_InitType(&StatVFSResultType, &statvfs_result_desc);
+#ifdef NEED_TICKS_PER_SECOND
+# if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
+ ticks_per_second = sysconf(_SC_CLK_TCK);
+# elif defined(HZ)
+ ticks_per_second = HZ;
+# else
+ ticks_per_second = 60; /* magic fallback value; may be bogus */
+# endif
+#endif
}
Py_INCREF((PyObject*) &StatResultType);
PyModule_AddObject(m, "stat_result", (PyObject*) &StatResultType);
Modified: python/branches/py3k-issue1717/Objects/bytearrayobject.c
==============================================================================
--- python/branches/py3k-issue1717/Objects/bytearrayobject.c (original)
+++ python/branches/py3k-issue1717/Objects/bytearrayobject.c Fri Jan 2 15:30:39 2009
@@ -1371,28 +1371,32 @@
PyObject *input_obj = (PyObject*)self;
const char *output_start;
Py_ssize_t inlen;
- PyObject *result;
+ PyObject *result = NULL;
int trans_table[256];
- PyObject *tableobj, *delobj = NULL;
+ PyObject *tableobj = NULL, *delobj = NULL;
Py_buffer vtable, vdel;
if (!PyArg_UnpackTuple(args, "translate", 1, 2,
&tableobj, &delobj))
return NULL;
- if (_getbuffer(tableobj, &vtable) < 0)
+ if (tableobj == Py_None) {
+ table = NULL;
+ tableobj = NULL;
+ } else if (_getbuffer(tableobj, &vtable) < 0) {
return NULL;
-
- if (vtable.len != 256) {
- PyErr_SetString(PyExc_ValueError,
- "translation table must be 256 characters long");
- result = NULL;
- goto done;
+ } else {
+ if (vtable.len != 256) {
+ PyErr_SetString(PyExc_ValueError,
+ "translation table must be 256 characters long");
+ goto done;
+ }
+ table = (const char*)vtable.buf;
}
if (delobj != NULL) {
if (_getbuffer(delobj, &vdel) < 0) {
- result = NULL;
+ delobj = NULL; /* don't try to release vdel buffer on exit */
goto done;
}
}
@@ -1401,7 +1405,6 @@
vdel.len = 0;
}
- table = (const char *)vtable.buf;
inlen = PyByteArray_GET_SIZE(input_obj);
result = PyByteArray_FromStringAndSize((char *)NULL, inlen);
if (result == NULL)
@@ -1409,7 +1412,7 @@
output_start = output = PyByteArray_AsString(result);
input = PyByteArray_AS_STRING(input_obj);
- if (vdel.len == 0) {
+ if (vdel.len == 0 && table != NULL) {
/* If no deletions are required, use faster code */
for (i = inlen; --i >= 0; ) {
c = Py_CHARMASK(*input++);
@@ -1417,9 +1420,14 @@
}
goto done;
}
-
- for (i = 0; i < 256; i++)
- trans_table[i] = Py_CHARMASK(table[i]);
+
+ if (table == NULL) {
+ for (i = 0; i < 256; i++)
+ trans_table[i] = Py_CHARMASK(i);
+ } else {
+ for (i = 0; i < 256; i++)
+ trans_table[i] = Py_CHARMASK(table[i]);
+ }
for (i = 0; i < vdel.len; i++)
trans_table[(int) Py_CHARMASK( ((unsigned char*)vdel.buf)[i] )] = -1;
@@ -1435,7 +1443,8 @@
PyByteArray_Resize(result, output - output_start);
done:
- PyBuffer_Release(&vtable);
+ if (tableobj != NULL)
+ PyBuffer_Release(&vtable);
if (delobj != NULL)
PyBuffer_Release(&vdel);
return result;
Modified: python/branches/py3k-issue1717/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k-issue1717/Objects/bytesobject.c (original)
+++ python/branches/py3k-issue1717/Objects/bytesobject.c Fri Jan 2 15:30:39 2009
@@ -1892,11 +1892,6 @@
del_table = PyBytes_AS_STRING(delobj);
dellen = PyBytes_GET_SIZE(delobj);
}
- else if (PyUnicode_Check(delobj)) {
- PyErr_SetString(PyExc_TypeError,
- "deletions are implemented differently for unicode");
- return NULL;
- }
else if (PyObject_AsCharBuffer(delobj, &del_table, &dellen))
return NULL;
}
Modified: python/branches/py3k-issue1717/Objects/dictobject.c
==============================================================================
--- python/branches/py3k-issue1717/Objects/dictobject.c (original)
+++ python/branches/py3k-issue1717/Objects/dictobject.c Fri Jan 2 15:30:39 2009
@@ -2122,7 +2122,7 @@
dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
{
dictiterobject *di;
- di = PyObject_New(dictiterobject, itertype);
+ di = PyObject_GC_New(dictiterobject, itertype);
if (di == NULL)
return NULL;
Py_INCREF(dict);
@@ -2139,6 +2139,7 @@
}
else
di->di_result = NULL;
+ _PyObject_GC_TRACK(di);
return (PyObject *)di;
}
@@ -2147,7 +2148,15 @@
{
Py_XDECREF(di->di_dict);
Py_XDECREF(di->di_result);
- PyObject_Del(di);
+ PyObject_GC_Del(di);
+}
+
+static int
+dictiter_traverse(dictiterobject *di, visitproc visit, void *arg)
+{
+ Py_VISIT(di->di_dict);
+ Py_VISIT(di->di_result);
+ return 0;
}
static PyObject *
@@ -2228,9 +2237,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2300,9 +2309,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2386,9 +2395,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2415,7 +2424,14 @@
dictview_dealloc(dictviewobject *dv)
{
Py_XDECREF(dv->dv_dict);
- PyObject_Del(dv);
+ PyObject_GC_Del(dv);
+}
+
+static int
+dictview_traverse(dictviewobject *dv, visitproc visit, void *arg)
+{
+ Py_VISIT(dv->dv_dict);
+ return 0;
}
static Py_ssize_t
@@ -2442,11 +2458,12 @@
type->tp_name, dict->ob_type->tp_name);
return NULL;
}
- dv = PyObject_New(dictviewobject, type);
+ dv = PyObject_GC_New(dictviewobject, type);
if (dv == NULL)
return NULL;
Py_INCREF(dict);
dv->dv_dict = (PyDictObject *)dict;
+ _PyObject_GC_TRACK(dv);
return (PyObject *)dv;
}
@@ -2693,9 +2710,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictview_traverse, /* tp_traverse */
0, /* tp_clear */
dictview_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2777,9 +2794,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictview_traverse, /* tp_traverse */
0, /* tp_clear */
dictview_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -2842,9 +2859,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)dictview_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
Modified: python/branches/py3k-issue1717/Objects/object.c
==============================================================================
--- python/branches/py3k-issue1717/Objects/object.c (original)
+++ python/branches/py3k-issue1717/Objects/object.c Fri Jan 2 15:30:39 2009
@@ -344,8 +344,11 @@
if (op == NULL)
fprintf(stderr, "NULL\n");
else {
+ PyGILState_STATE gil;
fprintf(stderr, "object : ");
+ gil = PyGILState_Ensure();
(void)PyObject_Print(op, stderr, 0);
+ PyGILState_Release(gil);
/* XXX(twouters) cast refcount to long until %zd is
universally available */
fprintf(stderr, "\n"
@@ -724,6 +727,17 @@
PyTypeObject *tp = Py_TYPE(v);
if (tp->tp_hash != NULL)
return (*tp->tp_hash)(v);
+ /* To keep to the general practice that inheriting
+ * solely from object in C code should work without
+ * an explicit call to PyType_Ready, we implicitly call
+ * PyType_Ready here and then check the tp_hash slot again
+ */
+ if (tp->tp_dict == NULL) {
+ if (PyType_Ready(tp) < 0)
+ return -1;
+ if (tp->tp_hash != NULL)
+ return (*tp->tp_hash)(v);
+ }
/* Otherwise, the object can't be hashed */
return PyObject_HashNotImplemented(v);
}
Modified: python/branches/py3k-issue1717/Objects/setobject.c
==============================================================================
--- python/branches/py3k-issue1717/Objects/setobject.c (original)
+++ python/branches/py3k-issue1717/Objects/setobject.c Fri Jan 2 15:30:39 2009
@@ -802,7 +802,14 @@
setiter_dealloc(setiterobject *si)
{
Py_XDECREF(si->si_set);
- PyObject_Del(si);
+ PyObject_GC_Del(si);
+}
+
+static int
+setiter_traverse(setiterobject *si, visitproc visit, void *arg)
+{
+ Py_VISIT(si->si_set);
+ return 0;
}
static PyObject *
@@ -880,9 +887,9 @@
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
- Py_TPFLAGS_DEFAULT, /* tp_flags */
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
0, /* tp_doc */
- 0, /* tp_traverse */
+ (traverseproc)setiter_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
@@ -895,7 +902,7 @@
static PyObject *
set_iter(PySetObject *so)
{
- setiterobject *si = PyObject_New(setiterobject, &PySetIter_Type);
+ setiterobject *si = PyObject_GC_New(setiterobject, &PySetIter_Type);
if (si == NULL)
return NULL;
Py_INCREF(so);
@@ -903,6 +910,7 @@
si->si_used = so->used;
si->si_pos = 0;
si->len = so->used;
+ _PyObject_GC_TRACK(si);
return (PyObject *)si;
}
Modified: python/branches/py3k-issue1717/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-issue1717/Objects/unicodeobject.c (original)
+++ python/branches/py3k-issue1717/Objects/unicodeobject.c Fri Jan 2 15:30:39 2009
@@ -418,7 +418,8 @@
}
}
-int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length)
+static
+int _PyUnicode_Resize(PyUnicodeObject **unicode, Py_ssize_t length)
{
register PyUnicodeObject *v;
@@ -427,7 +428,7 @@
PyErr_BadInternalCall();
return -1;
}
- v = (PyUnicodeObject *)*unicode;
+ v = *unicode;
if (v == NULL || !PyUnicode_Check(v) || Py_REFCNT(v) != 1 || length < 0) {
PyErr_BadInternalCall();
return -1;
@@ -444,7 +445,7 @@
Py_UNICODE_COPY(w->str, v->str,
length < v->length ? length : v->length);
Py_DECREF(*unicode);
- *unicode = (PyObject *)w;
+ *unicode = w;
return 0;
}
@@ -453,9 +454,10 @@
return unicode_resize(v, length);
}
-/* Internal API for use in unicodeobject.c only ! */
-#define _PyUnicode_Resize(unicodevar, length) \
- PyUnicode_Resize(((PyObject **)(unicodevar)), length)
+int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length)
+{
+ return _PyUnicode_Resize((PyUnicodeObject **)unicode, length);
+}
PyObject *PyUnicode_FromUnicode(const Py_UNICODE *u,
Py_ssize_t size)
@@ -989,7 +991,7 @@
PyObject_Free(callresults);
if (abuffer)
PyObject_Free(abuffer);
- _PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string));
+ PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string));
return string;
fail:
if (callresults) {
@@ -1549,7 +1551,7 @@
const char *encoding, const char *reason,
const char **input, const char **inend, Py_ssize_t *startinpos,
Py_ssize_t *endinpos, PyObject **exceptionObject, const char **inptr,
- PyObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr)
+ PyUnicodeObject **output, Py_ssize_t *outpos, Py_UNICODE **outptr)
{
static char *argparse = "O!n;decoding error handler must return (str, int) tuple";
@@ -1627,7 +1629,7 @@
if (requiredsize > outsize) {
if (requiredsize<2*outsize)
requiredsize = 2*outsize;
- if (PyUnicode_Resize(output, requiredsize) < 0)
+ if (_PyUnicode_Resize(output, requiredsize) < 0)
goto onError;
*outptr = PyUnicode_AS_UNICODE(*output) + *outpos;
}
@@ -1827,7 +1829,7 @@
errors, &errorHandler,
"utf7", errmsg,
&starts, &e, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&unicode, &outpos, &p))
+ &unicode, &outpos, &p))
goto onError;
}
@@ -1838,7 +1840,7 @@
errors, &errorHandler,
"utf7", "unterminated shift sequence",
&starts, &e, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&unicode, &outpos, &p))
+ &unicode, &outpos, &p))
goto onError;
if (s < e)
goto restart;
@@ -1871,7 +1873,7 @@
int encodeWhiteSpace,
const char *errors)
{
- PyObject *v, *result;
+ PyObject *v;
/* It might be possible to tighten this worst case */
Py_ssize_t cbAllocated = 5 * size;
int inShift = 0;
@@ -1887,11 +1889,11 @@
if (cbAllocated / 5 != size)
return PyErr_NoMemory();
- v = PyByteArray_FromStringAndSize(NULL, cbAllocated);
+ v = PyBytes_FromStringAndSize(NULL, cbAllocated);
if (v == NULL)
return NULL;
- start = out = PyByteArray_AS_STRING(v);
+ start = out = PyBytes_AS_STRING(v);
for (;i < size; ++i) {
Py_UNICODE ch = s[i];
@@ -1956,10 +1958,9 @@
*out++= B64(charsleft << (6-bitsleft) );
*out++ = '-';
}
-
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), out - start);
- Py_DECREF(v);
- return result;
+ if (_PyBytes_Resize(&v, out - start) < 0)
+ return NULL;
+ return v;
}
#undef SPECIAL
@@ -2166,7 +2167,7 @@
errors, &errorHandler,
"utf8", errmsg,
&starts, &e, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&unicode, &outpos, &p))
+ &unicode, &outpos, &p))
goto onError;
}
if (consumed)
@@ -2446,7 +2447,7 @@
errors, &errorHandler,
"utf32", errmsg,
&starts, (const char **)&e, &startinpos, &endinpos, &exc, (const char **)&q,
- (PyObject **)&unicode, &outpos, &p))
+ &unicode, &outpos, &p))
goto onError;
}
@@ -2477,7 +2478,7 @@
const char *errors,
int byteorder)
{
- PyObject *v, *result;
+ PyObject *v;
unsigned char *p;
Py_ssize_t nsize, bytesize;
#ifndef Py_UNICODE_WIDE
@@ -2513,11 +2514,11 @@
bytesize = nsize * 4;
if (bytesize / 4 != nsize)
return PyErr_NoMemory();
- v = PyByteArray_FromStringAndSize(NULL, bytesize);
+ v = PyBytes_FromStringAndSize(NULL, bytesize);
if (v == NULL)
return NULL;
- p = (unsigned char *)PyByteArray_AS_STRING(v);
+ p = (unsigned char *)PyBytes_AS_STRING(v);
if (byteorder == 0)
STORECHAR(0xFEFF);
if (size == 0)
@@ -2554,9 +2555,7 @@
}
done:
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
- Py_DECREF(v);
- return result;
+ return v;
#undef STORECHAR
}
@@ -2724,7 +2723,7 @@
errors, &errorHandler,
"utf16", errmsg,
&starts, (const char **)&e, &startinpos, &endinpos, &exc, (const char **)&q,
- (PyObject **)&unicode, &outpos, &p))
+ &unicode, &outpos, &p))
goto onError;
}
@@ -2755,7 +2754,7 @@
const char *errors,
int byteorder)
{
- PyObject *v, *result;
+ PyObject *v;
unsigned char *p;
Py_ssize_t nsize, bytesize;
#ifdef Py_UNICODE_WIDE
@@ -2790,11 +2789,11 @@
bytesize = nsize * 2;
if (bytesize / 2 != nsize)
return PyErr_NoMemory();
- v = PyByteArray_FromStringAndSize(NULL, bytesize);
+ v = PyBytes_FromStringAndSize(NULL, bytesize);
if (v == NULL)
return NULL;
- p = (unsigned char *)PyByteArray_AS_STRING(v);
+ p = (unsigned char *)PyBytes_AS_STRING(v);
if (byteorder == 0)
STORECHAR(0xFEFF);
if (size == 0)
@@ -2826,9 +2825,7 @@
}
done:
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(v), Py_SIZE(v));
- Py_DECREF(v);
- return result;
+ return v;
#undef STORECHAR
}
@@ -2949,7 +2946,7 @@
errors, &errorHandler,
"unicodeescape", "end of string in escape sequence",
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
goto nextByte;
}
@@ -2961,7 +2958,7 @@
errors, &errorHandler,
"unicodeescape", message,
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
goto nextByte;
}
@@ -3000,7 +2997,7 @@
errors, &errorHandler,
"unicodeescape", "illegal Unicode character",
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
}
break;
@@ -3042,7 +3039,7 @@
errors, &errorHandler,
"unicodeescape", message,
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
break;
@@ -3056,7 +3053,7 @@
errors, &errorHandler,
"unicodeescape", message,
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
}
else {
@@ -3118,7 +3115,7 @@
PyObject *PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s,
Py_ssize_t size)
{
- PyObject *repr, *result;
+ PyObject *repr;
char *p;
#ifdef Py_UNICODE_WIDE
@@ -3145,17 +3142,20 @@
escape.
*/
+ if (size == 0)
+ return PyBytes_FromStringAndSize(NULL, 0);
+
if (size > (PY_SSIZE_T_MAX - 2 - 1) / expandsize)
return PyErr_NoMemory();
- repr = PyByteArray_FromStringAndSize(NULL,
+ repr = PyBytes_FromStringAndSize(NULL,
2
+ expandsize*size
+ 1);
if (repr == NULL)
return NULL;
- p = PyByteArray_AS_STRING(repr);
+ p = PyBytes_AS_STRING(repr);
while (size-- > 0) {
Py_UNICODE ch = *s++;
@@ -3247,28 +3247,22 @@
*p++ = (char) ch;
}
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(repr),
- p - PyByteArray_AS_STRING(repr));
- Py_DECREF(repr);
- return result;
+ assert(p - PyBytes_AS_STRING(repr) > 0);
+ if (_PyBytes_Resize(&repr, p - PyBytes_AS_STRING(repr)) < 0)
+ return NULL;
+ return repr;
}
PyObject *PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
{
- PyObject *s, *result;
+ PyObject *s;
if (!PyUnicode_Check(unicode)) {
PyErr_BadArgument();
return NULL;
}
s = PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(unicode),
PyUnicode_GET_SIZE(unicode));
-
- if (!s)
- return NULL;
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(s),
- PyByteArray_GET_SIZE(s));
- Py_DECREF(s);
- return result;
+ return s;
}
/* --- Raw Unicode Escape Codec ------------------------------------------- */
@@ -3339,7 +3333,7 @@
errors, &errorHandler,
"rawunicodeescape", "truncated \\uXXXX",
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
goto nextByte;
}
@@ -3371,7 +3365,7 @@
errors, &errorHandler,
"rawunicodeescape", "\\Uxxxxxxxx out of range",
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
}
nextByte:
@@ -3393,7 +3387,7 @@
PyObject *PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s,
Py_ssize_t size)
{
- PyObject *repr, *result;
+ PyObject *repr;
char *p;
char *q;
@@ -3406,13 +3400,13 @@
if (size > PY_SSIZE_T_MAX / expandsize)
return PyErr_NoMemory();
- repr = PyByteArray_FromStringAndSize(NULL, expandsize * size);
+ repr = PyBytes_FromStringAndSize(NULL, expandsize * size);
if (repr == NULL)
return NULL;
if (size == 0)
- goto done;
+ return repr;
- p = q = PyByteArray_AS_STRING(repr);
+ p = q = PyBytes_AS_STRING(repr);
while (size-- > 0) {
Py_UNICODE ch = *s++;
#ifdef Py_UNICODE_WIDE
@@ -3472,15 +3466,15 @@
}
size = p - q;
- done:
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(repr), size);
- Py_DECREF(repr);
- return result;
+ assert(size > 0);
+ if (_PyBytes_Resize(&repr, size) < 0)
+ return NULL;
+ return repr;
}
PyObject *PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
{
- PyObject *s, *result;
+ PyObject *s;
if (!PyUnicode_Check(unicode)) {
PyErr_BadArgument();
return NULL;
@@ -3488,12 +3482,7 @@
s = PyUnicode_EncodeRawUnicodeEscape(PyUnicode_AS_UNICODE(unicode),
PyUnicode_GET_SIZE(unicode));
- if (!s)
- return NULL;
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(s),
- PyByteArray_GET_SIZE(s));
- Py_DECREF(s);
- return result;
+ return s;
}
/* --- Unicode Internal Codec ------------------------------------------- */
@@ -3551,7 +3540,7 @@
errors, &errorHandler,
"unicode_internal", reason,
&starts, &end, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p)) {
+ &v, &outpos, &p)) {
goto onError;
}
}
@@ -3715,7 +3704,6 @@
const char *reason = (limit == 256) ? "ordinal not in range(256)" : "ordinal not in range(128)";
PyObject *errorHandler = NULL;
PyObject *exc = NULL;
- PyObject *result = NULL;
/* the following variable is used for caching string comparisons
* -1=not initialized, 0=unknown, 1=strict, 2=replace, 3=ignore, 4=xmlcharrefreplace */
int known_errorHandler = -1;
@@ -3724,10 +3712,10 @@
replacements, if we need more, we'll resize */
if (size == 0)
return PyBytes_FromStringAndSize(NULL, 0);
- res = PyByteArray_FromStringAndSize(NULL, size);
+ res = PyBytes_FromStringAndSize(NULL, size);
if (res == NULL)
return NULL;
- str = PyByteArray_AS_STRING(res);
+ str = PyBytes_AS_STRING(res);
ressize = size;
while (p<endp) {
@@ -3777,7 +3765,7 @@
p = collend;
break;
case 4: /* xmlcharrefreplace */
- respos = str - PyByteArray_AS_STRING(res);
+ respos = str - PyBytes_AS_STRING(res);
/* determine replacement size (temporarily (mis)uses p) */
for (p = collstart, repsize = 0; p < collend; ++p) {
if (*p<10)
@@ -3804,9 +3792,9 @@
if (requiredsize > ressize) {
if (requiredsize<2*ressize)
requiredsize = 2*ressize;
- if (PyByteArray_Resize(res, requiredsize))
+ if (_PyBytes_Resize(&res, requiredsize))
goto onError;
- str = PyByteArray_AS_STRING(res) + respos;
+ str = PyBytes_AS_STRING(res) + respos;
ressize = requiredsize;
}
/* generate replacement (temporarily (mis)uses p) */
@@ -3824,17 +3812,17 @@
/* need more space? (at least enough for what we
have+the replacement+the rest of the string, so
we won't have to check space for encodable characters) */
- respos = str - PyByteArray_AS_STRING(res);
+ respos = str - PyBytes_AS_STRING(res);
repsize = PyUnicode_GET_SIZE(repunicode);
requiredsize = respos+repsize+(endp-collend);
if (requiredsize > ressize) {
if (requiredsize<2*ressize)
requiredsize = 2*ressize;
- if (PyByteArray_Resize(res, requiredsize)) {
+ if (_PyBytes_Resize(&res, requiredsize)) {
Py_DECREF(repunicode);
goto onError;
}
- str = PyByteArray_AS_STRING(res) + respos;
+ str = PyBytes_AS_STRING(res) + respos;
ressize = requiredsize;
}
/* check if there is anything unencodable in the replacement
@@ -3854,13 +3842,23 @@
}
}
}
- result = PyBytes_FromStringAndSize(PyByteArray_AS_STRING(res),
- str - PyByteArray_AS_STRING(res));
+ /* Resize if we allocated to much */
+ size = str - PyBytes_AS_STRING(res);
+ if (size < ressize) { /* If this falls res will be NULL */
+ assert(size >= 0);
+ if (_PyBytes_Resize(&res, size) < 0)
+ goto onError;
+ }
+
+ Py_XDECREF(errorHandler);
+ Py_XDECREF(exc);
+ return res;
+
onError:
- Py_DECREF(res);
+ Py_XDECREF(res);
Py_XDECREF(errorHandler);
Py_XDECREF(exc);
- return result;
+ return NULL;
}
PyObject *PyUnicode_EncodeLatin1(const Py_UNICODE *p,
@@ -3924,7 +3922,7 @@
errors, &errorHandler,
"ascii", "ordinal not in range(128)",
&starts, &e, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p))
+ &v, &outpos, &p))
goto onError;
}
}
@@ -4225,7 +4223,7 @@
errors, &errorHandler,
"charmap", "character maps to <undefined>",
&starts, &e, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p)) {
+ &v, &outpos, &p)) {
goto onError;
}
continue;
@@ -4275,7 +4273,7 @@
errors, &errorHandler,
"charmap", "character maps to <undefined>",
&starts, &e, &startinpos, &endinpos, &exc, &s,
- (PyObject **)&v, &outpos, &p)) {
+ &v, &outpos, &p)) {
Py_DECREF(x);
goto onError;
}
@@ -4843,7 +4841,8 @@
/* Resize if we allocated to much */
if (respos<PyBytes_GET_SIZE(res))
- _PyBytes_Resize(&res, respos);
+ if (_PyBytes_Resize(&res, respos) < 0)
+ goto onError;
Py_XDECREF(exc);
Py_XDECREF(errorHandler);
@@ -5025,7 +5024,7 @@
/* exponentially overallocate to minimize reallocations */
if (requiredsize < 2 * oldsize)
requiredsize = 2 * oldsize;
- if (_PyUnicode_Resize(outobj, requiredsize) < 0)
+ if (PyUnicode_Resize(outobj, requiredsize) < 0)
return -1;
*outp = PyUnicode_AS_UNICODE(*outobj) + outpos;
}
@@ -5204,7 +5203,7 @@
/* Resize if we allocated to much */
respos = str-PyUnicode_AS_UNICODE(res);
if (respos<PyUnicode_GET_SIZE(res)) {
- if (_PyUnicode_Resize(&res, respos) < 0)
+ if (PyUnicode_Resize(&res, respos) < 0)
goto onError;
}
Py_XDECREF(exc);
@@ -7743,7 +7742,7 @@
*p++ = PyUnicode_AS_UNICODE(repr)[0];
*p = '\0';
- _PyUnicode_Resize(&repr, p - PyUnicode_AS_UNICODE(repr));
+ PyUnicode_Resize(&repr, p - PyUnicode_AS_UNICODE(repr));
return repr;
}
Modified: python/branches/py3k-issue1717/Python/compile.c
==============================================================================
--- python/branches/py3k-issue1717/Python/compile.c (original)
+++ python/branches/py3k-issue1717/Python/compile.c Fri Jan 2 15:30:39 2009
@@ -1704,7 +1704,12 @@
c->u->u_argcount = asdl_seq_LEN(args->args);
c->u->u_kwonlyargcount = asdl_seq_LEN(args->kwonlyargs);
VISIT_IN_SCOPE(c, expr, e->v.Lambda.body);
- ADDOP_IN_SCOPE(c, RETURN_VALUE);
+ if (c->u->u_ste->ste_generator) {
+ ADDOP_IN_SCOPE(c, POP_TOP);
+ }
+ else {
+ ADDOP_IN_SCOPE(c, RETURN_VALUE);
+ }
co = assemble(c, 1);
compiler_exit_scope(c);
if (co == NULL)
Modified: python/branches/py3k-issue1717/Python/getargs.c
==============================================================================
--- python/branches/py3k-issue1717/Python/getargs.c (original)
+++ python/branches/py3k-issue1717/Python/getargs.c Fri Jan 2 15:30:39 2009
@@ -1392,7 +1392,7 @@
Py_ssize_t count;
PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
if (pb == NULL) {
- *errmsg = "string or buffer";
+ *errmsg = "bytes or buffer";
return -1;
}
if (pb->bf_getbuffer) {
@@ -1649,7 +1649,7 @@
}
}
- if (!IS_END_OF_FORMAT(*format)) {
+ if (!IS_END_OF_FORMAT(*format) && *format != '|') {
PyErr_Format(PyExc_RuntimeError,
"more argument specifiers than keyword list entries "
"(remaining format:'%s')", format);
Modified: python/branches/py3k-issue1717/Tools/pybench/Lists.py
==============================================================================
--- python/branches/py3k-issue1717/Tools/pybench/Lists.py (original)
+++ python/branches/py3k-issue1717/Tools/pybench/Lists.py Fri Jan 2 15:30:39 2009
@@ -293,3 +293,58 @@
for i in range(self.rounds):
pass
+
+class SimpleListComprehensions(Test):
+
+ version = 2.0
+ operations = 6
+ rounds = 20000
+
+ def test(self):
+
+ n = list(range(10)) * 10
+
+ for i in range(self.rounds):
+ l = [x for x in n]
+ l = [x for x in n if x]
+ l = [x for x in n if not x]
+
+ l = [x for x in n]
+ l = [x for x in n if x]
+ l = [x for x in n if not x]
+
+ def calibrate(self):
+
+ n = list(range(10)) * 10
+
+ for i in range(self.rounds):
+ pass
+
+class NestedListComprehensions(Test):
+
+ version = 2.0
+ operations = 6
+ rounds = 20000
+
+ def test(self):
+
+ m = list(range(10))
+ n = list(range(10))
+
+ for i in range(self.rounds):
+ l = [x for x in n for y in m]
+ l = [y for x in n for y in m]
+
+ l = [x for x in n for y in m if y]
+ l = [y for x in n for y in m if x]
+
+ l = [x for x in n for y in m if not y]
+ l = [y for x in n for y in m if not x]
+
+ def calibrate(self):
+
+ m = list(range(10))
+ n = list(range(10))
+
+ for i in range(self.rounds):
+ pass
Modified: python/branches/py3k-issue1717/setup.py
==============================================================================
--- python/branches/py3k-issue1717/setup.py (original)
+++ python/branches/py3k-issue1717/setup.py Fri Jan 2 15:30:39 2009
@@ -208,7 +208,8 @@
if missing:
print()
- print("Failed to find the necessary bits to build these modules:")
+ print("Python build finished, but the necessary bits to build "
+ "these modules were not found:")
print_three_column(missing)
print("To find the necessary bits, look in setup.py in"
" detect_modules() for the module's name.")
More information about the Python-checkins
mailing list