Opened 7 years ago

Closed 5 years ago

#18160 closed Bug (duplicate)

Auth - Unknown Encoding Error when syncdb

Reported by: anonymous Owned by: nobody
Component: contrib.auth Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Jannis Leidel)

When I was running ./ syncdb (with sqlite3), a LookupError shows up
as follow. I filed a patch to fix it.

In the UnitTest, I made import locale as inline (Or should I import it at
the beggining of the file?)

bash $ ./ syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Traceback (most recent call last):
File "./", line 13, in <module>
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 443, in execute_from_command_line
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 382, in execute
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 196, in run_from_argv
  self.execute(*args, **options.__dict__)
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 232, in execute
  output = self.handle(*args, **options)
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 371, in handle
  return self.handle_noargs(**options)
File "/Users/yippee/projects/YEditor/server/django/core/management/commands/", line 110, in handle_noargs
  emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 189, in emit_post_sync_signal
  interactive=interactive, db=db)
File "/Users/yippee/projects/YEditor/server/django/dispatch/", line 172, in send
  response = receiver(signal=self, sender=sender, **named)
File "/Users/yippee/projects/YEditor/server/django/contrib/auth/management/", line 73, in create_superuser
  call_command("createsuperuser", interactive=True, database=db)
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 150, in call_command
  return klass.execute(*args, **defaults)
File "/Users/yippee/projects/YEditor/server/django/core/management/", line 232, in execute
  output = self.handle(*args, **options)
File "/Users/yippee/projects/YEditor/server/django/contrib/auth/management/commands/", line 70, in handle
  default_username = get_default_username()
File "/Users/yippee/projects/YEditor/server/django/contrib/auth/management/", line 105, in get_default_username
  default_username = get_system_username()
File "/Users/yippee/projects/YEditor/server/django/contrib/auth/management/", line 85, in get_system_username
  return getpass.getuser().decode(locale.getdefaultlocale()[1])
LookupError: unknown encoding: x-mac-simp-chinese


Attachments (2)

auth_unknown_encoding.diff (1.3 KB) - added by mitnk 7 years ago.
auth_invalid_encoding.diff (2.1 KB) - added by mawe 7 years ago.
Updated patch which fixes unknown as well as invalid (None) encodings

Download all attachments as: .zip

Change History (7)

Changed 7 years ago by mitnk

Attachment: auth_unknown_encoding.diff added

comment:1 Changed 7 years ago by Jannis Leidel

Description: modified (diff)

Fixed traceback.

comment:2 Changed 7 years ago by Jannis Leidel

Triage Stage: UnreviewedAccepted

comment:3 Changed 7 years ago by Jannis Leidel

Triage Stage: AcceptedReady for checkin

comment:4 Changed 7 years ago by mawe

Triage Stage: Ready for checkinAccepted

While the original patch fixes the issue with an invalid encoding, it does not address the problem completely. There also seem to be many duplicate tickets regarding this issue (search for getdefaultlocale), but it seems like the easiest fix would be to simply use django.utils.encoding.DEFAULT_LOCALE_ENCODING, as in the attached patch auth_invalid_encoding.diff

Changed 7 years ago by mawe

Attachment: auth_invalid_encoding.diff added

Updated patch which fixes unknown as well as invalid (None) encodings

comment:5 Changed 5 years ago by Claude Paroz

Resolution: duplicate
Status: newclosed

Was fixed in #19933

Note: See TracTickets for help on using tickets.
Back to Top