From merllab at microsoft.com Mon Nov 2 17:53:12 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Mon, 2 Nov 2009 08:53:12 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/60904. MODIFIED SOURCES $/IronPython/IronPython_Main/Src/AssemblyVersion.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/Properties/ExtensionAssemblyInfo.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Chiron/Properties/AssemblyInfo.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Debugging/AssemblyInfo.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting/Properties/AssemblyInfo.cs From cenovsky at bakalari.cz Mon Nov 2 18:29:20 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Mon, 02 Nov 2009 18:29:20 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7B0468@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AEB250F.3050805@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7B0468@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <4AEF16F0.2040303@bakalari.cz> I was thinking about this... Does ir mean that (after adding such support to clrtype) and building a .dll from the interface class, this class can be used from c#? -- -- Luk?? Shri Borde wrote: > > The clrtype module could be extended to make it possible to declare > CLR interfaces in Python code. Something like: > > > > class IFoo(object): > > * __metaclass__ = ClrType.ClrInterface # Proposed way to indicate > an interface* > > @clrtype.accepts(int, str) > > @clrtype.returns(int) > > @clrtype.attribute(OperationContractAttribute)() > > def foo(i, s):raise RuntimeError("this should not get called") > > > > This does not work today... > > > > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Friday, October 30, 2009 10:41 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > Thanks. > > I wanted to implement WCF service in pure Ironpython but I overlooked > the [OperationContract] method attribute is used in the interface > declaration. Anyway, thanks to class attributes it is now possible to > implement the WCF service in IronPython and have only the interface > done in C#. See my blog post: > > http://gui-at.blogspot.com/2009/10/wcf-service-in-ironpython.html > > DllImport is good to have too - I can get rid of of my Win32API.dll > when simulating user's input > :-) > > -- > -- Luk?? > > > Shri Borde wrote: > > The following files extend DevHawk's blog and adds support for typed methods with attributes. It will be available as part of the samples released with the 2.6 RTM (over the next month). Do let us know if it works for you. > > Also, I would be curious to know what scenario you need method attributes for (other than DllImport for pinvokes)... > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky > Sent: Thursday, October 22, 2009 10:37 AM > To: Discussion of IronPython > Subject: [IronPython] .NET attributes for methods > > Hi, > I have read all DewHawk blogposts about .Net attributes in IronPython > via __clrtype__ metaclass > (http://devhawk.net/CategoryView,category,__clrtype__.aspx). He > describes how to add attributes to classes but not to methods. Is there > any example how to add attributes to a method. It looks like method > generation is necessary (like for getter and setter or in > http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659) > but this is kind of deep magic for me... > Thanks. > > -- > -- Luk?? > _______________________________________________ > 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 > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Mon Nov 2 21:07:48 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Mon, 2 Nov 2009 12:07:48 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <00b4feed-3c40-42da-bf8d-97abd423cea9@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/60916. ADDED SOURCES $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/index.htm $/IronPython/IronPython_2_6/Src/Tests/silverlight_sanity/index.html MODIFIED SOURCES $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/index.htm $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Dynamic/Properties/AssemblyInfo.cs $/IronPython/IronPython_2_6/Src/AssemblyVersion.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Chiron/Properties/AssemblyInfo.cs $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Debugging/AssemblyInfo.cs $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/Properties/ExtensionAssemblyInfo.cs $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/Properties/AssemblyInfo.cs $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting/Properties/AssemblyInfo.cs $/IronPython/IronPython_2_6/Src/Tests/silverlight_sanity/index.html $/IronPython/IronPython_2_6/Src/Tests/test_imp.py From fmerrow at qualcomm.com Mon Nov 2 21:27:33 2009 From: fmerrow at qualcomm.com (Frank Merrow) Date: Mon, 2 Nov 2009 12:27:33 -0800 Subject: [IronPython] Iron Python NewB questions . . . References: <304cd93c-3263-49a2-8a37-987d45ee4235@nasanexmsp02.na.qualcomm.com> Message-ID: >There's a couple of ways to do this. You can define an interface or base >class on the C# side and implement it on the Python side. Then you can >cast the Python object to the interface or base class and use it that way. Well . . . I was not able to "cast" this into anything . . . they are very different interfaces. I eventually started looking at the module pyc.py output in the Object Browser and trying to use it . . . not much information on the Internet for DLRCachedCode . . . and what does exist is . . . well over my head. Reminds me of the old days trying to call a DCOM object from C++ . . . was ugly, ugly code . . . this looks similar . . . and in the face of the much nicer option below, in true Monte Python style I decided to "run away". >Also w/ .NET 4.0 C# is getting the new static type "dynamic" which can >be used for interoperating with Python and other objects which respond >dynamically. VB.NET, while already having dynamic support, also gets >updated so that it can consume IronPython and IronRuby objects. Yeah, docs for this look MUCH NICER . . . I'm downloading the Beta's now to give this a try. If this works . . . I'll hang my hat on VS2010 and .NET 4.0 and hope I've never forced to look back. Thanks for the info. Frank From nbuttarelli at gmail.com Mon Nov 2 21:38:38 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Mon, 2 Nov 2009 21:38:38 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application Message-ID: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Mon Nov 2 21:41:55 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 2 Nov 2009 20:41:55 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas -------------- next part -------------- An HTML attachment was scrubbed... URL: From nbuttarelli at gmail.com Mon Nov 2 22:19:38 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Mon, 2 Nov 2009 22:19:38 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland wrote: > After creating your app domain you can do: > > > > ScriptEngine engine = Python.CreateEngine(someAppDomain); > > > > And then the rest of your code should work as it?s written. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 12:39 PM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Safe execution of python scripts on my .net > application > > > > Sorry, I don't know if my previous message have arrived. So, here it is: > > > > > > Hello all, > > > > I am starting with python and I would like to add to my web application > some web services. This services will allow the different clients of my > application to execute some python scripts. > > > > I would like to know if someone did this before and how can I do this in a > secure way. I mean, how can I do to restrict the environment where the > scripts will be executed. > > > > In .net I can do this using the AppDoman and setting the permission set. > > > > AppDomain.CreateDomain( string friendlyName, > Evidence securityInfo, > AppDomainSetup info, > PermissionSet grantSet, > params StrongName[] fullTrustAssemblies); > > > > > > Is there a way to do the same with my python scripts? > > > > I am running them using this: > > > > ScriptEngine engine = Python.CreateEngine(); > > ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > Thanks in advance. > > Nicolas > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Mon Nov 2 22:25:19 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 2 Nov 2009 21:25:19 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> Assuming the app domain is setup properly then there's no way for the Python code to elevate permissions (modulo CLR security bugs which are few and far between). This is because IronPython its self is 100% security transparent and does not affect any security decisions or assert any form of trust - so it's all up to the CLR to limit permissions. So for example while you can access the file object, or import ctypes, or call various other Python APIs which would require trust you'll get a security exception from the CLR when you don't have permissions to do something. For more complex scenarios you might also have an object model which you expose to the application and inject in via its scope. Once you've done that you'll want to make sure that the object model is also secure. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland > wrote: After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jregele23 at gmail.com Mon Nov 2 22:43:50 2009 From: jregele23 at gmail.com (Justin Regele) Date: Mon, 2 Nov 2009 13:43:50 -0800 Subject: [IronPython] Iron Python NewB questions . . . In-Reply-To: References: <304cd93c-3263-49a2-8a37-987d45ee4235@nasanexmsp02.na.qualcomm.com> Message-ID: <8429660911021343l2db64650xb4172d03e7899803@mail.gmail.com> Embedding IPy in C# isn't easy at first, and definitely not super straight-forward, but there are alot of options of how to do it. Get Mike's book, or at least download the source for the embedding chapter. Embedding ironpython is tricky now, but things are progressing quickly, and there ARE lots of ways to do it--different techniques for different situations. On Mon, Nov 2, 2009 at 12:27 PM, Frank Merrow wrote: > > There's a couple of ways to do this. You can define an interface or base >> class on the C# side and implement it on the Python side. Then you can >> cast the Python object to the interface or base class and use it that way. >> > > Well . . . I was not able to "cast" this into anything . . . they are very > different interfaces. > > I eventually started looking at the module pyc.py output in the Object > Browser and trying to use it . . . not much information on the Internet for > DLRCachedCode . . . and what does exist is . . . well over my head. Reminds > me of the old days trying to call a DCOM object from C++ . . . was ugly, > ugly code . . . this looks similar . . . and in the face of the much nicer > option below, in true Monte Python style I decided to "run away". > > > Also w/ .NET 4.0 C# is getting the new static type "dynamic" which can >> be used for interoperating with Python and other objects which respond >> dynamically. VB.NET, while already having dynamic support, also gets >> updated so that it can consume IronPython and IronRuby objects. >> > > Yeah, docs for this look MUCH NICER . . . I'm downloading the Beta's now to > give this a try. > > If this works . . . I'll hang my hat on VS2010 and .NET 4.0 and hope I've > never forced to look back. > > Thanks for the info. > > > Frank > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fmerrow at qualcomm.com Mon Nov 2 22:59:49 2009 From: fmerrow at qualcomm.com (Frank Merrow) Date: Mon, 2 Nov 2009 13:59:49 -0800 Subject: [IronPython] Iron Python NewB questions . . . In-Reply-To: <8429660911021343l2db64650xb4172d03e7899803@mail.gmail.com> References: <304cd93c-3263-49a2-8a37-987d45ee4235@nasanexmsp02.na.qualcomm.com> <8429660911021343l2db64650xb4172d03e7899803@mail.gmail.com> Message-ID: <05afeb8f-d391-4e1a-aa52-798c3786968c@nasanexmsp02.na.qualcomm.com> At 01:43 PM 11/2/2009, Justin Regele wrote: >Embedding IPy in C# isn't easy at first, and definitely not super >straight-forward, but there are alot of options of how to do it. Get >Mike's book, or at least download the source for the embedding >chapter. Embedding ironpython is tricky now, but things are >progressing quickly, and there ARE lots of ways to do it--different >techniques for different situations. Okay, maybe everyone on this list knows, but I don't . . . Mike Who and what book? Frank From dave.purrington at gmail.com Mon Nov 2 23:22:46 2009 From: dave.purrington at gmail.com (Dave Purrington) Date: Mon, 2 Nov 2009 17:22:46 -0500 Subject: [IronPython] Iron Python NewB questions . . . In-Reply-To: <05afeb8f-d391-4e1a-aa52-798c3786968c@nasanexmsp02.na.qualcomm.com> References: <304cd93c-3263-49a2-8a37-987d45ee4235@nasanexmsp02.na.qualcomm.com> <8429660911021343l2db64650xb4172d03e7899803@mail.gmail.com> <05afeb8f-d391-4e1a-aa52-798c3786968c@nasanexmsp02.na.qualcomm.com> Message-ID: <911188a90911021422l9620a12qce20a6942e00fd1@mail.gmail.com> Mike in this case is probably Michael Foord. http://www.ironpythoninaction.com/ Here's a good place to start (from Mike's blog): http://www.voidspace.org.uk/ironpython/hosting_api.shtm There are lots of variations of hosting, and many patterns. Sounds like you might be wanting to define classes in IPy and instantiate them. Basically, you run the script that defines the class, then get the class object from the runtime scope, then invoke the constructor which returns an instance of the object. Casting should work in that case (provided of course that you've derived from the type in question). For example: public T Load(string path, params object[] parameters) where T : class { ScriptSource script = _engine.CreateScriptSourceFromFile(path); CompiledCode code = script.Compile(); string className = Path.GetFileNameWithoutExtension(path); # this is just a convention object theClass = _scope.GetVariable(className); object instance = _engine.Operations.Invoke(theClass, parameters); return instance as T; } This isn't the only info you need, but should give you an idea of how it works. Try searching for "ironpython hosting" Hope this helps. On Mon, Nov 2, 2009 at 4:59 PM, Frank Merrow wrote: > At 01:43 PM 11/2/2009, Justin Regele wrote: > >> Embedding IPy in C# isn't easy at first, and definitely not super >> straight-forward, but there are alot of options of how to do it. Get Mike's >> book, or at least download the source for the embedding chapter. Embedding >> ironpython is tricky now, but things are progressing quickly, and there ARE >> lots of ways to do it--different techniques for different situations. >> > > Okay, maybe everyone on this list knows, but I don't . . . > > Mike Who and what book? > > > Frank > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Shri.Borde at microsoft.com Tue Nov 3 07:31:55 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Tue, 3 Nov 2009 06:31:55 +0000 Subject: [IronPython] .NET attributes for methods In-Reply-To: <4AEF16F0.2040303@bakalari.cz> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AEB250F.3050805@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7B0468@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AEF16F0.2040303@bakalari.cz> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C7B3825@TK5EX14MBXC140.redmond.corp.microsoft.com> It should be possible. However, note that you create the .dll using clr.GetSubclassedTypes (and clr.CompileSubclassedTypes) which requires you to run your application with all the scenarios you care about. You can't just run a simple command line like "csc.exe foo.cs" and get a dll. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Monday, November 02, 2009 9:29 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I was thinking about this... Does ir mean that (after adding such support to clrtype) and building a .dll from the interface class, this class can be used from c#? -- -- Luk?? Shri Borde wrote: The clrtype module could be extended to make it possible to declare CLR interfaces in Python code. Something like: class IFoo(object): __metaclass__ = ClrType.ClrInterface # Proposed way to indicate an interface @clrtype.accepts(int, str) @clrtype.returns(int) @clrtype.attribute(OperationContractAttribute)() def foo(i, s):raise RuntimeError("this should not get called") This does not work today... From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Friday, October 30, 2009 10:41 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods Thanks. I wanted to implement WCF service in pure Ironpython but I overlooked the [OperationContract] method attribute is used in the interface declaration. Anyway, thanks to class attributes it is now possible to implement the WCF service in IronPython and have only the interface done in C#. See my blog post: http://gui-at.blogspot.com/2009/10/wcf-service-in-ironpython.html DllImport is good to have too - I can get rid of of my Win32API.dll when simulating user's input :-) -- -- Luk?? Shri Borde wrote: The following files extend DevHawk's blog and adds support for typed methods with attributes. It will be available as part of the samples released with the 2.6 RTM (over the next month). Do let us know if it works for you. Also, I would be curious to know what scenario you need method attributes for (other than DllImport for pinvokes)... -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Thursday, October 22, 2009 10:37 AM To: Discussion of IronPython Subject: [IronPython] .NET attributes for methods Hi, I have read all DewHawk blogposts about .Net attributes in IronPython via __clrtype__ metaclass (http://devhawk.net/CategoryView,category,__clrtype__.aspx). He describes how to add attributes to classes but not to methods. Is there any example how to add attributes to a method. It looks like method generation is necessary (like for getter and setter or in http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659) but this is kind of deep magic for me... Thanks. -- -- Luk?? _______________________________________________ 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 ________________________________ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From nbuttarelli at gmail.com Tue Nov 3 21:07:42 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Tue, 3 Nov 2009 21:07:42 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> Hi again, thanks for your clear response. I was trying to do what you proposed but it is not working. I am receiving an exception: *Test method CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw exception: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. * I tried to find a solution but I couldn't. This is the minimal code that I am running to get this exception (I have removed all the security stuff but apparently that does not resolve the problem): *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain");* * * *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);* *SriptScope scope = engine.CreateScope();* *source.Execute(scope);* The exception is thronged in this line: *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* Do you have any idea which could be the problem? Thanks again, Nicolas On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland wrote: > Assuming the app domain is setup properly then there?s no way for the > Python code to elevate permissions (modulo CLR security bugs which are few > and far between). This is because IronPython its self is 100% security > transparent and does not affect any security decisions or assert any form of > trust ? so it?s all up to the CLR to limit permissions. So for example > while you can access the file object, or import ctypes, or call various > other Python APIs which would require trust you?ll get a security exception > from the CLR when you don?t have permissions to do something. > > > > For more complex scenarios you might also have an object model which you > expose to the application and inject in via its scope. Once you?ve done > that you?ll want to make sure that the object model is also secure. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 1:20 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Thanks for your response. > > > > But what happens with the python code? Does not exist a way to write some > scripts that can do some damage to my app, the server, the database, etc? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland wrote: > > After creating your app domain you can do: > > > > ScriptEngine engine = Python.CreateEngine(someAppDomain); > > > > And then the rest of your code should work as it?s written. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 12:39 PM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Safe execution of python scripts on my .net > application > > > > Sorry, I don't know if my previous message have arrived. So, here it is: > > > > > > Hello all, > > > > I am starting with python and I would like to add to my web application > some web services. This services will allow the different clients of my > application to execute some python scripts. > > > > I would like to know if someone did this before and how can I do this in a > secure way. I mean, how can I do to restrict the environment where the > scripts will be executed. > > > > In .net I can do this using the AppDoman and setting the permission set. > > > > AppDomain.CreateDomain( string friendlyName, > Evidence securityInfo, > AppDomainSetup info, > PermissionSet grantSet, > params StrongName[] fullTrustAssemblies); > > > > > > Is there a way to do the same with my python scripts? > > > > I am running them using this: > > > > ScriptEngine engine = Python.CreateEngine(); > > ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > Thanks in advance. > > Nicolas > > > _______________________________________________ > 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Shri.Borde at microsoft.com Tue Nov 3 21:29:35 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Tue, 3 Nov 2009 20:29:35 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> I think this happens if the new appdomain cannot load the required assembly. By default, the new appdomain should inherit its BaseDirectory property from the creating domain and should be able to load Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If not, can you try to put all assemblies in the same folder (or in the GAC) to see if it works? If that works, you can then figure out how to configure the new appdomain such that it can load Microsoft.Scripting.dll. There may be some setting in AppDomainSetup, or you could hook the AssemblyResolve event... From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 12:08 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Hi again, thanks for your clear response. I was trying to do what you proposed but it is not working. I am receiving an exception: Test method CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw exception: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. I tried to find a solution but I couldn't. This is the minimal code that I am running to get this exception (I have removed all the security stuff but apparently that does not resolve the problem): AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); SriptScope scope = engine.CreateScope(); source.Execute(scope); The exception is thronged in this line: ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); Do you have any idea which could be the problem? Thanks again, Nicolas On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: Assuming the app domain is setup properly then there's no way for the Python code to elevate permissions (modulo CLR security bugs which are few and far between). This is because IronPython its self is 100% security transparent and does not affect any security decisions or assert any form of trust - so it's all up to the CLR to limit permissions. So for example while you can access the file object, or import ctypes, or call various other Python APIs which would require trust you'll get a security exception from the CLR when you don't have permissions to do something. For more complex scenarios you might also have an object model which you expose to the application and inject in via its scope. Once you've done that you'll want to make sure that the object model is also secure. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland > wrote: After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From nbuttarelli at gmail.com Tue Nov 3 22:06:06 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Tue, 3 Nov 2009 22:06:06 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> Thanks Shri, I will try. In addition, I found this open issue: http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that it is related. On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde wrote: > I think this happens if the new appdomain cannot load the required > assembly. By default, the new appdomain should inherit its BaseDirectory > property from the creating domain and should be able to load > Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If > not, can you try to put all assemblies in the same folder (or in the GAC) to > see if it works? If that works, you can then figure out how to configure the > new appdomain such that it can load Microsoft.Scripting.dll. There may be > some setting in AppDomainSetup, or you could hook the AssemblyResolve event? > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 12:08 PM > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Hi again, thanks for your clear response. > > > > I was trying to do what you proposed but it is not working. I am receiving > an exception: > > > > *Test method > CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest > threw exception: System.Runtime.Serialization.SerializationException: Type > is not resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..* > > I tried to find a solution but I couldn't. This is the minimal code that I > am running to get this exception (I have removed all the security stuff but > apparently that does not resolve the problem): > > > > *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain");* > > > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);* > > *SriptScope scope = engine.CreateScope();* > > *source.Execute(scope);* > > > > The exception is thronged in this line: > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > > > > > Do you have any idea which could be the problem? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: > > Assuming the app domain is setup properly then there?s no way for the > Python code to elevate permissions (modulo CLR security bugs which are few > and far between). This is because IronPython its self is 100% security > transparent and does not affect any security decisions or assert any form of > trust ? so it?s all up to the CLR to limit permissions. So for example > while you can access the file object, or import ctypes, or call various > other Python APIs which would require trust you?ll get a security exception > from the CLR when you don?t have permissions to do something. > > > > For more complex scenarios you might also have an object model which you > expose to the application and inject in via its scope. Once you?ve done > that you?ll want to make sure that the object model is also secure. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 1:20 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Thanks for your response. > > > > But what happens with the python code? Does not exist a way to write some > scripts that can do some damage to my app, the server, the database, etc? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland wrote: > > After creating your app domain you can do: > > > > ScriptEngine engine = Python.CreateEngine(someAppDomain); > > > > And then the rest of your code should work as it?s written. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 12:39 PM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Safe execution of python scripts on my .net > application > > > > Sorry, I don't know if my previous message have arrived. So, here it is: > > > > > > Hello all, > > > > I am starting with python and I would like to add to my web application > some web services. This services will allow the different clients of my > application to execute some python scripts. > > > > I would like to know if someone did this before and how can I do this in a > secure way. I mean, how can I do to restrict the environment where the > scripts will be executed. > > > > In .net I can do this using the AppDoman and setting the permission set. > > > > AppDomain.CreateDomain( string friendlyName, > Evidence securityInfo, > AppDomainSetup info, > PermissionSet grantSet, > params StrongName[] fullTrustAssemblies); > > > > > > Is there a way to do the same with my python scripts? > > > > I am running them using this: > > > > ScriptEngine engine = Python.CreateEngine(); > > ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > Thanks in advance. > > Nicolas > > > _______________________________________________ > 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 > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nbuttarelli at gmail.com Tue Nov 3 22:29:46 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Tue, 3 Nov 2009 22:29:46 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> Message-ID: <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> I have create a new "Test Project" and an Unit Test class in order to test the following code inside: AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); I have add the references: - IronPython - Microsoft.Scripting - Microsoft.ScriptingCore But it still not working and throwing the same System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. Any ideas? 2009/11/3 Nicol?s Buttarelli > Thanks Shri, I will try. > > In addition, I found this open issue: > http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that > it is related. > > > On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde wrote: > >> I think this happens if the new appdomain cannot load the required >> assembly. By default, the new appdomain should inherit its BaseDirectory >> property from the creating domain and should be able to load >> Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If >> not, can you try to put all assemblies in the same folder (or in the GAC) to >> see if it works? If that works, you can then figure out how to configure the >> new appdomain such that it can load Microsoft.Scripting.dll. There may be >> some setting in AppDomainSetup, or you could hook the AssemblyResolve event? >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Tuesday, November 03, 2009 12:08 PM >> >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Hi again, thanks for your clear response. >> >> >> >> I was trying to do what you proposed but it is not working. I am receiving >> an exception: >> >> >> >> *Test method >> CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest >> threw exception: System.Runtime.Serialization.SerializationException: Type >> is not resolved for member >> 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, >> Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..* >> >> I tried to find a solution but I couldn't. This is the minimal code that I >> am running to get this exception (I have removed all the security stuff but >> apparently that does not resolve the problem): >> >> >> >> *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); >> * >> >> >> >> *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* >> >> *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); >> * >> >> *SriptScope scope = engine.CreateScope();* >> >> *source.Execute(scope);* >> >> >> >> The exception is thronged in this line: >> >> *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* >> >> >> >> >> >> Do you have any idea which could be the problem? >> >> >> >> Thanks again, >> >> Nicolas >> >> >> >> On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland >> wrote: >> >> Assuming the app domain is setup properly then there?s no way for the >> Python code to elevate permissions (modulo CLR security bugs which are few >> and far between). This is because IronPython its self is 100% security >> transparent and does not affect any security decisions or assert any form of >> trust ? so it?s all up to the CLR to limit permissions. So for example >> while you can access the file object, or import ctypes, or call various >> other Python APIs which would require trust you?ll get a security exception >> from the CLR when you don?t have permissions to do something. >> >> >> >> For more complex scenarios you might also have an object model which you >> expose to the application and inject in via its scope. Once you?ve done >> that you?ll want to make sure that the object model is also secure. >> >> >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Monday, November 02, 2009 1:20 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Thanks for your response. >> >> >> >> But what happens with the python code? Does not exist a way to write some >> scripts that can do some damage to my app, the server, the database, etc? >> >> >> >> Thanks again, >> >> Nicolas >> >> >> >> On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland >> wrote: >> >> After creating your app domain you can do: >> >> >> >> ScriptEngine engine = Python.CreateEngine(someAppDomain); >> >> >> >> And then the rest of your code should work as it?s written. >> >> >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Monday, November 02, 2009 12:39 PM >> *To:* users at lists.ironpython.com >> *Subject:* [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Sorry, I don't know if my previous message have arrived. So, here it is: >> >> >> >> >> >> Hello all, >> >> >> >> I am starting with python and I would like to add to my web application >> some web services. This services will allow the different clients of my >> application to execute some python scripts. >> >> >> >> I would like to know if someone did this before and how can I do this in a >> secure way. I mean, how can I do to restrict the environment where the >> scripts will be executed. >> >> >> >> In .net I can do this using the AppDoman and setting the permission set. >> >> >> >> AppDomain.CreateDomain( string friendlyName, >> Evidence securityInfo, >> AppDomainSetup info, >> PermissionSet grantSet, >> params StrongName[] fullTrustAssemblies); >> >> >> >> >> >> Is there a way to do the same with my python scripts? >> >> >> >> I am running them using this: >> >> >> >> ScriptEngine engine = Python.CreateEngine(); >> >> ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); >> >> ScriptScope scope = engine.CreateScope(); >> >> source.Execute(scope); >> >> >> >> Thanks in advance. >> >> Nicolas >> >> >> _______________________________________________ >> 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 >> >> >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Tue Nov 3 22:51:41 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 3 Nov 2009 21:51:41 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> Test projects are weird and somehow you don't end up inheriting the application base. This seems to work though: AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", null, setup); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString("2+2"); ScriptScope scope = engine.CreateScope(); Console.WriteLine(source.Execute(scope)); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 1:30 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application I have create a new "Test Project" and an Unit Test class in order to test the following code inside: AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); I have add the references: - IronPython - Microsoft.Scripting - Microsoft.ScriptingCore But it still not working and throwing the same System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. Any ideas? 2009/11/3 Nicol?s Buttarelli > Thanks Shri, I will try. In addition, I found this open issue: http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that it is related. On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: I think this happens if the new appdomain cannot load the required assembly. By default, the new appdomain should inherit its BaseDirectory property from the creating domain and should be able to load Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If not, can you try to put all assemblies in the same folder (or in the GAC) to see if it works? If that works, you can then figure out how to configure the new appdomain such that it can load Microsoft.Scripting.dll. There may be some setting in AppDomainSetup, or you could hook the AssemblyResolve event... From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 12:08 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Hi again, thanks for your clear response. I was trying to do what you proposed but it is not working. I am receiving an exception: Test method CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw exception: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. I tried to find a solution but I couldn't. This is the minimal code that I am running to get this exception (I have removed all the security stuff but apparently that does not resolve the problem): AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); SriptScope scope = engine.CreateScope(); source.Execute(scope); The exception is thronged in this line: ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); Do you have any idea which could be the problem? Thanks again, Nicolas On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: Assuming the app domain is setup properly then there's no way for the Python code to elevate permissions (modulo CLR security bugs which are few and far between). This is because IronPython its self is 100% security transparent and does not affect any security decisions or assert any form of trust - so it's all up to the CLR to limit permissions. So for example while you can access the file object, or import ctypes, or call various other Python APIs which would require trust you'll get a security exception from the CLR when you don't have permissions to do something. For more complex scenarios you might also have an object model which you expose to the application and inject in via its scope. Once you've done that you'll want to make sure that the object model is also secure. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland > wrote: After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas _______________________________________________ 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 _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Wed Nov 4 17:53:16 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Wed, 4 Nov 2009 08:53:16 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <0bf9efd0-8d7b-4d14-88e1-ccd07af4065e@tk5-exsmh-c102.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61019. ADDED SOURCES $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/index.htm $/IronPython/IronPython_Main/Src/Tests/encoded_files/cp1019.py $/IronPython/IronPython_Main/Src/Tests/silverlight_sanity/index.html DELETED SOURCES $/IronPython/IronPython_Main/Src/Tests/test_interpret_sanity.py MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/index.htm $/IronPython/IronPython_Main/Src/Tests/encoded_files/cp1019.py $/IronPython/IronPython_Main/Src/Tests/interop/net/type/test_clrtype.py $/IronPython/IronPython_Main/Src/Tests/interop/net/property/test_indexervb.py $/IronPython/IronPython_Main/Src/IronPython/Lib/iptest/assert_util.py $/IronPython/IronPython_Main/Src/Tests/ClrAssembly/Src/indexerdefinitionsvb.vb $/IronPython/IronPython_Main/Src/Tests/silverlight_sanity/index.html $/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleFlags.ps1 $/IronPython/IronPython_Main/Src/Tests/test_gc.py $/IronPython/IronPython_Main/Src/Tests/test_exceptions.py $/IronPython/IronPython_Main/Src/Tests/test_dllsite.py $/IronPython/IronPython_Main/Src/Tests/test_dict.py $/IronPython/IronPython_Main/Src/Tests/test_codecs.py $/IronPython/IronPython_Main/Src/Tests/test_cliclass.py $/IronPython/IronPython_Main/Src/Tests/test_ipye.py $/IronPython/IronPython_Main/Src/Tests/test_inheritance.py $/IronPython/IronPython_Main/Src/Tests/test_help.py $/IronPython/IronPython_Main/Src/Tests/test_memory.py $/IronPython/IronPython_Main/Src/Tests/test_methoddispatch.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1248149 Date: 11/2/2009 3:47:58 PM (dfugate) - CP1019 (test_codecs.py) - added regression. Not fixed - test_dllsite.py. Added a regression for a fixed bug - test_exceptions.py. Added a regression for one fixed bug...opened another in the process - CP8202 (test_gc.py) - not fixed - CP4190 (test_help.py) - added regression. Fixed - CP6703 (test_ipye.py) - added regression. Fixed - CP3740 (test_indexervb.py) - added regression. Not fixed (or won't fix?) - ConsoleFlags.ps1 - added regression. Fixed (Shelveset: CP78;REDMOND\dfugate | SNAP CheckinId: 9737) From slide.o.mix at gmail.com Wed Nov 4 18:04:43 2009 From: slide.o.mix at gmail.com (Slide) Date: Wed, 4 Nov 2009 10:04:43 -0700 Subject: [IronPython] Adding imports? Message-ID: Is it possible to add imports to a script without just adding text to the source code before compilation? Maybe something on the script scope or something? Thanks -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Wed Nov 4 18:08:39 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 4 Nov 2009 17:08:39 +0000 Subject: [IronPython] Adding imports? In-Reply-To: References: Message-ID: <1A472770E042064698CB5ADC83A12ACD04C3C9E2@TK5EX14MBXC118.redmond.corp.microsoft.com> You can do: scope.SetVariable("name", engine.ImportModule("module_name")); Where ImportModule is an extension method defined in IronPython.Hosting.Python. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Wednesday, November 04, 2009 9:05 AM To: Discussion of IronPython Subject: [IronPython] Adding imports? Is it possible to add imports to a script without just adding text to the source code before compilation? Maybe something on the script scope or something? Thanks -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From slide.o.mix at gmail.com Wed Nov 4 18:11:48 2009 From: slide.o.mix at gmail.com (Slide) Date: Wed, 4 Nov 2009 10:11:48 -0700 Subject: [IronPython] Adding imports? In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C3C9E2@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <1A472770E042064698CB5ADC83A12ACD04C3C9E2@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: That is perfect! Thanks! On Wed, Nov 4, 2009 at 10:08 AM, Dino Viehland wrote: > You can do: > > > > scope.SetVariable(?name?, engine.ImportModule(?module_name?)); > > > > Where ImportModule is an extension method defined in > IronPython.Hosting.Python. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Slide > *Sent:* Wednesday, November 04, 2009 9:05 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] Adding imports? > > > > Is it possible to add imports to a script without just adding text to the > source code before compilation? > > Maybe something on the script scope or something? > > Thanks > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.purrington at gmail.com Wed Nov 4 18:38:38 2009 From: dave.purrington at gmail.com (Dave Purrington) Date: Wed, 4 Nov 2009 12:38:38 -0500 Subject: [IronPython] Adding imports? In-Reply-To: References: <1A472770E042064698CB5ADC83A12ACD04C3C9E2@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <911188a90911040938p7bfd6b89me0b1caec4c44b35c@mail.gmail.com> You can load assemblies as well. For example, the hosting assembly: Assembly mainAssembly = Assembly.GetExecutingAssembly(); string rootDir = Directory.GetParent(mainAssembly.Location).FullName; _engine.Runtime.LoadAssembly(mainAssembly); On Wed, Nov 4, 2009 at 12:11 PM, Slide wrote: > That is perfect! Thanks! > > On Wed, Nov 4, 2009 at 10:08 AM, Dino Viehland wrote: > >> You can do: >> >> >> >> scope.SetVariable(?name?, engine.ImportModule(?module_name?)); >> >> >> >> Where ImportModule is an extension method defined in >> IronPython.Hosting.Python. >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Slide >> *Sent:* Wednesday, November 04, 2009 9:05 AM >> *To:* Discussion of IronPython >> *Subject:* [IronPython] Adding imports? >> >> >> >> Is it possible to add imports to a script without just adding text to the >> source code before compilation? >> >> Maybe something on the script scope or something? >> >> Thanks >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Shri.Borde at microsoft.com Wed Nov 4 19:36:15 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Wed, 4 Nov 2009 18:36:15 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/ has some info about test projects and appbase problems. You can also use fuslogvw (http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to see why Microsoft.Scripting.dll is failing to load. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Tuesday, November 03, 2009 1:52 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Test projects are weird and somehow you don't end up inheriting the application base. This seems to work though: AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", null, setup); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString("2+2"); ScriptScope scope = engine.CreateScope(); Console.WriteLine(source.Execute(scope)); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 1:30 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application I have create a new "Test Project" and an Unit Test class in order to test the following code inside: AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); I have add the references: - IronPython - Microsoft.Scripting - Microsoft.ScriptingCore But it still not working and throwing the same System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. Any ideas? 2009/11/3 Nicol?s Buttarelli > Thanks Shri, I will try. In addition, I found this open issue: http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that it is related. On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: I think this happens if the new appdomain cannot load the required assembly. By default, the new appdomain should inherit its BaseDirectory property from the creating domain and should be able to load Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If not, can you try to put all assemblies in the same folder (or in the GAC) to see if it works? If that works, you can then figure out how to configure the new appdomain such that it can load Microsoft.Scripting.dll. There may be some setting in AppDomainSetup, or you could hook the AssemblyResolve event... From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 12:08 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Hi again, thanks for your clear response. I was trying to do what you proposed but it is not working. I am receiving an exception: Test method CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw exception: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. I tried to find a solution but I couldn't. This is the minimal code that I am running to get this exception (I have removed all the security stuff but apparently that does not resolve the problem): AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); SriptScope scope = engine.CreateScope(); source.Execute(scope); The exception is thronged in this line: ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); Do you have any idea which could be the problem? Thanks again, Nicolas On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: Assuming the app domain is setup properly then there's no way for the Python code to elevate permissions (modulo CLR security bugs which are few and far between). This is because IronPython its self is 100% security transparent and does not affect any security decisions or assert any form of trust - so it's all up to the CLR to limit permissions. So for example while you can access the file object, or import ctypes, or call various other Python APIs which would require trust you'll get a security exception from the CLR when you don't have permissions to do something. For more complex scenarios you might also have an object model which you expose to the application and inject in via its scope. Once you've done that you'll want to make sure that the object model is also secure. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland > wrote: After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas _______________________________________________ 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 _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Wed Nov 4 21:08:19 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Wed, 4 Nov 2009 12:08:19 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <5e5ab46f-dd65-4dfb-b40a-6ecb0fc8c169@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61024. DELETED SOURCES $/IronPython/IronPython_2_6/Src/Tests/compat/sbs_library.dll MODIFIED SOURCES $/IronPython/IronPython_2_6/Src/Tests/compat/sbs_func_args.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1250429 Date: 11/3/2009 12:39:57 PM (dfugate) Migrated sbs_library.dll change from the Main branch over to IP_26. (Shelveset: SBS_LIBRARY_IP26;REDMOND\dfugate | SNAP CheckinId: 9735) From olomen at hotmail.com Wed Nov 4 21:12:26 2009 From: olomen at hotmail.com (Daniel D.) Date: Wed, 4 Nov 2009 23:12:26 +0300 Subject: [IronPython] Reproducing an C# array of floats Message-ID: Hi all, Sorry for the silly question. I'm quite new to ironpython and I've been trying to solve this issue for the last 3 hours. I'm not able to reproduce this code in IronPython. float[] sample = new float[8192/sizeof(float)] I've tried the following but nothing seems to work in my specific case: System.Array.CreateInstance(float, (8192/4)) clr.Reference[System.Array[float]](8192/4) System.Array[float]([(8192/4)]) I'm trying to use the SlimDX to capture the microphone input, and pass it to NumPy to do same FFT stuff. The original C# code is here: http://crsouza.blogspot.com/2009/08/capturing-sound-from-microphone-using.html And here my modified version import clr clr.AddReference('SlimDX') from SlimDX import * from System import * captureDevice = DirectSound.DirectSoundCapture() waveFormat = Multimedia.WaveFormat() waveFormat.FormatTag = Multimedia.WaveFormatTag.IeeeFloat # For Int16, change to Pcm waveFormat.BitsPerSample = 32 # Floats are 32 bits waveFormat.BlockAlignment = (waveFormat.BitsPerSample/8) waveFormat.Channels = 1 waveFormat.SamplesPerSecond = 44100 waveFormat.AverageBytesPerSecond = waveFormat.SamplesPerSecond*waveFormat.BlockAlignment*waveFormat.Channels bufferDescription = DirectSound.CaptureBufferDescription() bufferDescription.BufferBytes = 8192 bufferDescription.Format = waveFormat bufferDescription.WaveMapped = False buffer = DirectSound.CaptureBuffer(captureDevice,bufferDescription) buffer.Start(True) #float[] sample = new float[8192/sizeof(float)]; #sample = Array.CreateInstance(float, (8192/4)) #sample = clr.Reference[Array[float]](8192/4) sample = Array[float]([(8192/4)]) while (True): #print sample print buffer.Read(sample, 0, True); .... which is generating the following error C:\Documents and Settings\Administrator\My Documents>ipy sound_capture_test.py Traceback (most recent call last): File "sound_capture_test.py", line 34, in sound_capture_test.py TypeError: Read() takes at least 2147483647 arguments (3 given) Any help will be very appreciated. Thanks, Daniel _________________________________________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Wed Nov 4 21:20:35 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 4 Nov 2009 20:20:35 +0000 Subject: [IronPython] Reproducing an C# array of floats In-Reply-To: References: Message-ID: <1A472770E042064698CB5ADC83A12ACD04C3D7E4@TK5EX14MBXC118.redmond.corp.microsoft.com> float in Python is actually double in C#. You probably want: from System import Single System.Array.CreateInstance(Single, ...) And so on. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Daniel D. Sent: Wednesday, November 04, 2009 12:12 PM To: users at lists.ironpython.com Subject: [IronPython] Reproducing an C# array of floats Hi all, Sorry for the silly question. I'm quite new to ironpython and I've been trying to solve this issue for the last 3 hours. I'm not able to reproduce this code in IronPython. float[] sample = new float[8192/sizeof(float)] I've tried the following but nothing seems to work in my specific case: System.Array.CreateInstance(float, (8192/4)) clr.Reference[System.Array[float]](8192/4) System.Array[float]([(8192/4)]) I'm trying to use the SlimDX to capture the microphone input, and pass it to NumPy to do same FFT stuff. The original C# code is here: http://crsouza.blogspot.com/2009/08/capturing-sound-from-microphone-using.html And here my modified version import clr clr.AddReference('SlimDX') from SlimDX import * from System import * captureDevice = DirectSound.DirectSoundCapture() waveFormat = Multimedia.WaveFormat() waveFormat.FormatTag = Multimedia.WaveFormatTag.IeeeFloat # For Int16, change to Pcm waveFormat.BitsPerSample = 32 # Floats are 32 bits waveFormat.BlockAlignment = (waveFormat.BitsPerSample/8) waveFormat.Channels = 1 waveFormat.SamplesPerSecond = 44100 waveFormat.AverageBytesPerSecond = waveFormat.SamplesPerSecond*waveFormat.BlockAlignment*waveFormat.Channels bufferDescription = DirectSound.CaptureBufferDescription() bufferDescription.BufferBytes = 8192 bufferDescription.Format = waveFormat bufferDescription.WaveMapped = False buffer = DirectSound.CaptureBuffer(captureDevice,bufferDescription) buffer.Start(True) #float[] sample = new float[8192/sizeof(float)]; #sample = Array.CreateInstance(float, (8192/4)) #sample = clr.Reference[Array[float]](8192/4) sample = Array[float]([(8192/4)]) while (True): #print sample print buffer.Read(sample, 0, True); .... which is generating the following error C:\Documents and Settings\Administrator\My Documents>ipy sound_capture_test.py Traceback (most recent call last): File "sound_capture_test.py", line 34, in sound_capture_test.py TypeError: Read() takes at least 2147483647 arguments (3 given) Any help will be very appreciated. Thanks, Daniel ________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From olomen at hotmail.com Wed Nov 4 21:48:21 2009 From: olomen at hotmail.com (Daniel D.) Date: Wed, 4 Nov 2009 23:48:21 +0300 Subject: [IronPython] Reproducing an C# array of floats In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C3D7E4@TK5EX14MBXC118.redmond.corp.microsoft.com> References: Message-ID: Hi Dino, thanks for the quick reply. Now I'm using System.Single instead float but the error persists. For some reason the Read (ref. http://is.gd/4Ngjt) method of SlimDX.DirectSound.CaptureBuffer isn't accepting the array reference properly. Maybe I should try the Microsoft.DirextX.DirectSound lib, but it's been a little bit difficult to find good references about IronPython+DirectSound (probably by own fault). From: dinov at microsoft.com To: users at lists.ironpython.com Date: Wed, 4 Nov 2009 20:20:35 +0000 Subject: Re: [IronPython] Reproducing an C# array of floats float in Python is actually double in C#. You probably want: from System import Single System.Array.CreateInstance(Single, ?) And so on. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Daniel D. Sent: Wednesday, November 04, 2009 12:12 PM To: users at lists.ironpython.com Subject: [IronPython] Reproducing an C# array of floats Hi all, Sorry for the silly question. I'm quite new to ironpython and I've been trying to solve this issue for the last 3 hours. I'm not able to reproduce this code in IronPython. float[] sample = new float[8192/sizeof(float)] I've tried the following but nothing seems to work in my specific case: System.Array.CreateInstance(float, (8192/4)) clr.Reference[System.Array[float]](8192/4) System.Array[float]([(8192/4)]) I'm trying to use the SlimDX to capture the microphone input, and pass it to NumPy to do same FFT stuff. The original C# code is here: http://crsouza.blogspot.com/2009/08/capturing-sound-from-microphone-using.html And here my modified version import clr clr.AddReference('SlimDX') from SlimDX import * from System import * captureDevice = DirectSound.DirectSoundCapture() waveFormat = Multimedia.WaveFormat() waveFormat.FormatTag = Multimedia.WaveFormatTag.IeeeFloat # For Int16, change to Pcm waveFormat.BitsPerSample = 32 # Floats are 32 bits waveFormat.BlockAlignment = (waveFormat.BitsPerSample/8) waveFormat.Channels = 1 waveFormat.SamplesPerSecond = 44100 waveFormat.AverageBytesPerSecond = waveFormat.SamplesPerSecond*waveFormat.BlockAlignment*waveFormat.Channels bufferDescription = DirectSound.CaptureBufferDescription() bufferDescription.BufferBytes = 8192 bufferDescription.Format = waveFormat bufferDescription.WaveMapped = False buffer = DirectSound.CaptureBuffer(captureDevice,bufferDescription) buffer.Start(True) #float[] sample = new float[8192/sizeof(float)]; #sample = Array.CreateInstance(float, (8192/4)) #sample = clr.Reference[Array[float]](8192/4) sample = Array[float]([(8192/4)]) while (True): #print sample print buffer.Read(sample, 0, True); .... which is generating the following error C:\Documents and Settings\Administrator\My Documents>ipy sound_capture_test.py Traceback (most recent call last): File "sound_capture_test.py", line 34, in sound_capture_test.py TypeError: Read() takes at least 2147483647 arguments (3 given) Any help will be very appreciated. Thanks, Daniel Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. _________________________________________________________________ Windows Live Hotmail: Your friends can get your Facebook updates, right from Hotmail?. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Wed Nov 4 21:58:43 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 4 Nov 2009 20:58:43 +0000 Subject: [IronPython] Reproducing an C# array of floats In-Reply-To: References: Message-ID: <1A472770E042064698CB5ADC83A12ACD04C3D9EF@TK5EX14MBXC118.redmond.corp.microsoft.com> Ahh, read is a generic method and you're getting type inference from C# but not IronPython. IronPython 2.6 includes type inference on generic methods so this might just work there, but otherwise I think you can do: print buffer.Read[Single](sample, 0, True) The square brackets are how we specifiy generic type parameters. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Daniel D. Sent: Wednesday, November 04, 2009 12:48 PM To: users at lists.ironpython.com Subject: Re: [IronPython] Reproducing an C# array of floats Hi Dino, thanks for the quick reply. Now I'm using System.Single instead float but the error persists. For some reason the Read (ref. http://is.gd/4Ngjt) method of SlimDX.DirectSound.CaptureBuffer isn't accepting the array reference properly. Maybe I should try the Microsoft.DirextX.DirectSound lib, but it's been a little bit difficult to find good references about IronPython+DirectSound (probably by own fault). ________________________________ From: dinov at microsoft.com To: users at lists.ironpython.com Date: Wed, 4 Nov 2009 20:20:35 +0000 Subject: Re: [IronPython] Reproducing an C# array of floats float in Python is actually double in C#. You probably want: from System import Single System.Array.CreateInstance(Single, ...) And so on. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Daniel D. Sent: Wednesday, November 04, 2009 12:12 PM To: users at lists.ironpython.com Subject: [IronPython] Reproducing an C# array of floats Hi all, Sorry for the silly question. I'm quite new to ironpython and I've been trying to solve this issue for the last 3 hours. I'm not able to reproduce this code in IronPython. float[] sample = new float[8192/sizeof(float)] I've tried the following but nothing seems to work in my specific case: System.Array.CreateInstance(float, (8192/4)) clr.Reference[System.Array[float]](8192/4) System.Array[float]([(8192/4)]) I'm trying to use the SlimDX to capture the microphone input, and pass it to NumPy to do same FFT stuff. The original C# code is here: http://crsouza.blogspot.com/2009/08/capturing-sound-from-microphone-using.html And here my modified version import clr clr.AddReference('SlimDX') from SlimDX import * from System import * captureDevice = DirectSound.DirectSoundCapture() waveFormat = Multimedia.WaveFormat() waveFormat.FormatTag = Multimedia.WaveFormatTag.IeeeFloat # For Int16, change to Pcm waveFormat.BitsPerSample = 32 # Floats are 32 bits waveFormat.BlockAlignment = (waveFormat.BitsPerSample/8) waveFormat.Channels = 1 waveFormat.SamplesPerSecond = 44100 waveFormat.AverageBytesPerSecond = waveFormat.SamplesPerSecond*waveFormat.BlockAlignment*waveFormat.Channels bufferDescription = DirectSound.CaptureBufferDescription() bufferDescription.BufferBytes = 8192 bufferDescription.Format = waveFormat bufferDescription.WaveMapped = False buffer = DirectSound.CaptureBuffer(captureDevice,bufferDescription) buffer.Start(True) #float[] sample = new float[8192/sizeof(float)]; #sample = Array.CreateInstance(float, (8192/4)) #sample = clr.Reference[Array[float]](8192/4) sample = Array[float]([(8192/4)]) while (True): #print sample print buffer.Read(sample, 0, True); .... which is generating the following error C:\Documents and Settings\Administrator\My Documents>ipy sound_capture_test.py Traceback (most recent call last): File "sound_capture_test.py", line 34, in sound_capture_test.py TypeError: Read() takes at least 2147483647 arguments (3 given) Any help will be very appreciated. Thanks, Daniel ________________________________ Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you. ________________________________ Windows Live Hotmail: Your friends can get your Facebook updates, right from Hotmail(r). -------------- next part -------------- An HTML attachment was scrubbed... URL: From olomen at hotmail.com Wed Nov 4 22:08:27 2009 From: olomen at hotmail.com (Daniel D.) Date: Thu, 5 Nov 2009 00:08:27 +0300 Subject: [IronPython] Reproducing an C# array of floats In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C3D9EF@TK5EX14MBXC118.redmond.corp.microsoft.com> References: Message-ID: Ahh, read is a generic method and you?re getting type inference from C# but not IronPython. IronPython 2.6 includes type inference on generic methods so this might just work there, but otherwise I think you can do: print buffer.Read[Single](sample, 0, True) worked perfectly! thank you so much dino. _________________________________________________________________ Windows Live: Keep your friends up to date with what you do online. http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010 -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhoward at drawloop.com Thu Nov 5 18:57:28 2009 From: jhoward at drawloop.com (Jonathan Howard) Date: Thu, 5 Nov 2009 09:57:28 -0800 Subject: [IronPython] Embedded IronPython 2.6 Module Name Message-ID: Hi, We're trying to upgrade to IronPython 2.6 and are having a number of issues with it. The biggest issue is there doesn't appear to be a way to name the module that runs when you embed your code. We're using the Hosting API to create and run code within C#. The code runs, but we have other modules that are supposed to pull globals from the __main__ module. This worked in 1.1 by setting the DefaultModule on the PythonEngine instance. There doesn't seem to be a way to do this anymore. Any help would be appreciated. ~Jonathan -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhoward at drawloop.com Thu Nov 5 19:38:51 2009 From: jhoward at drawloop.com (Jonathan Howard) Date: Thu, 5 Nov 2009 10:38:51 -0800 Subject: [IronPython] Embedded IronPython 2.6 Module Name Message-ID: Looking further into this, it appears that __name__ is always set to . This is the behavior while trying to just use: Dictionary options = new Dictionary(); ScriptEngine se = Python.CreateEngine(); Console.WriteLine(se.Execute("__name__")); ~Jonathan -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Thu Nov 5 19:45:19 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 5 Nov 2009 11:45:19 -0700 Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: References: Message-ID: I'm not sure if there's a simpler way -- here's what I did a few months back when I needed to publish something via __main__: pythonContext = HostingHelpers.GetLanguageContext(self._engine) module = pythonContext.CreateModule() pythonContext.PublishModule('__main__', module) scope = HostingHelpers.CreateScriptScope(self._engine, module.Scope) scope.SetVariable('__name__', '__main__') scope.SetVariable('__doc__', '') HostingHelpers is a class in the DLR hosting interfaces. From C#, you'd need to explicitly cast the LanguageContext to a PythonContext. After this, you would run your Python code within the "scope" ScriptScope. On Thu, Nov 5, 2009 at 10:57 AM, Jonathan Howard wrote: > Hi, > > We're trying to upgrade to IronPython 2.6 and are having a number of issues > with it. The biggest issue is there doesn't appear to be a way to name the > module that runs when you embed your code. We're using the Hosting API to > create and run code within C#. The code runs, but we have other modules > that are supposed to pull globals from the __main__ module. This worked in > 1.1 by setting the DefaultModule on the PythonEngine instance. There > doesn't seem to be a way to do this anymore. > > Any help would be appreciated. > > ~Jonathan > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jhoward at drawloop.com Thu Nov 5 20:14:31 2009 From: jhoward at drawloop.com (Jonathan Howard) Date: Thu, 5 Nov 2009 11:14:31 -0800 Subject: [IronPython] Embedded IronPython 2.6 Module Name Message-ID: Thanks for the help, Curt. Perhaps it's a problem with the latest, RC? There is no "CreateModule" function on the PythonContext object. ~Jonathan -------------- next part -------------- An HTML attachment was scrubbed... URL: From nbuttarelli at gmail.com Thu Nov 5 20:17:38 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Thu, 5 Nov 2009 20:17:38 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> Again, thanks everyone for your help. But.. I bring bad news. This is still not working and it doesn't depend on the Test environment. I create another proyect, a Form project, with one button which executes the following code: // Creating the permission set to grant other assemblies PermissionSet aRestrictedPermissionSet = new PermissionSet(PermissionState.None); aRestrictedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; List strongNameList = new List(); strongNameList.Add(CreateStrongName(Assembly.GetExecutingAssembly())); AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", AppDomain.CurrentDomain.Evidence, domaininfo, aRestrictedPermissionSet, strongNameList.ToArray()); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); It throws this error: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. I used the fuslogvw application to see if the Microsoft.Scripting is loaded, an it is. What seems strange for me is that anyone has tried this before. I hope to find some more help here. Regards, Nicolas On Wed, Nov 4, 2009 at 7:36 PM, Shri Borde wrote: > http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/has some info about test projects and appbase problems. > > > > You can also use fuslogvw ( > http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to see why > Microsoft.Scripting.dll is failing to load. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Dino Viehland > *Sent:* Tuesday, November 03, 2009 1:52 PM > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Test projects are weird and somehow you don?t end up inheriting the > application base. This seems to work though: > > > > AppDomainSetup setup = new AppDomainSetup(); > > setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed > Domain", null, setup); > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = > engine.CreateScriptSourceFromString("2+2"); > > ScriptScope scope = engine.CreateScope(); > > Console.WriteLine(source.Execute(scope)); > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 1:30 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > I have create a new "Test Project" and an Unit Test class in order to test > the following code inside: > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > > > I have add the references: > > > > - IronPython > > - Microsoft.Scripting > > - Microsoft.ScriptingCore > > > > But it still not working and throwing the > same System.Runtime.Serialization.SerializationException: Type is not > resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. > > > > Any ideas? > > > > > > 2009/11/3 Nicol?s Buttarelli > > Thanks Shri, I will try. > > > > In addition, I found this open issue: > http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that > it is related. > > > > On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: > > I think this happens if the new appdomain cannot load the required > assembly. By default, the new appdomain should inherit its BaseDirectory > property from the creating domain and should be able to load > Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If > not, can you try to put all assemblies in the same folder (or in the GAC) to > see if it works? If that works, you can then figure out how to configure the > new appdomain such that it can load Microsoft.Scripting.dll. There may be > some setting in AppDomainSetup, or you could hook the AssemblyResolve event? > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 12:08 PM > > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Hi again, thanks for your clear response. > > > > I was trying to do what you proposed but it is not working. I am receiving > an exception: > > > > *Test method > CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest > threw exception: System.Runtime.Serialization.SerializationException: Type > is not resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..* > > I tried to find a solution but I couldn't. This is the minimal code that I > am running to get this exception (I have removed all the security stuff but > apparently that does not resolve the problem): > > > > *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain");* > > > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);* > > *SriptScope scope = engine.CreateScope();* > > *source.Execute(scope);* > > > > The exception is thronged in this line: > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > > > > > Do you have any idea which could be the problem? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: > > Assuming the app domain is setup properly then there?s no way for the > Python code to elevate permissions (modulo CLR security bugs which are few > and far between). This is because IronPython its self is 100% security > transparent and does not affect any security decisions or assert any form of > trust ? so it?s all up to the CLR to limit permissions. So for example > while you can access the file object, or import ctypes, or call various > other Python APIs which would require trust you?ll get a security exception > from the CLR when you don?t have permissions to do something. > > > > For more complex scenarios you might also have an object model which you > expose to the application and inject in via its scope. Once you?ve done > that you?ll want to make sure that the object model is also secure. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 1:20 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Thanks for your response. > > > > But what happens with the python code? Does not exist a way to write some > scripts that can do some damage to my app, the server, the database, etc? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland wrote: > > After creating your app domain you can do: > > > > ScriptEngine engine = Python.CreateEngine(someAppDomain); > > > > And then the rest of your code should work as it?s written. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 12:39 PM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Safe execution of python scripts on my .net > application > > > > Sorry, I don't know if my previous message have arrived. So, here it is: > > > > > > Hello all, > > > > I am starting with python and I would like to add to my web application > some web services. This services will allow the different clients of my > application to execute some python scripts. > > > > I would like to know if someone did this before and how can I do this in a > secure way. I mean, how can I do to restrict the environment where the > scripts will be executed. > > > > In .net I can do this using the AppDoman and setting the permission set. > > > > AppDomain.CreateDomain( string friendlyName, > Evidence securityInfo, > AppDomainSetup info, > PermissionSet grantSet, > params StrongName[] fullTrustAssemblies); > > > > > > Is there a way to do the same with my python scripts? > > > > I am running them using this: > > > > ScriptEngine engine = Python.CreateEngine(); > > ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > Thanks in advance. > > Nicolas > > > _______________________________________________ > 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 > > > > > _______________________________________________ > 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Fri Nov 6 01:07:17 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 6 Nov 2009 00:07:17 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C201CB@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911021319m3fecb7abo6568eef2146d757f@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C4C7D0@TK5EX14MBXC118.redmond.corp.microsoft.com> So you've run this as a standalone program and it's failing? In the standalone app are all of the IronPython and DLR DLLs present (IronPython.dll, IronPython.modules.dll, Microsoft.Scripting.Core.dll, Microsoft.Scripting.dll, Microsoft.Dynamic.dll and Micrsoft.Scripting.Extensionattribute.dll)? A slightly modified version of this, dropping the strong name, works just fine for me: using System; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; using IronPython.Hosting; using System.Security; using System.Security.Permissions; class Test { public static void Main(string[] args) { PermissionSet aRestrictedPermissionSet = new PermissionSet(PermissionState.None); aRestrictedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", AppDomain.CurrentDomain.Evidence, domaininfo, aRestrictedPermissionSet); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString("2+2"); ScriptScope scope = engine.CreateScope(); Console.WriteLine(source.Execute(scope)); } } Compile with: csc test.cs /r:Microsoft.Scripting.Core.dll /r:Microsoft.Scripting.dll /r:IronPython.dll And run and it prints 4. Does that not work for you? We also have a different way we do this in our test suite which also works: AppDomainSetup info = new AppDomainSetup(); info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; info.ApplicationName = "Test"; Evidence evidence = new Evidence(); evidence.AddHost(new Zone(SecurityZone.Internet)); AppDomain newDomain = AppDomain.CreateDomain("test", evidence, info); // create runtime in partial trust... ScriptRuntime runtime = Python.CreateRuntime(newDomain); // get the Python engine... ScriptEngine engine = runtime.GetEngine("py"); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Thursday, November 05, 2009 11:18 AM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Again, thanks everyone for your help. But.. I bring bad news. This is still not working and it doesn't depend on the Test environment. I create another proyect, a Form project, with one button which executes the following code: // Creating the permission set to grant other assemblies PermissionSet aRestrictedPermissionSet = new PermissionSet(PermissionState.None); aRestrictedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; List strongNameList = new List(); strongNameList.Add(CreateStrongName(Assembly.GetExecutingAssembly())); AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", AppDomain.CurrentDomain.Evidence, domaininfo, aRestrictedPermissionSet, strongNameList.ToArray()); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); It throws this error: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. I used the fuslogvw application to see if the Microsoft.Scripting is loaded, an it is. What seems strange for me is that anyone has tried this before. I hope to find some more help here. Regards, Nicolas On Wed, Nov 4, 2009 at 7:36 PM, Shri Borde > wrote: http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/ has some info about test projects and appbase problems. You can also use fuslogvw (http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to see why Microsoft.Scripting.dll is failing to load. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Tuesday, November 03, 2009 1:52 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Test projects are weird and somehow you don't end up inheriting the application base. This seems to work though: AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", null, setup); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString("2+2"); ScriptScope scope = engine.CreateScope(); Console.WriteLine(source.Execute(scope)); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 1:30 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application I have create a new "Test Project" and an Unit Test class in order to test the following code inside: AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); I have add the references: - IronPython - Microsoft.Scripting - Microsoft.ScriptingCore But it still not working and throwing the same System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. Any ideas? 2009/11/3 Nicol?s Buttarelli > Thanks Shri, I will try. In addition, I found this open issue: http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that it is related. On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: I think this happens if the new appdomain cannot load the required assembly. By default, the new appdomain should inherit its BaseDirectory property from the creating domain and should be able to load Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If not, can you try to put all assemblies in the same folder (or in the GAC) to see if it works? If that works, you can then figure out how to configure the new appdomain such that it can load Microsoft.Scripting.dll. There may be some setting in AppDomainSetup, or you could hook the AssemblyResolve event... From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 12:08 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Hi again, thanks for your clear response. I was trying to do what you proposed but it is not working. I am receiving an exception: Test method CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw exception: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. I tried to find a solution but I couldn't. This is the minimal code that I am running to get this exception (I have removed all the security stuff but apparently that does not resolve the problem): AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); SriptScope scope = engine.CreateScope(); source.Execute(scope); The exception is thronged in this line: ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); Do you have any idea which could be the problem? Thanks again, Nicolas On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: Assuming the app domain is setup properly then there's no way for the Python code to elevate permissions (modulo CLR security bugs which are few and far between). This is because IronPython its self is 100% security transparent and does not affect any security decisions or assert any form of trust - so it's all up to the CLR to limit permissions. So for example while you can access the file object, or import ctypes, or call various other Python APIs which would require trust you'll get a security exception from the CLR when you don't have permissions to do something. For more complex scenarios you might also have an object model which you expose to the application and inject in via its scope. Once you've done that you'll want to make sure that the object model is also secure. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland > wrote: After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas _______________________________________________ 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 _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From nbuttarelli at gmail.com Fri Nov 6 09:35:15 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Fri, 6 Nov 2009 09:35:15 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C4C7D0@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C20690@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C4C7D0@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <2c2511410911060035j3c9b12c2xa9b023a2fe743dc9@mail.gmail.com> Hi, On Fri, Nov 6, 2009 at 1:07 AM, Dino Viehland wrote: > So you?ve run this as a standalone program and it?s failing? In the > standalone app are all of the IronPython and DLR DLLs present > (IronPython.dll, IronPython.modules.dll, Microsoft.Scripting.Core.dll, > Microsoft.Scripting.dll, Microsoft.Dynamic.dll and > Micrsoft.Scripting.Extensionattribute.dll)? > Yes I have all this dlls present. > > > A slightly modified version of this, dropping the strong name, works just > fine for me: > > > > using System; > > using Microsoft.Scripting; > > using Microsoft.Scripting.Hosting; > > using IronPython.Hosting; > > using System.Security; > > using System.Security.Permissions; > > > > class Test { > > public static void Main(string[] args) { > > > > PermissionSet aRestrictedPermissionSet = new > PermissionSet(PermissionState.None); > > aRestrictedPermissionSet.AddPermission(new > SecurityPermission(SecurityPermissionFlag.Execution)); > > > > AppDomainSetup domaininfo = new AppDomainSetup(); > > domaininfo.ApplicationBase = System.Environment.CurrentDirectory; > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed > Domain", > > AppDomain.CurrentDomain.Evidence, > > domaininfo, > > aRestrictedPermissionSet); > > > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString("2+2"); > > ScriptScope scope = engine.CreateScope(); > > Console.WriteLine(source.Execute(scope)); > > > > } > > } > Great, I will try this after university. Thanks! > Compile with: > > > > csc test.cs /r:Microsoft.Scripting.Core.dll /r:Microsoft.Scripting.dll > /r:IronPython.dll > > > > And run and it prints 4. Does that not work for you? > > > > We also have a different way we do this in our test suite which also works: > > > > AppDomainSetup info = new AppDomainSetup(); > > info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; > > info.ApplicationName = "Test"; > > Evidence evidence = new Evidence(); > > evidence.AddHost(new Zone(SecurityZone.Internet)); > > AppDomain newDomain = AppDomain.CreateDomain("test", evidence, > info); > > > > // create runtime in partial trust... > > ScriptRuntime runtime = Python.CreateRuntime(newDomain); > > > > // get the Python engine... > > ScriptEngine engine = runtime.GetEngine("py"); > This make sense too, I will try it. Thanks again. > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Thursday, November 05, 2009 11:18 AM > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Again, thanks everyone for your help. > > > > But.. I bring bad news. This is still not working and it doesn't depend on > the Test environment. > > > > I create another proyect, a Form project, with one button which executes > the following code: > > > > // Creating the permission set to grant other assemblies > > PermissionSet aRestrictedPermissionSet = new > PermissionSet(PermissionState.None); > > aRestrictedPermissionSet.AddPermission(new > SecurityPermission(SecurityPermissionFlag.Execution)); > > > > AppDomainSetup domaininfo = new AppDomainSetup(); > > domaininfo.ApplicationBase = System.Environment.CurrentDirectory; > > > > List strongNameList = new List(); > > strongNameList.Add(CreateStrongName(Assembly.GetExecutingAssembly())); > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", > > > AppDomain.CurrentDomain.Evidence, > > > domaininfo, > > > aRestrictedPermissionSet, > > > strongNameList.ToArray()); > > > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > It throws this error: > > Type is not resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. > > > > I used the fuslogvw application to see if the Microsoft.Scripting is > loaded, an it is. > > > > What seems strange for me is that anyone has tried this before. I hope to > find some more help here. > > > > Regards, > > Nicolas > > > > > > On Wed, Nov 4, 2009 at 7:36 PM, Shri Borde > wrote: > > http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/has some info about test projects and appbase problems. > > > > You can also use fuslogvw ( > http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx)to see why Microsoft.Scripting.dll is failing to load. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Dino Viehland > *Sent:* Tuesday, November 03, 2009 1:52 PM > > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Test projects are weird and somehow you don?t end up inheriting the > application base. This seems to work though: > > > > AppDomainSetup setup = new AppDomainSetup(); > > setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed > Domain", null, setup); > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = > engine.CreateScriptSourceFromString("2+2"); > > ScriptScope scope = engine.CreateScope(); > > Console.WriteLine(source.Execute(scope)); > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 1:30 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > I have create a new "Test Project" and an Unit Test class in order to test > the following code inside: > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > > > I have add the references: > > > > - IronPython > > - Microsoft.Scripting > > - Microsoft.ScriptingCore > > > > But it still not working and throwing the > same System.Runtime.Serialization.SerializationException: Type is not > resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. > > > > Any ideas? > > > > > > 2009/11/3 Nicol?s Buttarelli > > Thanks Shri, I will try. > > > > In addition, I found this open issue: > http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that > it is related. > > > > On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: > > I think this happens if the new appdomain cannot load the required > assembly. By default, the new appdomain should inherit its BaseDirectory > property from the creating domain and should be able to load > Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If > not, can you try to put all assemblies in the same folder (or in the GAC) to > see if it works? If that works, you can then figure out how to configure the > new appdomain such that it can load Microsoft.Scripting.dll. There may be > some setting in AppDomainSetup, or you could hook the AssemblyResolve event? > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 12:08 PM > > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Hi again, thanks for your clear response. > > > > I was trying to do what you proposed but it is not working. I am receiving > an exception: > > > > *Test method > CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest > threw exception: System.Runtime.Serialization.SerializationException: Type > is not resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..* > > I tried to find a solution but I couldn't. This is the minimal code that I > am running to get this exception (I have removed all the security stuff but > apparently that does not resolve the problem): > > > > *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain");* > > > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);* > > *SriptScope scope = engine.CreateScope();* > > *source.Execute(scope);* > > > > The exception is thronged in this line: > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > > > > > Do you have any idea which could be the problem? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: > > Assuming the app domain is setup properly then there?s no way for the > Python code to elevate permissions (modulo CLR security bugs which are few > and far between). This is because IronPython its self is 100% security > transparent and does not affect any security decisions or assert any form of > trust ? so it?s all up to the CLR to limit permissions. So for example > while you can access the file object, or import ctypes, or call various > other Python APIs which would require trust you?ll get a security exception > from the CLR when you don?t have permissions to do something. > > > > For more complex scenarios you might also have an object model which you > expose to the application and inject in via its scope. Once you?ve done > that you?ll want to make sure that the object model is also secure. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 1:20 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Thanks for your response. > > > > But what happens with the python code? Does not exist a way to write some > scripts that can do some damage to my app, the server, the database, etc? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland wrote: > > After creating your app domain you can do: > > > > ScriptEngine engine = Python.CreateEngine(someAppDomain); > > > > And then the rest of your code should work as it?s written. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 12:39 PM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Safe execution of python scripts on my .net > application > > > > Sorry, I don't know if my previous message have arrived. So, here it is: > > > > > > Hello all, > > > > I am starting with python and I would like to add to my web application > some web services. This services will allow the different clients of my > application to execute some python scripts. > > > > I would like to know if someone did this before and how can I do this in a > secure way. I mean, how can I do to restrict the environment where the > scripts will be executed. > > > > In .net I can do this using the AppDoman and setting the permission set. > > > > AppDomain.CreateDomain( string friendlyName, > Evidence securityInfo, > AppDomainSetup info, > PermissionSet grantSet, > params StrongName[] fullTrustAssemblies); > > > > > > Is there a way to do the same with my python scripts? > > > > I am running them using this: > > > > ScriptEngine engine = Python.CreateEngine(); > > ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > Thanks in advance. > > Nicolas > > > _______________________________________________ > 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 > > > > > _______________________________________________ > 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 > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jozef.alexovic at gmail.com Fri Nov 6 15:19:54 2009 From: jozef.alexovic at gmail.com (Jozef) Date: Fri, 6 Nov 2009 15:19:54 +0100 Subject: [IronPython] What's wrong with IronPython (UIAutomation) Message-ID: Hi, I'm using UIAutomation framework with IronPython to test our application. For WPF dialogs it works perfectly. But I run into trouble when try to use it for some older dialogs. The problem: With IronPython I'm not able to get proper control type. Any controls appears as ControlType.Pane Simple example: (with windows calculator) --------------------------------------- IP Code ------------------------------------------------------ import clr clr.AddReference('UIAutomationClient') clr.AddReference('UIAutomationTypes') from System.Windows.Automation import * _rootElement = AutomationElement.RootElement if __name__ == '__main__': nameCondition = PropertyCondition(AutomationElement.NameProperty, "Calculator") typeCondition = PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window) calcCondition = AndCondition(nameCondition, typeCondition) appCalc = _rootElement.FindFirst(TreeScope.Children, calcCondition) if appCalc is not None: isFocusable = appCalc.GetCurrentPropertyValue(AutomationElement.IsKeyboardFocusableProperty, True) if isFocusable: #appCalc.SetFocus() #calling this raise: System.InvalidOperationException pass contList = appCalc.FindAll(TreeScope.Subtree, Condition.TrueCondition) for elm in contList: progName = elm.Current.ControlType.ProgrammaticName print progName ----------------------------------------------------------------------------------------------------------- above code produce following output: ControlType.Window ControlType.Pane ControlType.Pane ControlType.Pane ControlType.Pane ControlType.Pane . . . similar C# code works as expected ------------------------------------------ C# Code --------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Automation; using Automation = System.Windows.Automation; namespace UIAutTest { class Program { static void Main(string[] args) { AutomationElement rootElement = AutomationElement.RootElement; Automation.Condition nameCondition = new PropertyCondition(AutomationElement.NameProperty, "Calculator"); Automation.Condition controlCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window); Automation.Condition calcCondition = new AndCondition(nameCondition, controlCondition); AutomationElement appCalc = rootElement.FindFirst(TreeScope.Children, calcCondition); if (appCalc != null) { appCalc.SetFocus(); AutomationElementCollection allCont = appCalc.FindAll(TreeScope.Subtree, Condition.TrueCondition); foreach (AutomationElement elm in allCont) { string contProgNam = elm.Current.ControlType.ProgrammaticName; Console.WriteLine(contProgNam); } } } } } --------------------------------------------------------------------------------------------- C# code produce this output: ControlType.Window ControlType.Edit ControlType.CheckBox ControlType.CheckBox ControlType.Group ControlType.Button ControlType.RadioButton ControlType.RadioButton ControlType.RadioButton ControlType.RadioButton ControlType.Group ControlType.Group ControlType.RadioButton ControlType.RadioButton ControlType.RadioButton ControlType.Button . . Does anybody know why ControlType property retrieved by IP code is different then ControlType retrieved by C# ? Others element properties retrieved by IP code seems to by OK. Info: Windows Vista Business, SP2 IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4200 Thanks, Jozef PS: Duane Kaufman, send similar question : http://lists.ironpython.com/htdig.cgi/users-ironpython.com/2009-June/010693.html . But, no one answer him. -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Fri Nov 6 17:53:40 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Fri, 6 Nov 2009 08:53:40 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <0230f375-abcb-4177-a3f5-861dd48833a0@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61130. ADDED SOURCES $/IronPython/IronPython_Main/Src/Tests/modules/io_related/_fileio_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/codecs_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/cPickle_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/_bytesio_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/binascii_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/copy_reg_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related $/IronPython/IronPython_Main/Src/Tests/modules/io_related/cStringIO_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/marshal_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/re_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc $/IronPython/IronPython_Main/Src/Tests/modules/misc/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_random_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_sha256.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_sha512.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_warnings_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_weakref_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/datetime_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/future_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/math_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/operator_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/system_namespaces.py $/IronPython/IronPython_Main/Src/Tests/modules/network_related $/IronPython/IronPython_Main/Src/Tests/modules/network_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/network_related/_ssl_test.py $/IronPython/IronPython_Main/Src/Tests/modules/network_related/socket_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related $/IronPython/IronPython_Main/Src/Tests/modules/system_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/_locale_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/gc_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/nt_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/sys_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/thread_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/time_test.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related $/IronPython/IronPython_Main/Src/Tests/modules/type_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/_struct_test.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/array_test.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/types_test.py DELETED SOURCES $/IronPython/IronPython_Main/Src/Tests/modules/_fileio_test.py $/IronPython/IronPython_Main/Src/Tests/modules/array_test.py $/IronPython/IronPython_Main/Src/Tests/modules/_bytesio_test.py $/IronPython/IronPython_Main/Src/Tests/modules/_warnings_test.py $/IronPython/IronPython_Main/Src/Tests/modules/_ssl_test.py $/IronPython/IronPython_Main/Src/Tests/modules/_sha256.py $/IronPython/IronPython_Main/Src/Tests/modules/system_namespaces.py $/IronPython/IronPython_Main/Src/Tests/modules/_sha512.py $/IronPython/IronPython_Main/Src/Tests/modules/types_test.py $/IronPython/IronPython_Main/Src/Tests/test_copy_reg.py $/IronPython/IronPython_Main/Src/Tests/test_future.py $/IronPython/IronPython_Main/Src/Tests/test_datetime.py $/IronPython/IronPython_Main/Src/Tests/test_cStringIO.py $/IronPython/IronPython_Main/Src/Tests/test_cPickle.py $/IronPython/IronPython_Main/Src/Tests/test_codecs.py $/IronPython/IronPython_Main/Src/Tests/test_binascii.py $/IronPython/IronPython_Main/Src/Tests/test_nt.py $/IronPython/IronPython_Main/Src/Tests/test_locale.py $/IronPython/IronPython_Main/Src/Tests/test_re.py $/IronPython/IronPython_Main/Src/Tests/test_random.py $/IronPython/IronPython_Main/Src/Tests/test_operator.py $/IronPython/IronPython_Main/Src/Tests/test_math.py $/IronPython/IronPython_Main/Src/Tests/test_marshal.py $/IronPython/IronPython_Main/Src/Tests/test_gc.py $/IronPython/IronPython_Main/Src/Tests/test_sys.py $/IronPython/IronPython_Main/Src/Tests/test_thread.py $/IronPython/IronPython_Main/Src/Tests/test_struct.py $/IronPython/IronPython_Main/Src/Tests/test_socket.py $/IronPython/IronPython_Main/Src/Tests/test_time.py $/IronPython/IronPython_Main/Src/Tests/test_weakref.py MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Tests/modules/io_related/_fileio_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/codecs_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/cPickle_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/_bytesio_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/binascii_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/copy_reg_test.py $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicLanguageConfig.cs $/IronPython/IronPython_Main/Src/Tests/modules/io_related/cStringIO_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/marshal_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/re_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_random_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_sha256.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_sha512.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_warnings_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_weakref_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/datetime_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/future_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/math_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/operator_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/system_namespaces.py $/IronPython/IronPython_Main/Src/Tests/modules/network_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/network_related/_ssl_test.py $/IronPython/IronPython_Main/Src/Tests/modules/network_related/socket_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/_locale_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/gc_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/nt_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/sys_test.py $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Repl.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicApplication.cs $/IronPython/IronPython_Main/Src/Tests/modules/system_related/thread_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/time_test.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/__init__.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/_struct_test.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/array_test.py $/IronPython/IronPython_Main/Src/Tests/modules/type_related/types_test.py $/IronPython/IronPython_Main/Src/Tests/RunAgainstCpy.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1255422 Date: 11/5/2009 10:12:03 AM (dfugate) - throughput improvements to RowanTest.vsmdi (e.g., two COM interop test lists now) - moved nearly all of our standard module tests to IronPython\Tests\modules\* - cpy.bat: pass the "-B" flag so we don't generate *.pyc files - copy_reg_test.py: this test corrupted copy_reg._reconstructor without restoring it. This causes issues when running copy_reg_test with other tests in the same process. Fixed - fixes an ancient issue WRT to running test_math.py under CPy (Shelveset: SNAP_IMPROVE02;REDMOND\dfugate | SNAP CheckinId: 9755) -------------------------------------------------------------------------------- Changeset Id: 1257061 Date: 11/5/2009 10:35:08 PM (jimmysch) Fixes: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25174 Files modified: DynamicLanguageConfig.cs Makes the language.config file optional again as far as Microsoft.Scripting.Silverlight is concerned. Fixes: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25209 Files modified: DynamicApplication.cs, Repl.cs, and python\index.html The "console" initParam was broken. Now it shows the Repl for the first used language. Provides a handle to the Repl (DynamicApplication.Current.Console) to access the OutputBuffer property if the app wants to redirect output to it. The output-redirection should happen by default, but that'll be a fix for 2.6.1. Does NOT fix http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25208; this will be checked directly into the 2.6 branch. (Shelveset: ipy-rc2-fixes;REDMOND\jimmysch | SNAP CheckinId: 9765) From Shri.Borde at microsoft.com Fri Nov 6 19:18:53 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Fri, 6 Nov 2009 18:18:53 +0000 Subject: [IronPython] What's wrong with IronPython (UIAutomation) In-Reply-To: References: Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C7B706E@TK5EX14MBXC140.redmond.corp.microsoft.com> In the past, there had been issues with UIAutomation as mentioned in http://blogs.msdn.com/shrib/archive/2008/03/24/ironpython-cannot-call-automationelement-fromhandle.aspx. This could be related. You could try it on Win7 to see if its fixed. You can also try the techniques mentioned in http://blogs.msdn.com/shrib/archive/2008/03/24/what-if-a-c-snippet-does-not-work-when-transliterated-to-ironpython.aspx to narrow down the problem. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jozef Sent: Friday, November 06, 2009 6:20 AM To: users at lists.ironpython.com Subject: [IronPython] What's wrong with IronPython (UIAutomation) Hi, I'm using UIAutomation framework with IronPython to test our application. For WPF dialogs it works perfectly. But I run into trouble when try to use it for some older dialogs. The problem: With IronPython I'm not able to get proper control type. Any controls appears as ControlType.Pane Simple example: (with windows calculator) --------------------------------------- IP Code ------------------------------------------------------ import clr clr.AddReference('UIAutomationClient') clr.AddReference('UIAutomationTypes') from System.Windows.Automation import * _rootElement = AutomationElement.RootElement if __name__ == '__main__': nameCondition = PropertyCondition(AutomationElement.NameProperty, "Calculator") typeCondition = PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window) calcCondition = AndCondition(nameCondition, typeCondition) appCalc = _rootElement.FindFirst(TreeScope.Children, calcCondition) if appCalc is not None: isFocusable = appCalc.GetCurrentPropertyValue(AutomationElement.IsKeyboardFocusableProperty, True) if isFocusable: #appCalc.SetFocus() #calling this raise: System.InvalidOperationException pass contList = appCalc.FindAll(TreeScope.Subtree, Condition.TrueCondition) for elm in contList: progName = elm.Current.ControlType.ProgrammaticName print progName ----------------------------------------------------------------------------------------------------------- above code produce following output: ControlType.Window ControlType.Pane ControlType.Pane ControlType.Pane ControlType.Pane ControlType.Pane . . . similar C# code works as expected ------------------------------------------ C# Code --------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Automation; using Automation = System.Windows.Automation; namespace UIAutTest { class Program { static void Main(string[] args) { AutomationElement rootElement = AutomationElement.RootElement; Automation.Condition nameCondition = new PropertyCondition(AutomationElement.NameProperty, "Calculator"); Automation.Condition controlCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window); Automation.Condition calcCondition = new AndCondition(nameCondition, controlCondition); AutomationElement appCalc = rootElement.FindFirst(TreeScope.Children, calcCondition); if (appCalc != null) { appCalc.SetFocus(); AutomationElementCollection allCont = appCalc.FindAll(TreeScope.Subtree, Condition.TrueCondition); foreach (AutomationElement elm in allCont) { string contProgNam = elm.Current.ControlType.ProgrammaticName; Console.WriteLine(contProgNam); } } } } } --------------------------------------------------------------------------------------------- C# code produce this output: ControlType.Window ControlType.Edit ControlType.CheckBox ControlType.CheckBox ControlType.Group ControlType.Button ControlType.RadioButton ControlType.RadioButton ControlType.RadioButton ControlType.RadioButton ControlType.Group ControlType.Group ControlType.RadioButton ControlType.RadioButton ControlType.RadioButton ControlType.Button . . Does anybody know why ControlType property retrieved by IP code is different then ControlType retrieved by C# ? Others element properties retrieved by IP code seems to by OK. Info: Windows Vista Business, SP2 IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4200 Thanks, Jozef PS: Duane Kaufman, send similar question : http://lists.ironpython.com/htdig.cgi/users-ironpython.com/2009-June/010693.html. But, no one answer him. -------------- next part -------------- An HTML attachment was scrubbed... URL: From janrou at gmail.com Fri Nov 6 20:07:53 2009 From: janrou at gmail.com (Jan Rouvillain) Date: Fri, 6 Nov 2009 20:07:53 +0100 Subject: [IronPython] System.TimeSpan can't add time from IronPython Message-ID: Hi, System.TimeSpan does not add time when using Add: >>> clr.AddReference('System') >>> span = System.TimeSpan(1,0,0) >>> span.ToString() '01:00:00' >>> hour = System.TimeSpan(1,0,0) >>> hour.ToString() '01:00:00' >>> span.Add(hour) >>> span.ToString() '01:00:00' Should have been '02:00:00', because 1 hour is added. Regards Jan Rou -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Fri Nov 6 20:13:40 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 6 Nov 2009 19:13:40 +0000 Subject: [IronPython] System.TimeSpan can't add time from IronPython In-Reply-To: References: Message-ID: <1A472770E042064698CB5ADC83A12ACD04C5678E@TK5EX14MBXC118.redmond.corp.microsoft.com> span.Add() returns a new TimeSpan object, it does not mutate the existing object. You can see that the result of span.Add(hour) printed out the 2:00:00 time span in the repl that was returned. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jan Rouvillain Sent: Friday, November 06, 2009 11:08 AM To: Discussion of IronPython Subject: [IronPython] System.TimeSpan can't add time from IronPython Hi, System.TimeSpan does not add time when using Add: >>> clr.AddReference('System') >>> span = System.TimeSpan(1,0,0) >>> span.ToString() '01:00:00' >>> hour = System.TimeSpan(1,0,0) >>> hour.ToString() '01:00:00' >>> span.Add(hour) >>> span.ToString() '01:00:00' Should have been '02:00:00', because 1 hour is added. Regards Jan Rou -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Fri Nov 6 22:58:38 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Fri, 06 Nov 2009 22:58:38 +0100 Subject: [IronPython] DataBinding and INotifyPropertyChanged in IronPython Message-ID: <4AF49C0E.7080503@bakalari.cz> Hi all, I was looking for WPF data binding in IronPython and I have found nice Japanese blog about it: http://palepoli.skr.jp/wp/2009/06/28/wpf-listview-databinding-for-ironpython/ It links to http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=30322 that should have more information about how to implement INotifyPropertyChanged in IronPython which I am also interested in. Unfortunately this page is no more available. Does the guideline exist somewhere else? Thanks. PS: I know about http://lists.ironpython.com/pipermail/users-ironpython.com/2009-August/010938.html but I don't think using __setattr__ is good approach. Also implementing the PropertyChanged event is different on the blog. -- -- Luk?? From curt at hagenlocher.org Fri Nov 6 23:14:26 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 6 Nov 2009 15:14:26 -0700 Subject: [IronPython] DataBinding and INotifyPropertyChanged in IronPython In-Reply-To: <4AF49C0E.7080503@bakalari.cz> References: <4AF49C0E.7080503@bakalari.cz> Message-ID: Why don't you think that __setattr__ is a good approach? The alternative (as shown in the linked Japanese-language blog) is to implement setters for the properties you care about and to manually trigger the event. 2009/11/6 Lukas Cenovsky > Hi all, > I was looking for WPF data binding in IronPython and I have found nice > Japanese blog about it: > > http://palepoli.skr.jp/wp/2009/06/28/wpf-listview-databinding-for-ironpython/ > > It links to http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=30322that should have more information about how to implement > INotifyPropertyChanged in IronPython which I am also interested in. > Unfortunately this page is no more available. Does the guideline exist > somewhere else? Thanks. > > PS: I know about > http://lists.ironpython.com/pipermail/users-ironpython.com/2009-August/010938.htmlbut I don't think using __setattr__ is good approach. Also implementing the > PropertyChanged event is different on the blog. > > -- > -- Luk?? > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Fri Nov 6 23:18:20 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 6 Nov 2009 15:18:20 -0700 Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: References: Message-ID: It looks like you can just create the PythonModule directly now -- it's a public class with a public constructor. On Thu, Nov 5, 2009 at 12:14 PM, Jonathan Howard wrote: > Thanks for the help, Curt. Perhaps it's a problem with the latest, RC? > There is no "CreateModule" function on the PythonContext object. > > ~Jonathan > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Fri Nov 6 23:22:15 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Fri, 6 Nov 2009 22:22:15 +0000 Subject: [IronPython] DataBinding and INotifyPropertyChanged in IronPython In-Reply-To: <4AF49C0E.7080503@bakalari.cz> References: <4AF49C0E.7080503@bakalari.cz> Message-ID: <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> > It links to http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=30322 > that should have more information about how to implement > INotifyPropertyChanged in IronPython which I am also interested in. > Unfortunately this page is no more available. Does the guideline exist > somewhere else? Thanks. I've re-enabled the discussions tab on that defunct project, so that link is now active again. From fuzzyman at voidspace.org.uk Mon Nov 9 10:28:00 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 09 Nov 2009 10:28:00 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden Message-ID: <4AF7E0A0.2070406@voidspace.org.uk> Hello guys, IronPython 2.6 Release Candidate 2 supersedes Release Candidate 1, so the RC 1 download has been set to hidden. This means that it is no longer available to choose from the list of downloads and links to the download page are now effectively broken. If you have wiki admin rights on the IronPython codeplex site then you will still be able to view the page if you are logged in. To see what I mean you will have to log out first. It seems to me a bad policy to hide released versions... Michael -- http://www.ironpythoninaction.com/ From Jimmy.Schementi at microsoft.com Mon Nov 9 10:35:04 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Mon, 9 Nov 2009 09:35:04 +0000 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <4AF7E0A0.2070406@voidspace.org.uk> References: <4AF7E0A0.2070406@voidspace.org.uk> Message-ID: <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> I agree, but I think the desire it to keep that "Releases" list clean. Otherwise it would have every release ever in there. It's a CodePlex limitation that there is no way to hide those releases from that list, while still keeping the links active. Here are all the hidden releases; basically all superseded non-final releases: 2.6 Release Candidate 1 2.6 Beta 2 2.6 Beta 1 2.6 Alpha 1 2.0 Release Candidate 2 2.0 VS10 CTP 2.0 Release Candidate 1 2.0 Beta 5 2.0 Beta 4 1.1.2 RC1 2.0 Beta 3 2.0 Beta 2 2.0 Beta 1 2.0 Alpha 8 1.1.1 RC1 2.0 Alpha 7 2.0 Alpha 6 2.0 Alpha 5 2.0 Alpha 4 2.0 Alpha 3 2.0 Alpha 2 2.0 Alpha 1 1.1 First Release Candidate 1.1 Beta 1.1 Alpha 1.0 2nd Release Candidate 1.0 Release Candidate 1.0 9th Beta 1.0 8th Beta 1.0 7th Beta ~Jimmy > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Monday, November 09, 2009 1:28 AM > To: Discussion of IronPython > Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Hello guys, > > IronPython 2.6 Release Candidate 2 supersedes Release Candidate 1, so the RC > 1 download has been set to hidden. This means that it is no longer available > to choose from the list of downloads and links to the download page are now > effectively broken. > > If you have wiki admin rights on the IronPython codeplex site then you will > still be able to view the page if you are logged in. To see what I mean you > will have to log out first. > > It seems to me a bad policy to hide released versions... > > Michael > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Mon Nov 9 10:46:50 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 09 Nov 2009 10:46:50 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> References: <4AF7E0A0.2070406@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> Message-ID: <4AF7E50A.1030509@voidspace.org.uk> Jimmy Schementi wrote: > I agree, but I think the desire it to keep that "Releases" list clean. Otherwise it would have every release ever in there. It's a CodePlex limitation that there is no way to hide those releases from that list, while still keeping the links active. > I understand the motivation, but making releases that people / projects may have depended on is an unacceptable cost in my opinion. All the best, Michael > Here are all the hidden releases; basically all superseded non-final releases: > > 2.6 Release Candidate 1 > 2.6 Beta 2 > 2.6 Beta 1 > 2.6 Alpha 1 > 2.0 Release Candidate 2 > 2.0 VS10 CTP > 2.0 Release Candidate 1 > 2.0 Beta 5 > 2.0 Beta 4 > 1.1.2 RC1 > 2.0 Beta 3 > 2.0 Beta 2 > 2.0 Beta 1 > 2.0 Alpha 8 > 1.1.1 RC1 > 2.0 Alpha 7 > 2.0 Alpha 6 > 2.0 Alpha 5 > 2.0 Alpha 4 > 2.0 Alpha 3 > 2.0 Alpha 2 > 2.0 Alpha 1 > 1.1 First Release Candidate > 1.1 Beta > 1.1 Alpha > 1.0 2nd Release Candidate > 1.0 Release Candidate > 1.0 9th Beta > 1.0 8th Beta > 1.0 7th Beta > > ~Jimmy > > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Michael Foord >> Sent: Monday, November 09, 2009 1:28 AM >> To: Discussion of IronPython >> Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> Hello guys, >> >> IronPython 2.6 Release Candidate 2 supersedes Release Candidate 1, so the RC >> 1 download has been set to hidden. This means that it is no longer available >> to choose from the list of downloads and links to the download page are now >> effectively broken. >> >> If you have wiki admin rights on the IronPython codeplex site then you will >> still be able to view the page if you are logged in. To see what I mean you >> will have to log out first. >> >> It seems to me a bad policy to hide released versions... >> >> Michael >> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 > -- http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Mon Nov 9 11:04:40 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 09 Nov 2009 11:04:40 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <4AF7E50A.1030509@voidspace.org.uk> References: <4AF7E0A0.2070406@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> Message-ID: <4AF7E938.1030807@voidspace.org.uk> Michael Foord wrote: > Jimmy Schementi wrote: >> I agree, but I think the desire it to keep that "Releases" list >> clean. Otherwise it would have every release ever in there. It's a >> CodePlex limitation that there is no way to hide those releases from >> that list, while still keeping the links active. >> > > I understand the motivation, but making releases that people / > projects may have depended on is an unacceptable cost in my opinion. > As an addendum, if you need them many of the hidden releases are still available from the downloads page on the IronPython Cookbook: http://www.ironpython.info/index.php/Downloads All the best, Michael Foord > All the best, > > Michael >> Here are all the hidden releases; basically all superseded non-final >> releases: >> >> 2.6 Release Candidate 1 >> 2.6 Beta 2 2.6 Beta 1 >> 2.6 Alpha 1 2.0 Release Candidate 2 >> 2.0 VS10 CTP >> 2.0 Release Candidate 1 >> 2.0 Beta 5 >> 2.0 Beta 4 >> 1.1.2 RC1 >> 2.0 Beta 3 >> 2.0 Beta 2 >> 2.0 Beta 1 >> 2.0 Alpha 8 >> 1.1.1 RC1 >> 2.0 Alpha 7 >> 2.0 Alpha 6 >> 2.0 Alpha 5 >> 2.0 Alpha 4 >> 2.0 Alpha 3 >> 2.0 Alpha 2 >> 2.0 Alpha 1 >> 1.1 First Release Candidate >> 1.1 Beta >> 1.1 Alpha >> 1.0 2nd Release Candidate >> 1.0 Release Candidate >> 1.0 9th Beta >> 1.0 8th Beta >> 1.0 7th Beta >> >> ~Jimmy >> >> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users- >>> bounces at lists.ironpython.com] On Behalf Of Michael Foord >>> Sent: Monday, November 09, 2009 1:28 AM >>> To: Discussion of IronPython >>> Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden >>> >>> Hello guys, >>> >>> IronPython 2.6 Release Candidate 2 supersedes Release Candidate 1, >>> so the RC >>> 1 download has been set to hidden. This means that it is no longer >>> available >>> to choose from the list of downloads and links to the download page >>> are now >>> effectively broken. >>> >>> If you have wiki admin rights on the IronPython codeplex site then >>> you will >>> still be able to view the page if you are logged in. To see what I >>> mean you >>> will have to log out first. >>> >>> It seems to me a bad policy to hide released versions... >>> >>> Michael >>> >>> -- >>> http://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> 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 >> > > -- http://www.ironpythoninaction.com/ From nbuttarelli at gmail.com Mon Nov 9 16:48:32 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Mon, 9 Nov 2009 16:48:32 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911060035j3c9b12c2xa9b023a2fe743dc9@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C4C7D0@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911060035j3c9b12c2xa9b023a2fe743dc9@mail.gmail.com> Message-ID: <2c2511410911090748n6e9c66cem5b601627e54bdf75@mail.gmail.com> Hi all again, I am still working with the same problem. Now I am creating the appDomain in this way by recommendation of Dino: *public static AppDomain CreateSandboxAppDomain()* * {* * AppDomainSetup anAppDomainSetup = new AppDomainSetup();* * anAppDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;* * anAppDomainSetup.ApplicationName = "Testing";* * Evidence evidence = new Evidence();* * evidence.AddHost(new Zone(SecurityZone.Internet));* * * * AppDomain aSandboxedDomain = AppDomain.CreateDomain("Test Domain", * * evidence, * * anAppDomainSetup);* * * * return aSandboxedDomain;* * }* Now it is working but I have security restrictions over some .dll that I want to have full trusted permissions. I am trying to do this: *string aPythonScript =* *@"aDocument = CDLDocument()* *aFigure = TextBlock(1, 'type 1')* *anotherFigure = TextBlock(2, 'type 2')* *aDocument.AddFigure(aFigure)* *aDocument.AddFigure(anotherFigure)* *aList = aDocument.Figures* *";* * * *ScriptSource source = engine.CreateScriptSourceFromString(aPythonScript);* *ScriptScope scope = engine.CreateScope();* * * *scope.SetVariable("CDLDocument", typeof(CDLDocument));* *scope.SetVariable("TextBlock", typeof(TextBlock));* *source.Execute(scope);* This is throwing the System.Security.SecurityException. 1. How can I give full trusted to a specific dll in an AppDomain? 2. How can I include a .dll to the scope instead of do a SetVariable for each type which I have to manage from the python script? Thanks! Nicol?s 2009/11/6 Nicol?s Buttarelli > Hi, > > On Fri, Nov 6, 2009 at 1:07 AM, Dino Viehland wrote: > >> So you?ve run this as a standalone program and it?s failing? In the >> standalone app are all of the IronPython and DLR DLLs present >> (IronPython.dll, IronPython.modules.dll, Microsoft.Scripting.Core.dll, >> Microsoft.Scripting.dll, Microsoft.Dynamic.dll and >> Micrsoft.Scripting.Extensionattribute.dll)? >> > Yes I have all this dlls present. > >> >> >> A slightly modified version of this, dropping the strong name, works just >> fine for me: >> >> >> >> using System; >> >> using Microsoft.Scripting; >> >> using Microsoft.Scripting.Hosting; >> >> using IronPython.Hosting; >> >> using System.Security; >> >> using System.Security.Permissions; >> >> >> >> class Test { >> >> public static void Main(string[] args) { >> >> >> >> PermissionSet aRestrictedPermissionSet = new >> PermissionSet(PermissionState.None); >> >> aRestrictedPermissionSet.AddPermission(new >> SecurityPermission(SecurityPermissionFlag.Execution)); >> >> >> >> AppDomainSetup domaininfo = new AppDomainSetup(); >> >> domaininfo.ApplicationBase = System.Environment.CurrentDirectory; >> >> >> >> AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed >> Domain", >> >> AppDomain.CurrentDomain.Evidence, >> >> domaininfo, >> >> aRestrictedPermissionSet); >> >> >> >> ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); >> >> ScriptSource source = engine.CreateScriptSourceFromString("2+2"); >> >> ScriptScope scope = engine.CreateScope(); >> >> Console.WriteLine(source.Execute(scope)); >> >> >> >> } >> >> } >> > > Great, I will try this after university. Thanks! > >> Compile with: >> >> >> >> csc test.cs /r:Microsoft.Scripting.Core.dll /r:Microsoft.Scripting.dll >> /r:IronPython.dll >> >> >> >> And run and it prints 4. Does that not work for you? >> >> >> >> We also have a different way we do this in our test suite which also >> works: >> >> >> >> AppDomainSetup info = new AppDomainSetup(); >> >> info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; >> >> info.ApplicationName = "Test"; >> >> Evidence evidence = new Evidence(); >> >> evidence.AddHost(new Zone(SecurityZone.Internet)); >> >> AppDomain newDomain = AppDomain.CreateDomain("test", evidence, >> info); >> >> >> >> // create runtime in partial trust... >> >> ScriptRuntime runtime = Python.CreateRuntime(newDomain); >> >> >> >> // get the Python engine... >> >> ScriptEngine engine = runtime.GetEngine("py"); >> > > This make sense too, I will try it. Thanks again. > >> >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Thursday, November 05, 2009 11:18 AM >> >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Again, thanks everyone for your help. >> >> >> >> But.. I bring bad news. This is still not working and it doesn't depend on >> the Test environment. >> >> >> >> I create another proyect, a Form project, with one button which executes >> the following code: >> >> >> >> // Creating the permission set to grant other assemblies >> >> PermissionSet aRestrictedPermissionSet = new >> PermissionSet(PermissionState.None); >> >> aRestrictedPermissionSet.AddPermission(new >> SecurityPermission(SecurityPermissionFlag.Execution)); >> >> >> >> AppDomainSetup domaininfo = new AppDomainSetup(); >> >> domaininfo.ApplicationBase = System.Environment.CurrentDirectory; >> >> >> >> List strongNameList = new List(); >> >> strongNameList.Add(CreateStrongName(Assembly.GetExecutingAssembly())); >> >> >> >> AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", >> >> >> AppDomain.CurrentDomain.Evidence, >> >> >> domaininfo, >> >> >> aRestrictedPermissionSet, >> >> >> strongNameList.ToArray()); >> >> >> >> ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); >> >> ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); >> >> ScriptScope scope = engine.CreateScope(); >> >> source.Execute(scope); >> >> >> >> It throws this error: >> >> Type is not resolved for member >> 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, >> Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. >> >> >> >> I used the fuslogvw application to see if the Microsoft.Scripting is >> loaded, an it is. >> >> >> >> What seems strange for me is that anyone has tried this before. I hope to >> find some more help here. >> >> >> >> Regards, >> >> Nicolas >> >> >> >> >> >> On Wed, Nov 4, 2009 at 7:36 PM, Shri Borde >> wrote: >> >> http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/has some info about test projects and appbase problems. >> >> >> >> You can also use fuslogvw ( >> http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx)to see why Microsoft.Scripting.dll is failing to load. >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Dino Viehland >> *Sent:* Tuesday, November 03, 2009 1:52 PM >> >> >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Test projects are weird and somehow you don?t end up inheriting the >> application base. This seems to work though: >> >> >> >> AppDomainSetup setup = new AppDomainSetup(); >> >> setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; >> >> AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed >> Domain", null, setup); >> >> ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); >> >> ScriptSource source = >> engine.CreateScriptSourceFromString("2+2"); >> >> ScriptScope scope = engine.CreateScope(); >> >> Console.WriteLine(source.Execute(scope)); >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Tuesday, November 03, 2009 1:30 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> I have create a new "Test Project" and an Unit Test class in order to test >> the following code inside: >> >> >> >> AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); >> >> ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); >> >> ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); >> >> ScriptScope scope = engine.CreateScope(); >> >> source.Execute(scope); >> >> >> >> >> >> I have add the references: >> >> >> >> - IronPython >> >> - Microsoft.Scripting >> >> - Microsoft.ScriptingCore >> >> >> >> But it still not working and throwing the >> same System.Runtime.Serialization.SerializationException: Type is not >> resolved for member >> 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. >> >> >> >> Any ideas? >> >> >> >> >> >> 2009/11/3 Nicol?s Buttarelli >> >> Thanks Shri, I will try. >> >> >> >> In addition, I found this open issue: >> http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that >> it is related. >> >> >> >> On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde >> wrote: >> >> I think this happens if the new appdomain cannot load the required >> assembly. By default, the new appdomain should inherit its BaseDirectory >> property from the creating domain and should be able to load >> Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If >> not, can you try to put all assemblies in the same folder (or in the GAC) to >> see if it works? If that works, you can then figure out how to configure the >> new appdomain such that it can load Microsoft.Scripting.dll. There may be >> some setting in AppDomainSetup, or you could hook the AssemblyResolve event? >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Tuesday, November 03, 2009 12:08 PM >> >> >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Hi again, thanks for your clear response. >> >> >> >> I was trying to do what you proposed but it is not working. I am receiving >> an exception: >> >> >> >> *Test method >> CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest >> threw exception: System.Runtime.Serialization.SerializationException: Type >> is not resolved for member >> 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, >> Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..* >> >> I tried to find a solution but I couldn't. This is the minimal code that I >> am running to get this exception (I have removed all the security stuff but >> apparently that does not resolve the problem): >> >> >> >> *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); >> * >> >> >> >> *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* >> >> *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); >> * >> >> *SriptScope scope = engine.CreateScope();* >> >> *source.Execute(scope);* >> >> >> >> The exception is thronged in this line: >> >> *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* >> >> >> >> >> >> Do you have any idea which could be the problem? >> >> >> >> Thanks again, >> >> Nicolas >> >> >> >> On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland >> wrote: >> >> Assuming the app domain is setup properly then there?s no way for the >> Python code to elevate permissions (modulo CLR security bugs which are few >> and far between). This is because IronPython its self is 100% security >> transparent and does not affect any security decisions or assert any form of >> trust ? so it?s all up to the CLR to limit permissions. So for example >> while you can access the file object, or import ctypes, or call various >> other Python APIs which would require trust you?ll get a security exception >> from the CLR when you don?t have permissions to do something. >> >> >> >> For more complex scenarios you might also have an object model which you >> expose to the application and inject in via its scope. Once you?ve done >> that you?ll want to make sure that the object model is also secure. >> >> >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Monday, November 02, 2009 1:20 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Thanks for your response. >> >> >> >> But what happens with the python code? Does not exist a way to write some >> scripts that can do some damage to my app, the server, the database, etc? >> >> >> >> Thanks again, >> >> Nicolas >> >> >> >> On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland >> wrote: >> >> After creating your app domain you can do: >> >> >> >> ScriptEngine engine = Python.CreateEngine(someAppDomain); >> >> >> >> And then the rest of your code should work as it?s written. >> >> >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli >> *Sent:* Monday, November 02, 2009 12:39 PM >> *To:* users at lists.ironpython.com >> *Subject:* [IronPython] Safe execution of python scripts on my .net >> application >> >> >> >> Sorry, I don't know if my previous message have arrived. So, here it is: >> >> >> >> >> >> Hello all, >> >> >> >> I am starting with python and I would like to add to my web application >> some web services. This services will allow the different clients of my >> application to execute some python scripts. >> >> >> >> I would like to know if someone did this before and how can I do this in a >> secure way. I mean, how can I do to restrict the environment where the >> scripts will be executed. >> >> >> >> In .net I can do this using the AppDoman and setting the permission set. >> >> >> >> AppDomain.CreateDomain( string friendlyName, >> Evidence securityInfo, >> AppDomainSetup info, >> PermissionSet grantSet, >> params StrongName[] fullTrustAssemblies); >> >> >> >> >> >> Is there a way to do the same with my python scripts? >> >> >> >> I am running them using this: >> >> >> >> ScriptEngine engine = Python.CreateEngine(); >> >> ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); >> >> ScriptScope scope = engine.CreateScope(); >> >> source.Execute(scope); >> >> >> >> Thanks in advance. >> >> Nicolas >> >> >> _______________________________________________ >> 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 >> >> >> >> >> _______________________________________________ >> 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 >> >> >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Mon Nov 9 17:53:53 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Mon, 9 Nov 2009 08:53:53 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61249. ADDED SOURCES $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ILoopStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AstMethods.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/CollectableCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/LookupCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/ToDiskCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/UncollectableCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs $/IronPython/IronPython_Main/Src/Scripts/generate_UncollectableCompilationMode.py DELETED SOURCES $/IronPython/IronPython_Main/Src/IronPython/Compiler/ArrayGlobalAllocator.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/DictionaryGlobalAllocator.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AstGenerator.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/SharedGlobalAllocator.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/SharedGlobalAllocator.Generated.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/SavableGlobalAllocator.cs $/IronPython/IronPython_Main/Src/Scripts/generate_SharedGlobalAllocator.py MODIFIED SOURCES $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ILoopStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AstMethods.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/BinaryExpression.Generated.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/PythonNameBinder.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/PythonAst.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/PrintStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ParenthesisExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/Parameter.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/OrExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/Node.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/NameExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/MemberExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ListExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ListComprehensionIf.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ListComprehensionFor.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ListComprehension.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/LambdaExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/IndexExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ImportStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/IfStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/GlobalStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/GeneratorExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/FunctionDefinition.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/FromImportStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ForStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ExpressionStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/Expression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ExecStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ErrorExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/EmptyStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/DictionaryExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/DelStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ContinueStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ConstantExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ConditionalExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ClassDefinition.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/CallExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/BreakStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/BinaryExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/BackQuoteExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/SerializedScopeStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/CollectableCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/LookupCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/ClosureExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/CompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/ClosureInfo.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/OnDiskScriptCode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/PythonCompilerOptions.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/VariableKind.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/YieldExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/PythonVariable.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/PythonReference.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/WithStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/WhileStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/UnaryExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/TupleExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/TryStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/SuiteStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/Statement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/SliceExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/SequenceExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ScopeStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/ReturnStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/RaiseStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AugmentedAssignStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AssignmentStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AssertStatement.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/Arg.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/AndExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Parser.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/ToDiskCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/UncollectableCompilationMode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/UncollectableCompilationMode.Generated.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/RunnableScriptCode.cs $/IronPython/IronPython_Main/Src/IronPython/Modules/Builtin.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/PythonScriptCode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/PythonGlobal.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/RuntimeScriptCode.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Binding/MetaPythonType.Calls.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Binding/BindingHelpers.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Tokenizer.cs $/IronPython/IronPython_Main/Src/IronPython/IronPython.csproj $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Utils/CollectionUtils.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/CodeContext.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/FunctionCode.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/PythonFunction.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Operations/PythonOps.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/PythonContext.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Importer.cs $/IronPython/IronPython_Main/Src/Scripts/generate_UncollectableCompilationMode.py $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Debugging/DebuggableLambdaBuilder.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting.Core/Ast/Expression.cs $/IronPython/IronPython_Main/Src/Scripts/generate_walker.py $/IronPython/IronPython_Main/Src/Tests/test_function.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1258596 Date: 11/6/2009 2:16:40 PM (sborde) Adds support to declare intefaces in the clrtype sample (Shelveset: clrtype;REDMOND\sborde | SNAP CheckinId: 9759) -------------------------------------------------------------------------------- Changeset Id: 1258456 Date: 11/6/2009 1:18:39 PM (dinov) Improves import time and working set by making IronPython ASTs reducible DLR ASTs and delaying reduction of Python functions until they are run the first time. Before After % change Big import - no ngen 7646.252731 5129.492 -32.91496228 Big import Private WS - no ngen 58188 42560 -26.85777136 Big import Working Set - no ngen 74448 62800 -15.6458199 Hello world - no ngen 3764.7576 3600.676 -4.358357627 Big import 5696.948 3028.675 -46.83689407 Big import Private WS 55124 40260 -26.96466149 Big import Working Set 78912 59856 -24.14841849 Hello world 933.3606 844.5354 -9.51670769 (Shelveset: NewAstsFinal4;REDMOND\dinov | SNAP CheckinId: 9767) From dinov at microsoft.com Mon Nov 9 19:44:37 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 9 Nov 2009 18:44:37 +0000 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <2c2511410911090748n6e9c66cem5b601627e54bdf75@mail.gmail.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <2c2511410911031207i37c237e5qe2538129a33a8c5b@mail.gmail.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B41DB@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C4C7D0@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911060035j3c9b12c2xa9b023a2fe743dc9@mail.gmail.com> <2c2511410911090748n6e9c66cem5b601627e54bdf75@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C78DD9@TK5EX14MBXC118.redmond.corp.microsoft.com> Couple of options spring to mind: 1. Setup evidence such that your assembly is given full trust. I believe you had the start of this in your other code where you were adding some strong name evidence. You should be able to search the web for normal .NET partial trust scenarios for getting this right. 2. Setup your object model so that it is a MarshalByRefObject which lives in another app domain. You can then expose the remote object to the partial trust app domain via SetVariable. As far as including the DLL - you can call LoadAssembly on the ScriptRuntime and give it your assembly. Then the user can import all of the types from your DLL as they need them. That won't work w/ #2 though. Alternately you can implement IAttributesCollection (or use a dynamic object in 2.6 although IAC is still supported) and create a scope w/ that as the backing storage. Then you'll be able to lazily resolve the members rather than eagerly populating them - although you still need some code to lazily resolve them. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 09, 2009 7:49 AM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Hi all again, I am still working with the same problem. Now I am creating the appDomain in this way by recommendation of Dino: public static AppDomain CreateSandboxAppDomain() { AppDomainSetup anAppDomainSetup = new AppDomainSetup(); anAppDomainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; anAppDomainSetup.ApplicationName = "Testing"; Evidence evidence = new Evidence(); evidence.AddHost(new Zone(SecurityZone.Internet)); AppDomain aSandboxedDomain = AppDomain.CreateDomain("Test Domain", evidence, anAppDomainSetup); return aSandboxedDomain; } Now it is working but I have security restrictions over some .dll that I want to have full trusted permissions. I am trying to do this: string aPythonScript = @"aDocument = CDLDocument() aFigure = TextBlock(1, 'type 1') anotherFigure = TextBlock(2, 'type 2') aDocument.AddFigure(aFigure) aDocument.AddFigure(anotherFigure) aList = aDocument.Figures "; ScriptSource source = engine.CreateScriptSourceFromString(aPythonScript); ScriptScope scope = engine.CreateScope(); scope.SetVariable("CDLDocument", typeof(CDLDocument)); scope.SetVariable("TextBlock", typeof(TextBlock)); source.Execute(scope); This is throwing the System.Security.SecurityException. 1. How can I give full trusted to a specific dll in an AppDomain? 2. How can I include a .dll to the scope instead of do a SetVariable for each type which I have to manage from the python script? Thanks! Nicol?s 2009/11/6 Nicol?s Buttarelli > Hi, On Fri, Nov 6, 2009 at 1:07 AM, Dino Viehland > wrote: So you've run this as a standalone program and it's failing? In the standalone app are all of the IronPython and DLR DLLs present (IronPython.dll, IronPython.modules.dll, Microsoft.Scripting.Core.dll, Microsoft.Scripting.dll, Microsoft.Dynamic.dll and Micrsoft.Scripting.Extensionattribute.dll)? Yes I have all this dlls present. A slightly modified version of this, dropping the strong name, works just fine for me: using System; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; using IronPython.Hosting; using System.Security; using System.Security.Permissions; class Test { public static void Main(string[] args) { PermissionSet aRestrictedPermissionSet = new PermissionSet(PermissionState.None); aRestrictedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", AppDomain.CurrentDomain.Evidence, domaininfo, aRestrictedPermissionSet); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString("2+2"); ScriptScope scope = engine.CreateScope(); Console.WriteLine(source.Execute(scope)); } } Great, I will try this after university. Thanks! Compile with: csc test.cs /r:Microsoft.Scripting.Core.dll /r:Microsoft.Scripting.dll /r:IronPython.dll And run and it prints 4. Does that not work for you? We also have a different way we do this in our test suite which also works: AppDomainSetup info = new AppDomainSetup(); info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; info.ApplicationName = "Test"; Evidence evidence = new Evidence(); evidence.AddHost(new Zone(SecurityZone.Internet)); AppDomain newDomain = AppDomain.CreateDomain("test", evidence, info); // create runtime in partial trust... ScriptRuntime runtime = Python.CreateRuntime(newDomain); // get the Python engine... ScriptEngine engine = runtime.GetEngine("py"); This make sense too, I will try it. Thanks again. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Thursday, November 05, 2009 11:18 AM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Again, thanks everyone for your help. But.. I bring bad news. This is still not working and it doesn't depend on the Test environment. I create another proyect, a Form project, with one button which executes the following code: // Creating the permission set to grant other assemblies PermissionSet aRestrictedPermissionSet = new PermissionSet(PermissionState.None); aRestrictedPermissionSet.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution)); AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = System.Environment.CurrentDirectory; List strongNameList = new List(); strongNameList.Add(CreateStrongName(Assembly.GetExecutingAssembly())); AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", AppDomain.CurrentDomain.Evidence, domaininfo, aRestrictedPermissionSet, strongNameList.ToArray()); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); It throws this error: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. I used the fuslogvw application to see if the Microsoft.Scripting is loaded, an it is. What seems strange for me is that anyone has tried this before. I hope to find some more help here. Regards, Nicolas On Wed, Nov 4, 2009 at 7:36 PM, Shri Borde > wrote: http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/ has some info about test projects and appbase problems. You can also use fuslogvw (http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx) to see why Microsoft.Scripting.dll is failing to load. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Tuesday, November 03, 2009 1:52 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Test projects are weird and somehow you don't end up inheriting the application base. This seems to work though: AppDomainSetup setup = new AppDomainSetup(); setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", null, setup); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString("2+2"); ScriptScope scope = engine.CreateScope(); Console.WriteLine(source.Execute(scope)); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 1:30 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application I have create a new "Test Project" and an Unit Test class in order to test the following code inside: AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); ScriptScope scope = engine.CreateScope(); source.Execute(scope); I have add the references: - IronPython - Microsoft.Scripting - Microsoft.ScriptingCore But it still not working and throwing the same System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. Any ideas? 2009/11/3 Nicol?s Buttarelli > Thanks Shri, I will try. In addition, I found this open issue: http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that it is related. On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: I think this happens if the new appdomain cannot load the required assembly. By default, the new appdomain should inherit its BaseDirectory property from the creating domain and should be able to load Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If not, can you try to put all assemblies in the same folder (or in the GAC) to see if it works? If that works, you can then figure out how to configure the new appdomain such that it can load Microsoft.Scripting.dll. There may be some setting in AppDomainSetup, or you could hook the AssemblyResolve event... From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Tuesday, November 03, 2009 12:08 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Hi again, thanks for your clear response. I was trying to do what you proposed but it is not working. I am receiving an exception: Test method CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest threw exception: System.Runtime.Serialization.SerializationException: Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.. I tried to find a solution but I couldn't. This is the minimal code that I am running to get this exception (I have removed all the security stuff but apparently that does not resolve the problem): AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); SriptScope scope = engine.CreateScope(); source.Execute(scope); The exception is thronged in this line: ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); Do you have any idea which could be the problem? Thanks again, Nicolas On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: Assuming the app domain is setup properly then there's no way for the Python code to elevate permissions (modulo CLR security bugs which are few and far between). This is because IronPython its self is 100% security transparent and does not affect any security decisions or assert any form of trust - so it's all up to the CLR to limit permissions. So for example while you can access the file object, or import ctypes, or call various other Python APIs which would require trust you'll get a security exception from the CLR when you don't have permissions to do something. For more complex scenarios you might also have an object model which you expose to the application and inject in via its scope. Once you've done that you'll want to make sure that the object model is also secure. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] Safe execution of python scripts on my .net application Thanks for your response. But what happens with the python code? Does not exist a way to write some scripts that can do some damage to my app, the server, the database, etc? Thanks again, Nicolas On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland > wrote: After creating your app domain you can do: ScriptEngine engine = Python.CreateEngine(someAppDomain); And then the rest of your code should work as it's written. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Nicol?s Buttarelli Sent: Monday, November 02, 2009 12:39 PM To: users at lists.ironpython.com Subject: [IronPython] Safe execution of python scripts on my .net application Sorry, I don't know if my previous message have arrived. So, here it is: Hello all, I am starting with python and I would like to add to my web application some web services. This services will allow the different clients of my application to execute some python scripts. I would like to know if someone did this before and how can I do this in a secure way. I mean, how can I do to restrict the environment where the scripts will be executed. In .net I can do this using the AppDoman and setting the permission set. AppDomain.CreateDomain( string friendlyName, Evidence securityInfo, AppDomainSetup info, PermissionSet grantSet, params StrongName[] fullTrustAssemblies); Is there a way to do the same with my python scripts? I am running them using this: ScriptEngine engine = Python.CreateEngine(); ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); ScriptScope scope = engine.CreateScope(); source.Execute(scope); Thanks in advance. Nicolas _______________________________________________ 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 _______________________________________________ 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 _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From kay at fiber-space.de Mon Nov 9 21:47:53 2009 From: kay at fiber-space.de (Kay Schluehr) Date: Mon, 09 Nov 2009 21:47:53 +0100 Subject: [IronPython] Fail to execute "import System" on Silverlight embedded interpreter Message-ID: <4AF87FF9.1060607@fiber-space.de> Hi IronPython list, I worked along Michael Foords introductory article about embedding IronPython in Silverlight together with his "EmbeddingIronPythonSilverlight" project documented here: http://www.voidspace.org.uk/ironpython/silverlight/embedding_ironpython.shtml I added the following two lines to the source code source = pe.CreateScriptSourceFromString("import System", SourceCodeKind.Statements); source.Execute(scope); This worked all well with the given built and the shipped assemblies. Yesterday I downloaded the DLR dlr-34133, built it and replaced the assemblies of the "EmbeddingIronPython..." project with the latest SilverlightDebug ones. Running the code again I get following import error: System.NullReferenceException wurde nicht von Benutzercode behandelt. Message="Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt." StackTrace: bei Microsoft.Scripting.Silverlight.DynamicApplication.get_BaseUri() bei Microsoft.Scripting.Silverlight.DynamicApplication.MakeUri(Uri baseUri, Uri relativeUri) bei Microsoft.Scripting.Silverlight.HttpVirtualFilesystem.GetFileInternal(Object baseUri, Uri relativeUri) bei Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFileInternal(Object storageUnit, String relativePath) bei Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(Object storageUnit, String relativePath) bei Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(String relativePath) bei Microsoft.Scripting.Silverlight.BrowserPAL.FileExists(String path) bei IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext context, String name, String path) bei IronPython.Runtime.Importer.LoadPackageFromSource(CodeContext context, String name, String path) bei IronPython.Runtime.Importer.LoadFromDisk(CodeContext context, String name, String fullName, String str) bei IronPython.Runtime.Importer.ImportFromPathHook(CodeContext context, String name, String fullName, List path, Func`5 defaultLoader) bei IronPython.Runtime.Importer.ImportFromPath(CodeContext context, String name, String fullName, List path) bei IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext context, String name) bei IronPython.Runtime.Importer.ImportModule(CodeContext context, Object globals, String modName, Boolean bottom, Int32 level) bei IronPython.Modules.Builtin.__import__(CodeContext context, String name, Object globals, Object locals, Object fromlist, Int32 level) InnerException: Apparently, pre-loading assemblies in the loop foreach (string name in new string[] { "mscorlib", "System", "System.Windows", "System.Windows.Browser", "System.Net" }) { runtime.LoadAssembly(runtime.Host.PlatformAdaptationLayer.LoadAssembly(name)); } had no effect and IronPython attempts to load the 'System' module from the disk as a Python module. The standard import routine "import clr; clr.AddReference("System"); import System" causes the same problem. I'm puzzled. Regards, Kay From tom.wright at resolversystems.com Tue Nov 10 18:39:04 2009 From: tom.wright at resolversystems.com (Tom Wright) Date: Tue, 10 Nov 2009 17:39:04 +0000 Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types In-Reply-To: <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> References: <4AF49C0E.7080503@bakalari.cz> <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> Message-ID: <4AF9A538.2020103@resolversystems.com> Hi, Are there any restrictions placed on the list of types that can be passed to CompileSubclassTypes? We are having issues with a clr.AddReference(DllContainingSubclasses) being very slow, so are trying to split the compiled subclasses across multiple dlls to indicate progress between the loading of these dlls. However, when trying to compile a partial list of types we get the following error: Traceback (most recent call last): File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in c:\buildsha re\gitrepo\precompile_subclasses.py TypeError: : can only extend one CLI or builtin type, not both Microsoft.Scripti ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, Culture=neutr al, PublicKeyToken=b77a5c561934e089]] (for IronPython.Runtime.Types.PythonType) and IronPython.Runtime.SetCollection (for IronPython.Runtime.Types.PythonType) Any help is much appreciated, Tom From dinov at microsoft.com Tue Nov 10 18:44:35 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 10 Nov 2009 17:44:35 +0000 Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types In-Reply-To: <4AF9A538.2020103@resolversystems.com> References: <4AF49C0E.7080503@bakalari.cz> <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF9A538.2020103@resolversystems.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C7FC3D@TK5EX14MBXC118.redmond.corp.microsoft.com> The only restrictions are the normal restrictions that Python has regarding inheritance. In this case it looks like you're hitting that you cannot inherit from more than one base type w/ a different layout. Basically it looks like you're trying to pre-compile the equivalent of: class c(float, set): pass Which isn't legal in Python so my guess is there is an issue w/ the way you split them up. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Tom Wright > Sent: Tuesday, November 10, 2009 9:39 AM > To: Discussion of IronPython > Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types > > Hi, > > Are there any restrictions placed on the list of types that can be > passed to CompileSubclassTypes? > > We are having issues with a clr.AddReference(DllContainingSubclasses) > being very slow, so are trying to split the compiled subclasses across > multiple dlls to indicate progress between the loading of these dlls. > > However, when trying to compile a partial list of types we get the > following error: > > Traceback (most recent call last): > File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in > c:\buildsha > re\gitrepo\precompile_subclasses.py > TypeError: : can only extend one CLI or builtin type, not both > Microsoft.Scripti > ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, > Culture=neutr > al, PublicKeyToken=b77a5c561934e089]] (for > IronPython.Runtime.Types.PythonType) > and IronPython.Runtime.SetCollection (for > IronPython.Runtime.Types.PythonType) > > > Any help is much appreciated, > Tom > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From tom.wright at resolversystems.com Tue Nov 10 19:08:25 2009 From: tom.wright at resolversystems.com (Tom Wright) Date: Tue, 10 Nov 2009 18:08:25 +0000 Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C7FC3D@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <4AF49C0E.7080503@bakalari.cz> <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF9A538.2020103@resolversystems.com> <1A472770E042064698CB5ADC83A12ACD04C7FC3D@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <4AF9AC19.6060201@resolversystems.com> Thanks the reply, Could you clarify slightly what you mean by the Python's normal restrictions. I was guessing the restriction might be something like: "When compiling a list of types, if the list contains a class B which inherits from A then A must be contained in the list." The interesting thing here is that the call to CompileSubclassTypes works when we pass it one huge list of types, but not when we call if repeatedly with smaller lists. Thanks Tom Dino Viehland wrote: > The only restrictions are the normal restrictions that Python has regarding > inheritance. In this case it looks like you're hitting that you cannot > inherit from more than one base type w/ a different layout. > > Basically it looks like you're trying to pre-compile the equivalent of: > > class c(float, set): pass > > Which isn't legal in Python so my guess is there is an issue w/ the way you > split them up. > > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Tom Wright >> Sent: Tuesday, November 10, 2009 9:39 AM >> To: Discussion of IronPython >> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types >> >> Hi, >> >> Are there any restrictions placed on the list of types that can be >> passed to CompileSubclassTypes? >> >> We are having issues with a clr.AddReference(DllContainingSubclasses) >> being very slow, so are trying to split the compiled subclasses across >> multiple dlls to indicate progress between the loading of these dlls. >> >> However, when trying to compile a partial list of types we get the >> following error: >> >> Traceback (most recent call last): >> File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in >> c:\buildsha >> re\gitrepo\precompile_subclasses.py >> TypeError: : can only extend one CLI or builtin type, not both >> Microsoft.Scripti >> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, >> Culture=neutr >> al, PublicKeyToken=b77a5c561934e089]] (for >> IronPython.Runtime.Types.PythonType) >> and IronPython.Runtime.SetCollection (for >> IronPython.Runtime.Types.PythonType) >> >> >> Any help is much appreciated, >> Tom >> _______________________________________________ >> 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 > From dinov at microsoft.com Tue Nov 10 19:30:47 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 10 Nov 2009 18:30:47 +0000 Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types In-Reply-To: <4AF9AC19.6060201@resolversystems.com> References: <4AF49C0E.7080503@bakalari.cz> <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF9A538.2020103@resolversystems.com> <1A472770E042064698CB5ADC83A12ACD04C7FC3D@TK5EX14MBXC118.redmond.corp.microsoft.com> <4AF9AC19.6060201@resolversystems.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C80057@TK5EX14MBXC118.redmond.corp.microsoft.com> The restrictions are per-subclass so for example you cannot inherit from both a list and tuple. The reason here is that list and tuple both have their own independent layout in memory and there's no relationship between them. Or in your case it's set and float. CompileSubclassTypes takes an arbitrary number of parameters and those can be either a type (which gets compiled) or they can be a tuple of types which specify the collection of base types. The latter form is generally useful for including .NET interfaces. So clr.CompileSubclassTypes("foo", (set, float)) will fail as this is specifying that you want 1 class which inherits from both set and float. But you can do clr.CompileSubclassTypes("foo", set, float) and this specifies what you want 2 types, one that inherits from set and float. Or you can do: clr.CompileSubclassTypes("foo", (set, ), (float, )) and again that'll work because it's specifying 2 different base types. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Tom Wright > Sent: Tuesday, November 10, 2009 10:08 AM > To: Discussion of IronPython > Subject: Re: [IronPython] clr.CompileSubclassTypes restrictions on list of > types > > Thanks the reply, > > Could you clarify slightly what you mean by the Python's normal > restrictions. I was guessing the restriction might be something like: > > "When compiling a list of types, if the list contains a class B which > inherits from A then A must be contained in the list." > > The interesting thing here is that the call to CompileSubclassTypes > works when we pass it one huge list of types, but not when we call if > repeatedly with smaller lists. > > Thanks > Tom > > Dino Viehland wrote: > > The only restrictions are the normal restrictions that Python has regarding > > inheritance. In this case it looks like you're hitting that you cannot > > inherit from more than one base type w/ a different layout. > > > > Basically it looks like you're trying to pre-compile the equivalent of: > > > > class c(float, set): pass > > > > Which isn't legal in Python so my guess is there is an issue w/ the way you > > split them up. > > > > > >> -----Original Message----- > >> From: users-bounces at lists.ironpython.com [mailto:users- > >> bounces at lists.ironpython.com] On Behalf Of Tom Wright > >> Sent: Tuesday, November 10, 2009 9:39 AM > >> To: Discussion of IronPython > >> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of > types > >> > >> Hi, > >> > >> Are there any restrictions placed on the list of types that can be > >> passed to CompileSubclassTypes? > >> > >> We are having issues with a clr.AddReference(DllContainingSubclasses) > >> being very slow, so are trying to split the compiled subclasses across > >> multiple dlls to indicate progress between the loading of these dlls. > >> > >> However, when trying to compile a partial list of types we get the > >> following error: > >> > >> Traceback (most recent call last): > >> File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in > >> c:\buildsha > >> re\gitrepo\precompile_subclasses.py > >> TypeError: : can only extend one CLI or builtin type, not both > >> Microsoft.Scripti > >> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, > >> Culture=neutr > >> al, PublicKeyToken=b77a5c561934e089]] (for > >> IronPython.Runtime.Types.PythonType) > >> and IronPython.Runtime.SetCollection (for > >> IronPython.Runtime.Types.PythonType) > >> > >> > >> Any help is much appreciated, > >> Tom > >> _______________________________________________ > >> 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 > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kfarmer at thuban.org Tue Nov 10 19:35:57 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Tue, 10 Nov 2009 10:35:57 -0800 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <4AF7E50A.1030509@voidspace.org.uk> References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> Message-ID: "making releases that people / projects may have depended on is an unacceptable cost" You wanna rephrase that there, Michael? :) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Monday, November 09, 2009 1:47 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden Jimmy Schementi wrote: > I agree, but I think the desire it to keep that "Releases" list clean. Otherwise it would have every release ever in there. It's a CodePlex limitation that there is no way to hide those releases from that list, while still keeping the links active. > I understand the motivation, but making releases that people / projects may have depended on is an unacceptable cost in my opinion. From fuzzyman at voidspace.org.uk Tue Nov 10 20:25:11 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 20:25:11 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> Message-ID: <4AF9BE17.6050008@voidspace.org.uk> Keith J. Farmer wrote: > "making releases that people / projects may have depended on is an unacceptable cost" > > You wanna rephrase that there, Michael? :) > Ha. :-) making unavailable releases that people.... Thanks Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Monday, November 09, 2009 1:47 AM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Jimmy Schementi wrote: > >> I agree, but I think the desire it to keep that "Releases" list clean. Otherwise it would have every release ever in there. It's a CodePlex limitation that there is no way to hide those releases from that list, while still keeping the links active. >> >> > > I understand the motivation, but making releases that people / projects > may have depended on is an unacceptable cost in my opinion. > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Tue Nov 10 21:25:11 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 21:25:11 +0100 Subject: [IronPython] Fail to execute "import System" on Silverlight embedded interpreter In-Reply-To: <4AF87FF9.1060607@fiber-space.de> References: <4AF87FF9.1060607@fiber-space.de> Message-ID: <4AF9CC27.3010209@voidspace.org.uk> Kay Schluehr wrote: > Hi IronPython list, > > I worked along Michael Foords introductory article about embedding > IronPython in Silverlight together with his > "EmbeddingIronPythonSilverlight" project documented here: > > http://www.voidspace.org.uk/ironpython/silverlight/embedding_ironpython.shtml > > > I added the following two lines to the source code > > source = pe.CreateScriptSourceFromString("import System", > SourceCodeKind.Statements); > source.Execute(scope); > > This worked all well with the given built and the shipped assemblies. > > Yesterday I downloaded the DLR dlr-34133, built it and replaced the > assemblies of the "EmbeddingIronPython..." project with the latest > SilverlightDebug ones. Running the code > again I get following import error: > > System.NullReferenceException wurde nicht von Benutzercode behandelt. > Message="Der Objektverweis wurde nicht auf eine Objektinstanz > festgelegt." > StackTrace: > bei > Microsoft.Scripting.Silverlight.DynamicApplication.get_BaseUri() > bei > Microsoft.Scripting.Silverlight.DynamicApplication.MakeUri(Uri > baseUri, Uri relativeUri) > bei > Microsoft.Scripting.Silverlight.HttpVirtualFilesystem.GetFileInternal(Object > baseUri, Uri relativeUri) > bei > Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFileInternal(Object > storageUnit, String relativePath) > bei > Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(Object > storageUnit, String relativePath) > bei > Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(String > relativePath) > bei Microsoft.Scripting.Silverlight.BrowserPAL.FileExists(String > path) > bei IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext > context, String name, String path) > bei > IronPython.Runtime.Importer.LoadPackageFromSource(CodeContext context, > String name, String path) > bei IronPython.Runtime.Importer.LoadFromDisk(CodeContext > context, String name, String fullName, String str) > bei IronPython.Runtime.Importer.ImportFromPathHook(CodeContext > context, String name, String fullName, List path, Func`5 defaultLoader) > bei IronPython.Runtime.Importer.ImportFromPath(CodeContext > context, String name, String fullName, List path) > bei IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext > context, String name) > bei IronPython.Runtime.Importer.ImportModule(CodeContext > context, Object globals, String modName, Boolean bottom, Int32 level) > bei IronPython.Modules.Builtin.__import__(CodeContext context, > String name, Object globals, Object locals, Object fromlist, Int32 level) > InnerException: > > > Apparently, pre-loading assemblies in the loop > > foreach (string name in new string[] { "mscorlib", "System", > "System.Windows", "System.Windows.Browser", "System.Net" }) > { > > runtime.LoadAssembly(runtime.Host.PlatformAdaptationLayer.LoadAssembly(name)); > > } > > had no effect and IronPython attempts to load the 'System' module from > the disk as a Python module. The standard import > routine "import clr; clr.AddReference("System"); import System" causes > the same problem. I'm puzzled. I've had horrible problems with imports in Silverlight when using embedded IronPython and didn't really get any good answers I'm afraid. :-( Michael > > Regards, Kay > > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- http://www.ironpythoninaction.com/ From kfarmer at thuban.org Tue Nov 10 21:29:48 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Tue, 10 Nov 2009 12:29:48 -0800 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> Message-ID: As for the question at hand, though :) I'm not in blanket agreement here. I'd agree for some releases to be valid dependency points, but things like RCs, betas, obsoleted third-level versions -- not really. In the first two cases, those are bleeding-edge releases. If you take a dependency on them, expect to bleed. In the latter case, I wouldn't expect API differences, or other breaking changes unless they represented critical bug fixes. Again, I wouldn't want to support a dependency upon something horribly broken. In light of the above, then, I'd propose keeping the following versions: max(x).y.max(z)[.max(b)] and strongly consider keeping: [max(x)-1].y.max(z)[.max(b)] ________________________________ From: users-bounces at lists.ironpython.com on behalf of Michael Foord Sent: Tue 11/10/2009 11:25 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden Keith J. Farmer wrote: > "making releases that people / projects may have depended on is an unacceptable cost" > > You wanna rephrase that there, Michael? :) > Ha. :-) making unavailable releases that people.... Thanks Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Monday, November 09, 2009 1:47 AM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Jimmy Schementi wrote: > >> I agree, but I think the desire it to keep that "Releases" list clean. Otherwise it would have every release ever in there. It's a CodePlex limitation that there is no way to hide those releases from that list, while still keeping the links active. >> >> > > I understand the motivation, but making releases that people / projects > may have depended on is an unacceptable cost in my opinion. > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Tue Nov 10 21:34:35 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 21:34:35 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> Message-ID: <4AF9CE5B.8080406@voidspace.org.uk> Keith J. Farmer wrote: > As for the question at hand, though :) > > I'm not in blanket agreement here. I'd agree for some releases to be > valid dependency points, but things like RCs, betas, obsoleted > third-level versions -- not really. > > In the first two cases, those are bleeding-edge releases. If you take > a dependency on them, expect to bleed. > The problem is that if a developer has used (and depended on) APIs in a specific release of IronPython then the person who bleeds is likely to be an end user rather than the developer (who may have moved onto other things without updating their project). I don't have a problem with relegating obsolete releases to a small corner, but making them unavailable altogether is a high cost. Michael > In the latter case, I wouldn't expect API differences, or other > breaking changes unless they represented critical bug fixes. Again, I > wouldn't want to support a dependency upon something horribly broken. > > In light of the above, then, I'd propose keeping the following versions: > > max(x).y.max(z)[.max(b)] > > and strongly consider keeping: > > [max(x)-1].y.max(z)[.max(b)] > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > *Sent:* Tue 11/10/2009 11:25 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Keith J. Farmer wrote: > > "making releases that people / projects may have depended on is an > unacceptable cost" > > > > You wanna rephrase that there, Michael? :) > > > > Ha. :-) > > making unavailable releases that people.... > > Thanks > > Michael > > -----Original Message----- > > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > > Sent: Monday, November 09, 2009 1:47 AM > > To: Discussion of IronPython > > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > Jimmy Schementi wrote: > > > >> I agree, but I think the desire it to keep that "Releases" list > clean. Otherwise it would have every release ever in there. It's a > CodePlex limitation that there is no way to hide those releases from > that list, while still keeping the links active. > >> > >> > > > > I understand the motivation, but making releases that people / projects > > may have depended on is an unacceptable cost in my opinion. > > > > _______________________________________________ > > Users mailing list > > Users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From tony.meyer at gmail.com Tue Nov 10 21:36:44 2009 From: tony.meyer at gmail.com (Tony Meyer) Date: Wed, 11 Nov 2009 09:36:44 +1300 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: References: <4AF7E0A0.2070406@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> Message-ID: <6c63de570911101236h535474bdx294bd1f1677f0bea@mail.gmail.com> > I'm not in blanket agreement here.? I'd agree for some releases to be valid > dependency points, but things like RCs, betas, obsoleted third-level > versions -- not really. Couldn't someone in the IronPython team talk to someone in the CodePlex team and figure out a way for all releases to be permanently available without them cluttering up lists that most people would see? i.e. links to alpha (etc) versions would still work, and you could create a list of all releases, but normal users browsing the site would only see the latest (and latest major-1) version? Cheers, Tony From fuzzyman at voidspace.org.uk Tue Nov 10 21:38:28 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 21:38:28 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <6c63de570911101236h535474bdx294bd1f1677f0bea@mail.gmail.com> References: <4AF7E0A0.2070406@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <6c63de570911101236h535474bdx294bd1f1677f0bea@mail.gmail.com> Message-ID: <4AF9CF44.1030302@voidspace.org.uk> Tony Meyer wrote: >> I'm not in blanket agreement here. I'd agree for some releases to be valid >> dependency points, but things like RCs, betas, obsoleted third-level >> versions -- not really. >> > > Couldn't someone in the IronPython team talk to someone in the > CodePlex team and figure out a way for all releases to be permanently > available without them cluttering up lists that most people would see? > i.e. links to alpha (etc) versions would still work, and you could > create a list of all releases, but normal users browsing the site > would only see the latest (and latest major-1) version? > > I think this has been fixed already on the IronPython codeplex site (releases unhidden). All the best, Michael > Cheers, > Tony > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From Jimmy.Schementi at microsoft.com Tue Nov 10 21:53:54 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Tue, 10 Nov 2009 20:53:54 +0000 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <6c63de570911101236h535474bdx294bd1f1677f0bea@mail.gmail.com> References: <4AF7E0A0.2070406@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <6c63de570911101236h535474bdx294bd1f1677f0bea@mail.gmail.com> Message-ID: <1B42307CD4AADD438CDDA2FE1121CC92035951@TK5EX14MBXC134.redmond.corp.microsoft.com> Just because we work for the same company doesn't mean we can convince CodePlex to do some random work =P For now, there's a list of supported releases here, for anyone who wants a shorter list of releases. http://ironpython.codeplex.com/wikipage?title=SupportedReleaseList. It's linked to from the main codeplex page, so I'm sure people will find it. We could also just depend on Michael archiving them and link to his list. =) > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Tony Meyer > Sent: Tuesday, November 10, 2009 12:37 PM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > I'm not in blanket agreement here.? I'd agree for some releases to be > > valid dependency points, but things like RCs, betas, obsoleted > > third-level versions -- not really. > > Couldn't someone in the IronPython team talk to someone in the CodePlex > team and figure out a way for all releases to be permanently available > without them cluttering up lists that most people would see? > i.e. links to alpha (etc) versions would still work, and you could create a list of > all releases, but normal users browsing the site would only see the latest > (and latest major-1) version? > > Cheers, > Tony > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From lsaguisag at vmware.com Tue Nov 10 22:10:40 2009 From: lsaguisag at vmware.com (Leonides Saguisag) Date: Tue, 10 Nov 2009 13:10:40 -0800 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 Message-ID: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> Hi everyone, I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. Here is the test script that I put together: import sys sys.path.append(r'D:\Python25\Lib') import codecs print sys.version myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = myfile.readlines() myfile.close() if lines[0].startswith(codecs.BOM_UTF8): print ('UTF-8 BOM detected!') else: print ('UTF-8 BOM not detected!') myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines = myfile.readlines() myfile.close() if lines[0].startswith(codecs.BOM_UTF8): print ('UTF-8 BOM detected!') else: print ('UTF-8 BOM not detected!') If I run the executable that I get from SharpDevelop this is what I get: bin\Debug> Test.exe 2.5.0 () UTF-8 BOM detected! UTF-8 BOM detected! But if I run the same script using the standard python interpreter, this is what I get: bin\Debug> D:\Python25\python.exe ..\..\Program.py 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] UTF-8 BOM detected! UTF-8 BOM not detected! The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. Any ideas what is going wrong? Thanks! Best regards, -- Leo From fuzzyman at voidspace.org.uk Tue Nov 10 22:16:34 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 22:16:34 +0100 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> Message-ID: <4AF9D832.2050101@voidspace.org.uk> Leonides Saguisag wrote: > Hi everyone, > > I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. > > Here is the test script that I put together: > > > import sys > sys.path.append(r'D:\Python25\Lib') > import codecs > > print sys.version > myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') > lines = myfile.readlines() > myfile.close() > if lines[0].startswith(codecs.BOM_UTF8): > print ('UTF-8 BOM detected!') > else: > print ('UTF-8 BOM not detected!') > > myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') > lines = myfile.readlines() > myfile.close() > if lines[0].startswith(codecs.BOM_UTF8): > print ('UTF-8 BOM detected!') > else: > print ('UTF-8 BOM not detected!') > > > If I run the executable that I get from SharpDevelop this is what I get: > bin\Debug> Test.exe > 2.5.0 () > UTF-8 BOM detected! > UTF-8 BOM detected! > > > But if I run the same script using the standard python interpreter, this is what I get: > bin\Debug> D:\Python25\python.exe ..\..\Program.py > 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] > UTF-8 BOM detected! > UTF-8 BOM not detected! > > > The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. > > Any ideas what is going wrong? > I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. Michael > Thanks! > > Best regards, > -- Leo > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From kfarmer at thuban.org Tue Nov 10 22:21:25 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Tue, 10 Nov 2009 13:21:25 -0800 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> Message-ID: You're right .. the problem *is* a developer taking dependencies on specific releases. Further, I contend that it's the developer taking dependencies on experimental releases. That's improper, and why we as an industry label such things with "alpha", "beta", "RC" and so forth. Each of those are warning signs of "this may change, and you shouldn't depend on it yet". The low-level point releases, of course, represent (in theory) non-API fixes, and so the only dependency taken in those cases should not break, unless the dependency was on broken behavior in which case the end-user is more likely than not being sloppy. I have no qualms about them bleeding in that case. The years-long-betas of the *nix community notwithstanding, I'd as soon we stick to our guns regarding such things. Having to maintain (ie, support) n different versions is a tremendous burden. I myself had to maintain (no exaggeration) about 3 dozen different versions of the *same* product at one job, but there were other reasons that came to be. Would an image of a giant Monty Python foot stomping on the prior versions, with the caption "the version you are requesting has been obsoleted and is no longer supported -- use at your own risk" be an acceptable approach? :) ________________________________ From: users-bounces at lists.ironpython.com on behalf of Michael Foord Sent: Tue 11/10/2009 12:34 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden Keith J. Farmer wrote: > As for the question at hand, though :) > > I'm not in blanket agreement here. I'd agree for some releases to be > valid dependency points, but things like RCs, betas, obsoleted > third-level versions -- not really. > > In the first two cases, those are bleeding-edge releases. If you take > a dependency on them, expect to bleed. > The problem is that if a developer has used (and depended on) APIs in a specific release of IronPython then the person who bleeds is likely to be an end user rather than the developer (who may have moved onto other things without updating their project). I don't have a problem with relegating obsolete releases to a small corner, but making them unavailable altogether is a high cost. Michael > In the latter case, I wouldn't expect API differences, or other > breaking changes unless they represented critical bug fixes. Again, I > wouldn't want to support a dependency upon something horribly broken. > > In light of the above, then, I'd propose keeping the following versions: > > max(x).y.max(z)[.max(b)] > > and strongly consider keeping: > > [max(x)-1].y.max(z)[.max(b)] > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > *Sent:* Tue 11/10/2009 11:25 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Keith J. Farmer wrote: > > "making releases that people / projects may have depended on is an > unacceptable cost" > > > > You wanna rephrase that there, Michael? :) > > > > Ha. :-) > > making unavailable releases that people.... > > Thanks > > Michael > > -----Original Message----- > > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > > Sent: Monday, November 09, 2009 1:47 AM > > To: Discussion of IronPython > > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > Jimmy Schementi wrote: > > > >> I agree, but I think the desire it to keep that "Releases" list > clean. Otherwise it would have every release ever in there. It's a > CodePlex limitation that there is no way to hide those releases from > that list, while still keeping the links active. > >> > >> > > > > I understand the motivation, but making releases that people / projects > > may have depended on is an unacceptable cost in my opinion. > > > > _______________________________________________ > > Users mailing list > > Users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From lsaguisag at vmware.com Tue Nov 10 22:26:56 2009 From: lsaguisag at vmware.com (Leonides Saguisag) Date: Tue, 10 Nov 2009 13:26:56 -0800 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <4AF9D832.2050101@voidspace.org.uk> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> Message-ID: <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. Thanks! -- Leo -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: 2009?11?10? 13:17 To: Discussion of IronPython Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 Leonides Saguisag wrote: > Hi everyone, > > I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. > > Here is the test script that I put together: > > > import sys > sys.path.append(r'D:\Python25\Lib') > import codecs > > print sys.version > myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = > myfile.readlines() > myfile.close() > if lines[0].startswith(codecs.BOM_UTF8): > print ('UTF-8 BOM detected!') > else: > print ('UTF-8 BOM not detected!') > > myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines = > myfile.readlines() > myfile.close() > if lines[0].startswith(codecs.BOM_UTF8): > print ('UTF-8 BOM detected!') > else: > print ('UTF-8 BOM not detected!') > > > If I run the executable that I get from SharpDevelop this is what I get: > bin\Debug> Test.exe > 2.5.0 () > UTF-8 BOM detected! > UTF-8 BOM detected! > > > But if I run the same script using the standard python interpreter, this is what I get: > bin\Debug> D:\Python25\python.exe ..\..\Program.py > 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] > UTF-8 BOM detected! > UTF-8 BOM not detected! > > > The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. > > Any ideas what is going wrong? > I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. Michael > Thanks! > > Best regards, > -- Leo > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Tue Nov 10 22:31:46 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 22:31:46 +0100 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> Message-ID: <4AF9DBC2.1070804@voidspace.org.uk> Leonides Saguisag wrote: > Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. > Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. IronPython 2.X is a bit odd for the .NET framework in this respect. Michael > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 13:17 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Hi everyone, >> >> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >> >> Here is the test script that I put together: >> >> >> import sys >> sys.path.append(r'D:\Python25\Lib') >> import codecs >> >> print sys.version >> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >> myfile.readlines() >> myfile.close() >> if lines[0].startswith(codecs.BOM_UTF8): >> print ('UTF-8 BOM detected!') >> else: >> print ('UTF-8 BOM not detected!') >> >> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines = >> myfile.readlines() >> myfile.close() >> if lines[0].startswith(codecs.BOM_UTF8): >> print ('UTF-8 BOM detected!') >> else: >> print ('UTF-8 BOM not detected!') >> >> >> If I run the executable that I get from SharpDevelop this is what I get: >> bin\Debug> Test.exe >> 2.5.0 () >> UTF-8 BOM detected! >> UTF-8 BOM detected! >> >> >> But if I run the same script using the standard python interpreter, this is what I get: >> bin\Debug> D:\Python25\python.exe ..\..\Program.py >> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] >> UTF-8 BOM detected! >> UTF-8 BOM not detected! >> >> >> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >> >> Any ideas what is going wrong? >> >> > I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. > > Michael > > >> Thanks! >> >> Best regards, >> -- Leo >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Tue Nov 10 22:31:59 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 22:31:59 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> Message-ID: <4AF9DBCF.9050702@voidspace.org.uk> Hmm... I certainly don't suggest that the dynamic languages team *support* obsolete versions, but in my experience it is 'unusual' for an open source project to make previously released code / binaries *completely* unavailable - support notwithstanding. For Python itself I believe you can download the sources for version 0.9.1, but it isn't much of a maintenance burden these days... I don't see an upside to hiding code (or 'breaking things' as I like to put it) in quite the same way you do. :-) All the best, Michael Keith J. Farmer wrote: > You're right .. the problem *is* a developer taking dependencies on > specific releases. Further, I contend that it's the developer taking > dependencies on experimental releases. That's improper, and why we as > an industry label such things with "alpha", "beta", "RC" and so > forth. Each of those are warning signs of "this may change, and you > shouldn't depend on it yet". > > The low-level point releases, of course, represent (in theory) non-API > fixes, and so the only dependency taken in those cases should not > break, unless the dependency was on broken behavior in which case the > end-user is more likely than not being sloppy. I have no qualms about > them bleeding in that case. > > The years-long-betas of the *nix community notwithstanding, I'd as > soon we stick to our guns regarding such things. Having to maintain > (ie, support) n different versions is a tremendous burden. I myself > had to maintain (no exaggeration) about 3 dozen different versions of > the *same* product at one job, but there were other reasons that came > to be. > > Would an image of a giant Monty Python foot stomping on the prior > versions, with the caption "the version you are requesting has been > obsoleted and is no longer supported -- use at your own risk" be an > acceptable approach? :) > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > *Sent:* Tue 11/10/2009 12:34 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Keith J. Farmer wrote: > > As for the question at hand, though :) > > > > I'm not in blanket agreement here. I'd agree for some releases to be > > valid dependency points, but things like RCs, betas, obsoleted > > third-level versions -- not really. > > > > In the first two cases, those are bleeding-edge releases. If you take > > a dependency on them, expect to bleed. > > > > The problem is that if a developer has used (and depended on) APIs in a > specific release of IronPython then the person who bleeds is likely to > be an end user rather than the developer (who may have moved onto other > things without updating their project). > > I don't have a problem with relegating obsolete releases to a small > corner, but making them unavailable altogether is a high cost. > > Michael > > > > In the latter case, I wouldn't expect API differences, or other > > breaking changes unless they represented critical bug fixes. Again, I > > wouldn't want to support a dependency upon something horribly broken. > > > > In light of the above, then, I'd propose keeping the following versions: > > > > max(x).y.max(z)[.max(b)] > > > > and strongly consider keeping: > > > > [max(x)-1].y.max(z)[.max(b)] > > > > ------------------------------------------------------------------------ > > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > > *Sent:* Tue 11/10/2009 11:25 AM > > *To:* Discussion of IronPython > > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > Keith J. Farmer wrote: > > > "making releases that people / projects may have depended on is an > > unacceptable cost" > > > > > > You wanna rephrase that there, Michael? :) > > > > > > > Ha. :-) > > > > making unavailable releases that people.... > > > > Thanks > > > > Michael > > > -----Original Message----- > > > From: users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > > > Sent: Monday, November 09, 2009 1:47 AM > > > To: Discussion of IronPython > > > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > > > Jimmy Schementi wrote: > > > > > >> I agree, but I think the desire it to keep that "Releases" list > > clean. Otherwise it would have every release ever in there. It's a > > CodePlex limitation that there is no way to hide those releases from > > that list, while still keeping the links active. > > >> > > >> > > > > > > I understand the motivation, but making releases that people / > projects > > > may have depended on is an unacceptable cost in my opinion. > > > > > > _______________________________________________ > > > Users mailing list > > > Users at lists.ironpython.com > > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > > > -- > > http://www.ironpythoninaction.com/ > > > > _______________________________________________ > > 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 > > > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From lsaguisag at vmware.com Tue Nov 10 22:52:20 2009 From: lsaguisag at vmware.com (Leonides Saguisag) Date: Tue, 10 Nov 2009 13:52:20 -0800 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <4AF9DBC2.1070804@voidspace.org.uk> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> <4AF9DBC2.1070804@voidspace.org.uk> Message-ID: <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> Hi Michael, I just verified the empty string theory that you mentioned and Python25\lib\codecs.py (comes with the standard library in Python 2.5) has the following defined: # UTF-8 BOM_UTF8 = '\xef\xbb\xbf' So it is not an empty string. Maybe I am approaching this wrong and you guys can provide me with an alternative way of doing this. I am trying to read a file and determine if the file is encoded in UTF-8 or not. The approach I took was to use python's built-in open function to read the text file into an array of strings and check if the first line starts with the UTF-8 byte order mark by using line.startswith(codecs.BOM_UTF8). As I noted below, this works fine in Python 2.5 but in IronPython it just keeps saying it found a UTF-8 BOM even though there is none present. Thanks! -- Leo -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: 2009?11?10? 13:32 To: Discussion of IronPython Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 Leonides Saguisag wrote: > Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. > Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. IronPython 2.X is a bit odd for the .NET framework in this respect. Michael > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 13:17 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Hi everyone, >> >> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >> >> Here is the test script that I put together: >> >> >> import sys >> sys.path.append(r'D:\Python25\Lib') >> import codecs >> >> print sys.version >> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >> myfile.readlines() >> myfile.close() >> if lines[0].startswith(codecs.BOM_UTF8): >> print ('UTF-8 BOM detected!') >> else: >> print ('UTF-8 BOM not detected!') >> >> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines = >> myfile.readlines() >> myfile.close() >> if lines[0].startswith(codecs.BOM_UTF8): >> print ('UTF-8 BOM detected!') >> else: >> print ('UTF-8 BOM not detected!') >> >> >> If I run the executable that I get from SharpDevelop this is what I get: >> bin\Debug> Test.exe >> 2.5.0 () >> UTF-8 BOM detected! >> UTF-8 BOM detected! >> >> >> But if I run the same script using the standard python interpreter, this is what I get: >> bin\Debug> D:\Python25\python.exe ..\..\Program.py >> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] >> UTF-8 BOM detected! >> UTF-8 BOM not detected! >> >> >> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >> >> Any ideas what is going wrong? >> >> > I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. > > Michael > > >> Thanks! >> >> Best regards, >> -- Leo >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Tue Nov 10 23:04:42 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 23:04:42 +0100 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> <4AF9DBC2.1070804@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> Message-ID: <4AF9E37A.1050300@voidspace.org.uk> Leonides Saguisag wrote: > Hi Michael, > > I just verified the empty string theory that you mentioned and Python25\lib\codecs.py (comes with the standard library in Python 2.5) has the following defined: > > You're using IronPython 2.0 then? If I use IronPython 2.6 it correctly reports a text file as not starting with the BOM: >>> import codecs >>> codecs.BOM_UTF8 u'\xef\xbb\xbf' >>> lines = open('foo.txt').readlines() >>> lines ['foo'] >>> lines[0].startswith(codecs.BOM_UTF8) False All the best, Michael Foord > # UTF-8 > BOM_UTF8 = '\xef\xbb\xbf' > > > So it is not an empty string. > > Maybe I am approaching this wrong and you guys can provide me with an alternative way of doing this. I am trying to read a file and determine if the file is encoded in UTF-8 or not. The approach I took was to use python's built-in open function to read the text file into an array of strings and check if the first line starts with the UTF-8 byte order mark by using line.startswith(codecs.BOM_UTF8). As I noted below, this works fine in Python 2.5 but in IronPython it just keeps saying it found a UTF-8 BOM even though there is none present. > > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 13:32 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. >> >> > Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. > > If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. > > In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. > IronPython 2.X is a bit odd for the .NET framework in this respect. > > Michael > > >> Thanks! >> >> -- Leo >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >> Sent: 2009?11?10? 13:17 >> To: Discussion of IronPython >> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >> >> Leonides Saguisag wrote: >> >> >>> Hi everyone, >>> >>> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >>> >>> Here is the test script that I put together: >>> >>> >>> import sys >>> sys.path.append(r'D:\Python25\Lib') >>> import codecs >>> >>> print sys.version >>> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >>> myfile.readlines() >>> myfile.close() >>> if lines[0].startswith(codecs.BOM_UTF8): >>> print ('UTF-8 BOM detected!') >>> else: >>> print ('UTF-8 BOM not detected!') >>> >>> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines = >>> myfile.readlines() >>> myfile.close() >>> if lines[0].startswith(codecs.BOM_UTF8): >>> print ('UTF-8 BOM detected!') >>> else: >>> print ('UTF-8 BOM not detected!') >>> >>> >>> If I run the executable that I get from SharpDevelop this is what I get: >>> bin\Debug> Test.exe >>> 2.5.0 () >>> UTF-8 BOM detected! >>> UTF-8 BOM detected! >>> >>> >>> But if I run the same script using the standard python interpreter, this is what I get: >>> bin\Debug> D:\Python25\python.exe ..\..\Program.py >>> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] >>> UTF-8 BOM detected! >>> UTF-8 BOM not detected! >>> >>> >>> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >>> >>> Any ideas what is going wrong? >>> >>> >>> >> I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. >> >> Michael >> >> >> >>> Thanks! >>> >>> Best regards, >>> -- Leo >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From lsaguisag at vmware.com Tue Nov 10 23:17:09 2009 From: lsaguisag at vmware.com (Leonides Saguisag) Date: Tue, 10 Nov 2009 14:17:09 -0800 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <4AF9E37A.1050300@voidspace.org.uk> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> <4AF9DBC2.1070804@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> <4AF9E37A.1050300@voidspace.org.uk> Message-ID: <956CF991DC2D324AB6D1FD9093942B49E0755E5C@EXCH-MBX-4.vmware.com> Hi Michael, I am using SharpDevelop 3.1 which comes with "2.5.0 (IronPython 2.0.2 (2.0.0.0) on .NET 2.0.50727.3603)". So this issue is resolved with IronPython 2.6, then? Thanks! -- Leo -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: 2009?11?10? 14:05 To: Discussion of IronPython Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 Leonides Saguisag wrote: > Hi Michael, > > I just verified the empty string theory that you mentioned and Python25\lib\codecs.py (comes with the standard library in Python 2.5) has the following defined: > > You're using IronPython 2.0 then? If I use IronPython 2.6 it correctly reports a text file as not starting with the BOM: >>> import codecs >>> codecs.BOM_UTF8 u'\xef\xbb\xbf' >>> lines = open('foo.txt').readlines() >>> lines ['foo'] >>> lines[0].startswith(codecs.BOM_UTF8) False All the best, Michael Foord > # UTF-8 > BOM_UTF8 = '\xef\xbb\xbf' > > > So it is not an empty string. > > Maybe I am approaching this wrong and you guys can provide me with an alternative way of doing this. I am trying to read a file and determine if the file is encoded in UTF-8 or not. The approach I took was to use python's built-in open function to read the text file into an array of strings and check if the first line starts with the UTF-8 byte order mark by using line.startswith(codecs.BOM_UTF8). As I noted below, this works fine in Python 2.5 but in IronPython it just keeps saying it found a UTF-8 BOM even though there is none present. > > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 13:32 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. >> >> > Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. > > If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. > > In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. > IronPython 2.X is a bit odd for the .NET framework in this respect. > > Michael > > >> Thanks! >> >> -- Leo >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael >> Foord >> Sent: 2009?11?10? 13:17 >> To: Discussion of IronPython >> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >> >> Leonides Saguisag wrote: >> >> >>> Hi everyone, >>> >>> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >>> >>> Here is the test script that I put together: >>> >>> >>> import sys >>> sys.path.append(r'D:\Python25\Lib') >>> import codecs >>> >>> print sys.version >>> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >>> myfile.readlines() >>> myfile.close() >>> if lines[0].startswith(codecs.BOM_UTF8): >>> print ('UTF-8 BOM detected!') >>> else: >>> print ('UTF-8 BOM not detected!') >>> >>> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines >>> = >>> myfile.readlines() >>> myfile.close() >>> if lines[0].startswith(codecs.BOM_UTF8): >>> print ('UTF-8 BOM detected!') >>> else: >>> print ('UTF-8 BOM not detected!') >>> >>> >>> If I run the executable that I get from SharpDevelop this is what I get: >>> bin\Debug> Test.exe >>> 2.5.0 () >>> UTF-8 BOM detected! >>> UTF-8 BOM detected! >>> >>> >>> But if I run the same script using the standard python interpreter, this is what I get: >>> bin\Debug> D:\Python25\python.exe ..\..\Program.py >>> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit >>> (Intel)] >>> UTF-8 BOM detected! >>> UTF-8 BOM not detected! >>> >>> >>> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >>> >>> Any ideas what is going wrong? >>> >>> >>> >> I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. >> >> Michael >> >> >> >>> Thanks! >>> >>> Best regards, >>> -- Leo >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Tue Nov 10 23:30:26 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 23:30:26 +0100 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <956CF991DC2D324AB6D1FD9093942B49E0755E5C@EXCH-MBX-4.vmware.com> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> <4AF9DBC2.1070804@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> <4AF9E37A.1050300@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5C@EXCH-MBX-4.vmware.com> Message-ID: <4AF9E982.7020902@voidspace.org.uk> Leonides Saguisag wrote: > Hi Michael, > > I am using SharpDevelop 3.1 which comes with "2.5.0 (IronPython 2.0.2 (2.0.0.0) on .NET 2.0.50727.3603)". > > Yeah, that's IronPython 2.0 - which is fine but not as good as IronPython 2.6. ;-) > So this issue is resolved with IronPython 2.6, then? > > No idea. I can't reproduce the problem with IronPython 2.6 though. Try installing IronPython 2 and seeing what happens from the interactive interpreter (whether you can reproduce the problem or not). It is *possible* that it's caused by the way SharpDevelop generates its executables, but that's highly unlikely to be the cause of the problem. All the best, Michael Foord > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 14:05 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Hi Michael, >> >> I just verified the empty string theory that you mentioned and Python25\lib\codecs.py (comes with the standard library in Python 2.5) has the following defined: >> >> >> > You're using IronPython 2.0 then? > > If I use IronPython 2.6 it correctly reports a text file as not starting with the BOM: > > >>> import codecs > >>> codecs.BOM_UTF8 > u'\xef\xbb\xbf' > >>> lines = open('foo.txt').readlines() >>> lines ['foo'] >>> lines[0].startswith(codecs.BOM_UTF8) > False > > > All the best, > > Michael Foord > >> # UTF-8 >> BOM_UTF8 = '\xef\xbb\xbf' >> >> >> So it is not an empty string. >> >> Maybe I am approaching this wrong and you guys can provide me with an alternative way of doing this. I am trying to read a file and determine if the file is encoded in UTF-8 or not. The approach I took was to use python's built-in open function to read the text file into an array of strings and check if the first line starts with the UTF-8 byte order mark by using line.startswith(codecs.BOM_UTF8). As I noted below, this works fine in Python 2.5 but in IronPython it just keeps saying it found a UTF-8 BOM even though there is none present. >> >> Thanks! >> >> -- Leo >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >> Sent: 2009?11?10? 13:32 >> To: Discussion of IronPython >> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >> >> Leonides Saguisag wrote: >> >> >>> Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. >>> >>> >>> >> Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. >> >> If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. >> >> In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. >> IronPython 2.X is a bit odd for the .NET framework in this respect. >> >> Michael >> >> >> >>> Thanks! >>> >>> -- Leo >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael >>> Foord >>> Sent: 2009?11?10? 13:17 >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >>> >>> Leonides Saguisag wrote: >>> >>> >>> >>>> Hi everyone, >>>> >>>> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >>>> >>>> Here is the test script that I put together: >>>> >>>> >>>> import sys >>>> sys.path.append(r'D:\Python25\Lib') >>>> import codecs >>>> >>>> print sys.version >>>> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >>>> myfile.readlines() >>>> myfile.close() >>>> if lines[0].startswith(codecs.BOM_UTF8): >>>> print ('UTF-8 BOM detected!') >>>> else: >>>> print ('UTF-8 BOM not detected!') >>>> >>>> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines >>>> = >>>> myfile.readlines() >>>> myfile.close() >>>> if lines[0].startswith(codecs.BOM_UTF8): >>>> print ('UTF-8 BOM detected!') >>>> else: >>>> print ('UTF-8 BOM not detected!') >>>> >>>> >>>> If I run the executable that I get from SharpDevelop this is what I get: >>>> bin\Debug> Test.exe >>>> 2.5.0 () >>>> UTF-8 BOM detected! >>>> UTF-8 BOM detected! >>>> >>>> >>>> But if I run the same script using the standard python interpreter, this is what I get: >>>> bin\Debug> D:\Python25\python.exe ..\..\Program.py >>>> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit >>>> (Intel)] >>>> UTF-8 BOM detected! >>>> UTF-8 BOM not detected! >>>> >>>> >>>> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >>>> >>>> Any ideas what is going wrong? >>>> >>>> >>>> >>>> >>> I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. >>> >>> Michael >>> >>> >>> >>> >>>> Thanks! >>>> >>>> Best regards, >>>> -- Leo >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>>> >>>> >>>> >>> -- >>> http://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> 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 >>> >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From lsaguisag at vmware.com Tue Nov 10 23:51:29 2009 From: lsaguisag at vmware.com (Leonides Saguisag) Date: Tue, 10 Nov 2009 14:51:29 -0800 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <4AF9E982.7020902@voidspace.org.uk> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> <4AF9DBC2.1070804@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> <4AF9E37A.1050300@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5C@EXCH-MBX-4.vmware.com> <4AF9E982.7020902@voidspace.org.uk> Message-ID: <956CF991DC2D324AB6D1FD9093942B49E0755E5D@EXCH-MBX-4.vmware.com> Hi Michael, It seems to be a bug with IronPython 2.0.x then. I just installed IronPython 2.0.3 and this is what I found: C:\>"C:\Program Files\IronPython 2.0.3\ipy.exe" IronPython 2.0.3 (2.0.0.0) on .NET 2.0.50727.3603 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path.append(r'D:\Python25\lib') >>> import codecs >>> lines = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r').readlines() >>> print lines ['This is a text file without a UTF-8 BOM.\n', 'Line 2\n', 'Line 3'] >>> lines[0].startswith(codecs.BOM_UTF8) True >>> ^Z C:\> It returned 'True' even though the text file did not have a UTF-8 BOM. Contrasted with standard Python 2.5: C:\> D:\Python25\python.exe Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> import codecs >>> lines = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r').readlines() >>> print lines ['This is a text file without a UTF-8 BOM.\n', 'Line 2\n', 'Line 3'] >>> lines[0].startswith(codecs.BOM_UTF8) False >>> ^Z C:\> So it looks like there was a bug in IronPython 2.0.x with regards to the handling of codecs.BOM_UTF8 that now appears to be fixed in IronPython 2.6. Does that sound like a fair assessment? Thanks! -- Leo -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: 2009?11?10? 14:30 To: Discussion of IronPython Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 Leonides Saguisag wrote: > Hi Michael, > > I am using SharpDevelop 3.1 which comes with "2.5.0 (IronPython 2.0.2 (2.0.0.0) on .NET 2.0.50727.3603)". > > Yeah, that's IronPython 2.0 - which is fine but not as good as IronPython 2.6. ;-) > So this issue is resolved with IronPython 2.6, then? > > No idea. I can't reproduce the problem with IronPython 2.6 though. Try installing IronPython 2 and seeing what happens from the interactive interpreter (whether you can reproduce the problem or not). It is *possible* that it's caused by the way SharpDevelop generates its executables, but that's highly unlikely to be the cause of the problem. All the best, Michael Foord > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 14:05 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Hi Michael, >> >> I just verified the empty string theory that you mentioned and Python25\lib\codecs.py (comes with the standard library in Python 2.5) has the following defined: >> >> >> > You're using IronPython 2.0 then? > > If I use IronPython 2.6 it correctly reports a text file as not starting with the BOM: > > >>> import codecs > >>> codecs.BOM_UTF8 > u'\xef\xbb\xbf' > >>> lines = open('foo.txt').readlines() >>> lines ['foo'] >>> > lines[0].startswith(codecs.BOM_UTF8) > False > > > All the best, > > Michael Foord > >> # UTF-8 >> BOM_UTF8 = '\xef\xbb\xbf' >> >> >> So it is not an empty string. >> >> Maybe I am approaching this wrong and you guys can provide me with an alternative way of doing this. I am trying to read a file and determine if the file is encoded in UTF-8 or not. The approach I took was to use python's built-in open function to read the text file into an array of strings and check if the first line starts with the UTF-8 byte order mark by using line.startswith(codecs.BOM_UTF8). As I noted below, this works fine in Python 2.5 but in IronPython it just keeps saying it found a UTF-8 BOM even though there is none present. >> >> Thanks! >> >> -- Leo >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael >> Foord >> Sent: 2009?11?10? 13:32 >> To: Discussion of IronPython >> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >> >> Leonides Saguisag wrote: >> >> >>> Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. >>> >>> >>> >> Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. >> >> If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. >> >> In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. >> IronPython 2.X is a bit odd for the .NET framework in this respect. >> >> Michael >> >> >> >>> Thanks! >>> >>> -- Leo >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael >>> Foord >>> Sent: 2009?11?10? 13:17 >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >>> >>> Leonides Saguisag wrote: >>> >>> >>> >>>> Hi everyone, >>>> >>>> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >>>> >>>> Here is the test script that I put together: >>>> >>>> >>>> import sys >>>> sys.path.append(r'D:\Python25\Lib') >>>> import codecs >>>> >>>> print sys.version >>>> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >>>> myfile.readlines() >>>> myfile.close() >>>> if lines[0].startswith(codecs.BOM_UTF8): >>>> print ('UTF-8 BOM detected!') >>>> else: >>>> print ('UTF-8 BOM not detected!') >>>> >>>> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines >>>> = >>>> myfile.readlines() >>>> myfile.close() >>>> if lines[0].startswith(codecs.BOM_UTF8): >>>> print ('UTF-8 BOM detected!') >>>> else: >>>> print ('UTF-8 BOM not detected!') >>>> >>>> >>>> If I run the executable that I get from SharpDevelop this is what I get: >>>> bin\Debug> Test.exe >>>> 2.5.0 () >>>> UTF-8 BOM detected! >>>> UTF-8 BOM detected! >>>> >>>> >>>> But if I run the same script using the standard python interpreter, this is what I get: >>>> bin\Debug> D:\Python25\python.exe ..\..\Program.py >>>> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit >>>> (Intel)] >>>> UTF-8 BOM detected! >>>> UTF-8 BOM not detected! >>>> >>>> >>>> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >>>> >>>> Any ideas what is going wrong? >>>> >>>> >>>> >>>> >>> I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. >>> >>> Michael >>> >>> >>> >>> >>>> Thanks! >>>> >>>> Best regards, >>>> -- Leo >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>>> >>>> >>>> >>> -- >>> http://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> 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 >>> >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Tue Nov 10 23:53:52 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 10 Nov 2009 23:53:52 +0100 Subject: [IronPython] Weird issue with codecs.BOM_UTF8 In-Reply-To: <956CF991DC2D324AB6D1FD9093942B49E0755E5D@EXCH-MBX-4.vmware.com> References: <956CF991DC2D324AB6D1FD9093942B49E0755E59@EXCH-MBX-4.vmware.com> <4AF9D832.2050101@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5A@EXCH-MBX-4.vmware.com> <4AF9DBC2.1070804@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5B@EXCH-MBX-4.vmware.com> <4AF9E37A.1050300@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5C@EXCH-MBX-4.vmware.com> <4AF9E982.7020902@voidspace.org.uk> <956CF991DC2D324AB6D1FD9093942B49E0755E5D@EXCH-MBX-4.vmware.com> Message-ID: <4AF9EF00.9070102@voidspace.org.uk> Leonides Saguisag wrote: > Hi Michael, > > It seems to be a bug with IronPython 2.0.x then. I just installed IronPython 2.0.3 and this is what I found: > > > C:\>"C:\Program Files\IronPython 2.0.3\ipy.exe" > IronPython 2.0.3 (2.0.0.0) on .NET 2.0.50727.3603 > Type "help", "copyright", "credits" or "license" for more information. > >>>> import sys >>>> sys.path.append(r'D:\Python25\lib') >>>> import codecs >>>> lines = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r').readlines() >>>> print lines >>>> > ['This is a text file without a UTF-8 BOM.\n', 'Line 2\n', 'Line 3'] > >>>> lines[0].startswith(codecs.BOM_UTF8) >>>> > True > >>>> ^Z >>>> > > C:\> > > > It returned 'True' even though the text file did not have a UTF-8 BOM. Contrasted with standard Python 2.5: > > > C:\> D:\Python25\python.exe > Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>>> import sys >>>> import codecs >>>> lines = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r').readlines() >>>> print lines >>>> > ['This is a text file without a UTF-8 BOM.\n', 'Line 2\n', 'Line 3'] > >>>> lines[0].startswith(codecs.BOM_UTF8) >>>> > False > >>>> ^Z >>>> > > C:\> > > > So it looks like there was a bug in IronPython 2.0.x with regards to the handling of codecs.BOM_UTF8 that now appears to be fixed in IronPython 2.6. Does that sound like a fair assessment? > Looks to me like you are right. If the code that checks for the BOM is in your code rather than a library module then you'll have to find another way to do the check I'm afraid. (Or upgrade to IronPython 2.6 of course.) All the best, Michael Foord > Thanks! > > -- Leo > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: 2009?11?10? 14:30 > To: Discussion of IronPython > Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 > > Leonides Saguisag wrote: > >> Hi Michael, >> >> I am using SharpDevelop 3.1 which comes with "2.5.0 (IronPython 2.0.2 (2.0.0.0) on .NET 2.0.50727.3603)". >> >> >> > Yeah, that's IronPython 2.0 - which is fine but not as good as IronPython 2.6. ;-) > > >> So this issue is resolved with IronPython 2.6, then? >> >> >> > > No idea. I can't reproduce the problem with IronPython 2.6 though. Try installing IronPython 2 and seeing what happens from the interactive interpreter (whether you can reproduce the problem or not). It is > *possible* that it's caused by the way SharpDevelop generates its executables, but that's highly unlikely to be the cause of the problem. > > All the best, > > Michael Foord > > >> Thanks! >> >> -- Leo >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >> Sent: 2009?11?10? 14:05 >> To: Discussion of IronPython >> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >> >> Leonides Saguisag wrote: >> >> >>> Hi Michael, >>> >>> I just verified the empty string theory that you mentioned and Python25\lib\codecs.py (comes with the standard library in Python 2.5) has the following defined: >>> >>> >>> >>> >> You're using IronPython 2.0 then? >> >> If I use IronPython 2.6 it correctly reports a text file as not starting with the BOM: >> >> >>> import codecs >> >>> codecs.BOM_UTF8 >> u'\xef\xbb\xbf' >> >>> lines = open('foo.txt').readlines() >>> lines ['foo'] >>> >> lines[0].startswith(codecs.BOM_UTF8) >> False >> >> >> All the best, >> >> Michael Foord >> >> >>> # UTF-8 >>> BOM_UTF8 = '\xef\xbb\xbf' >>> >>> >>> So it is not an empty string. >>> >>> Maybe I am approaching this wrong and you guys can provide me with an alternative way of doing this. I am trying to read a file and determine if the file is encoded in UTF-8 or not. The approach I took was to use python's built-in open function to read the text file into an array of strings and check if the first line starts with the UTF-8 byte order mark by using line.startswith(codecs.BOM_UTF8). As I noted below, this works fine in Python 2.5 but in IronPython it just keeps saying it found a UTF-8 BOM even though there is none present. >>> >>> Thanks! >>> >>> -- Leo >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael >>> Foord >>> Sent: 2009?11?10? 13:32 >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >>> >>> Leonides Saguisag wrote: >>> >>> >>> >>>> Thank you for taking the time to reply. Any idea why this would happen in IronPython but not with the standard Python interpreter? What is weirding me out is that the exact same script behaves differently depending on whether I use IronPython or the standard Python interpreter. >>>> >>>> >>>> >>>> >>> Well, if codecs.BOM_UTF8 is set to the empty string (you didn't say if you have tried this yet?) then it would be due to a bug in IronPython somewhere - but at least you would know what was causing it. >>> >>> If it is the empty string, purely speculating, it could be due to the way the .NET framework treats the BOM at the start of strings. Pure speculation though - that might not be the problem at all or it could be caused by something entirely different. >>> >>> In .NET it would be more normal to check for the BOM with bytes, as by the time you have a string you have (usually) decoded already. >>> IronPython 2.X is a bit odd for the .NET framework in this respect. >>> >>> Michael >>> >>> >>> >>> >>>> Thanks! >>>> >>>> -- Leo >>>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com >>>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael >>>> Foord >>>> Sent: 2009?11?10? 13:17 >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] Weird issue with codecs.BOM_UTF8 >>>> >>>> Leonides Saguisag wrote: >>>> >>>> >>>> >>>> >>>>> Hi everyone, >>>>> >>>>> I am encountering a weird issue with getting to codecs.BOM_UTF8 to work correctly. I am using SharpDevelop 3.1. >>>>> >>>>> Here is the test script that I put together: >>>>> >>>>> >>>>> import sys >>>>> sys.path.append(r'D:\Python25\Lib') >>>>> import codecs >>>>> >>>>> print sys.version >>>>> myfile = open(r'D:\Temp\text_file_with_utf8_bom.txt', 'r') lines = >>>>> myfile.readlines() >>>>> myfile.close() >>>>> if lines[0].startswith(codecs.BOM_UTF8): >>>>> print ('UTF-8 BOM detected!') >>>>> else: >>>>> print ('UTF-8 BOM not detected!') >>>>> >>>>> myfile = open(r'D:\Temp\text_file_without_utf8_bom.txt', 'r') lines >>>>> = >>>>> myfile.readlines() >>>>> myfile.close() >>>>> if lines[0].startswith(codecs.BOM_UTF8): >>>>> print ('UTF-8 BOM detected!') >>>>> else: >>>>> print ('UTF-8 BOM not detected!') >>>>> >>>>> >>>>> If I run the executable that I get from SharpDevelop this is what I get: >>>>> bin\Debug> Test.exe >>>>> 2.5.0 () >>>>> UTF-8 BOM detected! >>>>> UTF-8 BOM detected! >>>>> >>>>> >>>>> But if I run the same script using the standard python interpreter, this is what I get: >>>>> bin\Debug> D:\Python25\python.exe ..\..\Program.py >>>>> 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit >>>>> (Intel)] >>>>> UTF-8 BOM detected! >>>>> UTF-8 BOM not detected! >>>>> >>>>> >>>>> The script works correctly with the standard python interpreter but for some reason is not working right with IronPython. >>>>> >>>>> Any ideas what is going wrong? >>>>> >>>>> >>>>> >>>>> >>>>> >>>> I'm not in a position to check right now, but this could happen if codes.UTF8_BOM is set to the empty string. >>>> >>>> Michael >>>> >>>> >>>> >>>> >>>> >>>>> Thanks! >>>>> >>>>> Best regards, >>>>> -- Leo >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>>> >>>>> >>>>> >>>>> >>>> -- >>>> http://www.ironpythoninaction.com/ >>>> >>>> _______________________________________________ >>>> 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 >>>> >>>> >>>> >>>> >>> -- >>> http://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> 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 >>> >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From cenovsky at bakalari.cz Tue Nov 10 23:59:05 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Tue, 10 Nov 2009 23:59:05 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <4AF9F039.7000301@bakalari.cz> I have just found that the Silverlight binding does not work with this version of clrtype and/or IronPython 2.6RC2. I used DevHawk demo [1] and after I added reference to Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But when I switch to your version, no items show in the listbox. By the way - I have seen a commit message you have added support for interfaces - nice! ;-) -- -- Luk?? [1] http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip Shri Borde wrote: > The following files extend DevHawk's blog and adds support for typed methods with attributes. It will be available as part of the samples released with the 2.6 RTM (over the next month). Do let us know if it works for you. > > Also, I would be curious to know what scenario you need method attributes for (other than DllImport for pinvokes)... > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky > Sent: Thursday, October 22, 2009 10:37 AM > To: Discussion of IronPython > Subject: [IronPython] .NET attributes for methods > > Hi, > I have read all DewHawk blogposts about .Net attributes in IronPython > via __clrtype__ metaclass > (http://devhawk.net/CategoryView,category,__clrtype__.aspx). He > describes how to add attributes to classes but not to methods. Is there > any example how to add attributes to a method. It looks like method > generation is necessary (like for getter and setter or in > http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659) > but this is kind of deep magic for me... > Thanks. > > -- > -- Luk?? > _______________________________________________ > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Shri.Borde at microsoft.com Wed Nov 11 02:05:05 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Wed, 11 Nov 2009 01:05:05 +0000 Subject: [IronPython] .NET attributes for methods In-Reply-To: <4AF9F039.7000301@bakalari.cz> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> Note that you will have to set __metaclass__ to ClrMetaclass, not ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the type. The old name will cause a NameError, but maybe SL is hiding exceptions. Can you do "o.GetType().GetFields()" and display that on the page to inspect the object and also make sure that no exceptions were thrown? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Tuesday, November 10, 2009 2:59 PM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I have just found that the Silverlight binding does not work with this version of clrtype and/or IronPython 2.6RC2. I used DevHawk demo [1] and after I added reference to Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But when I switch to your version, no items show in the listbox. By the way - I have seen a commit message you have added support for interfaces - nice! ;-) -- -- Luk?? [1] http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip Shri Borde wrote: The following files extend DevHawk's blog and adds support for typed methods with attributes. It will be available as part of the samples released with the 2.6 RTM (over the next month). Do let us know if it works for you. Also, I would be curious to know what scenario you need method attributes for (other than DllImport for pinvokes)... -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Thursday, October 22, 2009 10:37 AM To: Discussion of IronPython Subject: [IronPython] .NET attributes for methods Hi, I have read all DewHawk blogposts about .Net attributes in IronPython via __clrtype__ metaclass (http://devhawk.net/CategoryView,category,__clrtype__.aspx). He describes how to add attributes to classes but not to methods. Is there any example how to add attributes to a method. It looks like method generation is necessary (like for getter and setter or in http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_10.shtml#e659) but this is kind of deep magic for me... Thanks. -- -- Luk?? _______________________________________________ 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kfarmer at thuban.org Wed Nov 11 02:45:39 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Tue, 10 Nov 2009 17:45:39 -0800 Subject: [IronPython] TYPO: in exception message Message-ID: "Must have a non-empty display name or a a non-empty list of language names" Note the "a a". Found while playing around with the hosting APIs. -------------- next part -------------- An HTML attachment was scrubbed... URL: From kfarmer at thuban.org Wed Nov 11 05:23:39 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Tue, 10 Nov 2009 20:23:39 -0800 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <4AF9DBCF.9050702@voidspace.org.uk> References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> <4AF9DBCF.9050702@voidspace.org.uk> Message-ID: Well, perhaps because I don't see the upside in breaking things, either. Where I see an upside is in keeping people from taking inappropriate dependencies. :) Making use of IronPython in Action, by the way. One thing that seems to be missing from the hosting API discussion is talk about the ScriptRuntimeSetup classes. Might be worth a posting or two. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Tuesday, November 10, 2009 1:32 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden Hmm... I certainly don't suggest that the dynamic languages team *support* obsolete versions, but in my experience it is 'unusual' for an open source project to make previously released code / binaries *completely* unavailable - support notwithstanding. For Python itself I believe you can download the sources for version 0.9.1, but it isn't much of a maintenance burden these days... I don't see an upside to hiding code (or 'breaking things' as I like to put it) in quite the same way you do. :-) All the best, Michael Keith J. Farmer wrote: > You're right .. the problem *is* a developer taking dependencies on > specific releases. Further, I contend that it's the developer taking > dependencies on experimental releases. That's improper, and why we as > an industry label such things with "alpha", "beta", "RC" and so > forth. Each of those are warning signs of "this may change, and you > shouldn't depend on it yet". > > The low-level point releases, of course, represent (in theory) non-API > fixes, and so the only dependency taken in those cases should not > break, unless the dependency was on broken behavior in which case the > end-user is more likely than not being sloppy. I have no qualms about > them bleeding in that case. > > The years-long-betas of the *nix community notwithstanding, I'd as > soon we stick to our guns regarding such things. Having to maintain > (ie, support) n different versions is a tremendous burden. I myself > had to maintain (no exaggeration) about 3 dozen different versions of > the *same* product at one job, but there were other reasons that came > to be. > > Would an image of a giant Monty Python foot stomping on the prior > versions, with the caption "the version you are requesting has been > obsoleted and is no longer supported -- use at your own risk" be an > acceptable approach? :) > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > *Sent:* Tue 11/10/2009 12:34 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Keith J. Farmer wrote: > > As for the question at hand, though :) > > > > I'm not in blanket agreement here. I'd agree for some releases to be > > valid dependency points, but things like RCs, betas, obsoleted > > third-level versions -- not really. > > > > In the first two cases, those are bleeding-edge releases. If you take > > a dependency on them, expect to bleed. > > > > The problem is that if a developer has used (and depended on) APIs in a > specific release of IronPython then the person who bleeds is likely to > be an end user rather than the developer (who may have moved onto other > things without updating their project). > > I don't have a problem with relegating obsolete releases to a small > corner, but making them unavailable altogether is a high cost. > > Michael > > > > In the latter case, I wouldn't expect API differences, or other > > breaking changes unless they represented critical bug fixes. Again, I > > wouldn't want to support a dependency upon something horribly broken. > > > > In light of the above, then, I'd propose keeping the following versions: > > > > max(x).y.max(z)[.max(b)] > > > > and strongly consider keeping: > > > > [max(x)-1].y.max(z)[.max(b)] > > > > ------------------------------------------------------------------------ > > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > > *Sent:* Tue 11/10/2009 11:25 AM > > *To:* Discussion of IronPython > > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > Keith J. Farmer wrote: > > > "making releases that people / projects may have depended on is an > > unacceptable cost" > > > > > > You wanna rephrase that there, Michael? :) > > > > > > > Ha. :-) > > > > making unavailable releases that people.... > > > > Thanks > > > > Michael > > > -----Original Message----- > > > From: users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > > > Sent: Monday, November 09, 2009 1:47 AM > > > To: Discussion of IronPython > > > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > > > Jimmy Schementi wrote: > > > > > >> I agree, but I think the desire it to keep that "Releases" list > > clean. Otherwise it would have every release ever in there. It's a > > CodePlex limitation that there is no way to hide those releases from > > that list, while still keeping the links active. > > >> > > >> > > > > > > I understand the motivation, but making releases that people / > projects > > > may have depended on is an unacceptable cost in my opinion. > > > > > > _______________________________________________ > > > Users mailing list > > > Users at lists.ironpython.com > > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > > > -- > > http://www.ironpythoninaction.com/ > > > > _______________________________________________ > > 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 > > > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Wed Nov 11 06:25:55 2009 From: slide.o.mix at gmail.com (Slide) Date: Tue, 10 Nov 2009 22:25:55 -0700 Subject: [IronPython] Different file extension import? Message-ID: Is it possible to add extensions to the list of file extensions that are valid for importing? I am writing an application that I want to associate .pyt/.pys files with and they are actually Python scripts that will be used by the application via IronPython. I want to be able to allow importing of other modules, but would still like them to have .pyt/.pys for the file extension. Thanks, slide -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Wed Nov 11 10:16:33 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 11 Nov 2009 09:16:33 +0000 Subject: [IronPython] Fail to execute "import System" on Silverlight embedded interpreter In-Reply-To: <4AF9CC27.3010209@voidspace.org.uk> References: <4AF87FF9.1060607@fiber-space.de> <4AF9CC27.3010209@voidspace.org.uk> Message-ID: <1B42307CD4AADD438CDDA2FE1121CC92035939@TK5EX14MBXC134.redmond.corp.microsoft.com> Kay, This are a couple bad bugs in the current sources; we desperately need to have better test coverage on embedding IronPython in a C# Silverlight app (hopefully I'll get time for that next month). In the meantime, here are fixed, unsigned binaries: http://github.com/jschementi/orphanage/tree/master/embedding-ipy/Dependencies/. The IronPython and DLR sources should have the fix in the next couple days, and we'll discuss getting these fixes in for 2.6 RTM. Michael, I finally tracked down what is causing your sub-directory module importing issue: http://blog.jimmy.schementi.com/2009/11/embedding-ironpython-in-silverlight.html In short, an empty file in the XAP file is the same as a non-existent file, so make sure your __init__.py file(s) are not empty. ~js > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Tuesday, November 10, 2009 12:25 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Fail to execute "import System" on Silverlight > embedded interpreter > > Kay Schluehr wrote: > > Hi IronPython list, > > > > I worked along Michael Foords introductory article about embedding > > IronPython in Silverlight together with his > > "EmbeddingIronPythonSilverlight" project documented here: > > > > > http://www.voidspace.org.uk/ironpython/silverlight/embedding_ironpytho > > n.shtml > > > > > > I added the following two lines to the source code > > > > source = pe.CreateScriptSourceFromString("import System", > > SourceCodeKind.Statements); source.Execute(scope); > > > > This worked all well with the given built and the shipped assemblies. > > > > Yesterday I downloaded the DLR dlr-34133, built it and replaced the > > assemblies of the "EmbeddingIronPython..." project with the latest > > SilverlightDebug ones. Running the code again I get following import > > error: > > > > System.NullReferenceException wurde nicht von Benutzercode behandelt. > > Message="Der Objektverweis wurde nicht auf eine Objektinstanz > > festgelegt." > > StackTrace: > > bei > > Microsoft.Scripting.Silverlight.DynamicApplication.get_BaseUri() > > bei > > Microsoft.Scripting.Silverlight.DynamicApplication.MakeUri(Uri > > baseUri, Uri relativeUri) > > bei > > Microsoft.Scripting.Silverlight.HttpVirtualFilesystem.GetFileInternal( > > Object > > baseUri, Uri relativeUri) > > bei > > Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFileIntern > > al(Object > > storageUnit, String relativePath) > > bei > > Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(Objec > > t > > storageUnit, String relativePath) > > bei > > Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(Strin > > g > > relativePath) > > bei Microsoft.Scripting.Silverlight.BrowserPAL.FileExists(String > > path) > > bei > IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext > > context, String name, String path) > > bei > > IronPython.Runtime.Importer.LoadPackageFromSource(CodeContext > context, > > String name, String path) > > bei IronPython.Runtime.Importer.LoadFromDisk(CodeContext > > context, String name, String fullName, String str) > > bei IronPython.Runtime.Importer.ImportFromPathHook(CodeContext > > context, String name, String fullName, List path, Func`5 defaultLoader) > > bei IronPython.Runtime.Importer.ImportFromPath(CodeContext > > context, String name, String fullName, List path) > > bei IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext > > context, String name) > > bei IronPython.Runtime.Importer.ImportModule(CodeContext > > context, Object globals, String modName, Boolean bottom, Int32 level) > > bei IronPython.Modules.Builtin.__import__(CodeContext context, > > String name, Object globals, Object locals, Object fromlist, Int32 > > level) > > InnerException: > > > > > > Apparently, pre-loading assemblies in the loop > > > > foreach (string name in new string[] { "mscorlib", "System", > > "System.Windows", "System.Windows.Browser", "System.Net" }) > > { > > > > > runtime.LoadAssembly(runtime.Host.PlatformAdaptationLayer.LoadAssembl > y > > (name)); > > > > } > > > > had no effect and IronPython attempts to load the 'System' module from > > the disk as a Python module. The standard import routine "import clr; > > clr.AddReference("System"); import System" causes the same problem. > > I'm puzzled. > > I've had horrible problems with imports in Silverlight when using embedded > IronPython and didn't really get any good answers I'm afraid. :-( > > Michael > > > > > Regards, Kay > > > > > > > > > > _______________________________________________ > > Users mailing list > > Users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jozef.alexovic at gmail.com Wed Nov 11 11:15:58 2009 From: jozef.alexovic at gmail.com (Jozef) Date: Wed, 11 Nov 2009 11:15:58 +0100 Subject: [IronPython] What's wrong with IronPython (UIAutomation) In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7B706E@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <8E45365BECA665489F3CB8878A6C1B7D0C7B706E@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: Thanks for your response. Solution to my problem is to first instantiate AutomationElement from dll, not from IronPython. Then all subsequent AutomationElement retrieved from IronPython looks ok. Jozef 2009/11/6 Shri Borde > In the past, there had been issues with UIAutomation as mentioned in > http://blogs.msdn.com/shrib/archive/2008/03/24/ironpython-cannot-call-automationelement-fromhandle.aspx. > This could be related. You could try it on Win7 to see if its fixed. > > > > You can also try the techniques mentioned in > http://blogs.msdn.com/shrib/archive/2008/03/24/what-if-a-c-snippet-does-not-work-when-transliterated-to-ironpython.aspxto narrow down the problem. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Jozef > *Sent:* Friday, November 06, 2009 6:20 AM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] What's wrong with IronPython (UIAutomation) > > > > Hi, > > > > I'm using UIAutomation framework with IronPython to test our application. > > For WPF dialogs it works perfectly. But I run into trouble when try to use > it for some older dialogs. > > > > The problem: With IronPython I'm not able to get proper control type. Any > controls appears as ControlType.Pane > > > > Simple example: (with windows calculator) > > --------------------------------------- IP Code > ------------------------------------------------------ > > import clr > > > > clr.AddReference('UIAutomationClient') > > clr.AddReference('UIAutomationTypes') > > > > from System.Windows.Automation import * > > > > _rootElement = AutomationElement.RootElement > > > > if __name__ == '__main__': > > > > nameCondition = PropertyCondition(AutomationElement.NameProperty, > "Calculator") > > typeCondition = PropertyCondition(AutomationElement.ControlTypeProperty, > ControlType.Window) > > calcCondition = AndCondition(nameCondition, typeCondition) > > appCalc = _rootElement.FindFirst(TreeScope.Children, calcCondition) > > > > if appCalc is not None: > > > > isFocusable = > appCalc.GetCurrentPropertyValue(AutomationElement.IsKeyboardFocusableProperty, > True) > > > > if isFocusable: > > #appCalc.SetFocus() #calling this raise: System.InvalidOperationException > > pass > > > > contList = appCalc.FindAll(TreeScope.Subtree, Condition.TrueCondition) > > > > for elm in contList: > > progName = elm.Current.ControlType.ProgrammaticName > > print progName > > > ----------------------------------------------------------------------------------------------------------- > > above code produce following output: > > > > ControlType.Window > ControlType.Pane > ControlType.Pane > ControlType.Pane > ControlType.Pane > ControlType.Pane > . > > . > > . > > > > > similar C# code works as expected > > ------------------------------------------ C# Code > --------------------------------------------------- > > using System; > > using System.Collections.Generic; > > using System.Linq; > > using System.Text; > > using System.Windows.Automation; > > using Automation = System.Windows.Automation; > > > > namespace UIAutTest > > { > > class Program > > { > > static void Main(string[] args) > > { > > AutomationElement rootElement = AutomationElement.RootElement; > > > > Automation.Condition nameCondition = new > PropertyCondition(AutomationElement.NameProperty, "Calculator"); > > Automation.Condition controlCondition = new > PropertyCondition(AutomationElement.ControlTypeProperty, > ControlType.Window); > > Automation.Condition calcCondition = new AndCondition(nameCondition, > controlCondition); > > AutomationElement appCalc = rootElement.FindFirst(TreeScope.Children, > calcCondition); > > > > > > if (appCalc != null) > > { > > appCalc.SetFocus(); > > > > AutomationElementCollection allCont = appCalc.FindAll(TreeScope.Subtree, > Condition.TrueCondition); > > foreach (AutomationElement elm in allCont) > > { > > string contProgNam = elm.Current.ControlType.ProgrammaticName; > > Console.WriteLine(contProgNam); > > } > > } > > > > } > > } > > } > > > --------------------------------------------------------------------------------------------- > > C# code produce this output: > > > > ControlType.Window > ControlType.Edit > ControlType.CheckBox > ControlType.CheckBox > ControlType.Group > ControlType.Button > ControlType.RadioButton > ControlType.RadioButton > ControlType.RadioButton > ControlType.RadioButton > ControlType.Group > ControlType.Group > ControlType.RadioButton > ControlType.RadioButton > ControlType.RadioButton > ControlType.Button > . > > . > > > > > > Does anybody know why ControlType property retrieved by IP code is > different then ControlType retrieved by C# ? > > Others element properties retrieved by IP code seems to by OK. > > > > Info: > > Windows Vista Business, SP2 > > IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.4200 > > > > Thanks, > Jozef > > > > PS: Duane Kaufman, send similar question : > http://lists.ironpython.com/htdig.cgi/users-ironpython.com/2009-June/010693.html > . > > But, no one answer him. > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Wed Nov 11 11:36:45 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Wed, 11 Nov 2009 11:36:45 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <4AFA93BD.4040902@bakalari.cz> I did change __metaclass__ to ClrMetaclass. See the attached source I use for testing - the only difference is to comment/uncomment appropriate part in product.py. The outputs look the same, there are no visible exceptions: DevHawk: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) Shri: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) -- -- Luk?? Shri Borde wrote: > > Note that you will have to set __metaclass__ to ClrMetaclass, not > ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the > type. The old name will cause a NameError, but maybe SL is hiding > exceptions. Can you do "o.GetType().GetFields()" and display that on > the page to inspect the object and also make sure that no exceptions > were thrown? > > > > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Tuesday, November 10, 2009 2:59 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I have just found that the Silverlight binding does not work with this > version of clrtype and/or IronPython 2.6RC2. > I used DevHawk demo [1] and after I added reference to > Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But > when I switch to your version, no items show in the listbox. > > By the way - I have seen a commit message you have added support for > interfaces - nice! ;-) > > -- > -- Luk?? > > [1] > http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: clrtypesltest.zip Type: application/x-zip-compressed Size: 6423 bytes Desc: not available URL: From kay at fiber-space.de Wed Nov 11 12:41:56 2009 From: kay at fiber-space.de (Kay Schluehr) Date: Wed, 11 Nov 2009 12:41:56 +0100 Subject: [IronPython] Fail to execute "import System" on Silverlight embedded interpreter In-Reply-To: <1B42307CD4AADD438CDDA2FE1121CC92035939@TK5EX14MBXC134.redmond.corp.microsoft.com> References: <4AF87FF9.1060607@fiber-space.de> <4AF9CC27.3010209@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC92035939@TK5EX14MBXC134.redmond.corp.microsoft.com> Message-ID: <4AFAA304.40601@fiber-space.de> Jimmy Schementi schrieb: > Kay, > > This are a couple bad bugs in the current sources; we desperately need to have better test coverage on embedding IronPython in a C# Silverlight app (hopefully I'll get time for that next month). In the meantime, here are fixed, unsigned binaries: http://github.com/jschementi/orphanage/tree/master/embedding-ipy/Dependencies/. The IronPython and DLR sources should have the fix in the next couple days, and we'll discuss getting these fixes in for 2.6 RTM. > Hi Jimmy, I just finished tracking down the problem in the DLR myself and created a quick fix i.e. a fix which "just works" without any deeper understanding of the underlying import machinery and its data access. Thanks to you and Michael. Regards, Kay From nbuttarelli at gmail.com Wed Nov 11 13:15:54 2009 From: nbuttarelli at gmail.com (=?ISO-8859-1?Q?Nicol=E1s_Buttarelli?=) Date: Wed, 11 Nov 2009 13:15:54 +0100 Subject: [IronPython] Safe execution of python scripts on my .net application In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C78DD9@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <2c2511410911021238k10d57f8duc8ce268a5fbc18ab@mail.gmail.com> <2c2511410911031306m523d8cccs3d0daa248e461bb7@mail.gmail.com> <2c2511410911031329h231181a8g6f9ade8f28de973a@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C2EC54@TK5EX14MBXC118.redmond.corp.microsoft.com> <8E45365BECA665489F3CB8878A6C1B7D0C7B5085@TK5EX14MBXC140.redmond.corp.microsoft.com> <2c2511410911051117w19b1a8a7y54aeee45bd1701a9@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C4C7D0@TK5EX14MBXC118.redmond.corp.microsoft.com> <2c2511410911060035j3c9b12c2xa9b023a2fe743dc9@mail.gmail.com> <2c2511410911090748n6e9c66cem5b601627e54bdf75@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C78DD9@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <2c2511410911110415u2919d92fo8522d770542d1a20@mail.gmail.com> I am not sure if I understood all your comments but I have start from the begining. In this page http://msdn.microsoft.com/en-us/library/bb384237.aspx they explain how to get .NET partial trust scenarios and they say that I should use the PermissionSet class to create a proper sandbox. *Caution:* You cannot create a sandboxed application domain by specifying only evidence. You must specify a grant set or an application domain policy level. (Setting an application domain policy level is not discussed in this topic.) For example, if you use the CreateDomain(String, Evidence)method overload with Internet evidence, the permissions are enforced only at the application domain boundary. Within the application domain, assemblies are granted permissions based on standard security policy. For a console application on your computer, that would be full trust. As I commented before, if I use this CreateDomain method: AppDomain.CreateDomain("ChildDomain1", internetZone, adSetup, internetSet, null); When I create the engine using: *Python.CreateEngine(aSandboxedDomain)* it throws the exception: * System.Runtime.Serialization.SerializationException Type is not resolved for member 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting.* * * * * Dino gave me another way to create the appDomain, it works but it is not enough for what I am trying to do. Could you someone help me trying to understand why the Python.CreateEngine is throwing this exception when I pass as a parameter an AppDomain created with an PermissionSet? Thanks a lot. Nicolas On Mon, Nov 9, 2009 at 7:44 PM, Dino Viehland wrote: > Couple of options spring to mind: > > 1. Setup evidence such that your assembly is given full trust. I > believe you had the start of this in your other code where you were adding > some strong name evidence. You should be able to search the web for normal > .NET partial trust scenarios for getting this right. > > 2. Setup your object model so that it is a MarshalByRefObject which > lives in another app domain. You can then expose the remote object to the > partial trust app domain via SetVariable. > > > > As far as including the DLL ? you can call LoadAssembly on the > ScriptRuntime and give it your assembly. Then the user can import all of > the types from your DLL as they need them. That won?t work w/ #2 though. > Alternately you can implement IAttributesCollection (or use a dynamic object > in 2.6 although IAC is still supported) and create a scope w/ that as the > backing storage. Then you?ll be able to lazily resolve the members rather > than eagerly populating them - although you still need some code to lazily > resolve them. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 09, 2009 7:49 AM > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Hi all again, I am still working with the same problem. > > > > Now I am creating the appDomain in this way by recommendation of Dino: > > > > *public static AppDomain CreateSandboxAppDomain()* > > * {* > > * AppDomainSetup anAppDomainSetup = new AppDomainSetup();* > > * anAppDomainSetup.ApplicationBase = > AppDomain.CurrentDomain.BaseDirectory;* > > * anAppDomainSetup.ApplicationName = "Testing";* > > * Evidence evidence = new Evidence();* > > * evidence.AddHost(new Zone(SecurityZone.Internet));* > > * * > > * AppDomain aSandboxedDomain = AppDomain.CreateDomain("Test > Domain", * > > * > evidence, * > > * > anAppDomainSetup);* > > * * > > * return aSandboxedDomain;* > > * }* > > > > Now it is working but I have security restrictions over some .dll that I > want to have full trusted permissions. I am trying to do this: > > > > *string aPythonScript =* > > *@"aDocument = CDLDocument()* > > *aFigure = TextBlock(1, 'type 1')* > > *anotherFigure = TextBlock(2, 'type 2')* > > *aDocument.AddFigure(aFigure)* > > *aDocument.AddFigure(anotherFigure)* > > *aList = aDocument.Figures* > > *";* > > > > *ScriptSource source = engine.CreateScriptSourceFromString(aPythonScript); > * > > *ScriptScope scope = engine.CreateScope();* > > * * > > *scope.SetVariable("CDLDocument", typeof(CDLDocument));* > > *scope.SetVariable("TextBlock", typeof(TextBlock));* > > *source.Execute(scope);* > > > > This is throwing the System.Security.SecurityException. > > > > 1. How can I give full trusted to a specific dll in an AppDomain? > > > > 2. How can I include a .dll to the scope instead of do a SetVariable for > each type which I have to manage from the python script? > > > > Thanks! > > Nicol?s > > > > 2009/11/6 Nicol?s Buttarelli > > Hi, > > On Fri, Nov 6, 2009 at 1:07 AM, Dino Viehland wrote: > > So you?ve run this as a standalone program and it?s failing? In the > standalone app are all of the IronPython and DLR DLLs present > (IronPython.dll, IronPython.modules.dll, Microsoft.Scripting.Core.dll, > Microsoft.Scripting.dll, Microsoft.Dynamic.dll and > Micrsoft.Scripting.Extensionattribute.dll)? > > Yes I have all this dlls present. > > > > A slightly modified version of this, dropping the strong name, works just > fine for me: > > > > using System; > > using Microsoft.Scripting; > > using Microsoft.Scripting.Hosting; > > using IronPython.Hosting; > > using System.Security; > > using System.Security.Permissions; > > > > class Test { > > public static void Main(string[] args) { > > > > PermissionSet aRestrictedPermissionSet = new > PermissionSet(PermissionState.None); > > aRestrictedPermissionSet.AddPermission(new > SecurityPermission(SecurityPermissionFlag.Execution)); > > > > AppDomainSetup domaininfo = new AppDomainSetup(); > > domaininfo.ApplicationBase = System.Environment.CurrentDirectory; > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed > Domain", > > AppDomain.CurrentDomain.Evidence, > > domaininfo, > > aRestrictedPermissionSet); > > > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString("2+2"); > > ScriptScope scope = engine.CreateScope(); > > Console.WriteLine(source.Execute(scope)); > > > > } > > } > > > Great, I will try this after university. Thanks! > > Compile with: > > > > csc test.cs /r:Microsoft.Scripting.Core.dll /r:Microsoft.Scripting.dll > /r:IronPython.dll > > > > And run and it prints 4. Does that not work for you? > > > > We also have a different way we do this in our test suite which also works: > > > > AppDomainSetup info = new AppDomainSetup(); > > info.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; > > info.ApplicationName = "Test"; > > Evidence evidence = new Evidence(); > > evidence.AddHost(new Zone(SecurityZone.Internet)); > > AppDomain newDomain = AppDomain.CreateDomain("test", evidence, > info); > > > > // create runtime in partial trust... > > ScriptRuntime runtime = Python.CreateRuntime(newDomain); > > > > // get the Python engine... > > ScriptEngine engine = runtime.GetEngine("py"); > > > This make sense too, I will try it. Thanks again. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Thursday, November 05, 2009 11:18 AM > > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Again, thanks everyone for your help. > > > > But.. I bring bad news. This is still not working and it doesn't depend on > the Test environment. > > > > I create another proyect, a Form project, with one button which executes > the following code: > > > > // Creating the permission set to grant other assemblies > > PermissionSet aRestrictedPermissionSet = new > PermissionSet(PermissionState.None); > > aRestrictedPermissionSet.AddPermission(new > SecurityPermission(SecurityPermissionFlag.Execution)); > > > > AppDomainSetup domaininfo = new AppDomainSetup(); > > domaininfo.ApplicationBase = System.Environment.CurrentDirectory; > > > > List strongNameList = new List(); > > strongNameList.Add(CreateStrongName(Assembly.GetExecutingAssembly())); > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain", > > > AppDomain.CurrentDomain.Evidence, > > > domaininfo, > > > aRestrictedPermissionSet, > > > strongNameList.ToArray()); > > > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > It throws this error: > > Type is not resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. > > > > I used the fuslogvw application to see if the Microsoft.Scripting is > loaded, an it is. > > > > What seems strange for me is that anyone has tried this before. I hope to > find some more help here. > > > > Regards, > > Nicolas > > > > > > On Wed, Nov 4, 2009 at 7:36 PM, Shri Borde > wrote: > > http://www.dev102.com/2008/03/22/3-ways-to-run-nunit-from-visual-studio/has some info about test projects and appbase problems. > > > > You can also use fuslogvw ( > http://msdn.microsoft.com/en-us/library/e74a18c4(VS.71).aspx)to see why Microsoft.Scripting.dll is failing to load. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Dino Viehland > *Sent:* Tuesday, November 03, 2009 1:52 PM > > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Test projects are weird and somehow you don?t end up inheriting the > application base. This seems to work though: > > > > AppDomainSetup setup = new AppDomainSetup(); > > setup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory; > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed > Domain", null, setup); > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = > engine.CreateScriptSourceFromString("2+2"); > > ScriptScope scope = engine.CreateScope(); > > Console.WriteLine(source.Execute(scope)); > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 1:30 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > I have create a new "Test Project" and an Unit Test class in order to test > the following code inside: > > > > AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain"); > > ScriptEngine engine = Python.CreateEngine(aSandboxedDomain); > > ScriptSource source = engine.CreateScriptSourceFromString(pythonScript); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > > > I have add the references: > > > > - IronPython > > - Microsoft.Scripting > > - Microsoft.ScriptingCore > > > > But it still not working and throwing the > same System.Runtime.Serialization.SerializationException: Type is not > resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting. > > > > Any ideas? > > > > > > 2009/11/3 Nicol?s Buttarelli > > Thanks Shri, I will try. > > > > In addition, I found this open issue: > http://dlr.codeplex.com/WorkItem/View.aspx?WorkItemId=2816. I think that > it is related. > > > > On Tue, Nov 3, 2009 at 9:29 PM, Shri Borde > wrote: > > I think this happens if the new appdomain cannot load the required > assembly. By default, the new appdomain should inherit its BaseDirectory > property from the creating domain and should be able to load > Microsoft.Scripting.dll. Is your exe and all the dlls in the same folder? If > not, can you try to put all assemblies in the same folder (or in the GAC) to > see if it works? If that works, you can then figure out how to configure the > new appdomain such that it can load Microsoft.Scripting.dll. There may be > some setting in AppDomainSetup, or you could hook the AssemblyResolve event? > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Tuesday, November 03, 2009 12:08 PM > > > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Hi again, thanks for your clear response. > > > > I was trying to do what you proposed but it is not working. I am receiving > an exception: > > > > *Test method > CadworX3WCFRestTest.IronPython.SafeScriptExecutionTest.writingAFileTest > threw exception: System.Runtime.Serialization.SerializationException: Type > is not resolved for member > 'Microsoft.Scripting.Hosting.ScriptRuntimeSetup,Microsoft.Scripting, > Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'..* > > I tried to find a solution but I couldn't. This is the minimal code that I > am running to get this exception (I have removed all the security stuff but > apparently that does not resolve the problem): > > > > *AppDomain aSandboxedDomain = AppDomain.CreateDomain("Sandboxed Domain");* > > > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > *ScriptSource source = engine.CreateScriptSourceFromString(pythonScript);* > > *SriptScope scope = engine.CreateScope();* > > *source.Execute(scope);* > > > > The exception is thronged in this line: > > *ScriptEngine engine = Python.CreateEngine(aSandboxedDomain);* > > > > > > Do you have any idea which could be the problem? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 10:25 PM, Dino Viehland > wrote: > > Assuming the app domain is setup properly then there?s no way for the > Python code to elevate permissions (modulo CLR security bugs which are few > and far between). This is because IronPython its self is 100% security > transparent and does not affect any security decisions or assert any form of > trust ? so it?s all up to the CLR to limit permissions. So for example > while you can access the file object, or import ctypes, or call various > other Python APIs which would require trust you?ll get a security exception > from the CLR when you don?t have permissions to do something. > > > > For more complex scenarios you might also have an object model which you > expose to the application and inject in via its scope. Once you?ve done > that you?ll want to make sure that the object model is also secure. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 1:20 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Safe execution of python scripts on my .net > application > > > > Thanks for your response. > > > > But what happens with the python code? Does not exist a way to write some > scripts that can do some damage to my app, the server, the database, etc? > > > > Thanks again, > > Nicolas > > > > On Mon, Nov 2, 2009 at 9:41 PM, Dino Viehland wrote: > > After creating your app domain you can do: > > > > ScriptEngine engine = Python.CreateEngine(someAppDomain); > > > > And then the rest of your code should work as it?s written. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Nicol?s Buttarelli > *Sent:* Monday, November 02, 2009 12:39 PM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Safe execution of python scripts on my .net > application > > > > Sorry, I don't know if my previous message have arrived. So, here it is: > > > > > > Hello all, > > > > I am starting with python and I would like to add to my web application > some web services. This services will allow the different clients of my > application to execute some python scripts. > > > > I would like to know if someone did this before and how can I do this in a > secure way. I mean, how can I do to restrict the environment where the > scripts will be executed. > > > > In .net I can do this using the AppDoman and setting the permission set. > > > > AppDomain.CreateDomain( string friendlyName, > Evidence securityInfo, > AppDomainSetup info, > PermissionSet grantSet, > params StrongName[] fullTrustAssemblies); > > > > > > Is there a way to do the same with my python scripts? > > > > I am running them using this: > > > > ScriptEngine engine = Python.CreateEngine(); > > ScriptSource source = engine.CreateScriptSourceFromString(scriptAsString); > > ScriptScope scope = engine.CreateScope(); > > source.Execute(scope); > > > > Thanks in advance. > > Nicolas > > > _______________________________________________ > 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 > > > > > _______________________________________________ > 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 > > > > > _______________________________________________ > 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Wed Nov 11 15:12:39 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Wed, 11 Nov 2009 15:12:39 +0100 Subject: [IronPython] DataBinding and INotifyPropertyChanged in IronPython In-Reply-To: References: <4AF49C0E.7080503@bakalari.cz> Message-ID: <4AFAC657.507@bakalari.cz> __setattr__ is not clean and easy readable piece of code. That's why I dive into decorators and create a *notify_property*: class notify_property(property): def __init__(self, getter): def newgetter(slf): #return None when the property does not exist yet try: return getter(slf) except AttributeError: return None super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): # do not change value if the new value is the same # trigger PropertyChanged event when value changes oldvalue = self.fget(slf) if oldvalue != newvalue: setter(slf, newvalue) slf.OnPropertyChanged(setter.__name__) return property( fget=self.fget, fset=newsetter, fdel=self.fdel, doc=self.__doc__) The usage is the same as for @property - see details on my blog: http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html Unfortunately, this does not work in Silverlight - probably because such properties are not CLR fields. I'd like to find a way to make it work in Silverlight too. -- -- Luk?? Curt Hagenlocher wrote: > Why don't you think that __setattr__ is a good approach? The > alternative (as shown in the linked Japanese-language blog) is to > implement setters for the properties you care about and to manually > trigger the event. > 2009/11/6 Lukas Cenovsky > > > Hi all, > I was looking for WPF data binding in IronPython and I have found > nice Japanese blog about it: > http://palepoli.skr.jp/wp/2009/06/28/wpf-listview-databinding-for-ironpython/ > > It links to > http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=30322 that > should have more information about how to implement > INotifyPropertyChanged in IronPython which I am also interested > in. Unfortunately this page is no more available. Does the > guideline exist somewhere else? Thanks. > > PS: I know about > http://lists.ironpython.com/pipermail/users-ironpython.com/2009-August/010938.html > but I don't think using __setattr__ is good approach. Also > implementing the PropertyChanged event is different on the blog. > > -- > -- Luk?? > _______________________________________________ > 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Wed Nov 11 16:14:29 2009 From: matan504 at gmail.com (matan keret) Date: Wed, 11 Nov 2009 17:14:29 +0200 Subject: [IronPython] How to convert a 'str' type to byteArray Message-ID: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> hi, I have the following code which gets an image from an email. after getting it i need to pass it as a byteArray (byte[] in C#) to a C# function. i tried all sorts of things but no luck. I'm using ironPython 2.0.3 the important parts of the code are: # getting the image from the e-mail image = part.get_payload() # my try to cast the str into a byteArray byteArray = BitConverter.GetBytes(image.ToCharArray()) this last line returns 1 byte and doesn't seem to do the job. is there any equivalent to the 'bytearray(image)' function in CPython? thanks, Matan -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom.wright at resolversystems.com Wed Nov 11 16:22:04 2009 From: tom.wright at resolversystems.com (Tom Wright) Date: Wed, 11 Nov 2009 15:22:04 +0000 Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of types In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C80057@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <4AF49C0E.7080503@bakalari.cz> <1B42307CD4AADD438CDDA2FE1121CC9202F678@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF9A538.2020103@resolversystems.com> <1A472770E042064698CB5ADC83A12ACD04C7FC3D@TK5EX14MBXC118.redmond.corp.microsoft.com> <4AF9AC19.6060201@resolversystems.com> <1A472770E042064698CB5ADC83A12ACD04C80057@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <4AFAD69C.6000402@resolversystems.com> Thanks for the response. I've discovered the bug: I had clr.CompileSubclassTypes(name, listOfTypes) instead of clr.CompileSubclassTypes(name, *listOfTypes) Tom Dino Viehland wrote: > The restrictions are per-subclass so for example you cannot inherit > from both a list and tuple. The reason here is that list and tuple both > have their own independent layout in memory and there's no relationship > between them. Or in your case it's set and float. > > CompileSubclassTypes takes an arbitrary number of parameters and those > can be either a type (which gets compiled) or they can be a tuple of types > which specify the collection of base types. The latter form is generally useful > for including .NET interfaces. > > So clr.CompileSubclassTypes("foo", (set, float)) will fail as this is > specifying that you want 1 class which inherits from both set and float. > > But you can do clr.CompileSubclassTypes("foo", set, float) and this specifies > what you want 2 types, one that inherits from set and float. > > Or you can do: > > clr.CompileSubclassTypes("foo", (set, ), (float, )) > > and again that'll work because it's specifying 2 different base types. > > > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Tom Wright >> Sent: Tuesday, November 10, 2009 10:08 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] clr.CompileSubclassTypes restrictions on list of >> types >> >> Thanks the reply, >> >> Could you clarify slightly what you mean by the Python's normal >> restrictions. I was guessing the restriction might be something like: >> >> "When compiling a list of types, if the list contains a class B which >> inherits from A then A must be contained in the list." >> >> The interesting thing here is that the call to CompileSubclassTypes >> works when we pass it one huge list of types, but not when we call if >> repeatedly with smaller lists. >> >> Thanks >> Tom >> >> Dino Viehland wrote: >> >>> The only restrictions are the normal restrictions that Python has regarding >>> inheritance. In this case it looks like you're hitting that you cannot >>> inherit from more than one base type w/ a different layout. >>> >>> Basically it looks like you're trying to pre-compile the equivalent of: >>> >>> class c(float, set): pass >>> >>> Which isn't legal in Python so my guess is there is an issue w/ the way you >>> split them up. >>> >>> >>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users- >>>> bounces at lists.ironpython.com] On Behalf Of Tom Wright >>>> Sent: Tuesday, November 10, 2009 9:39 AM >>>> To: Discussion of IronPython >>>> Subject: [IronPython] clr.CompileSubclassTypes restrictions on list of >>>> >> types >> >>>> Hi, >>>> >>>> Are there any restrictions placed on the list of types that can be >>>> passed to CompileSubclassTypes? >>>> >>>> We are having issues with a clr.AddReference(DllContainingSubclasses) >>>> being very slow, so are trying to split the compiled subclasses across >>>> multiple dlls to indicate progress between the loading of these dlls. >>>> >>>> However, when trying to compile a partial list of types we get the >>>> following error: >>>> >>>> Traceback (most recent call last): >>>> File "c:\buildshare\gitrepo\precompile_subclasses.py", line 40, in >>>> c:\buildsha >>>> re\gitrepo\precompile_subclasses.py >>>> TypeError: : can only extend one CLI or builtin type, not both >>>> Microsoft.Scripti >>>> ng.Runtime.Extensible`1[[System.Double, mscorlib, Version=2.0.0.0, >>>> Culture=neutr >>>> al, PublicKeyToken=b77a5c561934e089]] (for >>>> IronPython.Runtime.Types.PythonType) >>>> and IronPython.Runtime.SetCollection (for >>>> IronPython.Runtime.Types.PythonType) >>>> >>>> >>>> Any help is much appreciated, >>>> Tom >>>> _______________________________________________ >>>> 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 >>> >>> >> _______________________________________________ >> 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 > From Brian.Ushman at tradingtechnologies.com Wed Nov 11 16:58:37 2009 From: Brian.Ushman at tradingtechnologies.com (Brian Ushman (TT)) Date: Wed, 11 Nov 2009 09:58:37 -0600 Subject: [IronPython] Help - Running IPY with .NET 3.5 Message-ID: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> Hello to All, I am new to Python in general, but I have downloaded the latest release of IronPython. I am using Windows XP SP3 x64. Everytime I start IPY is says that it is using .NET 2.0, however I would like it to load with .NET 3.5. From what I have read on the latest release of IPY, this should be possible but I have been unsuccessful. Is there a way to force IPY to load with .NET 3.5? Thank you! -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed Nov 11 16:58:44 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 16:58:44 +0100 Subject: [IronPython] How to convert a 'str' type to byteArray In-Reply-To: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> References: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> Message-ID: <4AFADF34.3040903@voidspace.org.uk> matan keret wrote: > hi, > > I have the following code which gets an image from an email. > after getting it i need to pass it as a byteArray (byte[] in C#) to a > C# function. > i tried all sorts of things but no luck. I'm using ironPython 2.0.3 > > the important parts of the code are: > > # getting the image from the e-mail > image = part.get_payload() > > # my try to cast the str into a byteArray > byteArray = BitConverter.GetBytes(image.ToCharArray()) > > > this last line returns 1 byte and doesn't seem to do the job. > is there any equivalent to the 'bytearray(image)' function in CPython? I have no idea about the *specific* APIs you mention, but you can turn a string into a byte array with code like this (ignoring encoding issues): from System import Array, Byte byteArray = Array[Byte](ord(c) for c in some_string) HTH! Michael > > thanks, > Matan > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Wed Nov 11 17:07:22 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 17:07:22 +0100 Subject: [IronPython] Help - Running IPY with .NET 3.5 In-Reply-To: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> References: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> Message-ID: <4AFAE13A.9050000@voidspace.org.uk> Brian Ushman (TT) wrote: > > Hello to All, > > > > I am new to Python in general, but I have downloaded the latest > release of IronPython. I am using Windows XP SP3 x64. Everytime I > start IPY is says that it is using .NET 2.0, however I would like it > to load with .NET 3.5. From what I have read on the latest release of > IPY, this should be possible but I have been unsuccessful. Is there a > way to force IPY to load with .NET 3.5? > > > .NET 3.5 is really just a set of new libraries on top of .NET 2, there is no new CLR as part of .NET 3.5. If you have .NET 3.5 then when you run IronPython you are using .NET 3.5... All the best, Michael Foord > Thank you! > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From Brian.Ushman at tradingtechnologies.com Wed Nov 11 17:10:32 2009 From: Brian.Ushman at tradingtechnologies.com (Brian Ushman (TT)) Date: Wed, 11 Nov 2009 10:10:32 -0600 Subject: [IronPython] Help - Running IPY with .NET 3.5 In-Reply-To: <4AFAE13A.9050000@voidspace.org.uk> References: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> <4AFAE13A.9050000@voidspace.org.uk> Message-ID: <32490DFF7774554A85D65D23A9F0F9380BC78EAC@chiex01> Thanks for your reply Michael. That makes sense that the clr has not changed. However, how would I have it load the newer .NET libraries instead of the 2.0 version. In my specific case I am trying to call the function "SequenceEqual" from the System.Array class. But is says that this method does not exist. I looked in the documentation and this function only exists 3.5 and later. That is what led me to believe that it is loading an older version of .NET that does not have this method available. Any ideas? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Wednesday, November 11, 2009 10:07 AM To: Discussion of IronPython Subject: Re: [IronPython] Help - Running IPY with .NET 3.5 Brian Ushman (TT) wrote: > > Hello to All, > > > > I am new to Python in general, but I have downloaded the latest > release of IronPython. I am using Windows XP SP3 x64. Everytime I > start IPY is says that it is using .NET 2.0, however I would like it > to load with .NET 3.5. From what I have read on the latest release of > IPY, this should be possible but I have been unsuccessful. Is there a > way to force IPY to load with .NET 3.5? > > > .NET 3.5 is really just a set of new libraries on top of .NET 2, there is no new CLR as part of .NET 3.5. If you have .NET 3.5 then when you run IronPython you are using .NET 3.5... All the best, Michael Foord > Thank you! > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Wed Nov 11 17:14:19 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 17:14:19 +0100 Subject: [IronPython] Help - Running IPY with .NET 3.5 In-Reply-To: <32490DFF7774554A85D65D23A9F0F9380BC78EAC@chiex01> References: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> <4AFAE13A.9050000@voidspace.org.uk> <32490DFF7774554A85D65D23A9F0F9380BC78EAC@chiex01> Message-ID: <4AFAE2DB.9070905@voidspace.org.uk> Brian Ushman (TT) wrote: > Thanks for your reply Michael. > > That makes sense that the clr has not changed. However, how would I > have it load the newer .NET libraries instead of the 2.0 version. > > In my specific case I am trying to call the function "SequenceEqual" > from the System.Array class. But is says that this method does not > exist. I looked in the documentation and this function only exists 3.5 > and later. That is what led me to believe that it is loading an older > version of .NET that does not have this method available. > > Any ideas? > You will get .NET 3.5 by default - however to import some of the .NET 3.5 classes you will need to add references to the correct assemblies. Is that method an extension method? They are not usually available directly in IronPython. There have been a few emails / blog entries on the topic if you google for them. All the best, Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Wednesday, November 11, 2009 10:07 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Help - Running IPY with .NET 3.5 > > Brian Ushman (TT) wrote: > >> Hello to All, >> >> >> >> I am new to Python in general, but I have downloaded the latest >> release of IronPython. I am using Windows XP SP3 x64. Everytime I >> start IPY is says that it is using .NET 2.0, however I would like it >> to load with .NET 3.5. From what I have read on the latest release of >> > > >> IPY, this should be possible but I have been unsuccessful. Is there a >> > > >> way to force IPY to load with .NET 3.5? >> >> >> >> > .NET 3.5 is really just a set of new libraries on top of .NET 2, there > is no new CLR as part of .NET 3.5. If you have .NET 3.5 then when you > run IronPython you are using .NET 3.5... > > All the best, > > Michael Foord > > > >> Thank you! >> >> >> > ------------------------------------------------------------------------ > >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Wed Nov 11 17:31:42 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 17:31:42 +0100 Subject: [IronPython] Fail to execute "import System" on Silverlight embedded interpreter In-Reply-To: <1B42307CD4AADD438CDDA2FE1121CC92035939@TK5EX14MBXC134.redmond.corp.microsoft.com> References: <4AF87FF9.1060607@fiber-space.de> <4AF9CC27.3010209@voidspace.org.uk> <1B42307CD4AADD438CDDA2FE1121CC92035939@TK5EX14MBXC134.redmond.corp.microsoft.com> Message-ID: <4AFAE6EE.9030308@voidspace.org.uk> Thanks for this Jimmy - looks like great progress. Michael Jimmy Schementi wrote: > Kay, > > This are a couple bad bugs in the current sources; we desperately need to have better test coverage on embedding IronPython in a C# Silverlight app (hopefully I'll get time for that next month). In the meantime, here are fixed, unsigned binaries: http://github.com/jschementi/orphanage/tree/master/embedding-ipy/Dependencies/. The IronPython and DLR sources should have the fix in the next couple days, and we'll discuss getting these fixes in for 2.6 RTM. > > Michael, I finally tracked down what is causing your sub-directory module importing issue: > http://blog.jimmy.schementi.com/2009/11/embedding-ironpython-in-silverlight.html > > In short, an empty file in the XAP file is the same as a non-existent file, so make sure your __init__.py file(s) are not empty. > > ~js > > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Michael Foord >> Sent: Tuesday, November 10, 2009 12:25 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] Fail to execute "import System" on Silverlight >> embedded interpreter >> >> Kay Schluehr wrote: >> >>> Hi IronPython list, >>> >>> I worked along Michael Foords introductory article about embedding >>> IronPython in Silverlight together with his >>> "EmbeddingIronPythonSilverlight" project documented here: >>> >>> >>> >> http://www.voidspace.org.uk/ironpython/silverlight/embedding_ironpytho >> >>> n.shtml >>> >>> >>> I added the following two lines to the source code >>> >>> source = pe.CreateScriptSourceFromString("import System", >>> SourceCodeKind.Statements); source.Execute(scope); >>> >>> This worked all well with the given built and the shipped assemblies. >>> >>> Yesterday I downloaded the DLR dlr-34133, built it and replaced the >>> assemblies of the "EmbeddingIronPython..." project with the latest >>> SilverlightDebug ones. Running the code again I get following import >>> error: >>> >>> System.NullReferenceException wurde nicht von Benutzercode behandelt. >>> Message="Der Objektverweis wurde nicht auf eine Objektinstanz >>> festgelegt." >>> StackTrace: >>> bei >>> Microsoft.Scripting.Silverlight.DynamicApplication.get_BaseUri() >>> bei >>> Microsoft.Scripting.Silverlight.DynamicApplication.MakeUri(Uri >>> baseUri, Uri relativeUri) >>> bei >>> Microsoft.Scripting.Silverlight.HttpVirtualFilesystem.GetFileInternal( >>> Object >>> baseUri, Uri relativeUri) >>> bei >>> Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFileIntern >>> al(Object >>> storageUnit, String relativePath) >>> bei >>> Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(Objec >>> t >>> storageUnit, String relativePath) >>> bei >>> Microsoft.Scripting.Silverlight.BrowserVirtualFilesystem.GetFile(Strin >>> g >>> relativePath) >>> bei Microsoft.Scripting.Silverlight.BrowserPAL.FileExists(String >>> path) >>> bei >>> >> IronPython.Runtime.Importer.LoadModuleFromSource(CodeContext >> >>> context, String name, String path) >>> bei >>> IronPython.Runtime.Importer.LoadPackageFromSource(CodeContext >>> >> context, >> >>> String name, String path) >>> bei IronPython.Runtime.Importer.LoadFromDisk(CodeContext >>> context, String name, String fullName, String str) >>> bei IronPython.Runtime.Importer.ImportFromPathHook(CodeContext >>> context, String name, String fullName, List path, Func`5 defaultLoader) >>> bei IronPython.Runtime.Importer.ImportFromPath(CodeContext >>> context, String name, String fullName, List path) >>> bei IronPython.Runtime.Importer.ImportTopAbsolute(CodeContext >>> context, String name) >>> bei IronPython.Runtime.Importer.ImportModule(CodeContext >>> context, Object globals, String modName, Boolean bottom, Int32 level) >>> bei IronPython.Modules.Builtin.__import__(CodeContext context, >>> String name, Object globals, Object locals, Object fromlist, Int32 >>> level) >>> InnerException: >>> >>> >>> Apparently, pre-loading assemblies in the loop >>> >>> foreach (string name in new string[] { "mscorlib", "System", >>> "System.Windows", "System.Windows.Browser", "System.Net" }) >>> { >>> >>> >>> >> runtime.LoadAssembly(runtime.Host.PlatformAdaptationLayer.LoadAssembl >> y >> >>> (name)); >>> >>> } >>> >>> had no effect and IronPython attempts to load the 'System' module from >>> the disk as a Python module. The standard import routine "import clr; >>> clr.AddReference("System"); import System" causes the same problem. >>> I'm puzzled. >>> >> I've had horrible problems with imports in Silverlight when using embedded >> IronPython and didn't really get any good answers I'm afraid. :-( >> >> Michael >> >> >>> Regards, Kay >>> >>> >>> >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 > -- http://www.ironpythoninaction.com/ From merllab at microsoft.com Wed Nov 11 17:54:44 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Wed, 11 Nov 2009 08:54:44 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <68d7160c-7d63-4640-8884-3c1ebf6016c6@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61287. ADDED SOURCES $/IronPython/IronPython_Main/Src/IronPython/Runtime/CollectionDebugView.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/ObjectDebugView.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/BranchLabel.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ControlFlowInstructions.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructionN.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructions.Generated.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/FieldOperations.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NumericConvertInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/TypeOperations.cs DELETED SOURCES $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/DynamicInstructions.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/DynamicInstructions.Generated.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/LightCompilerDebugView.cs MODIFIED SOURCES $/IronPython/IronPython_Main/Src/IronPython/Compiler/GeneratorRewriter.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/LazyCode.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/PythonScriptCode.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/CollectionDebugView.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/ObjectDebugView.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/BranchLabel.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/AddInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ArrayOperations.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/CallInstruction.Generated.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Hosting/Shell/OptionsParser.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Generation/CompilerHelpers.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/CodeContext.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/PythonGlobalVariableExpression.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/RuntimeScriptCode.cs $/IronPython/IronPython_Main/Src/IronPython.Modules/_collections.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Binding/PythonGetMemberBinder.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Types/NewTypeMaker.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/FunctionCode.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/PythonFunction.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/PythonDictionary.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/PythonModule.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Types/PythonType.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/PythonTuple.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Types/OldInstance.cs $/IronPython/IronPython_Main/Src/IronPython/GlobalSuppressions.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Types/OldClass.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Operations/PythonOps.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Operations/UserTypeOps.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/List.cs $/IronPython/IronPython_Main/Src/IronPython/Runtime/Set.cs $/IronPython/IronPython_Main/Src/IronPython/Compiler/Ast/FunctionDefinition.cs $/IronPython/IronPython_Main/Src/IronPython/IronPython.csproj $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/ControlFlowInstructions.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructionN.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/DynamicInstructions.Generated.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/EqualInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/FieldOperations.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/GreaterThanInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/InstructionList.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LessThanInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NotEqualInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/NumericConvertInstruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/TypeOperations.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/Instruction.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/LocalAccess.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Instructions/StackOperations.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/Interpreter.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/InterpretedFrame.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/LightCompiler.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/LightLambda.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/LastFaultingLineExpression.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Interpreter/LightDelegateCreator.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/PerfTrack.cs $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting/Hosting/LanguageSetup.cs $/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleFlags.ps1 $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Scripting/LanguageOptions.cs $/IronPython/IronPython_Main/Src/Scripts/generate_dynamic_instructions.py $/IronPython/IronPython_Main/Src/Scripts/generate_reflected_calls.py $/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleHelp.Debug.out $/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleHelp.Release.out CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1263511 Date: 11/10/2009 10:48:22 AM (dinov) Adds various DebuggerDisplay and DebuggerTypeProxy attributes and implementations for an improved debugging experience. This covers old-style and new-style classes and instances, built-in types such as list, tuple, dict, set, frozenset, and deque, functions, modules, and code context (which currently gets displayed as a module). There?ll need to be another round of making sure that we properly expose variables in local/global scopes that make it obvious how to get to locals/globals. I?m waiting for the NewAst change before doing that though. (Shelveset: AddDebugViewsFinal2;REDMOND\dinov | SNAP CheckinId: 9783) From dfugate at microsoft.com Wed Nov 11 18:31:13 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Wed, 11 Nov 2009 17:31:13 +0000 Subject: [IronPython] Help - Running IPY with .NET 3.5 In-Reply-To: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> References: <32490DFF7774554A85D65D23A9F0F9380BC78E8A@chiex01> Message-ID: <7CEEC335D70FFE4B957737DDE836F51B104AD375@TK5EX14MBXC123.redmond.corp.microsoft.com> Creating a file named ipy.exe.config alongside ipy.exe that looks similar to: will force IronPython to run against the given CLR runtime. Dave From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Brian Ushman (TT) Sent: Wednesday, November 11, 2009 7:59 AM To: users at lists.ironpython.com Subject: [IronPython] Help - Running IPY with .NET 3.5 Hello to All, I am new to Python in general, but I have downloaded the latest release of IronPython. I am using Windows XP SP3 x64. Everytime I start IPY is says that it is using .NET 2.0, however I would like it to load with .NET 3.5. >From what I have read on the latest release of IPY, this should be possible but I have been unsuccessful. Is there a way to force IPY to load with .NET 3.5? Thank you! -------------- next part -------------- An HTML attachment was scrubbed... URL: From josh at globalherald.net Wed Nov 11 20:12:17 2009 From: josh at globalherald.net (Joshua Kramer) Date: Wed, 11 Nov 2009 14:12:17 -0500 (EST) Subject: [IronPython] Embedding Python in MS-Office Message-ID: Hello, Does anyone have examples handy of how you might embed an IronPython script in MSO? For example, you might have a menu item that, when you select it, uses Python to aggregate data from outside sources and insert the data into a Word document or Excel cells. My end goal here is to make an abstraction library so that if you write an Office script, the same script can be used unmodified on MS-Office or OpenOffice. I've done scripts like this for OpenOffice but not MSO. Cheers, -JK -- ----- http://www.globalherald.net/jb01 From slide.o.mix at gmail.com Wed Nov 11 18:46:17 2009 From: slide.o.mix at gmail.com (Slide) Date: Wed, 11 Nov 2009 10:46:17 -0700 Subject: [IronPython] Embedding Python in MS-Office In-Reply-To: References: Message-ID: You'd have to write an add-in for office that hosted the .NET runtime and provided a hosting API that IP could interact with. I don't think this would be a small undertaking. slide On Wed, Nov 11, 2009 at 12:12 PM, Joshua Kramer wrote: > > Hello, > > Does anyone have examples handy of how you might embed an IronPython script > in MSO? > > For example, you might have a menu item that, when you select it, uses > Python to aggregate data from outside sources and insert the data into a > Word document or Excel cells. > > My end goal here is to make an abstraction library so that if you write an > Office script, the same script can be used unmodified on MS-Office or > OpenOffice. I've done scripts like this for OpenOffice but not MSO. > > Cheers, > -JK > > -- > > ----- > http://www.globalherald.net/jb01 > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From vernondcole at gmail.com Wed Nov 11 20:47:23 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Wed, 11 Nov 2009 12:47:23 -0700 Subject: [IronPython] How to convert a 'str' type to byteArray In-Reply-To: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> References: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> Message-ID: Make sure what data type is really being returned by part.getpayload() . Perhaps it is already in a suitable for when you get it? The Python 2.x language method of loading a binary blob of memory is to use the built in function "buffer" s = 'this is a string' b = buffer(s) "b" will be accepted my a byte arrary in most cases. but make sure that what you have is a legal ASCII string. CPython stores "strings" in ASCII and "unicode" differently. Iron Python stores "strings" in unicode, and buffer() tries to be smart about hiding that fact, in order to act like CPython in the easy cases. The above will work the same in either IronPython or CPython. On the other hand, in CPython: u = u'this is a unicode string' b = buffer(u) will produce a blob twice (or four times) as long as the above, since it stores all 16 (or 32) bits of the character code. (IronPython seems to store them internally in UTF-8 or some similar code.) To convert to "proper" 8-bit codes you must use something like: u = u'unicode string' b = buffer(u.encode('latin-1')) Python 3.x removes the problem by defining all character strings as unicode (as IronPython does now), and providing a byte() function, in which each 8 byte is treated as an integer, rather than a character. That will make things simpler in the future. -- VC On Wed, Nov 11, 2009 at 8:14 AM, matan keret wrote: > hi, > > I have the following code which gets an image from an email. > after getting it i need to pass it as a byteArray (byte[] in C#) to a C# > function. > i tried all sorts of things but no luck. I'm using ironPython 2.0.3 > > the important parts of the code are: > > # getting the image from the e-mail > image = part.get_payload() > > # my try to cast the str into a byteArray > byteArray = BitConverter.GetBytes(image.ToCharArray()) > > > this last line returns 1 byte and doesn't seem to do the job. > is there any equivalent to the 'bytearray(image)' function in CPython? > > thanks, > Matan > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed Nov 11 22:20:41 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 22:20:41 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> <4AF9DBCF.9050702@voidspace.org.uk> Message-ID: <4AFB2AA9.40606@voidspace.org.uk> Keith J. Farmer wrote: > Well, perhaps because I don't see the upside in breaking things, either. Where I see an upside is in keeping people from taking inappropriate dependencies. :) > You won't stop them taking dependencies on the latest released version (people are building stuff against IP 2.6 RC 2 as we speak). All you do is make those dependencies unavailable to users once the next release is out. > Making use of IronPython in Action, by the way. One thing that seems to be missing from the hosting API discussion is talk about the ScriptRuntimeSetup classes. Might be worth a posting or two. > > Sounds like something good to include in the next edition. :-) All the best, Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Tuesday, November 10, 2009 1:32 PM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Hmm... I certainly don't suggest that the dynamic languages team > *support* obsolete versions, but in my experience it is 'unusual' for an > open source project to make previously released code / binaries > *completely* unavailable - support notwithstanding. > > For Python itself I believe you can download the sources for version > 0.9.1, but it isn't much of a maintenance burden these days... > > I don't see an upside to hiding code (or 'breaking things' as I like to > put it) in quite the same way you do. :-) > > All the best, > > Michael > > Keith J. Farmer wrote: > >> You're right .. the problem *is* a developer taking dependencies on >> specific releases. Further, I contend that it's the developer taking >> dependencies on experimental releases. That's improper, and why we as >> an industry label such things with "alpha", "beta", "RC" and so >> forth. Each of those are warning signs of "this may change, and you >> shouldn't depend on it yet". >> >> The low-level point releases, of course, represent (in theory) non-API >> fixes, and so the only dependency taken in those cases should not >> break, unless the dependency was on broken behavior in which case the >> end-user is more likely than not being sloppy. I have no qualms about >> them bleeding in that case. >> >> The years-long-betas of the *nix community notwithstanding, I'd as >> soon we stick to our guns regarding such things. Having to maintain >> (ie, support) n different versions is a tremendous burden. I myself >> had to maintain (no exaggeration) about 3 dozen different versions of >> the *same* product at one job, but there were other reasons that came >> to be. >> >> Would an image of a giant Monty Python foot stomping on the prior >> versions, with the caption "the version you are requesting has been >> obsoleted and is no longer supported -- use at your own risk" be an >> acceptable approach? :) >> >> ------------------------------------------------------------------------ >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >> *Sent:* Tue 11/10/2009 12:34 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> Keith J. Farmer wrote: >> >>> As for the question at hand, though :) >>> >>> I'm not in blanket agreement here. I'd agree for some releases to be >>> valid dependency points, but things like RCs, betas, obsoleted >>> third-level versions -- not really. >>> >>> In the first two cases, those are bleeding-edge releases. If you take >>> a dependency on them, expect to bleed. >>> >>> >> The problem is that if a developer has used (and depended on) APIs in a >> specific release of IronPython then the person who bleeds is likely to >> be an end user rather than the developer (who may have moved onto other >> things without updating their project). >> >> I don't have a problem with relegating obsolete releases to a small >> corner, but making them unavailable altogether is a high cost. >> >> Michael >> >> >> >>> In the latter case, I wouldn't expect API differences, or other >>> breaking changes unless they represented critical bug fixes. Again, I >>> wouldn't want to support a dependency upon something horribly broken. >>> >>> In light of the above, then, I'd propose keeping the following versions: >>> >>> max(x).y.max(z)[.max(b)] >>> >>> and strongly consider keeping: >>> >>> [max(x)-1].y.max(z)[.max(b)] >>> >>> ------------------------------------------------------------------------ >>> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >>> *Sent:* Tue 11/10/2009 11:25 AM >>> *To:* Discussion of IronPython >>> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >>> >>> Keith J. Farmer wrote: >>> >>>> "making releases that people / projects may have depended on is an >>>> >>> unacceptable cost" >>> >>>> You wanna rephrase that there, Michael? :) >>>> >>>> >>> Ha. :-) >>> >>> making unavailable releases that people.... >>> >>> Thanks >>> >>> Michael >>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com >>>> >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >>> >>>> Sent: Monday, November 09, 2009 1:47 AM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >>>> >>>> Jimmy Schementi wrote: >>>> >>>> >>>>> I agree, but I think the desire it to keep that "Releases" list >>>>> >>> clean. Otherwise it would have every release ever in there. It's a >>> CodePlex limitation that there is no way to hide those releases from >>> that list, while still keeping the links active. >>> >>>>> >>>>> >>>> I understand the motivation, but making releases that people / >>>> >> projects >> >>>> may have depended on is an unacceptable cost in my opinion. >>>> >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>>> >>> -- >>> http://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> 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 >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- http://www.ironpythoninaction.com/ From kfarmer at thuban.org Wed Nov 11 22:57:51 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Wed, 11 Nov 2009 13:57:51 -0800 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> <4AF9DBCF.9050702@voidspace.org.uk> <4AFB2AA9.40606@voidspace.org.uk> Message-ID: While technically true -- I can't *stop* them -- I can tell them "I told you so" when support is rightfully removed. I agree it *would* be better to advertise that such-and-such version is not tracked for long-term support, rather than rely on the implication that "RC" means as much, but I don't see that the lack of advertisement is any significant omission, either. It's simply common sense. ________________________________ From: users-bounces at lists.ironpython.com on behalf of Michael Foord Sent: Wed 11/11/2009 1:20 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden Keith J. Farmer wrote: > Well, perhaps because I don't see the upside in breaking things, either. Where I see an upside is in keeping people from taking inappropriate dependencies. :) > You won't stop them taking dependencies on the latest released version (people are building stuff against IP 2.6 RC 2 as we speak). All you do is make those dependencies unavailable to users once the next release is out. > Making use of IronPython in Action, by the way. One thing that seems to be missing from the hosting API discussion is talk about the ScriptRuntimeSetup classes. Might be worth a posting or two. > > Sounds like something good to include in the next edition. :-) All the best, Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Tuesday, November 10, 2009 1:32 PM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Hmm... I certainly don't suggest that the dynamic languages team > *support* obsolete versions, but in my experience it is 'unusual' for an > open source project to make previously released code / binaries > *completely* unavailable - support notwithstanding. > > For Python itself I believe you can download the sources for version > 0.9.1, but it isn't much of a maintenance burden these days... > > I don't see an upside to hiding code (or 'breaking things' as I like to > put it) in quite the same way you do. :-) > > All the best, > > Michael > > Keith J. Farmer wrote: > >> You're right .. the problem *is* a developer taking dependencies on >> specific releases. Further, I contend that it's the developer taking >> dependencies on experimental releases. That's improper, and why we as >> an industry label such things with "alpha", "beta", "RC" and so >> forth. Each of those are warning signs of "this may change, and you >> shouldn't depend on it yet". >> >> The low-level point releases, of course, represent (in theory) non-API >> fixes, and so the only dependency taken in those cases should not >> break, unless the dependency was on broken behavior in which case the >> end-user is more likely than not being sloppy. I have no qualms about >> them bleeding in that case. >> >> The years-long-betas of the *nix community notwithstanding, I'd as >> soon we stick to our guns regarding such things. Having to maintain >> (ie, support) n different versions is a tremendous burden. I myself >> had to maintain (no exaggeration) about 3 dozen different versions of >> the *same* product at one job, but there were other reasons that came >> to be. >> >> Would an image of a giant Monty Python foot stomping on the prior >> versions, with the caption "the version you are requesting has been >> obsoleted and is no longer supported -- use at your own risk" be an >> acceptable approach? :) >> >> ------------------------------------------------------------------------ >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >> *Sent:* Tue 11/10/2009 12:34 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> Keith J. Farmer wrote: >> >>> As for the question at hand, though :) >>> >>> I'm not in blanket agreement here. I'd agree for some releases to be >>> valid dependency points, but things like RCs, betas, obsoleted >>> third-level versions -- not really. >>> >>> In the first two cases, those are bleeding-edge releases. If you take >>> a dependency on them, expect to bleed. >>> >>> >> The problem is that if a developer has used (and depended on) APIs in a >> specific release of IronPython then the person who bleeds is likely to >> be an end user rather than the developer (who may have moved onto other >> things without updating their project). >> >> I don't have a problem with relegating obsolete releases to a small >> corner, but making them unavailable altogether is a high cost. >> >> Michael >> >> >> >>> In the latter case, I wouldn't expect API differences, or other >>> breaking changes unless they represented critical bug fixes. Again, I >>> wouldn't want to support a dependency upon something horribly broken. >>> >>> In light of the above, then, I'd propose keeping the following versions: >>> >>> max(x).y.max(z)[.max(b)] >>> >>> and strongly consider keeping: >>> >>> [max(x)-1].y.max(z)[.max(b)] >>> >>> ------------------------------------------------------------------------ >>> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >>> *Sent:* Tue 11/10/2009 11:25 AM >>> *To:* Discussion of IronPython >>> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >>> >>> Keith J. Farmer wrote: >>> >>>> "making releases that people / projects may have depended on is an >>>> >>> unacceptable cost" >>> >>>> You wanna rephrase that there, Michael? :) >>>> >>>> >>> Ha. :-) >>> >>> making unavailable releases that people.... >>> >>> Thanks >>> >>> Michael >>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com >>>> >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >>> >>>> Sent: Monday, November 09, 2009 1:47 AM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >>>> >>>> Jimmy Schementi wrote: >>>> >>>> >>>>> I agree, but I think the desire it to keep that "Releases" list >>>>> >>> clean. Otherwise it would have every release ever in there. It's a >>> CodePlex limitation that there is no way to hide those releases from >>> that list, while still keeping the links active. >>> >>>>> >>>>> >>>> I understand the motivation, but making releases that people / >>>> >> projects >> >>>> may have depended on is an unacceptable cost in my opinion. >>>> >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>>> >>> -- >>> http://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> 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 >>> >>> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> >> > > > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed Nov 11 23:01:44 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 23:01:44 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> <4AF9DBCF.9050702@voidspace.org.uk> <4AFB2AA9.40606@voidspace.org.uk> Message-ID: <4AFB3448.4070006@voidspace.org.uk> Keith J. Farmer wrote: > While technically true -- I can't *stop* them -- I can tell them "I > told you so" when support is rightfully removed. Yep, and that's the *only* advantage of hiding releases - you get to say I told you so. :-) Michael > > I agree it *would* be better to advertise that such-and-such version > is not tracked for long-term support, rather than rely on the > implication that "RC" means as much, but I don't see that the lack of > advertisement is any significant omission, either. It's simply common > sense. > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > *Sent:* Wed 11/11/2009 1:20 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > Keith J. Farmer wrote: > > Well, perhaps because I don't see the upside in breaking things, > either. Where I see an upside is in keeping people from taking > inappropriate dependencies. :) > > > > You won't stop them taking dependencies on the latest released version > (people are building stuff against IP 2.6 RC 2 as we speak). All you do > is make those dependencies unavailable to users once the next release is > out. > > Making use of IronPython in Action, by the way. One thing that > seems to be missing from the hosting API discussion is talk about the > ScriptRuntimeSetup classes. Might be worth a posting or two. > > > > > > Sounds like something good to include in the next edition. :-) > > All the best, > > Michael > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > > Sent: Tuesday, November 10, 2009 1:32 PM > > To: Discussion of IronPython > > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > > > > Hmm... I certainly don't suggest that the dynamic languages team > > *support* obsolete versions, but in my experience it is 'unusual' for an > > open source project to make previously released code / binaries > > *completely* unavailable - support notwithstanding. > > > > For Python itself I believe you can download the sources for version > > 0.9.1, but it isn't much of a maintenance burden these days... > > > > I don't see an upside to hiding code (or 'breaking things' as I like to > > put it) in quite the same way you do. :-) > > > > All the best, > > > > Michael > > > > Keith J. Farmer wrote: > > > >> You're right .. the problem *is* a developer taking dependencies on > >> specific releases. Further, I contend that it's the developer taking > >> dependencies on experimental releases. That's improper, and why we as > >> an industry label such things with "alpha", "beta", "RC" and so > >> forth. Each of those are warning signs of "this may change, and you > >> shouldn't depend on it yet". > >> > >> The low-level point releases, of course, represent (in theory) non-API > >> fixes, and so the only dependency taken in those cases should not > >> break, unless the dependency was on broken behavior in which case the > >> end-user is more likely than not being sloppy. I have no qualms about > >> them bleeding in that case. > >> > >> The years-long-betas of the *nix community notwithstanding, I'd as > >> soon we stick to our guns regarding such things. Having to maintain > >> (ie, support) n different versions is a tremendous burden. I myself > >> had to maintain (no exaggeration) about 3 dozen different versions of > >> the *same* product at one job, but there were other reasons that came > >> to be. > >> > >> Would an image of a giant Monty Python foot stomping on the prior > >> versions, with the caption "the version you are requesting has been > >> obsoleted and is no longer supported -- use at your own risk" be an > >> acceptable approach? :) > >> > >> > ------------------------------------------------------------------------ > >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > >> *Sent:* Tue 11/10/2009 12:34 PM > >> *To:* Discussion of IronPython > >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > >> > >> Keith J. Farmer wrote: > >> > >>> As for the question at hand, though :) > >>> > >>> I'm not in blanket agreement here. I'd agree for some releases to be > >>> valid dependency points, but things like RCs, betas, obsoleted > >>> third-level versions -- not really. > >>> > >>> In the first two cases, those are bleeding-edge releases. If you take > >>> a dependency on them, expect to bleed. > >>> > >>> > >> The problem is that if a developer has used (and depended on) APIs in a > >> specific release of IronPython then the person who bleeds is likely to > >> be an end user rather than the developer (who may have moved onto other > >> things without updating their project). > >> > >> I don't have a problem with relegating obsolete releases to a small > >> corner, but making them unavailable altogether is a high cost. > >> > >> Michael > >> > >> > >> > >>> In the latter case, I wouldn't expect API differences, or other > >>> breaking changes unless they represented critical bug fixes. Again, I > >>> wouldn't want to support a dependency upon something horribly broken. > >>> > >>> In light of the above, then, I'd propose keeping the following > versions: > >>> > >>> max(x).y.max(z)[.max(b)] > >>> > >>> and strongly consider keeping: > >>> > >>> [max(x)-1].y.max(z)[.max(b)] > >>> > >>> > ------------------------------------------------------------------------ > >>> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord > >>> *Sent:* Tue 11/10/2009 11:25 AM > >>> *To:* Discussion of IronPython > >>> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > >>> > >>> Keith J. Farmer wrote: > >>> > >>>> "making releases that people / projects may have depended on is an > >>>> > >>> unacceptable cost" > >>> > >>>> You wanna rephrase that there, Michael? :) > >>>> > >>>> > >>> Ha. :-) > >>> > >>> making unavailable releases that people.... > >>> > >>> Thanks > >>> > >>> Michael > >>> > >>>> -----Original Message----- > >>>> From: users-bounces at lists.ironpython.com > >>>> > >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > >>> > >>>> Sent: Monday, November 09, 2009 1:47 AM > >>>> To: Discussion of IronPython > >>>> Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden > >>>> > >>>> Jimmy Schementi wrote: > >>>> > >>>> > >>>>> I agree, but I think the desire it to keep that "Releases" list > >>>>> > >>> clean. Otherwise it would have every release ever in there. It's a > >>> CodePlex limitation that there is no way to hide those releases from > >>> that list, while still keeping the links active. > >>> > >>>>> > >>>>> > >>>> I understand the motivation, but making releases that people / > >>>> > >> projects > >> > >>>> may have depended on is an unacceptable cost in my opinion. > >>>> > >>>> _______________________________________________ > >>>> Users mailing list > >>>> Users at lists.ironpython.com > >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >>>> > >>>> > >>> -- > >>> http://www.ironpythoninaction.com/ > >>> > >>> _______________________________________________ > >>> 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 > >>> > >>> > >> -- > >> http://www.ironpythoninaction.com/ > >> > >> _______________________________________________ > >> 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 > >> > >> > > > > > > > > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > 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 > -- http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Wed Nov 11 23:04:27 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 11 Nov 2009 23:04:27 +0100 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden In-Reply-To: <4AFB3448.4070006@voidspace.org.uk> References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> <4AF9DBCF.9050702@voidspace.org.uk> <4AFB2AA9.40606@voidspace.org.uk> <4AFB3448.4070006@voidspace.org.uk> Message-ID: <4AFB34EB.70200@voidspace.org.uk> Michael Foord wrote: > Keith J. Farmer wrote: >> While technically true -- I can't *stop* them -- I can tell them "I >> told you so" when support is rightfully removed. > > Yep, and that's the *only* advantage of hiding releases - you get to > say I told you so. :-) Oh, plus you don't clutter the download link. Does this still count as having the last word? Michael > > Michael >> >> I agree it *would* be better to advertise that such-and-such version >> is not tracked for long-term support, rather than rely on the >> implication that "RC" means as much, but I don't see that the lack of >> advertisement is any significant omission, either. It's simply >> common sense. >> >> ------------------------------------------------------------------------ >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >> *Sent:* Wed 11/11/2009 1:20 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> Keith J. Farmer wrote: >> > Well, perhaps because I don't see the upside in breaking things, >> either. Where I see an upside is in keeping people from taking >> inappropriate dependencies. :) >> > >> You won't stop them taking dependencies on the latest released version >> (people are building stuff against IP 2.6 RC 2 as we speak). All you do >> is make those dependencies unavailable to users once the next release is >> out. >> > Making use of IronPython in Action, by the way. One thing that >> seems to be missing from the hosting API discussion is talk about the >> ScriptRuntimeSetup classes. Might be worth a posting or two. >> > >> > >> Sounds like something good to include in the next edition. :-) >> >> All the best, >> >> Michael >> >> > -----Original Message----- >> > From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >> > Sent: Tuesday, November 10, 2009 1:32 PM >> > To: Discussion of IronPython >> > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> > >> > Hmm... I certainly don't suggest that the dynamic languages team >> > *support* obsolete versions, but in my experience it is 'unusual' >> for an >> > open source project to make previously released code / binaries >> > *completely* unavailable - support notwithstanding. >> > >> > For Python itself I believe you can download the sources for version >> > 0.9.1, but it isn't much of a maintenance burden these days... >> > >> > I don't see an upside to hiding code (or 'breaking things' as I >> like to >> > put it) in quite the same way you do. :-) >> > >> > All the best, >> > >> > Michael >> > >> > Keith J. Farmer wrote: >> > >> You're right .. the problem *is* a developer taking >> dependencies on >> >> specific releases. Further, I contend that it's the developer taking >> >> dependencies on experimental releases. That's improper, and why >> we as >> >> an industry label such things with "alpha", "beta", "RC" and so >> >> forth. Each of those are warning signs of "this may change, and you >> >> shouldn't depend on it yet". >> >> >> The low-level point releases, of course, represent (in theory) >> non-API >> >> fixes, and so the only dependency taken in those cases should not >> >> break, unless the dependency was on broken behavior in which case the >> >> end-user is more likely than not being sloppy. I have no qualms >> about >> >> them bleeding in that case. >> >> >> The years-long-betas of the *nix community notwithstanding, I'd as >> >> soon we stick to our guns regarding such things. Having to maintain >> >> (ie, support) n different versions is a tremendous burden. I myself >> >> had to maintain (no exaggeration) about 3 dozen different versions of >> >> the *same* product at one job, but there were other reasons that came >> >> to be. >> >> >> Would an image of a giant Monty Python foot stomping on the prior >> >> versions, with the caption "the version you are requesting has been >> >> obsoleted and is no longer supported -- use at your own risk" be an >> >> acceptable approach? :) >> >> >> >> >> ------------------------------------------------------------------------ >> >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >> >> *Sent:* Tue 11/10/2009 12:34 PM >> >> *To:* Discussion of IronPython >> >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> >> >> Keith J. Farmer wrote: >> >> >>> As for the question at hand, though :) >> >>> >> >>> I'm not in blanket agreement here. I'd agree for some releases >> to be >> >>> valid dependency points, but things like RCs, betas, obsoleted >> >>> third-level versions -- not really. >> >>> >> >>> In the first two cases, those are bleeding-edge releases. If you >> take >> >>> a dependency on them, expect to bleed. >> >>> >> >>> >> The problem is that if a developer has used (and depended >> on) APIs in a >> >> specific release of IronPython then the person who bleeds is >> likely to >> >> be an end user rather than the developer (who may have moved onto >> other >> >> things without updating their project). >> >> >> >> I don't have a problem with relegating obsolete releases to a small >> >> corner, but making them unavailable altogether is a high cost. >> >> >> >> Michael >> >> >> >> >> >> >>> In the latter case, I wouldn't expect API differences, or >> other >> >>> breaking changes unless they represented critical bug fixes. >> Again, I >> >>> wouldn't want to support a dependency upon something horribly >> broken. >> >>> >> >>> In light of the above, then, I'd propose keeping the following >> versions: >> >>> >> >>> max(x).y.max(z)[.max(b)] >> >>> >> >>> and strongly consider keeping: >> >>> >> >>> [max(x)-1].y.max(z)[.max(b)] >> >>> >> >>> >> ------------------------------------------------------------------------ >> >>> *From:* users-bounces at lists.ironpython.com on behalf of Michael >> Foord >> >>> *Sent:* Tue 11/10/2009 11:25 AM >> >>> *To:* Discussion of IronPython >> >>> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >>> >> >>> Keith J. Farmer wrote: >> >>> >>>> "making releases that people / projects may have >> depended on is an >> >>>> >>> unacceptable cost" >> >>> >>>> You wanna rephrase that there, Michael? :) >> >>>> >> >>>> >>> Ha. :-) >> >>> >> >>> making unavailable releases that people.... >> >>> >> >>> Thanks >> >>> >> >>> Michael >> >>> >>>> -----Original Message----- >> >>>> From: users-bounces at lists.ironpython.com >> >>>> >>> [mailto:users-bounces at lists.ironpython.com] On Behalf >> Of Michael Foord >> >>> >>>> Sent: Monday, November 09, 2009 1:47 AM >> >>>> To: Discussion of IronPython >> >>>> Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >>>> >> >>>> Jimmy Schementi wrote: >> >>>> >> >>>> >>>>> I agree, but I think the desire it to keep that >> "Releases" list >> >>>>> >>> clean. Otherwise it would have every release ever >> in there. It's a >> >>> CodePlex limitation that there is no way to hide those releases from >> >>> that list, while still keeping the links active. >> >>> >>>>> >>>>> >>>> I understand the motivation, but >> making releases that people / >> >>>> >> projects >> >> >>>> may have depended on is an unacceptable cost in my opinion. >> >>>> >> >>>> _______________________________________________ >> >>>> Users mailing list >> >>>> Users at lists.ironpython.com >> >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >>>> >> >>>> >>> -- >> >>> http://www.ironpythoninaction.com/ >> >>> >> >>> _______________________________________________ >> >>> 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 >> >>> >>> >> -- >> >> http://www.ironpythoninaction.com/ >> >> >> >> _______________________________________________ >> >> 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 >> >> >> > >> > >> > >> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> > > -- http://www.ironpythoninaction.com/ From kfarmer at thuban.org Thu Nov 12 02:44:18 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Wed, 11 Nov 2009 17:44:18 -0800 Subject: [IronPython] IronPython 2.6 RC 1 Release Hidden References: <4AF7E0A0.2070406@voidspace.org.uk><1B42307CD4AADD438CDDA2FE1121CC9203376B@TK5EX14MBXC134.redmond.corp.microsoft.com> <4AF7E50A.1030509@voidspace.org.uk> <4AF9BE17.6050008@voidspace.org.uk> <4AF9CE5B.8080406@voidspace.org.uk> <4AF9DBCF.9050702@voidspace.org.uk> <4AFB2AA9.40606@voidspace.org.uk> <4AFB3448.4070006@voidspace.org.uk> <4AFB34EB.70200@voidspace.org.uk> Message-ID: "I told you so" in an underutilized but very powerful feature of any rapidly-changing technology. I think we should be making greater use of it. (No, it didn't count /g/) ________________________________ From: users-bounces at lists.ironpython.com on behalf of Michael Foord Sent: Wed 11/11/2009 2:04 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden Michael Foord wrote: > Keith J. Farmer wrote: >> While technically true -- I can't *stop* them -- I can tell them "I >> told you so" when support is rightfully removed. > > Yep, and that's the *only* advantage of hiding releases - you get to > say I told you so. :-) Oh, plus you don't clutter the download link. Does this still count as having the last word? Michael > > Michael >> >> I agree it *would* be better to advertise that such-and-such version >> is not tracked for long-term support, rather than rely on the >> implication that "RC" means as much, but I don't see that the lack of >> advertisement is any significant omission, either. It's simply >> common sense. >> >> ------------------------------------------------------------------------ >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >> *Sent:* Wed 11/11/2009 1:20 PM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> Keith J. Farmer wrote: >> > Well, perhaps because I don't see the upside in breaking things, >> either. Where I see an upside is in keeping people from taking >> inappropriate dependencies. :) >> > >> You won't stop them taking dependencies on the latest released version >> (people are building stuff against IP 2.6 RC 2 as we speak). All you do >> is make those dependencies unavailable to users once the next release is >> out. >> > Making use of IronPython in Action, by the way. One thing that >> seems to be missing from the hosting API discussion is talk about the >> ScriptRuntimeSetup classes. Might be worth a posting or two. >> > >> > >> Sounds like something good to include in the next edition. :-) >> >> All the best, >> >> Michael >> >> > -----Original Message----- >> > From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >> > Sent: Tuesday, November 10, 2009 1:32 PM >> > To: Discussion of IronPython >> > Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> > >> > Hmm... I certainly don't suggest that the dynamic languages team >> > *support* obsolete versions, but in my experience it is 'unusual' >> for an >> > open source project to make previously released code / binaries >> > *completely* unavailable - support notwithstanding. >> > >> > For Python itself I believe you can download the sources for version >> > 0.9.1, but it isn't much of a maintenance burden these days... >> > >> > I don't see an upside to hiding code (or 'breaking things' as I >> like to >> > put it) in quite the same way you do. :-) >> > >> > All the best, >> > >> > Michael >> > >> > Keith J. Farmer wrote: >> > >> You're right .. the problem *is* a developer taking >> dependencies on >> >> specific releases. Further, I contend that it's the developer taking >> >> dependencies on experimental releases. That's improper, and why >> we as >> >> an industry label such things with "alpha", "beta", "RC" and so >> >> forth. Each of those are warning signs of "this may change, and you >> >> shouldn't depend on it yet". >> >> >> The low-level point releases, of course, represent (in theory) >> non-API >> >> fixes, and so the only dependency taken in those cases should not >> >> break, unless the dependency was on broken behavior in which case the >> >> end-user is more likely than not being sloppy. I have no qualms >> about >> >> them bleeding in that case. >> >> >> The years-long-betas of the *nix community notwithstanding, I'd as >> >> soon we stick to our guns regarding such things. Having to maintain >> >> (ie, support) n different versions is a tremendous burden. I myself >> >> had to maintain (no exaggeration) about 3 dozen different versions of >> >> the *same* product at one job, but there were other reasons that came >> >> to be. >> >> >> Would an image of a giant Monty Python foot stomping on the prior >> >> versions, with the caption "the version you are requesting has been >> >> obsoleted and is no longer supported -- use at your own risk" be an >> >> acceptable approach? :) >> >> >> >> >> ------------------------------------------------------------------------ >> >> *From:* users-bounces at lists.ironpython.com on behalf of Michael Foord >> >> *Sent:* Tue 11/10/2009 12:34 PM >> >> *To:* Discussion of IronPython >> >> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >> >> >> Keith J. Farmer wrote: >> >> >>> As for the question at hand, though :) >> >>> >> >>> I'm not in blanket agreement here. I'd agree for some releases >> to be >> >>> valid dependency points, but things like RCs, betas, obsoleted >> >>> third-level versions -- not really. >> >>> >> >>> In the first two cases, those are bleeding-edge releases. If you >> take >> >>> a dependency on them, expect to bleed. >> >>> >> >>> >> The problem is that if a developer has used (and depended >> on) APIs in a >> >> specific release of IronPython then the person who bleeds is >> likely to >> >> be an end user rather than the developer (who may have moved onto >> other >> >> things without updating their project). >> >> >> >> I don't have a problem with relegating obsolete releases to a small >> >> corner, but making them unavailable altogether is a high cost. >> >> >> >> Michael >> >> >> >> >> >> >>> In the latter case, I wouldn't expect API differences, or >> other >> >>> breaking changes unless they represented critical bug fixes. >> Again, I >> >>> wouldn't want to support a dependency upon something horribly >> broken. >> >>> >> >>> In light of the above, then, I'd propose keeping the following >> versions: >> >>> >> >>> max(x).y.max(z)[.max(b)] >> >>> >> >>> and strongly consider keeping: >> >>> >> >>> [max(x)-1].y.max(z)[.max(b)] >> >>> >> >>> >> ------------------------------------------------------------------------ >> >>> *From:* users-bounces at lists.ironpython.com on behalf of Michael >> Foord >> >>> *Sent:* Tue 11/10/2009 11:25 AM >> >>> *To:* Discussion of IronPython >> >>> *Subject:* Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >>> >> >>> Keith J. Farmer wrote: >> >>> >>>> "making releases that people / projects may have >> depended on is an >> >>>> >>> unacceptable cost" >> >>> >>>> You wanna rephrase that there, Michael? :) >> >>>> >> >>>> >>> Ha. :-) >> >>> >> >>> making unavailable releases that people.... >> >>> >> >>> Thanks >> >>> >> >>> Michael >> >>> >>>> -----Original Message----- >> >>>> From: users-bounces at lists.ironpython.com >> >>>> >>> [mailto:users-bounces at lists.ironpython.com] On Behalf >> Of Michael Foord >> >>> >>>> Sent: Monday, November 09, 2009 1:47 AM >> >>>> To: Discussion of IronPython >> >>>> Subject: Re: [IronPython] IronPython 2.6 RC 1 Release Hidden >> >>>> >> >>>> Jimmy Schementi wrote: >> >>>> >> >>>> >>>>> I agree, but I think the desire it to keep that >> "Releases" list >> >>>>> >>> clean. Otherwise it would have every release ever >> in there. It's a >> >>> CodePlex limitation that there is no way to hide those releases from >> >>> that list, while still keeping the links active. >> >>> >>>>> >>>>> >>>> I understand the motivation, but >> making releases that people / >> >>>> >> projects >> >> >>>> may have depended on is an unacceptable cost in my opinion. >> >>>> >> >>>> _______________________________________________ >> >>>> Users mailing list >> >>>> Users at lists.ironpython.com >> >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >>>> >> >>>> >>> -- >> >>> http://www.ironpythoninaction.com/ >> >>> >> >>> _______________________________________________ >> >>> 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 >> >>> >>> >> -- >> >> http://www.ironpythoninaction.com/ >> >> >> >> _______________________________________________ >> >> 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 >> >> >> > >> > >> > >> >> -- >> http://www.ironpythoninaction.com/ >> >> _______________________________________________ >> 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 >> > > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From antont at kyperjokki.fi Thu Nov 12 05:21:35 2009 From: antont at kyperjokki.fi (Toni Alatalo) Date: Thu, 12 Nov 2009 06:21:35 +0200 Subject: [IronPython] How to convert a 'str' type to byteArray In-Reply-To: References: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> Message-ID: <4AFB8D4F.2090607@kyperjokki.fi> Vernon Cole kirjoitti: > Make sure what data type is really being returned by part.getpayload() > . Perhaps it is already in a suitable for when you get it? Before he posted to the list we actually talked about this on irc too, and it seemed that it was unicode. He was seeing type 'str', but it seemed that str is unicode on ironpy, so probably that's why giving it to create a byte array doesn't work. > s = 'this is a string' > b = buffer(s) > stores "strings" in unicode, and buffer() tries to be smart about > hiding that fact, in order to act like CPython in the easy cases. The > above will work the same in either IronPython or CPython. Ok, AFAIK he wasn't trying buffer() yet and I also didnt't know much about it, so perhaps this is it? I'm sure he'll try soon. > (IronPython seems to store them internally in UTF-8 or some similar > code.) To convert to "proper" 8-bit codes you must use something like: > u = u'unicode string' > b = buffer(u.encode('latin-1')) The string/bytes is an image from an email (using some .net lib i guess, dunno on what that getpayload() is), I wonder if something like 'latin-1' is still the thing to use :o > Python 3.x removes the problem by defining all character strings as > unicode (as IronPython does now), and providing a byte() function, in > which each 8 byte is treated as an integer, rather than a character. > That will make things simpler in the future. Indeed, perhaps the main reason why am looking forward to living in that land eventually. Thanks for info! (I and the OP work in the same overall project (http://www.realxtend.org/ open source virtual worlds / network games plat), even though I'm not working on the same thing he is now (we use ironpy on the server and cpython on the client, I'm mostly busy with the client side right now) > VC ~Toni > On Wed, Nov 11, 2009 at 8:14 AM, matan keret > wrote: > > hi, > > I have the following code which gets an image from an email. > after getting it i need to pass it as a byteArray (byte[] in C#) > to a C# function. > i tried all sorts of things but no luck. I'm using ironPython 2.0.3 > > the important parts of the code are: > > # getting the image from the e-mail > image = part.get_payload() > > # my try to cast the str into a byteArray > byteArray = BitConverter.GetBytes(image.ToCharArray()) > > > this last line returns 1 byte and doesn't seem to do the job. > is there any equivalent to the 'bytearray(image)' function in CPython? > > thanks, > Matan > > > _______________________________________________ > 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 > From matan504 at gmail.com Thu Nov 12 10:41:54 2009 From: matan504 at gmail.com (matan keret) Date: Thu, 12 Nov 2009 11:41:54 +0200 Subject: [IronPython] How to convert a 'str' type to byteArray In-Reply-To: <4AFB8D4F.2090607@kyperjokki.fi> References: <5c1d2b3d0911110714u60c4637bj4f1ac9dba58c7312@mail.gmail.com> <4AFB8D4F.2090607@kyperjokki.fi> Message-ID: <5c1d2b3d0911120141s3b332e0es8a5fdd51f08b34cf@mail.gmail.com> Thank you all for your help! i tried the buffer idea, but it gave me a 'buffer' type and not a byteArray. so i tried Michael's idea, which gave me some error. but then I found this post: http://www.smallshire.org.uk/sufficientlysmall/tag/ironpython/ I fixed the code to: from System import Array, Byte a = Array[Byte](tuple(Byte(ord(c)) for c in image)) which seems to work :-) Like Tony said, Thanks a lot for the info! On Thu, Nov 12, 2009 at 6:21 AM, Toni Alatalo wrote: > Vernon Cole kirjoitti: > > Make sure what data type is really being returned by part.getpayload() . >> Perhaps it is already in a suitable for when you get it? >> > > Before he posted to the list we actually talked about this on irc too, and > it seemed that it was unicode. He was seeing type 'str', but it seemed that > str is unicode on ironpy, so probably that's why giving it to create a byte > array doesn't work. > >> s = 'this is a string' >> b = buffer(s) >> stores "strings" in unicode, and buffer() tries to be smart about hiding >> that fact, in order to act like CPython in the easy cases. The above will >> work the same in either IronPython or CPython. >> > > Ok, AFAIK he wasn't trying buffer() yet and I also didnt't know much about > it, so perhaps this is it? I'm sure he'll try soon. > > > (IronPython seems to store them internally in UTF-8 or some similar code.) >> To convert to "proper" 8-bit codes you must use something like: >> u = u'unicode string' >> b = buffer(u.encode('latin-1')) >> > > The string/bytes is an image from an email (using some .net lib i guess, > dunno on what that getpayload() is), I wonder if something like 'latin-1' is > still the thing to use :o > > > Python 3.x removes the problem by defining all character strings as unicode >> (as IronPython does now), and providing a byte() function, in which each 8 >> byte is treated as an integer, rather than a character. That will make >> things simpler in the future. >> > > Indeed, perhaps the main reason why am looking forward to living in that > land eventually. > > Thanks for info! (I and the OP work in the same overall project ( > http://www.realxtend.org/ open source virtual worlds / network games > plat), even though I'm not working on the same thing he is now (we use > ironpy on the server and cpython on the client, I'm mostly busy with the > client side right now) > > VC >> > > ~Toni > > >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.suhotjuk at gmail.com Thu Nov 12 16:22:44 2009 From: pavel.suhotjuk at gmail.com (Pavel Suhotyuk) Date: Thu, 12 Nov 2009 17:22:44 +0200 Subject: [IronPython] IPY and multitasking Message-ID: <4AFC2844.9000402@gmail.com> I have this collection of methods: -------------------------------------------------------------------------------------------------- public static class IronPythonHelper { public static ScriptEngine CreateScriptEngine(IEnumerable paths) { var langSetup = ScriptRuntimeSetup.ReadConfiguration(); var engine = new ScriptRuntime(langSetup).GetEngine("IronPython"); var path = engine.GetSearchPaths(); path.Extend(paths); engine.SetSearchPaths(path); engine.Execute("import citypay", engine.Runtime.Globals); engine.Execute("import cPickle", engine.Runtime.Globals); engine.Execute("from citypay.utils import Struct", engine.Runtime.Globals); return engine; } public static object PackParams(ScriptEngine engine, IDictionary param) { var scope = engine.CreateScope(); engine.Execute("from citypay.utils import Struct", scope); engine.Execute("def pack( params ) : return Struct(**dict(params))", scope); var pack = scope.GetVariable, object>>("pack"); return pack(param); } public static byte[] CPickleSerialize(ScriptEngine engine, object obj) { var scope = engine.CreateScope(); engine.Execute("import cPickle", scope); engine.Execute("def serialize( obj ) : return cPickle.dumps( obj )", scope); var serialize = scope.GetVariable>("serialize"); return Encoding.Unicode.GetBytes(serialize(obj)); } } -------------------------------------------------------------------------------------------------- I have base class used for create needed Engine and Scope as: -------------------------------------------------------------------------------------------------- public absract class SripterBase { private static readonly ScriptEngine engine = IronPythonHelper.CreateScriptEngine(Settings.Default.PythonLibPaths.Cast()); ... } -------------------------------------------------------------------------------------------------- My problem in next: Scripter based classes can be created in many threads in one time. Scripter class used for get pickle'd data by CPickleSerialize(), from something like: -------------------------------------------------------------------------------------------------- class Struct ( object ) : def __init__ ( self, **kwds ) : for name, val in kwds.iteritems() : setattr( self, name, val ) def _update ( self, **kwds ) : for name, val in kwds.iteritems() : setattr( self, name, val ) def _enum ( self ) : return [( a, getattr( self, a ) ) for a in dir( self ) if a.find( '__' ) == -1 and not a.startswith( '_' )] def __repr__ ( self ) : return '' % ' '.join( [ '%s=%s' % ( str( n ), repr( v ) ) for n, v in self._enum() ] ) def __eq__ ( self, other ) : if not isinstance( other, type( self ) ) : return NotImplemented return self._enum() == other._enum() -------------------------------------------------------------------------------------------------- Multithread code in some (not stable) cases throws 'strange' exceptions. This problem exists only in multithreaded environment and not exist in single thread. How I can fix or avoid this problem ? usmpsrv1 :: FATAL :: CityPay.Core.Utils.RecursiveException: Recursive ended. ---> IronPython.Runtime.Exceptions.ImportException: Cannot import name Struct in IronPython.Runtime.Importer.ImportFrom(CodeContext context, Object from, String name) in Microsoft.Scripting.Utils.InvokeHelper`4.Invoke(Object arg0, Object arg1, Object arg2) in Microsoft.Scripting.Interpreter.CallInstruction.Run(InterpretedFrame frame) in Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(InterpretedFrame frame) in Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) in Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 arg0, T1 arg1) in IronPython.Compiler.PythonScriptCode.Run(Scope scope) in IronPython.Compiler.RuntimeScriptCode.InvokeTarget(LambdaExpression code, Scope scope) in Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope scope) in CityPay.Core.Utils.IronPythonHelper.PackParams(ScriptEngine engine, IDictionary`2 param) in CityPay.Providers.Helpers.Beeline.PaymentInfo.Serialize(ScriptEngine engine) in CityPay.Providers.Helpers.PaymentInfoBase.ToString(ScriptEngine engine) in CityPay.PaymentsBroker.Bridge.WinService.Workers.ProcessWorker.Request(Payment payment) in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 count) in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 count) in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 count) in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 count) in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 count) in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 count) in CityPay.PaymentsBroker.Bridge.WinService.Workers.ProcessWorker.Execute(Object o) Logger: CityPay.PaymentsBroker.Bridge.WinService.Workers.ProcessWorker Thread: 4 Date: 2009-11-11 17:27:31,484 NDC: (null) usmpsrv1 :: FATAL :: CityPay.Core.Utils.RecursiveException: Recursive ended. ---> System.Exception: Can't pickle IronPython.Runtime.Types.BuiltinFunction: it's not the same object as copy_reg._reconstructor From Shri.Borde at microsoft.com Thu Nov 12 19:26:31 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Thu, 12 Nov 2009 18:26:31 +0000 Subject: [IronPython] .NET attributes for methods In-Reply-To: <4AFC3313.3060908@bakalari.cz> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> So the new clrtype.py still works - cool! I am not an expert on data binding, so I don't have any suggestions. Why do you say that the decorator approach will not work with Silverlight? Does @notifiy_property from http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html use any feature not available in Silverlight? From: Lukas Cenovsky [mailto:cenovsky at bakalari.cz] Sent: Thursday, November 12, 2009 8:09 AM To: Shri Borde Subject: Re: [IronPython] .NET attributes for methods Thanks, that works! What do you think would be the best approach to create notifiable properties for Silverlight? I did it for WPF (via decorators: http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) but it seems to me it won't be possible to do it similarly for Silverlight... -- -- Luk?? Shri Borde wrote: Can you use "_clrproperties" instead of "_clrfields"? DevHawk's same created a field and a property even when you just used "_clrfields". I don't do that anymore. So you will need to use "_clrproperties" to get properties, which SL must use for data binding. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Wednesday, November 11, 2009 2:37 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I did change __metaclass__ to ClrMetaclass. See the attached source I use for testing - the only difference is to comment/uncomment appropriate part in product.py. The outputs look the same, there are no visible exceptions: DevHawk: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) Shri: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) -- -- Luk?? Shri Borde wrote: Note that you will have to set __metaclass__ to ClrMetaclass, not ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the type. The old name will cause a NameError, but maybe SL is hiding exceptions. Can you do "o.GetType().GetFields()" and display that on the page to inspect the object and also make sure that no exceptions were thrown? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Tuesday, November 10, 2009 2:59 PM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I have just found that the Silverlight binding does not work with this version of clrtype and/or IronPython 2.6RC2. I used DevHawk demo [1] and after I added reference to Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But when I switch to your version, no items show in the listbox. By the way - I have seen a commit message you have added support for interfaces - nice! ;-) -- -- Luk?? [1] http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Thu Nov 12 19:36:44 2009 From: dinov at microsoft.com (Dino Viehland) Date: Thu, 12 Nov 2009 18:36:44 +0000 Subject: [IronPython] IPY and multitasking In-Reply-To: <4AFC2844.9000402@gmail.com> References: <4AFC2844.9000402@gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C93119@TK5EX14MBXC118.redmond.corp.microsoft.com> You're only using 1 ScriptEngine class? That should be fine based upon the code below but I just want to make sure I understand the scenario. Is citypay.utils being ran multiple times when you run the code in the multi-threaded scenario? If you have a console app you could put a print statement in utils.py to see if it's getting executed multiple times. If it's not a console app you could put some other logging into it. Executing Struct's definition multiple times might cause the exceptions you're seeing but I don't know why it would get executed multiple times. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Pavel Suhotyuk > Sent: Thursday, November 12, 2009 7:23 AM > To: Discussion of IronPython > Subject: [IronPython] IPY and multitasking > > I have this collection of methods: > ----------------------------------------------------------------------- > --------------------------- > public static class IronPythonHelper > { > public static ScriptEngine > CreateScriptEngine(IEnumerable paths) > { > var langSetup = ScriptRuntimeSetup.ReadConfiguration(); > var engine = new > ScriptRuntime(langSetup).GetEngine("IronPython"); > var path = engine.GetSearchPaths(); > path.Extend(paths); > engine.SetSearchPaths(path); > engine.Execute("import citypay", engine.Runtime.Globals); > engine.Execute("import cPickle", engine.Runtime.Globals); > engine.Execute("from citypay.utils import Struct", > engine.Runtime.Globals); > return engine; > } > > public static object PackParams(ScriptEngine engine, > IDictionary param) > { > var scope = engine.CreateScope(); > engine.Execute("from citypay.utils import Struct", scope); > engine.Execute("def pack( params ) : return > Struct(**dict(params))", scope); > var pack = scope.GetVariable object>, object>>("pack"); > return pack(param); > } > > public static byte[] CPickleSerialize(ScriptEngine engine, > object obj) > { > var scope = engine.CreateScope(); > engine.Execute("import cPickle", scope); > engine.Execute("def serialize( obj ) : return > cPickle.dumps( obj )", scope); > var serialize = scope.GetVariable string>>("serialize"); > return Encoding.Unicode.GetBytes(serialize(obj)); > } > } > ----------------------------------------------------------------------- > --------------------------- > I have base class used for create needed Engine and Scope as: > ----------------------------------------------------------------------- > --------------------------- > public absract class SripterBase { > private static readonly ScriptEngine engine = > IronPythonHelper.CreateScriptEngine(Settings.Default.PythonLibPaths.Cas > t()); > > ... > } > ----------------------------------------------------------------------- > --------------------------- > My problem in next: Scripter based classes can be created in many > threads in one time. > Scripter class used for get pickle'd data by CPickleSerialize(), from > something like: > ----------------------------------------------------------------------- > --------------------------- > class Struct ( object ) : > > def __init__ ( self, **kwds ) : > for name, val in kwds.iteritems() : > setattr( self, name, val ) > > def _update ( self, **kwds ) : > for name, val in kwds.iteritems() : > setattr( self, name, val ) > > def _enum ( self ) : > return [( a, getattr( self, a ) ) for a in dir( self ) if > a.find( '__' ) == -1 and not a.startswith( '_' )] > > def __repr__ ( self ) : > return '' % ' '.join( [ '%s=%s' % ( str( > n > ), repr( v ) ) for n, v in self._enum() ] ) > > def __eq__ ( self, other ) : > if not isinstance( other, type( self ) ) : > return NotImplemented > return self._enum() == other._enum() > ----------------------------------------------------------------------- > --------------------------- > > Multithread code in some (not stable) cases throws 'strange' > exceptions. > This problem exists only in multithreaded environment and not exist in > single thread. > > How I can fix or avoid this problem ? > > > usmpsrv1 :: FATAL :: CityPay.Core.Utils.RecursiveException: Recursive > ended. ---> IronPython.Runtime.Exceptions.ImportException: Cannot > import > name Struct > in IronPython.Runtime.Importer.ImportFrom(CodeContext context, > Object from, String name) > in Microsoft.Scripting.Utils.InvokeHelper`4.Invoke(Object arg0, > Object arg1, Object arg2) > in > Microsoft.Scripting.Interpreter.CallInstruction.Run(InterpretedFrame > frame) > in > Microsoft.Scripting.Interpreter.Interpreter.RunInstructions(Interpreted > Frame > frame) > in Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame > frame) > in Microsoft.Scripting.Interpreter.LightLambda.Run2[T0,T1,TRet](T0 > arg0, T1 arg1) > in IronPython.Compiler.PythonScriptCode.Run(Scope scope) > in > IronPython.Compiler.RuntimeScriptCode.InvokeTarget(LambdaExpression > code, Scope scope) > in Microsoft.Scripting.Hosting.ScriptSource.Execute(ScriptScope > scope) > in CityPay.Core.Utils.IronPythonHelper.PackParams(ScriptEngine > engine, IDictionary`2 param) > in > CityPay.Providers.Helpers.Beeline.PaymentInfo.Serialize(ScriptEngine > engine) > in CityPay.Providers.Helpers.PaymentInfoBase.ToString(ScriptEngine > engine) > in > CityPay.PaymentsBroker.Bridge.WinService.Workers.ProcessWorker.Request( > Payment > payment) > in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 > count) > in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 > count) > in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 > count) > in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 > count) > in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 > count) > in CityPay.Core.Utils.Util.Recursive[TResult](Func`1 func, Int32 > count) > in > CityPay.PaymentsBroker.Bridge.WinService.Workers.ProcessWorker.Execute( > Object > o) > Logger: CityPay.PaymentsBroker.Bridge.WinService.Workers.ProcessWorker > Thread: 4 > Date: 2009-11-11 17:27:31,484 > NDC: (null) > > usmpsrv1 :: FATAL :: CityPay.Core.Utils.RecursiveException: Recursive > ended. ---> System.Exception: Can't pickle > IronPython.Runtime.Types.BuiltinFunction: it's not the same object as > copy_reg._reconstructor > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Jimmy.Schementi at microsoft.com Thu Nov 12 20:56:08 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Thu, 12 Nov 2009 19:56:08 +0000 Subject: [IronPython] Please disregard - Testing IronPython Mailing List Message-ID: <1B42307CD4AADD438CDDA2FE1121CC9203754A@TK5EX14MBXC134.redmond.corp.microsoft.com> Changed name servers for ironpython.com, so making sure the MX records are still working properly. If people see this, hurray! From Shri.Borde at microsoft.com Thu Nov 12 22:59:11 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Thu, 12 Nov 2009 21:59:11 +0000 Subject: [IronPython] .NET attributes for methods In-Reply-To: <4AFC5B83.1000407@bakalari.cz> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC5B83.1000407@bakalari.cz> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> Here is an updated version of clrtype.py that uses @property + @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead of using "_clrproperties". I think its more Pythonic in general, but also you should be able to modify @notify_property to work with it. Note that notify_property won't just work. You will have to change it to propagate the func_name, arg_types, and return_type properties from the old getter/setter function objects to the new getter/setter function objects since these values are used by clrtype to generate the CLR members. Something like this: class notify_property(property): def propagate_attributes(old_function, new_function): new_function.func_name = old_function.func_name new_function.arg_types = old_function.arg_types new_function.return_type = old_function.return_type def __init__(self, getter): def newgetter(slf): try: return getter(slf) except AttributeError: return None propagate_attributes(getter, newgetter) super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): oldvalue = self.fget(slf) if oldvalue != newvalue: setter(slf, newvalue) slf.OnPropertyChanged(setter.__name__) propagate_attributes(setter, newsetter) return property( fget=self.fget, fset=newsetter, fdel=self.fdel, doc=self.__doc__) From: Lukas Cenovsky [mailto:cenovsky at bakalari.cz] Sent: Thursday, November 12, 2009 11:01 AM To: Shri Borde Subject: Re: [IronPython] .NET attributes for methods Shri Borde wrote: So the new clrtype.py still works - cool! Yep ;-) I am not an expert on data binding, so I don't have any suggestions. Why do you say that the decorator approach will not work with Silverlight? Does @notifiy_property from http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html use any feature not available in Silverlight? It does not (as far as I know because it is pure IronPython). But @notify_property does not work with clrtypes: class ViewModel(NotifyPropertyChangedBase): __metaclass__ = clrtype.ClrMetaclass _clrnamespace = "Cenda.ViewModel" _clrproperties = {'size': str} def __init__(self): super(ViewModel, self).__init__() # must be string to two-way binding work correctly self.size = '10' @notify_property def size(self): return self._size @size.setter def size(self, value): self._size = value print 'Size changed to %r' % self.size When I run this code, the size is still clr property and Python getter and setter are not run. So basically I need to override/enhance clr getter and setter created by clrtype._clrproperties. -- -- Luk?? From: Lukas Cenovsky [mailto:cenovsky at bakalari.cz] Sent: Thursday, November 12, 2009 8:09 AM To: Shri Borde Subject: Re: [IronPython] .NET attributes for methods Thanks, that works! What do you think would be the best approach to create notifiable properties for Silverlight? I did it for WPF (via decorators: http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) but it seems to me it won't be possible to do it similarly for Silverlight... -- -- Luk?? Shri Borde wrote: Can you use "_clrproperties" instead of "_clrfields"? DevHawk's same created a field and a property even when you just used "_clrfields". I don't do that anymore. So you will need to use "_clrproperties" to get properties, which SL must use for data binding. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Wednesday, November 11, 2009 2:37 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I did change __metaclass__ to ClrMetaclass. See the attached source I use for testing - the only difference is to comment/uncomment appropriate part in product.py. The outputs look the same, there are no visible exceptions: DevHawk: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) Shri: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) -- -- Luk?? Shri Borde wrote: Note that you will have to set __metaclass__ to ClrMetaclass, not ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the type. The old name will cause a NameError, but maybe SL is hiding exceptions. Can you do "o.GetType().GetFields()" and display that on the page to inspect the object and also make sure that no exceptions were thrown? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Tuesday, November 10, 2009 2:59 PM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I have just found that the Silverlight binding does not work with this version of clrtype and/or IronPython 2.6RC2. I used DevHawk demo [1] and after I added reference to Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But when I switch to your version, no items show in the listbox. By the way - I have seen a commit message you have added support for interfaces - nice! ;-) -- -- Luk?? [1] http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: clrtype.py Type: application/octet-stream Size: 21701 bytes Desc: clrtype.py URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: sample.py Type: application/octet-stream Size: 6816 bytes Desc: sample.py URL: From curt at hagenlocher.org Fri Nov 13 00:02:47 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 12 Nov 2009 15:02:47 -0800 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: Silverlight doesn't support ICustomTypeDescriptor -- that's probably why binding is failing. You need to emit CLR properties to use data binding with Silverlight 2 and 3. 2009/11/12 Shri Borde > So the new clrtype.py still works - cool! > > > > I am not an expert on data binding, so I don't have any suggestions. Why do > you say that the decorator approach will not work with Silverlight? Does > @notifiy_property from > http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.htmluse any feature not available in Silverlight? > > > > *From:* Lukas Cenovsky [mailto:cenovsky at bakalari.cz] > *Sent:* Thursday, November 12, 2009 8:09 AM > *To:* Shri Borde > *Subject:* Re: [IronPython] .NET attributes for methods > > > > Thanks, that works! > > What do you think would be the best approach to create notifiable > properties for Silverlight? I did it for WPF (via decorators: > http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) > but it seems to me it won't be possible to do it similarly for > Silverlight... > > -- > -- Luk?? > > Shri Borde wrote: > > Can you use "_clrproperties" instead of "_clrfields"? DevHawk's same > created a field and a property even when you just used "_clrfields". I don't > do that anymore. So you will need to use "_clrproperties" to get properties, > which SL must use for data binding. > > > > *From:* users-bounces at lists.ironpython.com [ > mailto:users-bounces at lists.ironpython.com] > *On Behalf Of *Lukas Cenovsky > *Sent:* Wednesday, November 11, 2009 2:37 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I did change __metaclass__ to ClrMetaclass. See the attached source I use > for testing - the only difference is to comment/uncomment appropriate part > in product.py. > > The outputs look the same, there are no visible exceptions: > > DevHawk: > > py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() > > => Array[FieldInfo]((, > > , > > , > > , > > , > > )) > > > Shri: > > py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() > > => Array[FieldInfo]((, > > , > > , > > , > > , > > )) > > > > -- > -- Luk?? > > > Shri Borde wrote: > > Note that you will have to set __metaclass__ to ClrMetaclass, not > ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the type. > The old name will cause a NameError, but maybe SL is hiding exceptions. Can > you do "o.GetType().GetFields()" and display that on the page to inspect the > object and also make sure that no exceptions were thrown? > > > > *From:* users-bounces at lists.ironpython.com [ > mailto:users-bounces at lists.ironpython.com] > *On Behalf Of *Lukas Cenovsky > *Sent:* Tuesday, November 10, 2009 2:59 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I have just found that the Silverlight binding does not work with this > version of clrtype and/or IronPython 2.6RC2. > I used DevHawk demo [1] and after I added reference to Microsoft.Dynamic in > clrtypemetaclass.py it worked flawlessly. But when I switch to your version, > no items show in the listbox. > > By the way - I have seen a commit message you have added support for > interfaces - nice! ;-) > > -- > -- Luk?? > > [1] > http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.suhotjuk at gmail.com Fri Nov 13 10:00:31 2009 From: pavel.suhotjuk at gmail.com (Pavel Suhotyuk) Date: Fri, 13 Nov 2009 11:00:31 +0200 Subject: [IronPython] IPY and multitasking In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C93119@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <4AFC2844.9000402@gmail.com> <1A472770E042064698CB5ADC83A12ACD04C93119@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <4AFD202F.4010202@gmail.com> I'm prepare simple test for problem demonstration. http://files.roinet.net/DLRTest.zip Module utils imported 6-7 times on 2x Dual-Core Opteron 2216 machine, but method IronPythonHelper.CreateScript() called one time. On Core 2 Quad this problem has detected 4 times. On Core 2 Duo problem has not detected. In file out.txt console output with exceptions and logging information. Dino Viehland wrote: > You're only using 1 ScriptEngine class? That should be fine based upon > the code below but I just want to make sure I understand the scenario. > > Is citypay.utils being ran multiple times when you run the code in the > multi-threaded scenario? If you have a console app you could put a > print statement in utils.py to see if it's getting executed multiple > times. If it's not a console app you could put some other logging > into it. Executing Struct's definition multiple times might cause > the exceptions you're seeing but I don't know why it would get executed > multiple times. > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From avinhan at gmail.com Fri Nov 13 12:11:01 2009 From: avinhan at gmail.com (Aravin) Date: Fri, 13 Nov 2009 19:11:01 +0800 Subject: [IronPython] n-dimensional array Message-ID: <000001ca6452$0e3b1790$2ab146b0$@com> Hello everyone, I'm developing an application for my research project. I'm using IronPython as a scripting engine to allow easy data manipulation like Matlab. I require a high performance n-dimensional array class. Does anyone know of any .net library which provides a powerful n-dimensional array? I would like to do slicing operations on the array like in NumPy. (A[:2, :5] etc.) And also things like ones(.) zeros(.). I tried to use NumPy with Ironclad but im having some issues and would prefer if I could have a .net/ Ironpython ndarray library. Can you please recommend me any such library? Thanks Aravin -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Fri Nov 13 12:18:28 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 13 Nov 2009 12:18:28 +0100 Subject: [IronPython] n-dimensional array In-Reply-To: <000001ca6452$0e3b1790$2ab146b0$@com> References: <000001ca6452$0e3b1790$2ab146b0$@com> Message-ID: <4AFD4084.5060003@voidspace.org.uk> Aravin wrote: > > Hello everyone, > > I?m developing an application for my research project. I?m using > IronPython as a scripting engine to allow easy data manipulation like > Matlab. I require a high performance n-dimensional array class. Does > anyone know of any .net library which provides a powerful > n-dimensional array? > > I would like to do slicing operations on the array like in NumPy. > (A[:2, :5] etc.) > I doubt you will find a .NET library that supports slicing in the same way as numpy... You might try looking at Math.NET though: http://www.mathdotnet.com/About.aspx > And also things like ones(?) zeros(?). I tried to use NumPy with > Ironclad but im having some issues > Have you reported those issues? All the best, Michael Foord > > and would prefer if I could have a .net/ Ironpython ndarray library. > Can you please recommend me any such library? Thanks > > Aravin > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From cenovsky at bakalari.cz Fri Nov 13 14:41:38 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Fri, 13 Nov 2009 14:41:38 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC5B83.1000407@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <4AFD6212.8030108@bakalari.cz> This looks very promising but I cannot make it work. I have changed product.py in DevHawk's example to: #from clrtypeold import ClrMetaclass import clrtype class Product(object): #__metaclass__ = ClrMetaclass __metaclass__ = clrtype.ClrClass _clrnamespace = "DevHawk.IronPython.ClrTypeSeries" #_clrproperties = { #"name":str, #"cost":float, #"quantity":int, #} def __init__(self, name, cost, quantity): self.name = name self.cost = cost self.quantity = quantity def calc_total(self): return self.cost * self.quantity @property @clrtype.accepts() @clrtype.returns(str) def name(self): return self._name @name.setter @clrtype.accepts(str) @clrtype.returns() def name(self, value): self._name = value When I run it I don't see any items in the listbox. When I check the name, it is a property: py> a.root.listbox1.Items[0] => py> a.root.listbox1.Items[0].GetType().GetProperties() => Array[PropertyInfo](()) Whe I used the old clrtype with _clrproperties = {'name': str, ...}, it worked. -- -- Luk?? Shri Borde wrote: > > Here is an updated version of clrtype.py that uses @property + > @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead > of using "_clrproperties". I think its more Pythonic in general, but > also you should be able to modify @notify_property to work with it. > > > > Note that notify_property won't just work. You will have to change it > to propagate the func_name, arg_types, and return_type properties from > the old getter/setter function objects to the new getter/setter > function objects since these values are used by clrtype to generate > the CLR members. Something like this: > > > > class notify_property(property): > > > > def propagate_attributes(old_function, new_function): > > new_function.func_name = old_function.func_name > > new_function.arg_types = old_function.arg_types > > new_function.return_type = old_function.return_type > > > > def __init__(self, getter): > > def newgetter(slf): > > try: > > return getter(slf) > > except AttributeError: > > return None > > propagate_attributes(getter, newgetter) > > super(notify_property, self).__init__(newgetter) > > > > def setter(self, setter): > > def newsetter(slf, newvalue): > > oldvalue = self.fget(slf) > > if oldvalue != newvalue: > > setter(slf, newvalue) > > slf.OnPropertyChanged(setter.__name__) > > propagate_attributes(setter, newsetter) > > return property( > > fget=self.fget, > > fset=newsetter, > > fdel=self.fdel, > > doc=self.__doc__) > > > > *From:* Lukas Cenovsky [mailto:cenovsky at bakalari.cz] > *Sent:* Thursday, November 12, 2009 11:01 AM > *To:* Shri Borde > *Subject:* Re: [IronPython] .NET attributes for methods > > > > Shri Borde wrote: > > So the new clrtype.py still works - cool! > > Yep ;-) > > I am not an expert on data binding, so I don't have any suggestions. > Why do you say that the decorator approach will not work with > Silverlight? Does @notifiy_property from > http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html > use any feature not available in Silverlight? > > It does not (as far as I know because it is pure IronPython). But > @notify_property does not work with clrtypes: > > class ViewModel(NotifyPropertyChangedBase): > __metaclass__ = clrtype.ClrMetaclass > _clrnamespace = "Cenda.ViewModel" > _clrproperties = {'size': str} > > def __init__(self): > super(ViewModel, self).__init__() > # must be string to two-way binding work correctly > self.size = '10' > > @notify_property > def size(self): > return self._size > > @size.setter > def size(self, value): > self._size = value > print 'Size changed to %r' % self.size > > > > When I run this code, the size is still clr property and Python getter > and setter are not run. > > So basically I need to override/enhance clr getter and setter created > by clrtype._clrproperties. > > -- > -- Luk?? > > > > > *From:* Lukas Cenovsky [mailto:cenovsky at bakalari.cz] > *Sent:* Thursday, November 12, 2009 8:09 AM > *To:* Shri Borde > *Subject:* Re: [IronPython] .NET attributes for methods > > > > Thanks, that works! > > What do you think would be the best approach to create notifiable > properties for Silverlight? I did it for WPF (via decorators: > http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) > but it seems to me it won't be possible to do it similarly for > Silverlight... > > -- > -- Luk?? > > Shri Borde wrote: > > Can you use "_clrproperties" instead of "_clrfields"? DevHawk's same > created a field and a property even when you just used "_clrfields". I > don't do that anymore. So you will need to use "_clrproperties" to get > properties, which SL must use for data binding. > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Wednesday, November 11, 2009 2:37 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I did change __metaclass__ to ClrMetaclass. See the attached source I > use for testing - the only difference is to comment/uncomment > appropriate part in product.py. > > The outputs look the same, there are no visible exceptions: > > DevHawk: > > py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() > => Array[FieldInfo]((, > , > , > , > , > )) > > > Shri: > > py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() > => Array[FieldInfo]((, > , > , > , > , > )) > > > > -- > -- Luk?? > > > Shri Borde wrote: > > Note that you will have to set __metaclass__ to ClrMetaclass, not > ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the > type. The old name will cause a NameError, but maybe SL is hiding > exceptions. Can you do "o.GetType().GetFields()" and display that on > the page to inspect the object and also make sure that no exceptions > were thrown? > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Tuesday, November 10, 2009 2:59 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I have just found that the Silverlight binding does not work with this > version of clrtype and/or IronPython 2.6RC2. > I used DevHawk demo [1] and after I added reference to > Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But > when I switch to your version, no items show in the listbox. > > By the way - I have seen a commit message you have added support for > interfaces - nice! ;-) > > -- > -- Luk?? > > [1] > http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Fri Nov 13 15:08:51 2009 From: matan504 at gmail.com (matan keret) Date: Fri, 13 Nov 2009 16:08:51 +0200 Subject: [IronPython] DLR Hosting, IronPython Engine shutdown issues Message-ID: <5c1d2b3d0911130608q1392db1al4773487a0ba34510@mail.gmail.com> Hi everyone, In the old IronPython hosting API there used to be a simple pyEngine.Shutdown() command. And then for cleanup we used: pyEngine.Dispose() What is the equivalent in the new hosting API's? (am using IronPython 2.0.3) I found that there is something like: pyEngine.Runtime.Shutdown(); Does that do the same as the old Shutdown() method? And what can I use instead of the Dispose() command that doesn't seem to exist anymore? Thanks, Matan -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Fri Nov 13 15:20:46 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Fri, 13 Nov 2009 15:20:46 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC5B83.1000407@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <4AFD6B3E.1010101@bakalari.cz> I also tested creating interfaces and it fails with the exception below. Does this mean it will not be possible to use IronPython interface in Silverlight because of AppDomain? -- -- Luk?? SystemError: Application code cannot access System.AppDomain.get_CurrentDomain() using Reflection. clrtype.py |Line 180: validate_clr_types(b) Line 181: if not ClrInterface.interface_module_builder: Line 182: assembly_builder = AppDomain.CurrentDomain.DefineDynamicAssembly(AssemblyName("interfaces"), AssemblyBuilderAccess.Run) Line 183: ClrInterface.interface_module_builder = assembly_builder.DefineDynamicModule("interfaces") Line 184: attrs = TypeAttributes.Public | TypeAttributes.Interface | TypeAttributes.Abstract | SystemError |at define_interface in clrtype.py, line 182 at __clrtype__ in clrtype.py, line 213 at app.py in app.py, line 12 CLR Stack Trace: at System.Reflection.MethodBase.PerformSecurityCheck(Object obj, RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) at Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean& shouldOptimize) at IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`1.Call0(CallSite site, CodeContext context, TFuncType func) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at IronPython.Runtime.Types.BuiltinFunction.Call0(CodeContext context, SiteLocalStorage`1 storage, Object instance) at IronPython.Runtime.Types.ReflectedProperty.CallGetter(CodeContext context, PythonType owner, SiteLocalStorage`1 storage, Object instance) at IronPython.Runtime.Types.ReflectedProperty.TryGetValue(CodeContext context, Object instance, PythonType owner, Object& value) at IronPython.Runtime.Binding.MetaPythonType.FastGetBinderHelper.SlotAccessDelegate.Target(CodeContext context, Object self, Object& result) at IronPython.Runtime.Types.TypeGetBase.RunDelegatesNoOptimize(Object self, CodeContext context) at IronPython.Runtime.Types.SystemTypeGet.Target(CallSite site, Object self, CodeContext context) at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at clrtype$3.define_interface$21(PythonFunction $function, Object typename, Object bases) at IronPython.Runtime.PythonFunction.FunctionCaller`2.Call2(CallSite site, CodeContext context, Object func, T0 arg0, T1 arg1) at System.Dynamic.UpdateDelegates.UpdateAndExecute4[T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at clrtype$3.__clrtype__$23(PythonFunction $function, Object self) at IronPython.Runtime.PythonFunction.FunctionCaller`1.Call1(CallSite site, CodeContext context, Object func, T0 arg0) at CallSite.Target(Closure , CallSite , CodeContext , Object ) at IronPython.NewTypes.IronPython.Runtime.Types.PythonType_1$1.__clrtype__() at IronPython.Runtime.Types.PythonType.InitializeUserType(CodeContext context, String name, PythonTuple bases, PythonDictionary vars) at IronPython.Runtime.Types.PythonType..ctor(CodeContext context, String name, PythonTuple bases, PythonDictionary dict) at IronPython.NewTypes.IronPython.Runtime.Types.PythonType_1$1..ctor(CodeContext context, PythonType cls, String name, PythonTuple bases, PythonDictionary dict) at CallSite.Target(Closure , CallSite , CodeContext , BuiltinFunction , PythonType , Object , Object , Object ) at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5) at IronPython.Runtime.Types.UserInstanceCreator.CreateInstance(CodeContext context, Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Types.PythonType.CreateInstance(CodeContext context, Object arg0, Object arg1, Object arg2) at IronPython.Runtime.Types.PythonType.__new__(CodeContext context, PythonType cls, String name, PythonTuple bases, PythonDictionary dict) at CallSite.Target(Closure , CallSite , CodeContext , Object , String , PythonTuple , PythonDictionary ) at System.Dynamic.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at CallSite.Target(Closure , CallSite , CodeContext , Object , String , PythonTuple , PythonDictionary ) at IronPython.Runtime.Operations.PythonOps.MakeClass(CodeContext context, String name, Object[] bases, String selfNames, PythonDictionary vars) at IronPython.Runtime.Operations.PythonOps.MakeClass(Object body, CodeContext parentContext, String name, Object[] bases, String selfNames) at $1.(CodeContext $globalContext, FunctionCode functionCode) at IronPython.Compiler.PythonScriptCode.RunWorker(CodeContext ctx) at IronPython.Compiler.PythonScriptCode.Run(Scope scope) at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope) at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope) at Microsoft.Scripting.Hosting.CompiledCode.Execute(ScriptScope scope) at Microsoft.Scripting.Silverlight.DynamicEngine.Run(String entryPoint) at Microsoft.Scripting.Silverlight.DynamicApplication.b__1() at Microsoft.Scripting.Silverlight.Cache.Download(List`1 uris, Action onComplete) at Microsoft.Scripting.Silverlight.HttpVirtualFilesystem.DownloadAndCache(List`1 uris, Action onComplete) at Microsoft.Scripting.Silverlight.DynamicScriptTags.DownloadExternalCode(Action onComplete) at Microsoft.Scripting.Silverlight.DynamicApplication.b__0() at Microsoft.Scripting.Silverlight.DynamicLanguageConfig.DownloadLanguages(DynamicAppManifest appManifest, Action onComplete) at Microsoft.Scripting.Silverlight.DynamicApplication.DynamicApplication_Startup(Object sender, StartupEventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) | Shri Borde wrote: > > Here is an updated version of clrtype.py that uses @property + > @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead > of using "_clrproperties". I think its more Pythonic in general, but > also you should be able to modify @notify_property to work with it. > > > > Note that notify_property won't just work. You will have to change it > to propagate the func_name, arg_types, and return_type properties from > the old getter/setter function objects to the new getter/setter > function objects since these values are used by clrtype to generate > the CLR members. Something like this: > > > > class notify_property(property): > > > > def propagate_attributes(old_function, new_function): > > new_function.func_name = old_function.func_name > > new_function.arg_types = old_function.arg_types > > new_function.return_type = old_function.return_type > > > > def __init__(self, getter): > > def newgetter(slf): > > try: > > return getter(slf) > > except AttributeError: > > return None > > propagate_attributes(getter, newgetter) > > super(notify_property, self).__init__(newgetter) > > > > def setter(self, setter): > > def newsetter(slf, newvalue): > > oldvalue = self.fget(slf) > > if oldvalue != newvalue: > > setter(slf, newvalue) > > slf.OnPropertyChanged(setter.__name__) > > propagate_attributes(setter, newsetter) > > return property( > > fget=self.fget, > > fset=newsetter, > > fdel=self.fdel, > > doc=self.__doc__) > > > > *From:* Lukas Cenovsky [mailto:cenovsky at bakalari.cz] > *Sent:* Thursday, November 12, 2009 11:01 AM > *To:* Shri Borde > *Subject:* Re: [IronPython] .NET attributes for methods > > > > Shri Borde wrote: > > So the new clrtype.py still works - cool! > > Yep ;-) > > I am not an expert on data binding, so I don't have any suggestions. > Why do you say that the decorator approach will not work with > Silverlight? Does @notifiy_property from > http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html > use any feature not available in Silverlight? > > It does not (as far as I know because it is pure IronPython). But > @notify_property does not work with clrtypes: > > class ViewModel(NotifyPropertyChangedBase): > __metaclass__ = clrtype.ClrMetaclass > _clrnamespace = "Cenda.ViewModel" > _clrproperties = {'size': str} > > def __init__(self): > super(ViewModel, self).__init__() > # must be string to two-way binding work correctly > self.size = '10' > > @notify_property > def size(self): > return self._size > > @size.setter > def size(self, value): > self._size = value > print 'Size changed to %r' % self.size > > > > When I run this code, the size is still clr property and Python getter > and setter are not run. > > So basically I need to override/enhance clr getter and setter created > by clrtype._clrproperties. > > -- > -- Luk?? > > > > > *From:* Lukas Cenovsky [mailto:cenovsky at bakalari.cz] > *Sent:* Thursday, November 12, 2009 8:09 AM > *To:* Shri Borde > *Subject:* Re: [IronPython] .NET attributes for methods > > > > Thanks, that works! > > What do you think would be the best approach to create notifiable > properties for Silverlight? I did it for WPF (via decorators: > http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) > but it seems to me it won't be possible to do it similarly for > Silverlight... > > -- > -- Luk?? > > Shri Borde wrote: > > Can you use "_clrproperties" instead of "_clrfields"? DevHawk's same > created a field and a property even when you just used "_clrfields". I > don't do that anymore. So you will need to use "_clrproperties" to get > properties, which SL must use for data binding. > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Wednesday, November 11, 2009 2:37 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I did change __metaclass__ to ClrMetaclass. See the attached source I > use for testing - the only difference is to comment/uncomment > appropriate part in product.py. > > The outputs look the same, there are no visible exceptions: > > DevHawk: > > py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() > => Array[FieldInfo]((, > , > , > , > , > )) > > > Shri: > > py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() > => Array[FieldInfo]((, > , > , > , > , > )) > > > > -- > -- Luk?? > > > Shri Borde wrote: > > Note that you will have to set __metaclass__ to ClrMetaclass, not > ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the > type. The old name will cause a NameError, but maybe SL is hiding > exceptions. Can you do "o.GetType().GetFields()" and display that on > the page to inspect the object and also make sure that no exceptions > were thrown? > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Tuesday, November 10, 2009 2:59 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > I have just found that the Silverlight binding does not work with this > version of clrtype and/or IronPython 2.6RC2. > I used DevHawk demo [1] and after I added reference to > Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But > when I switch to your version, no items show in the listbox. > > By the way - I have seen a commit message you have added support for > interfaces - nice! ;-) > > -- > -- Luk?? > > [1] > http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip > > > > > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Shri.Borde at microsoft.com Fri Nov 13 16:33:04 2009 From: Shri.Borde at microsoft.com (Shri Borde) Date: Fri, 13 Nov 2009 15:33:04 +0000 Subject: [IronPython] .NET attributes for methods In-Reply-To: <4AFD6212.8030108@bakalari.cz> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC5B83.1000407@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFD6212.8030108@bakalari.cz> Message-ID: <8E45365BECA665489F3CB8878A6C1B7D0C800CB2@TK5EX14MBXC140.redmond.corp.microsoft.com> I can help you create a property. And I can help you get it to work with your decorators (you can check if the "name" property exposes your @notify_property wrapper methods or not, and presumably that works). Beyond that, you are on your own :) I would try calling the property methods to make sure they are accessible. Something like this. If that works, I am not sure what Silverlight needs to make databinding happy. props = a.root.listbox1.Items[0].GetType().GetProperties() prop = props[0] prop.GetGetMethod.Invoke(a, None) # call using Reflection About the "SystemError: Application code cannot access System.AppDomain.get_CurrentDomain() using Reflection." error when defining interfaces, it could be worked around. We need to call AppDomain.DefineDynamicAssembly, and IronPython itself does do this. So its just a question of figuring out the right way to access an AppDomain instance. Will look into it, but I doubt it will help you with data binding. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Friday, November 13, 2009 5:42 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods This looks very promising but I cannot make it work. I have changed product.py in DevHawk's example to: #from clrtypeold import ClrMetaclass import clrtype class Product(object): #__metaclass__ = ClrMetaclass __metaclass__ = clrtype.ClrClass _clrnamespace = "DevHawk.IronPython.ClrTypeSeries" #_clrproperties = { #"name":str, #"cost":float, #"quantity":int, #} def __init__(self, name, cost, quantity): self.name = name self.cost = cost self.quantity = quantity def calc_total(self): return self.cost * self.quantity @property @clrtype.accepts() @clrtype.returns(str) def name(self): return self._name @name.setter @clrtype.accepts(str) @clrtype.returns() def name(self, value): self._name = value When I run it I don't see any items in the listbox. When I check the name, it is a property: py> a.root.listbox1.Items[0] => py> a.root.listbox1.Items[0].GetType().GetProperties() => Array[PropertyInfo](()) Whe I used the old clrtype with _clrproperties = {'name': str, ...}, it worked. -- -- Luk?? Shri Borde wrote: Here is an updated version of clrtype.py that uses @property + @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead of using "_clrproperties". I think its more Pythonic in general, but also you should be able to modify @notify_property to work with it. Note that notify_property won't just work. You will have to change it to propagate the func_name, arg_types, and return_type properties from the old getter/setter function objects to the new getter/setter function objects since these values are used by clrtype to generate the CLR members. Something like this: class notify_property(property): def propagate_attributes(old_function, new_function): new_function.func_name = old_function.func_name new_function.arg_types = old_function.arg_types new_function.return_type = old_function.return_type def __init__(self, getter): def newgetter(slf): try: return getter(slf) except AttributeError: return None propagate_attributes(getter, newgetter) super(notify_property, self).__init__(newgetter) def setter(self, setter): def newsetter(slf, newvalue): oldvalue = self.fget(slf) if oldvalue != newvalue: setter(slf, newvalue) slf.OnPropertyChanged(setter.__name__) propagate_attributes(setter, newsetter) return property( fget=self.fget, fset=newsetter, fdel=self.fdel, doc=self.__doc__) From: Lukas Cenovsky [mailto:cenovsky at bakalari.cz] Sent: Thursday, November 12, 2009 11:01 AM To: Shri Borde Subject: Re: [IronPython] .NET attributes for methods Shri Borde wrote: So the new clrtype.py still works - cool! Yep ;-) I am not an expert on data binding, so I don't have any suggestions. Why do you say that the decorator approach will not work with Silverlight? Does @notifiy_property from http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html use any feature not available in Silverlight? It does not (as far as I know because it is pure IronPython). But @notify_property does not work with clrtypes: class ViewModel(NotifyPropertyChangedBase): __metaclass__ = clrtype.ClrMetaclass _clrnamespace = "Cenda.ViewModel" _clrproperties = {'size': str} def __init__(self): super(ViewModel, self).__init__() # must be string to two-way binding work correctly self.size = '10' @notify_property def size(self): return self._size @size.setter def size(self, value): self._size = value print 'Size changed to %r' % self.size When I run this code, the size is still clr property and Python getter and setter are not run. So basically I need to override/enhance clr getter and setter created by clrtype._clrproperties. -- -- Luk?? From: Lukas Cenovsky [mailto:cenovsky at bakalari.cz] Sent: Thursday, November 12, 2009 8:09 AM To: Shri Borde Subject: Re: [IronPython] .NET attributes for methods Thanks, that works! What do you think would be the best approach to create notifiable properties for Silverlight? I did it for WPF (via decorators: http://gui-at.blogspot.com/2009/11/inotifypropertychanged-in-ironpython.html) but it seems to me it won't be possible to do it similarly for Silverlight... -- -- Luk?? Shri Borde wrote: Can you use "_clrproperties" instead of "_clrfields"? DevHawk's same created a field and a property even when you just used "_clrfields". I don't do that anymore. So you will need to use "_clrproperties" to get properties, which SL must use for data binding. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Wednesday, November 11, 2009 2:37 AM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I did change __metaclass__ to ClrMetaclass. See the attached source I use for testing - the only difference is to comment/uncomment appropriate part in product.py. The outputs look the same, there are no visible exceptions: DevHawk: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) Shri: py> a.root.FindName('listbox1').ItemsSource[0].GetType().GetFields() => Array[FieldInfo]((, , , , , )) -- -- Luk?? Shri Borde wrote: Note that you will have to set __metaclass__ to ClrMetaclass, not ClrTypeMetaclass as in DevHawk's sample. I had changed the name of the type. The old name will cause a NameError, but maybe SL is hiding exceptions. Can you do "o.GetType().GetFields()" and display that on the page to inspect the object and also make sure that no exceptions were thrown? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky Sent: Tuesday, November 10, 2009 2:59 PM To: Discussion of IronPython Subject: Re: [IronPython] .NET attributes for methods I have just found that the Silverlight binding does not work with this version of clrtype and/or IronPython 2.6RC2. I used DevHawk demo [1] and after I added reference to Microsoft.Dynamic in clrtypemetaclass.py it worked flawlessly. But when I switch to your version, no items show in the listbox. By the way - I have seen a commit message you have added support for interfaces - nice! ;-) -- -- Luk?? [1] http://cid-0d9bc809858885a4.skydrive.live.com/self.aspx/DevHawk%20Content/IronPython%20Stuff/^_^_clrtype^_^_/SL%20databinding%20demo.zip ________________________________ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Fri Nov 13 17:26:09 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Fri, 13 Nov 2009 17:26:09 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <8E45365BECA665489F3CB8878A6C1B7D0C800CB2@TK5EX14MBXC140.redmond.corp.microsoft.com> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC5B83.1000407@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFD6212.8030108@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C800CB2@TK5EX14MBXC140.redmond.corp.microsoft.com> Message-ID: <4AFD88A1.30807@bakalari.cz> Help with getting properties to work will hopefully resolve the databinding as well ;-) The property getter looks wrong but I have no idea what's wrong: py> props = a.root.listbox1.Items[0].GetType().GetProperties() py> props => Array[PropertyInfo](()) py> prop = props[0] py> prop.GetGetMethod() => py> prop.GetGetMethod().Invoke(a.root.listbox1.Items[0], None) System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. at in , line 0 Just for clarification "a" is Silverlight Application instance As for the interface error - this is a different strory. You may remember I created WCF service in IronPython with just interface defined in C#. To be able to move interface to IronPython, I need such interface to work with Silverlight too because Silverlight is the cause why I am building WCF services. -- -- Luk?? Shri Borde wrote: > > I can help you create a property. And I can help you get it to work > with your decorators (you can check if the "name" property exposes > your @notify_property wrapper methods or not, and presumably that > works). Beyond that, you are on your own :) > > > > I would try calling the property methods to make sure they are > accessible. Something like this. If that works, I am not sure what > Silverlight needs to make databinding happy. > > > > props = a.root.listbox1.Items[0].GetType().GetProperties() > > prop = props[0] > > prop.GetGetMethod.Invoke(a, None) # call using Reflection > > > > About the "SystemError: Application code cannot access > System.AppDomain.get_CurrentDomain() using Reflection." error when > defining interfaces, it could be worked around. We need to call > AppDomain.DefineDynamicAssembly, and IronPython itself does do this. > So its just a question of figuring out the right way to access an > AppDomain instance. Will look into it, but I doubt it will help you > with data binding. > > > > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky > *Sent:* Friday, November 13, 2009 5:42 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] .NET attributes for methods > > > > This looks very promising but I cannot make it work. I have changed > product.py in DevHawk's example to: > > #from clrtypeold import ClrMetaclass > import clrtype > > class Product(object): > #__metaclass__ = ClrMetaclass > __metaclass__ = clrtype.ClrClass > _clrnamespace = "DevHawk.IronPython.ClrTypeSeries" > #_clrproperties = { > #"name":str, > #"cost":float, > #"quantity":int, > #} > > def __init__(self, name, cost, quantity): > self.name = name > self.cost = cost > self.quantity = quantity > > def calc_total(self): > return self.cost * self.quantity > > @property > @clrtype.accepts() > @clrtype.returns(str) > def name(self): > return self._name > > @name.setter > @clrtype.accepts(str) > @clrtype.returns() > def name(self, value): > self._name = value > > > When I run it I don't see any items in the listbox. When I check the > name, it is a property: > > py> a.root.listbox1.Items[0] > => > py> a.root.listbox1.Items[0].GetType().GetProperties() > => Array[PropertyInfo](()) > > > Whe I used the old clrtype with _clrproperties = {'name': str, ...}, > it worked. > > -- > -- Luk?? > > > Shri Borde wrote: > > Here is an updated version of clrtype.py that uses @property + > @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead > of using "_clrproperties". I think its more Pythonic in general, but > also you should be able to modify @notify_property to work with it. > > > > Note that notify_property won't just work. You will have to change it > to propagate the func_name, arg_types, and return_type properties from > the old getter/setter function objects to the new getter/setter > function objects since these values are used by clrtype to generate > the CLR members. Something like this: > > > > class notify_property(property): > > > > def propagate_attributes(old_function, new_function): > > new_function.func_name = old_function.func_name > > new_function.arg_types = old_function.arg_types > > new_function.return_type = old_function.return_type > > > > def __init__(self, getter): > > def newgetter(slf): > > try: > > return getter(slf) > > except AttributeError: > > return None > > propagate_attributes(getter, newgetter) > > super(notify_property, self).__init__(newgetter) > > > > def setter(self, setter): > > def newsetter(slf, newvalue): > > oldvalue = self.fget(slf) > > if oldvalue != newvalue: > > setter(slf, newvalue) > > slf.OnPropertyChanged(setter.__name__) > > propagate_attributes(setter, newsetter) > > return property( > > fget=self.fget, > > fset=newsetter, > > fdel=self.fdel, > > doc=self.__doc__) > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Fri Nov 13 18:23:10 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 13 Nov 2009 17:23:10 +0000 Subject: [IronPython] DLR Hosting, IronPython Engine shutdown issues In-Reply-To: <5c1d2b3d0911130608q1392db1al4773487a0ba34510@mail.gmail.com> References: <5c1d2b3d0911130608q1392db1al4773487a0ba34510@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04C999A7@TK5EX14MBXC118.redmond.corp.microsoft.com> pyEngine.Runtime.Shutdown() is the equivalent. As far as Python is concerned the only interesting thing this does is run sys.exitfunc if it's been set - there's some other stuff that happens but it's logging and some cleanup which will happen on its own. So there's no need to really call a Dispose type method. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of matan keret Sent: Friday, November 13, 2009 6:09 AM To: Discussion of IronPython Subject: [IronPython] DLR Hosting, IronPython Engine shutdown issues Hi everyone, In the old IronPython hosting API there used to be a simple pyEngine.Shutdown() command. And then for cleanup we used: pyEngine.Dispose() What is the equivalent in the new hosting API's? (am using IronPython 2.0.3) I found that there is something like: pyEngine.Runtime.Shutdown(); Does that do the same as the old Shutdown() method? And what can I use instead of the Dispose() command that doesn't seem to exist anymore? Thanks, Matan -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Fri Nov 13 19:44:58 2009 From: matan504 at gmail.com (matan keret) Date: Fri, 13 Nov 2009 20:44:58 +0200 Subject: [IronPython] DLR Hosting, IronPython Engine shutdown issues In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04C999A7@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <5c1d2b3d0911130608q1392db1al4773487a0ba34510@mail.gmail.com> <1A472770E042064698CB5ADC83A12ACD04C999A7@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <5c1d2b3d0911131044s250e5945h654c9f9fac66d1ad@mail.gmail.com> OK thank you for the fast reply! On Fri, Nov 13, 2009 at 7:23 PM, Dino Viehland wrote: > pyEngine.Runtime.Shutdown() is the equivalent. As far as Python is > concerned the only interesting thing this does is run sys.exitfunc if it?s > been set - there?s some other stuff that happens but it?s logging and some > cleanup which will happen on its own. So there?s no need to really call a > Dispose type method. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *matan keret > *Sent:* Friday, November 13, 2009 6:09 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] DLR Hosting, IronPython Engine shutdown issues > > > > Hi everyone, > > > > In the old IronPython hosting API there used to be a simple > pyEngine.Shutdown() command. > > And then for cleanup we used: pyEngine.Dispose() > > > > What is the equivalent in the new hosting API's? (am using IronPython > 2.0.3) > > I found that there is something like: pyEngine.Runtime.Shutdown(); > > > > Does that do the same as the old Shutdown() method? > > And what can I use instead of the Dispose() command that doesn't seem to > exist anymore? > > > > Thanks, > > Matan > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From luis.bilar at gmail.com Fri Nov 13 21:26:52 2009 From: luis.bilar at gmail.com (luis bilar) Date: Fri, 13 Nov 2009 17:26:52 -0300 Subject: [IronPython] Hello, Message-ID: Hi My names is Luis Bilar , I'm from brazil, I have a problem, with I call libary in ironpython ? -- Thanks & Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU "The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited." -------------- next part -------------- An HTML attachment was scrubbed... URL: From ctrachte at gmail.com Fri Nov 13 21:33:37 2009 From: ctrachte at gmail.com (Carl Trachte) Date: Fri, 13 Nov 2009 13:33:37 -0700 Subject: [IronPython] Hello, In-Reply-To: References: Message-ID: <426ada670911131233x24aab399h199f5182d56b1abf@mail.gmail.com> On 11/13/09, luis bilar wrote: > Hi > My names is Luis Bilar , I'm from brazil, I have a problem, with I call > libary in ironpython ? > > -- > Thanks & Regards, > Luis Bilar > +55 85036522 > > System technology internet > Specialist in information security - > Recife Center for Advanced Studies and Systems - CESAR.EDU > > "The information in this e-mail and in its attachment(s) are confidential, > legally protected and intended for specific individual(s) and purposes. If > you are neither the intended recipient nor the person responsible for > delivering the message to the named addressee(s), please notify us > immediately and delete this message without retaining or making any copy. > Please be aware that any utilization, dissemination, disclosure or > reproduction of this message, as well as any action taken or neglected in > reliance on it is expressly prohibited." > Luis, Can you provide some code or background? If you're getting started, this is a good site: www.ironpython.info Carl T. From luis.bilar at gmail.com Fri Nov 13 21:53:30 2009 From: luis.bilar at gmail.com (luis bilar) Date: Fri, 13 Nov 2009 17:53:30 -0300 Subject: [IronPython] Hello, In-Reply-To: <426ada670911131233x24aab399h199f5182d56b1abf@mail.gmail.com> References: <426ada670911131233x24aab399h199f5182d56b1abf@mail.gmail.com> Message-ID: Hi, I need implematation this's code in ironpython from pytesser import* image = Image.open('fnord.tf') print image_to_string(image) but need call libary pytesser. please help me :( 2009/11/13 Carl Trachte > On 11/13/09, luis bilar wrote: > > Hi > > My names is Luis Bilar , I'm from brazil, I have a problem, with I call > > libary in ironpython ? > > > > -- > > Thanks & Regards, > > Luis Bilar > > +55 85036522 > > > > System technology internet > > Specialist in information security - > > Recife Center for Advanced Studies and Systems - CESAR.EDU > > > > "The information in this e-mail and in its attachment(s) are > confidential, > > legally protected and intended for specific individual(s) and purposes. > If > > you are neither the intended recipient nor the person responsible for > > delivering the message to the named addressee(s), please notify us > > immediately and delete this message without retaining or making any copy. > > Please be aware that any utilization, dissemination, disclosure or > > reproduction of this message, as well as any action taken or neglected in > > reliance on it is expressly prohibited." > > > > Luis, > > Can you provide some code or background? > > If you're getting started, this is a good site: > > www.ironpython.info > > Carl T. > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Thanks & Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU "The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited." -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Fri Nov 13 22:22:17 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Fri, 13 Nov 2009 22:22:17 +0100 Subject: [IronPython] .NET attributes for methods In-Reply-To: <4AFD88A1.30807@bakalari.cz> References: <4AE09833.8020203@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7A9BB7@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AF9F039.7000301@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FCAD5@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFA93BD.4040902@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FF499@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC3313.3060908@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C7FFE68@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFC5B83.1000407@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C80006B@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFD6212.8030108@bakalari.cz> <8E45365BECA665489F3CB8878A6C1B7D0C800CB2@TK5EX14MBXC140.redmond.corp.microsoft.com> <4AFD88A1.30807@bakalari.cz> Message-ID: <4AFDCE09.4030405@bakalari.cz> Thanks to Shri and the new clrtype both issues are resolved. I will post details soon on my blog. -- -- Luk?? Lukas Cenovsky wrote: > Help with getting properties to work will hopefully resolve the > databinding as well ;-) > > The property getter looks wrong but I have no idea what's wrong: > > py> props = a.root.listbox1.Items[0].GetType().GetProperties() > py> props > => Array[PropertyInfo](()) > py> prop = props[0] > py> prop.GetGetMethod() > => > py> prop.GetGetMethod().Invoke(a.root.listbox1.Items[0], None) > System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. > at in , line 0 > > > Just for clarification "a" is Silverlight Application instance > > As for the interface error - this is a different strory. You may > remember I created WCF service in IronPython with just interface > defined in C#. To be able to move interface to IronPython, I need such > interface to work with Silverlight too because Silverlight is the > cause why I am building WCF services. > > -- > -- Luk?? > > > Shri Borde wrote: >> >> I can help you create a property. And I can help you get it to work >> with your decorators (you can check if the "name" property exposes >> your @notify_property wrapper methods or not, and presumably that >> works). Beyond that, you are on your own :) >> >> >> >> I would try calling the property methods to make sure they are >> accessible. Something like this. If that works, I am not sure what >> Silverlight needs to make databinding happy. >> >> >> >> props = a.root.listbox1.Items[0].GetType().GetProperties() >> >> prop = props[0] >> >> prop.GetGetMethod.Invoke(a, None) # call using Reflection >> >> >> >> About the "SystemError: Application code cannot access >> System.AppDomain.get_CurrentDomain() using Reflection." error when >> defining interfaces, it could be worked around. We need to call >> AppDomain.DefineDynamicAssembly, and IronPython itself does do this. >> So its just a question of figuring out the right way to access an >> AppDomain instance. Will look into it, but I doubt it will help you >> with data binding. >> >> >> >> *From:* users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Lukas Cenovsky >> *Sent:* Friday, November 13, 2009 5:42 AM >> *To:* Discussion of IronPython >> *Subject:* Re: [IronPython] .NET attributes for methods >> >> >> >> This looks very promising but I cannot make it work. I have changed >> product.py in DevHawk's example to: >> >> #from clrtypeold import ClrMetaclass >> import clrtype >> >> class Product(object): >> #__metaclass__ = ClrMetaclass >> __metaclass__ = clrtype.ClrClass >> _clrnamespace = "DevHawk.IronPython.ClrTypeSeries" >> #_clrproperties = { >> #"name":str, >> #"cost":float, >> #"quantity":int, >> #} >> >> def __init__(self, name, cost, quantity): >> self.name = name >> self.cost = cost >> self.quantity = quantity >> >> def calc_total(self): >> return self.cost * self.quantity >> >> @property >> @clrtype.accepts() >> @clrtype.returns(str) >> def name(self): >> return self._name >> >> @name.setter >> @clrtype.accepts(str) >> @clrtype.returns() >> def name(self, value): >> self._name = value >> >> >> When I run it I don't see any items in the listbox. When I check the >> name, it is a property: >> >> py> a.root.listbox1.Items[0] >> => >> py> a.root.listbox1.Items[0].GetType().GetProperties() >> => Array[PropertyInfo](()) >> >> >> Whe I used the old clrtype with _clrproperties = {'name': str, ...}, >> it worked. >> >> -- >> -- Luk?? >> >> >> Shri Borde wrote: >> >> Here is an updated version of clrtype.py that uses @property + >> @clrtype.accepts/@clrtype.returns to indicate a CLR property, instead >> of using "_clrproperties". I think its more Pythonic in general, but >> also you should be able to modify @notify_property to work with it. >> >> >> >> Note that notify_property won't just work. You will have to change it >> to propagate the func_name, arg_types, and return_type properties >> from the old getter/setter function objects to the new getter/setter >> function objects since these values are used by clrtype to generate >> the CLR members. Something like this: >> >> >> >> class notify_property(property): >> >> >> >> def propagate_attributes(old_function, new_function): >> >> new_function.func_name = old_function.func_name >> >> new_function.arg_types = old_function.arg_types >> >> new_function.return_type = old_function.return_type >> >> >> >> def __init__(self, getter): >> >> def newgetter(slf): >> >> try: >> >> return getter(slf) >> >> except AttributeError: >> >> return None >> >> propagate_attributes(getter, newgetter) >> >> super(notify_property, self).__init__(newgetter) >> >> >> >> def setter(self, setter): >> >> def newsetter(slf, newvalue): >> >> oldvalue = self.fget(slf) >> >> if oldvalue != newvalue: >> >> setter(slf, newvalue) >> >> slf.OnPropertyChanged(setter.__name__) >> >> propagate_attributes(setter, newsetter) >> >> return property( >> >> fget=self.fget, >> >> fset=newsetter, >> >> fdel=self.fdel, >> >> doc=self.__doc__) >> > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ctrachte at gmail.com Fri Nov 13 22:31:16 2009 From: ctrachte at gmail.com (Carl Trachte) Date: Fri, 13 Nov 2009 14:31:16 -0700 Subject: [IronPython] Hello, In-Reply-To: References: <426ada670911131233x24aab399h199f5182d56b1abf@mail.gmail.com> Message-ID: <426ada670911131331g3e0c9a3n99eb5ae8146eff59@mail.gmail.com> On 11/13/09, luis bilar wrote: > Hi, > > I need implematation this's code in ironpython > > from pytesser import* > image = Image.open('fnord.tf') > print image_to_string(image) > > but need call libary pytesser. > > please help me :( Luis, OK, you're in the wrong place (on the wrong list). You need to use the standard implementation of Python 2.4 from www.python.org. Good luck. We can't help you here any more. Here is the google code link for pytesser: http://code.google.com/p/pytesser/ PyTesser PyTesser is an Optical Character Recognition module for Python. It takes as input an image or image file and outputs a string. PyTesser uses the Tesseract OCR engine, converting images to an accepted format and calling the Tesseract executable as an external script. A Windows executable is provided along with the Python scripts. The scripts should work in other operating systems as well. Dependencies PIL is required to work with images in memory. PyTesser has been tested with Python 2.4 in Windows XP. Usage Example >>> from pytesser import *>>> image = Image.open('fnord.tif') # Open image object using PIL>>> print image_to_string(image) # Run tesseract.exe on imagefnord>>> print image_file_to_string('fnord.tif')fnord(more examples in README) Carl T. > > 2009/11/13 Carl Trachte > >> On 11/13/09, luis bilar wrote: >> > Hi >> > My names is Luis Bilar , I'm from brazil, I have a problem, with I call >> > libary in ironpython ? >> > >> > -- >> > Thanks & Regards, >> > Luis Bilar >> > +55 85036522 >> > >> > System technology internet >> > Specialist in information security - >> > Recife Center for Advanced Studies and Systems - CESAR.EDU >> > >> > "The information in this e-mail and in its attachment(s) are >> confidential, >> > legally protected and intended for specific individual(s) and purposes. >> If >> > you are neither the intended recipient nor the person responsible for >> > delivering the message to the named addressee(s), please notify us >> > immediately and delete this message without retaining or making any >> > copy. >> > Please be aware that any utilization, dissemination, disclosure or >> > reproduction of this message, as well as any action taken or neglected >> > in >> > reliance on it is expressly prohibited." >> > >> >> Luis, >> >> Can you provide some code or background? >> >> If you're getting started, this is a good site: >> >> www.ironpython.info >> >> Carl T. >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > Thanks & Regards, > Luis Bilar > +55 85036522 > > System technology internet > Specialist in information security - > Recife Center for Advanced Studies and Systems - CESAR.EDU > > "The information in this e-mail and in its attachment(s) are confidential, > legally protected and intended for specific individual(s) and purposes. If > you are neither the intended recipient nor the person responsible for > delivering the message to the named addressee(s), please notify us > immediately and delete this message without retaining or making any copy. > Please be aware that any utilization, dissemination, disclosure or > reproduction of this message, as well as any action taken or neglected in > reliance on it is expressly prohibited." > From luis.bilar at gmail.com Sat Nov 14 02:44:04 2009 From: luis.bilar at gmail.com (luis bilar) Date: Fri, 13 Nov 2009 23:44:04 -0200 Subject: [IronPython] Hello, In-Reply-To: <426ada670911131331g3e0c9a3n99eb5ae8146eff59@mail.gmail.com> References: <426ada670911131233x24aab399h199f5182d56b1abf@mail.gmail.com> <426ada670911131331g3e0c9a3n99eb5ae8146eff59@mail.gmail.com> Message-ID: Tks the best. 2009/11/13 Carl Trachte > On 11/13/09, luis bilar wrote: > > Hi, > > > > I need implematation this's code in ironpython > > > > from pytesser import* > > image = Image.open('fnord.tf') > > print image_to_string(image) > > > > but need call libary pytesser. > > > > please help me :( > > Luis, > > OK, you're in the wrong place (on the wrong list). You need to use > the standard implementation of Python 2.4 from www.python.org. > > Good luck. We can't help you here any more. > > Here is the google code link for pytesser: > > http://code.google.com/p/pytesser/ > > PyTesser > PyTesser is an Optical Character Recognition module for Python. It > takes as input an image or image file and outputs a string. > PyTesser uses the Tesseract OCR engine, converting images to an > accepted format and calling the Tesseract executable as an external > script. A Windows executable is provided along with the Python > scripts. The scripts should work in other operating systems as well. > Dependencies > PIL is required to work with images in memory. PyTesser has been > tested with Python 2.4 in Windows XP. > Usage Example > >>> from pytesser import *>>> image = Image.open('fnord.tif') # Open image > object using PIL>>> print image_to_string(image) # Run tesseract.exe on > imagefnord>>> print image_file_to_string('fnord.tif')fnord(more examples in > README) > > Carl T. > > > > > 2009/11/13 Carl Trachte > > > >> On 11/13/09, luis bilar wrote: > >> > Hi > >> > My names is Luis Bilar , I'm from brazil, I have a problem, with I > call > >> > libary in ironpython ? > >> > > >> > -- > >> > Thanks & Regards, > >> > Luis Bilar > >> > +55 85036522 > >> > > >> > System technology internet > >> > Specialist in information security - > >> > Recife Center for Advanced Studies and Systems - CESAR.EDU > >> > > >> > "The information in this e-mail and in its attachment(s) are > >> confidential, > >> > legally protected and intended for specific individual(s) and > purposes. > >> If > >> > you are neither the intended recipient nor the person responsible for > >> > delivering the message to the named addressee(s), please notify us > >> > immediately and delete this message without retaining or making any > >> > copy. > >> > Please be aware that any utilization, dissemination, disclosure or > >> > reproduction of this message, as well as any action taken or neglected > >> > in > >> > reliance on it is expressly prohibited." > >> > > >> > >> Luis, > >> > >> Can you provide some code or background? > >> > >> If you're getting started, this is a good site: > >> > >> www.ironpython.info > >> > >> Carl T. > >> _______________________________________________ > >> Users mailing list > >> Users at lists.ironpython.com > >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > >> > > > > > > > > -- > > Thanks & Regards, > > Luis Bilar > > +55 85036522 > > > > System technology internet > > Specialist in information security - > > Recife Center for Advanced Studies and Systems - CESAR.EDU > > > > "The information in this e-mail and in its attachment(s) are > confidential, > > legally protected and intended for specific individual(s) and purposes. > If > > you are neither the intended recipient nor the person responsible for > > delivering the message to the named addressee(s), please notify us > > immediately and delete this message without retaining or making any copy. > > Please be aware that any utilization, dissemination, disclosure or > > reproduction of this message, as well as any action taken or neglected in > > reliance on it is expressly prohibited." > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Thanks & Regards, Luis Bilar +55 85036522 System technology internet Specialist in information security - Recife Center for Advanced Studies and Systems - CESAR.EDU "The information in this e-mail and in its attachment(s) are confidential, legally protected and intended for specific individual(s) and purposes. If you are neither the intended recipient nor the person responsible for delivering the message to the named addressee(s), please notify us immediately and delete this message without retaining or making any copy. Please be aware that any utilization, dissemination, disclosure or reproduction of this message, as well as any action taken or neglected in reliance on it is expressly prohibited." -------------- next part -------------- An HTML attachment was scrubbed... URL: From josh at globalherald.net Sun Nov 15 17:40:33 2009 From: josh at globalherald.net (Joshua Kramer) Date: Sun, 15 Nov 2009 11:40:33 -0500 (EST) Subject: [IronPython] Embedding IronPython in MS-Office (fwd) Message-ID: A while back, Slide wrote: "You'd have to write an add-in for office that hosted the .NET runtime and provided a hosting API that IP could interact with. I don't think this would be a small undertaking." Hmm. Is there any way to have MSO "see" IPY as a Scripting or Macro Language, like it sees VBA? I am familiar with writing console (or regular) apps in C# and using the Microsoft.Office.Interop assemblies - I could do this easily from IronPython but I'd rather it be usable from within the MSO environment. OpenOffice is better in this regard because it "sees" Python, Java, and Basic as just different scripting / macro languages, and therefore it's easy to write Python apps that EITHER run from within the environment or outside. Cheers, -JK -- ----- http://www.globalherald.net/jb01 GlobalHerald.NET, the Smarter Social Network! (tm) From curt at hagenlocher.org Sun Nov 15 16:16:10 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Sun, 15 Nov 2009 07:16:10 -0800 Subject: [IronPython] Embedding IronPython in MS-Office (fwd) In-Reply-To: References: Message-ID: VBA is embedded pretty tightly into Word and Excel; there's no way to swap it out for another scripting engine. On Sun, Nov 15, 2009 at 8:40 AM, Joshua Kramer wrote: > > A while back, Slide wrote: > > "You'd have to write an add-in for office that hosted the .NET runtime and > provided a hosting API that IP could interact with. I don't think this > would be a small undertaking." > > Hmm. Is there any way to have MSO "see" IPY as a Scripting or Macro > Language, like it sees VBA? I am familiar with writing console (or regular) > apps in C# and using the Microsoft.Office.Interop assemblies - I could do > this easily from IronPython but I'd rather it be usable from within the MSO > environment. > > OpenOffice is better in this regard because it "sees" Python, Java, and > Basic as just different scripting / macro languages, and therefore it's easy > to write Python apps that EITHER run from within the environment or outside. > > Cheers, > -JK > > -- > > ----- > http://www.globalherald.net/jb01 > GlobalHerald.NET, the Smarter Social Network! (tm) > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Sun Nov 15 17:34:14 2009 From: matan504 at gmail.com (matan keret) Date: Sun, 15 Nov 2009 18:34:14 +0200 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue Message-ID: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> Hi everyone! i wrote the next code which suppose to go to my hotmail account, fetch the last email's image attachment and save it to a file: import email, poplib, os, string def get_messages_id(message_list): items = [] for message in message_list[1]: message_parts = string.split(message,' ') message_id = message_parts[0] items.append(message_id) # print 'message id is: %s\n' % message_id # print 'done getting ids' return items host = "pop3.live.com" detach_dir = 'D:\\test-attachments\\' # directory where to save attachments (default: current) user = "matan.py at hotmail.com" pwd = "0okmnji9" server = poplib.POP3_SSL(host) server.user(user) server.pass_(pwd) numMessages = len(server.list()[1]) #print numMessages # server.list() returns messages info from server in # form of response, message_list, size where message_list # is. a list of messages in form of 'message_id size' message_list = server.list() # get the list of items id items = get_messages_id(message_list) items.reverse() # puts the last received mail's id in the first place in list is_image = False # find the first mail in items that has an attachment and get the attachment for emailid in items: # if we found an email with an image we break if is_image: break total_email_message = server.retr(emailid)[1] messageText = string.join(total_email_message, "\n") mail = email.message_from_string(messageText) # parsing the mail content to get a mail object # Check if there are any attachments at all if mail.get_content_maintype() != 'multipart': continue # we use walk to create a generator so we can iterate on the parts for part in mail.walk(): # skip any attachment which is not an image if part.get_content_maintype() != 'image': continue # is this part an attachment ? if part.get('Content-Disposition') is None: continue filename = part.get_filename() is_image = True # if there is no filename, we create one with a counter to avoid duplicates if not filename: filename = 'part-%03d%s' % (1, 'bin') att_path = os.path.join(detach_dir, filename) # Check if its not already there and finally write the file if not os.path.isfile(att_path) : fp = open(att_path, 'wb') fp.write(part.get_payload(decode=True)) fp.close() # if we found an email with an image we break after first image downloaded if is_image: break server.quit() print 'Finished fetching the image' # THE END also available at: http://pastebin.org/53873 This works fine on Cpython but on IronPython 2.0.3 I get: Traceback (most recent call last): File "get_first_attachment.py", line 21, in get_first_attachment.py File "D:\IronPython 2.0.3\Lib\poplib.py", line 361, in __init__ File "D:\IronPython 2.0.3\Lib\poplib.py", line 137, in _getresp File "D:\IronPython 2.0.3\Lib\poplib.py", line 374, in _getline File "D:\IronPython 2.0.3\Lib\poplib.py", line 364, in _fillBuffer MemoryError: Exception of type 'System.OutOfMemoryException' was thrown. this comes out from line 21: server = poplib.POP3_SSL(host) Any ideas why is that? How to fix it? Is it a known issue (tried to look but couldn't find)? Thanks, Matan -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony.meyer at gmail.com Sun Nov 15 20:54:24 2009 From: tony.meyer at gmail.com (Tony Meyer) Date: Mon, 16 Nov 2009 08:54:24 +1300 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> Message-ID: <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> Hi, > user = "matan.py at hotmail.com" > pwd = "XXXXXXXX" Just a warning: you included your username and password with your code - you should probably immediately change your password. > server = poplib.POP3_SSL(host) If you start up an IP shell and just do this (and 'import poplib'), does that cause the error as well? If so, then it's definitely a bug - ideally check if it's fixed in IP 2.6, and open a bug report. Cheers, Tony From slide.o.mix at gmail.com Sun Nov 15 23:37:53 2009 From: slide.o.mix at gmail.com (Slide) Date: Sun, 15 Nov 2009 15:37:53 -0700 Subject: [IronPython] Embedding IronPython in MS-Office (fwd) In-Reply-To: References: Message-ID: I think Office is tied to ActiveScripting which is COM based. I am not sure any ActiveScripting language will work either, they may have it tied directly to VBA as was said earlier. On Sun, Nov 15, 2009 at 8:16 AM, Curt Hagenlocher wrote: > VBA is embedded pretty tightly into Word and Excel; there's no way to swap > it out for another scripting engine. > > > On Sun, Nov 15, 2009 at 8:40 AM, Joshua Kramer wrote: > >> >> A while back, Slide wrote: >> >> "You'd have to write an add-in for office that hosted the .NET runtime and >> provided a hosting API that IP could interact with. I don't think this >> would be a small undertaking." >> >> Hmm. Is there any way to have MSO "see" IPY as a Scripting or Macro >> Language, like it sees VBA? I am familiar with writing console (or regular) >> apps in C# and using the Microsoft.Office.Interop assemblies - I could do >> this easily from IronPython but I'd rather it be usable from within the MSO >> environment. >> >> OpenOffice is better in this regard because it "sees" Python, Java, and >> Basic as just different scripting / macro languages, and therefore it's easy >> to write Python apps that EITHER run from within the environment or outside. >> >> Cheers, >> -JK >> >> -- >> >> ----- >> http://www.globalherald.net/jb01 >> GlobalHerald.NET, the Smarter Social Network! (tm) >> _______________________________________________ >> 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 > > -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Mon Nov 16 00:34:43 2009 From: matan504 at gmail.com (matan keret) Date: Mon, 16 Nov 2009 01:34:43 +0200 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> Message-ID: <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> Hi again, > Just a warning: you included your username and password with your code > you should probably immediately change your password. It's OK this is a mail box for testing only so nothing to worry about, there is nothing there :-) > If you start up an IP shell and just do this (and 'import poplib'), > does that cause the error as well? If so, then it's definitely a bug > ideally check if it's fixed in IP 2.6, and open a bug report. You might be surprised but IP 2.6 doesn't support SSL protocols at all :-( :-( and allow me to add one more... :-( Not Imap and not POP3. I ran the code in the IP shell (just import and the problematic line) and it does the same. So I guess it's a bug :-( Will open a bug report. -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony.meyer at gmail.com Mon Nov 16 00:39:03 2009 From: tony.meyer at gmail.com (Tony Meyer) Date: Mon, 16 Nov 2009 12:39:03 +1300 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> Message-ID: <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> > You might be surprised but IP 2.6 doesn't support SSL protocols at all :-( Ah, I'd forgotten about that. It's because of the changes that CPython 2.6 made. My suspicion is that you could use the CPython 2.5 poplib module with IP 2.6, though - it's not that SSL stopped working, it's that the _ssl module isn't in IP 2.6 and the CPython 2.6 poplib was changed to use that rather than the SSL socket method. Cheers, Tony From matan504 at gmail.com Mon Nov 16 00:47:04 2009 From: matan504 at gmail.com (matan keret) Date: Mon, 16 Nov 2009 01:47:04 +0200 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> Message-ID: <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> I tried that as well :-) you are right, the _ssl module is a problem and I don't know how to work around that (don't know that much about py). also tried to use it in IP 2.0.3 but the implementation is different and I'll need to dig much more in that to make it work. Which is not my main goal right now unfortunately. thanks, Matan On Mon, Nov 16, 2009 at 1:39 AM, Tony Meyer wrote: > > You might be surprised but IP 2.6 doesn't support SSL protocols at all > :-( > > Ah, I'd forgotten about that. It's because of the changes that > CPython 2.6 made. My suspicion is that you could use the CPython 2.5 > poplib module with IP 2.6, though - it's not that SSL stopped working, > it's that the _ssl module isn't in IP 2.6 and the CPython 2.6 poplib > was changed to use that rather than the SSL socket method. > > Cheers, > Tony > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony.meyer at gmail.com Mon Nov 16 01:52:39 2009 From: tony.meyer at gmail.com (Tony Meyer) Date: Mon, 16 Nov 2009 13:52:39 +1300 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> Message-ID: <6c63de570911151652g35335dd1v6211ed0947d08260@mail.gmail.com> > you are right, the _ssl module is a problem and I > don't know how to work around that Using the pre-2.6 module would have been the only way to work around it (i.e. work with the old socket methods). Since that doesn't work even in 2.6, then my guess would be that you'll just have to wait until the bug is fixed (unless IMAP or CPython are options). If you haven't already, I encourage you to vote for implementing the _ssl module: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21411&ProjectName=IronPython Cheers, Tony From avinhan at gmail.com Mon Nov 16 08:30:33 2009 From: avinhan at gmail.com (Aravin) Date: Mon, 16 Nov 2009 15:30:33 +0800 Subject: [IronPython] n-dimensional array In-Reply-To: <4AFD4084.5060003@voidspace.org.uk> References: <000001ca6452$0e3b1790$2ab146b0$@com> <4AFD4084.5060003@voidspace.org.uk> Message-ID: <000001ca668e$b2f68510$18e38f30$@com> Thank you Michael for your quick response. I started to write my own implementation of an n-dimensional array. Currently I have only implemented __getitem__. You can pass in slice like in numpy. E.g. >>>from IronMath import ndarray >>>a = ndarray(range(36), (6,6)) >>>print a [[0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16, 17], [18, 19, 20, 21, 22, 23], [24, 25, 26, 27, 28, 29], [30, 31, 32, 33, 34, 35]] >>>b = a[1:5:2, :] >>>print b [[6, 7, 8, 9, 10, 11], [18, 19, 20, 21, 22, 23]] >>>b.Shape (2, 6) >>>b.Shape = (3,4) >>>print b [[6, 7, 8, 9], [10, 11, 18, 19], [20, 21, 22, 23]] >>>c = b[:, [0,2,3]] >>>print c [[6, 8, 9], [10, 18, 19], [20, 22, 23]] Im using a List to hold the values internally. I'm not sure if this is the best possible way in terms of speed. I'm also attaching the source for the ndarray class. Can someone give me some pointers on optimization aspects? Should I make it generic like ndarray? I know this class has a long way to go, but if anyone is interested in it maybe I can set up a project on CodePlex and work on it? It could become a base for a math library for IronPython. Regards, Aravin -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, November 13, 2009 7:18 PM To: Discussion of IronPython Subject: Re: [IronPython] n-dimensional array Aravin wrote: > > Hello everyone, > > I'm developing an application for my research project. I'm using > IronPython as a scripting engine to allow easy data manipulation like > Matlab. I require a high performance n-dimensional array class. Does > anyone know of any .net library which provides a powerful > n-dimensional array? > > I would like to do slicing operations on the array like in NumPy. > (A[:2, :5] etc.) > I doubt you will find a .NET library that supports slicing in the same way as numpy... You might try looking at Math.NET though: http://www.mathdotnet.com/About.aspx > And also things like ones(.) zeros(.). I tried to use NumPy with > Ironclad but im having some issues > Have you reported those issues? All the best, Michael Foord > > and would prefer if I could have a .net/ Ironpython ndarray library. > Can you please recommend me any such library? Thanks > > Aravin > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: ndarray.cs URL: From cenovsky at bakalari.cz Mon Nov 16 11:50:31 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Mon, 16 Nov 2009 11:50:31 +0100 Subject: [IronPython] INotifyPropertyChanged and databinding in Silverlight with IronPython Message-ID: <4B012E77.8070701@bakalari.cz> I have published an article about $subj on http://gui-at.blogspot.com/2009/11/inotifypropertychanged-and-databinding.html -- -- Luk?? From matan504 at gmail.com Mon Nov 16 16:55:16 2009 From: matan504 at gmail.com (matan keret) Date: Mon, 16 Nov 2009 17:55:16 +0200 Subject: [IronPython] Using a struct from OpenMetaverse assembly Message-ID: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> Hi everyone, I'm trying to use the UUID struct from OpenMetaverse assembly (this is C# code) from IronPy 2.0.3. I'm using: asm2 = clr.LoadAssemblyByName(*'OpenMetaverse'*) OpenJPEG = asm2.OpenMetaverse.Imaging.OpenJPEG in order to use OpenJPEG class. this works fine, but when i try to do: UUID = asm2.OpenMetaverse.UUID I get an error that there is no such 'UUID'. also tried: OpenMeta = asm2.OpenMetaverse and calling: OpenMeta.UUID but no luck. to see more about OpenMetaverse and UUID struct (under OpenMetaverse namespace): http://lib.openmetaverse.org/docs/0.7/ any ideas? -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Mon Nov 16 16:58:28 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 16 Nov 2009 15:58:28 +0000 Subject: [IronPython] Using a struct from OpenMetaverse assembly In-Reply-To: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> References: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> Message-ID: <4B0176A4.5060006@voidspace.org.uk> matan keret wrote: > Hi everyone, > > I'm trying to use the UUID struct from OpenMetaverse assembly (this is > C# code) from IronPy 2.0.3. > I'm using: > > asm2 = clr.LoadAssemblyByName(/'OpenMetaverse'/) Out of interest, why not: clr.AddReference('OpenMetaverse') > OpenJPEG = asm2.OpenMetaverse.Imaging.OpenJPEG > > in order to use OpenJPEG class. this works fine, but when i try to do: > > UUID = asm2.OpenMetaverse.UUID > > I get an error that there is no such 'UUID'. > also tried: > > OpenMeta = asm2.OpenMetaverse What is present when you call: dir(OpenMeta) Michael > > and calling: OpenMeta.UUID > but no luck. > > to see more about OpenMetaverse and UUID struct (under OpenMetaverse > namespace): http://lib.openmetaverse.org/docs/0.7/ > > any ideas? > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From matan504 at gmail.com Mon Nov 16 20:10:54 2009 From: matan504 at gmail.com (matan keret) Date: Mon, 16 Nov 2009 21:10:54 +0200 Subject: [IronPython] Using a struct from OpenMetaverse assembly In-Reply-To: <4B0176A4.5060006@voidspace.org.uk> References: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> <4B0176A4.5060006@voidspace.org.uk> Message-ID: <5c1d2b3d0911161110w43f0681ahcbcccddf602f356e@mail.gmail.com> > > Michael Wrote: > Out of interest, why not: > > clr.AddReference('OpenMetaverse') > > > true.. no reason really, i changed it now to use AddReference. What is > the difference by the way? > > OpenMeta = asm2.OpenMetaverse >> >> dir(OpenMeta) >> >> > wasn't familier with that. it gave me: > > dir(OpenMeta): ['AcceptAllCertificatePolicy', 'AccessDeniedReason', 'AccessList', 'AgentFlags', 'AgentManager', 'AgentState', 'AgentThrottle', 'Animations', 'AppearanceManager ', 'AssetCache', 'AssetDownload', 'AssetManager', 'AssetUpload', 'Assets', 'Atta chmentPoint', 'Avatar', 'AvatarGroup', 'AvatarManager', 'BinBVHAnimationReader', 'BitPack', 'BuddyListEntry', 'Bumpiness', 'Caps', 'CapsEventDictionary', 'Chann elType', 'ChatAudibleLevel', 'ChatSessionMember', 'ChatSourceType', 'ChatType', 'ClassifiedAd', 'ClickAction', 'CompressedFlags', 'CoordinateFrame', 'DeRezDesti nation', 'DictionaryChangeCallback', 'DictionaryEventAction', 'DirectoryManager' , 'EffectType', 'EstateAssetType', 'EstateTask', 'EstateTools', 'ExtraParamType' , 'FaceType', 'FieldType', 'FriendInfo', 'FriendRights', 'FriendsManager', 'Gras s', 'GridAgentLocation', 'GridClient', 'GridItem', 'GridItemType', 'GridLayer', 'GridLayerType', 'GridManager', 'GridRegion', 'Group', 'GroupAccountSummary', 'G roupManager', 'GroupMember', 'GroupNotice', 'GroupNoticeList', 'GroupPowers', 'G roupProposal', 'GroupRole', 'GroupRoleUpdate', 'GroupTitle', 'HandPose', 'Helper s', 'HoleType', 'INetworkManager', 'ImageCodec', 'ImageDownload', 'ImageRequest' , 'ImageType', 'Imaging', 'IncomingPacketIDCollection', 'InstantMessage', 'Insta ntMessageDialog', 'InstantMessageOnline', 'Interfaces', 'InternalDictionary', 'I nvalidOutfitException', 'Inventory', 'InventoryAnimation', 'InventoryAttachment' , 'InventoryBase', 'InventoryCallingCard', 'InventoryCategory', 'InventoryExcept ion', 'InventoryFolder', 'InventoryGesture', 'InventoryItem', 'InventoryItemFlag s', 'InventoryLSL', 'InventoryLandmark', 'InventoryManager', 'InventoryNode', 'I nventoryNodeDictionary', 'InventoryNotecard', 'InventoryObject', 'InventorySnaps hot', 'InventorySortOrder', 'InventorySound', 'InventoryTexture', 'InventoryWear able', 'JointType', 'LandingType', 'Logger', 'LoginParams', 'LoginResponseData', 'LoginStatus', 'LookAtType', 'MapBlock', 'MapField', 'MapPacket', 'MappingType' , 'Material', 'MeanCollisionType', 'Messages', 'MoneyTransactionType', 'NameValu e', 'NetworkManager', 'NotConnectedException', 'ObjectCategory', 'ObjectManager' , 'ObjectPoolBase', 'ObjectReturnType', 'ObjectUpdate', 'ObservableDictionary', 'PCode', 'PacketBufferPool', 'PacketEventDictionary', 'PacketFrequency', 'Packet s', 'Parcel', 'ParcelAccessFlags', 'ParcelCategory', 'ParcelFlags', 'ParcelInfo' , 'ParcelManager', 'ParcelMedia', 'ParcelMediaCommand', 'ParcelOverlayType', 'Pa rcelPropertiesStatus', 'ParcelResult', 'ParcelStatus', 'PathCurve', 'PayPriceTyp e', 'PermissionMask', 'PermissionWho', 'Permissions', 'PointAtType', 'Pool', 'Pr imFlags', 'PrimType', 'Primitive', 'ProfileCurve', 'ProfileFlags', 'ProfilePick' , 'ProtocolManager', 'RegionFlags', 'Rendering', 'ReportType', 'ScriptControlCha nge', 'ScriptPermission', 'ScriptSensorTypeFlags', 'SculptType', 'Settings', 'Sh ininess', 'SimAccess', 'Simulator', 'SoundFlags', 'SoundManager', 'SourceType', 'StatusCode', 'TargetType', 'TeleportFlags', 'TeleportLureFlags', 'TeleportStatu s', 'TerraformAction', 'TerraformBrushSize', 'TerrainCompressor', 'TerrainManage r', 'TerrainPatch', 'TextureAttributes', 'TextureDownloadCallback', 'TexturePipe line', 'TextureRequestState', 'TransactionFlags', 'Transfer', 'TransferError', ' Tree', 'UDPBase', 'UDPPacketBuffer', 'UpdateType', 'VPElement', 'VisualParam', ' VisualParams', 'Voice', 'Vote', 'WrappedObject', 'XferDownload', 'binBVHJoint', 'binBVHJointKey'] also available in : http://pastebin.org/54229 as you can see it doesn't include the structures (UUID and others) any ideas why and how can i use that UUID struct? > to see more about OpenMetaverse and UUID struct (under OpenMetaverse >> namespace): http://lib.openmetaverse.org/docs/0.7/ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > Cheers, Matan -------------- next part -------------- An HTML attachment was scrubbed... URL: From mchanner at gmail.com Mon Nov 16 21:32:08 2009 From: mchanner at gmail.com (Matt Channer) Date: Mon, 16 Nov 2009 20:32:08 +0000 Subject: [IronPython] Using a struct from OpenMetaverse assembly In-Reply-To: <5c1d2b3d0911161110w43f0681ahcbcccddf602f356e@mail.gmail.com> References: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> <4B0176A4.5060006@voidspace.org.uk> <5c1d2b3d0911161110w43f0681ahcbcccddf602f356e@mail.gmail.com> Message-ID: <2cf17aed0911161232v3a3a54aapa8e5efbf68278871@mail.gmail.com> Browing the source for this project, it looks like the UUID struct is actually in a different dll - OpenMetaverseTypes.dll. 2009/11/16 matan keret > Michael Wrote: >> Out of interest, why not: >> >> clr.AddReference('OpenMetaverse') >> >> > true.. no reason really, i changed it now to use AddReference. What is >> the difference by the way? >> > > > >> OpenMeta = asm2.OpenMetaverse >>> >>> dir(OpenMeta) >>> >>> > wasn't familier with that. it gave me: >> >> > dir(OpenMeta): > ['AcceptAllCertificatePolicy', 'AccessDeniedReason', 'AccessList', > 'AgentFlags', > 'AgentManager', 'AgentState', 'AgentThrottle', 'Animations', > 'AppearanceManager > ', 'AssetCache', 'AssetDownload', 'AssetManager', 'AssetUpload', 'Assets', > 'Atta > chmentPoint', 'Avatar', 'AvatarGroup', 'AvatarManager', > 'BinBVHAnimationReader', > 'BitPack', 'BuddyListEntry', 'Bumpiness', 'Caps', 'CapsEventDictionary', > 'Chann > elType', 'ChatAudibleLevel', 'ChatSessionMember', 'ChatSourceType', > 'ChatType', > 'ClassifiedAd', 'ClickAction', 'CompressedFlags', 'CoordinateFrame', > 'DeRezDesti > nation', 'DictionaryChangeCallback', 'DictionaryEventAction', > 'DirectoryManager' > , 'EffectType', 'EstateAssetType', 'EstateTask', 'EstateTools', > 'ExtraParamType' > , 'FaceType', 'FieldType', 'FriendInfo', 'FriendRights', 'FriendsManager', > 'Gras > s', 'GridAgentLocation', 'GridClient', 'GridItem', 'GridItemType', > 'GridLayer', > 'GridLayerType', 'GridManager', 'GridRegion', 'Group', > 'GroupAccountSummary', 'G > roupManager', 'GroupMember', 'GroupNotice', 'GroupNoticeList', > 'GroupPowers', 'G > roupProposal', 'GroupRole', 'GroupRoleUpdate', 'GroupTitle', 'HandPose', > 'Helper > s', 'HoleType', 'INetworkManager', 'ImageCodec', 'ImageDownload', > 'ImageRequest' > , 'ImageType', 'Imaging', 'IncomingPacketIDCollection', 'InstantMessage', > 'Insta > ntMessageDialog', 'InstantMessageOnline', 'Interfaces', > 'InternalDictionary', 'I > nvalidOutfitException', 'Inventory', 'InventoryAnimation', > 'InventoryAttachment' > , 'InventoryBase', 'InventoryCallingCard', 'InventoryCategory', > 'InventoryExcept > ion', 'InventoryFolder', 'InventoryGesture', 'InventoryItem', > 'InventoryItemFlag > s', 'InventoryLSL', 'InventoryLandmark', 'InventoryManager', > 'InventoryNode', 'I > nventoryNodeDictionary', 'InventoryNotecard', 'InventoryObject', > 'InventorySnaps > hot', 'InventorySortOrder', 'InventorySound', 'InventoryTexture', > 'InventoryWear > able', 'JointType', 'LandingType', 'Logger', 'LoginParams', > 'LoginResponseData', > 'LoginStatus', 'LookAtType', 'MapBlock', 'MapField', 'MapPacket', > 'MappingType' > , 'Material', 'MeanCollisionType', 'Messages', 'MoneyTransactionType', > 'NameValu > e', 'NetworkManager', 'NotConnectedException', 'ObjectCategory', > 'ObjectManager' > , 'ObjectPoolBase', 'ObjectReturnType', 'ObjectUpdate', > 'ObservableDictionary', > 'PCode', 'PacketBufferPool', 'PacketEventDictionary', 'PacketFrequency', > 'Packet > s', 'Parcel', 'ParcelAccessFlags', 'ParcelCategory', 'ParcelFlags', > 'ParcelInfo' > , 'ParcelManager', 'ParcelMedia', 'ParcelMediaCommand', > 'ParcelOverlayType', 'Pa > rcelPropertiesStatus', 'ParcelResult', 'ParcelStatus', 'PathCurve', > 'PayPriceTyp > e', 'PermissionMask', 'PermissionWho', 'Permissions', 'PointAtType', > 'Pool', 'Pr > imFlags', 'PrimType', 'Primitive', 'ProfileCurve', 'ProfileFlags', > 'ProfilePick' > , 'ProtocolManager', 'RegionFlags', 'Rendering', 'ReportType', > 'ScriptControlCha > nge', 'ScriptPermission', 'ScriptSensorTypeFlags', 'SculptType', > 'Settings', 'Sh > ininess', 'SimAccess', 'Simulator', 'SoundFlags', 'SoundManager', > 'SourceType', > 'StatusCode', 'TargetType', 'TeleportFlags', 'TeleportLureFlags', > 'TeleportStatu > s', 'TerraformAction', 'TerraformBrushSize', 'TerrainCompressor', > 'TerrainManage > r', 'TerrainPatch', 'TextureAttributes', 'TextureDownloadCallback', > 'TexturePipe > line', 'TextureRequestState', 'TransactionFlags', 'Transfer', > 'TransferError', ' > Tree', 'UDPBase', 'UDPPacketBuffer', 'UpdateType', 'VPElement', > 'VisualParam', ' > VisualParams', 'Voice', 'Vote', 'WrappedObject', 'XferDownload', > 'binBVHJoint', > 'binBVHJointKey'] > > also available in : http://pastebin.org/54229 > > as you can see it doesn't include the structures (UUID and others) > any ideas why and how can i use that UUID struct? > > >> to see more about OpenMetaverse and UUID struct (under OpenMetaverse >>> namespace): http://lib.openmetaverse.org/docs/0.7/ >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >> > Cheers, > Matan > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Mon Nov 16 22:05:11 2009 From: matan504 at gmail.com (matan keret) Date: Mon, 16 Nov 2009 23:05:11 +0200 Subject: [IronPython] Using a struct from OpenMetaverse assembly In-Reply-To: <2cf17aed0911161232v3a3a54aapa8e5efbf68278871@mail.gmail.com> References: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> <4B0176A4.5060006@voidspace.org.uk> <5c1d2b3d0911161110w43f0681ahcbcccddf602f356e@mail.gmail.com> <2cf17aed0911161232v3a3a54aapa8e5efbf68278871@mail.gmail.com> Message-ID: <5c1d2b3d0911161305s1478c224t11159049897d7d9f@mail.gmail.com> > > > Browing the source for this project, it looks like the UUID struct is > actually in a different dll - OpenMetaverseTypes.dll. > True!! I didn't notice that... :-S This DLL is located in the same place as OpenMetaverse.dll. So I tried: clr.AddReference(*'OpenMetaverseTypes'*) from OpenMetaverseTypes import UUID but I get an error: No module named -------------- next part -------------- An HTML attachment was scrubbed... URL: From matan504 at gmail.com Mon Nov 16 22:07:28 2009 From: matan504 at gmail.com (matan keret) Date: Mon, 16 Nov 2009 23:07:28 +0200 Subject: [IronPython] Using a struct from OpenMetaverse assembly In-Reply-To: <2cf17aed0911161232v3a3a54aapa8e5efbf68278871@mail.gmail.com> References: <5c1d2b3d0911160755p56cf62bbif43a85e29ece8867@mail.gmail.com> <4B0176A4.5060006@voidspace.org.uk> <5c1d2b3d0911161110w43f0681ahcbcccddf602f356e@mail.gmail.com> <2cf17aed0911161232v3a3a54aapa8e5efbf68278871@mail.gmail.com> Message-ID: <5c1d2b3d0911161307s743d494cqac2ff4fe126f2ff7@mail.gmail.com> I'm sorry.. ignore that last post it was sent by accident. it is working well now :) thank you all! Matan On Mon, Nov 16, 2009 at 10:32 PM, Matt Channer wrote: > Browing the source for this project, it looks like the UUID struct is > actually in a different dll - OpenMetaverseTypes.dll. > > > > 2009/11/16 matan keret > > Michael Wrote: >>> Out of interest, why not: >>> >>> clr.AddReference('OpenMetaverse') >>> >>> > true.. no reason really, i changed it now to use AddReference. What is >>> the difference by the way? >>> >> >> >> >>> OpenMeta = asm2.OpenMetaverse >>>> >>>> dir(OpenMeta) >>>> >>>> > wasn't familier with that. it gave me: >>> >>> >> dir(OpenMeta): >> ['AcceptAllCertificatePolicy', 'AccessDeniedReason', 'AccessList', >> 'AgentFlags', >> 'AgentManager', 'AgentState', 'AgentThrottle', 'Animations', >> 'AppearanceManager >> ', 'AssetCache', 'AssetDownload', 'AssetManager', 'AssetUpload', 'Assets', >> 'Atta >> chmentPoint', 'Avatar', 'AvatarGroup', 'AvatarManager', >> 'BinBVHAnimationReader', >> 'BitPack', 'BuddyListEntry', 'Bumpiness', 'Caps', 'CapsEventDictionary', >> 'Chann >> elType', 'ChatAudibleLevel', 'ChatSessionMember', 'ChatSourceType', >> 'ChatType', >> 'ClassifiedAd', 'ClickAction', 'CompressedFlags', 'CoordinateFrame', >> 'DeRezDesti >> nation', 'DictionaryChangeCallback', 'DictionaryEventAction', >> 'DirectoryManager' >> , 'EffectType', 'EstateAssetType', 'EstateTask', 'EstateTools', >> 'ExtraParamType' >> , 'FaceType', 'FieldType', 'FriendInfo', 'FriendRights', 'FriendsManager', >> 'Gras >> s', 'GridAgentLocation', 'GridClient', 'GridItem', 'GridItemType', >> 'GridLayer', >> 'GridLayerType', 'GridManager', 'GridRegion', 'Group', >> 'GroupAccountSummary', 'G >> roupManager', 'GroupMember', 'GroupNotice', 'GroupNoticeList', >> 'GroupPowers', 'G >> roupProposal', 'GroupRole', 'GroupRoleUpdate', 'GroupTitle', 'HandPose', >> 'Helper >> s', 'HoleType', 'INetworkManager', 'ImageCodec', 'ImageDownload', >> 'ImageRequest' >> , 'ImageType', 'Imaging', 'IncomingPacketIDCollection', 'InstantMessage', >> 'Insta >> ntMessageDialog', 'InstantMessageOnline', 'Interfaces', >> 'InternalDictionary', 'I >> nvalidOutfitException', 'Inventory', 'InventoryAnimation', >> 'InventoryAttachment' >> , 'InventoryBase', 'InventoryCallingCard', 'InventoryCategory', >> 'InventoryExcept >> ion', 'InventoryFolder', 'InventoryGesture', 'InventoryItem', >> 'InventoryItemFlag >> s', 'InventoryLSL', 'InventoryLandmark', 'InventoryManager', >> 'InventoryNode', 'I >> nventoryNodeDictionary', 'InventoryNotecard', 'InventoryObject', >> 'InventorySnaps >> hot', 'InventorySortOrder', 'InventorySound', 'InventoryTexture', >> 'InventoryWear >> able', 'JointType', 'LandingType', 'Logger', 'LoginParams', >> 'LoginResponseData', >> 'LoginStatus', 'LookAtType', 'MapBlock', 'MapField', 'MapPacket', >> 'MappingType' >> , 'Material', 'MeanCollisionType', 'Messages', 'MoneyTransactionType', >> 'NameValu >> e', 'NetworkManager', 'NotConnectedException', 'ObjectCategory', >> 'ObjectManager' >> , 'ObjectPoolBase', 'ObjectReturnType', 'ObjectUpdate', >> 'ObservableDictionary', >> 'PCode', 'PacketBufferPool', 'PacketEventDictionary', 'PacketFrequency', >> 'Packet >> s', 'Parcel', 'ParcelAccessFlags', 'ParcelCategory', 'ParcelFlags', >> 'ParcelInfo' >> , 'ParcelManager', 'ParcelMedia', 'ParcelMediaCommand', >> 'ParcelOverlayType', 'Pa >> rcelPropertiesStatus', 'ParcelResult', 'ParcelStatus', 'PathCurve', >> 'PayPriceTyp >> e', 'PermissionMask', 'PermissionWho', 'Permissions', 'PointAtType', >> 'Pool', 'Pr >> imFlags', 'PrimType', 'Primitive', 'ProfileCurve', 'ProfileFlags', >> 'ProfilePick' >> , 'ProtocolManager', 'RegionFlags', 'Rendering', 'ReportType', >> 'ScriptControlCha >> nge', 'ScriptPermission', 'ScriptSensorTypeFlags', 'SculptType', >> 'Settings', 'Sh >> ininess', 'SimAccess', 'Simulator', 'SoundFlags', 'SoundManager', >> 'SourceType', >> 'StatusCode', 'TargetType', 'TeleportFlags', 'TeleportLureFlags', >> 'TeleportStatu >> s', 'TerraformAction', 'TerraformBrushSize', 'TerrainCompressor', >> 'TerrainManage >> r', 'TerrainPatch', 'TextureAttributes', 'TextureDownloadCallback', >> 'TexturePipe >> line', 'TextureRequestState', 'TransactionFlags', 'Transfer', >> 'TransferError', ' >> Tree', 'UDPBase', 'UDPPacketBuffer', 'UpdateType', 'VPElement', >> 'VisualParam', ' >> VisualParams', 'Voice', 'Vote', 'WrappedObject', 'XferDownload', >> 'binBVHJoint', >> 'binBVHJointKey'] >> >> also available in : http://pastebin.org/54229 >> >> as you can see it doesn't include the structures (UUID and others) >> any ideas why and how can i use that UUID struct? >> >> >>> to see more about OpenMetaverse and UUID struct (under OpenMetaverse >>>> namespace): http://lib.openmetaverse.org/docs/0.7/ >>>> >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>>> >>> >> Cheers, >> Matan >> >> _______________________________________________ >> 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From antont at kyperjokki.fi Tue Nov 17 08:13:07 2009 From: antont at kyperjokki.fi (Toni Alatalo) Date: Tue, 17 Nov 2009 09:13:07 +0200 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> Message-ID: <4B024D03.7050900@kyperjokki.fi> matan keret kirjoitti: > I tried that as well :-) you are right, the _ssl module is a problem > and I don't know how to work around that (don't know that much What was the prob with py 2.5 poplib with ip 2.6? Might be something simple.. How about using some .net lib for this directly? As a workaround while is broken in ipy at least. > Matan ~Toni > On Mon, Nov 16, 2009 at 1:39 AM, Tony Meyer > wrote: > > > You might be surprised but IP 2.6 doesn't support SSL protocols > at all :-( > > Ah, I'd forgotten about that. It's because of the changes that > CPython 2.6 made. My suspicion is that you could use the CPython 2.5 > poplib module with IP 2.6, though - it's not that SSL stopped working, > it's that the _ssl module isn't in IP 2.6 and the CPython 2.6 poplib > was changed to use that rather than the SSL socket method. > > Cheers, > Tony > _______________________________________________ > 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 > From tony.meyer at gmail.com Tue Nov 17 08:39:00 2009 From: tony.meyer at gmail.com (Tony Meyer) Date: Tue, 17 Nov 2009 20:39:00 +1300 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <4B024D03.7050900@kyperjokki.fi> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> <4B024D03.7050900@kyperjokki.fi> Message-ID: <6c63de570911162339t501ef32al6b2a9dc4d23b80d1@mail.gmail.com> > What was the prob with py 2.5 poplib with ip 2.6? Might be something > simple.. When I tried it, I got the same error as the OP did with the 2.5 poplib and IP 2.0. > How about using some .net lib for this directly? As a workaround while is > broken in ipy at least. Yes, that's a good suggestion. Matan, you could try the libraries suggested here: http://stackoverflow.com/questions/44383/reading-email-using-pop3-in-c Cheers, Tony From matan504 at gmail.com Tue Nov 17 10:53:33 2009 From: matan504 at gmail.com (matan keret) Date: Tue, 17 Nov 2009 11:53:33 +0200 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <6c63de570911162339t501ef32al6b2a9dc4d23b80d1@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> <6c63de570911151154l15225c29v67f912e9cc3c2767@mail.gmail.com> <5c1d2b3d0911151534p67eac5c8raf8fbaaab49021b1@mail.gmail.com> <6c63de570911151539k1ffab8bv48fad43257e3b39@mail.gmail.com> <5c1d2b3d0911151547w18655b47m52d6a231373140c2@mail.gmail.com> <4B024D03.7050900@kyperjokki.fi> <6c63de570911162339t501ef32al6b2a9dc4d23b80d1@mail.gmail.com> Message-ID: <5c1d2b3d0911170153p1b033c2fn61f5f73d3da6075c@mail.gmail.com> Toni and Tony, thank you for the suggestions :-) it seems for now that i can manage to do what i want with the Imap lib. so I'm gonna leave this bug for now. cheers, Matan On Tue, Nov 17, 2009 at 9:39 AM, Tony Meyer wrote: > > What was the prob with py 2.5 poplib with ip 2.6? Might be something > > simple.. > > When I tried it, I got the same error as the OP did with the 2.5 > poplib and IP 2.0. > > > How about using some .net lib for this directly? As a workaround while is > > broken in ipy at least. > > Yes, that's a good suggestion. Matan, you could try the libraries > suggested here: > http://stackoverflow.com/questions/44383/reading-email-using-pop3-in-c > > Cheers, > Tony > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cenovsky at bakalari.cz Tue Nov 17 13:15:09 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Tue, 17 Nov 2009 13:15:09 +0100 Subject: [IronPython] WCF Service in pure IronPython Message-ID: <4B0293CD.1000203@bakalari.cz> The latest version of clrtype.py has support for ClrInterface metaclass - see the usage on my blog: http://gui-at.blogspot.com/2009/11/wcf-service-in-pure-ironpython.html -- -- Luk?? From merllab at microsoft.com Tue Nov 17 17:53:03 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Tue, 17 Nov 2009 08:53:03 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <0d943a8f-8ff3-44ec-bc27-e37664ab85cc@tk5-exsmh-c102.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61477. MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/init.rb $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicScriptTags.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/BrowserVirtualFilesystem.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicEngine.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Chiron/App.config $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/ErrorFormatter.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicApplication.cs $/IronPython/IronPython_Main/Src/Tests/modules/io_related/codecs_test.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/re_test.py $/IronPython/IronPython_Main/Src/Tests/modules/system_related/nt_test.py $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/XamlScriptTags.cs $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Repl.cs $/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleFlags.ps1 $/IronPython/IronPython_Main/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Microsoft.Scripting.Silverlight.csproj $/IronPython/IronPython_Main/Src/Tests/regressions.py $/IronPython/IronPython_Main/Src/Tests/test_stdmodules.py $/IronPython/IronPython_Main/Src/Tests/test_list.py $/IronPython/IronPython_Main/Src/Tests/test_help.py $/IronPython/IronPython_Main/Src/Tests/test_bigint.py $/IronPython/IronPython_Main/Src/Tests/test_superconsole.py $/IronPython/IronPython_Main/Src/Tests/test_unicode.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1273643 Date: 11/16/2009 12:54:44 PM The upgrade to PowerShell 2.0 broke Modes\ConsoleFlags.ps1 in a number of ways. Fixed Reorganized VSMDI - moved more network-based tests into the "specialized" test category. Fixed installation of the DLR COM test library under Windows 7 machines. (Shelveset: CP80;REDMOND\dfugate | SNAP CheckinId: 9840) -------------------------------------------------------------------------------- Changeset Id: 1273466 Date: 11/16/2009 10:41:14 AM (CPy) test_marshal.py - CP20909 partially fixed (CPy) test_unicode_file.py - CP8784 fixed regressions.py: - CP18912 is fixed - CP19789 is fixed - CP24573 is fixed - CP24802 is fixed test_bigint.py - refactored and added a regression for long("") test_help.py - CP11883 is fixed test_list.py - CP20125 is fixed test_stdmodules.py - CP20162 is still broken test_superconsole.py - re-enabled a regression for CP12403. Fixed test_unicode.py - CP19005 is fixed ConsoleFlags.ps1 - updated to work under PowerShell 2.0 codecs_test.py - added regression test re_test.py - CP6277 is fixed nt_test.py - CP19310 and CP8784 are fixed Moved test_stdmodules.py to "specialized" poolset (this test depends on URLs). (Shelveset: CP79;REDMOND\dfugate | SNAP CheckinId: 9839) From jhoward at drawloop.com Tue Nov 17 23:02:00 2009 From: jhoward at drawloop.com (jhoward at drawloop.com) Date: Tue, 17 Nov 2009 14:02:00 -0800 (PST) Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: References: Message-ID: <89dd096a-a40c-45cb-94c3-e996c4fda673@k13g2000prh.googlegroups.com> I realize I'm replying rather late, but I just got to trying this again. This is something that really should be simple. Anytime a module is run from the ScriptEngine directly, I would expect the behavior to be running as "__main__" just as if I was running it from the command line using "ipy" or "python". Unfortunately, trying to create a module directly doesn't work as far as naming the module. Using the following code: PythonModule pm = new PythonModule(); ScriptEngine se = Python.CreateEngine(); PythonContext pc = (PythonContext) HostingHelpers.GetLanguageContext(se); pc.PublishModule("__main__", pm); ScriptScope ss = HostingHelpers.CreateScriptScope(se, new Microsoft.Scripting.Runtime.Scope(pm.Get__dict__())); ss.SetVariable("__name__", "__main__"); ss.SetVariable("__doc__", ""); doesn't work. There's no way to directly get the Scope from the PythonModule when working this way, as it's been marked as internal. Looking through the debugger, the _scope variable that actually holds the scope on the PythonModule object is null. I believe the old CreateModule way of doing this would have worked, but there's no way to that I've found to do this now. At this point, I'm really not sure how 2.6 is being marked as a release candidate. On an unrelated note, I could, in IronPython 1.1.2 do the following code: _pyEngine.Execute("python code", _pyEngine.DefaultModule, args); where "args" is a Dictionary and have those arguments passed in to a function call or the like. Is there any way to do this using the new hosting engine? Thanks again. On Nov 6, 2:18?pm, Curt Hagenlocher wrote: > It looks like you can just create the PythonModule directly now -- it's a > public class with a public constructor. > > On Thu, Nov 5, 2009 at 12:14 PM, Jonathan Howard wrote: > > > Thanks for the help, Curt. ?Perhaps it's a problem with the latest, RC? > > ?There is no "CreateModule" function on the PythonContext object. > > > ~Jonathan > > > _______________________________________________ > > Users mailing list > > Us... at lists.ironpython.com > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at microsoft.com Tue Nov 17 23:12:16 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 17 Nov 2009 22:12:16 +0000 Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: <89dd096a-a40c-45cb-94c3-e996c4fda673@k13g2000prh.googlegroups.com> References: <89dd096a-a40c-45cb-94c3-e996c4fda673@k13g2000prh.googlegroups.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04CBCD7F@TK5EX14MBXC118.redmond.corp.microsoft.com> I think you now want to do: PythonModule pm = new PythonModule(); ScriptEngine se = Python.CreateEngine(); PythonContext pc = (PythonContext) HostingHelpers.GetLanguageContext(se); pc.PublishModule("__main__", pm); var modContext = new ModuleContext(pm, pc); ScriptScope ss = HostingHelpers.CreateScriptScope(se, modContext.GlobalScope); ss.SetVariable("__name__", "__ main__"); ss.SetVariable("__doc__", ""); The change here is to create a ModuleContext which will let you then get the Scope. I agree this has gotten worse in 2.6 - I opened a bug a while ago to make working with modules easier - http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25190. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of jhoward at drawloop.com > Sent: Tuesday, November 17, 2009 2:02 PM > To: users at lists.ironpython.com > Subject: Re: [IronPython] Embedded IronPython 2.6 Module Name > > I realize I'm replying rather late, but I just got to trying this > again. This is something that really should be simple. Anytime a > module is run from the ScriptEngine directly, I would expect the > behavior to be running as "__main__" just as if I was running it from > the command line using "ipy" or "python". Unfortunately, trying to > create a module directly doesn't work as far as naming the module. > Using the following code: > > PythonModule pm = new PythonModule(); > ScriptEngine se = Python.CreateEngine(); > PythonContext pc = (PythonContext) > HostingHelpers.GetLanguageContext(se); > pc.PublishModule("__main__", pm); > ScriptScope ss = HostingHelpers.CreateScriptScope(se, new > Microsoft.Scripting.Runtime.Scope(pm.Get__dict__())); > ss.SetVariable("__name__", "__main__"); > ss.SetVariable("__doc__", ""); > > doesn't work. There's no way to directly get the Scope from the > PythonModule when working this way, as it's been marked as internal. > Looking through the debugger, the _scope variable that actually holds > the scope on the PythonModule object is null. I believe the old > CreateModule way of doing this would have worked, but there's no way > to that I've found to do this now. > > At this point, I'm really not sure how 2.6 is being marked as a > release candidate. > > On an unrelated note, I could, in IronPython 1.1.2 do the following > code: > > _pyEngine.Execute("python code", _pyEngine.DefaultModule, > args); > > where "args" is a Dictionary and have those arguments > passed in to a function call or the like. Is there any way to do this > using the new hosting engine? > > Thanks again. > > > On Nov 6, 2:18?pm, Curt Hagenlocher wrote: > > It looks like you can just create the PythonModule directly now -- > it's a > > public class with a public constructor. > > > > On Thu, Nov 5, 2009 at 12:14 PM, Jonathan Howard > wrote: > > > > > Thanks for the help, Curt. ?Perhaps it's a problem with the latest, > RC? > > > ?There is no "CreateModule" function on the PythonContext object. > > > > > ~Jonathan > > > > > _______________________________________________ > > > Users mailing list > > > Us... at lists.ironpython.com > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > > _______________________________________________ > > Users mailing list > > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/user > s-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jhoward at drawloop.com Tue Nov 17 23:26:01 2009 From: jhoward at drawloop.com (jhoward at drawloop.com) Date: Tue, 17 Nov 2009 14:26:01 -0800 (PST) Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04CBCD7F@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <89dd096a-a40c-45cb-94c3-e996c4fda673@k13g2000prh.googlegroups.com> <1A472770E042064698CB5ADC83A12ACD04CBCD7F@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <88d65d12-6aa5-4f48-8d3c-0403519d8a5a@a39g2000pre.googlegroups.com> Thanks, that gives me at least something. Any idea why: ss.Engine.Execute("__name__", ss); returns "" but: ss.Engine.CreateScriptSourceFromString("__name__", SourceCodeKind.Expression).Execute(ss); returns "__main__"? On Nov 17, 2:12?pm, Dino Viehland wrote: > I think you now want to do: > > ? ? ? ? ? ? ? PythonModule pm = new PythonModule(); > ? ? ? ? ? ? ScriptEngine se = Python.CreateEngine(); > ? ? ? ? ? ? PythonContext pc = (PythonContext) HostingHelpers.GetLanguageContext(se); > ? ? ? ? ? ? pc.PublishModule("__main__", pm); > > ? ? ? ? ? ? ? var modContext = new ModuleContext(pm, pc); > > ? ? ? ? ? ? ScriptScope ss = HostingHelpers.CreateScriptScope(se, modContext.GlobalScope); > ? ? ? ? ? ? ss.SetVariable("__name__", "__ main__"); > ? ? ? ? ? ? ss.SetVariable("__doc__", ""); > > The change here is to create a ModuleContext which will let you then get the Scope. > > I agree this has gotten worse in 2.6 - I opened a bug a while ago to make working with > modules easier -http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25190. > > > > > -----Original Message----- > > From: users-boun... at lists.ironpython.com [mailto:users- > > boun... at lists.ironpython.com] On Behalf Of jhow... at drawloop.com > > Sent: Tuesday, November 17, 2009 2:02 PM > > To: us... at lists.ironpython.com > > Subject: Re: [IronPython] Embedded IronPython 2.6 Module Name > > > I realize I'm replying rather late, but I just got to trying this > > again. ?This is something that really should be simple. ?Anytime a > > module is run from the ScriptEngine directly, I would expect the > > behavior to be running as "__main__" just as if I was running it from > > the command line using "ipy" or "python". ?Unfortunately, trying to > > create a module directly doesn't work as far as naming the module. > > Using the following code: > > > ? ? ? ? ? ? PythonModule pm = new PythonModule(); > > ? ? ? ? ? ? ScriptEngine se = Python.CreateEngine(); > > ? ? ? ? ? ? PythonContext pc = (PythonContext) > > HostingHelpers.GetLanguageContext(se); > > ? ? ? ? ? ? pc.PublishModule("__main__", pm); > > ? ? ? ? ? ? ScriptScope ss = HostingHelpers.CreateScriptScope(se, new > > Microsoft.Scripting.Runtime.Scope(pm.Get__dict__())); > > ? ? ? ? ? ? ss.SetVariable("__name__", "__main__"); > > ? ? ? ? ? ? ss.SetVariable("__doc__", ""); > > > doesn't work. ?There's no way to directly get the Scope from the > > PythonModule when working this way, as it's been marked as internal. > > Looking through the debugger, the _scope variable that actually holds > > the scope on the PythonModule object is null. ?I believe the old > > CreateModule way of doing this would have worked, but there's no way > > to that I've found to do this now. > > > At this point, I'm really not sure how 2.6 is being marked as a > > release candidate. > > > On an unrelated note, I could, in IronPython 1.1.2 do the following > > code: > > > ? ? ? ? ? ? _pyEngine.Execute("python code", _pyEngine.DefaultModule, > > args); > > > where "args" is a Dictionary and have those arguments > > passed in to a function call or the like. ?Is there any way to do this > > using the new hosting engine? > > > Thanks again. > > > On Nov 6, 2:18?pm, Curt Hagenlocher wrote: > > > It looks like you can just create the PythonModule directly now -- > > it's a > > > public class with a public constructor. > > > > On Thu, Nov 5, 2009 at 12:14 PM, Jonathan Howard > > wrote: > > > > > Thanks for the help, Curt. ?Perhaps it's a problem with the latest, > > RC? > > > > ?There is no "CreateModule" function on the PythonContext object. > > > > > ~Jonathan > > > > > _______________________________________________ > > > > Users mailing list > > > > Us... at lists.ironpython.com > > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > > > Users mailing list > > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/user > > s-ironpython.com > > _______________________________________________ > > Users mailing list > > Us... at lists.ironpython.com > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jhoward at drawloop.com Tue Nov 17 23:31:28 2009 From: jhoward at drawloop.com (jhoward at drawloop.com) Date: Tue, 17 Nov 2009 14:31:28 -0800 (PST) Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: <88d65d12-6aa5-4f48-8d3c-0403519d8a5a@a39g2000pre.googlegroups.com> References: <89dd096a-a40c-45cb-94c3-e996c4fda673@k13g2000prh.googlegroups.com> <1A472770E042064698CB5ADC83A12ACD04CBCD7F@TK5EX14MBXC118.redmond.corp.microsoft.com> <88d65d12-6aa5-4f48-8d3c-0403519d8a5a@a39g2000pre.googlegroups.com> Message-ID: <487874cf-d83f-460e-81cf-1d9a13e58a22@b25g2000prb.googlegroups.com> More specifically, there seems to be four easy ways to execute a string of python code. The following code has the output listed below: Console.WriteLine(ss.Engine.CreateScriptSourceFromString ("__name__", SourceCodeKind.Expression).Execute(ss)); Console.WriteLine(ss.Engine.CreateScriptSourceFromString ("__name__", SourceCodeKind.Expression).Execute()); Console.WriteLine(ss.Engine.Execute("__name__")); Console.WriteLine(ss.Engine.Execute("__name__", ss)); Output: __main__ __builtin__ On Nov 17, 2:26?pm, "jhow... at drawloop.com" wrote: > Thanks, that gives me at least something. ?Any idea why: > > ? ? ss.Engine.Execute("__name__", ss); > > returns "" but: > > ? ? ss.Engine.CreateScriptSourceFromString("__name__", > SourceCodeKind.Expression).Execute(ss); > > returns "__main__"? > > On Nov 17, 2:12?pm, Dino Viehland wrote: > > > I think you now want to do: > > > ? ? ? ? ? ? ? PythonModule pm = new PythonModule(); > > ? ? ? ? ? ? ScriptEngine se = Python.CreateEngine(); > > ? ? ? ? ? ? PythonContext pc = (PythonContext) HostingHelpers.GetLanguageContext(se); > > ? ? ? ? ? ? pc.PublishModule("__main__", pm); > > > ? ? ? ? ? ? ? var modContext = new ModuleContext(pm, pc); > > > ? ? ? ? ? ? ScriptScope ss = HostingHelpers.CreateScriptScope(se, modContext.GlobalScope); > > ? ? ? ? ? ? ss.SetVariable("__name__", "__ main__"); > > ? ? ? ? ? ? ss.SetVariable("__doc__", ""); > > > The change here is to create a ModuleContext which will let you then get the Scope. > > > I agree this has gotten worse in 2.6 - I opened a bug a while ago to make working with > > modules easier -http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25190. > > > > -----Original Message----- > > > From: users-boun... at lists.ironpython.com [mailto:users- > > > boun... at lists.ironpython.com] On Behalf Of jhow... at drawloop.com > > > Sent: Tuesday, November 17, 2009 2:02 PM > > > To: us... at lists.ironpython.com > > > Subject: Re: [IronPython] Embedded IronPython 2.6 Module Name > > > > I realize I'm replying rather late, but I just got to trying this > > > again. ?This is something that really should be simple. ?Anytime a > > > module is run from the ScriptEngine directly, I would expect the > > > behavior to be running as "__main__" just as if I was running it from > > > the command line using "ipy" or "python". ?Unfortunately, trying to > > > create a module directly doesn't work as far as naming the module. > > > Using the following code: > > > > ? ? ? ? ? ? PythonModule pm = new PythonModule(); > > > ? ? ? ? ? ? ScriptEngine se = Python.CreateEngine(); > > > ? ? ? ? ? ? PythonContext pc = (PythonContext) > > > HostingHelpers.GetLanguageContext(se); > > > ? ? ? ? ? ? pc.PublishModule("__main__", pm); > > > ? ? ? ? ? ? ScriptScope ss = HostingHelpers.CreateScriptScope(se, new > > > Microsoft.Scripting.Runtime.Scope(pm.Get__dict__())); > > > ? ? ? ? ? ? ss.SetVariable("__name__", "__main__"); > > > ? ? ? ? ? ? ss.SetVariable("__doc__", ""); > > > > doesn't work. ?There's no way to directly get the Scope from the > > > PythonModule when working this way, as it's been marked as internal. > > > Looking through the debugger, the _scope variable that actually holds > > > the scope on the PythonModule object is null. ?I believe the old > > > CreateModule way of doing this would have worked, but there's no way > > > to that I've found to do this now. > > > > At this point, I'm really not sure how 2.6 is being marked as a > > > release candidate. > > > > On an unrelated note, I could, in IronPython 1.1.2 do the following > > > code: > > > > ? ? ? ? ? ? _pyEngine.Execute("python code", _pyEngine.DefaultModule, > > > args); > > > > where "args" is a Dictionary and have those arguments > > > passed in to a function call or the like. ?Is there any way to do this > > > using the new hosting engine? > > > > Thanks again. > > > > On Nov 6, 2:18?pm, Curt Hagenlocher wrote: > > > > It looks like you can just create the PythonModule directly now -- > > > it's a > > > > public class with a public constructor. > > > > > On Thu, Nov 5, 2009 at 12:14 PM, Jonathan Howard > > > wrote: > > > > > > Thanks for the help, Curt. ?Perhaps it's a problem with the latest, > > > RC? > > > > > ?There is no "CreateModule" function on the PythonContext object. > > > > > > ~Jonathan > > > > > > _______________________________________________ > > > > > Users mailing list > > > > > Us... at lists.ironpython.com > > > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > _______________________________________________ > > > > Users mailing list > > > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/user > > > s-ironpython.com > > > _______________________________________________ > > > Users mailing list > > > Us... at lists.ironpython.com > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > _______________________________________________ > > Users mailing list > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From merllab at microsoft.com Wed Nov 18 17:52:21 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Wed, 18 Nov 2009 08:52:21 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61563. MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Tests/modules/io_related/re_test.py $/IronPython/IronPython_Main/Src/Tests/modules/misc/_warnings_test.py $/IronPython/IronPython_Main/Src/Tests/interop/net/derivation/test_method_override.py $/IronPython/IronPython_Main/Src/IronPython/Lib/iptest/assert_util.py $/IronPython/IronPython_Main/Src/Tests/ClrAssembly/Src/baseclasscs.cs $/IronPython/IronPython_Main/Src/Tests/test_class.py $/IronPython/IronPython_Main/Src/Tests/test_ipye.py $/IronPython/IronPython_Main/Src/Tests/test_importpkg.py $/IronPython/IronPython_Main/Src/Tests/test_generator.py $/IronPython/IronPython_Main/Src/Tests/test_complex.py $/IronPython/IronPython_Main/Src/Tests/test_stdmodules.py $/IronPython/IronPython_Main/Src/Tests/test_str.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1276299 Date: 11/17/2009 4:51:37 PM Defining a typed property with clrtype.py now uses the @property syntax which is more Pythonic, and can also expresses more information like actually wrapping getter and setter methods instead of just getting and setting an implicit field. In the future, you could have separate custom attributes and accessibilities for the getter and setter. Emit parameter names for parameters in the strongly-typed methods - needed by WCF Silverlight workaround for interface definitions - calling functions on AppDomain requires the workaround The typed constructors we were adding were incorect. They needed to implicitly pass the PythonType to the base type's constructor Adds clrtype.propagate_attributes to copy information needed by clrtype from a function to a wrapping function object (Shelveset: clrtype;REDMOND\sborde | SNAP CheckinId: 9854) -------------------------------------------------------------------------------- Changeset Id: 1275884 Date: 11/17/2009 1:27:41 PM test_generator.py - added regression for CP24031 test_method_override.py and baseclasscs.cs - added regression involving overriding protected virtual methods _warnings_test.py - CP24299 for due to a test setup issue. Removed (Shelveset: CP82;REDMOND\dfugate | SNAP CheckinId: 9852) -------------------------------------------------------------------------------- Changeset Id: 1275768 Date: 11/17/2009 12:04:13 PM (CPy) test_grammar.py - 159456 is fixed (CPy) test_wsgiref.py - 151031 is fixed iptest.assert_util - added a helper function to attempt to force a gc collect test_class.py - added regressions for CP22832 and CP23564 text_complex.py - CP21921 is still broken test_ipye.py - CP20594 is "fixed"? test_stdmodules.py - CP20603 is fixed test_str.py - extended a regression for CP21947 => not fixed re_test.py - renamed bug 827 to CP23668. Partially fixed (Shelveset: CP81;REDMOND\dfugate | SNAP CheckinId: 9851) From william.clifford.mit at gmail.com Wed Nov 18 19:27:02 2009 From: william.clifford.mit at gmail.com (William Clifford) Date: Wed, 18 Nov 2009 13:27:02 -0500 Subject: [IronPython] Ability to use CPython csv module Message-ID: <20bb19270911181027l476efe5bq289a3851296df93c@mail.gmail.com> Just curious if anyone has been able to get the CPython csv module to work with IronPython (2.6 rc2)? I use csv regularly for my regular python scripts, and I am exploring the ability to switch over to IronPython, simply for the ability to put together decent GUIs. Not being able to use it throws a major monkey wrench into the works. I have tried doing the following: C:> set IRONPYTHONPATH=C:\Python26\Lib C:> ipy IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.3603 Type "help", "copyright", "credits" or "license" for more information. >>> import csv Traceback (most recent call last): File "", line 1, in File "C:\Python26\Lib\csv.py", line 8, in C:\Python26\Lib\csv.py ImportError: No module named _csv >>> Same thing happens with the bsddb module. Now I have looked for anything named _csv.* in my python installation and have not found anything like _csv.pyd, _csv.dll, etc, so I am assuming that it is not something that should be in the PATH / PYTHONPATH / IRONPYTHONPATH folder(s). Anyone have any idea how to get this to work? Is it something that is simply not supported by IronPython? Thanks in advance -- William M. Clifford, M.I.T. william.clifford.mit at gmail.com Mobile: 954-347-8037 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Wed Nov 18 19:32:13 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 18 Nov 2009 18:32:13 +0000 Subject: [IronPython] Ability to use CPython csv module In-Reply-To: <20bb19270911181027l476efe5bq289a3851296df93c@mail.gmail.com> References: <20bb19270911181027l476efe5bq289a3851296df93c@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04CC67CE@TK5EX14MBXC118.redmond.corp.microsoft.com> You could try using CPython's _csv w/ IronClad but other than that we still need to implement _csv. If you, or anyone else, would like to see us hurry up and implement this http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=21395 is the bug to vote for. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of William Clifford Sent: Wednesday, November 18, 2009 10:27 AM To: users at lists.ironpython.com Subject: [IronPython] Ability to use CPython csv module Just curious if anyone has been able to get the CPython csv module to work with IronPython (2.6 rc2)? I use csv regularly for my regular python scripts, and I am exploring the ability to switch over to IronPython, simply for the ability to put together decent GUIs. Not being able to use it throws a major monkey wrench into the works. I have tried doing the following: C:> set IRONPYTHONPATH=C:\Python26\Lib C:> ipy IronPython 2.6 (2.6.10920.0) on .NET 2.0.50727.3603 Type "help", "copyright", "credits" or "license" for more information. >>> import csv Traceback (most recent call last): File "", line 1, in File "C:\Python26\Lib\csv.py", line 8, in C:\Python26\Lib\csv.py ImportError: No module named _csv >>> Same thing happens with the bsddb module. Now I have looked for anything named _csv.* in my python installation and have not found anything like _csv.pyd, _csv.dll, etc, so I am assuming that it is not something that should be in the PATH / PYTHONPATH / IRONPYTHONPATH folder(s). Anyone have any idea how to get this to work? Is it something that is simply not supported by IronPython? Thanks in advance -- William M. Clifford, M.I.T. william.clifford.mit at gmail.com Mobile: 954-347-8037 -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Wed Nov 18 19:44:06 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 18 Nov 2009 18:44:06 +0000 Subject: [IronPython] Embedded IronPython 2.6 Module Name In-Reply-To: <487874cf-d83f-460e-81cf-1d9a13e58a22@b25g2000prb.googlegroups.com> References: <89dd096a-a40c-45cb-94c3-e996c4fda673@k13g2000prh.googlegroups.com> <1A472770E042064698CB5ADC83A12ACD04CBCD7F@TK5EX14MBXC118.redmond.corp.microsoft.com> <88d65d12-6aa5-4f48-8d3c-0403519d8a5a@a39g2000pre.googlegroups.com> <487874cf-d83f-460e-81cf-1d9a13e58a22@b25g2000prb.googlegroups.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04CC68DD@TK5EX14MBXC118.redmond.corp.microsoft.com> The logic for assigning these is definitely a little bit weird. The theory is that we only assign __name__ if we believe the code being executed is a module. This is to mimic the behavior of exec/eval which doesn't set __name__: >>> x = {'__name__':'foo'} >>> exec 'print "hi"' in x hi >>> x['__name__'] 'foo' >>> So in the 1st two cases the theory is that we're not setting it all. I suspect in the 1st case though we are actually setting it somewhere when we create the default scope for executing the code. The last 2 we believe are modules but we don't have a path for the source code. When that happens we set the name to . I believe this is an attempt to match some behavior of CPython but I can't quite figure out what behavior it is replicating right now. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of jhoward at drawloop.com > Sent: Tuesday, November 17, 2009 2:31 PM > To: users at lists.ironpython.com > Subject: Re: [IronPython] Embedded IronPython 2.6 Module Name > > More specifically, there seems to be four easy ways to execute a > string of python code. The following code has the output listed > below: > > Console.WriteLine(ss.Engine.CreateScriptSourceFromString > ("__name__", SourceCodeKind.Expression).Execute(ss)); > Console.WriteLine(ss.Engine.CreateScriptSourceFromString > ("__name__", SourceCodeKind.Expression).Execute()); > Console.WriteLine(ss.Engine.Execute("__name__")); > Console.WriteLine(ss.Engine.Execute("__name__", ss)); > > Output: > > __main__ > __builtin__ > > > > On Nov 17, 2:26?pm, "jhow... at drawloop.com" > wrote: > > Thanks, that gives me at least something. ?Any idea why: > > > > ? ? ss.Engine.Execute("__name__", ss); > > > > returns "" but: > > > > ? ? ss.Engine.CreateScriptSourceFromString("__name__", > > SourceCodeKind.Expression).Execute(ss); > > > > returns "__main__"? > > > > On Nov 17, 2:12?pm, Dino Viehland wrote: > > > > > I think you now want to do: > > > > > ? ? ? ? ? ? ? PythonModule pm = new PythonModule(); > > > ? ? ? ? ? ? ScriptEngine se = Python.CreateEngine(); > > > ? ? ? ? ? ? PythonContext pc = (PythonContext) > HostingHelpers.GetLanguageContext(se); > > > ? ? ? ? ? ? pc.PublishModule("__main__", pm); > > > > > ? ? ? ? ? ? ? var modContext = new ModuleContext(pm, pc); > > > > > ? ? ? ? ? ? ScriptScope ss = HostingHelpers.CreateScriptScope(se, > modContext.GlobalScope); > > > ? ? ? ? ? ? ss.SetVariable("__name__", "__ main__"); > > > ? ? ? ? ? ? ss.SetVariable("__doc__", ""); > > > > > The change here is to create a ModuleContext which will let you > then get the Scope. > > > > > I agree this has gotten worse in 2.6 - I opened a bug a while ago > to make working with > > > modules easier - > http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25190. > > > > > > -----Original Message----- > > > > From: users-boun... at lists.ironpython.com [mailto:users- > > > > boun... at lists.ironpython.com] On Behalf Of jhow... at drawloop.com > > > > Sent: Tuesday, November 17, 2009 2:02 PM > > > > To: us... at lists.ironpython.com > > > > Subject: Re: [IronPython] Embedded IronPython 2.6 Module Name > > > > > > I realize I'm replying rather late, but I just got to trying this > > > > again. ?This is something that really should be simple. ?Anytime > a > > > > module is run from the ScriptEngine directly, I would expect the > > > > behavior to be running as "__main__" just as if I was running it > from > > > > the command line using "ipy" or "python". ?Unfortunately, trying > to > > > > create a module directly doesn't work as far as naming the > module. > > > > Using the following code: > > > > > > ? ? ? ? ? ? PythonModule pm = new PythonModule(); > > > > ? ? ? ? ? ? ScriptEngine se = Python.CreateEngine(); > > > > ? ? ? ? ? ? PythonContext pc = (PythonContext) > > > > HostingHelpers.GetLanguageContext(se); > > > > ? ? ? ? ? ? pc.PublishModule("__main__", pm); > > > > ? ? ? ? ? ? ScriptScope ss = HostingHelpers.CreateScriptScope(se, > new > > > > Microsoft.Scripting.Runtime.Scope(pm.Get__dict__())); > > > > ? ? ? ? ? ? ss.SetVariable("__name__", "__main__"); > > > > ? ? ? ? ? ? ss.SetVariable("__doc__", ""); > > > > > > doesn't work. ?There's no way to directly get the Scope from the > > > > PythonModule when working this way, as it's been marked as > internal. > > > > Looking through the debugger, the _scope variable that actually > holds > > > > the scope on the PythonModule object is null. ?I believe the old > > > > CreateModule way of doing this would have worked, but there's no > way > > > > to that I've found to do this now. > > > > > > At this point, I'm really not sure how 2.6 is being marked as a > > > > release candidate. > > > > > > On an unrelated note, I could, in IronPython 1.1.2 do the > following > > > > code: > > > > > > ? ? ? ? ? ? _pyEngine.Execute("python code", > _pyEngine.DefaultModule, > > > > args); > > > > > > where "args" is a Dictionary and have those > arguments > > > > passed in to a function call or the like. ?Is there any way to do > this > > > > using the new hosting engine? > > > > > > Thanks again. > > > > > > On Nov 6, 2:18?pm, Curt Hagenlocher wrote: > > > > > It looks like you can just create the PythonModule directly now > -- > > > > it's a > > > > > public class with a public constructor. > > > > > > > On Thu, Nov 5, 2009 at 12:14 PM, Jonathan Howard > > > > wrote: > > > > > > > > Thanks for the help, Curt. ?Perhaps it's a problem with the > latest, > > > > RC? > > > > > > ?There is no "CreateModule" function on the PythonContext > object. > > > > > > > > ~Jonathan > > > > > > > > _______________________________________________ > > > > > > Users mailing list > > > > > > Us... at lists.ironpython.com > > > > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > > > _______________________________________________ > > > > > Users mailing list > > > > > > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/user > > > > s-ironpython.com > > > > _______________________________________________ > > > > Users mailing list > > > > Us... at lists.ironpython.com > > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > _______________________________________________ > > > Users mailing list > > > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/user > s-ironpython.com > > > > _______________________________________________ > > Users mailing list > > > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/user > s-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at microsoft.com Wed Nov 18 20:00:10 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 18 Nov 2009 19:00:10 +0000 Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue In-Reply-To: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> References: <5c1d2b3d0911150834me898922sf24bd682b93ec869@mail.gmail.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04CC6B7E@TK5EX14MBXC118.redmond.corp.microsoft.com> It might be interesting to run w/ -X:ExceptionDetail to see where the OOM is actually coming from. It could be that there's one giant allocation which is failing or it could be that something's broken and causing a big loop which allocates forever. -X:ExceptionDetail might given an indication of which one it is. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of matan keret Sent: Sunday, November 15, 2009 8:34 AM To: Discussion of IronPython Subject: [IronPython] poplib.POP3_SSL OutOfMemory Issue Hi everyone! i wrote the next code which suppose to go to my hotmail account, fetch the last email's image attachment and save it to a file: import email, poplib, os, string def get_messages_id(message_list): items = [] for message in message_list[1]: message_parts = string.split(message,' ') message_id = message_parts[0] items.append(message_id) # print 'message id is: %s\n' % message_id # print 'done getting ids' return items host = "pop3.live.com" detach_dir = 'D:\\test-attachments\\' # directory where to save attachments (default: current) user = "matan.py at hotmail.com" pwd = "0okmnji9" server = poplib.POP3_SSL(host) server.user(user) server.pass_(pwd) numMessages = len(server.list()[1]) #print numMessages # server.list() returns messages info from server in # form of response, message_list, size where message_list # is. a list of messages in form of 'message_id size' message_list = server.list() # get the list of items id items = get_messages_id(message_list) items.reverse() # puts the last received mail's id in the first place in list is_image = False # find the first mail in items that has an attachment and get the attachment for emailid in items: # if we found an email with an image we break if is_image: break total_email_message = server.retr(emailid)[1] messageText = string.join(total_email_message, "\n") mail = email.message_from_string(messageText) # parsing the mail content to get a mail object # Check if there are any attachments at all if mail.get_content_maintype() != 'multipart': continue # we use walk to create a generator so we can iterate on the parts for part in mail.walk(): # skip any attachment which is not an image if part.get_content_maintype() != 'image': continue # is this part an attachment ? if part.get('Content-Disposition') is None: continue filename = part.get_filename() is_image = True # if there is no filename, we create one with a counter to avoid duplicates if not filename: filename = 'part-%03d%s' % (1, 'bin') att_path = os.path.join(detach_dir, filename) # Check if its not already there and finally write the file if not os.path.isfile(att_path) : fp = open(att_path, 'wb') fp.write(part.get_payload(decode=True)) fp.close() # if we found an email with an image we break after first image downloaded if is_image: break server.quit() print 'Finished fetching the image' # THE END also available at: http://pastebin.org/53873 This works fine on Cpython but on IronPython 2.0.3 I get: Traceback (most recent call last): File "get_first_attachment.py", line 21, in get_first_attachment.py File "D:\IronPython 2.0.3\Lib\poplib.py", line 361, in __init__ File "D:\IronPython 2.0.3\Lib\poplib.py", line 137, in _getresp File "D:\IronPython 2.0.3\Lib\poplib.py", line 374, in _getline File "D:\IronPython 2.0.3\Lib\poplib.py", line 364, in _fillBuffer MemoryError: Exception of type 'System.OutOfMemoryException' was thrown. this comes out from line 21: server = poplib.POP3_SSL(host) Any ideas why is that? How to fix it? Is it a known issue (tried to look but couldn't find)? Thanks, Matan -------------- next part -------------- An HTML attachment was scrubbed... URL: From josh at globalherald.net Wed Nov 18 21:58:59 2009 From: josh at globalherald.net (Joshua Kramer) Date: Wed, 18 Nov 2009 15:58:59 -0500 (EST) Subject: [IronPython] Ability to use CPython csv module Message-ID: Some time ago, William Clifford wrote: "Just curious if anyone has been able to get the CPython csv module to work with IronPython (2.6 rc2)?" I had some csv-involved tasks to complete with IronPython 2.0.2. I did not use CSV from CPython. However, there is another way to do this: http://www.ironpython.info/index.php/Reading_CSV_Files I was able to use the LumenWorks CSV DLL without issue. Best, -JK -- ----- http://www.globalherald.net/jb01 GlobalHerald.NET, the Smarter Social Network! (tm) From merllab at microsoft.com Wed Nov 18 21:07:27 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Wed, 18 Nov 2009 12:07:27 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <365ae26c-4521-4bdf-941f-b08140561201@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61566. ADDED SOURCES $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/init.rb MODIFIED SOURCES $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicScriptTags.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicLanguageConfig.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/BrowserVirtualFilesystem.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Chiron/App.config $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicApplication.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/DynamicEngine.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/ErrorFormatter.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/init.rb $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Repl.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Microsoft.Scripting.Silverlight.csproj $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/ExtensionTypes.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Window.cs $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/XamlScriptTags.cs From william.clifford.mit at gmail.com Wed Nov 18 22:16:35 2009 From: william.clifford.mit at gmail.com (William Clifford) Date: Wed, 18 Nov 2009 16:16:35 -0500 Subject: [IronPython] Ability to use CPython csv module Message-ID: <20bb19270911181316td8b0b75xf774ecfccb6f3d23@mail.gmail.com> Thanks. That may be an option for a little while, at least as far as reading csv files goes. Writing them really shouldn't be too hard to implement, but rather than re-write essentially a library of my code, I think I'll hold off on the switch for a little while, at least until some of the CPython mods like csv are ported over. Some time ago, Joshua Kramer wrote: > > I had some csv-involved tasks to complete with IronPython 2.0.2. I did > not use CSV from CPython. However, there is another way to do this: > > http://www.ironpython.info/index.php/Reading_CSV_Files > > I was able to use the LumenWorks CSV DLL without issue. > > Best, > -JK -- William M. Clifford, M.I.T. william.clifford.mit at gmail.com Mobile: 954-347-8037 -------------- next part -------------- An HTML attachment was scrubbed... URL: From slide.o.mix at gmail.com Wed Nov 18 22:45:04 2009 From: slide.o.mix at gmail.com (Slide) Date: Wed, 18 Nov 2009 14:45:04 -0700 Subject: [IronPython] Ability to use CPython csv module In-Reply-To: <20bb19270911181316td8b0b75xf774ecfccb6f3d23@mail.gmail.com> References: <20bb19270911181316td8b0b75xf774ecfccb6f3d23@mail.gmail.com> Message-ID: Are modules things that can be contributed to IP? If I were to go write a compatible _csv module and post it as a patch, would it be accepted? Thanks, slide On Wed, Nov 18, 2009 at 2:16 PM, William Clifford < william.clifford.mit at gmail.com> wrote: > Thanks. That may be an option for a little while, at least as far as > reading csv files goes. Writing them really shouldn't be too hard to > implement, but rather than re-write essentially a library of my code, I > think I'll hold off on the switch for a little while, at least until some of > the CPython mods like csv are ported over. > > Some time ago, Joshua Kramer wrote: > > > > I had some csv-involved tasks to complete with IronPython 2.0.2. I did > > not use CSV from CPython. However, there is another way to do this: > > > > http://www.ironpython.info/index.php/Reading_CSV_Files > > > > I was able to use the LumenWorks CSV DLL without issue. > > > > Best, > > -JK > > > -- > William M. Clifford, M.I.T. > william.clifford.mit at gmail.com > Mobile: 954-347-8037 > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dfugate at microsoft.com Thu Nov 19 00:25:44 2009 From: dfugate at microsoft.com (dfugate at microsoft.com) Date: Wed, 18 Nov 2009 15:25:44 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61570. ADDED SOURCES $/IronPython/IronPython_2_6/Doc/Chiron.txt MODIFIED SOURCES $/IronPython/IronPython_2_6/Doc/Chiron.txt $/IronPython/IronPython_2_6/Src/IronPython.Modules/IronPython.Modules.csproj $/IronPython/IronPython_2_6/Src/IronPython/IronPython.csproj $/IronPython/IronPython_2_6/Src/IronPythonTest/IronPythonTest.csproj $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Microsoft.Scripting.Silverlight.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Debugging/Microsoft.Scripting.Debugging.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting/Microsoft.Scripting.csproj $/IronPython/IronPython_2_6/Src/Tests/ClrAssembly/ClrAssembly.csproj CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1250429 Date: 11/3/2009 12:39:57 PM (dfugate) Migrated sbs_library.dll change from the Main branch over to IP_26. (Shelveset: SBS_LIBRARY_IP26;REDMOND\dfugate | SNAP CheckinId: 9735) From fuzzyman at voidspace.org.uk Thu Nov 19 20:26:46 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 19 Nov 2009 19:26:46 +0000 Subject: [IronPython] _codecs in Silverlight Message-ID: <4B059BF6.2070906@voidspace.org.uk> Hello all, In IronPython 2.6 RC2 the Silverlight implementation of _codecs seems to have missing 'bits' - specifically lookup_error is missing which breaks the encodings module. This means I can't use a recent version of simplejson with Silverlight. Any way I can mitigate against this? Any reason for this? All the best, Michael Foord -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From merllab at microsoft.com Thu Nov 19 21:09:03 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Thu, 19 Nov 2009 12:09:03 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <0aae7a7e-4a25-4bd2-86f1-17c817ec1ac0@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61619. MODIFIED SOURCES $/IronPython/IronPython_2_6/Src/IronPython.Modules/IronPython.Modules.csproj $/IronPython/IronPython_2_6/Src/IronPython/IronPython.csproj $/IronPython/IronPython_2_6/Src/IronPythonTest/IronPythonTest.csproj $/IronPython/IronPython_2_6/Src/Hosts/SilverLight/Microsoft.Scripting.Silverlight/Microsoft.Scripting.Silverlight.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Dynamic/Microsoft.Dynamic.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.Core.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Core/Microsoft.Scripting.ExtensionAttribute.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting.Debugging/Microsoft.Scripting.Debugging.csproj $/IronPython/IronPython_2_6/Src/Runtime/Microsoft.Scripting/Microsoft.Scripting.csproj $/IronPython/IronPython_2_6/Src/Tests/ClrAssembly/ClrAssembly.csproj CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1279997 Date: 11/19/2009 11:26:29 AM Added Chiron instructions in the form of Doc\Chiron.txt. Updated the Wix ProductVersion number for IP 2.6. From idmkid at yahoo.com Fri Nov 20 05:41:15 2009 From: idmkid at yahoo.com (David Seruyange) Date: Thu, 19 Nov 2009 20:41:15 -0800 (PST) Subject: [IronPython] IRONPYTHONPATH Message-ID: <316205.81264.qm@web30805.mail.mud.yahoo.com> It's been a while since I've written some IronPython. By reflex/memory I was going to set IRONPYTHONPATH but wondered if anything had changed w/r/t the Python Standard Library. Just for the sake of interest I ran "import this" with IronPython 2.6 RC2 and I do get The Zen of Python. Pretty trite but that didn't work w/o setting the aforementioned environment variable beforehand. David -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Fri Nov 20 11:02:55 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 20 Nov 2009 10:02:55 +0000 Subject: [IronPython] IRONPYTHONPATH In-Reply-To: <316205.81264.qm@web30805.mail.mud.yahoo.com> References: <316205.81264.qm@web30805.mail.mud.yahoo.com> Message-ID: <4B06694F.1080409@voidspace.org.uk> David Seruyange wrote: > It's been a while since I've written some IronPython. By reflex/memory > I was going to set IRONPYTHONPATH but wondered if anything had changed > w/r/t the Python Standard Library. Just for the sake of interest I ran > "import this" with IronPython 2.6 RC2 and I do get The Zen of Python. > Pretty trite but that didn't work w/o setting the aforementioned > environment variable beforehand. If you install IronPython 2.6 then you get the working parts of the Python standard library and they are automatically on sys.path - no need to set IRONPYTHONPATH just to get the standard library. All the best, Michael > > David > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From merllab at microsoft.com Fri Nov 20 17:52:38 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Fri, 20 Nov 2009 08:52:38 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <55776727-4958-4e23-a7ae-9e50c892662c@tk5-exsmh-c102.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61659. ADDED SOURCES $/IronPython/IronPython_Main/Doc/Chiron.txt MODIFIED SOURCES $/IronPython/IronPython_Main/Doc/Chiron.txt $/IronPython/IronPython_Main/Src/Tests/Modes/ConsoleFlags.ps1 CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1280333 Date: 11/19/2009 3:05:23 PM Merged over IronPython\Public\Doc changes from IP 2.6 branch. Attempting to fix another Win7/PowerShell 2.0 issue. (Shelveset: CHIRON_DOC;REDMOND\dfugate | SNAP CheckinId: 9864) From dfugate at microsoft.com Fri Nov 20 18:54:05 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Fri, 20 Nov 2009 17:54:05 +0000 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 Message-ID: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> Hello Python Community, We're pleased to announce the third and hopefully final release candidate of IronPython 2.6 which can be downloaded at http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. Release Candidate 3 only includes Silverlight-related changes pertaining to some incompatibilities between 2.6 RC1 and RC2. Those who utilize IronPython for non-Silverlight scenarios will happily find virtually no churn from RC2. We strongly encourage everyone interested in Silverlight to test out this release ASAP because we plan on releasing IronPython 2.6 final in a week if no major new regressions are detected. Thanks to everyone in the IronPython Community who reported bugs and provided valuable feedback: Zachc, yamakox, vernondcole, VAks, tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and dmajnemer. Thank you for your continued support of IronPython. The IronPython Team -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Sat Nov 21 01:00:35 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 21 Nov 2009 00:00:35 +0000 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 In-Reply-To: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> References: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> Message-ID: <4B072DA3.5090609@voidspace.org.uk> Dave Fugate wrote: > > Hello Python Community, > > We?re pleased to announce the third and hopefully final release > candidate of IronPython 2.6 which can be downloaded at > http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. > Release Candidate 3 only includes Silverlight-related changes > pertaining to some incompatibilities between 2.6 RC1 and RC2. Those > who utilize IronPython for non-Silverlight scenarios will happily find > virtually no churn from RC2. We strongly encourage everyone interested > in Silverlight to test out this release ASAP because we plan on > releasing IronPython 2.6 final in a week if no major new regressions > are detected. > Any chance the _codecs issue I mentioned is fixed in Release Candidate 3? It blocks me using the standard library json module (simplejson) in Silverlight so is a major PITA. Michael > Thanks to everyone in the IronPython Community who reported bugs and > provided valuable feedback: Zachc, yamakox, vernondcole, VAks, > tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, > srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, > pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, > NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, > lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, > klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, > hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, > chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, > __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and > dmajnemer. > > Thank you for your continued support of IronPython. > > The IronPython Team > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From dfugate at microsoft.com Sat Nov 21 05:36:57 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Sat, 21 Nov 2009 04:36:57 +0000 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 In-Reply-To: <4B072DA3.5090609@voidspace.org.uk> References: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> <4B072DA3.5090609@voidspace.org.uk> Message-ID: <7CEEC335D70FFE4B957737DDE836F51B104B988A@TK5EX14MBXC123.redmond.corp.microsoft.com> Hi Michael, glancing over the source history it appears as if _codecs.lookup_error has been disabled under Silverlight forever and is not a regression from IronPython 2.0. That said, it might turn out this falls under the umbrella of http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=17383, and is something we can address for 2.6.1. Thanks, Dave -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, November 20, 2009 4:01 PM To: Discussion of IronPython Subject: Re: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 Dave Fugate wrote: > > Hello Python Community, > > We're pleased to announce the third and hopefully final release > candidate of IronPython 2.6 which can be downloaded at > http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. > Release Candidate 3 only includes Silverlight-related changes > pertaining to some incompatibilities between 2.6 RC1 and RC2. Those > who utilize IronPython for non-Silverlight scenarios will happily find > virtually no churn from RC2. We strongly encourage everyone interested > in Silverlight to test out this release ASAP because we plan on > releasing IronPython 2.6 final in a week if no major new regressions > are detected. > Any chance the _codecs issue I mentioned is fixed in Release Candidate 3? It blocks me using the standard library json module (simplejson) in Silverlight so is a major PITA. Michael > Thanks to everyone in the IronPython Community who reported bugs and > provided valuable feedback: Zachc, yamakox, vernondcole, VAks, > tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, > srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, > pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, > NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, > lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, > klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, > hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, > chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, > __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and > dmajnemer. > > Thank you for your continued support of IronPython. > > The IronPython Team > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kfarmer at thuban.org Sat Nov 21 11:56:17 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Sat, 21 Nov 2009 02:56:17 -0800 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 In-Reply-To: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> References: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> Message-ID: Hey, Dave.. Based on Dino?s presentation at PDC, is it therefore certain that the hosting APIs will *not* ship as part of .NET 4? Has there been any official word as to support of those APIs in that event? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dave Fugate Sent: Friday, November 20, 2009 9:54 AM To: users at lists.ironpython.com; python-announce-list at python.org Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 Hello Python Community, We?re pleased to announce the third and hopefully final release candidate of IronPython 2.6 which can be downloaded at http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. Release Candidate 3 only includes Silverlight-related changes pertaining to some incompatibilities between 2.6 RC1 and RC2. Those who utilize IronPython for non-Silverlight scenarios will happily find virtually no churn from RC2. We strongly encourage everyone interested in Silverlight to test out this release ASAP because we plan on releasing IronPython 2.6 final in a week if no major new regressions are detected. Thanks to everyone in the IronPython Community who reported bugs and provided valuable feedback: Zachc, yamakox, vernondcole, VAks, tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and dmajnemer. Thank you for your continued support of IronPython. The IronPython Team -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Sat Nov 21 14:49:38 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sat, 21 Nov 2009 13:49:38 +0000 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 In-Reply-To: References: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> Message-ID: <1B42307CD4AADD438CDDA2FE1121CC9203F9CF@TK5EX14MBXC134.redmond.corp.microsoft.com> [Dropping python-announce-list] Yes, it?s certain that the hosting APIs will not ship in .NET 4. Basically everything that is in Microsoft.Scripting.Core.dll is what has made its way into .NET 4.0. Sorry if that wasn?t clear. You?ll also notice that Microsoft.Scripting.dll has been split into Microsoft.Scripting.dll and Microsoft.Dynamic.dll; the hosting APIs are still contained in Microsoft.Scripting.dll, while the things language implementers need to care about is in Microsoft.Dynamic.dll. We?re trying to not change Microsoft.Scripting.dll as much as possible, as those APIs have undergone some rigorous design and reviews. Microsoft.Dynamic.dll definitely will change. ~Jimmy From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Keith J. Farmer Sent: Saturday, November 21, 2009 2:56 AM To: Discussion of IronPython; python-announce-list at python.org Subject: Re: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 Hey, Dave.. Based on Dino?s presentation at PDC, is it therefore certain that the hosting APIs will *not* ship as part of .NET 4? Has there been any official word as to support of those APIs in that event? From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dave Fugate Sent: Friday, November 20, 2009 9:54 AM To: users at lists.ironpython.com; python-announce-list at python.org Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 Hello Python Community, We?re pleased to announce the third and hopefully final release candidate of IronPython 2.6 which can be downloaded at http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. Release Candidate 3 only includes Silverlight-related changes pertaining to some incompatibilities between 2.6 RC1 and RC2. Those who utilize IronPython for non-Silverlight scenarios will happily find virtually no churn from RC2. We strongly encourage everyone interested in Silverlight to test out this release ASAP because we plan on releasing IronPython 2.6 final in a week if no major new regressions are detected. Thanks to everyone in the IronPython Community who reported bugs and provided valuable feedback: Zachc, yamakox, vernondcole, VAks, tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and dmajnemer. Thank you for your continued support of IronPython. The IronPython Team -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Sat Nov 21 16:59:04 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 21 Nov 2009 15:59:04 +0000 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 In-Reply-To: <7CEEC335D70FFE4B957737DDE836F51B104B988A@TK5EX14MBXC123.redmond.corp.microsoft.com> References: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> <4B072DA3.5090609@voidspace.org.uk> <7CEEC335D70FFE4B957737DDE836F51B104B988A@TK5EX14MBXC123.redmond.corp.microsoft.com> Message-ID: <4B080E48.4030105@voidspace.org.uk> Dave Fugate wrote: > Hi Michael, glancing over the source history it appears as if _codecs.lookup_error has been disabled under Silverlight forever and is not a regression from IronPython 2.0. That said, it might turn out this falls under the umbrella of http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=17383, and is something we can address for 2.6.1. > > That issue is closed, shall I open a new one? Michael > Thanks, > > Dave > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Friday, November 20, 2009 4:01 PM > To: Discussion of IronPython > Subject: Re: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 > > Dave Fugate wrote: > >> Hello Python Community, >> >> We're pleased to announce the third and hopefully final release >> candidate of IronPython 2.6 which can be downloaded at >> http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. >> Release Candidate 3 only includes Silverlight-related changes >> pertaining to some incompatibilities between 2.6 RC1 and RC2. Those >> who utilize IronPython for non-Silverlight scenarios will happily find >> virtually no churn from RC2. We strongly encourage everyone interested >> in Silverlight to test out this release ASAP because we plan on >> releasing IronPython 2.6 final in a week if no major new regressions >> are detected. >> >> > Any chance the _codecs issue I mentioned is fixed in Release Candidate > 3? It blocks me using the standard library json module (simplejson) in > Silverlight so is a major PITA. > > Michael > > > >> Thanks to everyone in the IronPython Community who reported bugs and >> provided valuable feedback: Zachc, yamakox, vernondcole, VAks, >> tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, >> srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, >> pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, >> NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, >> lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, >> klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, >> hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, >> chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, >> __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and >> dmajnemer. >> >> Thank you for your continued support of IronPython. >> >> The IronPython Team >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From dfugate at microsoft.com Sun Nov 22 00:45:42 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Sat, 21 Nov 2009 23:45:42 +0000 Subject: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 In-Reply-To: <4B080E48.4030105@voidspace.org.uk> References: <7CEEC335D70FFE4B957737DDE836F51B104B8874@TK5EX14MBXC123.redmond.corp.microsoft.com> <4B072DA3.5090609@voidspace.org.uk> <7CEEC335D70FFE4B957737DDE836F51B104B988A@TK5EX14MBXC123.redmond.corp.microsoft.com> <4B080E48.4030105@voidspace.org.uk> Message-ID: <7CEEC335D70FFE4B957737DDE836F51B104B9E99@TK5EX14MBXC123.redmond.corp.microsoft.com> No need. It hasn't been verified as Fixed yet, and I should be getting to this particular bug next week. Looks like you've probably even saved me a bit of investigative time for proving this can't be closed so thanks:) Dave -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Saturday, November 21, 2009 7:59 AM To: Discussion of IronPython Subject: Re: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 Dave Fugate wrote: > Hi Michael, glancing over the source history it appears as if _codecs.lookup_error has been disabled under Silverlight forever and is not a regression from IronPython 2.0. That said, it might turn out this falls under the umbrella of http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=17383, and is something we can address for 2.6.1. > > That issue is closed, shall I open a new one? Michael > Thanks, > > Dave > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Friday, November 20, 2009 4:01 PM > To: Discussion of IronPython > Subject: Re: [IronPython] [ANN]: IronPython 2.6 Release Candidate 3 > > Dave Fugate wrote: > >> Hello Python Community, >> >> We're pleased to announce the third and hopefully final release >> candidate of IronPython 2.6 which can be downloaded at >> http://ironpython.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=36150. >> Release Candidate 3 only includes Silverlight-related changes >> pertaining to some incompatibilities between 2.6 RC1 and RC2. Those >> who utilize IronPython for non-Silverlight scenarios will happily find >> virtually no churn from RC2. We strongly encourage everyone interested >> in Silverlight to test out this release ASAP because we plan on >> releasing IronPython 2.6 final in a week if no major new regressions >> are detected. >> >> > Any chance the _codecs issue I mentioned is fixed in Release Candidate > 3? It blocks me using the standard library json module (simplejson) in > Silverlight so is a major PITA. > > Michael > > > >> Thanks to everyone in the IronPython Community who reported bugs and >> provided valuable feedback: Zachc, yamakox, vernondcole, VAks, >> tscottw, tonyandrewmeyer, tomwright, TomasMatousek, tkamiya, timers, >> srivatsn, sopeajw, saveenr, sanxiyn, rridge, ronniemaor, quirogaco, >> pythonfoo, py_sunil, pm100, pl6306, paulfelix, orestis, olegt, oldman, >> NDHUMuscle, mycall, mmaly, mmacdonaldssfcu, maplpro, luntain, llaske, >> lbaker, Lawouach, laurionb, laughingboy, kurhan, kuno, kowenswp, >> klrohe, kevgu, jmesserly, jlunder, jdhardy, jbevain, jackeyoo, >> hhonisch, gz, gjones, fwereade, deadalusai, daveremy, CurtHagenlocher, >> chaghi, cgravill, cartman, bobarnso, atifaziz, ashcor, alvanet, >> __Helmut__, fuzzyman, fabiofz, Eloff, egonw_, dungen, dsblank, and >> dmajnemer. >> >> Thank you for your continued support of IronPython. >> >> The IronPython Team >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From sanxiyn at gmail.com Sun Nov 22 18:20:11 2009 From: sanxiyn at gmail.com (Seo Sanghyeon) Date: Mon, 23 Nov 2009 02:20:11 +0900 Subject: [IronPython] Ability to use CPython csv module In-Reply-To: References: <20bb19270911181316td8b0b75xf774ecfccb6f3d23@mail.gmail.com> Message-ID: <5b0248170911220920h2f5598d9j943dda69048cca13@mail.gmail.com> 2009/11/19 Slide : > Are modules things that can be contributed to IP? If I were to go write a > compatible _csv module and post it as a patch, would it be accepted? As I understand, no. But you can provide a compatible _csv module outside of IP, and indeed this is exactly what is happening on pyexpat module right now. -- Seo Sanghyeon From cenovsky at bakalari.cz Sun Nov 22 21:19:25 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Sun, 22 Nov 2009 21:19:25 +0100 Subject: [IronPython] WCF Service in pure IronPython In-Reply-To: <4B0293CD.1000203@bakalari.cz> References: <4B0293CD.1000203@bakalari.cz> Message-ID: <4B099CCD.5040904@bakalari.cz> Hi, I am able to save the WCF service to the assembly, so I can use .config files to configure it - see http://gui-at.blogspot.com/2009/11/wcf-service-in-pure-ironpython-with.html I think there is only a small step left to make possible to host IronPython WCF services in IIS. IIS configures services in .svc files which contains the following: <% @ServiceHost Service="myWcfService.myService" %> This obviously fails because IIS cannot find such type in the .dll created by pyc.py. Does anybody have an idea how to overcome this issue? -- -- Luk?? Lukas Cenovsky wrote: > The latest version of clrtype.py has support for ClrInterface > metaclass - see the usage on my blog: > http://gui-at.blogspot.com/2009/11/wcf-service-in-pure-ironpython.html > > -- > -- Luk?? > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From cenovsky at bakalari.cz Sun Nov 22 22:26:37 2009 From: cenovsky at bakalari.cz (Lukas Cenovsky) Date: Sun, 22 Nov 2009 22:26:37 +0100 Subject: [IronPython] Compiling .py to .dll to use with Silverlight Message-ID: <4B09AC8D.4090207@bakalari.cz> Hi, I'd like to know status of the $subj. I have found some discussions (e.g. Michael tried to use pyc or http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=52207&ANCHOR ) but no working example - is there any? And if not will be any? :-) Thanks. -- -- Luk?? From slide.o.mix at gmail.com Mon Nov 23 06:04:25 2009 From: slide.o.mix at gmail.com (Slide) Date: Sun, 22 Nov 2009 22:04:25 -0700 Subject: [IronPython] built-in modules Message-ID: Are there any tutorials on writing modules that appear as built-ins? does it have to be part of the IronPython.Modules assembly to be loaded correctly? thanks, slide -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Mon Nov 23 06:13:47 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 23 Nov 2009 05:13:47 +0000 Subject: [IronPython] built-in modules In-Reply-To: References: Message-ID: <1A472770E042064698CB5ADC83A12ACD04CE8ED3@TK5EX14MBXC118.redmond.corp.microsoft.com> I started writing up some documentation around this as part of our push to actually have useful documentation :) Here's the current version of that - if you have any feedback or additional questions it'd be great to hear to improve the docs. 1. Implementing new modules in .NET When creating a new module usually you would just implement it in IronPython its self. But sometimes you may have requirements that preclude implementing it in IronPython. These could be due to needing a .NET library which IronPython cannot fully or easily consume (because it requires attributes, for example), due to performance, or other reasons. When you run into this road block you have one of two options. First, you can simply expose this functionality as a normal .NET library and allow the user to interact with it through the normal IronPython .NET interop mechanisms. Alternately you can implement a Python module in your favorite .NET language. If you're not entirely sure which one to choose you're lucky because there's not much difference between the two - but in this section we'll cover how to implement a Python module. The first thing to do is to create a new project, or open an existing one, and add a reference to IronPython.dll. The next step is to define a new class and add an assembly level PythonModuleAttribute which points at the class giving the module name and type. After doing this you should have a file which looks like: C# example: using System; using IronPython.Runtime; [assembly: PythonModule("my_module", typeof(MyModule))] public static class MyModule { } VB.NET example: Imports System Imports IronPython.Runtime Public Module MyModule End Module Consuming from Python: >>> import clr >>> clr.AddReference('test') >>> import my_module >From here you just need to start implementing the functionality of your module. You can start to add methods, fields, properties, or types. All the member must be static as there will not be an instance of the module created. Here's an example where we define a method, a property, and a couple of fields. One of the fields is a literal and the other is a static field. One important detail to note is that modules are entirely read-only. Even if you implement a property or a mutable field IronPython will never set a value into the property or field. Instead the updated field will always be stored in the modules dictionary. C# example: using System; using IronPython.Runtime; [assembly: PythonModule("my_module", typeof(MyModule))] public static class MyModule { public static void hello_world() { Console.WriteLine("hello world"); } public static string foo { get { return "foo"; } } public const string bar = "bar"; public static readonly string baz = "baz"; } VB.NET example: Imports System Imports IronPython.Runtime Public Module MyModule Public Sub hello_world() Console.WriteLine("Hello World") End Sub Public ReadOnly Property foo As String Get Return "foo" End Get End Property Public Const bar As String = "bar" Public ReadOnly baz As String = "baz" End Module Consuming from Python: >>> import clr >>> clr.AddReference('test') >>> import my_module >>> my_module.hello_world() hello world >>> my_module.foo 'foo' >>> my_module.bar 'bar' >>> my_module.baz 'baz' 1.1. Initialization / Reloading If your module requires to run specific code to be initialized you can provide a method marked with SpecialNameAttribute which receives the PythonContext the module is running in as well as the PythonDictionary where the module members will live. This example will make "some_name" available in the module and it will have the value "Hello World". C# example: using System; using System.Runtime.CompilerServices; using IronPython.Runtime; [assembly: PythonModule("my_module", typeof(MyModule))] public static class MyModule { [SpecialName] public static void PerformModuleReload(PythonContext context, PythonDictionary dict) { dict["some_name"] = "Hello World"; } } VB.NET example: Imports System Imports IronPython.Runtime Imports System.Runtime.CompilerServices Public Module MyModule _ Public Sub PerformModuleReload(ByVal context As PythonContext, ByVal dict As PythonDictionary) dict("some_name") = "Hello World" End Sub End Module Consuming from Python: >>> import clr >>> clr.AddReference('test') >>> import my_module >>> my_module.some_value 'Hello World' >>> 1.2. Per-Runtime State Because modules are static classes you need to have somewhere you can store state for the current IronPython runtime instance. If you were to store it in a static field this state would bleed between IronPython runtimes in the same app domain. To accomodate this the PythonContext has a set of APIs which are specifically designed for storing state for Python modules. These APIs can be used either in the PerformModuleReload method or in methods which receive CodeContext as their first parameter. The CodeContext object will automatically be flowed in and from it you can get the PythonContext from the LanguageContext property. C# example: using System; using IronPython.Runtime; [assembly: PythonModule("my_module", typeof(MyModule))] public static class MyModule { private static readonly object _stateKey = new object(); public static object get_state(CodeContext context, object value) { object prev_value = null; if (context.LanguageContext.HasModuleState(_stateKey)) { prev_value = context.LanguageContext.GetModuleState(_stateKey); } context.LanguageContext.SetModuleState(_stateKey, value); return prev_value; } } VB.NET example: Imports System Imports IronPython.Runtime Public Module MyModule dim _stateKey as object = new object() Public Function get_state(ByVal context As CodeContext, ByVal value As Object) As Object Dim moduleState As Object = Nothing If context.LanguageContext.HasModuleState(MyModule._stateKey) Then moduleState = context.LanguageContext.GetModuleState(MyModule._stateKey) End If context.LanguageContext.SetModuleState(MyModule._stateKey, value) Return moduleState End Function End Module Consuming from Python: >>> import clr >>> clr.AddReference('test') >>> from my_module import get_state >>> get_state(42) >>> get_state(23) 42 1.2.1. Runtime State API Reference public object GetModuleState(object key) Gets per-runtime state used by a module. The module should have a unique key for each piece of state it needs to store. public void SetModuleState(object key, object value) Sets per-runtime state used by a module. The module should have a unique key for each piece of state it needs to store. public object GetSetModuleState(object key, object value) Sets per-runtime state used by a module and returns the previous value. The module should have a unique key for each piece of state it needs to store. public T GetOrCreateModuleState(object key, Func value) Gets the the module state if a value already exists. If one does not exist then calls the provided delegate to create the new value. The module should have a unique key for each piece of state it needs to store. bool HasModuleState(object key) Checks to see if module state has the current value stored already. 1.3. Deploying Modules So far in all of the examples we've seen the Python consumer has been required to call clr.AddReference on the module containing the DLL before it can be used. Obviously this is less than ideal as it both requires import clr (which has the side effect of making .NET members available) as well as requiring the AddReference call itself. ipy.exe also supports automatically loading modules which have been deployed to a directory named "DLLs" next to ipy.exe. Therefore once you've finished developing your module you can copy it over and it will always be available. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Sunday, November 22, 2009 9:04 PM To: Discussion of IronPython Subject: [IronPython] built-in modules Are there any tutorials on writing modules that appear as built-ins? does it have to be part of the IronPython.Modules assembly to be loaded correctly? thanks, slide -- slide-o-blog http://slide-o-blog.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Mon Nov 23 17:54:37 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Mon, 23 Nov 2009 08:54:37 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <5f2291a4-ab53-4609-9f55-3703d3271c44@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61729. MODIFIED SOURCES $/IronPython/IronPython_Main/Config/Signed/App.config $/IronPython/IronPython_Main/Config/Unsigned/App.config $/IronPython/IronPython_Main/Tutorial/Tutorial.htm CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1282641 Date: 11/20/2009 6:33:26 PM http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25420 Disabled verification of section T3.1.2 in the IronPython Tutorial test. This is all based on AgentServer which doesn't exist in Windows 7. (Shelveset: MSAGENT_TUT;REDMOND\dfugate | SNAP CheckinId: 9879) From merllab at microsoft.com Tue Nov 24 17:52:42 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Tue, 24 Nov 2009 08:52:42 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <9c4030bf-426f-4434-b023-b38748ac1d7e@tk5-exsmh-c102.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61762. MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Tests/interop/net/type/test_clrtype.py $/IronPython/IronPython_Main/Src/IronPython/Lib/iptest/misc_util.py $/IronPython/IronPython_Main/Src/Tests/modules/io_related/codecs_test.py $/IronPython/IronPython_Main/Src/Tests/regressions.py $/IronPython/IronPython_Main/Src/Tests/test_help.py $/IronPython/IronPython_Main/Src/Tests/test_cliclass.py $/IronPython/IronPython_Main/Src/Tests/test_stdmodules.py $/IronPython/IronPython_Main/Src/Tests/test_winforms.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1284427 Date: 11/23/2009 2:05:34 PM (CPy) test_doctest.py - CP23430 has been fixed (CPy) test_mailbox.py - CP16453 and CP13702 are fixed, but test cases still disabled for other reasons iptest.misc_util - added a few more strange codec encodings regressions.py - added regressions for CP23822 and CP23823 test_cliclass.py - extended test_dir. Added regressions for test_cp24004 and test_cp23772 test_help.py - added a regression for "help(type)". Still broken under Silverlight test_stdmodules.py - added a regression for CP21929. Fixed test_winforms.py - CP9908 is fixed codecs_test.py - CP20302 is nearly fixed (Shelveset: CP84;REDMOND\dfugate | SNAP CheckinId: 9909) From jhoward at drawloop.com Wed Nov 25 01:44:31 2009 From: jhoward at drawloop.com (Jonathan Howard) Date: Tue, 24 Nov 2009 16:44:31 -0800 (PST) Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 Message-ID: <4e016d67-8744-44b6-be65-daaffafa5d3c@x25g2000prf.googlegroups.com> I'm trying to track down a memory leak in our hosted IronPython application as we upgrade to 2.6 from 1.1.2. I saw a post at stackoverflow ( http://stackoverflow.com/questions/1664567/embedded-ironpython-memory-leak ) showing how to set up the environment to avoid leaking memory, but we're still having a memory leak. If I take our identical setup code, and use it on very simple code, there's no problem, but we have thousands of lines of Python at this point. Below is a minimum way to introduce a memory leak inside a hosted IronPython application. I don't know if it's the only way, or if it's what's affecting us, but it does cause a leak: (Obviously it needs the appropriate DLLs etc.) ############################################# using System; using System.Threading; using IronPython.Hosting; using IronPython.Runtime; using IronPython.Compiler; using System.Collections.Generic; using Microsoft.Scripting.Hosting; namespace IPyTest { class Program { static void Main(string[] args) { bool cont = true; while (cont) { var ipy = new IPy(); try { // Set the below boolean to "false" to run without a memory leak // Set it to "true" to run with a memory leak. ipy.run(true); } catch { } } } } class IPy { private string scriptWithoutLeak = "import random; random.randint(1,10)"; private string scriptWithLeak = "raise Exception(), 'error'"; public IPy() { } public void run(bool withLeak) { //set up script environment Dictionary options = new Dictionary(); options["LightweightScopes"] = true; ScriptEngine engine = Python.CreateEngine(options); PythonCompilerOptions pco = (PythonCompilerOptions) engine.GetCompilerOptions(); pco.Module &= ~ModuleOptions.Optimized; engine.SetSearchPaths(new string[]{ @"C:\Program Files\IronPython 2.6\Lib" }); ScriptRuntime runtime = engine.Runtime; ScriptScope scope = runtime.CreateScope(); var source = engine.CreateScriptSourceFromString( withLeak ? scriptWithLeak : scriptWithoutLeak ); var comped = source.Compile(); comped.Execute(scope); runtime.Shutdown(); } } } From dinov at microsoft.com Wed Nov 25 14:37:36 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 25 Nov 2009 13:37:36 +0000 Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 In-Reply-To: <4e016d67-8744-44b6-be65-daaffafa5d3c@x25g2000prf.googlegroups.com> References: <4e016d67-8744-44b6-be65-daaffafa5d3c@x25g2000prf.googlegroups.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04CFCAC3@TK5EX14MBXC118.redmond.corp.microsoft.com> My guess here (I'm on vacation so I haven't tried this) is that some exception info is not getting cleared - ExceptionHelpers.DynamicStackFrames = null; In the catch block will probably fix it although we should probably do this ourselves. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Jonathan Howard > Sent: Tuesday, November 24, 2009 4:45 PM > To: users at lists.ironpython.com > Cc: jfelkner at drawloop.com > Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 > > I'm trying to track down a memory leak in our hosted IronPython > application as we upgrade to 2.6 from 1.1.2. I saw a post at > stackoverflow ( http://stackoverflow.com/questions/1664567/embedded- > ironpython-memory-leak > ) showing how to set up the environment to avoid leaking memory, but > we're still having a memory leak. If I take our identical setup code, > and use it on very simple code, there's no problem, but we have > thousands of lines of Python at this point. > > Below is a minimum way to introduce a memory leak inside a hosted > IronPython application. I don't know if it's the only way, or if it's > what's affecting us, but it does cause a leak: (Obviously it needs > the appropriate DLLs etc.) > > ############################################# > > using System; > using System.Threading; > using IronPython.Hosting; > using IronPython.Runtime; > using IronPython.Compiler; > using System.Collections.Generic; > using Microsoft.Scripting.Hosting; > > namespace IPyTest > { > class Program > { > static void Main(string[] args) > { > bool cont = true; > while (cont) > { > var ipy = new IPy(); > try > { > // Set the below boolean to "false" to run without > a memory leak > // Set it to "true" to run with a memory leak. > ipy.run(true); > } > catch { } > } > } > } > > class IPy > { > private string scriptWithoutLeak = "import random; > random.randint(1,10)"; > private string scriptWithLeak = "raise Exception(), 'error'"; > > public IPy() > { > } > > public void run(bool withLeak) > { > //set up script environment > Dictionary options = new > Dictionary(); > options["LightweightScopes"] = true; > ScriptEngine engine = Python.CreateEngine(options); > PythonCompilerOptions pco = (PythonCompilerOptions) > engine.GetCompilerOptions(); > pco.Module &= ~ModuleOptions.Optimized; > engine.SetSearchPaths(new string[]{ > @"C:\Program Files\IronPython 2.6\Lib" > }); > ScriptRuntime runtime = engine.Runtime; > ScriptScope scope = runtime.CreateScope(); > var source = engine.CreateScriptSourceFromString( > withLeak ? scriptWithLeak : scriptWithoutLeak > ); > var comped = source.Compile(); > comped.Execute(scope); > runtime.Shutdown(); > } > } > } > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Owen.Sigurdson at cmgl.ca Wed Nov 25 16:02:36 2009 From: Owen.Sigurdson at cmgl.ca (Owen Sigurdson) Date: Wed, 25 Nov 2009 08:02:36 -0700 Subject: [IronPython] Re the The Fifth Assembly post (http://devhawk.net/2008/10/21/The+Fifth+Assembly.aspx) Message-ID: <38B19FF06367EB40B888564C566676160415DE3F@emailsrv.cgy.cmgl.ca> Hello, We are experiencing the problem that is mentioned in this post using IronPython 2.6 RC 2 but are un-able to un-reference the associated assembly. I am getting the following error: Error 2 Unknown build error, 'Cannot resolve dependency to assembly 'Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' Would anyone have any insight into what is going on here? -------------- next part -------------- An HTML attachment was scrubbed... URL: From Owen.Sigurdson at cmgl.ca Wed Nov 25 16:22:37 2009 From: Owen.Sigurdson at cmgl.ca (Owen Sigurdson) Date: Wed, 25 Nov 2009 08:22:37 -0700 Subject: [IronPython] v1.1 IronPython.CodeDom.PythonProvider Message-ID: <38B19FF06367EB40B888564C566676160415DE5B@emailsrv.cgy.cmgl.ca> I am attempting to upgrade a component from iron python 1.1 to 2.6 that was previously using the PythonProvider to compile python code into a .NET assembly. It looks like this is no longer present in 2.6. Is this correct? Are their any plans to resurrect it? The biggest difficulty I am facing is not that we require the code to be compiled in an assembly but that reflection used to return methods in an python class. Now reflecting on a python class (that subclasses a given .NET class) only returns the .NET class members. Thanks, Owen -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Wed Nov 25 17:52:52 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Wed, 25 Nov 2009 08:52:52 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <6622fe67-fc97-43f0-b6ec-4e34c4fd1ed2@tk5-exsmh-c101.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61769. MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Tests/modules/misc/_warnings_test.py $/IronPython/IronPython_Main/Src/Runtime/Microsoft.Dynamic/Runtime/AssemblyTypeNames.cs $/IronPython/IronPython_Main/Src/Scripts/generate_AssemblyTypeNames.py $/IronPython/IronPython_Main/Src/Tests/regressions.py $/IronPython/IronPython_Main/Src/Tests/test_cliclass.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1287364 Date: 11/25/2009 8:24:53 AM test_cliclass.py - CP23938 is fixed. _warnings_test.py - removed test_warnings_showwarning. (Shelveset: CP85;REDMOND\dfugate | SNAP CheckinId: 9929) From jhoward at drawloop.com Wed Nov 25 18:45:16 2009 From: jhoward at drawloop.com (Jonathan Howard) Date: Wed, 25 Nov 2009 09:45:16 -0800 (PST) Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04CFCAC3@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <4e016d67-8744-44b6-be65-daaffafa5d3c@x25g2000prf.googlegroups.com> <1A472770E042064698CB5ADC83A12ACD04CFCAC3@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <330cefb9-1b24-4b1f-bd44-06a2eadacfba@b25g2000prb.googlegroups.com> That looks like it's removing that memory leak. I'm not positive that's the one we're having in our production code, but it certainly can't hurt. On Nov 25, 5:37?am, Dino Viehland wrote: > My guess here (I'm on vacation so I haven't tried this) is that some exception info > is not getting cleared - > > ExceptionHelpers.DynamicStackFrames = null; > > In the catch block will probably fix it although we should probably > do this ourselves. > > > > > > > -----Original Message----- > > From: users-boun... at lists.ironpython.com [mailto:users- > > boun... at lists.ironpython.com] On Behalf Of Jonathan Howard > > Sent: Tuesday, November 24, 2009 4:45 PM > > To: us... at lists.ironpython.com > > Cc: jfelk... at drawloop.com > > Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 > > > I'm trying to track down a memory leak in our hosted IronPython > > application as we upgrade to 2.6 from 1.1.2. ?I saw a post at > > stackoverflow (http://stackoverflow.com/questions/1664567/embedded- > > ironpython-memory-leak > > ) showing how to set up the environment to avoid leaking memory, but > > we're still having a memory leak. ?If I take our identical setup code, > > and use it on very simple code, there's no problem, but we have > > thousands of lines of Python at this point. > > > Below is a minimum way to introduce a memory leak inside a hosted > > IronPython application. ?I don't know if it's the only way, or if it's > > what's affecting us, but it does cause a leak: ?(Obviously it needs > > the appropriate DLLs etc.) > > > ############################################# > > > using System; > > using System.Threading; > > using IronPython.Hosting; > > using IronPython.Runtime; > > using IronPython.Compiler; > > using System.Collections.Generic; > > using Microsoft.Scripting.Hosting; > > > namespace IPyTest > > { > > ? ? class Program > > ? ? { > > ? ? ? ? static void Main(string[] args) > > ? ? ? ? { > > ? ? ? ? ? ? bool cont = true; > > ? ? ? ? ? ? while (cont) > > ? ? ? ? ? ? { > > ? ? ? ? ? ? ? ? var ipy = new IPy(); > > ? ? ? ? ? ? ? ? try > > ? ? ? ? ? ? ? ? { > > ? ? ? ? ? ? ? ? ? ? // Set the below boolean to "false" to run without > > a memory leak > > ? ? ? ? ? ? ? ? ? ? // Set it to "true" to run with a memory leak. > > ? ? ? ? ? ? ? ? ? ? ipy.run(true); > > ? ? ? ? ? ? ? ? } > > ? ? ? ? ? ? ? ? catch { } > > ? ? ? ? ? ? } > > ? ? ? ? } > > ? ? } > > > ? ? class IPy > > ? ? { > > ? ? ? ? private string scriptWithoutLeak = "import random; > > random.randint(1,10)"; > > ? ? ? ? private string scriptWithLeak = "raise Exception(), 'error'"; > > > ? ? ? ? public IPy() > > ? ? ? ? { > > ? ? ? ? } > > > ? ? ? ? public void run(bool withLeak) > > ? ? ? ? { > > ? ? ? ? ? ? //set up script environment > > ? ? ? ? ? ? Dictionary options = new > > Dictionary(); > > ? ? ? ? ? ? options["LightweightScopes"] = true; > > ? ? ? ? ? ? ScriptEngine engine = Python.CreateEngine(options); > > ? ? ? ? ? ? PythonCompilerOptions pco = (PythonCompilerOptions) > > engine.GetCompilerOptions(); > > ? ? ? ? ? ? pco.Module &= ~ModuleOptions.Optimized; > > ? ? ? ? ? ? engine.SetSearchPaths(new string[]{ > > ? ? ? ? ? ? ? ? @"C:\Program Files\IronPython 2.6\Lib" > > ? ? ? ? ? ? }); > > ? ? ? ? ? ? ScriptRuntime runtime = engine.Runtime; > > ? ? ? ? ? ? ScriptScope scope = runtime.CreateScope(); > > ? ? ? ? ? ? var source = engine.CreateScriptSourceFromString( > > ? ? ? ? ? ? ? ? withLeak ? scriptWithLeak : scriptWithoutLeak > > ? ? ? ? ? ? ); > > ? ? ? ? ? ? var comped = source.Compile(); > > ? ? ? ? ? ? comped.Execute(scope); > > ? ? ? ? ? ? runtime.Shutdown(); > > ? ? ? ? } > > ? ? } > > } > > _______________________________________________ > > Users mailing list > > Us... at lists.ironpython.com > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From avinhan at gmail.com Thu Nov 26 05:37:06 2009 From: avinhan at gmail.com (Aravin) Date: Thu, 26 Nov 2009 12:37:06 +0800 Subject: [IronPython] v1.1 IronPython.CodeDom.PythonProvider In-Reply-To: <38B19FF06367EB40B888564C566676160415DE5B@emailsrv.cgy.cmgl.ca> References: <38B19FF06367EB40B888564C566676160415DE5B@emailsrv.cgy.cmgl.ca> Message-ID: <001501ca6e52$1e25fc60$5a71f520$@com> Hi Owen, As far as I know if you want to compile a python code you could use: clr.CompileModules(.). Or you could use the pyc.py provided in the IronPython2.0 Samples download. ipy.exe pyc.py /main:winforms_hw.py /target:winexe which will produce a winforms_hw.dll as well. I'm not sure if you could use these compiles assemblies from C# or VB but with Ironpython it should be possible. I'm not sure if this is what you were looking for but hope it helps. Aravin From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Owen Sigurdson Sent: Wednesday, November 25, 2009 11:23 PM To: users at lists.ironpython.com Subject: [IronPython] v1.1 IronPython.CodeDom.PythonProvider I am attempting to upgrade a component from iron python 1.1 to 2.6 that was previously using the PythonProvider to compile python code into a .NET assembly. It looks like this is no longer present in 2.6. Is this correct? Are their any plans to resurrect it? The biggest difficulty I am facing is not that we require the code to be compiled in an assembly but that reflection used to return methods in an python class. Now reflecting on a python class (that subclasses a given .NET class) only returns the .NET class members. Thanks, Owen -------------- next part -------------- An HTML attachment was scrubbed... URL: From albert.szilvasy at autodesk.com Thu Nov 26 08:13:27 2009 From: albert.szilvasy at autodesk.com (Albert Szilvasy) Date: Wed, 25 Nov 2009 23:13:27 -0800 Subject: [IronPython] IronPyton fails to query IDynamicMetaObjectProvider when looking for IEnumerable In-Reply-To: <7E540C984054DD43BE5EA92FBA96208B5E31666AF1@ADSK-NAMSG-02.MGDADSK.autodesk.com> References: <7E540C984054DD43BE5EA92FBA96208B5E31666AF1@ADSK-NAMSG-02.MGDADSK.autodesk.com> Message-ID: <155A38FD45A9BC42AACCA9C78C31748C5D57EB594C@ADSK-NAMSG-02.MGDADSK.autodesk.com> Hi there, I'm experimenting with the DLR and IronPython and I've run into a puzzling issue. 1. I have a type (ObjectId) that implements IDynamicMetaObjectProvider (written in C#). 2. My derived DynamicMetaObjectProvider implements all the plumbing so that ObjectId can be converted to IEnumerable. Given the above the following C# code works: dynamic btr = ObjectId.GetBlockTableRecord(); foreach (dynamic o in btr) o.Prop = 1; HOWEVER, the following IronPython code fails: ----- import clr clr.AddReference("Dyn.exe") import Dyn for o in Dyn.ObjectId.GetBlockTableRecord() : o.Prop = 1 ----- The error I'm getting is this: TypeError: iteration over non-sequence of type ObjectId Note that IDynamicMetaObjectProvider::GetMetaObject isn't even called by the IronPython runtime in this situation. Is this a bug? How can make IronPython query IDynamicMetaObjectProvider in this case? For you reference here's all the C# code that implements Dyn.exe: ---------------------- using System; using System.Collections.Generic; using System.Dynamic; using System.Linq.Expressions; using System.Reflection; namespace Dyn { class EnumerableProxy : System.Collections.IEnumerable { ObjectId m_id; public EnumerableProxy(ObjectId id) { m_id = id; } public System.Collections.IEnumerator GetEnumerator() { DBObject o = m_id.Open(OpenMode.ForRead); System.Collections.IEnumerator e = ((System.Collections.IEnumerable)o).GetEnumerator(); o.Close(); return e; } } class DbObjectProxy : DynamicMetaObject { public DbObjectProxy(Expression expression, ObjectId value):base(expression,BindingRestrictions.Empty, value) { } public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) { Console.WriteLine("BindUnaryOperation"); return base.BindUnaryOperation(binder); } public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg) { Console.WriteLine("BindBinaryOperation"); return base.BindBinaryOperation(binder, arg); } public override DynamicMetaObject BindConvert(ConvertBinder binder) { Console.WriteLine("BindConvert"); var id = (ObjectId)base.Value; Type enumerable = id.Type.GetInterface("System.Collections.IEnumerable"); if (enumerable==null) return base.BindConvert(binder); //new EnumarableProxy(id); var exp = Expression.New(typeof(EnumerableProxy).GetConstructor(new Type[] { typeof(ObjectId) }), new Expression[] { Expression.Convert(base.Expression, typeof(ObjectId)) }); var restr = BindingRestrictions.GetTypeRestriction(base.Expression, typeof(ObjectId)); return new DynamicMetaObject(exp, restr); } public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindCreateInstance"); return base.BindCreateInstance(binder, args); } public override DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes) { Console.WriteLine("BindDeleteIndex"); return base.BindDeleteIndex(binder, indexes); } public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { Console.WriteLine("BindDeleteMember"); return base.BindDeleteMember(binder); } public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes) { Console.WriteLine("BindGetIndex"); var id = (ObjectId)base.Value; return CreateWrapper( Expression.MakeIndex(Expression.Convert(obj, id.Type), id.Type.GetProperty("Item"), new Expression[] { indexes[0].Expression }), OpenMode.ForRead); } public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindInvoke"); return base.BindInvoke(binder, args); } public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindInvokeMember"); return base.BindInvokeMember(binder, args); } public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) { Console.WriteLine("BindSetIndex"); var id = (ObjectId)base.Value; return CreateWrapper(Expression.Assign( Expression.MakeIndex(Expression.Convert(obj, id.Type), id.Type.GetProperty("Item"), new Expression[] { indexes[0].Expression }), value.Expression),OpenMode.ForWrite); } static ParameterExpression obj = Expression.Variable(typeof(DBObject), "obj"); DynamicMetaObject CreateWrapper(Expression body, OpenMode openMode) { Console.WriteLine("CreateWrapper {0}", body); var self = Expression.Convert(this.Expression, typeof(ObjectId)); /* DBObject obj = id.Open(); bool commit = false; try { retValue = commit = true; } finally { if (commit) obj.Close(); else obj.Cancel(); } (object)retValue; */ var commit = Expression.Variable(typeof(bool), "commit"); var retValue = Expression.Variable(body.Type, "retValue"); var target = Expression.Block( new ParameterExpression[] {obj, commit, retValue}, Expression.Assign( obj, Expression.Call(self, typeof(ObjectId).GetMethod("Open",BindingFlags.Instance | BindingFlags.NonPublic), Expression.Constant(openMode)) ), Expression.Assign(commit,Expression.Constant(false)), Expression.TryFinally( Expression.Block( Expression.Assign(retValue,body), Expression.Assign(commit,Expression.Constant(true)) ), Expression.IfThenElse(commit, Expression.Call(obj, typeof(DBObject).GetMethod("Close")), Expression.Call(obj, typeof(DBObject).GetMethod("Cancel"))) ) , Expression.Convert(retValue, typeof(object)) ); var id = (ObjectId)base.Value; var restrictions = BindingRestrictions.GetExpressionRestriction( Expression.Equal( Expression.MakeMemberAccess(self, typeof(ObjectId).GetProperty("Type")), Expression.Constant(id.Type)) ); return new DynamicMetaObject(target, restrictions); } public override DynamicMetaObject BindGetMember(GetMemberBinder binder) { Console.WriteLine("BindGetMember"); var id = (ObjectId)base.Value; return CreateWrapper( Expression.MakeMemberAccess(Expression.Convert(obj, id.Type), id.Type.GetProperty(binder.Name)), OpenMode.ForRead); } public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value) { Console.WriteLine("BindSetMember"); var id = (ObjectId)base.Value; return CreateWrapper(Expression.Assign( Expression.MakeMemberAccess(Expression.Convert(obj, id.Type), id.Type.GetProperty(binder.Name)), value.Expression),OpenMode.ForWrite); } public override IEnumerable GetDynamicMemberNames() { Console.WriteLine("GetDynamicMemberNames"); return base.GetDynamicMemberNames(); } } enum OpenMode { ForWrite, ForRead } class DBObject { public void Close() { Console.WriteLine("DBObject.Close()"); } public void Cancel() { Console.WriteLine("DBObject.Cancel()"); } } class Line : DBObject { int m_prop2; public int Prop { get { Console.WriteLine("Line.Prop.get()"); return m_prop2; } set { Console.WriteLine("Line.Prop.set()"); m_prop2 = value; } } } class BlockTableRecord : DBObject, System.Collections.IEnumerable { public System.Collections.IEnumerator GetEnumerator() { for (int i = 0; i < 5; i++) { yield return new ObjectId(typeof(Line)); } } int m_indexer; public int this[string val] { get { return m_indexer; } set { m_indexer = value; } } } public struct ObjectId : IDynamicMetaObjectProvider { int m_id; static Dictionary handleTable = new Dictionary(); public ObjectId(Type type) { DBObject obj = (DBObject)Activator.CreateInstance(type); m_id = obj.GetHashCode(); handleTable.Add(m_id, obj); } internal DBObject Open(OpenMode mode) { Console.WriteLine("ObjectId.Open({0})", mode); return handleTable[m_id]; } public Type Type { get { return handleTable[m_id].GetType(); } } public DynamicMetaObject GetMetaObject(Expression parameter) { Console.WriteLine("ObjectId.GetMetaObject({0})",parameter); return new DbObjectProxy(parameter, this); } public static ObjectId GetBlockTableRecord() { return new ObjectId(typeof(BlockTableRecord)); } public static ObjectId GetLine() { return new ObjectId(typeof(Line)); } } class Program { static void Main(string[] args) { dynamic btr = ObjectId.GetBlockTableRecord(); foreach (dynamic o in btr) { o.Prop = 1; } } } } --------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From merllab at microsoft.com Thu Nov 26 17:53:41 2009 From: merllab at microsoft.com (merllab at microsoft.com) Date: Thu, 26 Nov 2009 08:53:41 -0800 Subject: [IronPython] IronPython 2.6 CodePlex Source Update Message-ID: <67d27b5b-1652-4d71-a261-46efb48c8e21@tk5-exsmh-c102.redmond.corp.microsoft.com> This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/61784. MODIFIED SOURCES $/IronPython/IronPython_Main/Src/Tests/interop/net/test_accessibility.py CHECKIN COMMENTS -------------------------------------------------------------------------------- Changeset Id: 1288117 Date: 11/25/2009 3:10:29 PM test_accessibility.py - CP24106 not really fixed. (Shelveset: CP86;REDMOND\dfugate | SNAP CheckinId: 9940) From albert.szilvasy at autodesk.com Thu Nov 26 19:39:42 2009 From: albert.szilvasy at autodesk.com (Albert Szilvasy) Date: Thu, 26 Nov 2009 10:39:42 -0800 Subject: [IronPython] IronPyton fails to query IDynamicMetaObjectProvider when looking for IEnumerable In-Reply-To: <155A38FD45A9BC42AACCA9C78C31748C5D57EB594C@ADSK-NAMSG-02.MGDADSK.autodesk.com> References: <7E540C984054DD43BE5EA92FBA96208B5E31666AF1@ADSK-NAMSG-02.MGDADSK.autodesk.com> <155A38FD45A9BC42AACCA9C78C31748C5D57EB594C@ADSK-NAMSG-02.MGDADSK.autodesk.com> Message-ID: <155A38FD45A9BC42AACCA9C78C31748C5D57EB5BB8@ADSK-NAMSG-02.MGDADSK.autodesk.com> Ok. I got the latest source from codeplex to investigate this a bit. I understand why it doesn't work and I suspect this is a "bug" but I would love to hear what others say. So, things go south in PythonConversionBinder.Bind method. It has code like this: IPythonConvertible convertible = target as IPythonConvertible; if (convertible != null) { res = convertible.BindConvert(this); } else if (res == null) { res = FallbackConvert(self); } Of course, my DynamicMetaObject does not implement IPythonConvertible and this code falls back immediately instead of calling DynamicMetaObject.BindConvert. I quickly fixed this on my machine by adding a ConvertBinder like this: class PythonConvertBinder : ConvertBinder { PythonConversionBinder m_real; public PythonConvertBinder(PythonConversionBinder real) : base(real.Type, true) { m_real = real; } public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion) { return m_real.FallbackConvert(target); } } And modifying the above code like so: IPythonConvertible convertible = target as IPythonConvertible; if (convertible != null) { res = convertible.BindConvert(this); } else if (res == null) { res = target.BindConvert(new PythonConvertBinder(this)); } I doubt that this is the "right fix" but it demonstrates the nature of the problem. Albert From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Albert Szilvasy Sent: Wednesday, November 25, 2009 11:13 PM To: 'users at lists.ironpython.com' Subject: [IronPython] IronPyton fails to query IDynamicMetaObjectProvider when looking for IEnumerable Hi there, I'm experimenting with the DLR and IronPython and I've run into a puzzling issue. 1. I have a type (ObjectId) that implements IDynamicMetaObjectProvider (written in C#). 2. My derived DynamicMetaObjectProvider implements all the plumbing so that ObjectId can be converted to IEnumerable. Given the above the following C# code works: dynamic btr = ObjectId.GetBlockTableRecord(); foreach (dynamic o in btr) o.Prop = 1; HOWEVER, the following IronPython code fails: ----- import clr clr.AddReference("Dyn.exe") import Dyn for o in Dyn.ObjectId.GetBlockTableRecord() : o.Prop = 1 ----- The error I'm getting is this: TypeError: iteration over non-sequence of type ObjectId Note that IDynamicMetaObjectProvider::GetMetaObject isn't even called by the IronPython runtime in this situation. Is this a bug? How can make IronPython query IDynamicMetaObjectProvider in this case? For you reference here's all the C# code that implements Dyn.exe: ---------------------- using System; using System.Collections.Generic; using System.Dynamic; using System.Linq.Expressions; using System.Reflection; namespace Dyn { class EnumerableProxy : System.Collections.IEnumerable { ObjectId m_id; public EnumerableProxy(ObjectId id) { m_id = id; } public System.Collections.IEnumerator GetEnumerator() { DBObject o = m_id.Open(OpenMode.ForRead); System.Collections.IEnumerator e = ((System.Collections.IEnumerable)o).GetEnumerator(); o.Close(); return e; } } class DbObjectProxy : DynamicMetaObject { public DbObjectProxy(Expression expression, ObjectId value):base(expression,BindingRestrictions.Empty, value) { } public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) { Console.WriteLine("BindUnaryOperation"); return base.BindUnaryOperation(binder); } public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg) { Console.WriteLine("BindBinaryOperation"); return base.BindBinaryOperation(binder, arg); } public override DynamicMetaObject BindConvert(ConvertBinder binder) { Console.WriteLine("BindConvert"); var id = (ObjectId)base.Value; Type enumerable = id.Type.GetInterface("System.Collections.IEnumerable"); if (enumerable==null) return base.BindConvert(binder); //new EnumarableProxy(id); var exp = Expression.New(typeof(EnumerableProxy).GetConstructor(new Type[] { typeof(ObjectId) }), new Expression[] { Expression.Convert(base.Expression, typeof(ObjectId)) }); var restr = BindingRestrictions.GetTypeRestriction(base.Expression, typeof(ObjectId)); return new DynamicMetaObject(exp, restr); } public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindCreateInstance"); return base.BindCreateInstance(binder, args); } public override DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes) { Console.WriteLine("BindDeleteIndex"); return base.BindDeleteIndex(binder, indexes); } public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { Console.WriteLine("BindDeleteMember"); return base.BindDeleteMember(binder); } public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes) { Console.WriteLine("BindGetIndex"); var id = (ObjectId)base.Value; return CreateWrapper( Expression.MakeIndex(Expression.Convert(obj, id.Type), id.Type.GetProperty("Item"), new Expression[] { indexes[0].Expression }), OpenMode.ForRead); } public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindInvoke"); return base.BindInvoke(binder, args); } public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindInvokeMember"); return base.BindInvokeMember(binder, args); } public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) { Console.WriteLine("BindSetIndex"); var id = (ObjectId)base.Value; return CreateWrapper(Expression.Assign( Expression.MakeIndex(Expression.Convert(obj, id.Type), id.Type.GetProperty("Item"), new Expression[] { indexes[0].Expression }), value.Expression),OpenMode.ForWrite); } static ParameterExpression obj = Expression.Variable(typeof(DBObject), "obj"); DynamicMetaObject CreateWrapper(Expression body, OpenMode openMode) { Console.WriteLine("CreateWrapper {0}", body); var self = Expression.Convert(this.Expression, typeof(ObjectId)); /* DBObject obj = id.Open(); bool commit = false; try { retValue = commit = true; } finally { if (commit) obj.Close(); else obj.Cancel(); } (object)retValue; */ var commit = Expression.Variable(typeof(bool), "commit"); var retValue = Expression.Variable(body.Type, "retValue"); var target = Expression.Block( new ParameterExpression[] {obj, commit, retValue}, Expression.Assign( obj, Expression.Call(self, typeof(ObjectId).GetMethod("Open",BindingFlags.Instance | BindingFlags.NonPublic), Expression.Constant(openMode)) ), Expression.Assign(commit,Expression.Constant(false)), Expression.TryFinally( Expression.Block( Expression.Assign(retValue,body), Expression.Assign(commit,Expression.Constant(true)) ), Expression.IfThenElse(commit, Expression.Call(obj, typeof(DBObject).GetMethod("Close")), Expression.Call(obj, typeof(DBObject).GetMethod("Cancel"))) ) , Expression.Convert(retValue, typeof(object)) ); var id = (ObjectId)base.Value; var restrictions = BindingRestrictions.GetExpressionRestriction( Expression.Equal( Expression.MakeMemberAccess(self, typeof(ObjectId).GetProperty("Type")), Expression.Constant(id.Type)) ); return new DynamicMetaObject(target, restrictions); } public override DynamicMetaObject BindGetMember(GetMemberBinder binder) { Console.WriteLine("BindGetMember"); var id = (ObjectId)base.Value; return CreateWrapper( Expression.MakeMemberAccess(Expression.Convert(obj, id.Type), id.Type.GetProperty(binder.Name)), OpenMode.ForRead); } public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value) { Console.WriteLine("BindSetMember"); var id = (ObjectId)base.Value; return CreateWrapper(Expression.Assign( Expression.MakeMemberAccess(Expression.Convert(obj, id.Type), id.Type.GetProperty(binder.Name)), value.Expression),OpenMode.ForWrite); } public override IEnumerable GetDynamicMemberNames() { Console.WriteLine("GetDynamicMemberNames"); return base.GetDynamicMemberNames(); } } enum OpenMode { ForWrite, ForRead } class DBObject { public void Close() { Console.WriteLine("DBObject.Close()"); } public void Cancel() { Console.WriteLine("DBObject.Cancel()"); } } class Line : DBObject { int m_prop2; public int Prop { get { Console.WriteLine("Line.Prop.get()"); return m_prop2; } set { Console.WriteLine("Line.Prop.set()"); m_prop2 = value; } } } class BlockTableRecord : DBObject, System.Collections.IEnumerable { public System.Collections.IEnumerator GetEnumerator() { for (int i = 0; i < 5; i++) { yield return new ObjectId(typeof(Line)); } } int m_indexer; public int this[string val] { get { return m_indexer; } set { m_indexer = value; } } } public struct ObjectId : IDynamicMetaObjectProvider { int m_id; static Dictionary handleTable = new Dictionary(); public ObjectId(Type type) { DBObject obj = (DBObject)Activator.CreateInstance(type); m_id = obj.GetHashCode(); handleTable.Add(m_id, obj); } internal DBObject Open(OpenMode mode) { Console.WriteLine("ObjectId.Open({0})", mode); return handleTable[m_id]; } public Type Type { get { return handleTable[m_id].GetType(); } } public DynamicMetaObject GetMetaObject(Expression parameter) { Console.WriteLine("ObjectId.GetMetaObject({0})",parameter); return new DbObjectProxy(parameter, this); } public static ObjectId GetBlockTableRecord() { return new ObjectId(typeof(BlockTableRecord)); } public static ObjectId GetLine() { return new ObjectId(typeof(Line)); } } class Program { static void Main(string[] args) { dynamic btr = ObjectId.GetBlockTableRecord(); foreach (dynamic o in btr) { o.Prop = 1; } } } } --------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From pavel.suhotjuk at gmail.com Fri Nov 27 12:09:35 2009 From: pavel.suhotjuk at gmail.com (Pavel Suhotyuk) Date: Fri, 27 Nov 2009 13:09:35 +0200 Subject: [IronPython] Web Services library Message-ID: <4B0FB36F.4020801@gmail.com> Hello. What a client library you recomend for using WebServices with IronPython ( something like SOAP.PY ) ? From vernondcole at gmail.com Sun Nov 29 03:34:25 2009 From: vernondcole at gmail.com (Vernon Cole) Date: Sat, 28 Nov 2009 19:34:25 -0700 Subject: [IronPython] Poll: split of adodbapi.py into two modules? (django support) Message-ID: This is a feature poll. It will be cross posted on both the IronPython and pyWin32 groups. Please answer if you have strong feelings either way on this.... Introduction: I am now working on a new version (2.3.0) of adodbapi which is intended to have all of the features needed to interoperate with django. This should be a significant step forward to two projects: 1) MS SQL database support for django. 2) running django on IronPython. As the old saying goes: "Killing two birds with one stone." I order to accomplish this, I am taking some of the significant changes made to an earlier (non-IronPython) version of adodbapi and merging them into the current (IronPython compatible) version. This includes the changes needed to make adodbapi work with 'format' paramstyle, which django expects, as an option to the native 'qmark' paramstyle. In performing this Hurculan labor, Adam Vandenberg made some badly needed cleanups to the code. His work makes the module much more readable and easier to understand. Thank you, Adam! One of the changes Adam made was to remove dozens of lines defining various ADO constants from adodbapi.py and place them in another file, ado_consts.py. I really like the change, both because it takes the bloat out of adodbapi, and it makes the constants accessible to other uses: >>> ado_consts.adLongVarWChar 203 >>> ado_consts.ado_type_name(203) 'adLongVarWChar' >>> This will break code which expects some of these constants to be attributes of adodbapi, such as 'adUseClient' and 'adXactBrowse'. Question: Should I proceed to use the separate version of ado_consts, even though it might break some existing programs? -- Vernon Cole -------------- next part -------------- An HTML attachment was scrubbed... URL: From tony.meyer at gmail.com Sun Nov 29 04:19:39 2009 From: tony.meyer at gmail.com (Tony Meyer) Date: Sun, 29 Nov 2009 16:19:39 +1300 Subject: [IronPython] Poll: split of adodbapi.py into two modules? (django support) In-Reply-To: References: Message-ID: <6c63de570911281919m72408edcv98ac2f40a2d4f0f3@mail.gmail.com> On Sun, Nov 29, 2009 at 3:34 PM, Vernon Cole wrote: > One of the changes Adam made was to remove dozens of lines defining various > ADO constants from adodbapi.py and place them in > another file, ado_consts.py. [...] > This will break code which expects some of these constants to be attributes > of adodbapi, such as 'adUseClient' and 'adXactBrowse'. I'm not familiar with adodbapi, but couldn't you put "from ado_consts import *" at the top of adodbapi and have everything still work? (Or better, but much more work, import adodbapi, and then expose each of the constants via a DeprecationWarning-raising object). Cheers, Tony From andy.sy at neotitans.com Sun Nov 29 10:58:09 2009 From: andy.sy at neotitans.com (Andy Sy) Date: Sun, 29 Nov 2009 17:58:09 +0800 Subject: [IronPython] Where is Application.LoadRootVisual() documented? Message-ID: <4B1245B1.1070100@neotitans.com> Silverlight Iron Python examples show the following method to load an external XAML file: Application.Current.LoadRootVisual(ControlName(),"blah.xaml") Trouble is, I don't see LoadRootVisual() referred to in the Silverlight API reference. Is this IronPython specific and if so, is there a reference document that lists all such functions? From Jimmy.Schementi at microsoft.com Sun Nov 29 14:48:37 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sun, 29 Nov 2009 13:48:37 +0000 Subject: [IronPython] Where is Application.LoadRootVisual() documented? In-Reply-To: <4B1245B1.1070100@neotitans.com> References: <4B1245B1.1070100@neotitans.com> Message-ID: <474EB1E2-2B23-40B6-88AB-47E749B2C90E@microsoft.com> Application.Current.LoadRootVisual is IronPython-specific; Application.Current is an instance of Microsoft.Scripting.Silverlight.DynamicApplication, which exists in Microsft.Scripting.Silverlight.dll. Your best option for API docs is to look at the doc comments in the source code (http://ironpython.codeplex.com/sourcecontrol/changeset/view/61784?projectName=IronPython#992037 ... then navigate to ironPython 2.6, Src, Hosts, Silverlight, Microsoft.Scripting.Silverlight, DynmicApplication.cs). Documentation is lacking in general because we don't have a good place to put it; however the new ironpython website will be up shortly, which will include documentation for this. ~Jimmy Sent from my phone On Nov 29, 2009, at 4:50 AM, "Andy Sy" wrote: > Silverlight Iron Python examples show the following method > to load an external XAML file: > > Application.Current.LoadRootVisual(ControlName(),"blah.xaml") > > Trouble is, I don't see LoadRootVisual() referred to in the > Silverlight API reference. Is this IronPython specific and > if so, is there a reference document that lists all such > functions? > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From fuzzyman at voidspace.org.uk Sun Nov 29 21:30:50 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 29 Nov 2009 20:30:50 +0000 Subject: [IronPython] IronPython Training in New York, January 21st 2010 Message-ID: <4B12D9FA.8060204@voidspace.org.uk> Hello all, In association with Holdenweb Training [1] I'll be doing some IronPython training in New York in January (21st). The course is called "IronPython from the Ground Up": http://hwebipmc01.eventbrite.com/ Course details: Michael Foord is an early adopter of IronPython, having used it for (among other things) the creation of the Resolver One Python-driven spreadsheet product. He is the author of Manning's IronPython in Action and a well-known speaker at Python conferences throughout the world. IronPython is the implementation of Python for the .NET framework and Mono. IronPython combines the power of the .NET framework with the expressiveness and flexibility of the Python programming language. In this workshop you'll get hands on experience with using IronPython: from the basics of integrating with the framework assemblies and classes to embedding IronPython in .NET applications. This workshop is aimed at .NET developers with an interest in IronPython, and Python developers interested in IronPython. We'll cover how IronPython integrates with the .NET framework, including some of the tricky details that previous experience of Python or C# alone won't have prepared you for. We'll also be covering the IronPython hosting APIs and how to embed IronPython. Reasons you might want to consider IronPython include: * Using Python libraries from .NET * Using .NET libraries from Python * Writing multi-threaded Python code without a GIL * Embedding IronPython in .NET applications for user scripting * Exploring new assemblies and classes with the interactive interpreter * System administration and scripting * Developing for Silverlight (Python in the browser) Previous programming experience of Python is assumed, but no specific experience with Python or .NET is required. Places are limited, so reserve yours straight away. Course Outline The Interactive Interpreter Getting started with IronPython, basic .NET integration, executing IronPython scripts. Using the interactive interpreter as a tool to explore live assemblies and classes. IronPython for Python Developers Why should a Python developer be interested in IronPython? From multithreading without a GIL, to multiple and sandboxed Python engines, to native user interface libraries (plural!) on Windows or even cross platform development with Mono; we'll be looking at some of what the .NET framework and IronPython has to offer Python developers. Python for .NET Developers A whirlwind guide to Python syntax and the wonders of dynamic languages for .NET programmers. Tools and IDEs A rundown of the options for developing with IronPython and the different IDEs available, including their different capabilities. Application Development with IronPython Using Python and .NET libraries to build applications with IronPython. From simple scripting system administration tasks, to web applications to desktop applications. Using Ironclad for compatibility with Python C extensions, using the Python standard library and working with the .NET framework. Advanced .NET Integration Using a dynamic language on a statically typed framework. Many of the features of the .NET framework require specialised knowledge to use them from IronPython; including making use of new features in IronPython 2.6 like the __clrtype__ metaclass. Embedding IronPython and the IronPython Compliler Using the IronPython hosting API for embedding in .NET applications. This can be used for creating hybrid applications with parts in C# and user scripting. With Pyc the compiler tool it can also be used for deploying IronPython applications as binary form. We'll also see how .NET 4 makes interacting with IronPython and the Dynamic Language Runtime simpler from C#. Python in the Browser with Silverlight The basics of creating a Silverlight application with IronPython and the development process. Plus an overview of the APIs available in Silverlight; for building user interfaces, making web requests, and interacting with Javascript and the browser DOM. There will also be plenty of time for Q&A throughout the session. All the best, Michael Foord [1] http://holdenweb.com/py/training/ -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From pavel.suhotjuk at gmail.com Mon Nov 30 11:37:30 2009 From: pavel.suhotjuk at gmail.com (Pavel Suhotyuk) Date: Mon, 30 Nov 2009 12:37:30 +0200 Subject: [IronPython] Using ruby module from python. Message-ID: <4B13A06A.7040601@gmail.com> Hello. I want try to use ruby library (soap) in python code. I found method Use(str) in clr module for load the specified module searching all languages in the loaded ScriptRuntime, but don't understand how to used it. I try to call this method in any variants, but nothing happends. >>> import clr >>> clr.Use('soap/wsdlDriver') Traceback (most recent call last): File "", line 1, in ValueError: couldn't find module soap/wsdlDriver to use >>> clr.Use('soap.wsdlDriver') Traceback (most recent call last): File "", line 1, in ValueError: couldn't find module soap.wsdlDriver to use >>> clr.Use('soap/wsdlDriver.rb') Traceback (most recent call last): File "", line 1, in ValueError: couldn't find module soap/wsdlDriver.rb to use >>> clr.Use(r'''C:\usr\env\IronRuby\lib\ruby\1.8\soap\wsdlDriver.rb''', 'rb') >>> m = clr.Use(r'''C:\usr\env\IronRuby\lib\ruby\1.8\soap\wsdlDriver.rb''', 'rb') >>> m >>> dir(m) ['__builtins__'] Thanks. From Tomas.Matousek at microsoft.com Mon Nov 30 18:47:53 2009 From: Tomas.Matousek at microsoft.com (Tomas Matousek) Date: Mon, 30 Nov 2009 17:47:53 +0000 Subject: [IronPython] Using ruby module from python. In-Reply-To: <4B13A06A.7040601@gmail.com> References: <4B13A06A.7040601@gmail.com> Message-ID: <4B342496A3EFEB48839E10BB4BF5964C1826E1FB@TK5EX14MBXC129.redmond.corp.microsoft.com> Our Python-Ruby interop is not quite done yet so you need to use some workarounds. The easiest way how to get WSDL factory instance would be to write a simple Ruby script that loads it: == wsdl.rb == require 'soap/wsdlDriver' def get_factory SOAP::WSDLDriverFactory end === And then you can do: >>> import clr >>> wsdl = clr.Use('wsdl.rb', 'rb') >>> factory = wsdl.get_factory() >>> print factory("x.wsdl") Traceback (most recent call last): File "", line 1, in SystemError: Cannot connect to x.wsdl (Not HTTP.) get_factory method is exposed on the "wsdl" module so that Python can call it. IronRuby doesn't yet implement dynamic protocols for constant access so you need the get_factory helper for accessing Ruby constants. Also we have some work to do to make clr.Use work better with libraries of other DLR languages. Let us know if you hit some other issues. Tomas -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Pavel Suhotyuk Sent: Monday, November 30, 2009 2:38 AM To: Discussion of IronPython Subject: [IronPython] Using ruby module from python. Hello. I want try to use ruby library (soap) in python code. I found method Use(str) in clr module for load the specified module searching all languages in the loaded ScriptRuntime, but don't understand how to used it. I try to call this method in any variants, but nothing happends. >>> import clr >>> clr.Use('soap/wsdlDriver') Traceback (most recent call last): File "", line 1, in ValueError: couldn't find module soap/wsdlDriver to use >>> clr.Use('soap.wsdlDriver') Traceback (most recent call last): File "", line 1, in ValueError: couldn't find module soap.wsdlDriver to use >>> clr.Use('soap/wsdlDriver.rb') Traceback (most recent call last): File "", line 1, in ValueError: couldn't find module soap/wsdlDriver.rb to use >>> clr.Use(r'''C:\usr\env\IronRuby\lib\ruby\1.8\soap\wsdlDriver.rb''', 'rb') >>> m = clr.Use(r'''C:\usr\env\IronRuby\lib\ruby\1.8\soap\wsdlDriver.rb''', 'rb') >>> m >>> dir(m) ['__builtins__'] Thanks. _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From steve at mcneel.com Mon Nov 30 19:08:00 2009 From: steve at mcneel.com (Steve Baer) Date: Mon, 30 Nov 2009 10:08:00 -0800 Subject: [IronPython] Treat struct as tuple Message-ID: Say you have a .NET struct for something like a 3D point public struct Point3d { private double m_x, m_y, m_z; public double X{ get {return m_x;} set {m_x = value;} } public double Y{ get {return m_y;} set {m_y = value;} } public double Z{ get {return m_z;} set {m_z = value;} } // more functions... } We have a user that wants to treat this struct like a tuple of 3 values in IronPython so he can do things like pt = Point3d(1,2,3) for a in pt: print a -or- pass pt to a function that expects a tuple. I recommended that the user write a function to coerce the struct to a tuple def coerceTuple( pt ): return [pt.X, pt.Y, pt.Z] The user said this works, but would like to have something a bit cleaner. Do any of you guys suggestions about what I could do to make our Point3d struct more "python friendly"? Thanks, -Steve Steve Baer Robert McNeel & Associates www.rhino3d.com www.mcneel.com From dinov at microsoft.com Mon Nov 30 19:35:31 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 30 Nov 2009 18:35:31 +0000 Subject: [IronPython] Treat struct as tuple In-Reply-To: References: Message-ID: <1A472770E042064698CB5ADC83A12ACD04D1FAB9@TK5EX14MBXC118.redmond.corp.microsoft.com> You could do something like the code below. This is an example of an extension method on DateTime which enables indexing for read-only access to a couple of attributes. You could also define methods like __iter__ so the iteration will work (although it should work w/ just __getitem__), __repr__ so that print will work more reasonable, and you should be able to do define "PythonTuple ConvertToPythonTuple(Point3D point)" w/ [SpecialName, ImplicitConversionMethod] attributes to get the ability to pass to something which expects a tuple. The last one may not work as consistently as one would like though. using System; using IronPython.Hosting; using IronPython.Runtime; using IronPython.Runtime.Operations; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; using IronPython.Runtime.Exceptions; using System.Runtime.CompilerServices; using Microsoft.Scripting.Runtime; [assembly: ExtensionType(typeof(DateTime), typeof(DateTimeExtensions))] public class DateTimeExtensions { [SpecialName, ImplicitConversionMethodAttribute] public static object __getitem__(DateTime dt, int index) { switch(index) { case 0: return dt.Hour; case 1: return dt.Second; default: throw new NotImplementedException(); } } } class Foo { private static ScriptEngine pe; private static ScriptScope scope; public static void Main(string[] args){ pe = Python.CreateEngine(); pe.Runtime.LoadAssembly(typeof(DateTimeExtensions).Assembly); scope = pe.CreateScope(); scope.SetVariable("test", DateTime.Now); pe.Execute(@"print test[0]", scope); } } > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Steve Baer > Sent: Monday, November 30, 2009 10:08 AM > To: Users at lists.ironpython.com > Subject: [IronPython] Treat struct as tuple > > Say you have a .NET struct for something like a 3D point > public struct Point3d > { > private double m_x, m_y, m_z; > public double X{ get {return m_x;} set {m_x = value;} } > public double Y{ get {return m_y;} set {m_y = value;} } > public double Z{ get {return m_z;} set {m_z = value;} } > // more functions... > } > > We have a user that wants to treat this struct like a tuple of 3 values in > IronPython so he can do things like > pt = Point3d(1,2,3) > for a in pt: > print a > -or- > pass pt to a function that expects a tuple. > > I recommended that the user write a function to coerce the struct to a tuple > def coerceTuple( pt ): > return [pt.X, pt.Y, pt.Z] > > The user said this works, but would like to have something a bit cleaner. Do > any of you guys suggestions about what I could do to make our Point3d struct > more "python friendly"? > > Thanks, > -Steve > > Steve Baer > Robert McNeel & Associates > www.rhino3d.com > www.mcneel.com > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at microsoft.com Mon Nov 30 20:16:19 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 30 Nov 2009 19:16:19 +0000 Subject: [IronPython] v1.1 IronPython.CodeDom.PythonProvider In-Reply-To: <001501ca6e52$1e25fc60$5a71f520$@com> References: <38B19FF06367EB40B888564C566676160415DE5B@emailsrv.cgy.cmgl.ca> <001501ca6e52$1e25fc60$5a71f520$@com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04D1FEDD@TK5EX14MBXC118.redmond.corp.microsoft.com> Just to comment on this - pyc has always behaved quite differently then how the CodeDom compilation support worked. The CodeCom compilation support in particular was a hack so that we could support ASP.NET as it usually behaves. It was also fairly buggy and we didn't bring it forward to 2.6. The big difference between the two is that pyc produces code which IronPython can load while CodeDom produced a .NET assembly with specific types declared in specific namespaces based upon how the code was laid out. You could then load this assembly and instantiate those types and they'd still behave like Python types. If we brought this back I think we'd want to do a better job on it then we did in 1.x and it'd be a fair amount of work. Feel free to file a feature request on CodePlex and have people vote on it if there's general interest in seeing it again. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Aravin Sent: Wednesday, November 25, 2009 8:37 PM To: 'Discussion of IronPython' Subject: Re: [IronPython] v1.1 IronPython.CodeDom.PythonProvider Hi Owen, As far as I know if you want to compile a python code you could use: clr.CompileModules(...). Or you could use the pyc.py provided in the IronPython2.0 Samples download. ipy.exe pyc.py /main:winforms_hw.py /target:winexe which will produce a winforms_hw.dll as well. I'm not sure if you could use these compiles assemblies from C# or VB but with Ironpython it should be possible. I'm not sure if this is what you were looking for but hope it helps. Aravin From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Owen Sigurdson Sent: Wednesday, November 25, 2009 11:23 PM To: users at lists.ironpython.com Subject: [IronPython] v1.1 IronPython.CodeDom.PythonProvider I am attempting to upgrade a component from iron python 1.1 to 2.6 that was previously using the PythonProvider to compile python code into a .NET assembly. It looks like this is no longer present in 2.6. Is this correct? Are their any plans to resurrect it? The biggest difficulty I am facing is not that we require the code to be compiled in an assembly but that reflection used to return methods in an python class. Now reflecting on a python class (that subclasses a given .NET class) only returns the .NET class members. Thanks, Owen -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Mon Nov 30 20:21:22 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 30 Nov 2009 19:21:22 +0000 Subject: [IronPython] IronPyton fails to query IDynamicMetaObjectProvider when looking for IEnumerable In-Reply-To: <155A38FD45A9BC42AACCA9C78C31748C5D57EB5BB8@ADSK-NAMSG-02.MGDADSK.autodesk.com> References: <7E540C984054DD43BE5EA92FBA96208B5E31666AF1@ADSK-NAMSG-02.MGDADSK.autodesk.com> <155A38FD45A9BC42AACCA9C78C31748C5D57EB594C@ADSK-NAMSG-02.MGDADSK.autodesk.com> <155A38FD45A9BC42AACCA9C78C31748C5D57EB5BB8@ADSK-NAMSG-02.MGDADSK.autodesk.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04D1FF1D@TK5EX14MBXC118.redmond.corp.microsoft.com> You're right that we should be letting the object bind at some point. We should be using our CompatConversionBinder for this but it looks like we only use that for COM. I've opened this bug: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25477 From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Albert Szilvasy Sent: Thursday, November 26, 2009 10:40 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPyton fails to query IDynamicMetaObjectProvider when looking for IEnumerable Ok. I got the latest source from codeplex to investigate this a bit. I understand why it doesn't work and I suspect this is a "bug" but I would love to hear what others say. So, things go south in PythonConversionBinder.Bind method. It has code like this: IPythonConvertible convertible = target as IPythonConvertible; if (convertible != null) { res = convertible.BindConvert(this); } else if (res == null) { res = FallbackConvert(self); } Of course, my DynamicMetaObject does not implement IPythonConvertible and this code falls back immediately instead of calling DynamicMetaObject.BindConvert. I quickly fixed this on my machine by adding a ConvertBinder like this: class PythonConvertBinder : ConvertBinder { PythonConversionBinder m_real; public PythonConvertBinder(PythonConversionBinder real) : base(real.Type, true) { m_real = real; } public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion) { return m_real.FallbackConvert(target); } } And modifying the above code like so: IPythonConvertible convertible = target as IPythonConvertible; if (convertible != null) { res = convertible.BindConvert(this); } else if (res == null) { res = target.BindConvert(new PythonConvertBinder(this)); } I doubt that this is the "right fix" but it demonstrates the nature of the problem. Albert From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Albert Szilvasy Sent: Wednesday, November 25, 2009 11:13 PM To: 'users at lists.ironpython.com' Subject: [IronPython] IronPyton fails to query IDynamicMetaObjectProvider when looking for IEnumerable Hi there, I'm experimenting with the DLR and IronPython and I've run into a puzzling issue. 1. I have a type (ObjectId) that implements IDynamicMetaObjectProvider (written in C#). 2. My derived DynamicMetaObjectProvider implements all the plumbing so that ObjectId can be converted to IEnumerable. Given the above the following C# code works: dynamic btr = ObjectId.GetBlockTableRecord(); foreach (dynamic o in btr) o.Prop = 1; HOWEVER, the following IronPython code fails: ----- import clr clr.AddReference("Dyn.exe") import Dyn for o in Dyn.ObjectId.GetBlockTableRecord() : o.Prop = 1 ----- The error I'm getting is this: TypeError: iteration over non-sequence of type ObjectId Note that IDynamicMetaObjectProvider::GetMetaObject isn't even called by the IronPython runtime in this situation. Is this a bug? How can make IronPython query IDynamicMetaObjectProvider in this case? For you reference here's all the C# code that implements Dyn.exe: ---------------------- using System; using System.Collections.Generic; using System.Dynamic; using System.Linq.Expressions; using System.Reflection; namespace Dyn { class EnumerableProxy : System.Collections.IEnumerable { ObjectId m_id; public EnumerableProxy(ObjectId id) { m_id = id; } public System.Collections.IEnumerator GetEnumerator() { DBObject o = m_id.Open(OpenMode.ForRead); System.Collections.IEnumerator e = ((System.Collections.IEnumerable)o).GetEnumerator(); o.Close(); return e; } } class DbObjectProxy : DynamicMetaObject { public DbObjectProxy(Expression expression, ObjectId value):base(expression,BindingRestrictions.Empty, value) { } public override DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) { Console.WriteLine("BindUnaryOperation"); return base.BindUnaryOperation(binder); } public override DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg) { Console.WriteLine("BindBinaryOperation"); return base.BindBinaryOperation(binder, arg); } public override DynamicMetaObject BindConvert(ConvertBinder binder) { Console.WriteLine("BindConvert"); var id = (ObjectId)base.Value; Type enumerable = id.Type.GetInterface("System.Collections.IEnumerable"); if (enumerable==null) return base.BindConvert(binder); //new EnumarableProxy(id); var exp = Expression.New(typeof(EnumerableProxy).GetConstructor(new Type[] { typeof(ObjectId) }), new Expression[] { Expression.Convert(base.Expression, typeof(ObjectId)) }); var restr = BindingRestrictions.GetTypeRestriction(base.Expression, typeof(ObjectId)); return new DynamicMetaObject(exp, restr); } public override DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindCreateInstance"); return base.BindCreateInstance(binder, args); } public override DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes) { Console.WriteLine("BindDeleteIndex"); return base.BindDeleteIndex(binder, indexes); } public override DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { Console.WriteLine("BindDeleteMember"); return base.BindDeleteMember(binder); } public override DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes) { Console.WriteLine("BindGetIndex"); var id = (ObjectId)base.Value; return CreateWrapper( Expression.MakeIndex(Expression.Convert(obj, id.Type), id.Type.GetProperty("Item"), new Expression[] { indexes[0].Expression }), OpenMode.ForRead); } public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindInvoke"); return base.BindInvoke(binder, args); } public override DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { Console.WriteLine("BindInvokeMember"); return base.BindInvokeMember(binder, args); } public override DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) { Console.WriteLine("BindSetIndex"); var id = (ObjectId)base.Value; return CreateWrapper(Expression.Assign( Expression.MakeIndex(Expression.Convert(obj, id.Type), id.Type.GetProperty("Item"), new Expression[] { indexes[0].Expression }), value.Expression),OpenMode.ForWrite); } static ParameterExpression obj = Expression.Variable(typeof(DBObject), "obj"); DynamicMetaObject CreateWrapper(Expression body, OpenMode openMode) { Console.WriteLine("CreateWrapper {0}", body); var self = Expression.Convert(this.Expression, typeof(ObjectId)); /* DBObject obj = id.Open(); bool commit = false; try { retValue = commit = true; } finally { if (commit) obj.Close(); else obj.Cancel(); } (object)retValue; */ var commit = Expression.Variable(typeof(bool), "commit"); var retValue = Expression.Variable(body.Type, "retValue"); var target = Expression.Block( new ParameterExpression[] {obj, commit, retValue}, Expression.Assign( obj, Expression.Call(self, typeof(ObjectId).GetMethod("Open",BindingFlags.Instance | BindingFlags.NonPublic), Expression.Constant(openMode)) ), Expression.Assign(commit,Expression.Constant(false)), Expression.TryFinally( Expression.Block( Expression.Assign(retValue,body), Expression.Assign(commit,Expression.Constant(true)) ), Expression.IfThenElse(commit, Expression.Call(obj, typeof(DBObject).GetMethod("Close")), Expression.Call(obj, typeof(DBObject).GetMethod("Cancel"))) ) , Expression.Convert(retValue, typeof(object)) ); var id = (ObjectId)base.Value; var restrictions = BindingRestrictions.GetExpressionRestriction( Expression.Equal( Expression.MakeMemberAccess(self, typeof(ObjectId).GetProperty("Type")), Expression.Constant(id.Type)) ); return new DynamicMetaObject(target, restrictions); } public override DynamicMetaObject BindGetMember(GetMemberBinder binder) { Console.WriteLine("BindGetMember"); var id = (ObjectId)base.Value; return CreateWrapper( Expression.MakeMemberAccess(Expression.Convert(obj, id.Type), id.Type.GetProperty(binder.Name)), OpenMode.ForRead); } public override DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value) { Console.WriteLine("BindSetMember"); var id = (ObjectId)base.Value; return CreateWrapper(Expression.Assign( Expression.MakeMemberAccess(Expression.Convert(obj, id.Type), id.Type.GetProperty(binder.Name)), value.Expression),OpenMode.ForWrite); } public override IEnumerable GetDynamicMemberNames() { Console.WriteLine("GetDynamicMemberNames"); return base.GetDynamicMemberNames(); } } enum OpenMode { ForWrite, ForRead } class DBObject { public void Close() { Console.WriteLine("DBObject.Close()"); } public void Cancel() { Console.WriteLine("DBObject.Cancel()"); } } class Line : DBObject { int m_prop2; public int Prop { get { Console.WriteLine("Line.Prop.get()"); return m_prop2; } set { Console.WriteLine("Line.Prop.set()"); m_prop2 = value; } } } class BlockTableRecord : DBObject, System.Collections.IEnumerable { public System.Collections.IEnumerator GetEnumerator() { for (int i = 0; i < 5; i++) { yield return new ObjectId(typeof(Line)); } } int m_indexer; public int this[string val] { get { return m_indexer; } set { m_indexer = value; } } } public struct ObjectId : IDynamicMetaObjectProvider { int m_id; static Dictionary handleTable = new Dictionary(); public ObjectId(Type type) { DBObject obj = (DBObject)Activator.CreateInstance(type); m_id = obj.GetHashCode(); handleTable.Add(m_id, obj); } internal DBObject Open(OpenMode mode) { Console.WriteLine("ObjectId.Open({0})", mode); return handleTable[m_id]; } public Type Type { get { return handleTable[m_id].GetType(); } } public DynamicMetaObject GetMetaObject(Expression parameter) { Console.WriteLine("ObjectId.GetMetaObject({0})",parameter); return new DbObjectProxy(parameter, this); } public static ObjectId GetBlockTableRecord() { return new ObjectId(typeof(BlockTableRecord)); } public static ObjectId GetLine() { return new ObjectId(typeof(Line)); } } class Program { static void Main(string[] args) { dynamic btr = ObjectId.GetBlockTableRecord(); foreach (dynamic o in btr) { o.Prop = 1; } } } } --------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Mon Nov 30 20:26:50 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 30 Nov 2009 19:26:50 +0000 Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 In-Reply-To: <330cefb9-1b24-4b1f-bd44-06a2eadacfba@b25g2000prb.googlegroups.com> References: <4e016d67-8744-44b6-be65-daaffafa5d3c@x25g2000prf.googlegroups.com> <1A472770E042064698CB5ADC83A12ACD04CFCAC3@TK5EX14MBXC118.redmond.corp.microsoft.com> <330cefb9-1b24-4b1f-bd44-06a2eadacfba@b25g2000prb.googlegroups.com> Message-ID: <1A472770E042064698CB5ADC83A12ACD04D20104@TK5EX14MBXC118.redmond.corp.microsoft.com> Glad that worked, I've opened this bug to track fixing this: http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25478 > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Jonathan Howard > Sent: Wednesday, November 25, 2009 9:45 AM > To: users at lists.ironpython.com > Subject: Re: [IronPython] Memory Leak in IronPython 2.6 RC3 > > That looks like it's removing that memory leak. I'm not positive > that's the one we're having in our production code, but it certainly > can't hurt. > > On Nov 25, 5:37?am, Dino Viehland wrote: > > My guess here (I'm on vacation so I haven't tried this) is that some > exception info > > is not getting cleared - > > > > ExceptionHelpers.DynamicStackFrames = null; > > > > In the catch block will probably fix it although we should probably > > do this ourselves. > > > > > > > > > > > > > -----Original Message----- > > > From: users-boun... at lists.ironpython.com [mailto:users- > > > boun... at lists.ironpython.com] On Behalf Of Jonathan Howard > > > Sent: Tuesday, November 24, 2009 4:45 PM > > > To: us... at lists.ironpython.com > > > Cc: jfelk... at drawloop.com > > > Subject: [IronPython] Memory Leak in IronPython 2.6 RC3 > > > > > I'm trying to track down a memory leak in our hosted IronPython > > > application as we upgrade to 2.6 from 1.1.2. ?I saw a post at > > > stackoverflow (http://stackoverflow.com/questions/1664567/embedded- > > > ironpython-memory-leak > > > ) showing how to set up the environment to avoid leaking memory, but > > > we're still having a memory leak. ?If I take our identical setup code, > > > and use it on very simple code, there's no problem, but we have > > > thousands of lines of Python at this point. > > > > > Below is a minimum way to introduce a memory leak inside a hosted > > > IronPython application. ?I don't know if it's the only way, or if it's > > > what's affecting us, but it does cause a leak: ?(Obviously it needs > > > the appropriate DLLs etc.) > > > > > ############################################# > > > > > using System; > > > using System.Threading; > > > using IronPython.Hosting; > > > using IronPython.Runtime; > > > using IronPython.Compiler; > > > using System.Collections.Generic; > > > using Microsoft.Scripting.Hosting; > > > > > namespace IPyTest > > > { > > > ? ? class Program > > > ? ? { > > > ? ? ? ? static void Main(string[] args) > > > ? ? ? ? { > > > ? ? ? ? ? ? bool cont = true; > > > ? ? ? ? ? ? while (cont) > > > ? ? ? ? ? ? { > > > ? ? ? ? ? ? ? ? var ipy = new IPy(); > > > ? ? ? ? ? ? ? ? try > > > ? ? ? ? ? ? ? ? { > > > ? ? ? ? ? ? ? ? ? ? // Set the below boolean to "false" to run without > > > a memory leak > > > ? ? ? ? ? ? ? ? ? ? // Set it to "true" to run with a memory leak. > > > ? ? ? ? ? ? ? ? ? ? ipy.run(true); > > > ? ? ? ? ? ? ? ? } > > > ? ? ? ? ? ? ? ? catch { } > > > ? ? ? ? ? ? } > > > ? ? ? ? } > > > ? ? } > > > > > ? ? class IPy > > > ? ? { > > > ? ? ? ? private string scriptWithoutLeak = "import random; > > > random.randint(1,10)"; > > > ? ? ? ? private string scriptWithLeak = "raise Exception(), 'error'"; > > > > > ? ? ? ? public IPy() > > > ? ? ? ? { > > > ? ? ? ? } > > > > > ? ? ? ? public void run(bool withLeak) > > > ? ? ? ? { > > > ? ? ? ? ? ? //set up script environment > > > ? ? ? ? ? ? Dictionary options = new > > > Dictionary(); > > > ? ? ? ? ? ? options["LightweightScopes"] = true; > > > ? ? ? ? ? ? ScriptEngine engine = Python.CreateEngine(options); > > > ? ? ? ? ? ? PythonCompilerOptions pco = (PythonCompilerOptions) > > > engine.GetCompilerOptions(); > > > ? ? ? ? ? ? pco.Module &= ~ModuleOptions.Optimized; > > > ? ? ? ? ? ? engine.SetSearchPaths(new string[]{ > > > ? ? ? ? ? ? ? ? @"C:\Program Files\IronPython 2.6\Lib" > > > ? ? ? ? ? ? }); > > > ? ? ? ? ? ? ScriptRuntime runtime = engine.Runtime; > > > ? ? ? ? ? ? ScriptScope scope = runtime.CreateScope(); > > > ? ? ? ? ? ? var source = engine.CreateScriptSourceFromString( > > > ? ? ? ? ? ? ? ? withLeak ? scriptWithLeak : scriptWithoutLeak > > > ? ? ? ? ? ? ); > > > ? ? ? ? ? ? var comped = source.Compile(); > > > ? ? ? ? ? ? comped.Execute(scope); > > > ? ? ? ? ? ? runtime.Shutdown(); > > > ? ? ? ? } > > > ? ? } > > > } > > > _______________________________________________ > > > Users mailing list > > > Us... at lists.ironpython.com > > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > > Users mailing list > > Us... at lists.ironpython.comhttp://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 From dinov at microsoft.com Mon Nov 30 20:28:42 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 30 Nov 2009 19:28:42 +0000 Subject: [IronPython] Re the The Fifth Assembly post (http://devhawk.net/2008/10/21/The+Fifth+Assembly.aspx) In-Reply-To: <38B19FF06367EB40B888564C566676160415DE3F@emailsrv.cgy.cmgl.ca> References: <38B19FF06367EB40B888564C566676160415DE3F@emailsrv.cgy.cmgl.ca> Message-ID: <1A472770E042064698CB5ADC83A12ACD04D20161@TK5EX14MBXC118.redmond.corp.microsoft.com> How are the assemblies getting loaded here? Given the error message it seems like IronPython or some other DLL is getting loaded in a reflection only context. IronPython and the DLR doesn't ever do that it's probably your own code which is doing that. I would expect if you simply load the ExtensionAttribute assembly first (also as reflection only) then you'd be fine. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Owen Sigurdson Sent: Wednesday, November 25, 2009 7:03 AM To: users at lists.ironpython.com Subject: [IronPython] Re the The Fifth Assembly post (http://devhawk.net/2008/10/21/The+Fifth+Assembly.aspx) Hello, We are experiencing the problem that is mentioned in this post using IronPython 2.6 RC 2 but are un-able to un-reference the associated assembly. I am getting the following error: Error 2 Unknown build error, 'Cannot resolve dependency to assembly 'Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' Would anyone have any insight into what is going on here? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Mon Nov 30 20:30:44 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 30 Nov 2009 19:30:44 +0000 Subject: [IronPython] Compiling .py to .dll to use with Silverlight In-Reply-To: <4B09AC8D.4090207@bakalari.cz> References: <4B09AC8D.4090207@bakalari.cz> Message-ID: <1A472770E042064698CB5ADC83A12ACD04D2017F@TK5EX14MBXC118.redmond.corp.microsoft.com> I'm not aware of any working example of this. In theory you can do it by hand by just taking the resulting DLL that gets compiled on the desktop and updating all of the assembly versions to be the Silverlight assembly versions. That can be done by sending it through ildasm/ilasm. You'd need to update all of the IronPython and DLR assemblies as well as mscorlib and System all of which have different versions on Silverlight vs the desktop CLR. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky > Sent: Sunday, November 22, 2009 1:27 PM > To: Discussion of IronPython > Subject: [IronPython] Compiling .py to .dll to use with Silverlight > > Hi, > I'd like to know status of the $subj. I have found some discussions > (e.g. Michael tried to use pyc or > http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=52207&ANCHOR > ) but > no working example - is there any? And if not will be any? :-) > Thanks. > > -- > -- Luk?? > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Mon Nov 30 20:45:11 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 30 Nov 2009 19:45:11 +0000 Subject: [IronPython] Compiling .py to .dll to use with Silverlight In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04D2017F@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <4B09AC8D.4090207@bakalari.cz> <1A472770E042064698CB5ADC83A12ACD04D2017F@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <4B1420C7.8040403@voidspace.org.uk> Dino Viehland wrote: > I'm not aware of any working example of this. In theory you can do it by > hand by just taking the resulting DLL that gets compiled on the desktop > and updating all of the assembly versions to be the Silverlight assembly > versions. That can be done by sending it through ildasm/ilasm. You'd > need to update all of the IronPython and DLR assemblies as well as > mscorlib and System all of which have different versions on Silverlight > vs the desktop CLR. > For the record I tried this and it didn't work for me. The resulting assembly uses StrongBox (from memory) and possibly other features not available in CoreCLR. I would also love to see a solution to this as import time is a big factor in the startup of IronPython Silverlight apps and pre-compiled assemblies would help a lot. All the best, Michael > > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Lukas Cenovsky >> Sent: Sunday, November 22, 2009 1:27 PM >> To: Discussion of IronPython >> Subject: [IronPython] Compiling .py to .dll to use with Silverlight >> >> Hi, >> I'd like to know status of the $subj. I have found some discussions >> (e.g. Michael tried to use pyc or >> http://sdlsdk.codeplex.com/Thread/View.aspx?ThreadId=52207&ANCHOR >> ) but >> no working example - is there any? And if not will be any? :-) >> Thanks. >> >> -- >> -- Luk?? >> >> _______________________________________________ >> 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 > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From Owen.Sigurdson at cmgl.ca Mon Nov 30 21:36:13 2009 From: Owen.Sigurdson at cmgl.ca (Owen Sigurdson) Date: Mon, 30 Nov 2009 13:36:13 -0700 Subject: [IronPython] Re the The Fifth Assemblypost (http://devhawk.net/2008/10/21/The+Fifth+Assembly.aspx) In-Reply-To: <1A472770E042064698CB5ADC83A12ACD04D20161@TK5EX14MBXC118.redmond.corp.microsoft.com> References: <38B19FF06367EB40B888564C566676160415DE3F@emailsrv.cgy.cmgl.ca> <1A472770E042064698CB5ADC83A12ACD04D20161@TK5EX14MBXC118.redmond.corp.microsoft.com> Message-ID: <38B19FF06367EB40B888564C56667616041C0013@emailsrv.cgy.cmgl.ca> This error occurs in visual studio when performing a standard build so I can't see any reflection only loads happening at that time (unless visual studio itself is doing a reflection only load). From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Monday, November 30, 2009 12:29 PM To: Discussion of IronPython Subject: Re: [IronPython] Re the The Fifth Assemblypost (http://devhawk.net/2008/10/21/The+Fifth+Assembly.aspx) How are the assemblies getting loaded here? Given the error message it seems like IronPython or some other DLL is getting loaded in a reflection only context. IronPython and the DLR doesn't ever do that it's probably your own code which is doing that. I would expect if you simply load the ExtensionAttribute assembly first (also as reflection only) then you'd be fine. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Owen Sigurdson Sent: Wednesday, November 25, 2009 7:03 AM To: users at lists.ironpython.com Subject: [IronPython] Re the The Fifth Assembly post (http://devhawk.net/2008/10/21/The+Fifth+Assembly.aspx) Hello, We are experiencing the problem that is mentioned in this post using IronPython 2.6 RC 2 but are un-able to un-reference the associated assembly. I am getting the following error: Error 2 Unknown build error, 'Cannot resolve dependency to assembly 'Microsoft.Scripting.ExtensionAttribute, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.' Would anyone have any insight into what is going on here? -------------- next part -------------- An HTML attachment was scrubbed... URL: