no mangling of double underscore names in class

Bug #196118 reported by Alon Levy
2
Affects Status Importance Assigned to Milestone
Cython
New
Undecided
Unassigned

Bug Description

When defining a class attribute that starts with double underscores, CPython mangles the name from __bla to _classname_bla, but Cython produces classes don't.

Minimal example:

test.pyx and good.py are the same, like so:
class Test(object):
    __bla = 1

alon@alfajor:~/src/bugs/cython/doubleunderscore$ python
Python 2.5.2 (r252:60911, Feb 26 2008, 15:04:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import test
>>> test.Test
<class 'test.Test'>
>>> test.Test.__bla
1
>>>
alon@alfajor:~/src/bugs/cython/doubleunderscore$
alon@alfajor:~/src/bugs/cython/doubleunderscore$ ls
build setup.py test.c test.pyx test.so
alon@alfajor:~/src/bugs/cython/doubleunderscore$ cp test.pyx good.py
alon@alfajor:~/src/bugs/cython/doubleunderscore$ python
Python 2.5.2 (r252:60911, Feb 26 2008, 15:04:22)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import good
>>> good.Test
<class 'good.Test'>
>>> good.Test.__bla
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: type object 'Test' has no attribute '__bla'
>>> good.Test._Test__bla
1
>>>

Revision history for this message
Alon Levy (alonlevy1) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.