beeware / bugjar

A interactive graphical debugger for Python code.
BSD 3-Clause "New" or "Revised" License
249 stars 31 forks source link

Can't debug scripts without .py extension #1

Closed glyph closed 11 years ago

glyph commented 11 years ago

Here's what I tried, and here's the traceback:

$ bugjar ./bin/twistd -n web --path .
Listening on 0.0.0.0:3742 for a bugjar client
Got connection from ('127.0.0.1', 60247)
Exception in thread Thread-1:
Traceback (most recent call last):
  File ".../threading.py", line 808, in __bootstrap_inner
    self.run()
  File ".../threading.py", line 761, in run
    self.__target(*self.__args, **self.__kwargs)
  File ".../bugjar/connection.py", line 56, in command_buffer
    getattr(debugger, 'on_%s' % event)(**data)
  File ".../bugjar/connection.py", line 227, in on_stack
    self.view.on_stack(stack=stack)
  File ".../bugjar/view.py", line 473, in on_stack
    self.show_file(filename=filename, line=line)
  File ".../bugjar/view.py", line 324, in show_file
    self.code.filename = filename
  File ".../tkreadonly.py", line 197, in filename
    lexer = guess_lexer_for_filename(value, all_content, stripnl=False)
  File ".../pygments/lexers/__init__.py", line 181, in guess_lexer_for_filename
    raise ClassNotFound('no lexer for filename %r found' % fn)
ClassNotFound: no lexer for filename u'twistd' found
freakboy3742 commented 11 years ago

Thanks for the report Glyph; I have really only tested with simple scripts so far -- even Django's HTTP server causes problems (unless you turn off auto-reload). I'm just using Pygments auto-identification; how does Twisted normally handle content identification with Pygments?

glyph commented 11 years ago

"content identification with Pygments" is not normally a thing that we have to "handle" :). We write code in Python, usually with a .py extension, but very occasionally (as in this case) in the bin directory, with no extension, or with a weird extension (like .tac). Then, if a developer uses a tool which needs to know that the code in question is Python for some reason, that developer just tells that tool that the code in question is Python. 99% of the time this is just a text editor anyway, not Pygments.

IMHO, it would be reasonable for bugjar to always assume the argument that it's given on the command line is Python, since that is literally a requirement :-). If other files failed to syntax highlight that would be a far less annoying failure than failing to work entirely.

glyph commented 11 years ago

Thanks for the fix! Hopefully I'll try again soon :-).