diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index cec3b04..4043014 100644
|
a
|
b
|
from django.db.backends.mysql.client import DatabaseClient
|
| 37 | 37 | from django.db.backends.mysql.creation import DatabaseCreation |
| 38 | 38 | from django.db.backends.mysql.introspection import DatabaseIntrospection |
| 39 | 39 | from django.db.backends.mysql.validation import DatabaseValidation |
| | 40 | from django.utils.encoding import force_str |
| 40 | 41 | from django.utils.functional import cached_property |
| 41 | 42 | from django.utils.safestring import SafeBytes, SafeText |
| 42 | 43 | from django.utils import six |
| … |
… |
class DatabaseWrapper(BaseDatabaseWrapper):
|
| 390 | 391 | if settings_dict['NAME']: |
| 391 | 392 | kwargs['db'] = settings_dict['NAME'] |
| 392 | 393 | if settings_dict['PASSWORD']: |
| 393 | | kwargs['passwd'] = settings_dict['PASSWORD'] |
| | 394 | kwargs['passwd'] = force_str(settings_dict['PASSWORD']) |
| 394 | 395 | if settings_dict['HOST'].startswith('/'): |
| 395 | 396 | kwargs['unix_socket'] = settings_dict['HOST'] |
| 396 | 397 | elif settings_dict['HOST']: |
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index f6f534d..c8b88d5 100644
|
a
|
b
|
from django.db.backends.postgresql_psycopg2.client import DatabaseClient
|
| 13 | 13 | from django.db.backends.postgresql_psycopg2.creation import DatabaseCreation |
| 14 | 14 | from django.db.backends.postgresql_psycopg2.version import get_version |
| 15 | 15 | from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection |
| | 16 | from django.utils.encoding import force_str |
| 16 | 17 | from django.utils.log import getLogger |
| 17 | 18 | from django.utils.safestring import SafeText, SafeBytes |
| 18 | 19 | from django.utils import six |
| … |
… |
class DatabaseWrapper(BaseDatabaseWrapper):
|
| 172 | 173 | if settings_dict['USER']: |
| 173 | 174 | conn_params['user'] = settings_dict['USER'] |
| 174 | 175 | if settings_dict['PASSWORD']: |
| 175 | | conn_params['password'] = settings_dict['PASSWORD'] |
| | 176 | conn_params['password'] = force_str(settings_dict['PASSWORD']) |
| 176 | 177 | if settings_dict['HOST']: |
| 177 | 178 | conn_params['host'] = settings_dict['HOST'] |
| 178 | 179 | if settings_dict['PORT']: |
diff --git a/tests/regressiontests/backends/tests.py b/tests/regressiontests/backends/tests.py
index dc92189..70cf63c 100644
|
a
|
b
|
class BackendTestCase(TestCase):
|
| 401 | 401 | self.assertEqual(list(cursor.fetchmany(2)), [('Jane', 'Doe'), ('John', 'Doe')]) |
| 402 | 402 | self.assertEqual(list(cursor.fetchall()), [('Mary', 'Agnelline'), ('Peter', 'Parker')]) |
| 403 | 403 | |
| | 404 | def test_unicode_password(self): |
| | 405 | old_password = connection.settings_dict['PASSWORD'] |
| | 406 | connection.settings_dict['PASSWORD'] = "françois" |
| | 407 | try: |
| | 408 | cursor = connection.cursor() |
| | 409 | except backend.Database.DatabaseError: |
| | 410 | # As password is probably wrong, an exception is expected |
| | 411 | pass |
| | 412 | except Exception as e: |
| | 413 | self.fail("Unexpected error raised with unicode password: %s" % e) |
| | 414 | finally: |
| | 415 | connection.settings_dict['PASSWORD'] = old_password |
| | 416 | |
| 404 | 417 | def test_database_operations_helper_class(self): |
| 405 | 418 | # Ticket #13630 |
| 406 | 419 | self.assertTrue(hasattr(connection, 'ops')) |