Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

fixed #18160 Auth - Unknown Encoding Error when syncdb #570

Closed
wants to merge 4 commits into from

2 participants

@mitnk

I mentioned this error with sqlite3 in the original post. But the other day, I re-encounter it on another Macbook with PostgreSQL. So I think we'd better fix this issue for the non-ascii locales env.

mitnk added some commits
@mitnk mitnk fixed #18160 Auth - Unknown Encoding Error when syncdb
I mentioned this error with sqlite3. But the other day, I re-encounter it
on another Macbook with PostgreSQL. So I think we would better fix this
issue for the non-ascii locales env.
8df7f98
@mitnk mitnk Merge branch 'master' of https://github.com/django/django
c6f8289
django/contrib/auth/tests/management.py
@@ -31,6 +31,11 @@ def test_simple(self):
management.get_system_username = lambda: 'joe'
self.assertEqual(management.get_default_username(), 'joe')
+ def test_unknown_encoding(self):
+ import locale
+ locale.getdefaultlocale = lambda: ("en_US", "x-mac-simp-chinese")
@apollo13 Owner
apollo13 added a note

You at least have to reset this at the end of the test to not leak this change into other tests (use try/finally)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@mitnk

Is there still any thing block this pull request being merged?

cc @apollo13

@apollo13
Owner

I've never ran into an issue like this so I can't test it. @jezdez has a mac book, he might be able to test and give some pointers. Also this PR currently isn't mergeable (according to the GH merge button)

@mitnk

Yeah. I encountered twice on two different macbooks.

@mitnk mitnk closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 2, 2012
  1. @mitnk

    fixed #18160 Auth - Unknown Encoding Error when syncdb

    mitnk authored
    I mentioned this error with sqlite3. But the other day, I re-encounter it
    on another Macbook with PostgreSQL. So I think we would better fix this
    issue for the non-ascii locales env.
Commits on Dec 3, 2012
  1. @mitnk
Commits on Dec 8, 2012
  1. @mitnk
  2. @mitnk
This page is out of date. Refresh to see the latest.
View
3  django/contrib/auth/management/__init__.py
@@ -138,7 +138,8 @@ def get_system_username():
return ''
try:
result = result.decode(default_locale)
- except UnicodeDecodeError:
+ except (LookupError, UnicodeDecodeError):
+ # LookupError - default_locale may not a valid codec name
# UnicodeDecodeError - preventive treatment for non-latin Windows.
return ''
return result
View
9 django/contrib/auth/tests/management.py
@@ -31,6 +31,15 @@ def test_simple(self):
management.get_system_username = lambda: 'joe'
self.assertEqual(management.get_default_username(), 'joe')
+ def test_unknown_encoding(self):
+ import locale
+ try:
+ origin = locale.getdefaultlocale
+ locale.getdefaultlocale = lambda: ("en_US", "x-mac-simp-chinese")
+ self.assertEqual(management.get_default_username(), '')
+ finally:
+ locale.getdefaultlocale = origin
+
def test_existing(self):
models.User.objects.create(username='joe')
management.get_system_username = lambda: 'joe'
Something went wrong with that request. Please try again.