From f6a7002ef16b3c7ca62c0b44013d9274c0842094 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Wed, 10 Jan 2007 22:46:06 +0000 Subject: [PATCH] Fixed #3278 -- newforms: Fixed bug in DeclarativeFieldsMetaclass where it inadvertently overrode the class' name. Thanks, russblau@imapmail.org git-svn-id: http://code.djangoproject.com/svn/django/trunk@4303 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 2 +- tests/regressiontests/forms/tests.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 21c9722990..0b4687bcf3 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -29,7 +29,7 @@ class SortedDictFromList(SortedDict): class DeclarativeFieldsMetaclass(type): "Metaclass that converts Field attributes to a dictionary called 'fields'." def __new__(cls, name, bases, attrs): - fields = [(name, attrs.pop(name)) for name, obj in attrs.items() if isinstance(obj, Field)] + fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] fields.sort(lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter)) attrs['fields'] = SortedDictFromList(fields) return type.__new__(cls, name, bases, attrs) diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 3b252fb5a9..ad77d5795e 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -1551,7 +1551,7 @@ False >>> p.clean_data Traceback (most recent call last): ... -AttributeError: 'birthday' object has no attribute 'clean_data' +AttributeError: 'Person' object has no attribute 'clean_data' >>> print p @@ -1585,7 +1585,7 @@ False >>> p.clean_data Traceback (most recent call last): ... -AttributeError: 'birthday' object has no attribute 'clean_data' +AttributeError: 'Person' object has no attribute 'clean_data' >>> print p @@ -1627,7 +1627,7 @@ u'