Issue 16965: 2to3 should rewrite execfile() to open in 'rb' mode (original) (raw)

Issue16965

Created on 2013-01-14 18:24 by barry, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 8569 merged ZackerySpytz,2018-07-30 18:23
PR 9838 merged miss-islington,2018-10-13 09:27
PR 9839 merged miss-islington,2018-10-13 09:27
PR 9890 merged ZackerySpytz,2018-10-15 11:25
Messages (7)
msg179964 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2013-01-14 18:24
In this distribute bug I describe a problem when pip installing mimeparse, which has a setup.py with a BOM. distribute uses execfile() which gets fixed in Python 3 to use a combination of compile(open()) as the fixer. https://bitbucket.org/tarek/distribute/issue/349/dont-rely-on-2to3-to-properly-rewrite I think the problem is that the fixer opens the file in text mode, which leaves the BOM as a bogus first character, causing the SyntaxError. Instead, if the fixer opened the file in binary mode, then the BOM would be handled correctly by compile().
msg223226 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-16 15:52
Can we have a response to this please.
msg327567 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-12 07:18
`exec(compile(open("fn", "rb").read(), "fn", 'exec'))` will emit a resource warning because the open file is not closed explicitly. But this is a different issue.
msg327645 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-13 09:27
New changeset d4d60134b29290049e28df54f23493de4f1824b6 by Serhiy Storchaka (Zackery Spytz) in branch 'master': bpo-16965: 2to3 now rewrites execfile() to open with 'rb'. (GH-8569) https://github.com/python/cpython/commit/d4d60134b29290049e28df54f23493de4f1824b6
msg327646 - (view) Author: miss-islington (miss-islington) Date: 2018-10-13 09:48
New changeset 22381394ad1541db0b652eed802601f62510d22f by Miss Islington (bot) in branch '3.7': bpo-16965: 2to3 now rewrites execfile() to open with 'rb'. (GH-8569) https://github.com/python/cpython/commit/22381394ad1541db0b652eed802601f62510d22f
msg327647 - (view) Author: miss-islington (miss-islington) Date: 2018-10-13 09:51
New changeset 950fa40eee483f7507cd825b574a018b957dd253 by Miss Islington (bot) in branch '3.6': bpo-16965: 2to3 now rewrites execfile() to open with 'rb'. (GH-8569) https://github.com/python/cpython/commit/950fa40eee483f7507cd825b574a018b957dd253
msg327809 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-10-16 05:46
New changeset f5e00f490ab5abfcf5e38e58bf969c7b5dcb4818 by Serhiy Storchaka (Zackery Spytz) in branch '2.7': [2.7] bpo-16965: 2to3 now rewrites execfile() to open with rb. (GH-8569) (GH-9890) https://github.com/python/cpython/commit/f5e00f490ab5abfcf5e38e58bf969c7b5dcb4818
History
Date User Action Args
2022-04-11 14:57:40 admin set github: 61169
2018-10-16 05:47:18 serhiy.storchaka set status: open -> closedresolution: fixedstage: patch review -> resolved
2018-10-16 05:46:40 serhiy.storchaka set messages: +
2018-10-15 11:25:37 ZackerySpytz set pull_requests: + <pull%5Frequest9253>
2018-10-13 09:51:39 miss-islington set messages: +
2018-10-13 09:48:22 miss-islington set nosy: + miss-islingtonmessages: +
2018-10-13 09:27:50 miss-islington set pull_requests: + <pull%5Frequest9213>
2018-10-13 09:27:43 miss-islington set pull_requests: + <pull%5Frequest9212>
2018-10-13 09:27:35 serhiy.storchaka set messages: +
2018-10-12 07🔞26 serhiy.storchaka set nosy: + serhiy.storchakamessages: +
2018-07-31 05:24:32 BreamoreBoy set nosy: - BreamoreBoy
2018-07-30 18:24:15 ZackerySpytz set nosy: + ZackerySpytzversions: + Python 3.8, - Python 3.4, Python 3.5
2018-07-30 18:23:35 ZackerySpytz set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest8081>
2014-07-16 15:52:13 BreamoreBoy set versions: + Python 3.5, - Python 3.2, Python 3.3nosy: + BreamoreBoy, benjamin.petersonmessages: + type: behavior
2013-01-18 19:27:03 tshepang set nosy: + tshepang
2013-01-14 18:24:06 barry create