Opened 3 years ago

Last modified 2 years ago

#5519 enhancement new

Failure should become a new style class

Reported by: fijal Owned by:
Priority: normal Milestone: Python-3.x
Component: core Keywords: py3k
Cc: Branch:
Author: Launchpad Bug:

Description

According to glyph and exarkun, there is never ever a good reason to subclass a Failure, so it should not be a backwards incompatible change to make Failure a new style class.

Also, we can prohibit subclassing it in the first place *and* it makes pypy slightly faster.

Attachments (1)

failure.patch (882 bytes) - added by vperic 2 years ago.

Download all attachments as: .zip

Change History (4)

comment:1 Changed 2 years ago by exarkun

Some things to watch out for:

  1. The implementation of Failure.trap means Failure cannot just be an object subclass (you cannot raise arbitrary new-style instances, only classic instances and BaseException instances). Subclassing BaseException (or Exception) might be appropriate.
  2. Once Failure is an Exception of some sort, the tests for failure debug mode (TestDebugMode.setUp) need to change. It's not possible to assign to the __dict__ of an Exception subclass.
  3. CopyableFailure breaks and will need some adjustment.

comment:2 Changed 2 years ago by vperic

  • Keywords py3k added
  • Milestone set to Python-3.x

This is also relevant for Python 3 support, as old-style classes are no longer supported.

Changed 2 years ago by vperic

comment:3 Changed 2 years ago by vperic

Right, so the attached patch changes Failure to inherit from BaseException and fixes the __dict__ issue with setattr and all of test_failure passes. The problem is in test_pbfailure, which just hangs... I've traced the hang to two tests, test_asynchronousException and test_asynchronousError but that's as far as I got... Not even sure what CopyableFailure is (yet!).

Note: See TracTickets for help on using tickets.