Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#19933 closed Bug (fixed)

"ValueError: unknown locale: en_NG" in Django 1.5

Reported by: lanre.hbs@… Owned by: nobody
Component: Internationalization Version: 1.5-rc-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I get the error

ValueError: unknown locale: en_NG

after I create a new Django 1.5 project, run "python manage.py syncdb" and attempt to define a superuser. This was also a bug in Django 1.4 when it was first released but was eventually fixed.

Attachments (1)

19933-1.diff (1.4 KB) - added by claudep 2 years ago.
Using DEFAULT_LOCALE_ENCODING

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Please run the command with the --traceback option and provide the full traceback on the ticket.

comment:2 Changed 3 years ago by lanre.hbs@…

Please find the full traceback below based on including the --traceback option:

Traceback (most recent call last):
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
    output = self.handle(*args, **options)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/base.py", line 385, in handle
    return self.handle_noargs(**options)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/sql.py", line 195, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 170, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 117, in create_superuser
    call_command("createsuperuser", interactive=True, database=db)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 161, in call_command
    return klass.execute(*args, **defaults)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/core/management/base.py", line 255, in execute
    output = self.handle(*args, **options)
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/commands/createsuperuser.py", line 79, in handle
    default_username = get_default_username()
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 161, in get_default_username
    default_username = get_system_username()
  File "/home/lanre/.virtualenvs/D1.5R/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 136, in get_system_username
    default_locale = locale.getdefaultlocale()[1]
  File "/home/lanre/.virtualenvs/D1.5R/lib/python2.7/locale.py", line 511, in getdefaultlocale
    return _parse_localename(localename)
  File "/home/lanre/.virtualenvs/D1.5R/lib/python2.7/locale.py", line 443, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: en_NG
Last edited 3 years ago by claudep (previous) (diff)

comment:3 Changed 3 years ago by claudep

  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

Thanks for the traceback.

Python-related bugs:

Related Django ticket: #16017

We should definitely catch ValueError in get_system_username.

Changed 2 years ago by claudep

Using DEFAULT_LOCALE_ENCODING

comment:4 Changed 2 years ago by claudep

  • Has patch set

comment:5 Changed 2 years ago by Claude Paroz <claude@…>

In 8e8c9b908a0fe0d2437fcf3f0378eb2a62b81986:

Fixed getting default encoding in get_system_username

Refs #19933.

comment:6 Changed 2 years ago by Claude Paroz <claude@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 327c98ff08a95205919df4ae31dc633c1acec643:

[1.5.x] Fixed #19933 -- Catched ValueError in get_system_username

Thanks lanre.hbs at gmail.com for the report.

comment:7 Changed 2 years ago by claudep

As you can see by comparing the patches, I chose a different fix for stable (minimal potential impact) and master (bit of refactoring).

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