Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#4382 closed change (fixed)

Use new syntax to catch Python exceptions

Reported by: sebastian Assignee: sebastian
Priority: P3 Milestone:
Module: Sitescripts Keywords:
Cc: Blocked By:
Blocking: #4376 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

https://codereview.adblockplus.org/29350318/
https://codereview.adblockplus.org/29350329/
https://codereview.adblockplus.org/29350338/

Description

Background

Our legacy code (which still isn't compatible with Python 3) often catches exceptions like:

try:
    ...
except Exception, e:
    ...

Historically, this has been the only valid syntax. With Python 2.6, a new syntax has been introduced:

try:
    ...
except Exception as e:
    ...

Besides being more readable, this is the only syntax supported in Python 3. It's possible to automatically convert those statements using 2to3. Doing so is safe because we don't support any version older than Python 2.7, where both syntax results into the same bytecode.

What to change

Process all code in sitescripts, cms and buildtools with 2to3 --fix=except --write.

Change History (7)

comment:1 Changed 3 years ago by sebastian

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:2 Changed 3 years ago by sebastian

  • Component changed from Unknown to Sitescripts

comment:3 Changed 3 years ago by abpbot

A commit referencing this issue has landed:
Issue 4382 - Use new syntax to catch exceptions

comment:4 Changed 3 years ago by abpbot

A commit referencing this issue has landed:
Issue 4382 - Use new syntax to catch exceptions

comment:5 Changed 3 years ago by abpbot

A commit referencing this issue has landed:
Issue 4382 - Use new syntax to catch exceptions

comment:6 Changed 3 years ago by sebastian

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:7 Changed 3 years ago by sebastian

  • Blocking 4376 added
Note: See TracTickets for help on using tickets.