This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author mnewman
Recipients mnewman
Date 2010-02-19.12:52:12
SpamBayes Score 7.283063e-14
Marked as misclassified No
Message-id <1266583937.16.0.516750395183.issue7964@psf.upfronthosting.co.za>
In-reply-to
Content
Attached is a version checking script. When you run it normally, it produces output such as:

E:\notes\Programming\python3>c:\Python26\python.exe version_check.py
2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]

E:\notes\Programming\python3>c:\Python31\python.exe version_check.py
3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)]

I wanted to test using "-m pdb" on this script. It works okay for Python 2.6:

E:\notes\Programming\python3>c:\Python26\python.exe -m pdb version_check.py
> e:\notes\programming\python3\version_check.py(4)<module>()
-> Last Updated: 2008-12-21"""
(Pdb) c
2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)]
The program finished and will be restarted
> e:\notes\programming\python3\version_check.py(4)<module>()
-> Last Updated: 2008-12-21"""
(Pdb) q

However, if I try it on Python 3.1 I get a SyntaxError:

# --- Begin Python 3.1 Example with "\r\n" source code --- #

E:\notes\Programming\python3>c:\Python31\python.exe -m pdb version_check.py
SyntaxError: ('invalid syntax', ('e:\\notes\\programming\\python3\\version_check
.py', 4, 132, '"""Check what version of python is running.\r\n\r\nWritten by: Mi
chael Newman <michael.b.newman@gmail.com>\r\nLast Updated: 2008-12-21"""\r\n'))
> <string>(1)<module>()
(Pdb) c
Traceback (most recent call last):
  File "c:\Python31\lib\pdb.py", line 1297, in main
    pdb._runscript(mainpyfile)
  File "c:\Python31\lib\pdb.py", line 1216, in _runscript
    self.run(statement)
  File "c:\Python31\lib\bdb.py", line 378, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "e:\notes\programming\python3\version_check.py", line 4
    """Check what version of python is running.

Written by: Michael Newman <michael.b.newman@gmail.com>
Last Updated: 2008-12-21"""



^
SyntaxError: invalid syntax
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> <string>(1)<module>()
(Pdb) q
Post mortem debugger finished. The version_check.py will be restarted
SyntaxError: ('invalid syntax', ('e:\\notes\\programming\\python3\\version_check
.py', 4, 132, '"""Check what version of python is running.\r\n\r\nWritten by: Mi
chael Newman <michael.b.newman@gmail.com>\r\nLast Updated: 2008-12-21"""\r\n'))
> <string>(1)<module>()
(Pdb) q

# --- End Python 3.1 Example with "\r\n" source code --- #

As a hunch, my program is has Windows style line endings "\r\n", so I saved the file to another file name and converted it to Unix style "\n" line endings... and this version does work:

# --- Begin Python 3.1 Example using "\n" source code --- #

E:\notes\Programming\python3>copy version_check.py version_check_unix.py
        1 file(s) copied.

E:\notes\Programming\python3>which d2u
C:\Program Files\GnuWin32\bin\d2u.EXE

E:\notes\Programming\python3>d2u version_check_unix.py
version_check_unix.py: done.

E:\notes\Programming\python3>py31 -m pdb version_check_unix.py
> e:\notes\programming\python3\version_check_unix.py(4)<module>()
-> Last Updated: 2008-12-21"""
(Pdb) c
3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)]
The program finished and will be restarted
> e:\notes\programming\python3\version_check_unix.py(4)<module>()
-> Last Updated: 2008-12-21"""
(Pdb) q

# --- End Python 3.1 Example using "\n" source code --- #

Is "\r\n" not officially supported by "-m pdb"? Or is this a bug?
History
Date User Action Args
2010-02-19 12:52:17mnewmansetrecipients: + mnewman
2010-02-19 12:52:17mnewmansetmessageid: <1266583937.16.0.516750395183.issue7964@psf.upfronthosting.co.za>
2010-02-19 12:52:14mnewmanlinkissue7964 messages
2010-02-19 12:52:13mnewmancreate