Opened 6 years ago

Closed 5 years ago

#16065 closed enhancement (fixed)

Python 3 preparation: Handle removed exec statement

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: 67871a8 (Commits) Commit: 67871a8566fc34de2fc3762a7cf1fce19e316dd9
Dependencies: #16712 Stopgaps:

Description (last modified by aapitzsch)

In Py2 there is the exec statement, while in Py3 there is an exec() function.

The tool 2to3 changes the exec statement into the exec() function.
The tuple form of exec provides compatibility with Python 3, where exec is a function rather than a statement.

There are 6 effected modules.

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

Change History (13)

comment:1 Changed 6 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/16065
  • Commit set to b38818230b8eefa31bd202c1f145125c2c9bc5a4
  • Status changed from new to needs_review

New commits:

b388182use a python3 compatible syntax for exec statement

comment:3 Changed 5 years ago by chapoton

Hello, I have split up the first instance of exec, as this can be completely removed. Please have a look at #16712, and give it a positive review if you agree with it.

comment:4 Changed 5 years ago by aapitzsch

  • Dependencies set to #16712

comment:5 Changed 5 years ago by git

  • Commit changed from b38818230b8eefa31bd202c1f145125c2c9bc5a4 to 61544317f67f8271ba970221e447071ec9599161

Branch pushed to git repo; I updated commit sha1. New commits:

cca73cbtrac #16712 removed bad use of exec
8287bb2trac #16712 reviewer wish
6154431Merge branch '16712' into py3_exec_statement

comment:6 Changed 5 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:7 follow-up: Changed 5 years ago by chapoton

  • Branch changed from u/aapitzsch/ticket/16065 to public/ticket/16065
  • Commit changed from 61544317f67f8271ba970221e447071ec9599161 to 67871a8566fc34de2fc3762a7cf1fce19e316dd9

merged with 6.4.beta0


New commits:

67871a8Merge with 6.4.beta0

comment:8 in reply to: ↑ 7 Changed 5 years ago by aapitzsch

Frédéric, what's missing for a positive review?

comment:9 Changed 5 years ago by chapoton

I would give a positive review, but how can it be ok if exec() does not exists in python2 ?

"But the function is not supported by Py2." in the ticket description !

comment:10 Changed 5 years ago by aapitzsch

  • Description modified (diff)

See https://docs.python.org/2.7/reference/simple_stmts.html#exec

The first expression may also be a tuple of length 2 or 3. In this case, the optional parts must be omitted. The form exec(expr, globals) is equivalent to exec expr in globals, while the form exec(expr, globals, locals) is equivalent to exec expr in globals, locals. The tuple form of exec provides compatibility with Python 3, where exec is a function rather than a statement.

comment:11 Changed 5 years ago by chapoton

  • Status changed from needs_review to positive_review

ok, then.

comment:12 Changed 5 years ago by chapoton

  • Reviewers set to Frédéric Chapoton

comment:13 Changed 5 years ago by vbraun

  • Branch changed from public/ticket/16065 to 67871a8566fc34de2fc3762a7cf1fce19e316dd9
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.