I'm on 3.7.0 on Win 10, and get a different result. No traceback. Perhaps it's a bug in 3.4 that was fixed subsequently.

C:\test> py -m pdb bugInPDB.py
> c:\test\buginpdb.py(1)<module>()
-> password = 'bad'
(Pdb) tbreak 3
Breakpoint 1 at c:\test\buginpdb.py:3
(Pdb) cont
Deleted breakpoint 1 at c:\test\buginpdb.py:3
> c:\test\buginpdb.py(3)<module>()
-> print('bad password')
(Pdb) cont
bad password
The program exited via sys.exit(). Exit status: None
> c:\test\buginpdb.py(1)<module>()
-> password = 'bad'
(Pdb) q

C:\test>

On 6/09/2018 7:38 PM, Jach Fong wrote:
Here the script file, test0.py:
--------------------------
password = 'bad'
if password == 'bad':
    print('bad password')
    exit()
else:
    print('good password')

print('something else to do')
--------------------

    When running it under Python3.4 Windows Vista, no problem at all.

D:\Works\Python>py test0.py
bad password

    But if debug it under pdb:

D:\Works\Python>py -m pdb test0.py
> d:\works\python\test0.py(1)<module>()
-> password = 'bad'
(Pdb) tbreak 3
Breakpoint 1 at d:\works\python\test0.py:3
(Pdb) cont
Deleted breakpoint 1 at d:\works\python\test0.py:3
> d:\works\python\test0.py(3)<module>()
-> print('bad password')
(Pdb) cont
bad password
The program exited via sys.exit(). Exit status: None
> d:\works\python\test0.py(1)<module>()
-> password = 'bad'
(Pdb) Traceback (most recent call last):
  File "C:\Python34\lib\pdb.py", line 1661, in main
    pdb._runscript(mainpyfile)
  File "C:\Python34\lib\pdb.py", line 1542, in _runscript
    self.run(statement)
  File "C:\Python34\lib\bdb.py", line 431, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "d:\works\python\test0.py", line 1, in <module>
    password = 'bad'
  File "d:\works\python\test0.py", line 1, in <module>
    password = 'bad'
  File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "C:\Python34\lib\bdb.py", line 66, in dispatch_line
    self.user_line(frame)
  File "C:\Python34\lib\pdb.py", line 259, in user_line
    self.interaction(frame, None)
  File "C:\Python34\lib\pdb.py", line 346, in interaction
    self._cmdloop()
  File "C:\Python34\lib\pdb.py", line 319, in _cmdloop
    self.cmdloop()
  File "C:\Python34\lib\cmd.py", line 126, in cmdloop
    line = input(self.prompt)
ValueError: I/O operation on closed file.
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> c:\python34\lib\cmd.py(126)cmdloop()
-> line = input(self.prompt)
(Pdb) Traceback (most recent call last):
  File "C:\Python34\lib\pdb.py", line 1661, in main
    pdb._runscript(mainpyfile)
  File "C:\Python34\lib\pdb.py", line 1542, in _runscript
    self.run(statement)
  File "C:\Python34\lib\bdb.py", line 431, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "d:\works\python\test0.py", line 1, in <module>
    password = 'bad'
  File "d:\works\python\test0.py", line 1, in <module>
    password = 'bad'
  File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "C:\Python34\lib\bdb.py", line 66, in dispatch_line
    self.user_line(frame)
  File "C:\Python34\lib\pdb.py", line 259, in user_line
    self.interaction(frame, None)
  File "C:\Python34\lib\pdb.py", line 346, in interaction
    self._cmdloop()
  File "C:\Python34\lib\pdb.py", line 319, in _cmdloop
    self.cmdloop()
  File "C:\Python34\lib\cmd.py", line 126, in cmdloop
    line = input(self.prompt)
ValueError: I/O operation on closed file.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python34\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python34\lib\pdb.py", line 1688, in <module>
    pdb.main()
  File "C:\Python34\lib\pdb.py", line 1680, in main
    pdb.interaction(None, t)
  File "C:\Python34\lib\pdb.py", line 346, in interaction
    self._cmdloop()
  File "C:\Python34\lib\pdb.py", line 319, in _cmdloop
    self.cmdloop()
  File "C:\Python34\lib\cmd.py", line 126, in cmdloop
    line = input(self.prompt)
ValueError: I/O operation on closed file.

D:\Works\Python>

    How to get rid of these?

Best Regards,
Jach Fong


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus




--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to