Opened 10 years ago

Closed 10 years ago

#23032 closed Bug (needsinfo)

Error with add_to_builtins

Reported by: anonymous Owned by: nobody
Component: Uncategorized Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I use Django with Tornado Web Server. It work like a charm when i start my server direcly with Python.

I converted my project into a standalone exe program with py2exe. Now when i load a webpage i get the following error

ERROR:tornado.application:Uncaught exception, closing connection.
Traceback (most recent call last):
  File "tornado\iostream.pyc", line 354, in wrapper
  File "tornado\stack_context.pyc", line 331, in wrapped
  File "tornado\stack_context.pyc", line 302, in wrapped
  File "tornado\httpserver.pyc", line 328, in _on_headers
  File "tornado\wsgi.pyc", line 251, in __call__
  File "django\core\handlers\wsgi.pyc", line 206, in __call__
  File "django\core\handlers\base.pyc", line 196, in get_response
  File "django\core\handlers\base.pyc", line 231, in handle_uncaught_exception
  File "django\views\debug.pyc", line 69, in technical_500_response
  File "django\views\debug.pyc", line 322, in get_traceback_html
  File "django\template\base.pyc", line 125, in __init__
  File "django\template\base.pyc", line 152, in compile_string
  File "django\template\debug.pyc", line 35, in __init__
  File "django\template\base.pyc", line 239, in __init__
  File "django\template\base.pyc", line 353, in add_library
AttributeError: 'NoneType' object has no attribute 'tags'
ERROR:tornado.application:Exception in callback <functools.partial object at 0x0
3658DB0>
Traceback (most recent call last):
  File "tornado\ioloop.pyc", line 477, in _run_callback
  File "tornado\stack_context.pyc", line 331, in wrapped
  File "tornado\stack_context.pyc", line 302, in wrapped
  File "tornado\iostream.pyc", line 354, in wrapper
  File "tornado\stack_context.pyc", line 331, in wrapped
  File "tornado\stack_context.pyc", line 302, in wrapped
  File "tornado\httpserver.pyc", line 328, in _on_headers
  File "tornado\wsgi.pyc", line 251, in __call__
  File "django\core\handlers\wsgi.pyc", line 206, in __call__
  File "django\core\handlers\base.pyc", line 196, in get_response
  File "django\core\handlers\base.pyc", line 231, in handle_uncaught_exception
  File "django\views\debug.pyc", line 69, in technical_500_response
  File "django\views\debug.pyc", line 322, in get_traceback_html
  File "django\template\base.pyc", line 125, in __init__
  File "django\template\base.pyc", line 152, in compile_string
  File "django\template\debug.pyc", line 35, in __init__
  File "django\template\base.pyc", line 239, in __init__
  File "django\template\base.pyc", line 353, in add_library
AttributeError: 'NoneType' object has no attribute 'tags'

To fix that problem I add a condition in add_to_builtins. This add_to_builtins: https://github.com/django/django/blob/master/django/template/base.py#L1353

My add_to_builtins :

def add_to_builtins(module):
    mod_imported = import_library(module)
    if mod_imported != None :
        builtins.append(mod_imported)

Don't know if I fix that problem by the right way but that work for me.

Change History (4)

comment:1 by neihx@…, 10 years ago

comment:2 by Ludovic Lardies <ludoviclrds@…>, 10 years ago

Version: 1.6master

comment:3 by Tim Graham, 10 years ago

I'm concerned that the fix may be hiding an actual problem with your project. Can you check what the attempted imported module name is when None is added to builtins?

comment:4 by Tim Graham, 10 years ago

Resolution: needsinfo
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top