robertwb / issues-import-test

0 stars 0 forks source link

no mangling of double underscore names in class #31

Closed robertwb closed 8 years ago

robertwb commented 8 years ago

Reported by robertwb on 6 May 2008 00:16 UTC 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)
[4.2.3 (Ubuntu 4.2.3-2ubuntu1)](GCC) 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)
[4.2.3 (Ubuntu 4.2.3-2ubuntu1)](GCC) 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
>>>

Migrated-From: http://trac.cython.org/ticket/5

robertwb commented 8 years ago

Modified by robertwb on 6 May 2008 00:22 UTC

robertwb commented 8 years ago

Modified by robertwb on 3 Aug 2008 06:40 UTC

robertwb commented 8 years ago

Modified by robertwb on 19 Aug 2008 03:57 UTC

robertwb commented 8 years ago

Comment by Stefan Behnel on 5 Sep 2008 08:51 UTC I added a test case for this as tests/unimplemented/methodmangling.pyx

robertwb commented 8 years ago

Modified by scoder on 21 Dec 2008 20:09 UTC

robertwb commented 8 years ago

Modified by scoder on 21 Dec 2008 20:09 UTC

robertwb commented 8 years ago

Modified by scoder on 24 Oct 2010 17:38 UTC

robertwb commented 8 years ago

Modified by scoder on 10 Sep 2011 10:15 UTC

robertwb commented 8 years ago

Comment by scoder on 10 Sep 2011 10:28 UTC Fix is here:

https://github.com/cython/cython/commit/bce8b981a3e71378a164e8c9acca5f00bbbe32d7

robertwb commented 8 years ago

Modified by scoder on 12 Sep 2011 20:26 UTC