diff options
author | Mads Jensen <mje@inducks.org> | 2017-03-09 16:17:41 +0100 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-06-28 14:07:55 -0400 |
commit | 550cb3a365dee4edfdd1563224d5304de2a57fda (patch) | |
tree | fb532f38774ff7619edd2a4532c3daae1ee0ac5a /django/db/backends/postgresql/client.py | |
parent | 43a4835edf32c57eb74c0eb207c276734a34abcf (diff) | |
download | django-550cb3a365dee4edfdd1563224d5304de2a57fda.tar.gz |
Fixed #27818 -- Replaced try/except/pass with contextlib.suppress().
Diffstat (limited to 'django/db/backends/postgresql/client.py')
-rw-r--r-- | django/db/backends/postgresql/client.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/django/db/backends/postgresql/client.py b/django/db/backends/postgresql/client.py index 466c2986d2..8d08b0d5cf 100644 --- a/django/db/backends/postgresql/client.py +++ b/django/db/backends/postgresql/client.py @@ -1,6 +1,7 @@ import os import signal import subprocess +from contextlib import suppress from django.core.files.temp import NamedTemporaryFile from django.db.backends.base.client import BaseDatabaseClient @@ -40,7 +41,9 @@ class DatabaseClient(BaseDatabaseClient): if passwd: # Create temporary .pgpass file. temp_pgpass = NamedTemporaryFile(mode='w+') - try: + # If the current locale can't encode the data, let the user + # input the password manually. + with suppress(UnicodeEncodeError): print( _escape_pgpass(host) or '*', str(port) or '*', @@ -52,10 +55,6 @@ class DatabaseClient(BaseDatabaseClient): flush=True, ) os.environ['PGPASSFILE'] = temp_pgpass.name - except UnicodeEncodeError: - # If the current locale can't encode the data, we let - # the user input the password manually. - pass # Allow SIGINT to pass to psql to abort queries. signal.signal(signal.SIGINT, signal.SIG_IGN) subprocess.check_call(args) |