Opened 3 years ago

Closed 3 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 claudep 3 years ago.
Encode db password on Python 2

Download all attachments as: .zip

Change History (5)

comment:1 Changed 3 years ago by claudep

  • Component changed from Core (Management commands) to Database layer (models, ORM)
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

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

Changed 3 years ago by claudep

Encode db password on Python 2

comment:3 Changed 3 years ago by claudep

  • Has patch set

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

comment:4 Changed 3 years ago by Claude Paroz <claude@…>

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

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