[issue5524] execfile() removed from Python3
Jeremy Hylton jer...@alum.mit.edu added the comment: It doesn't seem helpful to leave this issue open, particularly since the title suggest there's a problem with execfile being removed and that's not going to change. -- nosy: +jhylton status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5524] execfile() removed from Python3
STINNER Victor victor.stin...@haypocalc.com added the comment: Ok... but there is the newline issue: (self quote) exec() doesn't support newline different than \n, see issue #4628. So that issue should get fixed, then. Ok, I will work in the other other issue. If #4628 is fixed, this issue becomes meaningless ;-) -- dependencies: +No universal newline support for compile() when using bytes ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5524] execfile() removed from Python3
STINNER Victor victor.stin...@haypocalc.com added the comment: martin There is a much simpler solution to the problem: martin use exec(open(fn,rb).read()) Ok... but there is the newline issue: (self quote) exec() doesn't support newline different than \n, see issue #4628. And open_python() can be used for other usages than execfile() ;-) Note: tokenize.open_python() is maybe not the best module and/or function name. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5524] execfile() removed from Python3
Martin v. Löwis mar...@v.loewis.de added the comment: Ok... but there is the newline issue: (self quote) exec() doesn't support newline different than \n, see issue #4628. So that issue should get fixed, then. And open_python() can be used for other usages than execfile() ;-) Note: tokenize.open_python() is maybe not the best module and/or function name. I remain opposed to the entire concept. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5524] execfile() removed from Python3
New submission from STINNER Victor victor.stin...@haypocalc.com: 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 problems. -- files: open_script.patch keywords: patch messages: 83845 nosy: haypo severity: normal status: open title: execfile() removed from Python3 versions: Python 3.0, Python 3.1 Added file: http://bugs.python.org/file13380/open_script.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5524] execfile() removed from Python3
Martin v. Löwis mar...@v.loewis.de added the comment: -1. There is a much simpler solution to the problem: use exec(open(fn, rb).read()) -- nosy: +loewis ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com