[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-17 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-17 Thread hai shi
hai shi added the comment: > Now, I wonder if we should also introduce PyType_GetModuleName for > __module__, or stop and close this as fixed. IMO, I suggest to close this bpo. We can get the `tp_name` by the C API now. If there have user want get `__module__`, we can open a new bpo to

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-17 Thread Petr Viktorin
Petr Viktorin added the comment: Now, I wonder if we should also introduce PyType_GetModuleName for __module__, or stop and close this as fixed. -- ___ Python tracker ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-17 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset fcd651d16fc5ac3d07dd3f57f1001a861a2e7d23 by Hai Shi in branch 'main': bpo-42035: Enhance test_get_type_name() of _testcapi (GH-27649) https://github.com/python/cpython/commit/fcd651d16fc5ac3d07dd3f57f1001a861a2e7d23 --

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-17 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset 3e2c643ae0b21f9e596bfd9c8ec99ca546ea8d0f by Hai Shi in branch 'main': bpo-42035: Add PyType_GetQualName() to get a type's qualified name. (GH-27551) https://github.com/python/cpython/commit/3e2c643ae0b21f9e596bfd9c8ec99ca546ea8d0f --

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-09 Thread STINNER Victor
STINNER Victor added the comment: PyType_GetName() is a nice addition, thanks. -- ___ Python tracker ___ ___ Python-bugs-list

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-06 Thread hai shi
Change by hai shi : -- pull_requests: +26143 pull_request: https://github.com/python/cpython/pull/27649 ___ Python tracker ___ ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-02 Thread hai shi
hai shi added the comment: > - for the qualified name you can use `PyObject_GetAttrString(t, > "__qualname__")` After PR-27551 merged, we can use PyType_GetQualName() to get type's `__qualname__`. -- ___ Python tracker

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-08-02 Thread hai shi
Change by hai shi : -- pull_requests: +26057 pull_request: https://github.com/python/cpython/pull/27551 ___ Python tracker ___ ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-07-29 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset a390ebea17a96d1c93fc5f75b1e19916090a4561 by Hai Shi in branch 'main': bpo-42035: Add a PyType_GetName() to get type's short name. (GH-23903) https://github.com/python/cpython/commit/a390ebea17a96d1c93fc5f75b1e19916090a4561 --

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-07-29 Thread Petr Viktorin
Petr Viktorin added the comment: > Can we create PyType_GetDataSlot function to return the data pointer? No, see the borrowed pointer issues above. > I will create another PR after PR-23903 merged. Great, thank you! -- ___ Python tracker

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-07-27 Thread hai shi
hai shi added the comment: > - there is still no way to get t.tp_name Can we create PyType_GetDataSlot function to return the data pointer? > If we go this way, why not add PyType_GetQualName as well? +1. I will create another PR after PR-23903 merged. --

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-07-27 Thread Petr Viktorin
Petr Viktorin added the comment: Sorry for the delay; getting 652 into Python 3.10 took up most of my time. So, in the current proposal: - `PyType_GetName(t)` is equivalent to `PyObject_GetAttrString(t, "__name__")` - for the qualified name you can use `PyObject_GetAttrString(t,

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-02-01 Thread hai shi
hai shi added the comment: I found `type.__name__` has the implementation details in https://github.com/python/cpython/blob/master/Objects/typeobject.c#L486. IMHO, keep the consistency in `PyType_GetName()` is OK. Victor, Petr. Do you think it make senses? --

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-01-21 Thread hai shi
hai shi added the comment: Wait. petr mentioned `_PyType_Name` in PR 23903 which use the short name. So I am not sure which way is better. Lol~ -- ___ Python tracker ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-01-20 Thread hai shi
hai shi added the comment: > New C API functions must not return borrowed references, but strong > references. Thanks petr, victor for your suggestion. It's more friendly to users. > Which one should be returned by PyType_GetName()? Is there a warranty that > it's always short or always

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-01-19 Thread STINNER Victor
STINNER Victor added the comment: A type has different names: * short name: "name" * qualified name: "module.name" Which one should be returned by PyType_GetName()? Is there a warranty that it's always short or always qualified? -- ___ Python

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-01-19 Thread STINNER Victor
STINNER Victor added the comment: New C API functions must not return borrowed references, but strong references. -- ___ Python tracker ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-01-19 Thread Petr Viktorin
Petr Viktorin added the comment: Now that I see the implementation (and now that I'm spending a lot of time trying to formalize what is good stable API), I see a problem with PyType_GetName: it effectively returns a borrowed reference. The proposed docs say: Callers can hold [the

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2021-01-07 Thread STINNER Victor
Change by STINNER Victor : -- nosy: +vstinner ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-12-22 Thread hai shi
Change by hai shi : -- keywords: +patch pull_requests: +22757 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23903 ___ Python tracker ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-12-15 Thread Petr Viktorin
Petr Viktorin added the comment: I'll be happy to review adding a PyType_GetName function. -- ___ Python tracker ___ ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-11-03 Thread hai shi
Change by hai shi : -- nosy: +shihai1991 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-23 Thread Petr Viktorin
Petr Viktorin added the comment: Yes, for some cases the ship has sailed. I don't think we can add unions now -- the stable ABI needs to be stable. -- ___ Python tracker ___

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-22 Thread fancitron
fancitron added the comment: True enough. Btw, PyType_FromSpec accepts Py_tp_doc (char *), Py_tp_base (PyTypeObject *), etc ... so to be strictly standard compliant, a union would be necessary. PyType_GetName() sounds great. One "proper" workaround at the moment is

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Ah, scratch that: PyType_GetSlot returns a function pointer. To be correct, we should to expose a new function like PyType_GetName. It's true that CPython currently doesn't always honor the distinction between data and function pointers, but the C standard

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: The slots are originally intended for defining types (PyType_FromSpec); PyType_GetSlot is not as useful as it could be. tp_name can be exposed, but it needs to also be handled properly PyType_FromSpec -- e.g. raise an error. --

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-14 Thread STINNER Victor
Change by STINNER Victor : -- nosy: +corona10, petr.viktorin title: PyType_GetSlot cannot get tp_name -> [C API] PyType_GetSlot cannot get tp_name ___ Python tracker ___