diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py index d8023428e1..c5f6469548 100644 --- a/django/contrib/auth/management/commands/createsuperuser.py +++ b/django/contrib/auth/management/commands/createsuperuser.py @@ -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 diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 076e7a9910..7f5f5f6801 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -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) diff --git a/django/db/models/base.py b/django/db/models/base.py index b77d2d0760..a1f9e2f26e 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -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):