Opened 9 years ago

Closed 8 years ago

#16066 closed enhancement (fixed)

Python 3 preparation: Handle removed execfile() function

Reported by: Wilfried Luebbe Owned by:
Priority: major Milestone: sage-6.4
Component: distribution Keywords: python3
Cc: Merged in:
Authors: André Apitzsch Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 4d24882 (Commits, GitHub, GitLab) Commit: 4d248826f13c25a939382900293b601665a69083
Dependencies: Stopgaps:

Status badges

Description

In Py2 there is the execfile() function, while in Py3 there is none.

The tool 2to3 changes the calls to execfile() to wrapped calls of the builtin open(), compile and exec() functions. An example of a change lib2to3/fixes/fix_execfile.py is

-        execfile(fpath, globals)
+        exec(compile(open(fpath).read(), fpath, 'exec'), globals)

There are 2 occurences of execfile() in sage/misc/preparser.py.
The code has to depend on the Python version!

This ticket is tracked as a dependency of meta-ticket ticket:16052.

Change History (5)

comment:1 Changed 9 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:2 Changed 8 years ago by aapitzsch

Authors: André Apitzsch
Branch: u/aapitzsch/ticket/16066
Commit: 4d248826f13c25a939382900293b601665a69083
Status: newneeds_review

New commits:

4d24882replace execfile by python3 compatible functions

comment:3 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4

comment:4 Changed 8 years ago by Frédéric Chapoton

Reviewers: Frédéric Chapoton
Status: needs_reviewpositive_review

ok, looks good to me.

comment:5 Changed 8 years ago by Volker Braun

Branch: u/aapitzsch/ticket/160664d248826f13c25a939382900293b601665a69083
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.