[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-19 Thread STINNER Victor
STINNER Victor added the comment: I close this issue until we can agree on an API. -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-12 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +8682 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-11 Thread STINNER Victor
STINNER Victor added the comment: Petr Viktorin asked me to open a wider discussion about this issue on python-dev. I just reverted my first change and posted: https://mail.python.org/pipermail/python-dev/2018-September/155150.html -- ___ Python

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-11 Thread STINNER Victor
STINNER Victor added the comment: New changeset 998b80636690ffbdb0a278810d9c031fad38631d by Victor Stinner in branch 'master': Revert "bpo-34595: Add %T format to PyUnicode_FromFormatV() (GH-9080)" (GH-9187) https://github.com/python/cpython/commit/998b80636690ffbdb0a278810d9c031fad38631d

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-11 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +8625 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-11 Thread Petr Viktorin
Petr Viktorin added the comment: > The PEP 399 requires that C accelerator behaves exactly as Python, [...] It does not. PEP 399 requires that that the C code must pass the same *test suite*. And error messages in particular tend to not be checked in tests. Anyway, I don't see how that

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > in error messages And in reprs. It is common to format a repr as "{typename}(...)" or "<{typename}(...)>". The difference is whether the typename is a short or fully qualified name. -- ___ Python tracker

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: > Ok, I wrote PR 9122 to add %t format and modify %T format: Nice! I agree that it is easy to use _PyType_Name() directly. But using _PyType_FullName() instead of tp_name can be cumbersome because it returns a new object and needs error handling. > Or

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread STINNER Victor
STINNER Victor added the comment: > I think we need to handle only two cases: short and fully qualified names. > __qualname__ without __module__ doesn't make sense, and the value of tp_name > depends on implementation details (is it Python class or builtin class, heap > class or dynamic

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +8576 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I think we need to handle only two cases: short and fully qualified names. __qualname__ without __module__ doesn't make sense, and the value of tp_name depends on implementation details (is it Python class or builtin class, heap class or dynamic class?).

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-08 Thread STINNER Victor
STINNER Victor added the comment: An alternative would be to add multiple formatters. Example: * %Tn: type name, type.__name__, Py_TYPE(obj)->tp_name * %Tq: qualified name, type.__qualname__ * %Ts: short name, never contains "." * %Tf: fully qualified name, "module.qualified.name" What do

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-07 Thread STINNER Victor
STINNER Victor added the comment: > In some cases we have the type itself, not an instance. So it makes sense to > make %T an equivalent of arg->tp_name instead of Py_TYPE(arg)->tp_name. "arg->tp_name" is rare in the code base, whereas "Py_TYPE(arg)->tp_name" is a very common pattern. I'm

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-07 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: IIRC there is similar issue or a discussion on one of mailing lists. But the idea about adding this feature on Python side too was considered. It would be better to find this discussion before pushing this change. In some cases we have the type itself,

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-07 Thread STINNER Victor
Change by STINNER Victor : -- pull_requests: +8557 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-07 Thread STINNER Victor
STINNER Victor added the comment: New changeset 886483e2b9bbabf60ab769683269b873381dd5ee by Victor Stinner in branch 'master': bpo-34595: Add %T format to PyUnicode_FromFormatV() (GH-9080) https://github.com/python/cpython/commit/886483e2b9bbabf60ab769683269b873381dd5ee --

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-06 Thread Eric V. Smith
Eric V. Smith added the comment: I don't think you have to worry about %T being used by other formatting functions. If (heaven forbid) dates were ever supported by PyUnicode_FromFormat(), there would have to be a way to switch from "normal" argument processing to argument-specific

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-06 Thread STINNER Victor
STINNER Victor added the comment: Oh, PyUnicode_FromFormat() has %A to format as ASCII, whereas printf() already has %A but for a different meaning: a, A For a conversion, the double argument is converted to hexadecimal notation (using the letters abcdef) in the style [-]0xh.p+-;

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-06 Thread STINNER Victor
STINNER Victor added the comment: I cannot find %T in printf() manual pages on Fedora 28 (Linux). I can find it in the strftime() documentation: %T The time in 24-hour notation (%H:%M:%S). (SU) But I don't think that it's an issue since printf() and strftime() formatters are

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-06 Thread STINNER Victor
STINNER Victor added the comment: My previous attempt to fix that issue, 7 years ago: bpo-10833 :-) See also bpo-7330 where I implemented width and precision (ex: "%5.3s") in PyUnicode_FromFormat(). -- ___ Python tracker

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-06 Thread STINNER Victor
Change by STINNER Victor : -- keywords: +patch pull_requests: +8539 stage: -> patch review ___ Python tracker ___ ___

[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-06 Thread STINNER Victor
New submission from STINNER Victor : The PEP 399 requires that C accelerator behaves exactly as Python, but a lot of C code truncates type name to an arbitrary length: 80, 100, 200, up to 500 (not sure if it's a number of bytes or characters). Py_TYPE(obj)->tp_name is a common pattern: it