﻿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
17447	Problematic logical expressions for types.ClassType checks in django.utils.dictconfig	Stefan Zimmermann	nobody	"`BaseConfigurator.configure_custom` and `DictConfigurator.configure_handler` both contain the following code:
{{{#!python
if not hasattr(c, '__call__') and hasattr(types, 'ClassType') and type(c) != types.ClassType:
    c = self.resolve(c)
}}}
The problem is that this logical expression always fails if the `types` module doesn't have the `ClassType` attribute (I encountered this when working with the django-3k fork)

The expression could be written like this:
{{{#!python
if not hasattr(c, '__call__') and (not hasattr(types, 'ClassType') or type(c) != types.ClassType):
    c = self.resolve(c)
}}}
But the `hasattr` call could also be completely dropped (In python 2.x `types.ClassType` is always there and `2to3` converts it to `type`):
{{{#!python
if not hasattr(c, '__call__') and type(c) != types.ClassType:
    c = self.resolve(c)
}}}"	Cleanup/optimization	closed	Python 3	dev	Normal	worksforme	types ClassType logic expression hasattr		Accepted	1	0	0	1	1	0
