Skip to content

Conversation

@tiran
Copy link
Member

@tiran tiran commented Feb 17, 2022

PyType_GetQualName returns a new reference.

Signed-off-by: Christian Heimes [email protected]

https://bugs.python.org/issue46730

``PyType_GetQualName`` returns a new reference.

Signed-off-by: Christian Heimes <[email protected]>
@sweeneyde
Copy link
Member

I'll try to be more cautious about ref-leaks in the future. Thanks for catching this!

@markshannon markshannon marked this pull request as ready for review February 17, 2022 16:41
@markshannon markshannon added the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 17, 2022
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @markshannon for commit a22802e 🤖

If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 17, 2022
@tiran
Copy link
Member Author

tiran commented Feb 17, 2022

@sweeneyde The buildbots have not finished verifying this PR yet. Next time please wait until all buildbots are successful.

@sweeneyde
Copy link
Member

Ah, my apologies, I was just looking at the refleak bots. I will wait next time. Thank you for the help!

@Alex-Blade
Copy link
Contributor

Oh, apologies, should have checked that

@geryogam
Copy link
Contributor

@tiran In which case could you have the last error message "AttributeError: property has no getter" that you introduced in the else clause? In other words, when does PyType_GetQualName(Py_TYPE(obj)) return NULL in C?

I can’t get that error message by making hasattr(type(obj), "__qualname__") return False in Python:

class M(type):
    def __getattribute__(self, name): raise AttributeError

class A(metaclass=M): pass

obj = A()
hasattr(type(obj), "__qualname__") # returns False
property().__get__(obj)  # raises AttributeError: property of 'A' object has no getter

It seems that property().__get__(obj) uses vars(type)["__qualname__"].__get__(type(obj)) (which returns 'A') and not type(obj).__qualname__ (which raises AttributeError) to get the __qualname__ attribute of type(obj).

So is your else clause dead code?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants