Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

@property outside of class definition causes NRE #1335

Description

ex:

@property
def foo(self):
    return 123

causes an NRE because declaringType is null for functions outside of a class scope, and in the constructor for PythonPropertyType we do not check for null declaring type.

Activity

  1. jakebailey commented on Aug 7, 2019

    @jakebailey
    Member

    Doesn't even have to be outside of a class; scikit-learn's deprecation util library hits this:

    class deprecation:
        def _decorate_property(self, prop):
            msg = self.extra
    
            @property
            def wrapped(*args, **kwargs):
                warnings.warn(msg, category=DeprecationWarning)
                return prop.fget(*args, **kwargs)
    
            return wrapped

    declaringType is null.

  2. jakebailey commented on Aug 7, 2019

    @jakebailey
    Member

    I'm not entirely sure how properties work now, but we may need to stop attaching them to any one type, and just let their existence as a member of something else be enough to distinguish them.

  3. MikhailArkhipov commented on Aug 7, 2019

    @MikhailArkhipov

    We can either not create the odd property or make it a standalone function if there is no declared type. I guess problem is that it gets member type of property or method and that implies declaring type.

    Generally we don't handle classes or inner functions inside other functions very well in master atm. I fixed a number of this cases in persistence branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions