Reputation: 141
I am trying to debug my python application which uses the "mailbot" module together with triggered user callbacks. These get triggered when a specific email has been received. Yesterday, debugging the application with PDB worked perfectly fine and I kind of finished my work. But today it seems that the world has changed... I can't remember having changed any relevant code since yesterday, but when I invoke my application within the PDB setting, it causes many exceptions which I don't know how to interpret.
When omitting PDB and starting the application with python application.py
, the application runs fine. So (and the error messages suggest it as well), the problems do not seem to have anything to do with my application, the usage of callbacks or the mailbot module.
Here is the story until the error messages. Sorry, it appears to be lengthy.
starting python in PDB mode...
C:\...> python -m pdb application.py
> c:\...\application.py(2)<module>()
-> from __future__ import print_function
setting breakpoint to one step before exception...
(Pdb) b c:\PROGS\Python34\Lib\site-packages\mailbot\mailbot.py:52
Breakpoint 1 at c:\progs\python34\lib\site-packages\mailbot\mailbot.py:52
starting execution until breakpoint...
(Pdb) c
> c:\progs\python34\lib\site-packages\mailbot\mailbot.py(52)process_message()
-> return callback.trigger()
show relevant listing...
(Pdb) l
47
48 def process_message(self, message, callback_class, rules):
49 """Check if callback matches rules, and if so, trigger."""
50 callback = callback_class(message, rules)
51 if callback.check_rules():
52 B-> return callback.trigger()
53
54 def process_messages(self):
55 """Process messages: check which callbacks should be triggered."""
56 from . import CALLBACKS_MAP
57 self.reset_timeout_messages()
examining next statement...
(Pdb) callback.trigger
<bound method cbLookUpMindmapAndSendText.trigger of <callbacks.cbLookUpMindmapAndSendText object at 0x02EB95B0>>
stepping into the callback...
(Pdb) s
--Call--
Traceback (most recent call last):
File "C:\PROGS\Python34\lib\pdb.py", line 1661, in main
pdb._runscript(mainpyfile)
File "C:\PROGS\Python34\lib\pdb.py", line 1542, in _runscript
self.run(statement)
File "C:\PROGS\Python34\lib\bdb.py", line 431, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "c:\...\application.py", line 25, in <module>
mailbox.process_messages()
File "C:\PROGS\Python34\lib\site-packages\mailbot\mailbot.py", line 64, in process_messages
self.process_message(message, callback_class, rules)
File "C:\PROGS\Python34\lib\site-packages\mailbot\mailbot.py", line 52, in process_message
return callback.trigger()
Traceback (most recent call last):
File "C:\PROGS\Python34\lib\pdb.py", line 1661, in main
pdb._runscript(mainpyfile)
File "C:\PROGS\Python34\lib\pdb.py", line 1542, in _runscript
self.run(statement)
File "C:\PROGS\Python34\lib\bdb.py", line 431, in run
exec(cmd, globals, locals)
File "<string>", line 1, in <module>
File "c:\...\application.py", line 25, in <module>
mailbox.process_messages()
File "C:\PROGS\Python34\lib\site-packages\mailbot\mailbot.py", line 64, in process_messages
self.process_message(message, callback_class, rules)
File "C:\PROGS\Python34\lib\site-packages\mailbot\mailbot.py", line 52, in process_message
return callback.trigger()
File "C:\...\callbacks.py", line 20, in trigger
File "C:\PROGS\Python34\lib\bdb.py", line 50, in trace_dispatch
return self.dispatch_call(frame, arg)
File "C:\PROGS\Python34\lib\bdb.py", line 82, in dispatch_call
self.user_call(frame, arg)
File "C:\PROGS\Python34\lib\pdb.py", line 249, in user_call
self.interaction(frame, None)
File "C:\PROGS\Python34\lib\pdb.py", line 345, in interaction
self.print_stack_entry(self.stack[self.curindex])
File "C:\PROGS\Python34\lib\pdb.py", line 1447, in print_stack_entry
self.format_stack_entry(frame_lineno, prompt_prefix))
File "C:\PROGS\Python34\lib\bdb.py", line 411, in format_stack_entry
line = linecache.getline(filename, lineno, frame.f_globals)
File "C:\PROGS\Python34\lib\linecache.py", line 15, in getline
lines = getlines(filename, module_globals)
File "C:\PROGS\Python34\lib\linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "C:\PROGS\Python34\lib\linecache.py", line 127, in updatecache
lines = fp.readlines()
File "C:\PROGS\Python34\lib\codecs.py", line 319, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 351: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\PROGS\Python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "C:\PROGS\Python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\PROGS\Python34\lib\pdb.py", line 1685, in <module>
pdb.main()
File "C:\PROGS\Python34\lib\pdb.py", line 1673, in main
traceback.print_exc()
File "C:\PROGS\Python34\lib\traceback.py", line 252, in print_exc
print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
File "C:\PROGS\Python34\lib\traceback.py", line 169, in print_exception
for line in _format_exception_iter(etype, value, tb, limit, chain):
File "C:\PROGS\Python34\lib\traceback.py", line 153, in _format_exception_iter
yield from _format_list_iter(_extract_tb_iter(tb, limit=limit))
File "C:\PROGS\Python34\lib\traceback.py", line 18, in _format_list_iter
for filename, lineno, name, line in extracted_list:
File "C:\PROGS\Python34\lib\traceback.py", line 65, in _extract_tb_or_stack_iter
line = linecache.getline(filename, lineno, f.f_globals)
File "C:\PROGS\Python34\lib\linecache.py", line 15, in getline
lines = getlines(filename, module_globals)
File "C:\PROGS\Python34\lib\linecache.py", line 41, in getlines
return updatecache(filename, module_globals)
File "C:\PROGS\Python34\lib\linecache.py", line 127, in updatecache
lines = fp.readlines()
File "C:\PROGS\Python34\lib\codecs.py", line 319, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xfc in position 351: invalid start byte
C:\...>
Any hints, where or how to work for a solution?
Thank you. nnako
Upvotes: 1
Views: 290
Reputation: 141
finally, I found the solution by trying to run the application on a Linux machine. Running it on Windows (without PDB) resulted in NO ERRORS. Linux showed this output while trying to run the command python application.py
:
Traceback (most recent call last):
File "application.py", line 12, in <module>
import callbacks
File "/home/pi/examples/callbacks.py", line 16
SyntaxError: Non-ASCII character '\xfc' in file /home/pi/examples/callbacks.py on line 16, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
So I found out that the oddity was caused by a non printable character "\xfc" hidden somewhere in a comment line. Removing the line and re-typing its contents solved the problem. Even though I do not have a clue how this could possibly cause the exception messages described in the post above.
Hope, this would be some help for someone some day.
Thanks. nnako
Upvotes: 1