Opened 9 years ago

Closed 8 years ago

## #16065 closed enhancement (fixed)

# Python 3 preparation: Handle removed exec statement

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: | 67871a8 (Commits, GitHub, GitLab) | Commit: | 67871a8566fc34de2fc3762a7cf1fce19e316dd9 |

Dependencies: | #16712 | Stopgaps: |

### Description (last modified by )

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 9 years ago by

Milestone: | sage-6.2 → sage-6.3 |
---|

### comment:2 Changed 8 years ago by

Authors: | → André Apitzsch |
---|---|

Branch: | → u/aapitzsch/ticket/16065 |

Commit: | → b38818230b8eefa31bd202c1f145125c2c9bc5a4 |

Status: | new → needs_review |

### comment:3 Changed 8 years ago by

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 8 years ago by

Dependencies: | → #16712 |
---|

### comment:5 Changed 8 years ago by

Commit: | b38818230b8eefa31bd202c1f145125c2c9bc5a4 → 61544317f67f8271ba970221e447071ec9599161 |
---|

### comment:6 Changed 8 years ago by

Milestone: | sage-6.3 → sage-6.4 |
---|

### comment:7 follow-up: 8 Changed 8 years ago by

Branch: | u/aapitzsch/ticket/16065 → public/ticket/16065 |
---|---|

Commit: | 61544317f67f8271ba970221e447071ec9599161 → 67871a8566fc34de2fc3762a7cf1fce19e316dd9 |

### comment:9 Changed 8 years ago by

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 8 years ago by

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:12 Changed 8 years ago by

Reviewers: | → Frédéric Chapoton |
---|

### comment:13 Changed 8 years ago by

Branch: | public/ticket/16065 → 67871a8566fc34de2fc3762a7cf1fce19e316dd9 |
---|---|

Resolution: | → fixed |

Status: | positive_review → closed |

**Note:**See TracTickets for help on using tickets.

New commits:

`use a python3 compatible syntax for exec statement`