[issue13224] Change str(class) to return only the class name

Éric Araujo report at bugs.python.org
Wed Nov 2 17:31:12 CET 2011


Éric Araujo <merwok at netwok.org> added the comment:

I’ve updated my patch to handle modules and functions too, but there is a decision to make.  The functions of built-in modules are implemented by methodobject.c, not functionobject.c (that’s for Python functions), so if we want str(sys.exc_info) to be equal to 'exc_info', then we’ll have str(dict.update) == 'update'.  Is this okay?

The patch needs a review.

- I tried using PyUnicode_FromString(name) instead of PyUnicode_FromFormat("%U", name), just like in Python I would use str(x) instead of '%s' % x, but this caused segfaults.  Is there a simpler function to use?

- I’ve used copy-paste-tweak and checked the results; I’m still learning C and know very little about Python’s types and refcounting internals, so review mercilessly!  I forgot to run the tests in findleaks mode, so I’m doing it right now.

----------
Added file: http://bugs.python.org/file23591/change-some-__str__.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13224>
_______________________________________


More information about the Python-bugs-list mailing list