GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||
GeezerVison is showing github.com — bpo-42035: Add a PyType_GetQualName() to get type's qualified name. by shihai1991 · Pull Request #27551 · python/cpython Conversation
|
|
@encukou Hi, Petr. Would you mind to take a look :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| if (PyObject_SetAttrString(HeapTypeNameType, | ||
| "__qualname__", spec_name) < 0) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting test.
Would it make sense to test the original qualname first, then assign a different one and test that PyType_GetQualName returns the replacement?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Haha. I try to get some qual names in _testcapimodule. But I can get the qual name with prefix.
The reason is res->ht_qualname = res->ht_name; in https://github.com/python/cpython/blob/main/Objects/typeobject.c#L3439.
I don't know the reason why the qual name need to reomve the prefix too.
So I set a qual name with prefix to test this C API, somthing like a mock behavior~
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Right, C-API classes don't have distinct qualnames.
IMO, the best thing to do here would be:
Ideally, the same thing would be tested for PyType_GetName as well – it's not that different from this function.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Right, C-API classes don't have distinct qualnames.
IMO, the best thing to do here would be:
- Test the original qualname (same as the short name)
- Change the qualname
- Then test the new qualname.
Make sense. How about this updated PR :)
Ideally, the same thing would be tested for
PyType_GetNameas well – it's not that different from this function.
Got it. I will update enhance this test case later.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks good, thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thanks a million, petr :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.