This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2009-03-20.01:54:02
SpamBayes Score 5.8369976e-13
Marked as misclassified No
Message-id <>
In "What’s New In Python 3.0" document, I can read "Removed 
execfile(). Instead of execfile(fn) use exec(open(fn).read())". The 
new syntax has two problems:
 - if the file is not encoding in UTF-8, we get an unicode error. Eg. 
see issue #4282
 - exec() doesn't support newline different than \n, see issue #4628

We need a short function which opens the Python file with the right 
encoding. Get Python file encoding and open it with the right encoding 
is a command pattern.

Attached patch proposes a function open_script() to open a Python 
script with the correct encoding. Using it, execfile() can be replaced 
by exec(open_script(fn).read()) which doesn't have to two binary file 
Date User Action Args
2009-03-20 01:54:05vstinnersetrecipients: + vstinner
2009-03-20 01:54:04vstinnersetmessageid: <>
2009-03-20 01:54:03vstinnerlinkissue5524 messages
2009-03-20 01:54:03vstinnercreate