From 4e7f04cdad2eb1ec39ea2e3769657da082a6494f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anssi=20K=C3=A4=C3=A4ri=C3=A4inen?= Date: Tue, 14 Aug 2012 16:05:53 +0300 Subject: [PATCH] [py3] Fixed file.read().decode(), used codecs.open() instead --- django/core/management/sql.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/django/core/management/sql.py b/django/core/management/sql.py index 7579cbe8ab..b02a548314 100644 --- a/django/core/management/sql.py +++ b/django/core/management/sql.py @@ -1,5 +1,6 @@ from __future__ import unicode_literals +import codecs import os import re @@ -168,10 +169,10 @@ def custom_sql_for_model(model, style, connection): os.path.join(app_dir, "%s.sql" % opts.object_name.lower())] for sql_file in sql_files: if os.path.exists(sql_file): - with open(sql_file, 'U') as fp: + with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp: # Some backends can't execute more than one SQL statement at a time, # so split into separate statements. - output.extend(_split_statements(fp.read().decode(settings.FILE_CHARSET))) + output.extend(_split_statements(fp.read())) return output