Fixes for Python 3 compatibility.

This commit is contained in:
Russell Keith-Magee 2012-09-16 18:09:27 +08:00
parent dfd72131d8
commit dbb3900775
3 changed files with 5 additions and 5 deletions

View File

@ -62,7 +62,7 @@ class Command(BaseCommand):
other_data[field_name] = field.clean(options[field_name], None)
else:
raise CommandError("You must use --%s with --noinput." % field_name)
except exceptions.ValidationError, e:
except exceptions.ValidationError as e:
raise CommandError('; '.join(e.messages))
else:
@ -84,7 +84,7 @@ class Command(BaseCommand):
username = default_username
try:
username = username_field.clean(raw_value, None)
except exceptions.ValidationError, e:
except exceptions.ValidationError as e:
self.stderr.write("Error: %s" % '; '.join(e.messages))
username = None
continue
@ -105,7 +105,7 @@ class Command(BaseCommand):
raw_value = input(capfirst(field.verbose_name + ': '))
try:
other_data[field_name] = field.clean(raw_value, None)
except exceptions.ValidationError, e:
except exceptions.ValidationError as e:
self.stderr.write("Error: %s" % '; '.join(e.messages))
other_data[field_name] = None

View File

@ -289,7 +289,7 @@ class AbstractUser(AbstractBaseUser):
help_text=_('Required. 30 characters or fewer. Letters, numbers and '
'@/./+/-/_ characters'),
validators=[
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _(u'Enter a valid username.'), 'invalid')
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), 'invalid')
])
first_name = models.CharField(_('first name'), max_length=30, blank=True)
last_name = models.CharField(_('last name'), max_length=30, blank=True)

View File

@ -110,7 +110,7 @@ class ModelBase(type):
# If the model is a proxy, ensure that the base class
# hasn't been swapped out.
if is_proxy and base_meta.swapped:
if is_proxy and base_meta and base_meta.swapped:
raise TypeError("%s cannot proxy the swapped model '%s'." % (name, base_meta.swapped))
if getattr(new_class, '_default_manager', None):