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

@property outside of class definition causes NRE #1335

Closed
CTrando opened this issue Jul 15, 2019 · 3 comments · Fixed by #1416
Closed

@property outside of class definition causes NRE #1335

CTrando opened this issue Jul 15, 2019 · 3 comments · Fixed by #1416
Assignees
Labels
bug Something isn't working good first issue Good for newcomers
Milestone

Comments

@CTrando
Copy link
Contributor

CTrando commented Jul 15, 2019

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.

@CTrando CTrando added bug Something isn't working good first issue Good for newcomers labels Jul 15, 2019
@CTrando CTrando self-assigned this Jul 15, 2019
@jakebailey
Copy link
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.

@jakebailey
Copy link
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.

@MikhailArkhipov
Copy link

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants