Ticket #5 (new defect)

Opened 8 months ago

Last modified 2 weeks ago

no mangling of double underscore names in class

Reported by: robertwb Assigned to: somebody
Priority: minor Milestone: 1.0
Component: Code Generation Version:
Keywords: Cc:

Description (Last modified by scoder)

When defining a class attribute that starts with double underscores, CPython mangles the name from __bla to _classname_bla, but Cython produced 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
>>>

Change History

05/05/2008 05:22:24 PM changed by robertwb

  • owner changed from robertwb to somebody.

08/02/2008 11:40:14 PM changed by robertwb

  • priority changed from major to minor.

08/18/2008 08:57:10 PM changed by robertwb

  • milestone set to wishlist.

09/05/2008 01:51:02 AM changed by Stefan Behnel

  • component changed from Build System to Code Generation.

I added a test case for this as tests/unimplemented/methodmangling.pyx

12/21/2008 12:09:38 PM changed by scoder

  • description changed.
  • milestone changed from wishlist to 1.0.

12/21/2008 12:09:54 PM changed by scoder

  • description changed.