[IronPython] Lambdas, properties and namespace leakage

Michael Foord fuzzyman at voidspace.org.uk
Fri Jun 1 19:04:38 CEST 2007


Martin Maly wrote:
> Thanks for a fun bug, Michael, just to clarify, this is using the IronPython 1.1 release, correct?
>   

Yes. Given the performance degradation (on XP) and the lack of multiple 
engine support we can't switch to 2.0 yet...

Are bugfixes still being ported to the 1.X branch?

Thanks

Michael
http://www.voidspace.org.uk/ironpython/index.shtml

> If it is of any consolation, this is the output from the IronPython 2.0 alpha where this no longer happens:
>
> IronPython console: IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.42
> Copyright (c) Microsoft Corporation. All rights reserved.
>   
>>>> class X(object):
>>>>         
> ...     p2 = property(lambda self: 3)
> ...
>   
>>>> dir(X)
>>>>         
> ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__', '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', '__weakref__', 'p2']
>
> Martin
>
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
> Sent: Friday, June 01, 2007 8:06 AM
> To: Discussion of IronPython
> Subject: [IronPython] Lambdas, properties and namespace leakage
>
> Hello all,
>
> Another fun one. If you use 'property' to wrap a lambda in a class
> namespace then an extra name leaks into the class namespace (which
> confused our documentation system).
>
> CPython:
>  >>> class X(object):
> ...  p2 = property(lambda self: 34)
> ...
>  >>> dir(X)
> ['__class__', '__delattr__', '__dict__', '__doc__', '__getattribute__',
> '__hash_
> _', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__',
> '__repr_
> _', '__setattr__', '__str__', '__weakref__', 'p2']
>
> Amongst all the detritus you can see 'p2' nestled there at the end.
>
> IronPython:
>  >>> class X(object):
> ...  p2 = property(lambda self: 34)
> ...
>  >>> dir(X)
> ['<lambda$0>', '__class__', '__dict__', '__doc__', '__init__',
> '__module__', '__
> new__', '__reduce__', '__reduce_ex__', '__repr__', '__weakref__', 'p2']
>
> See the weird first entry! Shouldn't be there...
>
> Thanks
>
> Michael
>
>
>
> --
> Michael Foord
> Resolver Systems
> michael.foord at resolversystems.com
>
> Office address:     17a Clerkenwell Road, London EC1M 5RD, UK
> Registered address: 843 Finchley Road, London NW11 8NA, UK
>
> Resolver Systems Limited is registered in England and Wales as company number 5467329.
> VAT No. GB 893 5643 79
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>   




More information about the Ironpython-users mailing list