Skip to content

Can't inherit from a proxied class #80

@benrg

Description

@benrg

In 1.10.0, this fails with a TypeError:

import lazy_object_proxy

@lazy_object_proxy.Proxy
def Base():
    class Base: pass
    return Base

class Derived(Base): pass

The problem is that class takes type(Base) to be Derived's metaclass, and calls it with three arguments, but Proxy.__init__ expects only one.

Adding three metaclass methods to Proxy appears to fix the problem:

class FixedProxy(lazy_object_proxy.Proxy):
    def __mro_entries__(self, bases):
        return (self.__wrapped__,)

    def __subclasscheck__(self, subclass):
        return issubclass(subclass, self.__wrapped__)

    def __instancecheck__(self, instance):
        return isinstance(instance, self.__wrapped__)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy