﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
6442	base.py: TypeError: 'str' object is not callable when importing a module fails	miohtama	gptvnt	"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
}}}"	Bug	closed	Core (Other)	dev	Normal	worksforme		tomi.kyostila@… say4ne@…	Accepted	0	0	0	0	0	0
