◐ Shell
reader mode source ↗
Skip to content

DO-NOT-MERGE: bpo-34595: Add %t format to PyUnicode_FromFormatV()#9122

Closed
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:unicode_format_t
Closed

DO-NOT-MERGE: bpo-34595: Add %t format to PyUnicode_FromFormatV()#9122
vstinner wants to merge 1 commit into
python:masterfrom
vstinner:unicode_format_t

Conversation

@vstinner

@vstinner vstinner commented Sep 9, 2018

Copy link
Copy Markdown
Member
  • The %T format of PyUnicode_FromFormatV() now returns the fully
    qualified name of an object type (ex: "module.namespace.typename").
  • Add %t format to PyUnicode_FromFormatV(), and so to
    PyUnicode_FromFormat() and PyErr_Format(), to format the "short
    name" of an object type: equivalent to "%s" with
    _PyType_Name(Py_TYPE(obj)).
  • Replace %T format with %t format in unicodeobject.c.

https://bugs.python.org/issue34595

* The %T format of PyUnicode_FromFormatV() now returns the fully
  qualified name of an object type (ex: "module.namespace.typename").
* Add %t format to PyUnicode_FromFormatV(), and so to
  PyUnicode_FromFormat() and PyErr_Format(), to format the "short
  name" of an object type: equivalent to "%s" with
  _PyType_Name(Py_TYPE(obj)).
* Replace %T format with %t format in unicodeobject.c.
* Update existing NEWS entry
@vstinner

Copy link
Copy Markdown
Member Author

I rebased my changed and made requested changes.

@vstinner

Copy link
Copy Markdown
Member Author

I propose to replace Py_TYPE(obj)->tp_name with %t in C to mimick Python code which uses type(obj).name or obj.class.name.

If we want to use %T in C code, I suggest to also update the related Python code, especially for "C accelerators" modules like _asyncio/_pickle. I suggest to only start to use %T on a case by base basis.

@vstinner

Copy link
Copy Markdown
Member Author

#Linux-PR_20180911.05 failed: the CI is broken, it failed on apt-get install.

@vstinner vstinner changed the title bpo-34595: Add %t format to PyUnicode_FromFormatV() Sep 11, 2018
@vstinner

Copy link
Copy Markdown
Member Author

I changed the status of this PR to "DO-NOT-MERGE", since Petr Viktorin asked me to open a discussion on python-dev:

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.

4 participants