Ticket #5519 enhancement new

Opened 2 years ago

Last modified 21 months ago

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

failure.patch Download (0.9 KB) - added by vperic 21 months ago.

Change History

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.

2

Changed 23 months 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 21 months ago by vperic

3

Changed 21 months 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.