home / django_tickets / tickets

tickets: 6442

This data as json

id created changetime last_pulled_from_trac stage status component type severity version resolution summary description owner reporter keywords easy has_patch needs_better_patch needs_tests needs_docs ui_ux
6442 2008-01-22 23:41:03 2011-06-09 15:02:24 2022-03-06 03:37:09.487236 Accepted closed Core (Other) Bug Normal dev worksforme base.py: TypeError: 'str' object is not callable when importing a module fails If you specify a module which does not import (it has syntax error or missing dependendies), base.py will raise mysterious TypeError. This is because urlresolver does not raise an exception when callback is not callable, but returns the original string instead. This makes it very difficult for a developer to track down the real cause of the problem, since the orignal ImportError is silently eaten. I suggest that urlresolver would raise an exception on invalid look-ups. I can create test case and patch if there is no reason why the current behavior should kept. Steps to reproduce. 1. Create a views.py module with any function 2. Make views.py have an invalid import {{{ import x def any_function(request, *args, **kwargs): pass }}} 3. Add views.py to urlconf, e.g. {{{ (r'^sampleurl/(.*)$', 'myproduct.views.any_function'), }}} 4. Use test client to get the URI {{{ c = Client() response = c.get("/sampleurl/") }}} Sample result below: {{{ Traceback (most recent call last): File "/home/moo/workspace/web/dependencies/django-go/scaler/tests/scaletest.py", line 102, in testServeScaledImage response = c.get(uri) File "/home/moo/workspace/web/dependencies/django-trunk/django/test/client.py", line 219, in get return self.request(**r) File "/home/moo/workspace/web/dependencies/django-trunk/django/core/handlers/base.py", line 82, in _real_get_response response = callback(request, *callback_args, **callback_kwargs) TypeError: 'str' object is not callable }}} gptvnt miohtama   0 0 0 0 0 0
Powered by Datasette · Queries took 0.948ms