#30405: IndexError in _get_lines_from_file when module does not match file
contents
(via loader)
-------------------------------------------+------------------------
Reporter: Daniel Hahler | Owner: (none)
Type: Bug | Status: new
Component: Error reporting | Version: 2.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
{{{
self = <django.views.debug.ExceptionReporter object at 0x7f2a7908ac18>
filename = '…/project/.venv/lib/python3.7/site-packages/pdb.py'
lineno = 230
context_lines = 7
loader = <_frozen_importlib_external.SourceFileLoader object at
0x7f2a73609278>
module_name = 'pdb'
[23]
…/Vcs/django/django/core/handlers/exception.py(90)response_for_exception()
-> response = handle_uncaught_exception(request,
get_resolver(get_urlconf()), sys.exc_info())
[24]
…/Vcs/django/django/core/handlers/exception.py(125)handle_uncaught_exception()
-> return debug.technical_500_response(request, *exc_info)
[25] …/Vcs/django/django/views/debug.py(94)technical_500_response()
-> html = reporter.get_traceback_html()
[26] …/Vcs/django/django/views/debug.py(333)get_traceback_html()
-> c = Context(self.get_traceback_data(), use_l10n=False)
[27] …/Vcs/django/django/views/debug.py(264)get_traceback_data()
-> frames = self.get_traceback_frames()
[28] …/Vcs/django/django/views/debug.py(427)get_traceback_frames()
-> filename, lineno, 7, loader, module_name,
385 try:
386 context_line = source[lineno]
387 except:
388 __import__('pdb').set_trace()
389 -> post_context = source[lineno + 1:upper_bound]
390
391 return lower_bound, pre_context, context_line,
post_context
(Pdb++) source
['# this file is needed to hijack pdb without eggs', 'import os.path',
"pdb_path = os.path.join(os.path.dirname(os.path.dirname(__file__)),
'pdb.py')", 'with open(pdb_path) as f:', " exec(compile(f.read(),
pdb_path, 'exec'))"]
}}}
It uses the loader
(https://github.com/django/django/blob/47885278c669dd7a13a4c3ff7e58e1cbe88af385/django/views/debug.py#L351),
which picks up the `pth`, and then the contents does not match the
expected line number.
I think it should maybe always use the given filename?!
--
Ticket URL: <https://code.djangoproject.com/ticket/30405>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.e34f8878c2053353d9f8ab07ff766814%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.