7c2f06f8541c — Jimmy Laguna Montano 4 years ago
newmigration.py edited online with Bitbucket. Update for windows users
1 files changed, 4 insertions(+), 2 deletions(-)

M yoyo/scripts/newmigration.py
M yoyo/scripts/newmigration.py +4 -2
@@ 154,12 154,14 @@ def make_filename(config, directory, mes
 
 def create_with_editor(config, directory, migration_source):
     editor = utils.get_editor(config)
-    tmpfile = NamedTemporaryFile(dir=directory,
+    tmpfile = NamedTemporaryFile(mode='w',
+                                 dir=directory,
                                  prefix=tempfile_prefix,
                                  suffix='.py',
+                                 encoding='UTF-8',
                                  delete=False)
     try:
-        with io.open(tmpfile.name, 'w', encoding='UTF-8') as f:
+        with tmpfile as f:
             f.write(migration_source)
 
         editor = [part.format(tmpfile.name) for part in shlex.split(editor)]