- System: Windows 11 upgraded from Windows 10 with Python 3.14. Our programs on on another network drive which is E:
- My program is e:\myprog\cleardupe.py
- My programs always begin with
r""" """on the first line where I put many comments about what the program does. I use therbecause sometimes I have a Windows path with a backslash and usingrremoves errors from that. - I start my program in a .bat file like this:
python -m pdb cleardupe.py --inputfile:"inputfiles\My file with spaces.xlsx" --overwrite
Each time I exit the debugger I seem to get 3 tracebacks which are ValueError: I/O operation on closed file but those make no sense. The program completes normally. At the end of the program I write a log file like this and the log file appears to be closed correctly.
if not os.path.exists(options.logfn):
file = open(options.logfn, 'w') # Open a text file.
content = listjoin(hdr)
file.write(content) # Write file header.
else:
file = open(options.logfn, 'a') # Open a text file for append.
content = listjoin(mylist) # \n is CRLF.
file.write("\n" + content) # \n needed before new line is added.
file.close() # Always close file when done.
Sorry! Here are the errors.
> e:\myprog\cleardupe.py(2)<module>()
-> r""" This is a template for othe programs.
(Pdb) q
*** SystemExit: None
(Pdb) Traceback (most recent call last):
File "C:\Program Files\Python314\Lib\pdb.py", line 3601, in main
pdb._run(target)
~~~~~~~~^^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 2522, in _run
self.run(target.code)
~~~~~~~~^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\bdb.py", line 899, in run
exec(cmd, globals, locals)
~~~~^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 1, in <module>
File "E:\myprog\cleardupe.py", line 2, in <module>
r""" This is a template for othe programs.
...<220 lines>...
"""
File "C:\Program Files\Python314\Lib\bdb.py", line 94, in wrapper
ret = func(frame, *args)
File "C:\Program Files\Python314\Lib\bdb.py", line 130, in line_callback
frame.f_trace(frame, 'line', None)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\bdb.py", line 284, in trace_dispatch
return self.dispatch_line(frame)
~~~~~~~~~~~~~~~~~~^^^^^^^
File "C:\Program Files\Python314\Lib\bdb.py", line 310, in dispatch_line
self.user_line(frame)
~~~~~~~~~~~~~~^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 547, in user_line
self.interaction(frame, None)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 736, in interaction
self._cmdloop()
~~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\pdb.py", line 601, in _cmdloop
self.cmdloop()
~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\cmd.py", line 137, 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:\program files\python314\lib\cmd.py(137)cmdloop()
-> line = input(self.prompt)
(Pdb) Traceback (most recent call last):
File "C:\Program Files\Python314\Lib\pdb.py", line 3601, in main
pdb._run(target)
~~~~~~~~^^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 2522, in _run
self.run(target.code)
~~~~~~~~^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\bdb.py", line 899, in run
exec(cmd, globals, locals)
~~~~^^^^^^^^^^^^^^^^^^^^^^
File "<string>", line 1, in <module>
File "E:\myprog\cleardupe.py", line 2, in <module>
r""" This is a template for othe programs.
...<220 lines>...
"""
File "C:\Program Files\Python314\Lib\bdb.py", line 94, in wrapper
ret = func(frame, *args)
File "C:\Program Files\Python314\Lib\bdb.py", line 130, in line_callback
frame.f_trace(frame, 'line', None)
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\bdb.py", line 284, in trace_dispatch
return self.dispatch_line(frame)
~~~~~~~~~~~~~~~~~~^^^^^^^
File "C:\Program Files\Python314\Lib\bdb.py", line 310, in dispatch_line
self.user_line(frame)
~~~~~~~~~~~~~~^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 547, in user_line
self.interaction(frame, None)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 736, in interaction
self._cmdloop()
~~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\pdb.py", line 601, in _cmdloop
self.cmdloop()
~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\cmd.py", line 137, 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 "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Program Files\Python314\Lib\pdb.py", line 3627, in <module>
pdb.main()
~~~~~~~~^^
File "C:\Program Files\Python314\Lib\pdb.py", line 3614, in main
pdb.interaction(None, e)
~~~~~~~~~~~~~~~^^^^^^^^^
File "C:\Program Files\Python314\Lib\pdb.py", line 736, in interaction
self._cmdloop()
~~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\pdb.py", line 601, in _cmdloop
self.cmdloop()
~~~~~~~~~~~~^^
File "C:\Program Files\Python314\Lib\cmd.py", line 137, in cmdloop
line = input(self.prompt)
ValueError: I/O operation on closed file.
Python 3.11 did not do this. How do I get rid of all these errors?
Thank you.