Skip to content

Commit e64de92

Browse files
committed
Merged revisions 83429,83436 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/release27-maint ................ r83429 | georg.brandl | 2010-08-01 21:14:56 +0200 (So, 01 Aug 2010) | 37 lines Merged revisions 83352,83356-83358,83362,83366,83368-83369 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83352 | georg.brandl | 2010-07-31 20:11:07 +0200 (Sa, 31 Jul 2010) | 1 line #9440: Remove borderline test case that fails based on unpredictable conditions such as compiler flags. ........ r83356 | georg.brandl | 2010-07-31 21:29:15 +0200 (Sa, 31 Jul 2010) | 1 line Remove trailing whitespace. ........ r83357 | georg.brandl | 2010-07-31 21:59:55 +0200 (Sa, 31 Jul 2010) | 1 line #5778: document that sys.version can contain a newline. ........ r83358 | georg.brandl | 2010-07-31 22:05:31 +0200 (Sa, 31 Jul 2010) | 1 line #9442: do not document a specific format for sys.version; rather refer to version_info and the platform module. ........ r83362 | georg.brandl | 2010-07-31 23:12:15 +0200 (Sa, 31 Jul 2010) | 1 line #8910: add a file explaining why Lib/test/data is there. ........ r83366 | georg.brandl | 2010-07-31 23:26:40 +0200 (Sa, 31 Jul 2010) | 1 line There always is a False and True now. ........ r83368 | georg.brandl | 2010-07-31 23:40:15 +0200 (Sa, 31 Jul 2010) | 1 line #7909: the prefixes \\.\ and \\?\ indicate special Windows paths, do not try to manipulate them. See http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx for details. ........ r83369 | georg.brandl | 2010-07-31 23:41:42 +0200 (Sa, 31 Jul 2010) | 1 line Fix "Berkeley" name. ........ ................ r83436 | georg.brandl | 2010-08-01 21:33:15 +0200 (So, 01 Aug 2010) | 42 lines Merged revisions 83259,83261,83264-83265,83268-83269,83271-83272,83281 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r83259 | georg.brandl | 2010-07-30 09:03:39 +0200 (Fr, 30 Jul 2010) | 1 line Clarification. ........ r83261 | georg.brandl | 2010-07-30 09:21:26 +0200 (Fr, 30 Jul 2010) | 1 line #9230: allow Pdb.checkline() to be called without a current frame, for setting breakpoints before starting debugging. ........ r83264 | georg.brandl | 2010-07-30 10:45:26 +0200 (Fr, 30 Jul 2010) | 1 line Document the "jump" command in pdb.__doc__, and add a version tag for "until X". ........ r83265 | georg.brandl | 2010-07-30 10:54:49 +0200 (Fr, 30 Jul 2010) | 1 line #8015: fix crash when entering an empty line for breakpoint commands. Also restore environment properly when an exception occurs during the definition of commands. ........ r83268 | georg.brandl | 2010-07-30 11:23:23 +0200 (Fr, 30 Jul 2010) | 2 lines Issue #8048: Prevent doctests from failing when sys.displayhook has been reassigned. ........ r83269 | georg.brandl | 2010-07-30 11:43:00 +0200 (Fr, 30 Jul 2010) | 1 line #6719: In pdb, do not stop somewhere in the encodings machinery if the source file to be debugged is in a non-builtin encoding. ........ r83271 | georg.brandl | 2010-07-30 11:59:28 +0200 (Fr, 30 Jul 2010) | 1 line #5727: Restore the ability to use readline when calling into pdb in doctests. ........ r83272 | georg.brandl | 2010-07-30 12:29:19 +0200 (Fr, 30 Jul 2010) | 1 line #5294: Fix the behavior of pdb "continue" command when called in the top-level debugged frame. ........ r83281 | georg.brandl | 2010-07-30 15:36:43 +0200 (Fr, 30 Jul 2010) | 1 line Add myself for pdb. ........ ................
1 parent 03c1cff commit e64de92

11 files changed

Lines changed: 99 additions & 27 deletions

File tree

Doc/library/ftplib.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ followed by ``lines`` for the text version or ``binary`` for the binary version.
186186
Retrieve a file or directory listing in ASCII transfer mode. *command*
187187
should be an appropriate ``RETR`` command (see :meth:`retrbinary`) or a
188188
command such as ``LIST``, ``NLST`` or ``MLSD`` (usually just the string
189-
``'LIST'``). The *callback* function is called for each line, with the
190-
trailing CRLF stripped. The default *callback* prints the line to
191-
``sys.stdout``.
189+
``'LIST'``). The *callback* function is called for each line with a
190+
string argument containing the line with the trailing CRLF stripped.
191+
The default *callback* prints the line to ``sys.stdout``.
192192

193193

194194
.. method:: FTP.set_pasv(boolean)

Doc/library/sys.rst

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -909,14 +909,10 @@ always available.
909909
.. data:: version
910910

911911
A string containing the version number of the Python interpreter plus additional
912-
information on the build number and compiler used. It has a value of the form
913-
``'version (#build_number, build_date, build_time) [compiler]'``. The first
914-
three characters are used to identify the version in the installation
915-
directories (where appropriate on each platform). An example::
916-
917-
>>> import sys
918-
>>> sys.version
919-
'1.5.2 (#0 Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)]'
912+
information on the build number and compiler used. This string is displayed
913+
when the interactive interpreter is started. Do not extract version information
914+
out of it, rather, use :data:`version_info` and the functions provided by the
915+
:mod:`platform` module.
920916

921917

922918
.. data:: api_version

Lib/bdb.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def stop_here(self, frame):
9898
# (CT) stopframe may now also be None, see dispatch_call.
9999
# (CT) the former test for None is therefore removed from here.
100100
if frame is self.stopframe:
101+
if self.stoplineno == -1:
102+
return False
101103
return frame.f_lineno >= self.stoplineno
102104
while frame is not None and frame is not self.stopframe:
103105
if frame is self.botframe:
@@ -155,10 +157,12 @@ def user_exception(self, frame, exc_info):
155157
but only if we are to stop at or just below this level."""
156158
pass
157159

158-
def _set_stopinfo(self, stopframe, returnframe, stoplineno=-1):
160+
def _set_stopinfo(self, stopframe, returnframe, stoplineno=0):
159161
self.stopframe = stopframe
160162
self.returnframe = returnframe
161163
self.quitting = 0
164+
# stoplineno >= 0 means: stop at line >= the stoplineno
165+
# stoplineno -1 means: don't stop at all
162166
self.stoplineno = stoplineno
163167

164168
# Derived classes and clients can call the following methods
@@ -171,7 +175,7 @@ def set_until(self, frame): #the name "until" is borrowed from gdb
171175

172176
def set_step(self):
173177
"""Stop after one line of code."""
174-
self._set_stopinfo(None,None)
178+
self._set_stopinfo(None, None)
175179

176180
def set_next(self, frame):
177181
"""Stop on the next line in or below the given frame."""
@@ -198,7 +202,7 @@ def set_trace(self, frame=None):
198202

199203
def set_continue(self):
200204
# Don't stop except at breakpoints or when finished
201-
self._set_stopinfo(self.botframe, None)
205+
self._set_stopinfo(self.botframe, None, -1)
202206
if not self.breaks:
203207
# no breakpoints; run without debugger overhead
204208
sys.settrace(None)

Lib/doctest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ def __init__(self, out):
335335
self.__out = out
336336
self.__debugger_used = False
337337
pdb.Pdb.__init__(self, stdout=out)
338+
# still use input() to get user input
339+
self.use_rawinput = 1
338340

339341
def set_trace(self, frame=None):
340342
self.__debugger_used = True
@@ -1381,12 +1383,17 @@ def run(self, test, compileflags=None, out=None, clear_globs=True):
13811383
self.save_linecache_getlines = linecache.getlines
13821384
linecache.getlines = self.__patched_linecache_getlines
13831385

1386+
# Make sure sys.displayhook just prints the value to stdout
1387+
save_displayhook = sys.displayhook
1388+
sys.displayhook = sys.__displayhook__
1389+
13841390
try:
13851391
return self.__run(test, compileflags, out)
13861392
finally:
13871393
sys.stdout = save_stdout
13881394
pdb.set_trace = save_set_trace
13891395
linecache.getlines = self.save_linecache_getlines
1396+
sys.displayhook = save_displayhook
13901397
if clear_globs:
13911398
test.globs.clear()
13921399

Lib/ntpath.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,12 @@ def normpath(path):
399399
"""Normalize path, eliminating double slashes, etc."""
400400
# Preserve unicode (if path is unicode)
401401
backslash, dot = (u'\\', u'.') if isinstance(path, unicode) else ('\\', '.')
402+
if path.startswith(('\\\\.\\', '\\\\?\\')):
403+
# in the case of paths with these prefixes:
404+
# \\.\ -> device names
405+
# \\?\ -> literal paths
406+
# do not do any normalization, but return the path unchanged
407+
return path
402408
path = path.replace("/", "\\")
403409
prefix, path = splitdrive(path)
404410
# We need to be careful here. If the prefix is empty, and the path starts

Lib/pdb.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,18 @@ def bp_commands(self,frame):
171171

172172
def user_return(self, frame, return_value):
173173
"""This function is called when a return trap is set here."""
174+
if self._wait_for_mainpyfile:
175+
return
174176
frame.f_locals['__return__'] = return_value
175177
print >>self.stdout, '--Return--'
176178
self.interaction(frame, None)
177179

178180
def user_exception(self, frame, exc_info):
179-
exc_type, exc_value, exc_traceback = exc_info
180181
"""This function is called if an exception occurs,
181182
but only if we are to stop at or just below this level."""
183+
if self._wait_for_mainpyfile:
184+
return
185+
exc_type, exc_value, exc_traceback = exc_info
182186
frame.f_locals['__exception__'] = exc_type, exc_value
183187
if type(exc_type) == type(''):
184188
exc_type_name = exc_type
@@ -265,16 +269,18 @@ def onecmd(self, line):
265269
return self.handle_command_def(line)
266270

267271
def handle_command_def(self,line):
268-
""" Handles one command line during command list definition. """
272+
"""Handles one command line during command list definition."""
269273
cmd, arg, line = self.parseline(line)
274+
if not cmd:
275+
return
270276
if cmd == 'silent':
271277
self.commands_silent[self.commands_bnum] = True
272278
return # continue to handle other cmd def in the cmd list
273279
elif cmd == 'end':
274280
self.cmdqueue = []
275281
return 1 # end of cmd list
276282
cmdlist = self.commands[self.commands_bnum]
277-
if (arg):
283+
if arg:
278284
cmdlist.append(cmd+' '+arg)
279285
else:
280286
cmdlist.append(cmd)
@@ -313,9 +319,11 @@ def do_commands(self, arg):
313319
prompt_back = self.prompt
314320
self.prompt = '(com) '
315321
self.commands_defining = True
316-
self.cmdloop()
317-
self.commands_defining = False
318-
self.prompt = prompt_back
322+
try:
323+
self.cmdloop()
324+
finally:
325+
self.commands_defining = False
326+
self.prompt = prompt_back
319327

320328
def do_break(self, arg, temporary = 0):
321329
# break [ ([filename:]lineno | function) [, "condition"] ]
@@ -451,7 +459,10 @@ def checkline(self, filename, lineno):
451459
Return `lineno` if it is, 0 if not (e.g. a docstring, comment, blank
452460
line or EOF). Warning: testing is not comprehensive.
453461
"""
454-
line = linecache.getline(filename, lineno, self.curframe.f_globals)
462+
# this method should be callable before starting debugging, so default
463+
# to "no globals" if there is no current frame
464+
globs = self.curframe.f_globals if hasattr(self, 'curframe') else None
465+
line = linecache.getline(filename, lineno, globs)
455466
if not line:
456467
print >>self.stdout, 'End of file'
457468
return 0
@@ -1280,7 +1291,7 @@ def main():
12801291
# changed by the user from the command line. There is a "restart" command which
12811292
# allows explicit specification of command line arguments.
12821293
pdb = Pdb()
1283-
while 1:
1294+
while True:
12841295
try:
12851296
pdb._runscript(mainpyfile)
12861297
if pdb._user_requested_quit:

Lib/test/test_doctest.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,35 @@ def exceptions(): r"""
907907
...
908908
ZeroDivisionError: integer division or modulo by zero
909909
TestResults(failed=1, attempted=1)
910+
"""
911+
def displayhook(): r"""
912+
Test that changing sys.displayhook doesn't matter for doctest.
913+
914+
>>> import sys
915+
>>> orig_displayhook = sys.displayhook
916+
>>> def my_displayhook(x):
917+
... print('hi!')
918+
>>> sys.displayhook = my_displayhook
919+
>>> def f():
920+
... '''
921+
... >>> 3
922+
... 3
923+
... '''
924+
>>> test = doctest.DocTestFinder().find(f)[0]
925+
>>> r = doctest.DocTestRunner(verbose=False).run(test)
926+
>>> post_displayhook = sys.displayhook
927+
928+
We need to restore sys.displayhook now, so that we'll be able to test
929+
results.
930+
931+
>>> sys.displayhook = orig_displayhook
932+
933+
Ok, now we can check that everything is ok.
934+
935+
>>> r
936+
TestResults(failed=0, attempted=1)
937+
>>> post_displayhook is my_displayhook
938+
True
910939
"""
911940
def optionflags(): r"""
912941
Tests of `DocTestRunner`'s option flag handling.

Lib/test/test_ntpath.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ def test_normpath(self):
128128
self.assertTrue(isinstance(ntpath.normpath(path), unicode),
129129
'normpath() returned str instead of unicode')
130130

131+
tester("ntpath.normpath('\\\\.\\NUL')", r'\\.\NUL')
132+
tester("ntpath.normpath('\\\\?\\D:/XY\\Z')", r'\\?\D:/XY\Z')
133+
131134
def test_expandvars(self):
132135
oldenv = os.environ.copy()
133136
try:

Lib/test/test_optparse.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -799,15 +799,13 @@ def test_bool_false(self):
799799
(options, args) = self.assertParseOK(["-q"],
800800
{'verbose': 0},
801801
[])
802-
if hasattr(__builtins__, 'False'):
803-
self.failUnless(options.verbose is False)
802+
self.assertTrue(options.verbose is False)
804803

805804
def test_bool_true(self):
806805
(options, args) = self.assertParseOK(["-v"],
807806
{'verbose': 1},
808807
[])
809-
if hasattr(__builtins__, 'True'):
810-
self.failUnless(options.verbose is True)
808+
self.assertTrue(options.verbose is True)
811809

812810
def test_bool_flicker_on_and_off(self):
813811
self.assertParseOK(["-qvq", "-q", "-v"],

Misc/NEWS

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,24 @@ C-API
8989
Library
9090
-------
9191

92+
- Issue #5294: Fix the behavior of pdb's "continue" command when called
93+
in the top-level debugged frame.
94+
95+
- Issue #5727: Restore the ability to use readline when calling into pdb
96+
in doctests.
97+
98+
- Issue #6719: In pdb, do not stop somewhere in the encodings machinery
99+
if the source file to be debugged is in a non-builtin encoding.
100+
101+
- Issue #8048: Prevent doctests from failing when sys.displayhook has
102+
been reassigned.
103+
104+
- Issue #8015: In pdb, do not crash when an empty line is entered as
105+
a breakpoint command.
106+
107+
- Issue #7909: Do not touch paths with the special prefixes ``\\.\``
108+
or ``\\?\`` in ntpath.normpath().
109+
92110
- Issue #5146: Handle UID THREAD command correctly in imaplib.
93111

94112
- Issue #5147: Fix the header generated for cookie files written by

0 commit comments

Comments
 (0)