Opened on 08/30/2016 at 01:27:01 PM

Closed on 08/31/2016 at 08:47:17 AM

Last modified on 09/09/2016 at 02:44:17 PM

#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.

Attachments (0)

Change History (7)

comment:1 Changed on 08/30/2016 at 01:33:55 PM by sebastian

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

comment:2 Changed on 08/30/2016 at 01:35:50 PM by sebastian

  • Component changed from Unknown to Sitescripts

comment:3 Changed on 08/30/2016 at 02:25:31 PM by abpbot

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

comment:4 Changed on 08/30/2016 at 02:27:07 PM by abpbot

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

comment:5 Changed on 08/31/2016 at 08:44:49 AM by abpbot

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

comment:6 Changed on 08/31/2016 at 08:47:17 AM by sebastian

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

comment:7 Changed on 09/09/2016 at 02:44:17 PM by sebastian

  • Blocking 4376 added

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from sebastian.
 
Note: See TracTickets for help on using tickets.