﻿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
18171	TypeErrors pass silently inside of authentication backends `authenticate()`	David Eyk <deyk@…>	Renato Oliveira	"`TypeError`s pass silently when raised inside of an authentication backend's `authenticate` method. This can make debugging a backend tricky.

A simple example:

{{{
class MyBackend(object):
    def authenticate(self, username, password):
        for item in None:  # Raises a TypeError, which passes silently!
            print ""You'll never get here!""
}}}

Because `django.auth.authenticate` uses `TypeError`s to check whether the backend has been called with the correct signature, there may not be an easy solution for this, but some options would include:

1. Check `Exception.message` for `/takes (?:exactly \d+|no) arguments?/` and re-raise or `logger.exception()` if it doesn't match. This would significantly narrow down the cases where the wrong exception would silently pass. (A simpler, quicker check of `""argument"" in e.message` would also work)

2. Document this behavior, recommending that backends should handle their own TypeErrors in https://docs.djangoproject.com/en/1.4/topics/auth/#writing-an-authentication-backend"	Bug	closed	contrib.auth	1.4	Normal	fixed		charette.s@… jeffhui	Ready for checkin	1	0	0	0	1	0
