Skip to content

bpo-46730: Fix refleak and tighten NULL checks #31389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2022

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