Skip to content

Conversation

@tiran
Copy link
Member

@tirantiran commented Feb 17, 2022

PyType_GetQualName returns a new reference.

Signed-off-by: Christian Heimes christian@python.org

https://bugs.python.org/issue46730

``PyType_GetQualName`` returns a new reference. Signed-off-by: Christian Heimes <christian@python.org>
@sweeneyde
Copy link
Member

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

@markshannonmarkshannon marked this pull request as ready for review February 17, 2022 16:41
@markshannonmarkshannon 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-botbedevere-bot removed the 🔨 test-with-buildbots Test PR w/ buildbots; report in status section label Feb 17, 2022
@tiran
Copy link
MemberAuthor

@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:

classM(type): def__getattribute__(self, name): raiseAttributeErrorclassA(metaclass=M): passobj=A() hasattr(type(obj), "__qualname__") # returns Falseproperty().__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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@tiran@sweeneyde@bedevere-bot@Alex-Blade@geryogam@JelleZijlstra@markshannon@the-knights-who-say-ni