[pypy-issue] [issue1292] repr() of type created in non-module code varies from CPython

PJ Eby tracker at bugs.pypy.org
Thu Oct 18 00:21:00 CEST 2012


New submission from PJ Eby <pje at telecommunity.com>:

If you create a new-style class in a namespace which is
not a module (i.e. it lacks a __name__, as in e.g. a
doctest file), PyPy assumes it is a built-in type, and
produces a repr accordingly.  However, CPython still
considers the type a user-defined class, and displays
its repr accordingly:

$ py27
Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> del __name__
>>> class x(int): pass
...
>>> x
<class 'x'>

$ pypy
Python 2.7.2 (341e1e3821ff, Jun 07 2012, 15:43:00)
[PyPy 1.9.0 with MSC v.1500 32 bit] on win32
Type "help", "copyright", "credits" or "license" for more information.
And now for something completely different: ``first they laugh at you, then
they ignore you, then they fight you, then you win''
>>>> del __name__
>>>> class x(int): pass
>>>> x
<type 'x'>

This causes doctests that display a type defined in that
doctest to break, relative to the same doctest on CPython,
making it challenging to support PyPy in such a test suite.

----------
messages: 4858
nosy: pje, pypy-issue
priority: bug
status: unread
title: repr() of type created in non-module code varies from CPython

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1292>
________________________________________


More information about the pypy-issue mailing list