[New-bugs-announce] [issue33818] Make PyExceptionClass_Name returning a const string

Serhiy Storchaka report at bugs.python.org
Sun Jun 10 02:35:52 EDT 2018


New submission from Serhiy Storchaka <storchaka+cpython at gmail.com>:

PyExceptionClass_Name() returns just the tp_name field, a pointer to immutable char array. tp_name had type "char *" in old Python versions, but it was changed to "const char *" in revision af68c874a6803b4e90b616077a602c0593719a1d.

But PyExceptionClass_Name() still casts tp_name to "char *". I think it would be better to return "const char *". It would be a breaking change, but seems most third-party code uses the result of PyExceptionClass_Name() in context where "const char *" is acceptable [1], and it is easy to add "const" in a variable declaration if the result is assigned to a variable (as in both cases of using PyExceptionClass_Name() in the CPython core).

Since several similar breaking changes were made in 3.7 (isee ssue28761 and issue28769), it would be nice to made this change in 3.7 too. But it may be too late for 3.7.

[1] https://github.com/search?q=PyExceptionClass_Name&type=Code

----------
components: Interpreter Core
messages: 319200
nosy: ned.deily, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Make PyExceptionClass_Name returning a const string
type: enhancement
versions: Python 3.7, Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33818>
_______________________________________


More information about the New-bugs-announce mailing list