Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[py3] Fixed file.read().decode(), used codecs.open() instead

  • Loading branch information...
commit 4e7f04cdad2eb1ec39ea2e3769657da082a6494f 1 parent 62a9ed0
Anssi Kääriäinen authored August 14, 2012

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  django/core/management/sql.py
5  django/core/management/sql.py
... ...
@@ -1,5 +1,6 @@
1 1
 from __future__ import unicode_literals
2 2
 
  3
+import codecs
3 4
 import os
4 5
 import re
5 6
 
@@ -168,10 +169,10 @@ def custom_sql_for_model(model, style, connection):
168 169
                  os.path.join(app_dir, "%s.sql" % opts.object_name.lower())]
169 170
     for sql_file in sql_files:
170 171
         if os.path.exists(sql_file):
171  
-            with open(sql_file, 'U') as fp:
  172
+            with codecs.open(sql_file, 'U', encoding=settings.FILE_CHARSET) as fp:
172 173
                 # Some backends can't execute more than one SQL statement at a time,
173 174
                 # so split into separate statements.
174  
-                output.extend(_split_statements(fp.read().decode(settings.FILE_CHARSET)))
  175
+                output.extend(_split_statements(fp.read()))
175 176
     return output
176 177
 
177 178
 

0 notes on commit 4e7f04c

Please sign in to comment.
Something went wrong with that request. Please try again.