New submission from Michael Newman <michael.b.new...@gmail.com>: 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.new...@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.new...@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.new...@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? ---------- components: Library (Lib) files: version_check.py messages: 99570 nosy: mnewman severity: normal status: open title: "-m pdb" SyntaxError for "\r\n" formatted py files type: behavior versions: Python 3.1, Python 3.2 Added file: http://bugs.python.org/file16256/version_check.py _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue7964> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com