Open mxndtaylor opened 4 weeks ago
python's mangling system is convenient, but with this method of aliasing member, we do not mangle the alias names.
leading to issues like this:
class Foo: @aka.valiases("__mangled_alias") def __mangled_initial(self): return "val" print(Foo().__mangled_alias()) # prints "val"
I would expect the above to fail, and leave the alias's name as _Foo__mangled_alias instead, so that this succeeds:
_Foo__mangled_alias
class Foo: @aka.valiases("__mangled_alias") def __mangled_initial(self): return "val" print(Foo()._Foo__mangled_alias()) # prints "val"
if alias.__set_name__ gets a name that has leading __ (with at most 1 trailing _), then mangle the alias's name based on owner.__name__.
alias.__set_name__
name
__
_
owner.__name__
ex:
class Foo: prop = 1 prop_alias = alias(alias_name="__prop") prop_alias.attach(Foo) assert Foo()._Foo__prop == 1
We might want to add a parameter no_mangle or such that disables this behavior
no_mangle
Is your feature request related to a problem?
python's mangling system is convenient, but with this method of aliasing member, we do not mangle the alias names.
leading to issues like this:
I would expect the above to fail, and leave the alias's name as
_Foo__mangled_alias
instead, so that this succeeds:Describe the solution you'd like
if
alias.__set_name__
gets aname
that has leading__
(with at most 1 trailing_
), then mangle the alias's name based onowner.__name__
.ex:
Additional context
We might want to add a parameter
no_mangle
or such that disables this behavior