Opened 12 years ago

Closed 12 years ago

#18790 closed Bug (fixed)

Non-ascii characters in password for database settings don't work

Reported by: thcourbon@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: unicode
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

An UnicodeError is raised when using a password that contains non-ascii characters.

For example the following settings cause an error when I run ./manage.py syncdb.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'DBName',
        'USER': 'DBUser',
        'PASSWORD': u'je suis français',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

To run ./manage.py runserver with an empty project (just update the settings) you have to add the magix comment on top of the file :
# -*- coding: utf-8 -*-

Attachments (1)

18790-1.diff (3.4 KB ) - added by Claude Paroz 12 years ago.
Encode db password on Python 2

Download all attachments as: .zip

Change History (5)

comment:1 by Claude Paroz, 12 years ago

Component: Core (Management commands)Database layer (models, ORM)
Triage Stage: UnreviewedAccepted

Confirmed that the Python 2 psycopg adapter does not support unicode password input (OK with Python 3).

by Claude Paroz, 12 years ago

Attachment: 18790-1.diff added

Encode db password on Python 2

comment:3 by Claude Paroz, 12 years ago

Has patch: set

Someone should test it with oracle to see if the password encoding is also needed.

comment:4 by Claude Paroz <claude@…>, 12 years ago

Resolution: fixed
Status: newclosed

In 859aa2a6c4496a0feafebef7c7ea8fc57d9913f4:

Fixed #18790 -- Encoded database password on Python 2

Thanks thcourbon@… for the report.

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