Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python traceback is missing line numbers, files #785

Closed
ni-tterry opened this issue Jan 20, 2017 · 4 comments
Closed

python traceback is missing line numbers, files #785

ni-tterry opened this issue Jan 20, 2017 · 4 comments

Comments

@ni-tterry
Copy link

The traceback display of the python katas isn't showing files or line counts, which makes debugging difficult.

This is what the traceback ends up looking like:

Traceback:
   in 
   in tower_builder
TypeError: can't multiply sequence by non-int of type 'float'

This is what it should look like:

def uh_oh():
    a = a

>>> uh_oh()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in uh_oh
UnboundLocalError: local variable 'a' referenced before assignment

To repro:
Raise any error (or cause an error to be raised) in any code block of any kata.

I don't think this is kata specific... this has been happening with every kata.

It doesn't appear to be a CSS or client side problem. Here's the source from the element:

<raw content="Traceback:
   in <module>
   in interpreter
UnboundLocalError: local variable 'a' referenced before assignment">Traceback:
   in <module>
   in interpreter
UnboundLocalError: local variable 'a' referenced before assignment</module></raw>

But for what it's worth: OS X 11.6, Chrome 55.0.2883.95

@ni-tterry ni-tterry changed the title python stderr doesn't show traceback correctly python traceback doesn't display correctly Jan 20, 2017
@ni-tterry ni-tterry changed the title python traceback doesn't display correctly python traceback is missing line numbers, files Jan 20, 2017
@kazk
Copy link
Member

kazk commented Mar 28, 2017

Currently, file names and line numbers are intentionally removed, so it's not CSS or browser issue.

// get rid of some of the noisy content. We remove line numbers since
// they don't match up to what the user sees and will only confuse them.

This is because Python tests are executed using concatenated file:

# python -c file.py / python3 -c file.py
try: from imp import reload
except: pass
reload(__import__('sys')).path.append('./frameworks/python')
reload(__import__('sys')).path.append('/home/codewarrior')

test = Test = reload(__import__('cw-2'))

# +Preloaded

# +Solution

# +Tests

I haven't looked into the reasons why it's done this way, but this needs to be improved first in order to enable useful tracebacks.


lib/runners/python.js

@ni-tterry
Copy link
Author

Thanks! This would be a great improvement, especially for people who are just starting out, or for people working on the more complex katas.

@kazk
Copy link
Member

kazk commented Mar 22, 2018

The new runner avoids concatenation so it'll show line numbers with error messages.

def multiply(a, b):
    return a b

image

@kazk
Copy link
Member

kazk commented Apr 5, 2018

The new runner was deployed :) #1336

@kazk kazk closed this as completed Apr 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants