Opened 6 years ago

Closed 6 years ago

#15982 closed enhancement (fixed)

Python 3 preparation: Change the syntax of the except clause

Reported by: wluebbe Owned by:
Priority: major Milestone: sage-6.2
Component: distribution Keywords: python3
Cc: Merged in:
Authors: Wilfried Luebbe Reviewers: Travis Scrimshaw
Report Upstream: N/A Work issues:
Branch: a16afe1 (Commits) Commit: a16afe1ac28960a45fa6814239cbe91b96039b81
Dependencies: Stopgaps:

Description

Only the modern syntax of the except clause (in the try-except statement) is accepted by Python 3.

Changes according to lib2to3/fixes/fix_except.py:

- "except E, T:" where T is a name:

    except E as T:

- "except E, T:" where T is not a name, tuple or list:

        except E as t:
            T = t

    This is done because the target of an "except" clause must be a
    name.

- "except E, T:" where T is a tuple or list literal:

        except E as t:
            T = t.args

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

Change History (3)

comment:1 Changed 6 years ago by wluebbe

  • Branch set to u/wluebbe/ticket/15982
  • Commit set to a16afe1ac28960a45fa6814239cbe91b96039b81
  • Status changed from new to needs_review

Changed for .py modules by 2to3 tool and for .pyx modules manually.

./sage -t -p --all --long --logfile=logs/ptestlong-15982-b.log
...
All tests passed!

New commits:

3f94b5fchange "except Exc,e" to "except Exc as e" with 2to3 tool
a16afe1change "except Exc,e" to "except Exc as e" in .pyx modules

comment:2 Changed 6 years ago by tscrim

  • Authors set to Wilfried Luebbe
  • Reviewers set to Travis Scrimshaw
  • Status changed from needs_review to positive_review

Looks good to me.

comment:3 Changed 6 years ago by vbraun

  • Branch changed from u/wluebbe/ticket/15982 to a16afe1ac28960a45fa6814239cbe91b96039b81
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.