Skip to content

Commit 1a6e0d0

Browse files
committed
Merged revisions 66974,66977,66984,66989,66992,66994-66996,66998-67000,67007,67015 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r66974 | benjamin.peterson | 2008-10-19 08:59:01 -0500 (Sun, 19 Oct 2008) | 1 line fix compiler warning ........ r66977 | benjamin.peterson | 2008-10-19 14:39:16 -0500 (Sun, 19 Oct 2008) | 1 line mention -n ........ r66984 | armin.ronacher | 2008-10-20 16:29:08 -0500 (Mon, 20 Oct 2008) | 3 lines Fixed #4062, added import for _ast.__version__ to ast to match the documented behavior. ........ r66989 | matthias.klose | 2008-10-21 04:12:25 -0500 (Tue, 21 Oct 2008) | 2 lines - install versioned manpage ........ r66992 | benjamin.peterson | 2008-10-21 15:51:13 -0500 (Tue, 21 Oct 2008) | 1 line make sure to call iteritems() ........ r66994 | amaury.forgeotdarc | 2008-10-21 17:01:38 -0500 (Tue, 21 Oct 2008) | 6 lines #4157 move two test functions out of platform.py. Turn them into unit tests, and correct an obvious typo: (("a", "b") ("c", "d") ("e", "f")) compiles even with the missing commas, but does not execute very well... ........ r66995 | benjamin.peterson | 2008-10-21 17:18:29 -0500 (Tue, 21 Oct 2008) | 1 line return ArgInfo from inspect.getargvalues #4092 ........ r66996 | benjamin.peterson | 2008-10-21 17:20:31 -0500 (Tue, 21 Oct 2008) | 1 line add NEWs note for last change ........ r66998 | benjamin.peterson | 2008-10-22 15:57:43 -0500 (Wed, 22 Oct 2008) | 1 line fix a few typos ........ r66999 | benjamin.peterson | 2008-10-22 16:05:30 -0500 (Wed, 22 Oct 2008) | 1 line and another typo... ........ r67000 | benjamin.peterson | 2008-10-22 16:16:34 -0500 (Wed, 22 Oct 2008) | 1 line fix #4150: pdb's up command didn't work for generators in post-mortem ........ r67007 | benjamin.peterson | 2008-10-23 16:43:48 -0500 (Thu, 23 Oct 2008) | 1 line only nonempty __slots__ don't work ........ r67015 | georg.brandl | 2008-10-25 02:00:52 -0500 (Sat, 25 Oct 2008) | 2 lines Typo fix. ........
1 parent cbda96e commit 1a6e0d0

File tree

12 files changed

+56
-59
lines changed

12 files changed

+56
-59
lines changed

Doc/library/2to3.rst

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ It can be converted to Python 3.x code via 2to3 on the command line::
3737

3838
A diff against the original source file is printed. 2to3 can also write the
3939
needed modifications right back to the source file. (Of course, a backup of the
40-
original is also be made.) Writing the changes back is enabled with the
41-
:option:`-w` flag::
40+
original is also be made unless :option:`-n` is also given.) Writing the
41+
changes back is enabled with the :option:`-w` flag::
4242

4343
$ 2to3 -w example.py
4444

@@ -50,11 +50,10 @@ After transformation, :file:`example.py` looks like this::
5050
name = input()
5151
greet(name)
5252

53-
Comments and and exact indentation are preserved throughout the translation
54-
process.
53+
Comments and exact indentation are preserved throughout the translation process.
5554

5655
By default, 2to3 runs a set of predefined fixers. The :option:`-l` flag lists
57-
all avaible fixers. An explicit set of fixers to run can be given with
56+
all available fixers. An explicit set of fixers to run can be given with
5857
:option:`-f`. Likewise the :option:`-x` explicitly disables a fixer. The
5958
following example runs only the ``imports`` and ``has_key`` fixers::
6059

@@ -64,18 +63,18 @@ This command runs every fixer except the ``apply`` fixer::
6463

6564
$ 2to3 -x apply example.py
6665

67-
Some fixers are *explicit*, meaning they aren't run be default and must be
66+
Some fixers are *explicit*, meaning they aren't run by default and must be
6867
listed on the command line to be run. Here, in addition to the default fixers,
6968
the ``idioms`` fixer is run::
7069

7170
$ 2to3 -f all -f idioms example.py
7271

7372
Notice how passing ``all`` enables all default fixers.
7473

75-
Sometimes 2to3 will find will find a place in your source code that needs to be
76-
changed, but 2to3 cannot fix automatically. In this case, 2to3 will print a
77-
warning beneath the diff for a file. You should address the warning in order to
78-
have compliant 3.x code.
74+
Sometimes 2to3 will find a place in your source code that needs to be changed,
75+
but 2to3 cannot fix automatically. In this case, 2to3 will print a warning
76+
beneath the diff for a file. You should address the warning in order to have
77+
compliant 3.x code.
7978

8079
2to3 can also refactor doctests. To enable this mode, use the :option:`-d`
8180
flag. Note that *only* doctests will be refactored. This also doesn't require
@@ -89,7 +88,7 @@ When the :option:`-p` is passed, 2to3 treats ``print`` as a function instead of
8988
a statement. This is useful when ``from __future__ import print_function`` is
9089
being used. If this option is not given, the print fixer will surround print
9190
calls in an extra set of parentheses because it cannot differentiate between the
92-
and print statement with parentheses (such as ``print ("a" + "b" + "c")``) and a
91+
print statement with parentheses (such as ``print ("a" + "b" + "c")``) and a
9392
true function call.
9493

9594

Doc/reference/datamodel.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,8 +1465,8 @@ Notes on using *__slots__*
14651465
defined. As a result, subclasses will have a *__dict__* unless they also define
14661466
*__slots__*.
14671467

1468-
* *__slots__* do not work for classes derived from "variable-length" built-in
1469-
types such as :class:`int`, :class:`str` and :class:`tuple`.
1468+
* Nonempty *__slots__* does not work for classes derived from "variable-length"
1469+
built-in types such as :class:`int`, :class:`str` and :class:`tuple`.
14701470

14711471
* Any non-string iterable may be assigned to *__slots__*. Mappings may also be
14721472
used; however, in the future, special meaning may be assigned to the values

Lib/ast.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
:license: Python License.
2727
"""
2828
from _ast import *
29+
from _ast import __version__
2930

3031

3132
def parse(expr, filename='<unknown>', mode='exec'):

Lib/bdb.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ def get_stack(self, f, t):
319319
while t is not None:
320320
stack.append((t.tb_frame, t.tb_lineno))
321321
t = t.tb_next
322+
if f is None:
323+
i = max(0, len(stack) - 1)
322324
return stack, i
323325

324326
#

Lib/inspect.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ def getargvalues(frame):
826826
'varargs' and 'varkw' are the names of the * and ** arguments or None.
827827
'locals' is the locals dictionary of the given frame."""
828828
args, varargs, varkw = getargs(frame.f_code)
829-
return args, varargs, varkw, frame.f_locals
829+
return ArgInfo(args, varargs, varkw, frame.f_locals)
830830

831831
def joinseq(seq):
832832
if len(seq) == 1:

Lib/pdb.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,9 +1220,7 @@ def post_mortem(t=None):
12201220

12211221
p = Pdb()
12221222
p.reset()
1223-
while t.tb_next is not None:
1224-
t = t.tb_next
1225-
p.interaction(t.tb_frame, t)
1223+
p.interaction(None, t)
12261224

12271225
def pm():
12281226
post_mortem(sys.last_traceback)
@@ -1285,9 +1283,7 @@ def main():
12851283
print("Uncaught exception. Entering post mortem debugging")
12861284
print("Running 'cont' or 'step' will restart the program")
12871285
t = sys.exc_info()[2]
1288-
while t.tb_next is not None:
1289-
t = t.tb_next
1290-
pdb.interaction(t.tb_frame,t)
1286+
pdb.interaction(None, t)
12911287
print("Post mortem debugger finished. The "+mainpyfile+" will be restarted")
12921288

12931289

Lib/platform.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,6 @@ def _parse_release_file(firstline):
266266
id = ''
267267
return '', version, id
268268

269-
def _test_parse_release_file():
270-
271-
for input, output in (
272-
# Examples of release file contents:
273-
('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64'))
274-
('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64'))
275-
('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586'))
276-
('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux'))
277-
('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche'))
278-
('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike'))
279-
('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant'))
280-
('CentOS release 4', ('CentOS', '4', None))
281-
('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia'))
282-
):
283-
parsed = _parse_release_file(input)
284-
if parsed != output:
285-
print((input, parsed))
286-
287269
def linux_distribution(distname='', version='', id='',
288270

289271
supported_dists=_supported_dists,
@@ -1357,21 +1339,6 @@ def _sys_version(sys_version=None):
13571339
_sys_version_cache[sys_version] = result
13581340
return result
13591341

1360-
def _test_sys_version():
1361-
1362-
_sys_version_cache.clear()
1363-
for input, output in (
1364-
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
1365-
('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
1366-
('IronPython 1.0.60816 on .NET 2.0.50727.42',
1367-
('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
1368-
('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
1369-
('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
1370-
):
1371-
parsed = _sys_version(input)
1372-
if parsed != output:
1373-
print((input, parsed))
1374-
13751342
def python_implementation():
13761343

13771344
""" Returns a string identifying the Python implementation.

Lib/test/test_platform.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,40 @@ def test_libc_ver(self):
115115
executable = executable + '.exe'
116116
res = platform.libc_ver(sys.executable)
117117

118+
def test_parse_release_file(self):
119+
120+
for input, output in (
121+
# Examples of release file contents:
122+
('SuSE Linux 9.3 (x86-64)', ('SuSE Linux ', '9.3', 'x86-64')),
123+
('SUSE LINUX 10.1 (X86-64)', ('SUSE LINUX ', '10.1', 'X86-64')),
124+
('SUSE LINUX 10.1 (i586)', ('SUSE LINUX ', '10.1', 'i586')),
125+
('Fedora Core release 5 (Bordeaux)', ('Fedora Core', '5', 'Bordeaux')),
126+
('Red Hat Linux release 8.0 (Psyche)', ('Red Hat Linux', '8.0', 'Psyche')),
127+
('Red Hat Linux release 9 (Shrike)', ('Red Hat Linux', '9', 'Shrike')),
128+
('Red Hat Enterprise Linux release 4 (Nahant)', ('Red Hat Enterprise Linux', '4', 'Nahant')),
129+
('CentOS release 4', ('CentOS', '4', None)),
130+
('Rocks release 4.2.1 (Cydonia)', ('Rocks', '4.2.1', 'Cydonia')),
131+
):
132+
self.assertEqual(platform._parse_release_file(input), output)
133+
134+
def test_sys_version(self):
135+
136+
platform._sys_version_cache.clear()
137+
for input, output in (
138+
('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]',
139+
('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')),
140+
('IronPython 1.0.60816 on .NET 2.0.50727.42',
141+
('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')),
142+
('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42',
143+
('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')),
144+
):
145+
# branch and revision are not "parsed", but fetched
146+
# from sys.subversion. Ignore them
147+
(name, version, branch, revision, buildno, builddate, compiler) \
148+
= platform._sys_version(input)
149+
self.assertEqual(
150+
(name, version, '', '', buildno, builddate, compiler), output)
151+
118152
def test_main():
119153
support.run_unittest(
120154
PlatformTest

Lib/test/test_urllib.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ def test_iter(self):
117117
class ProxyTests(unittest.TestCase):
118118

119119
def setUp(self):
120-
unittest.TestCase.setUp(self)
121120
# Save all proxy related env vars
122121
self._saved_environ = dict([(k, v) for k, v in os.environ.items()
123122
if k.lower().find('proxy') >= 0])
@@ -126,9 +125,8 @@ def setUp(self):
126125
del os.environ[k]
127126

128127
def tearDown(self):
129-
unittest.TestCase.tearDown(self)
130128
# Restore all proxy related env vars
131-
for k, v in self._saved_environ:
129+
for k, v in self._saved_environ.items():
132130
os.environ[k] = v
133131

134132
def test_getproxies_environment_keep_no_proxies(self):

Makefile.pre.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@ maninstall:
796796
fi; \
797797
done
798798
$(INSTALL_DATA) $(srcdir)/Misc/python.man \
799-
$(DESTDIR)$(MANDIR)/man1/python.1
799+
$(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
800800

801801
# Install the library
802802
PLATDIR= plat-$(MACHDEP)

0 commit comments

Comments
 (0)