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

AttributeError: 'SafeString' object has no attribute 'pygmentized' #1662

Closed
daniel-butler opened this issue Aug 16, 2022 · 3 comments
Closed

Comments

@daniel-butler
Copy link
Contributor

Django Version: 4.1
Python Version: 3.10
Django Debug Toolbar Version: 3.5.0

Steps to Reproduce:

  1. Open the toolbar
  2. Click Templates
  3. Click on a Specific Template

Screen Shot 2022-08-16 at 1 41 17 PM

ERROR 2022-08-16 12:29:00,535 log 82 275499009792 Internal Server Error: /__debug__/template_source/
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/asgiref/sync.py", line 472, in thread_handler
    raise exc_info[1]
  File "/usr/local/lib/python3.10/site-packages/django/core/handlers/exception.py", line 42, in inner
    response = await get_response(request)
  File "/usr/local/lib/python3.10/site-packages/django/core/handlers/base.py", line 253, in _get_response_async
    response = await wrapped_callback(
  File "/usr/local/lib/python3.10/site-packages/asgiref/sync.py", line 435, in __call__
    ret = await asyncio.wait_for(future, timeout=None)
  File "/usr/local/lib/python3.10/asyncio/tasks.py", line 408, in wait_for
    return await fut
  File "/usr/local/lib/python3.10/site-packages/asgiref/current_thread_executor.py", line 22, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.10/site-packages/asgiref/sync.py", line 476, in thread_handler
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.10/contextlib.py", line 79, in inner
    return func(*args, **kwds)
  File "/usr/local/lib/python3.10/site-packages/debug_toolbar/decorators.py", line 15, in inner
    return view(request, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/debug_toolbar/panels/templates/views.py", line 56, in template_source
    source.pygmentized = True
AttributeError: 'SafeString' object has no attribute 'pygmentized'
@matthiask
Copy link
Member

Ah yes, that's caused by https://code.djangoproject.com/ticket/33465

We should use a standalone variable for the pygmentized flag instead of attaching it to source.

Do you want to attempt fixing this?

@matthiask
Copy link
Member

I submitted #1663 which should hopefully fix this issue.

@daniel-butler
Copy link
Contributor Author

Nice! Thanks a ton!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants