Python-checkins
Threads by month
- ----- 2024 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
September 2008
- 18 participants
- 914 discussions
r66707 - in sandbox/trunk/2to3/lib2to3: fixes/fix_import.py tests/test_fixers.py
by benjamin.peterson 30 Sep '08
by benjamin.peterson 30 Sep '08
30 Sep '08
Author: benjamin.peterson
Date: Wed Oct 1 01:27:10 2008
New Revision: 66707
Log:
fix #4001: fix_imports didn't check for __init__.py before converting to relative imports
Modified:
sandbox/trunk/2to3/lib2to3/fixes/fix_import.py
sandbox/trunk/2to3/lib2to3/tests/test_fixers.py
Modified: sandbox/trunk/2to3/lib2to3/fixes/fix_import.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/fixes/fix_import.py (original)
+++ sandbox/trunk/2to3/lib2to3/fixes/fix_import.py Wed Oct 1 01:27:10 2008
@@ -54,6 +54,10 @@
imp_name = imp_name.split('.', 1)[0].strip()
base_path = dirname(file_path)
base_path = join(base_path, imp_name)
+ # If there is no __init__.py next to the file its not in a package
+ # so can't be a relative import.
+ if not exists(join(dirname(base_path), '__init__.py')):
+ return False
for ext in ['.py', pathsep, '.pyc', '.so', '.sl', '.pyd']:
if exists(base_path + ext):
return True
Modified: sandbox/trunk/2to3/lib2to3/tests/test_fixers.py
==============================================================================
--- sandbox/trunk/2to3/lib2to3/tests/test_fixers.py (original)
+++ sandbox/trunk/2to3/lib2to3/tests/test_fixers.py Wed Oct 1 01:27:10 2008
@@ -9,10 +9,10 @@
import support
# Python imports
+import os
import unittest
from itertools import chain
from operator import itemgetter
-from os.path import dirname, pathsep
# Local imports
from .. import pygram
@@ -3272,14 +3272,19 @@
# Need to replace fix_import's exists method
# so we can check that it's doing the right thing
self.files_checked = []
+ self.present_files = set()
self.always_exists = True
def fake_exists(name):
self.files_checked.append(name)
- return self.always_exists
+ return self.always_exists or (name in self.present_files)
from ..fixes import fix_import
fix_import.exists = fake_exists
+ def tearDown(self):
+ from lib2to3.fixes import fix_import
+ fix_import.exists = os.path.exists
+
def check_both(self, b, a):
self.always_exists = True
FixerTestCase.check(self, b, a)
@@ -3289,10 +3294,12 @@
def test_files_checked(self):
def p(path):
# Takes a unix path and returns a path with correct separators
- return pathsep.join(path.split("/"))
+ return os.path.pathsep.join(path.split("/"))
self.always_exists = False
- expected_extensions = ('.py', pathsep, '.pyc', '.so', '.sl', '.pyd')
+ self.present_files = set(['__init__.py'])
+ expected_extensions = ('.py', os.path.pathsep, '.pyc', '.so',
+ '.sl', '.pyd')
names_to_test = (p("/spam/eggs.py"), "ni.py", p("../../shrubbery.py"))
for name in names_to_test:
@@ -3300,11 +3307,32 @@
self.filename = name
self.unchanged("import jam")
- if dirname(name): name = dirname(name) + '/jam'
- else: name = 'jam'
+ if os.path.dirname(name):
+ name = os.path.dirname(name) + '/jam'
+ else:
+ name = 'jam'
expected_checks = set(name + ext for ext in expected_extensions)
+ expected_checks.add("__init__.py")
+
+ self.assertEqual(set(self.files_checked), expected_checks)
+
+ def test_not_in_package(self):
+ s = "import bar"
+ self.always_exists = False
+ self.present_files = set(["bar.py"])
+ self.unchanged(s)
- self.failUnlessEqual(set(self.files_checked), expected_checks)
+ def test_in_package(self):
+ b = "import bar"
+ a = "from . import bar"
+ self.always_exists = False
+ self.present_files = set(["__init__.py", "bar.py"])
+ self.check(b, a)
+
+ def test_comments_and_indent(self):
+ b = "import bar # Foo"
+ a = "from . import bar # Foo"
+ self.check(b, a)
def test_from(self):
b = "from foo import bar, baz"
1
0
Author: thomas.lee
Date: Wed Oct 1 00:24:45 2008
New Revision: 66706
Log:
Merged revisions 66521-66699 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
................
r66523 | georg.brandl | 2008-09-21 17:14:44 +1000 (Sun, 21 Sep 2008) | 2 lines
#3852: fix some select.kqueue and kevent docs.
................
r66524 | georg.brandl | 2008-09-21 17:15:59 +1000 (Sun, 21 Sep 2008) | 2 lines
#3912: document default for *places* arg.
................
r66525 | georg.brandl | 2008-09-21 17:17:00 +1000 (Sun, 21 Sep 2008) | 2 lines
#3916: fixes for docs wrt. Windows directory layout
................
r66526 | georg.brandl | 2008-09-21 17:18:28 +1000 (Sun, 21 Sep 2008) | 2 lines
#3914: add //= to the augmented assign operators.
................
r66529 | georg.brandl | 2008-09-21 17:24:11 +1000 (Sun, 21 Sep 2008) | 2 lines
#3901: bsddb fix.
................
r66530 | georg.brandl | 2008-09-21 17:31:52 +1000 (Sun, 21 Sep 2008) | 2 lines
#3897: _collections now has an underscore.
................
r66532 | georg.brandl | 2008-09-21 17:36:22 +1000 (Sun, 21 Sep 2008) | 2 lines
Update readme and Makefile (web builder doesn't exist).
................
r66535 | georg.brandl | 2008-09-21 18:03:21 +1000 (Sun, 21 Sep 2008) | 2 lines
#3918: note that uniform() args can be swapped.
................
r66538 | georg.brandl | 2008-09-21 20:03:39 +1000 (Sun, 21 Sep 2008) | 2 lines
Add "dist" target.
................
r66539 | hirokazu.yamamoto | 2008-09-21 21:44:23 +1000 (Sun, 21 Sep 2008) | 2 lines
Issue #3838: TarFile object assigned to self.tar should be closed explicitly.
Reviewed by Lars Gustäbel.
................
r66542 | hirokazu.yamamoto | 2008-09-22 06:48:41 +1000 (Mon, 22 Sep 2008) | 2 lines
Issue #3925: Ignores shutil.rmtree error on cygwin too.
Reviewed by Benjamin Peterson.
................
r66544 | benjamin.peterson | 2008-09-22 07:27:51 +1000 (Mon, 22 Sep 2008) | 4 lines
#3879 fix a regression in urllib.getproxies_environment
reviewers: Benjamin, Georg
................
r66546 | georg.brandl | 2008-09-22 08:31:59 +1000 (Mon, 22 Sep 2008) | 2 lines
Fill out download page.
................
r66552 | andrew.macintyre | 2008-09-23 00:10:54 +1000 (Tue, 23 Sep 2008) | 5 lines
should use macro'ed symbols not direct
Part of source_os2emx.patch in issue 3868
Reviewed by Amaury Forgeot d'Arc
................
r66553 | andrew.macintyre | 2008-09-23 00:11:41 +1000 (Tue, 23 Sep 2008) | 5 lines
any platform without HAVE_LOG1P should have DBL_EPSILON in <float.h>
Part of source_os2emx.patch in issue 3868
Reviewed by Amaury Forgeot d'Arc
................
r66554 | andrew.macintyre | 2008-09-23 00:23:45 +1000 (Tue, 23 Sep 2008) | 8 lines
build_os2emx.patch in issue 3868 - update OS/2 EMX makefile and config files
Part of source_os2emx.patch in issue 3868:
Include/pystrcmp.h: OS/2 has same C APIs as Windows
Lib/test/test_io.py: OS/2 has same behaviour as Windows for this test
Reviewed by Amaury Forgeot d'Arc
................
r66557 | benjamin.peterson | 2008-09-23 07:11:43 +1000 (Tue, 23 Sep 2008) | 1 line
use the new threading properties for multiprocessing (reviewed by Jesse #3927)
................
r66561 | benjamin.peterson | 2008-09-23 08:13:29 +1000 (Tue, 23 Sep 2008) | 1 line
clean up docs for platform's linux_distribution and dist functions
................
r66564 | benjamin.peterson | 2008-09-23 23:32:46 +1000 (Tue, 23 Sep 2008) | 1 line
mention how to override boolean evaluation
................
r66566 | hirokazu.yamamoto | 2008-09-24 02:11:09 +1000 (Wed, 24 Sep 2008) | 2 lines
Issue #3945: Fixed compile error on cygwin. (initializer element is not constant)
Reviewed by Amaury Forgeot d'Arc.
................
r66568 | jesus.cea | 2008-09-24 04:54:08 +1000 (Wed, 24 Sep 2008) | 5 lines
Bugfix for issue3885 and 'DB.verify()' crash.
Reviewed by Nick Coghlan.
................
r66569 | benjamin.peterson | 2008-09-24 06:43:09 +1000 (Wed, 24 Sep 2008) | 1 line
backport the atexit test for r66563
................
r66580 | georg.brandl | 2008-09-24 19:47:55 +1000 (Wed, 24 Sep 2008) | 2 lines
Indentation normalization.
................
r66610 | andrew.kuchling | 2008-09-25 03:27:55 +1000 (Thu, 25 Sep 2008) | 1 line
Improve wording
................
r66611 | thomas.heller | 2008-09-25 04:26:05 +1000 (Thu, 25 Sep 2008) | 3 lines
Fix issue #3547: ctypes is confused by bitfields of varying integer types
Reviewed by Fredrik Lundh and Skip Montanaro.
................
r66614 | benjamin.peterson | 2008-09-25 08:11:59 +1000 (Thu, 25 Sep 2008) | 4 lines
#3950 fix missing scale factors in turtle.py
reviewers: Georg, Benjamin
................
r66616 | martin.v.loewis | 2008-09-25 14:12:50 +1000 (Thu, 25 Sep 2008) | 2 lines
Bug #3951: Py_USING_MEMORY_DEBUGGER should not be enabled by default.
................
r66618 | benjamin.peterson | 2008-09-26 06:35:45 +1000 (Fri, 26 Sep 2008) | 1 line
add a NEWs entry for r66614
................
r66620 | amaury.forgeotdarc | 2008-09-26 06:52:56 +1000 (Fri, 26 Sep 2008) | 5 lines
#3965: on Windows, open() crashes if the filename or the mode is invalid,
and if the filename is a unicode string.
Reviewed by Martin von Loewis.
................
r66624 | raymond.hettinger | 2008-09-26 09:31:52 +1000 (Fri, 26 Sep 2008) | 1 line
Fix namedtuple bug reported by Glenn Linderman. Template did not form correctly if the field names were input in Unicode.
................
r66625 | benjamin.peterson | 2008-09-26 12:58:36 +1000 (Fri, 26 Sep 2008) | 1 line
add the beginnings of a C-API 2 -> 3 porting guide
................
r66628 | benjamin.peterson | 2008-09-27 06:52:06 +1000 (Sat, 27 Sep 2008) | 1 line
add an 'other options' section
................
r66629 | georg.brandl | 2008-09-27 07:15:21 +1000 (Sat, 27 Sep 2008) | 2 lines
typos.
................
r66631 | amaury.forgeotdarc | 2008-09-27 08:34:08 +1000 (Sat, 27 Sep 2008) | 7 lines
#3967: Correct a crash in count() and find() methods of string-like objects.
For example:
"".count("xxxx", sys.maxint, 0)
Reviewed by Benjamin Peterson.
Will port to 2.5 and 3.0.
................
r66634 | benjamin.peterson | 2008-09-27 12:49:54 +1000 (Sat, 27 Sep 2008) | 7 lines
give ftplib a real test suite
A asyncore based mock ftp server is used to test the protocol.
This is all thanks to Giampaolo Rodola #3939
(Barry gave me permission to do this before final on IRC.)
................
r66643 | andrew.kuchling | 2008-09-28 00:12:33 +1000 (Sun, 28 Sep 2008) | 1 line
Add a last bunch of items
................
r66645 | benjamin.peterson | 2008-09-28 02:23:55 +1000 (Sun, 28 Sep 2008) | 1 line
2to3's api should be considered unstable
................
r66653 | benjamin.peterson | 2008-09-28 07:09:10 +1000 (Sun, 28 Sep 2008) | 49 lines
Merged revisions 66511,66548-66549,66644,66646-66652 via svnmerge from
svn+ssh://pythondev@svn.python.org/sandbox/trunk/2to3/lib2to3
........
r66511 | benjamin.peterson | 2008-09-18 21:49:27 -0500 (Thu, 18 Sep 2008) | 1 line
remove a useless if __name__ == '__main__'
........
r66548 | benjamin.peterson | 2008-09-21 21:14:14 -0500 (Sun, 21 Sep 2008) | 1 line
avoid the perils of mutable default arguments
........
r66549 | benjamin.peterson | 2008-09-21 21:26:11 -0500 (Sun, 21 Sep 2008) | 1 line
some places in RefactoringTool should raise an error instead of logging it
........
r66644 | benjamin.peterson | 2008-09-27 10:45:10 -0500 (Sat, 27 Sep 2008) | 1 line
fix doctest refactoring
........
r66646 | benjamin.peterson | 2008-09-27 11:40:13 -0500 (Sat, 27 Sep 2008) | 1 line
don't print to stdout when 2to3 is used as a library
........
r66647 | benjamin.peterson | 2008-09-27 12:28:28 -0500 (Sat, 27 Sep 2008) | 1 line
let fixer modules and classes have different prefixes
........
r66648 | benjamin.peterson | 2008-09-27 14:02:13 -0500 (Sat, 27 Sep 2008) | 1 line
raise errors when 2to3 is used as a library
........
r66649 | benjamin.peterson | 2008-09-27 14:03:38 -0500 (Sat, 27 Sep 2008) | 1 line
fix docstring
........
r66650 | benjamin.peterson | 2008-09-27 14:22:21 -0500 (Sat, 27 Sep 2008) | 1 line
make use of enumerate
........
r66651 | benjamin.peterson | 2008-09-27 14:24:13 -0500 (Sat, 27 Sep 2008) | 1 line
revert last revision; it breaks things
........
r66652 | benjamin.peterson | 2008-09-27 16:03:06 -0500 (Sat, 27 Sep 2008) | 1 line
add tests for lib2to3.refactor
........
................
r66654 | benjamin.peterson | 2008-09-28 07:12:20 +1000 (Sun, 28 Sep 2008) | 1 line
enable refactor tests
................
r66657 | benjamin.peterson | 2008-09-28 08:08:12 +1000 (Sun, 28 Sep 2008) | 1 line
backport r66656 so people using -Qnew aren't affected
................
r66660 | andrew.kuchling | 2008-09-28 08:54:08 +1000 (Sun, 28 Sep 2008) | 1 line
#3510: future-proof text
................
r66661 | benjamin.peterson | 2008-09-28 09:28:43 +1000 (Sun, 28 Sep 2008) | 1 line
clarify a few things
................
r66662 | andrew.kuchling | 2008-09-28 10:15:27 +1000 (Sun, 28 Sep 2008) | 1 line
#1579477: mention necessity to flush output before exec'ing
................
r66663 | andrew.kuchling | 2008-09-28 11:08:47 +1000 (Sun, 28 Sep 2008) | 1 line
#1415508: Document two functions
................
r66664 | benjamin.peterson | 2008-09-28 11:51:36 +1000 (Sun, 28 Sep 2008) | 1 line
better grammar
................
r66665 | benjamin.peterson | 2008-09-28 11:53:29 +1000 (Sun, 28 Sep 2008) | 1 line
note the 2to3 -d could be useful for other refactoring
................
r66667 | georg.brandl | 2008-09-28 18:34:31 +1000 (Sun, 28 Sep 2008) | 2 lines
No downloads for RCs.
................
r66670 | georg.brandl | 2008-09-29 06:01:36 +1000 (Mon, 29 Sep 2008) | 2 lines
Don't show version in title.
................
r66673 | benjamin.peterson | 2008-09-29 06:57:21 +1000 (Mon, 29 Sep 2008) | 1 line
merge in the fix for test_ftplib on some bots [reviewed by Georg]
................
r66676 | jesus.cea | 2008-09-29 09:24:19 +1000 (Mon, 29 Sep 2008) | 1 line
bsddb4.7.3pre9 renamed to 4.7.3
................
r66677 | brett.cannon | 2008-09-29 13:41:21 +1000 (Mon, 29 Sep 2008) | 7 lines
The _lsprof module could crash the interpreter if it was given an external
timer that did not return a float and a timer was still running when the
Profiler object was garbage collected.
Fixes issue 3895.
Code review by Benjamin Peterson.
................
r66681 | georg.brandl | 2008-09-30 02:51:35 +1000 (Tue, 30 Sep 2008) | 2 lines
Update nasm location.
................
r66682 | bill.janssen | 2008-09-30 04:56:38 +1000 (Tue, 30 Sep 2008) | 1 line
fix for release blocker 3910, 2.6 regression in socket.ssl method
................
r66683 | thomas.heller | 2008-09-30 05:56:24 +1000 (Tue, 30 Sep 2008) | 1 line
Fix issue #3547 for MingW, update comments.
................
r66686 | martin.v.loewis | 2008-09-30 08:09:07 +1000 (Tue, 30 Sep 2008) | 5 lines
Issue #3965: Allow repeated calls to turtle.Screen, by making it a
true singleton object.
Reviewed by Gregor Lingl.
................
r66688 | jesse.noller | 2008-09-30 10:15:45 +1000 (Tue, 30 Sep 2008) | 2 lines
issue3770: if SEM_OPEN is 0, disable the mp.synchronize module, rev. Nick Coghlan, Damien Miller
................
r66689 | benjamin.peterson | 2008-09-30 11:31:49 +1000 (Tue, 30 Sep 2008) | 5 lines
fix security issue 2: imageop's poor validation of arguments could result in segfaults
patch by Victor Stinner
reviewed by myself and Brett
................
r66693 | benjamin.peterson | 2008-09-30 12:11:07 +1000 (Tue, 30 Sep 2008) | 4 lines
Victor Stinner's patches to check the return result of PyLong_Ssize_t
reviewed by Amaury
................
r66696 | andrew.kuchling | 2008-09-30 22:31:07 +1000 (Tue, 30 Sep 2008) | 1 line
Edits, and add markup
................
r66697 | andrew.kuchling | 2008-09-30 23:00:34 +1000 (Tue, 30 Sep 2008) | 1 line
Markup fix
................
r66698 | andrew.kuchling | 2008-09-30 23:00:51 +1000 (Tue, 30 Sep 2008) | 1 line
Markup fixes
................
r66699 | andrew.kuchling | 2008-09-30 23:01:46 +1000 (Tue, 30 Sep 2008) | 1 line
Markup fixes. (optparse.rst probably needs an entire revision pass.)
................
Added:
python/branches/tlee-ast-optimize/Doc/howto/cporting.rst
- copied unchanged from r66699, /python/trunk/Doc/howto/cporting.rst
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/data/fixers/
- copied from r66699, /python/trunk/Lib/lib2to3/tests/data/fixers/
python/branches/tlee-ast-optimize/Lib/lib2to3/tests/test_refactor.py
- copied unchanged from r66699, /python/trunk/Lib/lib2to3/tests/test_refactor.py
Modified:
python/branches/tlee-ast-optimize/ (props changed)
python/branches/tlee-ast-optimize/Demo/turtle/turtleDemo.py
python/branches/tlee-ast-optimize/Doc/Makefile
python/branches/tlee-ast-optimize/Doc/README.txt
python/branches/tlee-ast-optimize/Doc/c-api/number.rst
python/branches/tlee-ast-optimize/Doc/c-api/object.rst
python/branches/tlee-ast-optimize/Doc/howto/index.rst
python/branches/tlee-ast-optimize/Doc/howto/urllib2.rst
python/branches/tlee-ast-optimize/Doc/library/2to3.rst
python/branches/tlee-ast-optimize/Doc/library/autogil.rst
python/branches/tlee-ast-optimize/Doc/library/ctypes.rst
python/branches/tlee-ast-optimize/Doc/library/json.rst
python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst
python/branches/tlee-ast-optimize/Doc/library/optparse.rst
python/branches/tlee-ast-optimize/Doc/library/os.rst
python/branches/tlee-ast-optimize/Doc/library/platform.rst
python/branches/tlee-ast-optimize/Doc/library/random.rst
python/branches/tlee-ast-optimize/Doc/library/select.rst
python/branches/tlee-ast-optimize/Doc/library/site.rst
python/branches/tlee-ast-optimize/Doc/library/socket.rst
python/branches/tlee-ast-optimize/Doc/library/subprocess.rst
python/branches/tlee-ast-optimize/Doc/library/turtle.rst
python/branches/tlee-ast-optimize/Doc/library/unittest.rst
python/branches/tlee-ast-optimize/Doc/reference/expressions.rst
python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst
python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html
python/branches/tlee-ast-optimize/Doc/using/windows.rst
python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst
python/branches/tlee-ast-optimize/Include/pystrcmp.h
python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py
python/branches/tlee-ast-optimize/Lib/collections.py
python/branches/tlee-ast-optimize/Lib/ctypes/test/test_bitfields.py
python/branches/tlee-ast-optimize/Lib/distutils/tests/test_build_ext.py
python/branches/tlee-ast-optimize/Lib/ftplib.py
python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py
python/branches/tlee-ast-optimize/Lib/lib2to3/ (props changed)
python/branches/tlee-ast-optimize/Lib/lib2to3/main.py
python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
python/branches/tlee-ast-optimize/Lib/multiprocessing/dummy/__init__.py
python/branches/tlee-ast-optimize/Lib/multiprocessing/synchronize.py
python/branches/tlee-ast-optimize/Lib/ssl.py
python/branches/tlee-ast-optimize/Lib/test/regrtest.py
python/branches/tlee-ast-optimize/Lib/test/string_tests.py
python/branches/tlee-ast-optimize/Lib/test/test_atexit.py
python/branches/tlee-ast-optimize/Lib/test/test_collections.py
python/branches/tlee-ast-optimize/Lib/test/test_cprofile.py
python/branches/tlee-ast-optimize/Lib/test/test_file.py
python/branches/tlee-ast-optimize/Lib/test/test_ftplib.py
python/branches/tlee-ast-optimize/Lib/test/test_imageop.py
python/branches/tlee-ast-optimize/Lib/test/test_io.py
python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py
python/branches/tlee-ast-optimize/Lib/test/test_multiprocessing.py
python/branches/tlee-ast-optimize/Lib/test/test_ssl.py
python/branches/tlee-ast-optimize/Lib/test/test_tarfile.py
python/branches/tlee-ast-optimize/Lib/test/test_urllib.py
python/branches/tlee-ast-optimize/Lib/urllib.py
python/branches/tlee-ast-optimize/Misc/NEWS
python/branches/tlee-ast-optimize/Modules/Setup.dist
python/branches/tlee-ast-optimize/Modules/_bsddb.c
python/branches/tlee-ast-optimize/Modules/_bytesio.c
python/branches/tlee-ast-optimize/Modules/_ctypes/cfield.c
python/branches/tlee-ast-optimize/Modules/_fileio.c
python/branches/tlee-ast-optimize/Modules/_lsprof.c
python/branches/tlee-ast-optimize/Modules/_struct.c
python/branches/tlee-ast-optimize/Modules/bsddb.h
python/branches/tlee-ast-optimize/Modules/imageop.c
python/branches/tlee-ast-optimize/Modules/selectmodule.c
python/branches/tlee-ast-optimize/Objects/fileobject.c
python/branches/tlee-ast-optimize/Objects/floatobject.c
python/branches/tlee-ast-optimize/Objects/obmalloc.c
python/branches/tlee-ast-optimize/Objects/stringlib/count.h
python/branches/tlee-ast-optimize/Objects/stringlib/find.h
python/branches/tlee-ast-optimize/PC/os2emx/Makefile
python/branches/tlee-ast-optimize/PC/os2emx/config.c
python/branches/tlee-ast-optimize/PC/os2emx/pyconfig.h
python/branches/tlee-ast-optimize/PCbuild/readme.txt
python/branches/tlee-ast-optimize/Python/pymath.c
python/branches/tlee-ast-optimize/setup.py
Modified: python/branches/tlee-ast-optimize/Demo/turtle/turtleDemo.py
==============================================================================
--- python/branches/tlee-ast-optimize/Demo/turtle/turtleDemo.py (original)
+++ python/branches/tlee-ast-optimize/Demo/turtle/turtleDemo.py Wed Oct 1 00:24:45 2008
@@ -94,8 +94,8 @@
left_frame.pack(side=LEFT, fill=BOTH, expand=0)
self.graph_frame = g_frame = Frame(root)
- turtle.Screen._root = g_frame
- turtle.Screen._canvas = turtle.ScrolledCanvas(g_frame, 800, 600, 1000, 800)
+ turtle._Screen._root = g_frame
+ turtle._Screen._canvas = turtle.ScrolledCanvas(g_frame, 800, 600, 1000, 800)
#xturtle.Screen._canvas.pack(expand=1, fill="both")
self.screen = _s_ = turtle.Screen()
self.scanvas = _s_._canvas
Modified: python/branches/tlee-ast-optimize/Doc/Makefile
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/Makefile (original)
+++ python/branches/tlee-ast-optimize/Doc/Makefile Wed Oct 1 00:24:45 2008
@@ -9,22 +9,23 @@
SPHINXOPTS =
PAPER =
SOURCES =
+DISTVERSION =
ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \
$(SPHINXOPTS) . build/$(BUILDER) $(SOURCES)
-.PHONY: help checkout update build html web htmlhelp clean coverage
+.PHONY: help checkout update build html htmlhelp clean coverage dist
help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
- @echo " web to make file usable by Sphinx.web"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " text to make plain text files"
@echo " changes to make an overview over all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " coverage to check documentation coverage for library and C API"
+ @echo " dist to create a \"dist\" directory with archived docs for download"
checkout:
@if [ ! -d tools/sphinx ]; then \
@@ -59,12 +60,6 @@
html: build
@echo "Build finished. The HTML pages are in build/html."
-web: BUILDER = web
-web: build
- @echo "Build finished; now you can run"
- @echo " PYTHONPATH=tools $(PYTHON) -m sphinx.web build/web"
- @echo "to start the server."
-
htmlhelp: BUILDER = htmlhelp
htmlhelp: build
@echo "Build finished; now you can run HTML Help Workshop with the" \
@@ -105,6 +100,44 @@
htmlview: html
$(PYTHON) -c "import webbrowser; webbrowser.open('build/html/index.html')"
+
clean:
-rm -rf build/*
-rm -rf tools/sphinx
+
+dist:
+ -rm -rf dist
+ mkdir -p dist
+
+ # archive the HTML
+ make html
+ cp -a 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 -a 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
+
+ # 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
+
Modified: python/branches/tlee-ast-optimize/Doc/README.txt
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/README.txt (original)
+++ python/branches/tlee-ast-optimize/Doc/README.txt Wed Oct 1 00:24:45 2008
@@ -38,9 +38,6 @@
* "html", which builds standalone HTML files for offline viewing.
- * "web", which builds files usable with the Sphinx.web application (used to
- serve the docs online at http://docs.python.org/).
-
* "htmlhelp", which builds HTML files and a HTML Help project file usable to
convert them into a single Compiled HTML (.chm) file -- these are popular
under Microsoft Windows, but very handy on every platform.
Modified: python/branches/tlee-ast-optimize/Doc/c-api/number.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/c-api/number.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/c-api/number.rst Wed Oct 1 00:24:45 2008
@@ -285,7 +285,7 @@
.. cfunction:: PyObject* PyNumber_Index(PyObject *o)
Returns the *o* converted to a Python int or long on success or *NULL* with a
- TypeError exception raised on failure.
+ :exc:`TypeError` exception raised on failure.
.. versionadded:: 2.5
Modified: python/branches/tlee-ast-optimize/Doc/c-api/object.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/c-api/object.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/c-api/object.rst Wed Oct 1 00:24:45 2008
@@ -279,7 +279,7 @@
.. cfunction:: long PyObject_HashNotImplemented(PyObject *o)
- Set a TypeError indicating that ``type(o)`` is not hashable and return ``-1``.
+ Set a :exc:`TypeError` indicating that ``type(o)`` is not hashable and return ``-1``.
This function receives special treatment when stored in a ``tp_hash`` slot,
allowing a type to explicitly indicate to the interpreter that it is not
hashable.
Modified: python/branches/tlee-ast-optimize/Doc/howto/index.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/howto/index.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/howto/index.rst Wed Oct 1 00:24:45 2008
@@ -14,6 +14,7 @@
:maxdepth: 1
advocacy.rst
+ cporting.rst
curses.rst
doanddont.rst
functional.rst
Modified: python/branches/tlee-ast-optimize/Doc/howto/urllib2.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/howto/urllib2.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/howto/urllib2.rst Wed Oct 1 00:24:45 2008
@@ -182,11 +182,12 @@
Handling Exceptions
===================
-*urlopen* raises ``URLError`` when it cannot handle a response (though as usual
-with Python APIs, builtin exceptions such as ValueError, TypeError etc. may also
+*urlopen* raises :exc:`URLError` when it cannot handle a response (though as usual
+with Python APIs, builtin exceptions such as
+:exc:`ValueError`, :exc:`TypeError` etc. may also
be raised).
-``HTTPError`` is the subclass of ``URLError`` raised in the specific case of
+:exc:`HTTPError` is the subclass of :exc:`URLError` raised in the specific case of
HTTP URLs.
URLError
@@ -215,12 +216,12 @@
default handlers will handle some of these responses for you (for example, if
the response is a "redirection" that requests the client fetch the document from
a different URL, urllib2 will handle that for you). For those it can't handle,
-urlopen will raise an ``HTTPError``. Typical errors include '404' (page not
+urlopen will raise an :exc:`HTTPError`. Typical errors include '404' (page not
found), '403' (request forbidden), and '401' (authentication required).
See section 10 of RFC 2616 for a reference on all the HTTP error codes.
-The ``HTTPError`` instance raised will have an integer 'code' attribute, which
+The :exc:`HTTPError` instance raised will have an integer 'code' attribute, which
corresponds to the error sent by the server.
Error Codes
@@ -303,7 +304,7 @@
}
When an error is raised the server responds by returning an HTTP error code
-*and* an error page. You can use the ``HTTPError`` instance as a response on the
+*and* an error page. You can use the :exc:`HTTPError` instance as a response on the
page returned. This means that as well as the code attribute, it also has read,
geturl, and info, methods. ::
@@ -325,7 +326,7 @@
Wrapping it Up
--------------
-So if you want to be prepared for ``HTTPError`` *or* ``URLError`` there are two
+So if you want to be prepared for :exc:`HTTPError` *or* :exc:`URLError` there are two
basic approaches. I prefer the second approach.
Number 1
@@ -351,7 +352,7 @@
.. note::
The ``except HTTPError`` *must* come first, otherwise ``except URLError``
- will *also* catch an ``HTTPError``.
+ will *also* catch an :exc:`HTTPError`.
Number 2
~~~~~~~~
@@ -376,8 +377,8 @@
info and geturl
===============
-The response returned by urlopen (or the ``HTTPError`` instance) has two useful
-methods ``info`` and ``geturl``.
+The response returned by urlopen (or the :exc:`HTTPError` instance) has two useful
+methods :meth:`info` and :meth:`geturl`.
**geturl** - this returns the real URL of the page fetched. This is useful
because ``urlopen`` (or the opener object used) may have followed a
Modified: python/branches/tlee-ast-optimize/Doc/library/2to3.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/2to3.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/2to3.rst Wed Oct 1 00:24:45 2008
@@ -74,7 +74,9 @@
have compliant 3.x code.
2to3 can also refactor doctests. To enable this mode, use the :option:`-d`
-flag. Note that *only* doctests will be refactored.
+flag. Note that *only* doctests will be refactored. This also doesn't require
+the module to be valid Python. For example, doctest like examples in a reST
+document could also be refactored with this option.
The :option:`-v` option enables the output of more information on the
translation process.
@@ -95,4 +97,10 @@
.. moduleauthor:: Guido van Rossum
.. moduleauthor:: Collin Winter
+
+.. warning::
+
+ The :mod:`lib2to3` API should be considered unstable and may change
+ drastically in the future.
+
.. XXX What is the public interface anyway?
Modified: python/branches/tlee-ast-optimize/Doc/library/autogil.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/autogil.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/autogil.rst Wed Oct 1 00:24:45 2008
@@ -15,7 +15,7 @@
.. warning::
- This module is removed in 3.0.
+ This module has been removed in 3.0.
.. exception:: AutoGILError
Modified: python/branches/tlee-ast-optimize/Doc/library/ctypes.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/ctypes.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/ctypes.rst Wed Oct 1 00:24:45 2008
@@ -1392,7 +1392,7 @@
The *use_last_error* parameter, when set to True, enables the same
mechanism for the Windows error code which is managed by the
-GetLastError() and SetLastError() Windows api functions;
+:func:`GetLastError` and :func:`SetLastError` Windows API functions;
`ctypes.get_last_error()` and `ctypes.set_last_error(value)` are used
to request and change the ctypes private copy of the windows error
code.
Modified: python/branches/tlee-ast-optimize/Doc/library/json.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/json.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/json.rst Wed Oct 1 00:24:45 2008
@@ -371,9 +371,9 @@
def default(self, o):
try:
- iterable = iter(o)
+ iterable = iter(o)
except TypeError:
- pass
+ pass
else:
return list(iterable)
return JSONEncoder.default(self, o)
Modified: python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/multiprocessing.rst Wed Oct 1 00:24:45 2008
@@ -18,6 +18,13 @@
leverage multiple processors on a given machine. It runs on both Unix and
Windows.
+.. warning::
+
+ Some of this package's functionality requires a functioning shared semaphore
+ implementation on the host operating system. Without one, the
+ :mod:`multiprocessing.synchronize` module will be disabled, and attempts to
+ import it will result in an :exc:`ImportError`. See
+ :issue:`3770` for additional information.
The :class:`Process` class
~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: python/branches/tlee-ast-optimize/Doc/library/optparse.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/optparse.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/optparse.rst Wed Oct 1 00:24:45 2008
@@ -602,7 +602,7 @@
programmer errors and user errors. Programmer errors are usually erroneous
calls to ``parser.add_option()``, e.g. invalid option strings, unknown option
attributes, missing option attributes, etc. These are dealt with in the usual
-way: raise an exception (either ``optparse.OptionError`` or ``TypeError``) and
+way: raise an exception (either ``optparse.OptionError`` or :exc:`TypeError`) and
let the program crash.
Handling user errors is much more important, since they are guaranteed to happen
@@ -799,10 +799,10 @@
The keyword arguments define attributes of the new Option object. The most
important option attribute is :attr:`action`, and it largely determines which
other attributes are relevant or required. If you pass irrelevant option
-attributes, or fail to pass required ones, :mod:`optparse` raises an OptionError
-exception explaining your mistake.
+attributes, or fail to pass required ones, :mod:`optparse` raises an
+:exc:`OptionError` exception explaining your mistake.
-An options's *action* determines what :mod:`optparse` does when it encounters
+An option's *action* determines what :mod:`optparse` does when it encounters
this option on the command-line. The standard option actions hard-coded into
:mod:`optparse` are:
@@ -1059,7 +1059,7 @@
The following option attributes may be passed as keyword arguments to
``parser.add_option()``. If you pass an option attribute that is not relevant
to a particular option, or fail to pass a required option attribute,
-:mod:`optparse` raises OptionError.
+:mod:`optparse` raises :exc:`OptionError`.
* :attr:`action` (default: ``"store"``)
@@ -1152,7 +1152,7 @@
``choice`` options are a subtype of ``string`` options. The ``choices`` option
attribute (a sequence of strings) defines the set of allowed option arguments.
``optparse.check_choice()`` compares user-supplied option arguments against this
-master list and raises OptionValueError if an invalid string is given.
+master list and raises :exc:`OptionValueError` if an invalid string is given.
.. _optparse-parsing-arguments:
@@ -1198,22 +1198,37 @@
Querying and manipulating your option parser
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Sometimes, it's useful to poke around your option parser and see what's there.
-OptionParser provides a couple of methods to help you out:
-
-``has_option(opt_str)``
- Return true if the OptionParser has an option with option string ``opt_str``
- (e.g., ``"-q"`` or ``"--verbose"``).
+The default behavior of the option parser can be customized slightly,
+and you can also poke around your option parser and see what's there.
+OptionParser provides several methods to help you out:
+
+``disable_interspersed_args()``
+ Set parsing to stop on the first non-option. Use this if you have a
+ command processor which runs another command which has options of
+ its own and you want to make sure these options don't get
+ confused. For example, each command might have a different
+ set of options.
+
+``enable_interspersed_args()``
+ Set parsing to not stop on the first non-option, allowing
+ interspersing switches with command arguments. For example,
+ ``"-s arg1 --long arg2"`` would return ``["arg1", "arg2"]``
+ as the command arguments and ``-s, --long`` as options.
+ This is the default behavior.
``get_option(opt_str)``
Returns the Option instance with the option string ``opt_str``, or ``None`` if
no options have that option string.
+``has_option(opt_str)``
+ Return true if the OptionParser has an option with option string ``opt_str``
+ (e.g., ``"-q"`` or ``"--verbose"``).
+
``remove_option(opt_str)``
- If the OptionParser has an option corresponding to ``opt_str``, that option is
+ If the :class:`OptionParser` has an option corresponding to ``opt_str``, that option is
removed. If that option provided any other option strings, all of those option
strings become invalid. If ``opt_str`` does not occur in any option belonging to
- this OptionParser, raises ValueError.
+ this :class:`OptionParser`, raises :exc:`ValueError`.
.. _optparse-conflicts-between-options:
@@ -1244,13 +1259,13 @@
The available conflict handlers are:
``error`` (default)
- assume option conflicts are a programming error and raise OptionConflictError
+ assume option conflicts are a programming error and raise :exc:`OptionConflictError`
``resolve``
resolve option conflicts intelligently (see below)
-As an example, let's define an OptionParser that resolves conflicts
+As an example, let's define an :class:`OptionParser` that resolves conflicts
intelligently and add conflicting options to it::
parser = OptionParser(conflict_handler="resolve")
@@ -1480,7 +1495,7 @@
Raising errors in a callback
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The callback function should raise OptionValueError if there are any problems
+The callback function should raise :exc:`OptionValueError` if there are any problems
with the option or its argument(s). :mod:`optparse` catches this and terminates
the program, printing the error message you supply to stderr. Your message
should be clear, concise, accurate, and mention the option at fault. Otherwise,
@@ -1681,9 +1696,9 @@
:meth:`OptionParser.parse_args`, or be passed to a callback as the ``value``
parameter.
-Your type-checking function should raise OptionValueError if it encounters any
-problems. OptionValueError takes a single string argument, which is passed
-as-is to OptionParser's :meth:`error` method, which in turn prepends the program
+Your type-checking function should raise :exc:`OptionValueError` if it encounters any
+problems. :exc:`OptionValueError` takes a single string argument, which is passed
+as-is to :class:`OptionParser`'s :meth:`error` method, which in turn prepends the program
name and the string ``"error:"`` and prints everything to stderr before
terminating the process.
Modified: python/branches/tlee-ast-optimize/Doc/library/os.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/os.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/os.rst Wed Oct 1 00:24:45 2008
@@ -1451,7 +1451,13 @@
These functions all execute a new program, replacing the current process; they
do not return. On Unix, the new executable is loaded into the current process,
and will have the same process id as the caller. Errors will be reported as
- :exc:`OSError` exceptions.
+ :exc:`OSError` exceptions.
+
+ The current process is replaced immediately. Open file objects and
+ descriptors are not flushed, so if there may be data buffered
+ on these open files, you should flush them using
+ :func:`sys.stdout.flush` or :func:`os.fsync` before calling an
+ :func:`exec\*` function.
The "l" and "v" variants of the :func:`exec\*` functions differ in how
command-line arguments are passed. The "l" variants are perhaps the easiest
@@ -1477,8 +1483,9 @@
used to define the environment variables for the new process (these are used
instead of the current process' environment); the functions :func:`execl`,
:func:`execlp`, :func:`execv`, and :func:`execvp` all cause the new process to
- inherit the environment of the current process. Availability: Unix,
- Windows.
+ inherit the environment of the current process.
+
+ Availability: Unix, Windows.
.. function:: _exit(n)
Modified: python/branches/tlee-ast-optimize/Doc/library/platform.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/platform.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/platform.rst Wed Oct 1 00:24:45 2008
@@ -234,29 +234,23 @@
.. function:: dist(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...))
- Tries to determine the name of the OS distribution name Returns a tuple
- ``(distname, version, id)`` which defaults to the args given as parameters.
-
- ``supported_dists`` may be given to define the set of Linux
- distributions to look for. It defaults to a list of currently
- supported Linux distributions identified by their release file
- name.
+ This is another name for :func:`linux_distribution`.
.. function:: linux_distribution(distname='', version='', id='', supported_dists=('SuSE','debian','redhat','mandrake',...), full_distribution_name=1)
Tries to determine the name of the Linux OS distribution name.
- ``supported_dists`` may be given to define the set of Linux
- distributions to look for. It defaults to a list of currently
- supported Linux distributions identified by their release file
- name.
-
- If ``full_distribution_name`` is true (default), the full
- distribution read from the OS is returned. Otherwise the short name
- taken from ``supported_dists`` is used.
-
- Returns a tuple ``(distname,version,id)`` which defaults to the
- args given as parameters.
+ ``supported_dists`` may be given to define the set of Linux distributions to
+ look for. It defaults to a list of currently supported Linux distributions
+ identified by their release file name.
+
+ If ``full_distribution_name`` is true (default), the full distribution read
+ from the OS is returned. Otherwise the short name taken from
+ ``supported_dists`` is used.
+
+ Returns a tuple ``(distname,version,id)`` which defaults to the args given as
+ parameters. ``id`` is the item in parentheses after the version number. It
+ is usually the version codename.
.. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048)
Modified: python/branches/tlee-ast-optimize/Doc/library/random.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/random.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/random.rst Wed Oct 1 00:24:45 2008
@@ -188,7 +188,9 @@
.. function:: uniform(a, b)
- Return a random floating point number *N* such that ``a <= N < b``.
+ Return a random floating point number *N* such that ``a <= N < b`` for
+ ``a <= b`` and ``b <= N < a`` for ``b < a``.
+
.. function:: triangular(low, high, mode)
Modified: python/branches/tlee-ast-optimize/Doc/library/select.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/select.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/select.rst Wed Oct 1 00:24:45 2008
@@ -50,7 +50,7 @@
.. versionadded:: 2.6
-.. function:: kqueue(ident, filter=KQ_FILTER_READ, flags=KQ_ADD, fflags=0, data=0, udata=0)
+.. function:: kevent(ident, filter=KQ_FILTER_READ, flags=KQ_ADD, fflags=0, data=0, udata=0)
(Only supported on BSD.) Returns a kernel event object object; see section
:ref:`kevent-objects` below for the methods supported by kqueue objects.
@@ -272,12 +272,12 @@
Return the file descriptor number of the control fd.
-.. method:: epoll.fromfd(fd)
+.. method:: kqueue.fromfd(fd)
Create a kqueue object from a given file descriptor.
-.. method:: control(changelist, max_events=0[, timeout=None]) -> eventlist
+.. method:: kqueue.control(changelist, max_events[, timeout=None]) -> eventlist
Low level interface to kevent
Modified: python/branches/tlee-ast-optimize/Doc/library/site.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/site.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/site.rst Wed Oct 1 00:24:45 2008
@@ -62,10 +62,11 @@
bar
-Then the following directories are added to ``sys.path``, in this order::
+Then the following version-specific directories are added to
+``sys.path``, in this order::
- /usr/local/lib/python2.6/site-packages/bar
- /usr/local/lib/python2.6/site-packages/foo
+ /usr/local/lib/pythonX.Y/site-packages/bar
+ /usr/local/lib/pythonX.Y/site-packages/foo
Note that :file:`bletch` is omitted because it doesn't exist; the :file:`bar`
directory precedes the :file:`foo` directory because :file:`bar.pth` comes
Modified: python/branches/tlee-ast-optimize/Doc/library/socket.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/socket.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/socket.rst Wed Oct 1 00:24:45 2008
@@ -219,18 +219,18 @@
.. function:: getaddrinfo(host, port[, family[, socktype[, proto[, flags]]]])
Resolves the *host*/*port* argument, into a sequence of 5-tuples that contain
- all the necessary argument for the sockets manipulation. *host* is a domain
- name, a string representation of IPv4/v6 address or ``None``. *port* is a string
- service name (like ``'http'``), a numeric port number or ``None``.
+ all the necessary arguments for creating the corresponding socket. *host* is a domain
+ name, a string representation of an IPv4/v6 address or ``None``. *port* is a string
+ service name such as ``'http'``, a numeric port number or ``None``.
+ The rest of the arguments are optional and must be numeric if specified.
+ By passing ``None`` as the value of *host* and *port*, , you can pass ``NULL`` to the C API.
- The rest of the arguments are optional and must be numeric if specified. For
- *host* and *port*, by passing ``None``, you can pass ``NULL`` to the C API.
The :func:`getaddrinfo` function returns a list of 5-tuples with the following
structure:
``(family, socktype, proto, canonname, sockaddr)``
- *family*, *socktype*, *proto* are all integer and are meant to be passed to the
+ *family*, *socktype*, *proto* are all integers and are meant to be passed to the
:func:`socket` function. *canonname* is a string representing the canonical name
of the *host*. It can be a numeric IPv4/v6 address when :const:`AI_CANONNAME` is
specified for a numeric *host*. *sockaddr* is a tuple describing a socket
@@ -244,7 +244,7 @@
Return a fully qualified domain name for *name*. If *name* is omitted or empty,
it is interpreted as the local host. To find the fully qualified name, the
- hostname returned by :func:`gethostbyaddr` is checked, then aliases for the
+ hostname returned by :func:`gethostbyaddr` is checked, followed by aliases for the
host, if available. The first name which includes a period is selected. In
case no fully qualified domain name is available, the hostname as returned by
:func:`gethostname` is returned.
Modified: python/branches/tlee-ast-optimize/Doc/library/subprocess.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/subprocess.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/subprocess.rst Wed Oct 1 00:24:45 2008
@@ -138,7 +138,7 @@
.. function:: check_call(*popenargs, **kwargs)
Run command with arguments. Wait for command to complete. If the exit code was
- zero then return, otherwise raise :exc:`CalledProcessError.` The
+ zero then return, otherwise raise :exc:`CalledProcessError`. The
:exc:`CalledProcessError` object will have the return code in the
:attr:`returncode` attribute.
Modified: python/branches/tlee-ast-optimize/Doc/library/turtle.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/turtle.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/turtle.rst Wed Oct 1 00:24:45 2008
@@ -40,10 +40,10 @@
:class:`ScrolledCanvas` as argument. It should be used when :mod:`turtle` is
used as part of some application.
- Derived from :class:`TurtleScreen` is the subclass :class:`Screen`. Screen
- is implemented as sort of singleton, so there can exist only one instance of
- Screen at a time. It should be used when :mod:`turtle` is used as a
- standalone tool for doing graphics.
+ The function :func:`Screen` returns a singleton object of a
+ :class:`TurtleScreen` subclass. This function should be used when
+ :mod:`turtle` is used as a standalone tool for doing graphics.
+ As a singleton object, inheriting from its class is not possible.
All methods of TurtleScreen/Screen also exist as functions, i.e. as part of
the procedure-oriented interface.
Modified: python/branches/tlee-ast-optimize/Doc/library/unittest.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/unittest.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/library/unittest.rst Wed Oct 1 00:24:45 2008
@@ -595,7 +595,8 @@
TestCase.failUnlessAlmostEqual(first, second[, places[, msg]])
Test that *first* and *second* are approximately equal by computing the
- difference, rounding to the given number of *places*, and comparing to zero.
+ difference, rounding to the given number of decimal *places* (default 7),
+ and comparing to zero.
Note that comparing a given number of decimal places is not the same as
comparing a given number of significant digits. If the values do not compare
equal, the test will fail with the explanation given by *msg*, or :const:`None`.
@@ -605,7 +606,8 @@
TestCase.failIfAlmostEqual(first, second[, places[, msg]])
Test that *first* and *second* are not approximately equal by computing the
- difference, rounding to the given number of *places*, and comparing to zero.
+ difference, rounding to the given number of decimal *places* (default 7),
+ and comparing to zero.
Note that comparing a given number of decimal places is not the same as
comparing a given number of significant digits. If the values do not compare
equal, the test will fail with the explanation given by *msg*, or :const:`None`.
Modified: python/branches/tlee-ast-optimize/Doc/reference/expressions.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/expressions.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/reference/expressions.rst Wed Oct 1 00:24:45 2008
@@ -1143,7 +1143,8 @@
control flow statements, the following values are interpreted as false:
``False``, ``None``, numeric zero of all types, and empty strings and containers
(including strings, tuples, lists, dictionaries, sets and frozensets). All
-other values are interpreted as true.
+other values are interpreted as true. (See the :meth:`~object.__nonzero__`
+special method for a way to change this.)
.. index:: operator: not
Modified: python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/reference/simple_stmts.rst Wed Oct 1 00:24:45 2008
@@ -229,7 +229,7 @@
.. productionlist::
augmented_assignment_stmt: `target` `augop` (`expression_list` | `yield_expression`)
- augop: "+=" | "-=" | "*=" | "/=" | "%=" | "**="
+ augop: "+=" | "-=" | "*=" | "/=" | "//=" | "%=" | "**="
: | ">>=" | "<<=" | "&=" | "^=" | "|="
(See section :ref:`primaries` for the syntax definitions for the last three
Modified: python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html (original)
+++ python/branches/tlee-ast-optimize/Doc/tools/sphinxext/download.html Wed Oct 1 00:24:45 2008
@@ -1,21 +1,43 @@
{% extends "layout.html" %}
{% set title = 'Download' %}
+{% set dlbase = 'http://docs.python.org/ftp/python/doc/' + release %}
{% block body %}
-<h1>Download Python {{ release }} Documentation
- {%- if last_updated %} (last updated on {{ last_updated }}){% endif %}</h1>
+<h1>Download Python {{ release }} Documentation</h1>
-<p>Currently, the development documentation isn't packaged for download.</p>
+{% if 'a' in release or 'b' in release or 'c' in release %}
+<p>We don't package the documentation for development releases for download.
+ Downloads will be available for the final release.</p>
+
+{% else %}
+{% if last_updated %}<p><b>Last updated on: {{ last_updated }}.</b></p>{% endif %}
-<!--
<p>To download an archive containing all the documents for this version of
Python in one of various formats, follow one of links in this table. The numbers
in the table are the size of the download files in Kilobytes.</p>
-{# XXX download links #}
+<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>
+ </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>
+ </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>
+ </tr>
+ <tr><td>Plain Text</td>
+ <td><a href="{{ dlbase }}/python-docs-pdf-text.zip">Download</a> (ca. 2 MB)</td>
+ <td><a href="{{ dlbase }}/python-docs-pdf-text.tar.bz2">Download</a> (ca. 1.5 MB)</td>
+ </tr>
+</table>
-<p>These archives contain all the content in the documentation section.</p>
+<p>These archives contain all the content in the documentation.</p>
<h2>Unpacking</h2>
@@ -26,22 +48,13 @@
best compression and fastest download times.</p>
<p>Windows users can use the ZIP archives since those are customary on that
-platform. These are created on Unix using the InfoZIP zip program. They may be
-unpacked using the free WiZ tool (from the InfoZIP developers) or any other
-tool for handling ZIP archives; any of them should work.</p>
-
-<p>Note that the .tar.bz2 files are smaller than the other archives; Windows
-users may want to install the bzip2 tools on their systems as well. Windows
-binaries for a command-line tool are available at <a
-href="http://www.bzip.org">The bzip2 and libbzip2 official home page</a>, but
-most other archiving utilities support the tar and bzip2 formats as well.</p>
+platform. These are created on Unix using the InfoZIP zip program.</p>
<h2>Problems</h2>
<p>If you have comments or suggestions for the Python documentation, please send
email to <a href="docs(a)python.org">docs(a)python.org</a>.</p>
-
--->
+{% endif %}
{% endblock %}
Modified: python/branches/tlee-ast-optimize/Doc/using/windows.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/using/windows.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/using/windows.rst Wed Oct 1 00:24:45 2008
@@ -142,7 +142,7 @@
entries. An example variable could look like this (assuming the first two
entries are Windows' default)::
- C:\WINNT\system32;C:\WINNT;C:\Python25
+ C:\WINDOWS\system32;C:\WINDOWS;C:\Python25
Typing :command:`python` on your command prompt will now fire up the Python
interpreter. Thus, you can also execute your scripts with command line options,
@@ -278,11 +278,11 @@
+====================+==============+=======================+
| :file:`PC/VC6/` | 6.0 | 97 |
+--------------------+--------------+-----------------------+
-| :file:`PCbuild/` | 7.1 | 2003 |
+| :file:`PC/VS7.1/` | 7.1 | 2003 |
+--------------------+--------------+-----------------------+
-| :file:`PCbuild8/` | 8.0 | 2005 |
+| :file:`PC/VS8.0/` | 8.0 | 2005 |
+--------------------+--------------+-----------------------+
-| :file:`PCbuild9/` | 9.0 | 2008 |
+| :file:`PCbuild/` | 9.0 | 2008 |
+--------------------+--------------+-----------------------+
Note that not all of these build directories are fully supported. Read the
Modified: python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst (original)
+++ python/branches/tlee-ast-optimize/Doc/whatsnew/2.6.rst Wed Oct 1 00:24:45 2008
@@ -1806,8 +1806,11 @@
is now available as a standalone package. The web page for the package is
`www.jcea.es/programacion/pybsddb.htm
<http://www.jcea.es/programacion/pybsddb.htm>`__.
+ The plan is to remove the package from the standard library
+ in Python 3.0, because its pace of releases is much more frequent than
+ Python's.
-* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
+ The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
available, instead of restricting itself to protocol 1.
(Contributed by W. Barnes; :issue:`1551443`.)
@@ -1817,6 +1820,12 @@
"/cgi-bin/add.py?category=1". (Contributed by Alexandre Fiori and
Nubis; :issue:`1817`.)
+ The :func:`parse_qs` and :func:`parse_qsl` functions have been
+ relocated from the :mod:`cgi` module to the :mod:`urlparse` module.
+ The versions still available in the :mod:`cgi` module will
+ trigger :exc:`PendingDeprecationWarning` messages in 2.6
+ (:issue:`600362`).
+
* The :mod:`cmath` module underwent extensive revision,
contributed by Mark Dickinson and Christian Heimes.
Five new functions were added:
@@ -1900,6 +1909,11 @@
(Contributed by Raymond Hettinger.)
+* The :mod:`Cookie` module's :class:`Morsel` objects now support an
+ :attr:`httponly` attribute. In some browsers. cookies with this attribute
+ set cannot be accessed or manipulated by JavaScript code.
+ (Contributed by Arvin Schnell; :issue:`1638033`.)
+
* A new window method in the :mod:`curses` module,
:meth:`chgat`, changes the display attributes for a certain number of
characters on a single line. (Contributed by Fabian Kreutz.) ::
@@ -2498,8 +2512,9 @@
``with tempfile.NamedTemporaryFile() as tmp: ...``.
(Contributed by Alexander Belopolsky; :issue:`2021`.)
-* The :mod:`test.test_support` module now contains an
- :func:`EnvironmentVarGuard`
+* The :mod:`test.test_support` module gained a number
+ of context managers useful for writing tests.
+ :func:`EnvironmentVarGuard` is a
context manager that temporarily changes environment variables and
automatically restores them to their old values.
@@ -2514,6 +2529,16 @@
f = urllib.urlopen('https://sf.net')
...
+ Finally, :func:`check_warnings` resets the :mod:`warning` module's
+ warning filters and returns an object that will record all warning
+ messages triggered (:issue:`3781`)::
+
+ with test_support.check_warnings() as wrec:
+ warnings.simplefilter("always")
+ ... code that triggers a warning ...
+ assert str(wrec.message) == "function is outdated"
+ assert len(wrec.warnings) == 1, "Multiple warnings raised"
+
(Contributed by Brett Cannon.)
* The :mod:`textwrap` module can now preserve existing whitespace
@@ -2600,11 +2625,19 @@
(Added by Facundo Batista.)
+* The Unicode database provided by the :mod:`unicodedata` module
+ has been updated to version 5.1.0. (Updated by
+ Martin von Loewis; :issue:`3811`.)
+
* The :mod:`warnings` module's :func:`formatwarning` and :func:`showwarning`
gained an optional *line* argument that can be used to supply the
line of source code. (Added as part of :issue:`1631171`, which re-implemented
part of the :mod:`warnings` module in C code.)
+ A new function, :func:`catch_warnings`, is a context manager
+ intended for testing purposes that lets you temporarily modify the
+ warning filters and then restore their original values (:issue:`3781`).
+
* The XML-RPC :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
classes can now be prevented from immediately opening and binding to
their socket by passing True as the ``bind_and_activate``
Modified: python/branches/tlee-ast-optimize/Include/pystrcmp.h
==============================================================================
--- python/branches/tlee-ast-optimize/Include/pystrcmp.h (original)
+++ python/branches/tlee-ast-optimize/Include/pystrcmp.h Wed Oct 1 00:24:45 2008
@@ -8,7 +8,7 @@
PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t);
PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *);
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) || defined(PYOS_OS2)
#define PyOS_strnicmp strnicmp
#define PyOS_stricmp stricmp
#else
Modified: python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py (original)
+++ python/branches/tlee-ast-optimize/Lib/bsddb/test/test_basics.py Wed Oct 1 00:24:45 2008
@@ -573,6 +573,15 @@
#----------------------------------------
+ def test07_verify(self):
+ # Verify bug solved in 4.7.3pre8
+ self.d.close()
+ d = db.DB(self.env)
+ d.verify(self.filename)
+
+
+ #----------------------------------------
+
#----------------------------------------------------------------------
@@ -602,13 +611,13 @@
#----------------------------------------
- def test07_EnvRemoveAndRename(self):
+ def test08_EnvRemoveAndRename(self):
if not self.env:
return
if verbose:
print '\n', '-=' * 30
- print "Running %s.test07_EnvRemoveAndRename..." % self.__class__.__name__
+ print "Running %s.test08_EnvRemoveAndRename..." % self.__class__.__name__
# can't rename or remove an open DB
self.d.close()
@@ -619,7 +628,7 @@
# dbremove and dbrename are in 4.1 and later
if db.version() < (4,1):
- del test07_EnvRemoveAndRename
+ del test08_EnvRemoveAndRename
#----------------------------------------
@@ -720,11 +729,11 @@
#----------------------------------------
- def test07_TxnTruncate(self):
+ def test08_TxnTruncate(self):
d = self.d
if verbose:
print '\n', '-=' * 30
- print "Running %s.test07_TxnTruncate..." % self.__class__.__name__
+ print "Running %s.test08_TxnTruncate..." % self.__class__.__name__
d.put("abcde", "ABCDE");
txn = self.env.txn_begin()
@@ -737,7 +746,7 @@
#----------------------------------------
- def test08_TxnLateUse(self):
+ def test09_TxnLateUse(self):
txn = self.env.txn_begin()
txn.abort()
try:
@@ -771,11 +780,11 @@
dbtype = db.DB_BTREE
dbsetflags = db.DB_RECNUM
- def test07_RecnoInBTree(self):
+ def test08_RecnoInBTree(self):
d = self.d
if verbose:
print '\n', '-=' * 30
- print "Running %s.test07_RecnoInBTree..." % self.__class__.__name__
+ print "Running %s.test08_RecnoInBTree..." % self.__class__.__name__
rec = d.get(200)
self.assertEqual(type(rec), type(()))
@@ -805,11 +814,11 @@
class BasicDUPTestCase(BasicTestCase):
dbsetflags = db.DB_DUP
- def test08_DuplicateKeys(self):
+ def test09_DuplicateKeys(self):
d = self.d
if verbose:
print '\n', '-=' * 30
- print "Running %s.test08_DuplicateKeys..." % \
+ print "Running %s.test09_DuplicateKeys..." % \
self.__class__.__name__
d.put("dup0", "before")
@@ -878,11 +887,11 @@
else:
return db.DB_BTREE
- def test09_MultiDB(self):
+ def test10_MultiDB(self):
d1 = self.d
if verbose:
print '\n', '-=' * 30
- print "Running %s.test09_MultiDB..." % self.__class__.__name__
+ print "Running %s.test10_MultiDB..." % self.__class__.__name__
d2 = db.DB(self.env)
d2.open(self.filename, "second", self.dbtype,
@@ -1014,9 +1023,20 @@
self.obj = db.DB()
class CrashAndBurn(unittest.TestCase) :
- def test01_OpenCrash(self) :
- # See http://bugs.python.org/issue3307
- self.assertRaises(db.DBInvalidArgError, db.DB, None, 65535)
+ import sys
+ if sys.version_info[:3] < (2, 4, 0):
+ def assertTrue(self, expr, msg=None):
+ self.failUnless(expr,msg=msg)
+
+ #def test01_OpenCrash(self) :
+ # # See http://bugs.python.org/issue3307
+ # self.assertRaises(db.DBInvalidArgError, db.DB, None, 65535)
+
+ def test02_DBEnv_dealloc(self):
+ # http://bugs.python.org/issue3885
+ import gc
+ self.assertRaises(db.DBInvalidArgError, db.DBEnv, ~db.DB_RPCCLIENT)
+ gc.collect()
#----------------------------------------------------------------------
@@ -1044,7 +1064,7 @@
suite.addTest(unittest.makeSuite(HashMultiDBTestCase))
suite.addTest(unittest.makeSuite(DBEnvPrivateObject))
suite.addTest(unittest.makeSuite(DBPrivateObject))
- #suite.addTest(unittest.makeSuite(CrashAndBurn))
+ suite.addTest(unittest.makeSuite(CrashAndBurn))
return suite
Modified: python/branches/tlee-ast-optimize/Lib/collections.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/collections.py (original)
+++ python/branches/tlee-ast-optimize/Lib/collections.py Wed Oct 1 00:24:45 2008
@@ -38,7 +38,7 @@
# generating informative error messages and preventing template injection attacks.
if isinstance(field_names, basestring):
field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas
- field_names = tuple(field_names)
+ field_names = tuple(map(str, field_names))
for name in (typename,) + field_names:
if not all(c.isalnum() or c=='_' for c in name):
raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name)
Modified: python/branches/tlee-ast-optimize/Lib/ctypes/test/test_bitfields.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/ctypes/test/test_bitfields.py (original)
+++ python/branches/tlee-ast-optimize/Lib/ctypes/test/test_bitfields.py Wed Oct 1 00:24:45 2008
@@ -215,6 +215,22 @@
("b", c_ubyte, 4)]
self.failUnlessEqual(sizeof(X), sizeof(c_byte))
+ def test_mixed_4(self):
+ class X(Structure):
+ _fields_ = [("a", c_short, 4),
+ ("b", c_short, 4),
+ ("c", c_int, 24),
+ ("d", c_short, 4),
+ ("e", c_short, 4),
+ ("f", c_int, 24)]
+ # MSVC does NOT combine c_short and c_int into one field, GCC
+ # does (unless GCC is run with '-mms-bitfields' which
+ # produces code compatible with MSVC).
+ if os.name in ("nt", "ce"):
+ self.failUnlessEqual(sizeof(X), sizeof(c_int) * 4)
+ else:
+ self.failUnlessEqual(sizeof(X), sizeof(c_int) * 2)
+
def test_anon_bitfields(self):
# anonymous bit-fields gave a strange error message
class X(Structure):
Modified: python/branches/tlee-ast-optimize/Lib/distutils/tests/test_build_ext.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/distutils/tests/test_build_ext.py (original)
+++ python/branches/tlee-ast-optimize/Lib/distutils/tests/test_build_ext.py Wed Oct 1 00:24:45 2008
@@ -62,8 +62,8 @@
# Get everything back to normal
test_support.unload('xx')
sys.path = self.sys_path
- # XXX on Windows the test leaves a directory with xx.pyd in TEMP
- shutil.rmtree(self.tmp_dir, False if os.name != "nt" else True)
+ # XXX on Windows the test leaves a directory with xx module in TEMP
+ shutil.rmtree(self.tmp_dir, os.name == 'nt' or sys.platform == 'cygwin')
def test_suite():
if not sysconfig.python_build:
Modified: python/branches/tlee-ast-optimize/Lib/ftplib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/ftplib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/ftplib.py Wed Oct 1 00:24:45 2008
@@ -252,7 +252,7 @@
port number.
'''
hbytes = host.split('.')
- pbytes = [repr(port/256), repr(port%256)]
+ pbytes = [repr(port//256), repr(port%256)]
bytes = hbytes + pbytes
cmd = 'PORT ' + ','.join(bytes)
return self.voidcmd(cmd)
Modified: python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib-tk/turtle.py Wed Oct 1 00:24:45 2008
@@ -732,7 +732,7 @@
"""Configure image item as to draw image object
at position (x,y) on canvas)
"""
- self.cv.coords(item, (x, -y))
+ self.cv.coords(item, (x * self.xscale, -y * self.yscale))
self.cv.itemconfig(item, image=image)
def _setbgpic(self, item, image):
@@ -2422,7 +2422,7 @@
shape=_CFG["shape"],
undobuffersize=_CFG["undobuffersize"],
visible=_CFG["visible"]):
- if isinstance(canvas, Screen):
+ if isinstance(canvas, _Screen):
self.screen = canvas
elif isinstance(canvas, TurtleScreen):
if canvas not in RawTurtle.screens:
@@ -3539,29 +3539,33 @@
RawPen = RawTurtle
-### Screen - Klasse ########################
+### Screen - Singleton ########################
-class Screen(TurtleScreen):
+def Screen():
+ """Return the singleton screen object.
+ If none exists at the moment, create a new one and return it,
+ else return the existing one."""
+ if Turtle._screen is None:
+ Turtle._screen = _Screen()
+ return Turtle._screen
+
+class _Screen(TurtleScreen):
_root = None
_canvas = None
_title = _CFG["title"]
- # Borg-Idiom
-
- _shared_state = {}
-
- def __new__(cls, *args, **kwargs):
- obj = object.__new__(cls, *args, **kwargs)
- obj.__dict__ = cls._shared_state
- return obj
-
def __init__(self):
- if Screen._root is None:
- Screen._root = self._root = _Root()
- self._root.title(Screen._title)
+ # XXX there is no need for this code to be conditional,
+ # as there will be only a single _Screen instance, anyway
+ # XXX actually, the turtle demo is injecting root window,
+ # so perhaps the conditional creation of a root should be
+ # preserved (perhaps by passing it as an optional parameter)
+ if _Screen._root is None:
+ _Screen._root = self._root = _Root()
+ self._root.title(_Screen._title)
self._root.ondestroy(self._destroy)
- if Screen._canvas is None:
+ if _Screen._canvas is None:
width = _CFG["width"]
height = _CFG["height"]
canvwidth = _CFG["canvwidth"]
@@ -3569,10 +3573,9 @@
leftright = _CFG["leftright"]
topbottom = _CFG["topbottom"]
self._root.setupcanvas(width, height, canvwidth, canvheight)
- Screen._canvas = self._root._getcanvas()
+ _Screen._canvas = self._root._getcanvas()
self.setup(width, height, leftright, topbottom)
- TurtleScreen.__init__(self, Screen._canvas)
- Turtle._screen = self
+ TurtleScreen.__init__(self, _Screen._canvas)
def setup(self, width=_CFG["width"], height=_CFG["height"],
startx=_CFG["leftright"], starty=_CFG["topbottom"]):
@@ -3626,17 +3629,17 @@
Example (for a Screen instance named screen):
>>> screen.title("Welcome to the turtle-zoo!")
"""
- if Screen._root is not None:
- Screen._root.title(titlestring)
- Screen._title = titlestring
+ if _Screen._root is not None:
+ _Screen._root.title(titlestring)
+ _Screen._title = titlestring
def _destroy(self):
root = self._root
- if root is Screen._root:
+ if root is _Screen._root:
Turtle._pen = None
Turtle._screen = None
- Screen._root = None
- Screen._canvas = None
+ _Screen._root = None
+ _Screen._canvas = None
TurtleScreen._RUNNING = True
root.destroy()
@@ -3728,7 +3731,7 @@
docsdict = {}
for methodname in _tg_screen_functions:
- key = "Screen."+methodname
+ key = "_Screen."+methodname
docsdict[key] = eval(key).__doc__
for methodname in _tg_turtle_functions:
key = "Turtle."+methodname
@@ -3842,14 +3845,14 @@
for methodname in _tg_screen_functions:
- pl1, pl2 = getmethparlist(eval('Screen.' + methodname))
+ pl1, pl2 = getmethparlist(eval('_Screen.' + methodname))
if pl1 == "":
print ">>>>>>", pl1, pl2
continue
defstr = ("def %(key)s%(pl1)s: return _getscreen().%(key)s%(pl2)s" %
{'key':methodname, 'pl1':pl1, 'pl2':pl2})
exec defstr
- eval(methodname).__doc__ = _screen_docrevise(eval('Screen.'+methodname).__doc__)
+ eval(methodname).__doc__ = _screen_docrevise(eval('_Screen.'+methodname).__doc__)
for methodname in _tg_turtle_functions:
pl1, pl2 = getmethparlist(eval('Turtle.' + methodname))
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/main.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/main.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/main.py Wed Oct 1 00:24:45 2008
@@ -10,6 +10,20 @@
from . import refactor
+class StdoutRefactoringTool(refactor.RefactoringTool):
+ """
+ Prints output to stdout.
+ """
+
+ def log_error(self, msg, *args, **kwargs):
+ self.errors.append((msg, args, kwargs))
+ self.logger.error(msg, *args, **kwargs)
+
+ def print_output(self, lines):
+ for line in lines:
+ print line
+
+
def main(fixer_pkg, args=None):
"""Main program.
@@ -68,7 +82,7 @@
fixer_names = avail_names if "all" in options.fix else explicit
else:
fixer_names = avail_names
- rt = refactor.RefactoringTool(fixer_names, rt_opts, explicit=explicit)
+ rt = StdoutRefactoringTool(fixer_names, rt_opts, explicit=explicit)
# Refactor all files and directories passed as arguments
if not rt.errors:
@@ -80,7 +94,3 @@
# Return error status (0 if rt.errors is zero)
return int(bool(rt.errors))
-
-
-if __name__ == "__main__":
- sys.exit(main())
Modified: python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py (original)
+++ python/branches/tlee-ast-optimize/Lib/lib2to3/refactor.py Wed Oct 1 00:24:45 2008
@@ -90,11 +90,18 @@
for fix_name in get_all_fix_names(pkg_name, False)]
+class FixerError(Exception):
+ """A fixer could not be loaded."""
+
+
class RefactoringTool(object):
_default_options = {"print_function": False}
- def __init__(self, fixer_names, options=None, explicit=[]):
+ CLASS_PREFIX = "Fix" # The prefix for fixer classes
+ FILE_PREFIX = "fix_" # The prefix for modules with a fixer within
+
+ def __init__(self, fixer_names, options=None, explicit=None):
"""Initializer.
Args:
@@ -103,7 +110,7 @@
explicit: a list of fixers to run even if they are explicit.
"""
self.fixers = fixer_names
- self.explicit = explicit
+ self.explicit = explicit or []
self.options = self._default_options.copy()
if options is not None:
self.options.update(options)
@@ -134,29 +141,17 @@
pre_order_fixers = []
post_order_fixers = []
for fix_mod_path in self.fixers:
- try:
- mod = __import__(fix_mod_path, {}, {}, ["*"])
- except ImportError:
- self.log_error("Can't load transformation module %s",
- fix_mod_path)
- continue
+ mod = __import__(fix_mod_path, {}, {}, ["*"])
fix_name = fix_mod_path.rsplit(".", 1)[-1]
- if fix_name.startswith("fix_"):
- fix_name = fix_name[4:]
+ if fix_name.startswith(self.FILE_PREFIX):
+ fix_name = fix_name[len(self.FILE_PREFIX):]
parts = fix_name.split("_")
- class_name = "Fix" + "".join([p.title() for p in parts])
+ class_name = self.CLASS_PREFIX + "".join([p.title() for p in parts])
try:
fix_class = getattr(mod, class_name)
except AttributeError:
- self.log_error("Can't find %s.%s",
- fix_name, class_name)
- continue
- try:
- fixer = fix_class(self.options, self.fixer_log)
- except Exception, err:
- self.log_error("Can't instantiate fixes.fix_%s.%s()",
- fix_name, class_name, exc_info=True)
- continue
+ raise FixerError("Can't find %s.%s" % (fix_name, class_name))
+ fixer = fix_class(self.options, self.fixer_log)
if fixer.explicit and self.explicit is not True and \
fix_mod_path not in self.explicit:
self.log_message("Skipping implicit fixer: %s", fix_name)
@@ -168,7 +163,7 @@
elif fixer.order == "post":
post_order_fixers.append(fixer)
else:
- raise ValueError("Illegal fixer order: %r" % fixer.order)
+ raise FixerError("Illegal fixer order: %r" % fixer.order)
key_func = operator.attrgetter("run_order")
pre_order_fixers.sort(key=key_func)
@@ -176,9 +171,8 @@
return (pre_order_fixers, post_order_fixers)
def log_error(self, msg, *args, **kwds):
- """Increments error count and log a message."""
- self.errors.append((msg, args, kwds))
- self.logger.error(msg, *args, **kwds)
+ """Called when an error occurs."""
+ raise
def log_message(self, msg, *args):
"""Hook to log a message."""
@@ -191,13 +185,17 @@
msg = msg % args
self.logger.debug(msg)
+ def print_output(self, lines):
+ """Called with lines of output to give to the user."""
+ pass
+
def refactor(self, items, write=False, doctests_only=False):
"""Refactor a list of files and directories."""
for dir_or_file in items:
if os.path.isdir(dir_or_file):
- self.refactor_dir(dir_or_file, write)
+ self.refactor_dir(dir_or_file, write, doctests_only)
else:
- self.refactor_file(dir_or_file, write)
+ self.refactor_file(dir_or_file, write, doctests_only)
def refactor_dir(self, dir_name, write=False, doctests_only=False):
"""Descends down a directory and refactor every Python file found.
@@ -348,12 +346,11 @@
if old_text == new_text:
self.log_debug("No changes to %s", filename)
return
- diff_texts(old_text, new_text, filename)
- if not write:
- self.log_debug("Not writing changes to %s", filename)
- return
+ self.print_output(diff_texts(old_text, new_text, filename))
if write:
self.write_file(new_text, filename, old_text)
+ else:
+ self.log_debug("Not writing changes to %s", filename)
def write_file(self, new_text, filename, old_text=None):
"""Writes a string to a file.
@@ -528,10 +525,9 @@
def diff_texts(a, b, filename):
- """Prints a unified diff of two strings."""
+ """Return a unified diff of two strings."""
a = a.splitlines()
b = b.splitlines()
- for line in difflib.unified_diff(a, b, filename, filename,
- "(original)", "(refactored)",
- lineterm=""):
- print line
+ return difflib.unified_diff(a, b, filename, filename,
+ "(original)", "(refactored)",
+ lineterm="")
Modified: python/branches/tlee-ast-optimize/Lib/multiprocessing/dummy/__init__.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/multiprocessing/dummy/__init__.py (original)
+++ python/branches/tlee-ast-optimize/Lib/multiprocessing/dummy/__init__.py Wed Oct 1 00:24:45 2008
@@ -54,12 +54,6 @@
else:
return None
- is_alive = threading.Thread.is_alive.im_func
- get_name = threading.Thread.getName.im_func
- set_name = threading.Thread.setName.im_func
- is_daemon = threading.Thread.isDaemon.im_func
- set_daemon = threading.Thread.setDaemon.im_func
-
#
#
#
Modified: python/branches/tlee-ast-optimize/Lib/multiprocessing/synchronize.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/multiprocessing/synchronize.py (original)
+++ python/branches/tlee-ast-optimize/Lib/multiprocessing/synchronize.py Wed Oct 1 00:24:45 2008
@@ -21,6 +21,17 @@
from multiprocessing.util import Finalize, register_after_fork, debug
from multiprocessing.forking import assert_spawning, Popen
+# Try to import the mp.synchronize module cleanly, if it fails
+# raise ImportError for platforms lacking a working sem_open implementation.
+# See issue 3770
+try:
+ from _multiprocessing import SemLock
+except (ImportError):
+ raise ImportError("This platform lacks a functioning sem_open" +
+ " implementation, therefore, the required" +
+ " synchronization primitives needed will not" +
+ " function, see issue 3770.")
+
#
# Constants
#
Modified: python/branches/tlee-ast-optimize/Lib/ssl.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/ssl.py (original)
+++ python/branches/tlee-ast-optimize/Lib/ssl.py Wed Oct 1 00:24:45 2008
@@ -434,7 +434,18 @@
for compability with Python 2.5 and earlier. Will disappear in
Python 3.0."""
- ssl_sock = _ssl.sslwrap(sock._sock, 0, keyfile, certfile, CERT_NONE,
+ if hasattr(sock, "_sock"):
+ sock = sock._sock
+
+ ssl_sock = _ssl.sslwrap(sock, 0, keyfile, certfile, CERT_NONE,
PROTOCOL_SSLv23, None)
- ssl_sock.do_handshake()
+ try:
+ sock.getpeername()
+ except:
+ # no, no connection yet
+ pass
+ else:
+ # yes, do the handshake
+ ssl_sock.do_handshake()
+
return ssl_sock
Modified: python/branches/tlee-ast-optimize/Lib/test/regrtest.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/regrtest.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/regrtest.py Wed Oct 1 00:24:45 2008
@@ -1047,6 +1047,7 @@
test_tcl
test_timeout
test_urllibnet
+ test_multiprocessing
""",
'aix5':
"""
@@ -1077,6 +1078,7 @@
test_ossaudiodev
test_pep277
test_tcl
+ test_multiprocessing
""",
'netbsd3':
"""
@@ -1092,6 +1094,7 @@
test_ossaudiodev
test_pep277
test_tcl
+ test_multiprocessing
""",
}
_expectations['freebsd5'] = _expectations['freebsd4']
Modified: python/branches/tlee-ast-optimize/Lib/test/string_tests.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/string_tests.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/string_tests.py Wed Oct 1 00:24:45 2008
@@ -120,6 +120,14 @@
self.checkequal(2, 'aaa', 'count', '', -1)
self.checkequal(4, 'aaa', 'count', '', -10)
+ self.checkequal(1, '', 'count', '')
+ self.checkequal(0, '', 'count', '', 1, 1)
+ self.checkequal(0, '', 'count', '', sys.maxint, 0)
+
+ self.checkequal(0, '', 'count', 'xx')
+ self.checkequal(0, '', 'count', 'xx', 1, 1)
+ self.checkequal(0, '', 'count', 'xx', sys.maxint, 0)
+
self.checkraises(TypeError, 'hello', 'count')
self.checkraises(TypeError, 'hello', 'count', 42)
@@ -169,6 +177,14 @@
self.checkraises(TypeError, 'hello', 'find')
self.checkraises(TypeError, 'hello', 'find', 42)
+ self.checkequal(0, '', 'find', '')
+ self.checkequal(-1, '', 'find', '', 1, 1)
+ self.checkequal(-1, '', 'find', '', sys.maxint, 0)
+
+ self.checkequal(-1, '', 'find', 'xx')
+ self.checkequal(-1, '', 'find', 'xx', 1, 1)
+ self.checkequal(-1, '', 'find', 'xx', sys.maxint, 0)
+
# For a variety of combinations,
# verify that str.find() matches __contains__
# and that the found substring is really at that location
Modified: python/branches/tlee-ast-optimize/Lib/test/test_atexit.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_atexit.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_atexit.py Wed Oct 1 00:24:45 2008
@@ -22,6 +22,19 @@
atexit._exithandlers = save_handlers
self.assertEqual(s.getvalue(), "h4 (4,) {'kw': 'abc'}\nh4 () {}\nh1\n")
+ def test_badargs(self):
+ s = StringIO.StringIO()
+ sys.stdout = sys.stderr = s
+ save_handlers = atexit._exithandlers
+ atexit._exithandlers = []
+ try:
+ atexit.register(lambda: 1, 0, 0, (x for x in (1,2)), 0, 0)
+ self.assertRaises(TypeError, atexit._run_exitfuncs)
+ finally:
+ sys.stdout = sys.__stdout__
+ sys.stderr = sys.__stderr__
+ atexit._exithandlers = save_handlers
+
def test_order(self):
# be sure handlers are executed in reverse order
s = StringIO.StringIO()
Modified: python/branches/tlee-ast-optimize/Lib/test/test_collections.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_collections.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_collections.py Wed Oct 1 00:24:45 2008
@@ -34,6 +34,11 @@
namedtuple('Point0', 'x1 y2') # Verify that numbers are allowed in names
namedtuple('_', 'a b c') # Test leading underscores in a typename
+ nt = namedtuple('nt', u'the quick brown fox') # check unicode input
+ self.assert_("u'" not in repr(nt._fields))
+ nt = namedtuple('nt', (u'the', u'quick')) # check unicode input
+ self.assert_("u'" not in repr(nt._fields))
+
self.assertRaises(TypeError, Point._make, [11]) # catch too few args
self.assertRaises(TypeError, Point._make, [11, 22, 33]) # catch too many args
Modified: python/branches/tlee-ast-optimize/Lib/test/test_cprofile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_cprofile.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_cprofile.py Wed Oct 1 00:24:45 2008
@@ -1,7 +1,7 @@
"""Test suite for the cProfile module."""
import sys
-from test.test_support import run_unittest
+from test.test_support import run_unittest, TESTFN, unlink
# rip off all interesting stuff from test_profile
import cProfile
@@ -10,6 +10,20 @@
class CProfileTest(ProfileTest):
profilerclass = cProfile.Profile
+ # Issue 3895.
+ def test_bad_counter_during_dealloc(self):
+ import _lsprof
+ # Must use a file as StringIO doesn't trigger the bug.
+ sys.stderr = open(TESTFN, 'w')
+ try:
+ obj = _lsprof.Profiler(lambda: int)
+ obj.enable()
+ obj = _lsprof.Profiler(1)
+ obj.disable()
+ finally:
+ sys.stderr = sys.__stderr__
+ unlink(TESTFN)
+
def test_main():
run_unittest(CProfileTest)
Modified: python/branches/tlee-ast-optimize/Lib/test/test_file.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_file.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_file.py Wed Oct 1 00:24:45 2008
@@ -134,6 +134,16 @@
f.close()
self.fail('%r is an invalid file mode' % mode)
+ # Some invalid modes fail on Windows, but pass on Unix
+ # Issue3965: avoid a crash on Windows when filename is unicode
+ for name in (TESTFN, unicode(TESTFN), unicode(TESTFN + '\t')):
+ try:
+ f = open(name, "rr")
+ except IOError:
+ pass
+ else:
+ f.close()
+
def testStdin(self):
# This causes the interpreter to exit on OSF1 v5.1.
if sys.platform != 'osf1V5':
Modified: python/branches/tlee-ast-optimize/Lib/test/test_ftplib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_ftplib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_ftplib.py Wed Oct 1 00:24:45 2008
@@ -1,43 +1,411 @@
-import socket
-import threading
+"""Test script for ftplib module."""
+
+# Modified by Giampaolo Rodola' to test FTP class and IPv6 environment
+
import ftplib
-import time
+import threading
+import asyncore
+import asynchat
+import socket
+import StringIO
from unittest import TestCase
from test import test_support
+from test.test_support import HOST
-HOST = test_support.HOST
-# This function sets the evt 3 times:
-# 1) when the connection is ready to be accepted.
-# 2) when it is safe for the caller to close the connection
-# 3) when we have closed the socket
-def server(evt, serv):
- serv.listen(5)
- # (1) Signal the caller that we are ready to accept the connection.
- evt.set()
- try:
- conn, addr = serv.accept()
- except socket.timeout:
- pass
- else:
- conn.send("1 Hola mundo\n")
- # (2) Signal the caller that it is safe to close the socket.
- evt.set()
+# the dummy data returned by server over the data channel when
+# RETR, LIST and NLST commands are issued
+RETR_DATA = 'abcde12345\r\n' * 1000
+LIST_DATA = 'foo\r\nbar\r\n'
+NLST_DATA = 'foo\r\nbar\r\n'
+
+
+class DummyDTPHandler(asynchat.async_chat):
+
+ def __init__(self, conn, baseclass):
+ asynchat.async_chat.__init__(self, conn)
+ self.baseclass = baseclass
+ self.baseclass.last_received_data = ''
+
+ def handle_read(self):
+ self.baseclass.last_received_data += self.recv(1024)
+
+ def handle_close(self):
+ self.baseclass.push('226 transfer complete')
+ self.close()
+
+
+class DummyFTPHandler(asynchat.async_chat):
+
+ def __init__(self, conn):
+ asynchat.async_chat.__init__(self, conn)
+ self.set_terminator("\r\n")
+ self.in_buffer = []
+ self.dtp = None
+ self.last_received_cmd = None
+ self.last_received_data = ''
+ self.next_response = ''
+ self.push('220 welcome')
+
+ def collect_incoming_data(self, data):
+ self.in_buffer.append(data)
+
+ def found_terminator(self):
+ line = ''.join(self.in_buffer)
+ self.in_buffer = []
+ if self.next_response:
+ self.push(self.next_response)
+ self.next_response = ''
+ cmd = line.split(' ')[0].lower()
+ self.last_received_cmd = cmd
+ space = line.find(' ')
+ if space != -1:
+ arg = line[space + 1:]
+ else:
+ arg = ""
+ if hasattr(self, 'cmd_' + cmd):
+ method = getattr(self, 'cmd_' + cmd)
+ method(arg)
+ else:
+ self.push('550 command "%s" not understood.' %cmd)
+
+ def handle_error(self):
+ raise
+
+ def push(self, data):
+ asynchat.async_chat.push(self, data + '\r\n')
+
+ def cmd_port(self, arg):
+ addr = map(int, arg.split(','))
+ ip = '%d.%d.%d.%d' %tuple(addr[:4])
+ port = (addr[4] * 256) + addr[5]
+ s = socket.create_connection((ip, port), timeout=2)
+ self.dtp = DummyDTPHandler(s, baseclass=self)
+ self.push('200 active data connection established')
+
+ def cmd_pasv(self, arg):
+ sock = socket.socket()
+ sock.bind((self.socket.getsockname()[0], 0))
+ sock.listen(5)
+ sock.settimeout(2)
+ ip, port = sock.getsockname()[:2]
+ ip = ip.replace('.', ','); p1 = port / 256; p2 = port % 256
+ self.push('227 entering passive mode (%s,%d,%d)' %(ip, p1, p2))
+ conn, addr = sock.accept()
+ self.dtp = DummyDTPHandler(conn, baseclass=self)
+
+ def cmd_eprt(self, arg):
+ af, ip, port = arg.split(arg[0])[1:-1]
+ port = int(port)
+ s = socket.create_connection((ip, port), timeout=2)
+ self.dtp = DummyDTPHandler(s, baseclass=self)
+ self.push('200 active data connection established')
+
+ def cmd_epsv(self, arg):
+ sock = socket.socket(socket.AF_INET6)
+ sock.bind((self.socket.getsockname()[0], 0))
+ sock.listen(5)
+ sock.settimeout(2)
+ port = sock.getsockname()[1]
+ self.push('229 entering extended passive mode (|||%d|)' %port)
+ conn, addr = sock.accept()
+ self.dtp = DummyDTPHandler(conn, baseclass=self)
+
+ def cmd_echo(self, arg):
+ # sends back the received string (used by the test suite)
+ self.push(arg)
+
+ def cmd_user(self, arg):
+ self.push('331 username ok')
+
+ def cmd_pass(self, arg):
+ self.push('230 password ok')
+
+ def cmd_acct(self, arg):
+ self.push('230 acct ok')
+
+ def cmd_rnfr(self, arg):
+ self.push('350 rnfr ok')
+
+ def cmd_rnto(self, arg):
+ self.push('250 rnto ok')
+
+ def cmd_dele(self, arg):
+ self.push('250 dele ok')
+
+ def cmd_cwd(self, arg):
+ self.push('250 cwd ok')
+
+ def cmd_size(self, arg):
+ self.push('250 1000')
+
+ def cmd_mkd(self, arg):
+ self.push('257 "%s"' %arg)
+
+ def cmd_rmd(self, arg):
+ self.push('250 rmd ok')
+
+ def cmd_pwd(self, arg):
+ self.push('257 "pwd ok"')
+
+ def cmd_type(self, arg):
+ self.push('200 type ok')
+
+ def cmd_quit(self, arg):
+ self.push('221 quit ok')
+ self.close()
+
+ def cmd_stor(self, arg):
+ self.push('125 stor ok')
+
+ def cmd_retr(self, arg):
+ self.push('125 retr ok')
+ self.dtp.push(RETR_DATA)
+ self.dtp.close_when_done()
+
+ def cmd_list(self, arg):
+ self.push('125 list ok')
+ self.dtp.push(LIST_DATA)
+ self.dtp.close_when_done()
+
+ def cmd_nlst(self, arg):
+ self.push('125 nlst ok')
+ self.dtp.push(NLST_DATA)
+ self.dtp.close_when_done()
+
+
+class DummyFTPServer(asyncore.dispatcher, threading.Thread):
+
+ handler = DummyFTPHandler
+
+ def __init__(self, address, af=socket.AF_INET):
+ threading.Thread.__init__(self)
+ asyncore.dispatcher.__init__(self)
+ self.create_socket(af, socket.SOCK_STREAM)
+ self.bind(address)
+ self.listen(5)
+ self.active = False
+ self.active_lock = threading.Lock()
+ self.host, self.port = self.socket.getsockname()[:2]
+
+ def start(self):
+ assert not self.active
+ self.__flag = threading.Event()
+ threading.Thread.start(self)
+ self.__flag.wait()
+
+ def run(self):
+ self.active = True
+ self.__flag.set()
+ while self.active and asyncore.socket_map:
+ self.active_lock.acquire()
+ asyncore.loop(timeout=0.1, count=1)
+ self.active_lock.release()
+ asyncore.close_all(ignore_all=True)
+
+ def stop(self):
+ assert self.active
+ self.active = False
+ self.join()
+
+ def handle_accept(self):
+ conn, addr = self.accept()
+ self.handler = self.handler(conn)
+ self.close()
+
+ def handle_connect(self):
+ self.close()
+ handle_read = handle_connect
+
+ def writable(self):
+ return 0
+
+ def handle_error(self):
+ raise
+
+
+class TestFTPClass(TestCase):
+
+ def setUp(self):
+ self.server = DummyFTPServer((HOST, 0))
+ self.server.start()
+ self.client = ftplib.FTP(timeout=2)
+ self.client.connect(self.server.host, self.server.port)
+
+ def tearDown(self):
+ self.client.close()
+ self.server.stop()
+
+ def test_getwelcome(self):
+ self.assertEqual(self.client.getwelcome(), '220 welcome')
+
+ def test_sanitize(self):
+ self.assertEqual(self.client.sanitize('foo'), repr('foo'))
+ self.assertEqual(self.client.sanitize('pass 12345'), repr('pass *****'))
+ self.assertEqual(self.client.sanitize('PASS 12345'), repr('PASS *****'))
+
+ def test_exceptions(self):
+ self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 400')
+ self.assertRaises(ftplib.error_temp, self.client.sendcmd, 'echo 499')
+ self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 500')
+ self.assertRaises(ftplib.error_perm, self.client.sendcmd, 'echo 599')
+ self.assertRaises(ftplib.error_proto, self.client.sendcmd, 'echo 999')
+
+ def test_all_errors(self):
+ exceptions = (ftplib.error_reply, ftplib.error_temp, ftplib.error_perm,
+ ftplib.error_proto, ftplib.Error, IOError, EOFError)
+ for x in exceptions:
+ try:
+ raise x('exception not included in all_errors set')
+ except ftplib.all_errors:
+ pass
+
+ def test_set_pasv(self):
+ # passive mode is supposed to be enabled by default
+ self.assertTrue(self.client.passiveserver)
+ self.client.set_pasv(True)
+ self.assertTrue(self.client.passiveserver)
+ self.client.set_pasv(False)
+ self.assertFalse(self.client.passiveserver)
+
+ def test_voidcmd(self):
+ self.client.voidcmd('echo 200')
+ self.client.voidcmd('echo 299')
+ self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 199')
+ self.assertRaises(ftplib.error_reply, self.client.voidcmd, 'echo 300')
+
+ def test_login(self):
+ self.client.login()
+
+ def test_acct(self):
+ self.client.acct('passwd')
+
+ def test_rename(self):
+ self.client.rename('a', 'b')
+ self.server.handler.next_response = '200'
+ self.assertRaises(ftplib.error_reply, self.client.rename, 'a', 'b')
+
+ def test_delete(self):
+ self.client.delete('foo')
+ self.server.handler.next_response = '199'
+ self.assertRaises(ftplib.error_reply, self.client.delete, 'foo')
+
+ def test_size(self):
+ self.client.size('foo')
+
+ def test_mkd(self):
+ dir = self.client.mkd('/foo')
+ self.assertEqual(dir, '/foo')
+
+ def test_rmd(self):
+ self.client.rmd('foo')
+
+ def test_pwd(self):
+ dir = self.client.pwd()
+ self.assertEqual(dir, 'pwd ok')
+
+ def test_quit(self):
+ self.assertEqual(self.client.quit(), '221 quit ok')
+ # Ensure the connection gets closed; sock attribute should be None
+ self.assertEqual(self.client.sock, None)
+
+ def test_retrbinary(self):
+ received = []
+ self.client.retrbinary('retr', received.append)
+ self.assertEqual(''.join(received), RETR_DATA)
+
+ def test_retrlines(self):
+ received = []
+ self.client.retrlines('retr', received.append)
+ self.assertEqual(''.join(received), RETR_DATA.replace('\r\n', ''))
+
+ def test_storbinary(self):
+ f = StringIO.StringIO(RETR_DATA)
+ self.client.storbinary('stor', f)
+ self.assertEqual(self.server.handler.last_received_data, RETR_DATA)
+ # test new callback arg
+ flag = []
+ f.seek(0)
+ self.client.storbinary('stor', f, callback=lambda x: flag.append(None))
+ self.assertTrue(flag)
+
+ def test_storlines(self):
+ f = StringIO.StringIO(RETR_DATA.replace('\r\n', '\n'))
+ self.client.storlines('stor', f)
+ self.assertEqual(self.server.handler.last_received_data, RETR_DATA)
+ # test new callback arg
+ flag = []
+ f.seek(0)
+ self.client.storlines('stor foo', f, callback=lambda x: flag.append(None))
+ self.assertTrue(flag)
+
+ def test_nlst(self):
+ self.client.nlst()
+ self.assertEqual(self.client.nlst(), NLST_DATA.split('\r\n')[:-1])
+
+ def test_dir(self):
+ l = []
+ self.client.dir(lambda x: l.append(x))
+ self.assertEqual(''.join(l), LIST_DATA.replace('\r\n', ''))
+
+ def test_makeport(self):
+ self.client.makeport()
+ # IPv4 is in use, just make sure send_eprt has not been used
+ self.assertEqual(self.server.handler.last_received_cmd, 'port')
+
+ def test_makepasv(self):
+ host, port = self.client.makepasv()
+ conn = socket.create_connection((host, port), 2)
conn.close()
- finally:
- serv.close()
- # (3) Signal the caller that we are done.
- evt.set()
+ # IPv4 is in use, just make sure send_epsv has not been used
+ self.assertEqual(self.server.handler.last_received_cmd, 'pasv')
+
-class GeneralTests(TestCase):
+class TestIPv6Environment(TestCase):
+
+ def setUp(self):
+ self.server = DummyFTPServer((HOST, 0), af=socket.AF_INET6)
+ self.server.start()
+ self.client = ftplib.FTP()
+ self.client.connect(self.server.host, self.server.port)
+
+ def tearDown(self):
+ self.client.close()
+ self.server.stop()
+
+ def test_af(self):
+ self.assertEqual(self.client.af, socket.AF_INET6)
+
+ def test_makeport(self):
+ self.client.makeport()
+ self.assertEqual(self.server.handler.last_received_cmd, 'eprt')
+
+ def test_makepasv(self):
+ host, port = self.client.makepasv()
+ conn = socket.create_connection((host, port), 2)
+ conn.close()
+ self.assertEqual(self.server.handler.last_received_cmd, 'epsv')
+
+ def test_transfer(self):
+ def retr():
+ received = []
+ self.client.retrbinary('retr', received.append)
+ self.assertEqual(''.join(received), RETR_DATA)
+ self.client.set_pasv(True)
+ retr()
+ self.client.set_pasv(False)
+ retr()
+
+
+class TestTimeouts(TestCase):
def setUp(self):
self.evt = threading.Event()
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.settimeout(3)
self.port = test_support.bind_port(self.sock)
- threading.Thread(target=server, args=(self.evt,self.sock)).start()
+ threading.Thread(target=self.server, args=(self.evt,self.sock)).start()
# Wait for the server to be ready.
self.evt.wait()
self.evt.clear()
@@ -46,14 +414,27 @@
def tearDown(self):
self.evt.wait()
- def testBasic(self):
- # do nothing
- ftplib.FTP()
-
- # connects
- ftp = ftplib.FTP(HOST)
- self.evt.wait()
- ftp.close()
+ def server(self, evt, serv):
+ # This method sets the evt 3 times:
+ # 1) when the connection is ready to be accepted.
+ # 2) when it is safe for the caller to close the connection
+ # 3) when we have closed the socket
+ serv.listen(5)
+ # (1) Signal the caller that we are ready to accept the connection.
+ evt.set()
+ try:
+ conn, addr = serv.accept()
+ except socket.timeout:
+ pass
+ else:
+ conn.send("1 Hola mundo\n")
+ # (2) Signal the caller that it is safe to close the socket.
+ evt.set()
+ conn.close()
+ finally:
+ serv.close()
+ # (3) Signal the caller that we are done.
+ evt.set()
def testTimeoutDefault(self):
# default -- use global socket timeout
@@ -109,8 +490,21 @@
ftp.close()
-def test_main(verbose=None):
- test_support.run_unittest(GeneralTests)
+def test_main():
+ tests = [TestFTPClass, TestTimeouts]
+ if socket.has_ipv6:
+ try:
+ DummyFTPServer((HOST, 0), af=socket.AF_INET6)
+ except socket.error:
+ pass
+ else:
+ tests.append(TestIPv6Environment)
+ thread_info = test_support.threading_setup()
+ try:
+ test_support.run_unittest(*tests)
+ finally:
+ test_support.threading_cleanup(*thread_info)
+
if __name__ == '__main__':
test_main()
Modified: python/branches/tlee-ast-optimize/Lib/test/test_imageop.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_imageop.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_imageop.py Wed Oct 1 00:24:45 2008
@@ -5,13 +5,74 @@
Roger E. Masse
"""
-from test.test_support import verbose, unlink, import_module
+from test.test_support import verbose, unlink, import_module, run_unittest
imageop = import_module('imageop', deprecated=True)
-import uu, os, imgfile
+import uu, os, unittest
+
+
+SIZES = (1, 2, 3, 4)
+_VALUES = (1, 2, 2**10, 2**15-1, 2**15, 2**15+1, 2**31-2, 2**31-1)
+VALUES = tuple( -x for x in reversed(_VALUES) ) + (0,) + _VALUES
+AAAAA = "A" * 1024
+
+
+class InputValidationTests(unittest.TestCase):
+
+ def _check(self, name, size=None, *extra):
+ func = getattr(imageop, name)
+ for height in VALUES:
+ for width in VALUES:
+ strlen = abs(width * height)
+ if size:
+ strlen *= size
+ if strlen < 1024:
+ data = "A" * strlen
+ else:
+ data = AAAAA
+ if size:
+ arguments = (data, size, width, height) + extra
+ else:
+ arguments = (data, width, height) + extra
+ try:
+ func(*arguments)
+ except (ValueError, imageop.error):
+ pass
+
+ def check_size(self, name, *extra):
+ for size in SIZES:
+ self._check(name, size, *extra)
+
+ def check(self, name, *extra):
+ self._check(name, None, *extra)
+
+ def test_input_validation(self):
+ self.check_size("crop", 0, 0, 0, 0)
+ self.check_size("scale", 1, 0)
+ self.check_size("scale", -1, -1)
+ self.check_size("tovideo")
+ self.check("grey2mono", 128)
+ self.check("grey2grey4")
+ self.check("grey2grey2")
+ self.check("dither2mono")
+ self.check("dither2grey2")
+ self.check("mono2grey", 0, 0)
+ self.check("grey22grey")
+ self.check("rgb2rgb8") # nlen*4 == len
+ self.check("rgb82rgb")
+ self.check("rgb2grey")
+ self.check("grey2rgb")
+
def test_main():
+ run_unittest(InputValidationTests)
+
+ try:
+ import imgfile
+ except ImportError:
+ return
+
# Create binary test files
uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')
Modified: python/branches/tlee-ast-optimize/Lib/test/test_io.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_io.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_io.py Wed Oct 1 00:24:45 2008
@@ -201,7 +201,7 @@
# On Windows and Mac OSX this test comsumes large resources; It takes
# a long time to build the >2GB file and takes >2GB of disk space
# therefore the resource must be enabled to run this test.
- if sys.platform[:3] == 'win' or sys.platform == 'darwin':
+ if sys.platform[:3] in ('win', 'os2') or sys.platform == 'darwin':
if not test_support.is_resource_enabled("largefile"):
print("\nTesting large file ops skipped on %s." % sys.platform,
file=sys.stderr)
Modified: python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_lib2to3.py Wed Oct 1 00:24:45 2008
@@ -1,13 +1,13 @@
# Skipping test_parser and test_all_fixers
# because of running
-from lib2to3.tests import test_fixers, test_pytree, test_util
+from lib2to3.tests import test_fixers, test_pytree, test_util, test_refactor
import unittest
from test.test_support import run_unittest
def suite():
tests = unittest.TestSuite()
loader = unittest.TestLoader()
- for m in (test_fixers,test_pytree,test_util):
+ for m in (test_fixers,test_pytree,test_util, test_refactor):
tests.addTests(loader.loadTestsFromModule(m))
return tests
Modified: python/branches/tlee-ast-optimize/Lib/test/test_multiprocessing.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_multiprocessing.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_multiprocessing.py Wed Oct 1 00:24:45 2008
@@ -18,6 +18,14 @@
import random
import logging
+
+# Work around broken sem_open implementations
+try:
+ import multiprocessing.synchronize
+except ImportError, e:
+ from test.test_support import TestSkipped
+ raise TestSkipped(e)
+
import multiprocessing.dummy
import multiprocessing.connection
import multiprocessing.managers
Modified: python/branches/tlee-ast-optimize/Lib/test/test_ssl.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_ssl.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_ssl.py Wed Oct 1 00:24:45 2008
@@ -34,6 +34,21 @@
if test_support.verbose:
sys.stdout.write(prefix + exc_format)
+ def testSimpleSSLwrap(self):
+ try:
+ ssl.sslwrap_simple(socket.socket(socket.AF_INET))
+ except IOError, e:
+ if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that
+ pass
+ else:
+ raise
+ try:
+ ssl.sslwrap_simple(socket.socket(socket.AF_INET)._sock)
+ except IOError, e:
+ if e.errno == 32: # broken pipe when ssl_sock.do_handshake(), this test doesn't care about that
+ pass
+ else:
+ raise
class BasicTests(unittest.TestCase):
@@ -58,7 +73,6 @@
finally:
s.close()
-
def testCrucialConstants(self):
ssl.PROTOCOL_SSLv2
ssl.PROTOCOL_SSLv23
Modified: python/branches/tlee-ast-optimize/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_tarfile.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_tarfile.py Wed Oct 1 00:24:45 2008
@@ -787,6 +787,7 @@
self.tar.add(self.foo)
def tearDown(self):
+ self.tar.close()
os.remove(self.foo)
os.remove(self.bar)
Modified: python/branches/tlee-ast-optimize/Lib/test/test_urllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_urllib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_urllib.py Wed Oct 1 00:24:45 2008
@@ -94,6 +94,31 @@
for line in self.returned_obj.__iter__():
self.assertEqual(line, self.text)
+
+class ProxyTests(unittest.TestCase):
+
+ def setUp(self):
+ unittest.TestCase.setUp(self)
+ # Save all proxy related env vars
+ self._saved_environ = dict([(k, v) for k, v in os.environ.iteritems()
+ if k.lower().find('proxy') >= 0])
+ # Delete all proxy related env vars
+ for k in self._saved_environ:
+ del os.environ[k]
+
+ def tearDown(self):
+ unittest.TestCase.tearDown(self)
+ # Restore all proxy related env vars
+ for k, v in self._saved_environ:
+ os.environ[k] = v
+
+ def test_getproxies_environment_keep_no_proxies(self):
+ os.environ['NO_PROXY'] = 'localhost'
+ proxies = urllib.getproxies_environment()
+ # getproxies_environment use lowered case truncated (no '_proxy') keys
+ self.assertEquals('localhost', proxies['no'])
+
+
class urlopen_HttpTests(unittest.TestCase):
"""Test urlopen() opening a fake http connection."""
@@ -648,6 +673,7 @@
urlopen_FileTests,
urlopen_HttpTests,
urlretrieve_FileTests,
+ ProxyTests,
QuotingTests,
UnquotingTests,
urlencode_Tests,
Modified: python/branches/tlee-ast-optimize/Lib/urllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/urllib.py (original)
+++ python/branches/tlee-ast-optimize/Lib/urllib.py Wed Oct 1 00:24:45 2008
@@ -1299,9 +1299,6 @@
proxies = {}
for name, value in os.environ.items():
name = name.lower()
- if name == 'no_proxy':
- # handled in proxy_bypass_environment
- continue
if value and name[-6:] == '_proxy':
proxies[name[:-6]] = value
return proxies
Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS (original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS Wed Oct 1 00:24:45 2008
@@ -12,9 +12,31 @@
Core and Builtins
-----------------
+- Issue #3967: Fixed a crash in the count() and find() methods of string-like
+ objects, when the "start" parameter is a huge value.
+
+- Issue #3965: Fixed a crash on Windows when open() is given an invalid
+ filename or mode, and the filename is a unicode string.
+
+- Bug #3951: Py_USING_MEMORY_DEBUGGER should not be enabled by default.
+
Library
-------
+- Issue #3965: Allow repeated calls to turtle.Screen, by making it a
+ true singleton object.
+
+- Issue #3895: It was possible to crash the interpreter when an external timer
+ was used with cProfile that returned an object that could not be converted
+ into a float.
+
+- Issue #3950: Made turtle respect scale factors.
+
+- Issue #3547: Fixed ctypes structures bitfields of varying integer
+ sizes.
+
+- Issue #3879: A regression in urllib.getproxies_enviroment was fixed.
+
Build
-----
@@ -32,6 +54,9 @@
Extension Modules
-----------------
+- Security Issue #2: imageop did not validate arguments correctly and could
+ segfault as a result.
+
- Issue #3886: Possible integer overflows in the _hashopenssl module were
closed.
@@ -655,7 +680,7 @@
- Support for Windows 9x has been removed from the winsound module.
-- bsddb module updated to version 4.7.3pre2.
+- bsddb module updated to version 4.7.3.
http://www.jcea.es/programacion/pybsddb.htm#bsddb3-4.7.3. This
code should be compatible with Python 3.0.
Modified: python/branches/tlee-ast-optimize/Modules/Setup.dist
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/Setup.dist (original)
+++ python/branches/tlee-ast-optimize/Modules/Setup.dist Wed Oct 1 00:24:45 2008
@@ -176,7 +176,7 @@
#_weakref _weakref.c # basic weak reference support
#_testcapi _testcapimodule.c # Python C API test module
#_random _randommodule.c # Random number generator
-#collections collectionsmodule.c # Container types
+#_collections _collectionsmodule.c # Container types
#itertools itertoolsmodule.c # Functions creating iterators for efficient looping
#strop stropmodule.c # String manipulations
Modified: python/branches/tlee-ast-optimize/Modules/_bsddb.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_bsddb.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_bsddb.c Wed Oct 1 00:24:45 2008
@@ -989,7 +989,7 @@
/* Forward declaration */
-static PyObject *DB_close_internal(DBObject* self, int flags);
+static PyObject *DB_close_internal(DBObject* self, int flags, int do_not_close);
static void
DB_dealloc(DBObject* self)
@@ -997,8 +997,15 @@
PyObject *dummy;
if (self->db != NULL) {
- dummy=DB_close_internal(self,0);
- Py_XDECREF(dummy);
+ dummy=DB_close_internal(self, 0, 0);
+ /*
+ ** Raising exceptions while doing
+ ** garbage collection is a fatal error.
+ */
+ if (dummy)
+ Py_DECREF(dummy);
+ else
+ PyErr_Clear();
}
if (self->in_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *) self);
@@ -1052,8 +1059,15 @@
PyObject *dummy;
if (self->dbc != NULL) {
- dummy=DBC_close_internal(self);
- Py_XDECREF(dummy);
+ dummy=DBC_close_internal(self);
+ /*
+ ** Raising exceptions while doing
+ ** garbage collection is a fatal error.
+ */
+ if (dummy)
+ Py_DECREF(dummy);
+ else
+ PyErr_Clear();
}
if (self->in_weakreflist != NULL) {
PyObject_ClearWeakRefs((PyObject *) self);
@@ -1071,6 +1085,7 @@
if (self == NULL)
return NULL;
+ self->db_env = NULL;
self->closed = 1;
self->flags = flags;
self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE;
@@ -1107,8 +1122,15 @@
PyObject *dummy;
if (self->db_env) {
- dummy=DBEnv_close_internal(self,0);
- Py_XDECREF(dummy);
+ dummy=DBEnv_close_internal(self, 0);
+ /*
+ ** Raising exceptions while doing
+ ** garbage collection is a fatal error.
+ */
+ if (dummy)
+ Py_DECREF(dummy);
+ else
+ PyErr_Clear();
}
Py_XDECREF(self->event_notifyCallback);
@@ -1186,8 +1208,17 @@
if (self->txn) {
int flag_prepare = self->flag_prepare;
+
dummy=DBTxn_abort_discard_internal(self,0);
- Py_XDECREF(dummy);
+ /*
+ ** Raising exceptions while doing
+ ** garbage collection is a fatal error.
+ */
+ if (dummy)
+ Py_DECREF(dummy);
+ else
+ PyErr_Clear();
+
if (!flag_prepare) {
PyErr_Warn(PyExc_RuntimeWarning,
"DBTxn aborted in destructor. No prior commit() or abort().");
@@ -1280,7 +1311,14 @@
if (self->sequence != NULL) {
dummy=DBSequence_close_internal(self,0,0);
- Py_XDECREF(dummy);
+ /*
+ ** Raising exceptions while doing
+ ** garbage collection is a fatal error.
+ */
+ if (dummy)
+ Py_DECREF(dummy);
+ else
+ PyErr_Clear();
}
if (self->in_weakreflist != NULL) {
@@ -1485,10 +1523,10 @@
static PyObject*
-DB_close_internal(DBObject* self, int flags)
+DB_close_internal(DBObject* self, int flags, int do_not_close)
{
PyObject *dummy;
- int err;
+ int err = 0;
if (self->db != NULL) {
/* Can be NULL if db is not in an environment */
@@ -1511,10 +1549,20 @@
}
#endif
- MYDB_BEGIN_ALLOW_THREADS;
- err = self->db->close(self->db, flags);
- MYDB_END_ALLOW_THREADS;
- self->db = NULL;
+ /*
+ ** "do_not_close" is used to dispose all related objects in the
+ ** tree, without actually releasing the "root" object.
+ ** This is done, for example, because function calls like
+ ** "DB.verify()" implicitly close the underlying handle. So
+ ** the handle doesn't need to be closed, but related objects
+ ** must be cleaned up.
+ */
+ if (!do_not_close) {
+ MYDB_BEGIN_ALLOW_THREADS;
+ err = self->db->close(self->db, flags);
+ MYDB_END_ALLOW_THREADS;
+ self->db = NULL;
+ }
RETURN_IF_ERR();
}
RETURN_NONE();
@@ -1526,7 +1574,7 @@
int flags=0;
if (!PyArg_ParseTuple(args,"|i:close", &flags))
return NULL;
- return DB_close_internal(self,flags);
+ return DB_close_internal(self, flags, 0);
}
@@ -2146,7 +2194,7 @@
if (makeDBError(err)) {
PyObject *dummy;
- dummy=DB_close_internal(self,0);
+ dummy=DB_close_internal(self, 0, 0);
Py_XDECREF(dummy);
return NULL;
}
@@ -2840,21 +2888,24 @@
/* XXX(nnorwitz): it should probably be an exception if outFile
can't be opened. */
- MYDB_BEGIN_ALLOW_THREADS;
- err = self->db->verify(self->db, fileName, dbName, outFile, flags);
- MYDB_END_ALLOW_THREADS;
- if (outFile)
- fclose(outFile);
-
{ /* DB.verify acts as a DB handle destructor (like close) */
PyObject *error;
- error=DB_close_internal(self,0);
+ error=DB_close_internal(self, 0, 1);
if (error ) {
return error;
}
}
+ MYDB_BEGIN_ALLOW_THREADS;
+ err = self->db->verify(self->db, fileName, dbName, outFile, flags);
+ MYDB_END_ALLOW_THREADS;
+
+ self->db = NULL; /* Implicit close; related objects already released */
+
+ if (outFile)
+ fclose(outFile);
+
RETURN_IF_ERR();
RETURN_NONE();
}
@@ -3978,7 +4029,7 @@
Py_XDECREF(dummy);
}
while(self->children_dbs) {
- dummy=DB_close_internal(self->children_dbs,0);
+ dummy=DB_close_internal(self->children_dbs, 0, 0);
Py_XDECREF(dummy);
}
}
@@ -4003,7 +4054,7 @@
if (!PyArg_ParseTuple(args, "|i:close", &flags))
return NULL;
- return DBEnv_close_internal(self,flags);
+ return DBEnv_close_internal(self, flags);
}
@@ -5949,7 +6000,7 @@
}
#endif
while (self->children_dbs) {
- dummy=DB_close_internal(self->children_dbs,0);
+ dummy=DB_close_internal(self->children_dbs, 0, 0);
Py_XDECREF(dummy);
}
@@ -6030,6 +6081,14 @@
self->txn=NULL;
}
+ /*
+ ** "do_not_close" is used to dispose all related objects in the
+ ** tree, without actually releasing the "root" object.
+ ** This is done, for example, because function calls like
+ ** "DBSequence.remove()" implicitly close the underlying handle. So
+ ** the handle doesn't need to be closed, but related objects
+ ** must be cleaned up.
+ */
if (!do_not_close) {
MYDB_BEGIN_ALLOW_THREADS
err = self->sequence->close(self->sequence, flags);
Modified: python/branches/tlee-ast-optimize/Modules/_bytesio.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_bytesio.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_bytesio.c Wed Oct 1 00:24:45 2008
@@ -221,6 +221,8 @@
if (PyInt_Check(arg)) {
size = PyInt_AsSsize_t(arg);
+ if (size == -1 && PyErr_Occurred())
+ return NULL;
}
else if (arg == Py_None) {
/* Read until EOF is reached, by default. */
@@ -288,6 +290,8 @@
if (PyInt_Check(arg)) {
size = PyInt_AsSsize_t(arg);
+ if (size == -1 && PyErr_Occurred())
+ return NULL;
}
else if (arg == Py_None) {
/* No size limit, by default. */
@@ -332,6 +336,8 @@
if (PyInt_Check(arg)) {
maxsize = PyInt_AsSsize_t(arg);
+ if (maxsize == -1 && PyErr_Occurred())
+ return NULL;
}
else if (arg == Py_None) {
/* No size limit, by default. */
@@ -415,6 +421,8 @@
if (PyInt_Check(arg)) {
size = PyInt_AsSsize_t(arg);
+ if (size == -1 && PyErr_Occurred())
+ return NULL;
}
else if (arg == Py_None) {
/* Truncate to current position if no argument is passed. */
Modified: python/branches/tlee-ast-optimize/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_ctypes/cfield.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_ctypes/cfield.c Wed Oct 1 00:24:45 2008
@@ -65,10 +65,12 @@
}
if (bitsize /* this is a bitfield request */
&& *pfield_size /* we have a bitfield open */
-#if defined(MS_WIN32) && !defined(__MINGW32__)
- && dict->size * 8 == *pfield_size /* MSVC */
+#ifdef MS_WIN32
+ /* MSVC, GCC with -mms-bitfields */
+ && dict->size * 8 == *pfield_size
#else
- && dict->size * 8 <= *pfield_size /* GCC, MINGW */
+ /* GCC */
+ && dict->size * 8 <= *pfield_size
#endif
&& (*pbitofs + bitsize) <= *pfield_size) {
/* continue bit field */
@@ -163,7 +165,7 @@
break;
case EXPAND_BITFIELD:
- /* XXX needs more */
+ *poffset += dict->size - *pfield_size/8;
*psize += dict->size - *pfield_size/8;
*pfield_size = dict->size * 8;
Modified: python/branches/tlee-ast-optimize/Modules/_fileio.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_fileio.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_fileio.c Wed Oct 1 00:24:45 2008
@@ -831,7 +831,7 @@
};
PyTypeObject PyFileIO_Type = {
- PyVarObject_HEAD_INIT(&PyType_Type, 0)
+ PyVarObject_HEAD_INIT(NULL, 0)
"_FileIO",
sizeof(PyFileIOObject),
0,
Modified: python/branches/tlee-ast-optimize/Modules/_lsprof.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_lsprof.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_lsprof.c Wed Oct 1 00:24:45 2008
@@ -150,7 +150,16 @@
}
Py_DECREF(o);
if (PyErr_Occurred()) {
- PyErr_WriteUnraisable((PyObject *) pObj);
+ PyObject *context = (PyObject *)pObj;
+ /* May have been called by profiler_dealloc(). */
+ if (Py_REFCNT(context) < 1) {
+ context = PyString_FromString("profiler calling an "
+ "external timer");
+ if (context == NULL) {
+ return 0;
+ }
+ }
+ PyErr_WriteUnraisable(context);
return 0;
}
return result;
Modified: python/branches/tlee-ast-optimize/Modules/_struct.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/_struct.c (original)
+++ python/branches/tlee-ast-optimize/Modules/_struct.c Wed Oct 1 00:24:45 2008
@@ -1755,6 +1755,8 @@
/* Extract the offset from the first argument */
offset = PyInt_AsSsize_t(PyTuple_GET_ITEM(args, 1));
+ if (offset == -1 && PyErr_Occurred())
+ return NULL;
/* Support negative offsets. */
if (offset < 0)
Modified: python/branches/tlee-ast-optimize/Modules/bsddb.h
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/bsddb.h (original)
+++ python/branches/tlee-ast-optimize/Modules/bsddb.h Wed Oct 1 00:24:45 2008
@@ -105,7 +105,7 @@
#error "eek! DBVER can't handle minor versions > 9"
#endif
-#define PY_BSDDB_VERSION "4.7.3pre5"
+#define PY_BSDDB_VERSION "4.7.3"
/* Python object definitions */
Modified: python/branches/tlee-ast-optimize/Modules/imageop.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/imageop.c (original)
+++ python/branches/tlee-ast-optimize/Modules/imageop.c Wed Oct 1 00:24:45 2008
@@ -26,6 +26,46 @@
static PyObject *ImageopError;
static PyObject *ImageopDict;
+/**
+ * Check a coordonnate, make sure that (0 < value).
+ * Return 0 on error.
+ */
+static int
+check_coordonnate(int value, const char* name)
+{
+ if ( 0 < value)
+ return 1;
+ PyErr_Format(PyExc_ValueError, "%s value is negative or nul", name);
+ return 0;
+}
+
+/**
+ * Check integer overflow to make sure that product == x*y*size.
+ * Return 0 on error.
+ */
+static int
+check_multiply_size(int product, int x, const char* xname, int y, const char* yname, int size)
+{
+ if ( !check_coordonnate(x, xname) )
+ return 0;
+ if ( !check_coordonnate(y, yname) )
+ return 0;
+ if ( size == (product / y) / x )
+ return 1;
+ PyErr_SetString(ImageopError, "String has incorrect length");
+ return 0;
+}
+
+/**
+ * Check integer overflow to make sure that product == x*y.
+ * Return 0 on error.
+ */
+static int
+check_multiply(int product, int x, int y)
+{
+ return check_multiply_size(product, x, "x", y, "y", 1);
+}
+
/* If this function returns true (the default if anything goes wrong), we're
behaving in a backward-compatible way with respect to how multi-byte pixels
are stored in the strings. The code in this module was originally written
@@ -85,26 +125,21 @@
if ( !PyArg_ParseTuple(args, "s#iiiiiii", &cp, &len, &size, &x, &y,
&newx1, &newy1, &newx2, &newy2) )
return 0;
-
+
if ( size != 1 && size != 2 && size != 4 ) {
PyErr_SetString(ImageopError, "Size should be 1, 2 or 4");
return 0;
}
- if (( len != size*x*y ) ||
- ( size != ((len / x) / y) )) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(len, x, "x", y, "y", size) )
return 0;
- }
+
xstep = (newx1 < newx2)? 1 : -1;
ystep = (newy1 < newy2)? 1 : -1;
-
+
nlen = (abs(newx2-newx1)+1)*(abs(newy2-newy1)+1)*size;
- if ( size != ((nlen / (abs(newx2-newx1)+1)) / (abs(newy2-newy1)+1)) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(nlen, abs(newx2-newx1)+1, "abs(newx2-newx1)+1", abs(newy2-newy1)+1, "abs(newy2-newy1)+1", size) )
return 0;
- }
- rv = PyString_FromStringAndSize(NULL,
- (abs(newx2-newx1)+1)*(abs(newy2-newy1)+1)*size);
+ rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
ncp = (char *)PyString_AsString(rv);
@@ -131,7 +166,7 @@
}
return rv;
}
-
+
static PyObject *
imageop_scale(PyObject *self, PyObject *args)
{
@@ -146,22 +181,17 @@
if ( !PyArg_ParseTuple(args, "s#iiiii",
&cp, &len, &size, &x, &y, &newx, &newy) )
return 0;
-
+
if ( size != 1 && size != 2 && size != 4 ) {
PyErr_SetString(ImageopError, "Size should be 1, 2 or 4");
return 0;
}
- if ( ( len != size*x*y ) ||
- ( size != ((len / x) / y) ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(len, x, "x", y, "y", size) )
return 0;
- }
nlen = newx*newy*size;
- if ( size != ((nlen / newx) / newy) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(nlen, newx, "newx", newy, "newy", size) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
@@ -193,8 +223,8 @@
unsigned char *cp, *ncp;
int width;
PyObject *rv;
-
-
+
+
if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &width, &maxx, &maxy) )
return 0;
@@ -202,12 +232,9 @@
PyErr_SetString(ImageopError, "Size should be 1 or 4");
return 0;
}
- if ( ( maxx*maxy*width != len ) ||
- ( maxx != ((len / maxy) / width) ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(len, maxx, "max", maxy, "maxy", width) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, len);
if ( rv == 0 )
return 0;
@@ -248,17 +275,14 @@
unsigned char ovalue;
PyObject *rv;
int i, bit;
-
-
+
+
if ( !PyArg_ParseTuple(args, "s#iii", &cp, &len, &x, &y, &tres) )
return 0;
- if ( ( x*y != len ) ||
- ( x != len / y ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, (len+7)/8);
if ( rv == 0 )
return 0;
@@ -290,17 +314,14 @@
PyObject *rv;
int i;
int pos;
-
-
+
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- if ( ( x*y != len ) ||
- ( x != len / y ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, (len+1)/2);
if ( rv == 0 )
return 0;
@@ -330,17 +351,14 @@
PyObject *rv;
int i;
int pos;
-
-
+
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- if ( ( x*y != len ) ||
- ( x != len / y ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, (len+3)/4);
if ( rv == 0 )
return 0;
@@ -369,17 +387,14 @@
unsigned char ovalue;
PyObject *rv;
int i, bit;
-
-
+
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- if ( ( x*y != len ) ||
- ( x != len / y ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, (len+7)/8);
if ( rv == 0 )
return 0;
@@ -416,17 +431,14 @@
int i;
int pos;
int sum = 0, nvalue;
-
-
+
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- if ( ( x*y != len ) ||
- ( x != len / y ) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, (len+3)/4);
if ( rv == 0 )
return 0;
@@ -457,20 +469,18 @@
unsigned char *cp, *ncp;
PyObject *rv;
int i, bit;
-
+
if ( !PyArg_ParseTuple(args, "s#iiii", &cp, &len, &x, &y, &v0, &v1) )
return 0;
nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(nlen, x, y) )
return 0;
- }
if ( (nlen+7)/8 != len ) {
PyErr_SetString(ImageopError, "String has incorrect length");
return 0;
}
-
+
rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
@@ -498,20 +508,19 @@
unsigned char *cp, *ncp;
PyObject *rv;
int i, pos, value = 0, nvalue;
-
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(nlen, x, y) ) {
return 0;
}
if ( (nlen+3)/4 != len ) {
PyErr_SetString(ImageopError, "String has incorrect length");
return 0;
}
-
+
rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
@@ -538,20 +547,18 @@
unsigned char *cp, *ncp;
PyObject *rv;
int i, pos, value = 0, nvalue;
-
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(nlen, x, y) )
return 0;
- }
if ( (nlen+1)/2 != len ) {
PyErr_SetString(ImageopError, "String has incorrect length");
return 0;
}
-
+
rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
@@ -579,20 +586,16 @@
PyObject *rv;
int i, r, g, b;
int backward_compatible = imageop_backward_compatible();
-
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(len*4, x, "x", y, "y", 4) )
return 0;
- }
- if ( nlen*4 != len ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ nlen = x*y;
+ if ( !check_multiply(nlen, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
@@ -627,31 +630,22 @@
int i, r, g, b;
unsigned char value;
int backward_compatible = imageop_backward_compatible();
-
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
- return 0;
- }
- if ( nlen != len ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
-
- if ( nlen / x != y || nlen > INT_MAX / 4) {
- PyErr_SetString(ImageopError, "Image is too large");
+ nlen = x*y*4;
+ if ( !check_multiply_size(nlen, x, "x", y, "y", 4) )
return 0;
- }
-
- rv = PyString_FromStringAndSize(NULL, nlen*4);
+
+ rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
ncp = (unsigned char *)PyString_AsString(rv);
- for ( i=0; i < nlen; i++ ) {
+ for ( i=0; i < len; i++ ) {
/* Bits in source: RRRBBGGG
** Red and Green are multiplied by 36.5, Blue by 85
*/
@@ -686,20 +680,16 @@
int i, r, g, b;
int nvalue;
int backward_compatible = imageop_backward_compatible();
-
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply_size(len, x, "x", y, "y", 4) )
return 0;
- }
- if ( nlen*4 != len ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ nlen = x*y;
+ if ( !check_multiply(nlen, x, y) )
return 0;
- }
-
+
rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
@@ -735,31 +725,22 @@
int i;
unsigned char value;
int backward_compatible = imageop_backward_compatible();
-
+
if ( !PyArg_ParseTuple(args, "s#ii", &cp, &len, &x, &y) )
return 0;
- nlen = x*y;
- if ( x != (nlen / y) ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ if ( !check_multiply(len, x, y) )
return 0;
- }
- if ( nlen != len ) {
- PyErr_SetString(ImageopError, "String has incorrect length");
+ nlen = x*y*4;
+ if ( !check_multiply_size(nlen, x, "x", y, "y", 4) )
return 0;
- }
-
- if ( nlen / x != y || nlen > INT_MAX / 4) {
- PyErr_SetString(ImageopError, "Image is too large");
- return 0;
- }
-
- rv = PyString_FromStringAndSize(NULL, nlen*4);
+
+ rv = PyString_FromStringAndSize(NULL, nlen);
if ( rv == 0 )
return 0;
ncp = (unsigned char *)PyString_AsString(rv);
- for ( i=0; i < nlen; i++ ) {
+ for ( i=0; i < len; i++ ) {
value = *cp++;
if (backward_compatible) {
* (Py_UInt32 *) ncp = (Py_UInt32) value | ((Py_UInt32) value << 8 ) | ((Py_UInt32) value << 16);
@@ -774,39 +755,6 @@
return rv;
}
-/*
-static object *
-imageop_mul(object *self, object *args)
-{
- char *cp, *ncp;
- int len, size, x, y;
- object *rv;
- int i;
-
- if ( !getargs(args, "(s#iii)", &cp, &len, &size, &x, &y) )
- return 0;
-
- if ( size != 1 && size != 4 ) {
- err_setstr(ImageopError, "Size should be 1 or 4");
- return 0;
- }
- if ( len != size*x*y ) {
- err_setstr(ImageopError, "String has incorrect length");
- return 0;
- }
-
- rv = newsizedstringobject(NULL, XXXX);
- if ( rv == 0 )
- return 0;
- ncp = (char *)getstringvalue(rv);
-
-
- for ( i=0; i < len; i += size ) {
- }
- return rv;
-}
-*/
-
static PyMethodDef imageop_methods[] = {
{ "crop", imageop_crop, METH_VARARGS },
{ "scale", imageop_scale, METH_VARARGS },
@@ -831,11 +779,11 @@
initimageop(void)
{
PyObject *m;
-
+
if (PyErr_WarnPy3k("the imageop module has been removed in "
"Python 3.0", 2) < 0)
return;
-
+
m = Py_InitModule("imageop", imageop_methods);
if (m == NULL)
return;
Modified: python/branches/tlee-ast-optimize/Modules/selectmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/selectmodule.c (original)
+++ python/branches/tlee-ast-optimize/Modules/selectmodule.c Wed Oct 1 00:24:45 2008
@@ -1607,7 +1607,7 @@
}
PyDoc_STRVAR(kqueue_queue_control_doc,
-"control(changelist, max_events=0[, timeout=None]) -> eventlist\n\
+"control(changelist, max_events[, timeout=None]) -> eventlist\n\
\n\
Calls the kernel kevent function.\n\
- changelist must be a list of kevent objects describing the changes\n\
Modified: python/branches/tlee-ast-optimize/Objects/fileobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/fileobject.c (original)
+++ python/branches/tlee-ast-optimize/Objects/fileobject.c Wed Oct 1 00:24:45 2008
@@ -305,10 +305,17 @@
#endif
/* EINVAL is returned when an invalid filename or
* an invalid mode is supplied. */
- if (errno == EINVAL)
- PyErr_Format(PyExc_IOError,
- "invalid filename: %s or mode: %s",
- name, mode);
+ if (errno == EINVAL) {
+ PyObject *v;
+ char message[100];
+ PyOS_snprintf(message, 100,
+ "invalid mode ('%.50s') or filename", mode);
+ v = Py_BuildValue("(isO)", errno, message, f->f_name);
+ if (v != NULL) {
+ PyErr_SetObject(PyExc_IOError, v);
+ Py_DECREF(v);
+ }
+ }
else
PyErr_SetFromErrnoWithFilenameObject(PyExc_IOError, f->f_name);
f = NULL;
Modified: python/branches/tlee-ast-optimize/Objects/floatobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/floatobject.c (original)
+++ python/branches/tlee-ast-optimize/Objects/floatobject.c Wed Oct 1 00:24:45 2008
@@ -1339,12 +1339,12 @@
s++;
/* infinities and nans */
- if (PyOS_mystrnicmp(s, "nan", 4) == 0) {
+ if (PyOS_strnicmp(s, "nan", 4) == 0) {
x = Py_NAN;
goto finished;
}
- if (PyOS_mystrnicmp(s, "inf", 4) == 0 ||
- PyOS_mystrnicmp(s, "infinity", 9) == 0) {
+ if (PyOS_strnicmp(s, "inf", 4) == 0 ||
+ PyOS_strnicmp(s, "infinity", 9) == 0) {
x = sign*Py_HUGE_VAL;
goto finished;
}
Modified: python/branches/tlee-ast-optimize/Objects/obmalloc.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/obmalloc.c (original)
+++ python/branches/tlee-ast-optimize/Objects/obmalloc.c Wed Oct 1 00:24:45 2008
@@ -677,8 +677,8 @@
/* This is only useful when running memory debuggers such as
* Purify or Valgrind. Uncomment to use.
*
- */
#define Py_USING_MEMORY_DEBUGGER
+ */
#ifdef Py_USING_MEMORY_DEBUGGER
Modified: python/branches/tlee-ast-optimize/Objects/stringlib/count.h
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/stringlib/count.h (original)
+++ python/branches/tlee-ast-optimize/Objects/stringlib/count.h Wed Oct 1 00:24:45 2008
@@ -13,11 +13,10 @@
{
Py_ssize_t count;
- if (sub_len == 0) {
- if (str_len < 0)
- return 0; /* start > len(str) */
+ if (str_len < 0)
+ return 0; /* start > len(str) */
+ if (sub_len == 0)
return str_len + 1;
- }
count = fastsearch(str, str_len, sub, sub_len, FAST_COUNT);
Modified: python/branches/tlee-ast-optimize/Objects/stringlib/find.h
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/stringlib/find.h (original)
+++ python/branches/tlee-ast-optimize/Objects/stringlib/find.h Wed Oct 1 00:24:45 2008
@@ -14,11 +14,10 @@
{
Py_ssize_t pos;
- if (sub_len == 0) {
- if (str_len < 0)
- return -1;
+ if (str_len < 0)
+ return -1;
+ if (sub_len == 0)
return offset;
- }
pos = fastsearch(str, str_len, sub, sub_len, FAST_SEARCH);
Modified: python/branches/tlee-ast-optimize/PC/os2emx/Makefile
==============================================================================
--- python/branches/tlee-ast-optimize/PC/os2emx/Makefile (original)
+++ python/branches/tlee-ast-optimize/PC/os2emx/Makefile Wed Oct 1 00:24:45 2008
@@ -287,7 +287,7 @@
Modules/binascii.c \
Modules/cmathmodule.c \
Modules/_codecsmodule.c \
- Modules/collectionsmodule.c \
+ Modules/_collectionsmodule.c \
Modules/cPickle.c \
Modules/cStringIO.c \
Modules/_csv.c \
@@ -295,6 +295,7 @@
Modules/dlmodule.c \
Modules/errnomodule.c \
Modules/fcntlmodule.c \
+ Modules/_fileio.c \
Modules/_functoolsmodule.c \
Modules/_heapqmodule.c \
Modules/imageop.c \
@@ -305,7 +306,6 @@
Modules/md5module.c \
Modules/operator.c \
Modules/_randommodule.c \
- Modules/rgbimgmodule.c \
Modules/shamodule.c \
Modules/sha256module.c \
Modules/sha512module.c \
@@ -343,6 +343,8 @@
Python/compile.c \
Python/codecs.c \
Python/errors.c \
+ Python/formatter_string.c \
+ Python/formatter_unicode.c \
Python/frozen.c \
Python/frozenmain.c \
Python/future.c \
@@ -359,8 +361,10 @@
Python/modsupport.c \
Python/mysnprintf.c \
Python/mystrtoul.c \
+ Python/peephole.c \
Python/pyarena.c \
Python/pyfpe.c \
+ Python/pymath.c \
Python/pystate.c \
Python/pystrtod.c \
Python/pythonrun.c \
@@ -370,11 +374,14 @@
Python/traceback.c \
Python/getopt.c \
Python/dynload_shlib.c \
- Python/thread.c)
+ Python/thread.c \
+ Python/_warnings.c)
SRC.OBJECT= $(addprefix $(TOP), \
Objects/abstract.c \
Objects/boolobject.c \
Objects/bufferobject.c \
+ Objects/bytearrayobject.c \
+ Objects/bytes_methods.c \
Objects/cellobject.c \
Objects/classobject.c \
Objects/cobject.c \
Modified: python/branches/tlee-ast-optimize/PC/os2emx/config.c
==============================================================================
--- python/branches/tlee-ast-optimize/PC/os2emx/config.c (original)
+++ python/branches/tlee-ast-optimize/PC/os2emx/config.c Wed Oct 1 00:24:45 2008
@@ -52,12 +52,13 @@
extern void initbinascii();
extern void initcPickle();
extern void initcStringIO();
-extern void initcollections();
+extern void init_collections();
extern void initcmath();
extern void initdatetime();
extern void initdl();
extern void initerrno();
extern void initfcntl();
+extern void init_fileio();
extern void init_functools();
extern void init_heapq();
extern void initimageop();
@@ -65,7 +66,6 @@
extern void initmath();
extern void init_md5();
extern void initoperator();
-extern void initrgbimg();
extern void init_sha();
extern void init_sha256();
extern void init_sha512();
@@ -118,12 +118,13 @@
{"binascii", initbinascii},
{"cPickle", initcPickle},
{"cStringIO", initcStringIO},
- {"collections", initcollections},
+ {"_collections", init_collections},
{"cmath", initcmath},
{"datetime", initdatetime},
{"dl", initdl},
{"errno", initerrno},
{"fcntl", initfcntl},
+ {"_fileio", init_fileio},
{"_functools", init_functools},
{"_heapq", init_heapq},
{"imageop", initimageop},
@@ -131,7 +132,6 @@
{"math", initmath},
{"_md5", init_md5},
{"operator", initoperator},
- {"rgbimg", initrgbimg},
{"_sha", init_sha},
{"_sha256", init_sha256},
{"_sha512", init_sha512},
Modified: python/branches/tlee-ast-optimize/PC/os2emx/pyconfig.h
==============================================================================
--- python/branches/tlee-ast-optimize/PC/os2emx/pyconfig.h (original)
+++ python/branches/tlee-ast-optimize/PC/os2emx/pyconfig.h Wed Oct 1 00:24:45 2008
@@ -264,6 +264,9 @@
/* Define if you have the <conio.h> header file. */
#undef HAVE_CONIO_H
+/* Define to 1 if you have the `copysign' function. */
+#define HAVE_COPYSIGN 1
+
/* Define if you have the <direct.h> header file. */
#undef HAVE_DIRECT_H
Modified: python/branches/tlee-ast-optimize/PCbuild/readme.txt
==============================================================================
--- python/branches/tlee-ast-optimize/PCbuild/readme.txt (original)
+++ python/branches/tlee-ast-optimize/PCbuild/readme.txt Wed Oct 1 00:24:45 2008
@@ -21,7 +21,7 @@
The PCbuild directory is compatible with all versions of Visual Studio from
VS C++ Express Edition over the standard edition up to the professional
-edition. However the express edition does support features like solution
+edition. However the express edition does not support features like solution
folders or profile guided optimization (PGO). The missing bits and pieces
won't stop you from building Python.
@@ -104,7 +104,7 @@
Python-controlled subprojects that wrap external projects:
_bsddb
- Wraps Berkeley DB 4.4.20, which is currently built by _bsddb44.vcproj.
+ Wraps Berkeley DB 4.7.25, which is currently built by _bsddb.vcproj.
project (see below).
_sqlite3
Wraps SQLite 3.5.9, which is currently built by sqlite3.vcproj (see below).
@@ -153,7 +153,7 @@
build process will automatically select the latest version.
You must install the NASM assembler from
- http://www.kernel.org/pub/software/devel/nasm/binaries/win32/
+ http://nasm.sf.net
for x86 builds. Put nasmw.exe anywhere in your PATH.
You can also install ActivePerl from
@@ -213,7 +213,7 @@
This will be cleaned up in the future; ideally Tcl/Tk will be brought into our
pcbuild.sln as custom .vcproj files, just as we've recently done with the
-_bsddb44.vcproj and sqlite3.vcproj files, which will remove the need for
+_bsddb.vcproj and sqlite3.vcproj files, which will remove the need for
Tcl/Tk to be built separately via a batch file.
XXX trent.nelson 02-Apr-08:
Modified: python/branches/tlee-ast-optimize/Python/pymath.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/pymath.c (original)
+++ python/branches/tlee-ast-optimize/Python/pymath.c Wed Oct 1 00:24:45 2008
@@ -35,6 +35,8 @@
#endif /* HAVE_COPYSIGN */
#ifndef HAVE_LOG1P
+#include <float.h>
+
double
log1p(double x)
{
Modified: python/branches/tlee-ast-optimize/setup.py
==============================================================================
--- python/branches/tlee-ast-optimize/setup.py (original)
+++ python/branches/tlee-ast-optimize/setup.py Wed Oct 1 00:24:45 2008
@@ -1269,6 +1269,14 @@
)
libraries = []
+ elif platform.startswith('openbsd'):
+ macros = dict( # OpenBSD
+ HAVE_SEM_OPEN=0, # Not implemented
+ HAVE_SEM_TIMEDWAIT=0,
+ HAVE_FD_TRANSFER=1,
+ )
+ libraries = []
+
else: # Linux and other unices
macros = dict(
HAVE_SEM_OPEN=1,
1
0
The Buildbot has detected a new failure of AMD64 W2k8 trunk.
Full details are available at:
http://www.python.org/dev/buildbot/all/AMD64%20W2k8%20trunk/builds/976
Buildbot URL: http://www.python.org/dev/buildbot/all/
Buildslave for this Build: nelson-win64
Build Reason:
Build Source Stamp: [branch trunk] HEAD
Blamelist: gregory.p.smith
BUILD FAILED: failed test
Excerpt from the test logfile:
1 test failed:
test_strptime
sincerely,
-The Buildbot
1
0
r66703 - in python/trunk: Doc/library/os.rst Lib/test/test_threading.py Misc/NEWS
by gregory.p.smith 30 Sep '08
by gregory.p.smith 30 Sep '08
30 Sep '08
Author: gregory.p.smith
Date: Tue Sep 30 22:41:13 2008
New Revision: 66703
Log:
Works around issue3863: freebsd4/5/6 and os2emx are known to have OS bugs when
calling fork() from a child thread. This disables that unit test (with a note
printed to stderr) on those platforms.
A caveat about buggy platforms is added to the os.fork documentation.
Modified:
python/trunk/Doc/library/os.rst
python/trunk/Lib/test/test_threading.py
python/trunk/Misc/NEWS
Modified: python/trunk/Doc/library/os.rst
==============================================================================
--- python/trunk/Doc/library/os.rst (original)
+++ python/trunk/Doc/library/os.rst Tue Sep 30 22:41:13 2008
@@ -1646,6 +1646,10 @@
Fork a child process. Return ``0`` in the child and the child's process id in the
parent. If an error occurs :exc:`OSError` is raised.
+
+ Note that some platforms including FreeBSD <= 6.3, Cygwin and OS/2 EMX have
+ known issues when using fork() from a thread.
+
Availability: Unix.
Modified: python/trunk/Lib/test/test_threading.py
==============================================================================
--- python/trunk/Lib/test/test_threading.py (original)
+++ python/trunk/Lib/test/test_threading.py Tue Sep 30 22:41:13 2008
@@ -380,6 +380,12 @@
import os
if not hasattr(os, 'fork'):
return
+ # Skip platforms with known problems forking from a worker thread.
+ # See http://bugs.python.org/issue3863.
+ if sys.platform in ('freebsd4', 'freebsd5', 'freebsd6', 'os2emx'):
+ print >>sys.stderr, ('Skipping test_3_join_in_forked_from_thread'
+ ' due to known OS bugs on'), sys.platform
+ return
script = """if 1:
main_thread = threading.current_thread()
def worker():
Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Tue Sep 30 22:41:13 2008
@@ -37,6 +37,9 @@
- Issue #3879: A regression in urllib.getproxies_enviroment was fixed.
+- Issue #3863: Disabled a unit test of fork being called from a thread
+ when running on platforms known to exhibit OS bugs when attempting that.
+
Build
-----
1
0
The Buildbot has detected a new failure of sparc Debian 2.5.
Full details are available at:
http://www.python.org/dev/buildbot/all/sparc%20Debian%202.5/builds/102
Buildbot URL: http://www.python.org/dev/buildbot/all/
Buildslave for this Build: klose-debian-sparc
Build Reason:
Build Source Stamp: [branch branches/release25-maint] HEAD
Blamelist: brett.cannon
BUILD FAILED: failed test
Excerpt from the test logfile:
1 test failed:
test_subprocess
make: *** [buildbottest] Error 1
sincerely,
-The Buildbot
1
0
Author: brett.cannon
Date: Tue Sep 30 19:47:50 2008
New Revision: 66701
Log:
Fix a refleak introduced by r66678 (backport of r66700).
Modified:
python/branches/release25-maint/Modules/_lsprof.c
Modified: python/branches/release25-maint/Modules/_lsprof.c
==============================================================================
--- python/branches/release25-maint/Modules/_lsprof.c (original)
+++ python/branches/release25-maint/Modules/_lsprof.c Tue Sep 30 19:47:50 2008
@@ -150,16 +150,7 @@
}
Py_DECREF(o);
if (PyErr_Occurred()) {
- PyObject *context = (PyObject *)pObj;
- /* May have been called by profiler_dealloc(). */
- if (context->ob_refcnt < 1) {
- context = PyString_FromString("profiler calling an "
- "external timer");
- if (context == NULL) {
- return 0;
- }
- }
- PyErr_WriteUnraisable(context);
+ PyErr_WriteUnraisable(pObj->externalTimer);
return 0;
}
return result;
1
0
Author: brett.cannon
Date: Tue Sep 30 19:46:03 2008
New Revision: 66700
Log:
Fix a refleak introduced by r66677.
Fix suggested by Amaury Forgeot d'Arc.
Closes issue #4003.
Modified:
python/trunk/Modules/_lsprof.c
Modified: python/trunk/Modules/_lsprof.c
==============================================================================
--- python/trunk/Modules/_lsprof.c (original)
+++ python/trunk/Modules/_lsprof.c Tue Sep 30 19:46:03 2008
@@ -150,16 +150,7 @@
}
Py_DECREF(o);
if (PyErr_Occurred()) {
- PyObject *context = (PyObject *)pObj;
- /* May have been called by profiler_dealloc(). */
- if (Py_REFCNT(context) < 1) {
- context = PyString_FromString("profiler calling an "
- "external timer");
- if (context == NULL) {
- return 0;
- }
- }
- PyErr_WriteUnraisable(context);
+ PyErr_WriteUnraisable(pObj->externalTimer);
return 0;
}
return result;
1
0
More important issues:
----------------------
test_cprofile leaked [1, 1, 1] references, sum=3
Less important issues:
----------------------
test_smtplib leaked [197, -197, 88] references, sum=88
test_sys leaked [42, 0, 0] references, sum=42
test_threadsignals leaked [0, -8, 0] references, sum=-8
test_urllib2_localnet leaked [3, 3, 3] references, sum=9
test_xmlrpc leaked [0, -85, 85] references, sum=0
1
0
r66699 - in python/trunk/Doc/library: ctypes.rst optparse.rst subprocess.rst
by andrew.kuchling 30 Sep '08
by andrew.kuchling 30 Sep '08
30 Sep '08
Author: andrew.kuchling
Date: Tue Sep 30 15:01:46 2008
New Revision: 66699
Log:
Markup fixes. (optparse.rst probably needs an entire revision pass.)
Modified:
python/trunk/Doc/library/ctypes.rst
python/trunk/Doc/library/optparse.rst
python/trunk/Doc/library/subprocess.rst
Modified: python/trunk/Doc/library/ctypes.rst
==============================================================================
--- python/trunk/Doc/library/ctypes.rst (original)
+++ python/trunk/Doc/library/ctypes.rst Tue Sep 30 15:01:46 2008
@@ -1392,7 +1392,7 @@
The *use_last_error* parameter, when set to True, enables the same
mechanism for the Windows error code which is managed by the
-GetLastError() and SetLastError() Windows api functions;
+:func:`GetLastError` and :func:`SetLastError` Windows API functions;
`ctypes.get_last_error()` and `ctypes.set_last_error(value)` are used
to request and change the ctypes private copy of the windows error
code.
Modified: python/trunk/Doc/library/optparse.rst
==============================================================================
--- python/trunk/Doc/library/optparse.rst (original)
+++ python/trunk/Doc/library/optparse.rst Tue Sep 30 15:01:46 2008
@@ -602,7 +602,7 @@
programmer errors and user errors. Programmer errors are usually erroneous
calls to ``parser.add_option()``, e.g. invalid option strings, unknown option
attributes, missing option attributes, etc. These are dealt with in the usual
-way: raise an exception (either ``optparse.OptionError`` or ``TypeError``) and
+way: raise an exception (either ``optparse.OptionError`` or :exc:`TypeError`) and
let the program crash.
Handling user errors is much more important, since they are guaranteed to happen
@@ -799,10 +799,10 @@
The keyword arguments define attributes of the new Option object. The most
important option attribute is :attr:`action`, and it largely determines which
other attributes are relevant or required. If you pass irrelevant option
-attributes, or fail to pass required ones, :mod:`optparse` raises an OptionError
-exception explaining your mistake.
+attributes, or fail to pass required ones, :mod:`optparse` raises an
+:exc:`OptionError` exception explaining your mistake.
-An options's *action* determines what :mod:`optparse` does when it encounters
+An option's *action* determines what :mod:`optparse` does when it encounters
this option on the command-line. The standard option actions hard-coded into
:mod:`optparse` are:
@@ -1059,7 +1059,7 @@
The following option attributes may be passed as keyword arguments to
``parser.add_option()``. If you pass an option attribute that is not relevant
to a particular option, or fail to pass a required option attribute,
-:mod:`optparse` raises OptionError.
+:mod:`optparse` raises :exc:`OptionError`.
* :attr:`action` (default: ``"store"``)
@@ -1152,7 +1152,7 @@
``choice`` options are a subtype of ``string`` options. The ``choices`` option
attribute (a sequence of strings) defines the set of allowed option arguments.
``optparse.check_choice()`` compares user-supplied option arguments against this
-master list and raises OptionValueError if an invalid string is given.
+master list and raises :exc:`OptionValueError` if an invalid string is given.
.. _optparse-parsing-arguments:
@@ -1225,10 +1225,10 @@
(e.g., ``"-q"`` or ``"--verbose"``).
``remove_option(opt_str)``
- If the OptionParser has an option corresponding to ``opt_str``, that option is
+ If the :class:`OptionParser` has an option corresponding to ``opt_str``, that option is
removed. If that option provided any other option strings, all of those option
strings become invalid. If ``opt_str`` does not occur in any option belonging to
- this OptionParser, raises ValueError.
+ this :class:`OptionParser`, raises :exc:`ValueError`.
.. _optparse-conflicts-between-options:
@@ -1259,13 +1259,13 @@
The available conflict handlers are:
``error`` (default)
- assume option conflicts are a programming error and raise OptionConflictError
+ assume option conflicts are a programming error and raise :exc:`OptionConflictError`
``resolve``
resolve option conflicts intelligently (see below)
-As an example, let's define an OptionParser that resolves conflicts
+As an example, let's define an :class:`OptionParser` that resolves conflicts
intelligently and add conflicting options to it::
parser = OptionParser(conflict_handler="resolve")
@@ -1495,7 +1495,7 @@
Raising errors in a callback
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The callback function should raise OptionValueError if there are any problems
+The callback function should raise :exc:`OptionValueError` if there are any problems
with the option or its argument(s). :mod:`optparse` catches this and terminates
the program, printing the error message you supply to stderr. Your message
should be clear, concise, accurate, and mention the option at fault. Otherwise,
@@ -1696,9 +1696,9 @@
:meth:`OptionParser.parse_args`, or be passed to a callback as the ``value``
parameter.
-Your type-checking function should raise OptionValueError if it encounters any
-problems. OptionValueError takes a single string argument, which is passed
-as-is to OptionParser's :meth:`error` method, which in turn prepends the program
+Your type-checking function should raise :exc:`OptionValueError` if it encounters any
+problems. :exc:`OptionValueError` takes a single string argument, which is passed
+as-is to :class:`OptionParser`'s :meth:`error` method, which in turn prepends the program
name and the string ``"error:"`` and prints everything to stderr before
terminating the process.
Modified: python/trunk/Doc/library/subprocess.rst
==============================================================================
--- python/trunk/Doc/library/subprocess.rst (original)
+++ python/trunk/Doc/library/subprocess.rst Tue Sep 30 15:01:46 2008
@@ -138,7 +138,7 @@
.. function:: check_call(*popenargs, **kwargs)
Run command with arguments. Wait for command to complete. If the exit code was
- zero then return, otherwise raise :exc:`CalledProcessError.` The
+ zero then return, otherwise raise :exc:`CalledProcessError`. The
:exc:`CalledProcessError` object will have the return code in the
:attr:`returncode` attribute.
1
0
Author: andrew.kuchling
Date: Tue Sep 30 15:00:51 2008
New Revision: 66698
Log:
Markup fixes
Modified:
python/trunk/Doc/howto/urllib2.rst
Modified: python/trunk/Doc/howto/urllib2.rst
==============================================================================
--- python/trunk/Doc/howto/urllib2.rst (original)
+++ python/trunk/Doc/howto/urllib2.rst Tue Sep 30 15:00:51 2008
@@ -182,11 +182,12 @@
Handling Exceptions
===================
-*urlopen* raises ``URLError`` when it cannot handle a response (though as usual
-with Python APIs, builtin exceptions such as ValueError, TypeError etc. may also
+*urlopen* raises :exc:`URLError` when it cannot handle a response (though as usual
+with Python APIs, builtin exceptions such as
+:exc:`ValueError`, :exc:`TypeError` etc. may also
be raised).
-``HTTPError`` is the subclass of ``URLError`` raised in the specific case of
+:exc:`HTTPError` is the subclass of :exc:`URLError` raised in the specific case of
HTTP URLs.
URLError
@@ -215,12 +216,12 @@
default handlers will handle some of these responses for you (for example, if
the response is a "redirection" that requests the client fetch the document from
a different URL, urllib2 will handle that for you). For those it can't handle,
-urlopen will raise an ``HTTPError``. Typical errors include '404' (page not
+urlopen will raise an :exc:`HTTPError`. Typical errors include '404' (page not
found), '403' (request forbidden), and '401' (authentication required).
See section 10 of RFC 2616 for a reference on all the HTTP error codes.
-The ``HTTPError`` instance raised will have an integer 'code' attribute, which
+The :exc:`HTTPError` instance raised will have an integer 'code' attribute, which
corresponds to the error sent by the server.
Error Codes
@@ -303,7 +304,7 @@
}
When an error is raised the server responds by returning an HTTP error code
-*and* an error page. You can use the ``HTTPError`` instance as a response on the
+*and* an error page. You can use the :exc:`HTTPError` instance as a response on the
page returned. This means that as well as the code attribute, it also has read,
geturl, and info, methods. ::
@@ -325,7 +326,7 @@
Wrapping it Up
--------------
-So if you want to be prepared for ``HTTPError`` *or* ``URLError`` there are two
+So if you want to be prepared for :exc:`HTTPError` *or* :exc:`URLError` there are two
basic approaches. I prefer the second approach.
Number 1
@@ -351,7 +352,7 @@
.. note::
The ``except HTTPError`` *must* come first, otherwise ``except URLError``
- will *also* catch an ``HTTPError``.
+ will *also* catch an :exc:`HTTPError`.
Number 2
~~~~~~~~
@@ -376,8 +377,8 @@
info and geturl
===============
-The response returned by urlopen (or the ``HTTPError`` instance) has two useful
-methods ``info`` and ``geturl``.
+The response returned by urlopen (or the :exc:`HTTPError` instance) has two useful
+methods :meth:`info` and :meth:`geturl`.
**geturl** - this returns the real URL of the page fetched. This is useful
because ``urlopen`` (or the opener object used) may have followed a
1
0