Opened 5 years ago

Closed 5 years ago

#16066 closed enhancement (fixed)

Python 3 preparation: Handle removed execfile() function

Reported by: wluebbe 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) Commit: 4d248826f13c25a939382900293b601665a69083
Dependencies: Stopgaps:

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 5 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:2 Changed 5 years ago by aapitzsch

  • Authors set to André Apitzsch
  • Branch set to u/aapitzsch/ticket/16066
  • Commit set to 4d248826f13c25a939382900293b601665a69083
  • Status changed from new to needs_review

New commits:

4d24882replace execfile by python3 compatible functions

comment:3 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:4 Changed 5 years ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

ok, looks good to me.

comment:5 Changed 5 years ago by vbraun

  • Branch changed from u/aapitzsch/ticket/16066 to 4d248826f13c25a939382900293b601665a69083
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.