diff Lib/idlelib/PyShell.py @ 72173:fe7777f1ed14 3.2

Issue #12636: IDLE reads the coding cookie when executing a Python script.
author Victor Stinner <victor.stinner@haypocalc.com>
date Fri, 02 Sep 2011 01:00:40 +0200
parents d1d2dfbca812
children e74860883a9c
line wrap: on
line diff
--- a/Lib/idlelib/PyShell.py	Fri Sep 02 00:57:04 2011 +0200
+++ b/Lib/idlelib/PyShell.py	Fri Sep 02 01:00:40 2011 +0200
@@ -1,16 +1,17 @@
 #! /usr/bin/env python3
 
+import getopt
 import os
 import os.path
-import sys
-import getopt
 import re
 import socket
+import subprocess
+import sys
+import threading
 import time
-import threading
+import tokenize
 import traceback
 import types
-import subprocess
 
 import linecache
 from code import InteractiveInterpreter
@@ -572,7 +573,7 @@
     def execfile(self, filename, source=None):
         "Execute an existing file"
         if source is None:
-            with open(filename, "r") as fp:
+            with tokenize.open(filename) as fp:
                 source = fp.read()
         try:
             code = compile(source, filename, "exec")