Problem with abstract classes

Bug #1520397 reported by Davanum Srinivas (DIMS)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
debtcollector
Triaged
Medium
Unassigned

Bug Description

The following test:

    def test_remove_with_abstract_class_inheritance(self):
        @six.add_metaclass(abc.ABCMeta)
        class AbstractSerializer(object):
            pass

        @removals.remove(version="2.9", removal_version="3.0")
        class ConcreteSerializer(AbstractSerializer):
            pass

        class MyConcreteSerializer(ConcreteSerializer):
            pass

        MyConcreteSerializer()

Ends up with the following error in python 2.7:

Traceback (most recent call last):
  File "debtcollector/tests/test_deprecation.py", line 546, in test_remove_with_abstract_class_inheritance
    class MyConcreteSerializer(ConcreteSerializer):
  File "/Users/dims/openstack/oslo/debtcollector/.tox/py27/bin/../lib/python2.7/abc.py", line 87, in __new__
    cls = super(ABCMeta, mcls).__new__(mcls, name, bases, namespace)
TypeError: Error when calling the metaclass bases
    metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

And ends up with the following error in python 3.4:

Traceback (most recent call last):
  File "/Users/dims/openstack/oslo/debtcollector/debtcollector/tests/test_deprecation.py", line 549, in test_remove_with_abstract_class_inheritance
    MyConcreteSerializer()
TypeError: 'tuple' object is not callable

Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote :

Note that this showed up in a real life situation :) when we added deprecation to RequestContextSerializer in oslo.messaging and we will be breaking ironic:

https://s3.amazonaws.com/archive.travis-ci.org/jobs/93447606/log.txt
https://s3.amazonaws.com/archive.travis-ci.org/jobs/93447607/log.txt

Revision history for this message
Joshua Harlow (harlowja) wrote :
Revision history for this message
Matt Riedemann (mriedem) wrote :

This broke ironic, see bug 1524041.

Revision history for this message
Joshua Harlow (harlowja) wrote :

https://review.openstack.org/#/c/260117/ is an alternative for this weakness....

Julien Danjou (jdanjou)
Changed in debtcollector:
status: New → Triaged
importance: Undecided → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.