Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix ticket #5: mangle private '__xyz' attribute names inside of Pytho…
…n classes --HG-- rename : tests/run/methodmangling_T5.pyx => tests/run/methodmangling_T5.py
- Loading branch information
Stefan Behnel
committed
Sep 10, 2011
1 parent
57b5f0c
commit bce8b98
Showing
6 changed files
with
101 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# mode: run | ||
# ticket: 5 | ||
|
||
class CyTest(object): | ||
""" | ||
>>> cy = CyTest() | ||
>>> '_CyTest__private' in dir(cy) | ||
True | ||
>>> cy._CyTest__private() | ||
8 | ||
>>> '__private' in dir(cy) | ||
False | ||
>>> '_CyTest__x' in dir(cy) | ||
True | ||
>>> '__x' in dir(cy) | ||
False | ||
""" | ||
__x = 1 | ||
def __private(self): return 8 | ||
|
||
def get(self): | ||
""" | ||
>>> CyTest().get() | ||
(1, 1, 8) | ||
""" | ||
return self._CyTest__x, self.__x, self.__private() | ||
|
||
def get_inner(self): | ||
""" | ||
>>> CyTest().get_inner() | ||
(1, 1, 8) | ||
""" | ||
def get(o): | ||
return o._CyTest__x, o.__x, o.__private() | ||
return get(self) | ||
|
||
class CyTestSub(CyTest): | ||
""" | ||
>>> cy = CyTestSub() | ||
>>> '_CyTestSub__private' in dir(cy) | ||
True | ||
>>> cy._CyTestSub__private() | ||
9 | ||
>>> '_CyTest__private' in dir(cy) | ||
True | ||
>>> cy._CyTest__private() | ||
8 | ||
>>> '__private' in dir(cy) | ||
False | ||
>>> '_CyTestSub__x' in dir(cy) | ||
False | ||
>>> '_CyTestSub__y' in dir(cy) | ||
True | ||
>>> '_CyTest__x' in dir(cy) | ||
True | ||
>>> '__x' in dir(cy) | ||
False | ||
""" | ||
__y = 2 | ||
def __private(self): return 9 | ||
|
||
def get(self): | ||
""" | ||
>>> CyTestSub().get() | ||
(1, 2, 2, 9) | ||
""" | ||
return self._CyTest__x, self._CyTestSub__y, self.__y, self.__private() | ||
|
||
def get_inner(self): | ||
""" | ||
>>> CyTestSub().get_inner() | ||
(1, 2, 2, 9) | ||
""" | ||
def get(o): | ||
return o._CyTest__x, o._CyTestSub__y, o.__y, o.__private() | ||
return get(self) |
This file was deleted.
Oops, something went wrong.