From jdhardy at gmail.com Thu Jan 1 00:47:33 2009 From: jdhardy at gmail.com (Jeff Hardy) Date: Wed, 31 Dec 2008 16:47:33 -0700 Subject: [IronPython] Frames in IronPython In-Reply-To: References: Message-ID: On Wed, Dec 31, 2008 at 9:22 AM, Curt Hagenlocher wrote: > As I understand it, the biggest problem with getframe has always been > its performance implications. Would you want all IronPython code to > be slowed down so that this feature is supported? What if you needed > to opt-in on the command-line with a -X:getframe? It depends on how big the speed hit is and how much work it is to mark frames support optional. If the speed hit is only 10%, then I don't think it's worth the effort to make it optional unless it's trivial to make it so. If it's 50% then it should definitely be optional. I can deal with it being optional, if that's the case. > > Also, I don't see a lot of votes here. *wink* I'm hoping this little PSA will help change that. :) - Jeff From jdhardy at gmail.com Thu Jan 1 01:42:13 2009 From: jdhardy at gmail.com (Jeff Hardy) Date: Wed, 31 Dec 2008 17:42:13 -0700 Subject: [IronPython] Frames in IronPython In-Reply-To: <5b0248170812310807s3afab7d1sf8178222060bf52e@mail.gmail.com> References: <5b0248170812310807s3afab7d1sf8178222060bf52e@mail.gmail.com> Message-ID: On Wed, Dec 31, 2008 at 9:07 AM, Seo Sanghyeon wrote: > 2008/12/31 Jeff Hardy : >> I don't know what the feature list is going to be for 2.1, but I'd >> like to see frame objects near the top. Almost every piece of Python >> code I've tried uses them in some way. Often it's for debugging >> purposes (and can be worked around), but not always. Trac has this >> lovely piece of code: > > This is pretty sad state of affair, especially considering that such > (like Trac's) use of getting frame local is usually unnecessary with > a bit of metaclass. The issue is the client interface: class WikiModule(Component): implements(IContentConverter, INavigationContributor, IPermissionRequestor, ...) This is just an odd interface for Python to support (in Ruby it'd be fine[1]). Something like: class WikiModule(Component): implements = (IContentConverter, INavigationContributor, IPermissionRequestor, ...) Would be more natural, IMHO. A little digging showed that Trac had a previously had a different version (non-threadsafe, and some other issues[2]) that didn't use frames but supported the same client interface. Reverting to that allows that particular set of tests to pass, so I'll see where I can go from here (until I need Genshi, at any rate). A real fix would probably require changing the client interface, and I don't know how willing they'll be to do that after just breaking it for 0.11. [1] http://blog.ianbicking.org/more-on-python-metaprogramming.html [2] http://groups.google.com/group/trac-dev/browse_thread/thread/7bccf999eb3407ed?pli=1 - Jeff From fuzzyman at voidspace.org.uk Thu Jan 1 15:35:55 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 01 Jan 2009 14:35:55 +0000 Subject: [IronPython] Frames in IronPython In-Reply-To: References: Message-ID: <495CD4CB.1060002@voidspace.org.uk> Jeff Hardy wrote: > On Wed, Dec 31, 2008 at 9:22 AM, Curt Hagenlocher wrote: > >> As I understand it, the biggest problem with getframe has always been >> its performance implications. Would you want all IronPython code to >> be slowed down so that this feature is supported? What if you needed >> to opt-in on the command-line with a -X:getframe? >> > > It depends on how big the speed hit is and how much work it is to mark > frames support optional. If the speed hit is only 10%, then I don't > think it's worth the effort to make it optional unless it's trivial to > make it so. If it's 50% then it should definitely be optional. I can > deal with it being optional, if that's the case. > Well, I wouldn't be happy with a 10% slowdown. :-) I tend to agree with Seo, use of Python stack frames indicates a poorly designed API. On the other hand I understand the problem, so at least optional support would be nice. Michael Foord > >> Also, I don't see a lot of votes here. *wink* >> > > I'm hoping this little PSA will help change that. :) > > - Jeff > _______________________________________________ > 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 dan.eloff at gmail.com Thu Jan 1 20:18:51 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Thu, 1 Jan 2009 14:18:51 -0500 Subject: [IronPython] Odd tracebacks Message-ID: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> I've been experiencing off tracebacks for several weeks now, mostly I just ignore them because it could be my fault, and it's not a blocker. On AttributeErrors I see very strange tracebacks, impossible tracebacks, sometimes even misleading tracebacks. Have a look at this (complete) traceback: --------------- Phony Traceback Part --------------- at __getattr__ in game\models\__init__.py, line 144 at pairwise in game/utils\functions.py, line 42 at __getattr__ in game\models\__init__.py, line 144 at pairwise in game/utils\functions.py, line 42 at __getattr__ in game\models\__init__.py, line 144 at pairwise in game/utils\functions.py, line 42 at pairwise in game/utils\functions.py, line 42 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 --------------- Real Traceback Part ----------------- at __getattr__ in beskar\namespace.py, line 46 at __getattr__ in beskar\context.py, line 46 at FleetStrengthDisplay in , line 4 at Content in , line 39 at body in , line 21 at render in beskar\template.py, line 92 at _wrapper in beskar\template.py, line 97 at load_xaml in game\templates\__init__.py, line 18 line 46 of __getattr__ of beskar\namespace.py is where the AttributeError originates, everything beyond that in the traceback is completely out to lunch. Unfortunately this is such odd behavior, I haven't discovered how to reproduce it. Any idea what could cause this? Thanks, -Dan From dinov at microsoft.com Fri Jan 2 18:33:24 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 2 Jan 2009 09:33:24 -0800 Subject: [IronPython] Odd tracebacks In-Reply-To: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> Are there other exceptions being thrown, potentially somewhere on the stack below game\models\__init__.py on line 144? Maybe we're calling a built-in function somewhere that's calling back into your code and is doing something funky with the exception tracking. Can you run this under VS and get the stack traces where all the exceptions are being thrown leading up to the problem? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff Sent: Thursday, January 01, 2009 11:19 AM To: Discussion of IronPython Subject: [IronPython] Odd tracebacks I've been experiencing off tracebacks for several weeks now, mostly I just ignore them because it could be my fault, and it's not a blocker. On AttributeErrors I see very strange tracebacks, impossible tracebacks, sometimes even misleading tracebacks. Have a look at this (complete) traceback: --------------- Phony Traceback Part --------------- at __getattr__ in game\models\__init__.py, line 144 at pairwise in game/utils\functions.py, line 42 at __getattr__ in game\models\__init__.py, line 144 at pairwise in game/utils\functions.py, line 42 at __getattr__ in game\models\__init__.py, line 144 at pairwise in game/utils\functions.py, line 42 at pairwise in game/utils\functions.py, line 42 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 at __getattr__ in game\models\__init__.py, line 144 --------------- Real Traceback Part ----------------- at __getattr__ in beskar\namespace.py, line 46 at __getattr__ in beskar\context.py, line 46 at FleetStrengthDisplay in , line 4 at Content in , line 39 at body in , line 21 at render in beskar\template.py, line 92 at _wrapper in beskar\template.py, line 97 at load_xaml in game\templates\__init__.py, line 18 line 46 of __getattr__ of beskar\namespace.py is where the AttributeError originates, everything beyond that in the traceback is completely out to lunch. Unfortunately this is such odd behavior, I haven't discovered how to reproduce it. Any idea what could cause this? Thanks, -Dan _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at microsoft.com Fri Jan 2 18:40:37 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 2 Jan 2009 09:40:37 -0800 Subject: [IronPython] Frames in IronPython In-Reply-To: <495CD4CB.1060002@voidspace.org.uk> References: <495CD4CB.1060002@voidspace.org.uk> Message-ID: <350E7D38B6D819428718949920EC235557046B6C11@NA-EXMSG-C102.redmond.corp.microsoft.com> It is certainly more like 50% on trivial functions than 10%. Given that I have this mostly written I think we can probably get it into 2.1. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Thursday, January 01, 2009 6:36 AM To: Discussion of IronPython Subject: Re: [IronPython] Frames in IronPython Jeff Hardy wrote: > On Wed, Dec 31, 2008 at 9:22 AM, Curt Hagenlocher wrote: > >> As I understand it, the biggest problem with getframe has always been >> its performance implications. Would you want all IronPython code to >> be slowed down so that this feature is supported? What if you needed >> to opt-in on the command-line with a -X:getframe? >> > > It depends on how big the speed hit is and how much work it is to mark > frames support optional. If the speed hit is only 10%, then I don't > think it's worth the effort to make it optional unless it's trivial to > make it so. If it's 50% then it should definitely be optional. I can > deal with it being optional, if that's the case. > Well, I wouldn't be happy with a 10% slowdown. :-) I tend to agree with Seo, use of Python stack frames indicates a poorly designed API. On the other hand I understand the problem, so at least optional support would be nice. Michael Foord > >> Also, I don't see a lot of votes here. *wink* >> > > I'm hoping this little PSA will help change that. :) > > - Jeff > _______________________________________________ > 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 dinov at microsoft.com Fri Jan 2 18:59:52 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 2 Jan 2009 09:59:52 -0800 Subject: [IronPython] Embedding IronPython In-Reply-To: <8cd017b80812310435t719d1a90p9023a57df886ebe0@mail.gmail.com> References: <20081225210901.F261A1C70480@smtp.webfaction.com> <495A9B05.8060703@voidspace.org.uk> <495B4E68.8050606@gmx.de> <8cd017b80812310435t719d1a90p9023a57df886ebe0@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC235557046B6C1B@NA-EXMSG-C102.redmond.corp.microsoft.com> This would appear to be a bad default value for compiling. You can explicitly disable compiling the code as optimized and it will be fully collectible: var runtime = Python.CreateRuntime(); var engine = runtime.GetEngine("py"); var sum = 0.0; PythonCompilerOptions pco = (PythonCompilerOptions)engine.GetCompilerOptions(); pco.Module &= ~ModuleOptions.Optimized; while (true) { var code = engine.CreateScriptSourceFromString("1.0+2.0").Compile(pco); sum += code.Execute(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Console.WriteLine(sum); } I am inclined to change this, or at least add some other way that makes this more discoverable (e.g. via the Python class). But I think changing the default should probably wait until 2.1 as it could have some small perf surprises for people who are expecting it to be in the more optimal form (globals will be ~10% slower). Longer term we're working w/ the CLR team to get the best of both worlds. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dody Gunawinata Sent: Wednesday, December 31, 2008 4:35 AM To: Discussion of IronPython Subject: Re: [IronPython] Embedding IronPython Please we need more vote on the memory leak issue because it has huge impact on the usage of Iron Python for the web environment as well. On Wed, Dec 31, 2008 at 11:50 AM, Christian Schmidt > wrote: Hi Josh, CompiledCode cc = src.Compile(); This will leak memory. So you will run out of memory after a while (in our case after 100'000 compiles on x86). [http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20399] Is this going to work or will I run into threading problems? In other words, is the ScriptEngine thread-safe? Will it serialize all of my cc.Execute() calls? Any other insight into its behavior in this regard would be appreciated. I think globals and imports will be shared. So modifying them might give unexpected results. Cheers, Christian _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Fri Jan 2 20:39:54 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Fri, 2 Jan 2009 11:39:54 -0800 Subject: [IronPython] MouseButtonDownEvent doesn't fire + which tool to work in? In-Reply-To: <21115998.post@talk.nabble.com> References: <21115998.post@talk.nabble.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDEF6CB24@NA-EXMSG-C116.redmond.corp.microsoft.com> > Another question: Which tool do you guys say is the best for developing > IronPython + Silverlight apps? I find it hard in Visual Studio since > the > debugger only lets you step through the code but you can't see any > variable > values. I use the debugger, and you can see the variable values ... but you have to dig a couple levels to find the "python" values. Or you can use print statements =) The next release of the agdlr bits will have a HTML console in it, where print statements will show up, code can run, etc. You can check it out at http://github.com/jschementi/agdlr. It doesn't work for perfectly for python yet, so any help there would be great =) From empirebuilder at gmail.com Sat Jan 3 03:21:12 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Sat, 3 Jan 2009 04:21:12 +0200 Subject: [IronPython] Embedding IronPython In-Reply-To: <350E7D38B6D819428718949920EC235557046B6C1B@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <20081225210901.F261A1C70480@smtp.webfaction.com> <495A9B05.8060703@voidspace.org.uk> <495B4E68.8050606@gmx.de> <8cd017b80812310435t719d1a90p9023a57df886ebe0@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C1B@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <8cd017b80901021821h23bcd476g85ecc985892b6a1d@mail.gmail.com> OK, this is definitely surprising. Is it correct to assume that by setting the compilation to non-optimized mode, the compilation result will behave like a normal .Net object in being subjected to normal GC collection when it's out of scope? Or do I have to explicitly set GC collection after usage? Dody G. On Fri, Jan 2, 2009 at 7:59 PM, Dino Viehland wrote: > This would appear to be a bad default value for compiling. You can > explicitly disable compiling the code as optimized and it will be fully > collectible: > > > > var runtime = Python.CreateRuntime(); > > var engine = runtime.GetEngine("py"); > > var sum = 0.0; > > *PythonCompilerOptions pco = > (PythonCompilerOptions)engine.GetCompilerOptions();* > > *pco.Module &= ~ModuleOptions.Optimized;* > > * * > > while (true) > > { > > var code = engine.CreateScriptSourceFromString("1.0+2.0").Compile(*pco*); > > sum += code.Execute(); > > GC.Collect(); > > GC.WaitForPendingFinalizers(); > > GC.Collect(); > > Console.WriteLine(sum); > > } > > > > I am inclined to change this, or at least add some other way that makes > this more discoverable (e.g. via the Python class). But I think changing > the default should probably wait until 2.1 as it could have some small perf > surprises for people who are expecting it to be in the more optimal form > (globals will be ~10% slower). Longer term we're working w/ the CLR team to > get the best of both worlds. > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Dody Gunawinata > *Sent:* Wednesday, December 31, 2008 4:35 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Embedding IronPython > > > > Please we need more vote on the memory leak issue because it has huge > impact on the usage of Iron Python for the web environment as well. > > On Wed, Dec 31, 2008 at 11:50 AM, Christian Schmidt < > christian2.schmidt at gmx.de> wrote: > > Hi Josh, > > CompiledCode cc = src.Compile(); > > > This will leak memory. So you will run out of memory after a while (in our > case after 100'000 compiles on x86). > [http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20399] > > > > Is this going to work or will I run into threading problems? In other > words, is the ScriptEngine thread-safe? Will it serialize all of my > cc.Execute() calls? Any other insight into its behavior in this regard > would be appreciated. > > > > I think globals and imports will be shared. So modifying them might give > unexpected results. > > Cheers, > Christian > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > nomadlife.org > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Sat Jan 3 03:44:28 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 2 Jan 2009 18:44:28 -0800 Subject: [IronPython] Embedding IronPython In-Reply-To: <8cd017b80901021821h23bcd476g85ecc985892b6a1d@mail.gmail.com> References: <20081225210901.F261A1C70480@smtp.webfaction.com> <495A9B05.8060703@voidspace.org.uk> <495B4E68.8050606@gmx.de> <8cd017b80812310435t719d1a90p9023a57df886ebe0@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C1B@NA-EXMSG-C102.redmond.corp.microsoft.com> <8cd017b80901021821h23bcd476g85ecc985892b6a1d@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704BD0165@NA-EXMSG-C102.redmond.corp.microsoft.com> Yeah, it was surprising to me too :) But your assumption is correct - it'll be collected like just any other object. Also Rauhotz has commented on the bug 20399 that if you move the CreateRuntime/GetEngine calls into the loop that we still leak memory though :( That definitely looks like a bad bug but I think I'll need to talk to the DLR team about it. Once we have a fix that seems like a definite candidate for 2.0x. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dody Gunawinata Sent: Friday, January 02, 2009 6:21 PM To: Discussion of IronPython Subject: Re: [IronPython] Embedding IronPython OK, this is definitely surprising. Is it correct to assume that by setting the compilation to non-optimized mode, the compilation result will behave like a normal .Net object in being subjected to normal GC collection when it's out of scope? Or do I have to explicitly set GC collection after usage? Dody G. On Fri, Jan 2, 2009 at 7:59 PM, Dino Viehland > wrote: This would appear to be a bad default value for compiling. You can explicitly disable compiling the code as optimized and it will be fully collectible: var runtime = Python.CreateRuntime(); var engine = runtime.GetEngine("py"); var sum = 0.0; PythonCompilerOptions pco = (PythonCompilerOptions)engine.GetCompilerOptions(); pco.Module &= ~ModuleOptions.Optimized; while (true) { var code = engine.CreateScriptSourceFromString("1.0+2.0").Compile(pco); sum += code.Execute(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Console.WriteLine(sum); } I am inclined to change this, or at least add some other way that makes this more discoverable (e.g. via the Python class). But I think changing the default should probably wait until 2.1 as it could have some small perf surprises for people who are expecting it to be in the more optimal form (globals will be ~10% slower). Longer term we're working w/ the CLR team to get the best of both worlds. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dody Gunawinata Sent: Wednesday, December 31, 2008 4:35 AM To: Discussion of IronPython Subject: Re: [IronPython] Embedding IronPython Please we need more vote on the memory leak issue because it has huge impact on the usage of Iron Python for the web environment as well. On Wed, Dec 31, 2008 at 11:50 AM, Christian Schmidt > wrote: Hi Josh, CompiledCode cc = src.Compile(); This will leak memory. So you will run out of memory after a while (in our case after 100'000 compiles on x86). [http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20399] Is this going to work or will I run into threading problems? In other words, is the ScriptEngine thread-safe? Will it serialize all of my cc.Execute() calls? Any other insight into its behavior in this regard would be appreciated. I think globals and imports will be shared. So modifying them might give unexpected results. Cheers, Christian _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- nomadlife.org -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian at merrells.org Sun Jan 4 17:58:05 2009 From: brian at merrells.org (Brian Merrell) Date: Sun, 4 Jan 2009 11:58:05 -0500 Subject: [IronPython] Problems with hashlib and threading In-Reply-To: References: <4a3ced360812201356i4914639gefa19fcb8d326d4f@mail.gmail.com> Message-ID: <4a3ced360901040858q7d55dacxd85bca68c77514ea@mail.gmail.com> Thanks Curt. I've filed a bug report. It makes me a bit nervous realizing that it isn't entirely transparent when shared memory/objects are being used. Normally I would think a local instance of hashlib.md5() would be thread-safe from other local instances. Is there any documentation of what other modules use global/static instances or other non-thread-safe implementations in IronPython? On Tue, Dec 30, 2008 at 12:13 PM, Curt Hagenlocher wrote: > I'm going to guess that this is because we use a static instance > of MD5CryptoServiceProvider to do the hashing, something which may not be > thread-safe. It looks like all of the IronPython crypto implementations do > the same thing, so the SHA functions may have a similar issue. > Please file this as a bug on Codeplex. > > On Sat, Dec 20, 2008 at 1:56 PM, Brian Merrell wrote: > >> I get the following error periodically: >> >> Exception in thread Thread-2: >> Traceback (most recent call last): >> File "C:\Program Files\IronPython 2.0\Lib\threading.py", line 486, in >> _Thread__bootstrap_inner >> self.run() >> File "initial_ingest.py", line 33, in run >> md5 = hashlib.md5(contents).hexdigest() >> SystemError: Hash not valid for use in specified state. >> >> I am not sharing a md5() object between threads and have tried to avoid >> any shared memory issues: >> >> >> class Convert(threading.Thread): >> def __init__(self, queue): >> threading.Thread.__init__(self) >> self.queue = queue >> def run(self): >> import hashlib >> while True: >> abs_filename = self.queue.get() >> f = open(abs_filename, "rb") >> contents = f.read() >> f.close() >> md5 = hashlib.md5(contents).hexdigest() >> print md5, abs_filename >> self.queue.task_done() >> >> Any ideas why this is failing? Thanks, >> >> -brian >> >> _______________________________________________ >> 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 curt at hagenlocher.org Mon Jan 5 01:09:14 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Sun, 4 Jan 2009 16:09:14 -0800 Subject: [IronPython] Problems with hashlib and threading In-Reply-To: <4a3ced360901040858q7d55dacxd85bca68c77514ea@mail.gmail.com> References: <4a3ced360812201356i4914639gefa19fcb8d326d4f@mail.gmail.com> <4a3ced360901040858q7d55dacxd85bca68c77514ea@mail.gmail.com> Message-ID: Not without looking at the source code... We want to be at least as thread-safe as CPython, with the exception that we have no interest in implementing the equivalent of a "global interpreter lock" :). This particular case is just bad coding on our part. I can't promise you that there aren't other examples, but at least this one is pretty easy to fix. On Sun, Jan 4, 2009 at 8:58 AM, Brian Merrell wrote: > Thanks Curt. I've filed a bug report. It makes me a bit nervous realizing > that it isn't entirely transparent when shared memory/objects are being > used. Normally I would think a local instance of hashlib.md5() would be > thread-safe from other local instances. Is there any documentation of what > other modules use global/static instances or other non-thread-safe > implementations in IronPython? > > > On Tue, Dec 30, 2008 at 12:13 PM, Curt Hagenlocher wrote: > >> I'm going to guess that this is because we use a static instance >> of MD5CryptoServiceProvider to do the hashing, something which may not be >> thread-safe. It looks like all of the IronPython crypto implementations do >> the same thing, so the SHA functions may have a similar issue. >> Please file this as a bug on Codeplex. >> >> On Sat, Dec 20, 2008 at 1:56 PM, Brian Merrell wrote: >> >>> I get the following error periodically: >>> >>> Exception in thread Thread-2: >>> Traceback (most recent call last): >>> File "C:\Program Files\IronPython 2.0\Lib\threading.py", line 486, in >>> _Thread__bootstrap_inner >>> self.run() >>> File "initial_ingest.py", line 33, in run >>> md5 = hashlib.md5(contents).hexdigest() >>> SystemError: Hash not valid for use in specified state. >>> >>> I am not sharing a md5() object between threads and have tried to avoid >>> any shared memory issues: >>> >>> >>> class Convert(threading.Thread): >>> def __init__(self, queue): >>> threading.Thread.__init__(self) >>> self.queue = queue >>> def run(self): >>> import hashlib >>> while True: >>> abs_filename = self.queue.get() >>> f = open(abs_filename, "rb") >>> contents = f.read() >>> f.close() >>> md5 = hashlib.md5(contents).hexdigest() >>> print md5, abs_filename >>> self.queue.task_done() >>> >>> Any ideas why this is failing? Thanks, >>> >>> -brian >>> >>> _______________________________________________ >>> 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 brian at merrells.org Mon Jan 5 05:42:47 2009 From: brian at merrells.org (Brian Merrell) Date: Sun, 4 Jan 2009 23:42:47 -0500 Subject: [IronPython] Problems with hashlib and threading In-Reply-To: References: <4a3ced360812201356i4914639gefa19fcb8d326d4f@mail.gmail.com> <4a3ced360901040858q7d55dacxd85bca68c77514ea@mail.gmail.com> Message-ID: <4a3ced360901042042h2b5949e9g16e847d8f41f52b6@mail.gmail.com> Thanks! Given that useful multi-threaded hashing is only available because of IronPython's lack of GIL I can't complain too much :-) For reference, here is the issue link: http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20324 I look forward to the fix in a future release. On Sun, Jan 4, 2009 at 7:09 PM, Curt Hagenlocher wrote: > Not without looking at the source code... > > We want to be at least as thread-safe as CPython, with the exception that > we have no interest in implementing the equivalent of a "global interpreter > lock" :). This particular case is just bad coding on our part. I can't > promise you that there aren't other examples, but at least this one is > pretty easy to fix. > > > On Sun, Jan 4, 2009 at 8:58 AM, Brian Merrell wrote: > >> Thanks Curt. I've filed a bug report. It makes me a bit nervous >> realizing that it isn't entirely transparent when shared memory/objects are >> being used. Normally I would think a local instance of hashlib.md5() would >> be thread-safe from other local instances. Is there any documentation of >> what other modules use global/static instances or other non-thread-safe >> implementations in IronPython? >> >> >> On Tue, Dec 30, 2008 at 12:13 PM, Curt Hagenlocher wrote: >> >>> I'm going to guess that this is because we use a static instance >>> of MD5CryptoServiceProvider to do the hashing, something which may not be >>> thread-safe. It looks like all of the IronPython crypto implementations do >>> the same thing, so the SHA functions may have a similar issue. >>> Please file this as a bug on Codeplex. >>> >>> On Sat, Dec 20, 2008 at 1:56 PM, Brian Merrell wrote: >>> >>>> I get the following error periodically: >>>> >>>> Exception in thread Thread-2: >>>> Traceback (most recent call last): >>>> File "C:\Program Files\IronPython 2.0\Lib\threading.py", line 486, in >>>> _Thread__bootstrap_inner >>>> self.run() >>>> File "initial_ingest.py", line 33, in run >>>> md5 = hashlib.md5(contents).hexdigest() >>>> SystemError: Hash not valid for use in specified state. >>>> >>>> I am not sharing a md5() object between threads and have tried to avoid >>>> any shared memory issues: >>>> >>>> >>>> class Convert(threading.Thread): >>>> def __init__(self, queue): >>>> threading.Thread.__init__(self) >>>> self.queue = queue >>>> def run(self): >>>> import hashlib >>>> while True: >>>> abs_filename = self.queue.get() >>>> f = open(abs_filename, "rb") >>>> contents = f.read() >>>> f.close() >>>> md5 = hashlib.md5(contents).hexdigest() >>>> print md5, abs_filename >>>> self.queue.task_done() >>>> >>>> Any ideas why this is failing? Thanks, >>>> >>>> -brian >>>> >>>> _______________________________________________ >>>> 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 dan.eloff at gmail.com Mon Jan 5 18:12:07 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Mon, 5 Jan 2009 12:12:07 -0500 Subject: [IronPython] Odd tracebacks In-Reply-To: <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> On Fri, Jan 2, 2009 at 12:33 PM, Dino Viehland wrote: > Are there other exceptions being thrown, potentially somewhere on the stack below game\models\__init__.py on line 144? Maybe we're calling a built-in function somewhere that's calling back into your code and is doing something funky with the exception tracking. Can you run this under VS and get the stack traces where all the exceptions are being thrown leading up to the problem? > Sorry I took so long to get back to you. Here is a similar error that I created in an easier to debug place. This is looking very much more like a bug now, note the CLR stack trace seems correct, but the python stack trace is crazy. This is silverlight, so it's possible the fault could be in Microsoft.Scripting.Silverlight's error formatting code. Print statements at the top of Model.__getattr__ and pairwise show that neither are called in the process of rasing this error, as the CLR stack trace confirms. I ran this under VS, from when I click the button that triggers the error, here's what happens in order: an AttributeError at __getattr__ in beskar\namespace.py, line 47 After pressing Continue: an AttributeError at __getattr__ in beskar\namespace.py, line 47 Not sure why it seems to be raised twice in a row like that, the print statement right above raise is executed only once, do you know why? Call stack for both (only addresses change): Snippets.debug.scripting!S$34.__getattr__$686(object self, object attr = "BuildList") Line 47 + 0x184 bytes [External Code] Snippets.debug.scripting!S$38.__getattr__$776(object self, object attr = "BuildList") Line 37 + 0x107 bytes [External Code] Snippets.debug.scripting!S$35.LoadXaml$738(object self) Line 51 + 0x3ac bytes [External Code] Snippets.debug.scripting!S$74.OnCreateBuildOrder$1693(object self, object sender = {System.Windows.Controls.Button}, object e = {System.Windows.RoutedEventArgs}) Line 166 + 0x204 bytes [External Code] Pressing Continue simply lets me watch the stack unwind, pausing around the end of each of the other three methods in the call stack, and then silverlight displays the error. In case it is relevant, the method in beskar\namespace.py: def __getattr__(self, attr): for d in self._dicts: if attr in d: return d[attr] print 'AttributeError %s' % attr raise AttributeError(attr) And the method in beskar\context.py: def __getattr__(self, attr): v = Namespace.__getattr__(self, attr) if utils.requires_context(v): return types.MethodType(v, self) else: return v Traceback as displayed in silverlight: AttributeError: BuildList game\models\__init__.py Line 143: return FACTIONS.reverse_lookup_title(side) Line 144: Line 145: raise AttributeError(attr) Line 146: else: Line 147: if SERVER and isinstance(v, list): at __getattr__ in game\models\__init__.py, line 145 at pairwise in game/utils\functions.py, line 46 at __getattr__ in game\models\__init__.py, line 145 at pairwise in game/utils\functions.py, line 46 at pairwise in game/utils\functions.py, line 46 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in game\models\__init__.py, line 145 at __getattr__ in beskar\namespace.py, line 47 <----- First exception thrown here (explicit raise AttributeError) at __getattr__ in beskar\context.py, line 37 at init16 in , line 49 at LoadXaml in beskar\output.py, line 51 at OnCreateBuildOrder in game\planet.py, line 166 CLR Stack Trace: at S$34.__getattr__$757(Closure , Object self, Object attr) at _stub_$163##135(Closure , CallSite , CodeContext , Object , Object , Object ) at _stub_$2230##942(Closure , CallSite , CodeContext , Object , Object , Object ) at S$39.__getattr__$826(Closure , Object self, Object attr) at _stub_$1710##493(Closure , CallSite , CodeContext , Object , Object , String ) at _stub_$1709##492(Closure , CallSite , CodeContext , Object , String ) at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at _stub_$3474##2131(Closure , CallSite , Object , CodeContext ) at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at init16$2925##1582(Closure , Object ) at _stub_$2149##861(Closure , CallSite , Object , Object ) at Microsoft.Scripting.Runtime.DynamicOperations.Invoke(Object obj, Object[] parameters) at Microsoft.Scripting.Hosting.ObjectOperations.Call(Object obj, Object[] parameters) at BeskarNET.Python.Call(Object callable, Object[] args) at BeskarNET.BeskarRuntime.Init(FrameworkElement el, String id) at BeskarNET.Beskar.Load(Object obj, BeskarRuntime runtime) at BeskarNET.Beskar.LoadXaml(String xaml, Object context, Beskar beskar) at _stub_$2146##858(Closure , CallSite , CodeContext , Object , Object , Object , Object ) at S$37.LoadXaml$809(Closure , Object self) at _stub_$3343##2000(Closure , CallSite , CodeContext , Object , Object ) at _stub_$54##26(Closure , CallSite , CodeContext , Object ) at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at S$74.OnCreateBuildOrder$1769(Closure , Object self, Object sender, Object e) at _stub_$3457##2114(Closure , CallSite , CodeContext , Object , Object , Object , Object ) at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute5[T0,T1,T2,T3,T4,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at _stub_$3456##2113(Closure , CallSite , Object , Object , Object ) at Microsoft.Scripting.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at _stub_$2787##1496(Closure , CallSite , Object , Object , Object ) at System.Void(Object, Object)(Object[] , Object , Object ) at BeskarNET.EventGroup.Repeat(Object sender, Object e) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) Thanks, -Dan From caspar.lessing at gmail.com Tue Jan 6 14:58:32 2009 From: caspar.lessing at gmail.com (Caspar Lessing) Date: Tue, 6 Jan 2009 15:58:32 +0200 Subject: [IronPython] Global and Local ScriptScope Message-ID: Hello People I use an embedded instance of IronPython. My program spends effort to create a global context. It then continues to to execute statements inside a local context which need resolve the items in the global context as well. Think of python functions' local context and its interaction with the module context. In an older version of IronPython I had a EngineModule which I used for my global context and I could use a Dictionary for my locals. This allowed my to do the following: PythonEngine pe = new PythonEngine(); Context = pe.CreateModule(); pe.Execute(ExpensiveGlobalSetupScript,Context); Dictionary[] locals = new Dictionary[ScriptList.Length]; for(int i = 0; i < ScriptList.Length; i++) { locals[i] = new Dictionary() pe.Execute(ScriptList[i], Context, locals[i]); } I am having trouble doing something similar with ScriptScope. I have explored some avenues: 1. Copying the global context into each local one. It seems too expensive. Possibly it is only the cloning of some form of dictionary, but still. 2. Implementing a new CustomSymbolDictionary and overriding TryGetExtraValue. Problem is that it is called before trying to resolve symbols internally (Which leads to globals being resolved rather than locals) 3. Creating my own implementation of IAttributesCollection (Seemed too complex after discovering the Parent mechanism in Scope) I eventually found the Parent mechanism inside Scope. However I do not have access to create a new ScriptScope (Internal constructor) based on a Parent Scope. I had to create a new Factory method inside ScriptEngine which looks as follows: public sealed class ScriptEngine { ..... public ScriptScope CreateScope(ScriptScope parent) { ContractUtils.RequiresNotNull(parent, "parent"); return new ScriptScope(this, new Scope(parent.Scope,null)); } .... } My question if whether this is a sensible addition to ScriptEngine or am I missing something? Much appreciated Caz -------------- next part -------------- An HTML attachment was scrubbed... URL: From glenn.k.jones+ipy at gmail.com Tue Jan 6 15:07:18 2009 From: glenn.k.jones+ipy at gmail.com (Glenn Jones) Date: Tue, 6 Jan 2009 14:07:18 +0000 Subject: [IronPython] Weird performance issue Message-ID: <2679f6510901060607r3ad0bc1am4bb6701905f264df@mail.gmail.com> Hi all, More from the Resolver One upgrade: We are seeing several performance failures in our tests, which we expect because the performance profile of IPy2 is different to IPy1. There is one that is perplexing and we hope that someone can give us some insight into possible causes for us to investigate. One of our performance tests only fails when it is preceded by other tests. There is (as far as we can tell) no shared state between the tests. After much poking around, we discovered that replacing a set with a list caused the performance to improve from ~700ms down to ~100ms. We have been unable get a minimal repro, so far. Here's a little more detail on the how the code works: class Thing(object): def run(arg1, arg2): * do some stuff s = set() * do stuff that populates s return list(s) We create a Thing and call run so that the set contains an entry, if we then create a new Thing and call the run method it takes 10 times longer than expected. If we change s = set to s = [] (and convert s.add to s.append, where appropriate), and do the same as above, the second call to run behaves as we expect. There is (at least in our code) nothing shared between the first call to run and the second call. Does anyone have any ideas about where we can look to work out what's happening? Any suggestions for ways to diagnose this? Thanks Glenn & Kamil -------------- next part -------------- An HTML attachment was scrubbed... URL: From kristian.jaksch at gmail.com Tue Jan 6 15:08:15 2009 From: kristian.jaksch at gmail.com (Kristian) Date: Tue, 6 Jan 2009 06:08:15 -0800 (PST) Subject: [IronPython] Get a string from JavaScript to IronPython Message-ID: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> I have a code editor written in JavaScript on my page and I want to send the code that it is typed in as a string to IronPython so that it can be executed from IronPython. I got this to work in C# but not in IronPython. Below is the JavaScript I use: The code replaces a standard HTML-textarea with the JavaScript editor. The function "invokeManagedCode()" sends the text in the code editor to a C# method. The C# code is really simple: namespace htmlDom1 { public partial class Page : UserControl { public Page() { InitializeComponent(); HtmlPage.RegisterScriptableObject("codeProvider", this); } [ScriptableMember()] public void Code(string codeString) { this.Message.Text = codeString; } } } How can I achieve the same in IronPython? I tried to do exactly the same as in C#. See below: [ScriptableMember()] def Code(codeString): root.sl2TextBox.Text = codeString # Show that it works by writing the string # from the javascript code editor to a Silverlight textbox HtmlPage.RegisterScriptableObject("codeProvider", Code) But this doesn't work. How to do it properly? Thanks for help! From curt at hagenlocher.org Tue Jan 6 15:56:24 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 6 Jan 2009 06:56:24 -0800 Subject: [IronPython] Global and Local ScriptScope In-Reply-To: References: Message-ID: How many symbols are there in this shared global context? Can't you just initialize them in one ScriptScope and then copy the symbols into the other ScriptScopes where you want to use them? This would be analogous to saying "from pricy_scope import *" at the beginning of each module. On Tue, Jan 6, 2009 at 5:58 AM, Caspar Lessing wrote: > Hello People > > I use an embedded instance of IronPython. > My program spends effort to create a global context. It then continues to > to execute statements inside a local context which need resolve the items in > the global context as well. Think of python functions' local context and its > interaction with the module context. > > In an older version of IronPython I had a EngineModule which I used for my > global context and I could use a Dictionary for my locals. > > This allowed my to do the following: > > PythonEngine pe = new PythonEngine(); > Context = pe.CreateModule(); > pe.Execute(ExpensiveGlobalSetupScript,Context); > Dictionary[] locals = new > Dictionary[ScriptList.Length]; > for(int i = 0; i < ScriptList.Length; i++) > { > locals[i] = new Dictionary() > pe.Execute(ScriptList[i], Context, locals[i]); > } > > I am having trouble doing something similar with ScriptScope. I have > explored some avenues: > 1. Copying the global context into each local one. It seems too expensive. > Possibly it is only the cloning of some form of dictionary, but still. > 2. Implementing a new CustomSymbolDictionary and overriding > TryGetExtraValue. Problem is that it is called before trying to resolve > symbols internally (Which leads to globals being resolved rather than > locals) > 3. Creating my own implementation of IAttributesCollection (Seemed too > complex after discovering the Parent mechanism in Scope) > > I eventually found the Parent mechanism inside Scope. However I do not have > access to create a new ScriptScope (Internal constructor) based on a Parent > Scope. > I had to create a new Factory method inside ScriptEngine which looks as > follows: > > public sealed class ScriptEngine > { > ..... > public ScriptScope CreateScope(ScriptScope parent) > { > ContractUtils.RequiresNotNull(parent, "parent"); > return new ScriptScope(this, new Scope(parent.Scope,null)); > } > .... > } > > My question if whether this is a sensible addition to ScriptEngine or am I > missing something? > > Much appreciated > Caz > > _______________________________________________ > 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 Jan 6 16:07:35 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 06 Jan 2009 15:07:35 +0000 Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> Message-ID: <496373B7.7000401@voidspace.org.uk> Kristian wrote: > I have a code editor written in JavaScript on my page and I want to > send the code that it is typed in as a string to IronPython so that it > can be executed from IronPython. I got this to work in C# but not in > IronPython. Below is the JavaScript I use: > > > > The code replaces a standard HTML-textarea with the JavaScript editor. > The function "invokeManagedCode()" sends the text in the code editor > to a C# method. The C# code is really simple: > > namespace htmlDom1 > { > public partial class Page : UserControl > { > public Page() > { > InitializeComponent(); > HtmlPage.RegisterScriptableObject("codeProvider", this); > } > > [ScriptableMember()] > public void Code(string codeString) > { > this.Message.Text = codeString; > } > > } > } > > > How can I achieve the same in IronPython? I tried to do exactly the > same as in C#. See below: > > [ScriptableMember()] > Although this is valid Python syntax, it doesn't do what you think... (It actually created a new list - but as you don't assign a name to it, it will be garbage collected.) Unfortunately we can't apply attributes to Python classes. I get round this particular problem by creating stub classes in C# and inheriting from them in Python. See: http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml All the best, Michael > def Code(codeString): > root.sl2TextBox.Text = codeString # Show that it works by writing > the string > # from the > javascript code editor to a Silverlight textbox > > HtmlPage.RegisterScriptableObject("codeProvider", Code) > > > But this doesn't work. How to do it properly? > > Thanks for help! > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ From slide.o.mix at gmail.com Tue Jan 6 16:52:51 2009 From: slide.o.mix at gmail.com (Slide) Date: Tue, 6 Jan 2009 08:52:51 -0700 Subject: [IronPython] IRC Channel? Message-ID: Is there an IRC channel that people from the IP community hang out in frequently? If not, I believe there is an unofficial channel on freenode that could use some more people ;-) -- slide-o-blog http://slide-o-blog.blogspot.com/ From lukas.cenovsky at radiantsystems.com Tue Jan 6 18:13:28 2009 From: lukas.cenovsky at radiantsystems.com (Cenovsky, Lukas) Date: Tue, 6 Jan 2009 12:13:28 -0500 Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: <496373B7.7000401@voidspace.org.uk> References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> <496373B7.7000401@voidspace.org.uk> Message-ID: > Unfortunately we can't apply attributes to Python classes. I > get round > this particular problem by creating stub classes in C# and inheriting > from them in Python. See: > > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml Is there a CodePlex issue to resolve this? -- -- Lukas From dinov at microsoft.com Tue Jan 6 18:44:45 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 6 Jan 2009 09:44:45 -0800 Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> <496373B7.7000401@voidspace.org.uk> Message-ID: <350E7D38B6D819428718949920EC23555704BD0808@NA-EXMSG-C102.redmond.corp.microsoft.com> Strangely I don't see one - this is frequently asked for so I'm a little surprised :) I have a plan on how to enable this (and some other .NET scenarios) in the next major release. My current thinking is to support this via meta-classes and providing a new method on type which lets you specify the underlying .NET type used for the Python type. That will enable this feature to be implemented in Python along with other .NET interop features like: having a Python type which has a default constructor which is available to .NET (important for frameworks which use reflection to create instances). Having concrete .NET members which expose Python members (important for frameworks which use reflection for member access - e.g. data binding). People can then debate and throw around code for what the best syntax for .NET custom attributes is from Python and implement it themselves. If anyone has feedback on this I'd love to hear it. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Cenovsky, Lukas Sent: Tuesday, January 06, 2009 9:13 AM To: Discussion of IronPython Subject: Re: [IronPython] Get a string from JavaScript to IronPython > Unfortunately we can't apply attributes to Python classes. I > get round > this particular problem by creating stub classes in C# and inheriting > from them in Python. See: > > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml Is there a CodePlex issue to resolve this? -- -- Lukas _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From sh at defuze.org Tue Jan 6 19:02:24 2009 From: sh at defuze.org (Sylvain Hellegouarch) Date: Tue, 06 Jan 2009 19:02:24 +0100 Subject: [IronPython] IRC Channel? In-Reply-To: References: Message-ID: <49639CB0.8080104@defuze.org> Slide a ?crit : > Is there an IRC channel that people from the IP community hang out in > frequently? If not, I believe there is an unofficial channel on > freenode that could use some more people ;-) > > Indeed there is that unofficial one but it appears not so many people go there. Come one folks :) - Sylvain From kristian.jaksch at gmail.com Tue Jan 6 19:33:30 2009 From: kristian.jaksch at gmail.com (Kristian) Date: Tue, 6 Jan 2009 10:33:30 -0800 (PST) Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: <496373B7.7000401@voidspace.org.uk> References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> <496373B7.7000401@voidspace.org.uk> Message-ID: <2b29b2d3-ef72-4e47-b598-b162d1b81439@r41g2000prr.googlegroups.com> Thanks for the reply. I actually got it to work straight away :-) On Jan 6, 4:07?pm, Michael Foord wrote: > Kristian wrote: > > I have a code editor written in JavaScript on my page and I want to > > send the code that it is typed in as a string to IronPython so that it > > can be executed from IronPython. I got this to work in C# but not in > > IronPython. Below is the JavaScript I use: > > > ? ? > > > The code replaces a standard HTML-textarea with the JavaScript editor. > > The function "invokeManagedCode()" sends the text in the code editor > > to a C# method. The C# code is really simple: > > > namespace htmlDom1 > > { > > ? ? public partial class Page : UserControl > > ? ? { > > ? ? ? ? public Page() > > ? ? ? ? { > > ? ? ? ? ? ? InitializeComponent(); > > ? ? ? ? ? ? HtmlPage.RegisterScriptableObject("codeProvider", this); > > ? ? ? ? } > > > ? ? ? ? [ScriptableMember()] > > ? ? ? ? public void Code(string codeString) > > ? ? ? ? { > > ? ? ? ? ? ? this.Message.Text = codeString; > > ? ? ? ? } > > > ? ? } > > } > > > How can I achieve the same in IronPython? I tried to do exactly the > > same as in C#. See below: > > > [ScriptableMember()] > > Although this is valid Python syntax, it doesn't do what you think... > (It actually created a new list - but as you don't assign a name to it, > it will be garbage collected.) > > Unfortunately we can't apply attributes to Python classes. I get round > this particular problem by creating stub classes in C# and inheriting > from them in Python. See: > > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml > > All the best, > > Michael > > > > > def Code(codeString): > > ? ? root.sl2TextBox.Text = codeString # Show that it works by writing > > the string > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?# from the > > javascript code editor to a Silverlight textbox > > > HtmlPage.RegisterScriptableObject("codeProvider", Code) > > > But this doesn't work. How to do it properly? > > > Thanks for help! > > _______________________________________________ > > Users mailing list > > Us... at lists.ironpython.com > >http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > --http://www.ironpythoninaction.com/ > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at microsoft.com Tue Jan 6 20:24:59 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 6 Jan 2009 11:24:59 -0800 Subject: [IronPython] Weird performance issue In-Reply-To: <2679f6510901060607r3ad0bc1am4bb6701905f264df@mail.gmail.com> References: <2679f6510901060607r3ad0bc1am4bb6701905f264df@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704BD08E4@NA-EXMSG-C102.redmond.corp.microsoft.com> I think we are thrashing the hash code call site in CommonDictionaryStorage.HashSite._HashSite. Alternately it could be the equals call site in PythonContext._equalRetBoolSite. Similar to the property issue you can look at the call site object and see if it's going to the fixed read-only EmptyRuleSet. We can probably add 2 sites which are per-dictionary but we might need to do something more clever as that could regress general dictionary perf. The DLR team is going to be looking into general issues with understanding what's going on with call sites. Yesterday I pointed out performance investigations as being something important for them to look at. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Glenn Jones Sent: Tuesday, January 06, 2009 6:07 AM To: Discussion of IronPython Subject: [IronPython] Weird performance issue Hi all, More from the Resolver One upgrade: We are seeing several performance failures in our tests, which we expect because the performance profile of IPy2 is different to IPy1. There is one that is perplexing and we hope that someone can give us some insight into possible causes for us to investigate. One of our performance tests only fails when it is preceded by other tests. There is (as far as we can tell) no shared state between the tests. After much poking around, we discovered that replacing a set with a list caused the performance to improve from ~700ms down to ~100ms. We have been unable get a minimal repro, so far. Here's a little more detail on the how the code works: class Thing(object): def run(arg1, arg2): * do some stuff s = set() * do stuff that populates s return list(s) We create a Thing and call run so that the set contains an entry, if we then create a new Thing and call the run method it takes 10 times longer than expected. If we change s = set to s = [] (and convert s.add to s.append, where appropriate), and do the same as above, the second call to run behaves as we expect. There is (at least in our code) nothing shared between the first call to run and the second call. Does anyone have any ideas about where we can look to work out what's happening? Any suggestions for ways to diagnose this? Thanks Glenn & Kamil -------------- next part -------------- An HTML attachment was scrubbed... URL: From caspar.lessing at gmail.com Tue Jan 6 21:07:16 2009 From: caspar.lessing at gmail.com (Caspar Lessing) Date: Tue, 6 Jan 2009 22:07:16 +0200 Subject: [IronPython] Global and Local ScriptScope In-Reply-To: References: Message-ID: You are right, it is basically a "from pricy_scope import *" for each one of my local scopes. I considered doing that, but decided against it as I'm really loathe to copy the context a whole bunch of times. The number of symbols _should_ not be excessive but the pricy_scope setup script is configuration and eventually could have a fair amount of symbols. The number of local contexts however will be fairly high. Thousands to 10s of thousands. So copying gets multiplied by that. So I am trying hard not do the copying thing. However the Scope Parent mechanism is perfectly suited for wat I need. So I was hoping I could use that which means no copying required. On Tue, Jan 6, 2009 at 4:56 PM, Curt Hagenlocher wrote: > How many symbols are there in this shared global context? Can't you just > initialize them in one ScriptScope and then copy the symbols into the other > ScriptScopes where you want to use them? This would be analogous to saying > "from pricy_scope import *" at the beginning of each module. > > On Tue, Jan 6, 2009 at 5:58 AM, Caspar Lessing wrote: > >> Hello People >> >> I use an embedded instance of IronPython. >> My program spends effort to create a global context. It then continues to >> to execute statements inside a local context which need resolve the items in >> the global context as well. Think of python functions' local context and its >> interaction with the module context. >> >> In an older version of IronPython I had a EngineModule which I used for my >> global context and I could use a Dictionary for my locals. >> >> This allowed my to do the following: >> >> PythonEngine pe = new PythonEngine(); >> Context = pe.CreateModule(); >> pe.Execute(ExpensiveGlobalSetupScript,Context); >> Dictionary[] locals = new >> Dictionary[ScriptList.Length]; >> for(int i = 0; i < ScriptList.Length; i++) >> { >> locals[i] = new Dictionary() >> pe.Execute(ScriptList[i], Context, locals[i]); >> } >> >> I am having trouble doing something similar with ScriptScope. I have >> explored some avenues: >> 1. Copying the global context into each local one. It seems too expensive. >> Possibly it is only the cloning of some form of dictionary, but still. >> 2. Implementing a new CustomSymbolDictionary and overriding >> TryGetExtraValue. Problem is that it is called before trying to resolve >> symbols internally (Which leads to globals being resolved rather than >> locals) >> 3. Creating my own implementation of IAttributesCollection (Seemed too >> complex after discovering the Parent mechanism in Scope) >> >> I eventually found the Parent mechanism inside Scope. However I do not >> have access to create a new ScriptScope (Internal constructor) based on a >> Parent Scope. >> I had to create a new Factory method inside ScriptEngine which looks as >> follows: >> >> public sealed class ScriptEngine >> { >> ..... >> public ScriptScope CreateScope(ScriptScope parent) >> { >> ContractUtils.RequiresNotNull(parent, "parent"); >> return new ScriptScope(this, new Scope(parent.Scope,null)); >> } >> .... >> } >> >> My question if whether this is a sensible addition to ScriptEngine or am I >> missing something? >> >> Much appreciated >> Caz >> >> _______________________________________________ >> 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 curt at hagenlocher.org Tue Jan 6 21:39:57 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 6 Jan 2009 12:39:57 -0800 Subject: [IronPython] Global and Local ScriptScope In-Reply-To: References: Message-ID: Scopes are intended for the language-implementation side of things. Languages like Ruby and Javascript support nested lexical scoping but Python does not. Even if we were to expose a mechanism in the hosting API that let you create ScriptScopes which reference nested Scopes, there's no guarantee that Python's name resolution would automatically work with this. You shouldn't need to define your own implementation of IAttributesCollection. Can't you just use the SymbolDictionary defined in Microsoft.Scripting and fill it manually? On Tue, Jan 6, 2009 at 12:07 PM, Caspar Lessing wrote: > You are right, it is basically a "from pricy_scope import *" for each one > of my local scopes. > > I considered doing that, but decided against it as I'm really loathe to > copy the context a whole bunch of times. The number of symbols _should_ not > be excessive but the pricy_scope setup script is configuration and > eventually could have a fair amount of symbols. The number of local contexts > however will be fairly high. Thousands to 10s of thousands. So copying gets > multiplied by that. So I am trying hard not do the copying thing. > > However the Scope Parent mechanism is perfectly suited for wat I need. So I > was hoping I could use that which means no copying required. > > > > On Tue, Jan 6, 2009 at 4:56 PM, Curt Hagenlocher wrote: > >> How many symbols are there in this shared global context? Can't you just >> initialize them in one ScriptScope and then copy the symbols into the other >> ScriptScopes where you want to use them? This would be analogous to saying >> "from pricy_scope import *" at the beginning of each module. >> >> On Tue, Jan 6, 2009 at 5:58 AM, Caspar Lessing wrote: >> >>> Hello People >>> >>> I use an embedded instance of IronPython. >>> My program spends effort to create a global context. It then continues to >>> to execute statements inside a local context which need resolve the items in >>> the global context as well. Think of python functions' local context and its >>> interaction with the module context. >>> >>> In an older version of IronPython I had a EngineModule which I used for >>> my global context and I could use a Dictionary for my locals. >>> >>> This allowed my to do the following: >>> >>> PythonEngine pe = new PythonEngine(); >>> Context = pe.CreateModule(); >>> pe.Execute(ExpensiveGlobalSetupScript,Context); >>> Dictionary[] locals = new >>> Dictionary[ScriptList.Length]; >>> for(int i = 0; i < ScriptList.Length; i++) >>> { >>> locals[i] = new Dictionary() >>> pe.Execute(ScriptList[i], Context, locals[i]); >>> } >>> >>> I am having trouble doing something similar with ScriptScope. I have >>> explored some avenues: >>> 1. Copying the global context into each local one. It seems too >>> expensive. Possibly it is only the cloning of some form of dictionary, but >>> still. >>> 2. Implementing a new CustomSymbolDictionary and overriding >>> TryGetExtraValue. Problem is that it is called before trying to resolve >>> symbols internally (Which leads to globals being resolved rather than >>> locals) >>> 3. Creating my own implementation of IAttributesCollection (Seemed too >>> complex after discovering the Parent mechanism in Scope) >>> >>> I eventually found the Parent mechanism inside Scope. However I do not >>> have access to create a new ScriptScope (Internal constructor) based on a >>> Parent Scope. >>> I had to create a new Factory method inside ScriptEngine which looks as >>> follows: >>> >>> public sealed class ScriptEngine >>> { >>> ..... >>> public ScriptScope CreateScope(ScriptScope parent) >>> { >>> ContractUtils.RequiresNotNull(parent, "parent"); >>> return new ScriptScope(this, new Scope(parent.Scope,null)); >>> } >>> .... >>> } >>> >>> My question if whether this is a sensible addition to ScriptEngine or am >>> I missing something? >>> >>> Much appreciated >>> Caz >>> >>> _______________________________________________ >>> 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 Tomas.Matousek at microsoft.com Tue Jan 6 21:59:31 2009 From: Tomas.Matousek at microsoft.com (Tomas Matousek) Date: Tue, 6 Jan 2009 12:59:31 -0800 Subject: [IronPython] Global and Local ScriptScope In-Reply-To: References: Message-ID: The current scope chaining is rather a remnant of a legacy technique of using Scopes for local variables in IronPython and JScript. The hosting API doesn't support chaining by design (this might change in future). The best option for you for now, I think, is to implement IAttributesCollection. That is the way the host should customize scope variable lookup. What we need to do on our side is to simplify this interface. Tomas From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 06, 2009 12:40 PM To: Discussion of IronPython Subject: Re: [IronPython] Global and Local ScriptScope Scopes are intended for the language-implementation side of things. Languages like Ruby and Javascript support nested lexical scoping but Python does not. Even if we were to expose a mechanism in the hosting API that let you create ScriptScopes which reference nested Scopes, there's no guarantee that Python's name resolution would automatically work with this. You shouldn't need to define your own implementation of IAttributesCollection. Can't you just use the SymbolDictionary defined in Microsoft.Scripting and fill it manually? On Tue, Jan 6, 2009 at 12:07 PM, Caspar Lessing > wrote: You are right, it is basically a "from pricy_scope import *" for each one of my local scopes. I considered doing that, but decided against it as I'm really loathe to copy the context a whole bunch of times. The number of symbols _should_ not be excessive but the pricy_scope setup script is configuration and eventually could have a fair amount of symbols. The number of local contexts however will be fairly high. Thousands to 10s of thousands. So copying gets multiplied by that. So I am trying hard not do the copying thing. However the Scope Parent mechanism is perfectly suited for wat I need. So I was hoping I could use that which means no copying required. On Tue, Jan 6, 2009 at 4:56 PM, Curt Hagenlocher > wrote: How many symbols are there in this shared global context? Can't you just initialize them in one ScriptScope and then copy the symbols into the other ScriptScopes where you want to use them? This would be analogous to saying "from pricy_scope import *" at the beginning of each module. On Tue, Jan 6, 2009 at 5:58 AM, Caspar Lessing > wrote: Hello People I use an embedded instance of IronPython. My program spends effort to create a global context. It then continues to to execute statements inside a local context which need resolve the items in the global context as well. Think of python functions' local context and its interaction with the module context. In an older version of IronPython I had a EngineModule which I used for my global context and I could use a Dictionary for my locals. This allowed my to do the following: PythonEngine pe = new PythonEngine(); Context = pe.CreateModule(); pe.Execute(ExpensiveGlobalSetupScript,Context); Dictionary[] locals = new Dictionary[ScriptList.Length]; for(int i = 0; i < ScriptList.Length; i++) { locals[i] = new Dictionary() pe.Execute(ScriptList[i], Context, locals[i]); } I am having trouble doing something similar with ScriptScope. I have explored some avenues: 1. Copying the global context into each local one. It seems too expensive. Possibly it is only the cloning of some form of dictionary, but still. 2. Implementing a new CustomSymbolDictionary and overriding TryGetExtraValue. Problem is that it is called before trying to resolve symbols internally (Which leads to globals being resolved rather than locals) 3. Creating my own implementation of IAttributesCollection (Seemed too complex after discovering the Parent mechanism in Scope) I eventually found the Parent mechanism inside Scope. However I do not have access to create a new ScriptScope (Internal constructor) based on a Parent Scope. I had to create a new Factory method inside ScriptEngine which looks as follows: public sealed class ScriptEngine { ..... public ScriptScope CreateScope(ScriptScope parent) { ContractUtils.RequiresNotNull(parent, "parent"); return new ScriptScope(this, new Scope(parent.Scope,null)); } .... } My question if whether this is a sensible addition to ScriptEngine or am I missing something? Much appreciated Caz _______________________________________________ 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 fuzzyman at voidspace.org.uk Wed Jan 7 00:07:01 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 06 Jan 2009 23:07:01 +0000 Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: <350E7D38B6D819428718949920EC23555704BD0808@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> <496373B7.7000401@voidspace.org.uk> <350E7D38B6D819428718949920EC23555704BD0808@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4963E415.8030202@voidspace.org.uk> Dino Viehland wrote: > Strangely I don't see one - this is frequently asked for so I'm a little surprised :) > > I have a plan on how to enable this (and some other .NET scenarios) in the next major release. My current thinking is to support this via meta-classes and providing a new method on type which lets you specify the underlying .NET type used for the Python type. That will enable this feature to be implemented in Python along with other .NET interop features like: > having a Python type which has a default constructor which is available to .NET (important for frameworks which use reflection to create instances). > Having concrete .NET members which expose Python members (important for frameworks which use reflection for member access - e.g. data binding). > > People can then debate and throw around code for what the best syntax for .NET custom attributes is from Python and implement it themselves. If anyone has feedback on this I'd love to hear it. > If the class is created by type then ordinary decorator syntax could be used - attaching metadata to the methods which type could use. If a pure Python class uses attributes then I guess a real .NET type would need to be created, which may restrict some of the things that can be done to the class. Definitely a price worth paying if it allows us to use attributes. Being able to use Python classes with frameworks that use reflection would also be great! Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Cenovsky, Lukas > Sent: Tuesday, January 06, 2009 9:13 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Get a string from JavaScript to IronPython > > >> Unfortunately we can't apply attributes to Python classes. I >> get round >> this particular problem by creating stub classes in C# and inheriting >> from them in Python. See: >> >> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml >> > > Is there a CodePlex issue to resolve this? > > -- > -- Lukas > > _______________________________________________ > 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 dinov at microsoft.com Wed Jan 7 00:22:01 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 6 Jan 2009 15:22:01 -0800 Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: <4963E415.8030202@voidspace.org.uk> References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com> <496373B7.7000401@voidspace.org.uk> <350E7D38B6D819428718949920EC23555704BD0808@NA-EXMSG-C102.redmond.corp.microsoft.com> <4963E415.8030202@voidspace.org.uk> Message-ID: <350E7D38B6D819428718949920EC23555704BD0AF0@NA-EXMSG-C102.redmond.corp.microsoft.com> Yep, I agree that's the right way to go about the actual Python side of the implementation of custom attributes. Of course there's also: field support w/ custom attributes (which would presumably need a new descriptor) property support w/ CAs (and properties can't have arbitrary attached attributes, so maybe another new descriptor needs to be defined) event support? Etc... The restrictions should be fairly minimal and also depend upon what the new underlying system type does. For example for custom attributes it may be the case that there are no restrictions. You can always re-assign the functions and have the methods defined which have the custom attributes on them dispatch through the PythonType to even allow the implementations to be replaced at runtime like you can normally. For defining a concrete .NET type I would expect only that assigning to __class__ would be invalid. Also, my expectation is that in the future when there's consensus on various helpers which use this new feature, and what features they should have, that we'll add the most important ones to the clr module as built-ins. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Tuesday, January 06, 2009 3:07 PM To: Discussion of IronPython Subject: Re: [IronPython] Get a string from JavaScript to IronPython Dino Viehland wrote: > Strangely I don't see one - this is frequently asked for so I'm a little surprised :) > > I have a plan on how to enable this (and some other .NET scenarios) in the next major release. My current thinking is to support this via meta-classes and providing a new method on type which lets you specify the underlying .NET type used for the Python type. That will enable this feature to be implemented in Python along with other .NET interop features like: > having a Python type which has a default constructor which is available to .NET (important for frameworks which use reflection to create instances). > Having concrete .NET members which expose Python members (important for frameworks which use reflection for member access - e.g. data binding). > > People can then debate and throw around code for what the best syntax for .NET custom attributes is from Python and implement it themselves. If anyone has feedback on this I'd love to hear it. > If the class is created by type then ordinary decorator syntax could be used - attaching metadata to the methods which type could use. If a pure Python class uses attributes then I guess a real .NET type would need to be created, which may restrict some of the things that can be done to the class. Definitely a price worth paying if it allows us to use attributes. Being able to use Python classes with frameworks that use reflection would also be great! Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Cenovsky, Lukas > Sent: Tuesday, January 06, 2009 9:13 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Get a string from JavaScript to IronPython > > >> Unfortunately we can't apply attributes to Python classes. I >> get round >> this particular problem by creating stub classes in C# and inheriting >> from them in Python. See: >> >> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml >> > > Is there a CodePlex issue to resolve this? > > -- > -- Lukas > > _______________________________________________ > 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 _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From caspar.lessing at gmail.com Wed Jan 7 08:15:58 2009 From: caspar.lessing at gmail.com (Caspar Lessing) Date: Wed, 7 Jan 2009 09:15:58 +0200 Subject: [IronPython] Global and Local ScriptScope In-Reply-To: References: Message-ID: That answers my question. Thanx guys. Regards Caz On Tue, Jan 6, 2009 at 10:59 PM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote: > The current scope chaining is rather a remnant of a legacy technique of > using Scopes for local variables in IronPython and JScript. The hosting API > doesn't support chaining by design (this might change in future). The best > option for you for now, I think, is to implement IAttributesCollection. That > is the way the host should customize scope variable lookup. What we need to > do on our side is to simplify this interface. > > > > Tomas > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Curt Hagenlocher > *Sent:* Tuesday, January 06, 2009 12:40 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Global and Local ScriptScope > > > > Scopes are intended for the language-implementation side of things. > Languages like Ruby and Javascript support nested lexical scoping but > Python does not. Even if we were to expose a mechanism in the hosting API > that let you create ScriptScopes which reference nested Scopes, there's no > guarantee that Python's name resolution would automatically work with this. > > > > You shouldn't need to define your own implementation of > IAttributesCollection. Can't you just use the SymbolDictionary defined in > Microsoft.Scripting and fill it manually? > > On Tue, Jan 6, 2009 at 12:07 PM, Caspar Lessing > wrote: > > You are right, it is basically a "from pricy_scope import *" for each one > of my local scopes. > > I considered doing that, but decided against it as I'm really loathe to > copy the context a whole bunch of times. The number of symbols _should_ not > be excessive but the pricy_scope setup script is configuration and > eventually could have a fair amount of symbols. The number of local contexts > however will be fairly high. Thousands to 10s of thousands. So copying gets > multiplied by that. So I am trying hard not do the copying thing. > > However the Scope Parent mechanism is perfectly suited for wat I need. So I > was hoping I could use that which means no copying required. > > > > On Tue, Jan 6, 2009 at 4:56 PM, Curt Hagenlocher > wrote: > > How many symbols are there in this shared global context? Can't you just > initialize them in one ScriptScope and then copy the symbols into the other > ScriptScopes where you want to use them? This would be analogous to saying > "from pricy_scope import *" at the beginning of each module. > > On Tue, Jan 6, 2009 at 5:58 AM, Caspar Lessing > wrote: > > Hello People > > I use an embedded instance of IronPython. > My program spends effort to create a global context. It then continues to > to execute statements inside a local context which need resolve the items in > the global context as well. Think of python functions' local context and its > interaction with the module context. > > In an older version of IronPython I had a EngineModule which I used for my > global context and I could use a Dictionary for my locals. > > This allowed my to do the following: > > PythonEngine pe = new PythonEngine(); > Context = pe.CreateModule(); > pe.Execute(ExpensiveGlobalSetupScript,Context); > Dictionary[] locals = new > Dictionary[ScriptList.Length]; > for(int i = 0; i < ScriptList.Length; i++) > { > locals[i] = new Dictionary() > pe.Execute(ScriptList[i], Context, locals[i]); > } > > I am having trouble doing something similar with ScriptScope. I have > explored some avenues: > 1. Copying the global context into each local one. It seems too expensive. > Possibly it is only the cloning of some form of dictionary, but still. > 2. Implementing a new CustomSymbolDictionary and overriding > TryGetExtraValue. Problem is that it is called before trying to resolve > symbols internally (Which leads to globals being resolved rather than > locals) > 3. Creating my own implementation of IAttributesCollection (Seemed too > complex after discovering the Parent mechanism in Scope) > > I eventually found the Parent mechanism inside Scope. However I do not have > access to create a new ScriptScope (Internal constructor) based on a Parent > Scope. > I had to create a new Factory method inside ScriptEngine which looks as > follows: > > public sealed class ScriptEngine > { > ..... > public ScriptScope CreateScope(ScriptScope parent) > { > ContractUtils.RequiresNotNull(parent, "parent"); > return new ScriptScope(this, new Scope(parent.Scope,null)); > } > .... > } > > My question if whether this is a sensible addition to ScriptEngine or am I > missing something? > > Much appreciated > Caz > > _______________________________________________ > 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 lukas.cenovsky at radiantsystems.com Wed Jan 7 16:54:55 2009 From: lukas.cenovsky at radiantsystems.com (Cenovsky, Lukas) Date: Wed, 7 Jan 2009 10:54:55 -0500 Subject: [IronPython] Get a string from JavaScript to IronPython In-Reply-To: <350E7D38B6D819428718949920EC23555704BD0808@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <5b84df87-1fa7-41c1-b4d4-a3f423acdddf@i24g2000prf.googlegroups.com><496373B7.7000401@voidspace.org.uk> <350E7D38B6D819428718949920EC23555704BD0808@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: I did not see any too, so I have created one: Item #20489: Add .NET attribute support http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20489 Vote guys if you want it ;-) -- -- Lukas > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland > Sent: Tuesday, January 06, 2009 6:45 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Get a string from JavaScript to IronPython > > Strangely I don't see one - this is frequently asked for so > I'm a little surprised :) > > I have a plan on how to enable this (and some other .NET > scenarios) in the next major release. My current thinking is > to support this via meta-classes and providing a new method > on type which lets you specify the underlying .NET type used > for the Python type. That will enable this feature to be > implemented in Python along with other .NET interop features like: > having a Python type which has a default constructor > which is available to .NET (important for frameworks which > use reflection to create instances). > Having concrete .NET members which expose Python > members (important for frameworks which use reflection for > member access - e.g. data binding). > > People can then debate and throw around code for what the > best syntax for .NET custom attributes is from Python and > implement it themselves. If anyone has feedback on this I'd > love to hear it. > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of > Cenovsky, Lukas > Sent: Tuesday, January 06, 2009 9:13 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Get a string from JavaScript to IronPython > > > Unfortunately we can't apply attributes to Python classes. I > > get round > > this particular problem by creating stub classes in C# and > inheriting > > from them in Python. See: > > > > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml > > Is there a CodePlex issue to resolve this? > > -- > -- Lukas > > _______________________________________________ > 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 dan.eloff at gmail.com Wed Jan 7 21:51:21 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 7 Jan 2009 15:51:21 -0500 Subject: [IronPython] ThrowingErrorSink and CompilerContext Message-ID: <4817b6fc0901071251s7958ae29v838a51feeac80648@mail.gmail.com> Internally, in compile builtin, IronPython creates a CompilerContext like: new CompilerContext(sourceUnit, opts, ThrowingErrorSink.Default) But ThrowingErrorSink is internal, what can I do to get a equivalent CompilerContext? This is blocking the _ast module from running on unpatched IronPython. Thanks, -Dan From dinov at microsoft.com Wed Jan 7 21:59:53 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 7 Jan 2009 12:59:53 -0800 Subject: [IronPython] ThrowingErrorSink and CompilerContext In-Reply-To: <4817b6fc0901071251s7958ae29v838a51feeac80648@mail.gmail.com> References: <4817b6fc0901071251s7958ae29v838a51feeac80648@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704BD0F8D@NA-EXMSG-C102.redmond.corp.microsoft.com> You should be able to just copy and paste throwing error sink into your own version, it's pretty simple: internal class ThrowingErrorSink : ErrorSink { public static new readonly ThrowingErrorSink/*!*/ Default = new ThrowingErrorSink(); private ThrowingErrorSink() { } public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) { if (severity == Severity.Warning) { throw PythonOps.SyntaxWarning(message, sourceUnit, span, errorCode); } else { throw PythonOps.SyntaxError(message, sourceUnit, span, errorCode); } } } -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff Sent: Wednesday, January 07, 2009 12:51 PM To: Discussion of IronPython Subject: [IronPython] ThrowingErrorSink and CompilerContext Internally, in compile builtin, IronPython creates a CompilerContext like: new CompilerContext(sourceUnit, opts, ThrowingErrorSink.Default) But ThrowingErrorSink is internal, what can I do to get a equivalent CompilerContext? This is blocking the _ast module from running on unpatched IronPython. Thanks, -Dan _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kamil at dworakowski.name Wed Jan 7 22:10:51 2009 From: kamil at dworakowski.name (Kamil Dworakowski) Date: Wed, 7 Jan 2009 13:10:51 -0800 (PST) Subject: [IronPython] weird performance issue In-Reply-To: <350E7D38B6D819428718949920EC2355564BF25556@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <93fc29d60812161107y79acc3dqbd99391e42f24eed@mail.gmail.com> <350E7D38B6D819428718949920EC2355564BF25378@NA-EXMSG-C102.redmond.corp.microsoft.com> <93fc29d60812171002r1ff25939v67fbae80be9dee7a@mail.gmail.com> <350E7D38B6D819428718949920EC2355564BF25556@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <758523a8-c973-4b70-93db-392224df77e1@k1g2000prb.googlegroups.com> Dino, sorry for the late reply. I have checked that the patch you gave us made the performance test pass (only one though). I hope it will get into next release. I don't know how to collect the call stacks you asked for. On Dec 17 2008, 7:04?pm, Dino Viehland wrote: > Oh, if you also want to get a list of call stacks to PythonContext.Call and send those our way that'd be useful as well. > > In general we only want to hit that when the overall cost of whatever we're doing will dwarf any overhead of that one call. ?And we certainly have more calls to it then we should :( > > > > > -----Original Message----- > > From: users-boun... at lists.ironpython.com [mailto:users- > > boun... at lists.ironpython.com] On Behalf Of Kamil Dworakowski > > Sent: Wednesday, December 17, 2008 10:03 AM > > To: Discussion of IronPython > > Subject: Re: [IronPython] weird performance issue > > > Thanks Dino, it looks like you are right. I print whenever > > _supportAdding == false. > > It happens a lot with the snippet executed, whereas it doesn't happen > > at all with > > the snippet commented out. > > > We also discovered that the slow down only occurs when we compile code > > to dlls (no _supportAdding == false if runned from sources). > > Still can't come up with a repro though. If you provide us with a > > patch, we can > > test if it solves the problem in our code. > > > As a short term solution we have removed all the properties from > > decorated functions. This fixed one performance test. We moved to > > other performance tests and we still see that some functions are > > slower when executed from dlls, so the same slow down might be > > triggered by sth else. > > > On Wed, Dec 17, 2008 at 3:21 AM, Dino Viehland > > wrote: > > > My guess would be that we're pushing the PythonContext._callSplatSite > > outside of the sweet spot in DLR site caches. > > > > You could check this by putting a breakpoint in > > PythonContext.Call(object, params object[]). ?Then look and see if > > _callSplatSite._rules is an instance of EmptyRuleSet with > > _supportAdding == false. > > > > If this is the cause it should be pretty easy to fix - property's > > should probably get their own call site object so it'll be specialized > > to the specific property (maybe we could share a common one of the > > function is a PythonFunction as these generate highly shareable calls > > between multiple function instances). ?We're also doing a params call > > today which we could stop doing and get a nice perf boost on > > properties. > > > >> -----Original Message----- > > >> From: users-boun... at lists.ironpython.com [mailto:users- > > >> boun... at lists.ironpython.com] On Behalf Of Kamil Dworakowski > > >> Sent: Tuesday, December 16, 2008 11:08 AM > > >> To: us... at lists.ironpython.com > > >> Subject: [IronPython] weird performance issue > > > >> We see a very strange side effect of running the follwing code on > > the > > >> performance of recalculations in Resolver One. > > > >> def Dumbcorator(fn): > > >> ? ? def _inner(self, *args): > > >> ? ? ? ? return fn(self, *args) > > >> ? ? return _inner > > > >> class Locker(object): > > >> ? ? @property > > >> ? ? @Dumbcorator > > >> ? ? def thing(self): > > >> ? ? ? ? return 2 > > > >> l = Locker() > > >> l.thing > > > >> Specifically, one of the performance test reports results 4 to 8 > > times > > >> worse with this snippet in than without (the clock is turned on > > after > > >> this snippet executes). If I comment out this snippet from the code, > > >> it suddenly runs 4 to 8 times faster. The fact that I can comment it > > >> out means that it is not used in the test, so it is bizzare that it > > >> slows it down. > > > >> We can't reproduce the slow down in a clean example though. I hope > > >> something clicks for somebody and gives me a hint as to what is > > going > > >> on. Tomorrow I'll continue on trying to minimize the code that is > > >> being slowed down, and hopefully come up with some decent repro. > > >> _______________________________________________ > > >> Users mailing list > > >> Us... at lists.ironpython.com > > >>http://lists.ironpython.com/listinfo.cgi/users-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.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 dan.eloff at gmail.com Thu Jan 8 01:51:26 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 7 Jan 2009 19:51:26 -0500 Subject: [IronPython] ThrowingErrorSink and CompilerContext In-Reply-To: <350E7D38B6D819428718949920EC23555704BD0F8D@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <4817b6fc0901071251s7958ae29v838a51feeac80648@mail.gmail.com> <350E7D38B6D819428718949920EC23555704BD0F8D@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4817b6fc0901071651h1249e11ai1dd0e945ce869eb6@mail.gmail.com> Thanks, I'll do that. On Wed, Jan 7, 2009 at 3:59 PM, Dino Viehland wrote: > You should be able to just copy and paste throwing error sink into your own version, it's pretty simple: > > internal class ThrowingErrorSink : ErrorSink { > public static new readonly ThrowingErrorSink/*!*/ Default = new ThrowingErrorSink(); > > private ThrowingErrorSink() { > } > > public override void Add(SourceUnit sourceUnit, string message, SourceSpan span, int errorCode, Severity severity) { > if (severity == Severity.Warning) { > throw PythonOps.SyntaxWarning(message, sourceUnit, span, errorCode); > } else { > throw PythonOps.SyntaxError(message, sourceUnit, span, errorCode); > } > } > } > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff > Sent: Wednesday, January 07, 2009 12:51 PM > To: Discussion of IronPython > Subject: [IronPython] ThrowingErrorSink and CompilerContext > > Internally, in compile builtin, IronPython creates a CompilerContext like: > > new CompilerContext(sourceUnit, opts, ThrowingErrorSink.Default) > > But ThrowingErrorSink is internal, what can I do to get a equivalent > CompilerContext? > > This is blocking the _ast module from running on unpatched IronPython. > > Thanks, > -Dan > _______________________________________________ > 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 oren at held.org.il Thu Jan 8 14:20:15 2009 From: oren at held.org.il (Oren Held) Date: Thu, 08 Jan 2009 15:20:15 +0200 Subject: [IronPython] platform.system() == "cli" Message-ID: <200901081520.15651.oren@held.org.il> Hi Guys, The following calls return "cli" instead of, what I would expect, "win32" or something simliar: platform.system() sys.platform I'm aware that it's not a new issue (it was mentioned here and there), but I still couldn't figure out why this behaviour is preserved.. Shouldn't it be changed? 10x - Oren From dblank at brynmawr.edu Thu Jan 8 16:31:34 2009 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Thu, 08 Jan 2009 10:31:34 -0500 Subject: [IronPython] DLR Languages? Message-ID: <49661C56.8090502@brynmawr.edu> Hello all, (This might not be the right place for this question...) What are the current DLR languages, and their states? I'm wondering about those early stabs, ones under development, from MS and others. I'm especially interested in those that can be run cross-platform. I'd like to see a list of resources, like: Project: IronPython Developer: Microsoft URL: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython Version: 2.0 State: mature DLR State: current License: Microsoft Public License Available as: source, binaries Project: IronRuby Developer: Microsoft URL: http://www.ironruby.net/ Version: 1.0 alpha 2, source only State: active development DLR State: current License: Microsoft Public License Available as: source Project: IronScheme Developer: leppie URL: http://www.codeplex.com/IronScheme Version: 1.0 beta 1 (Oct 2008) DLR state: early adopter; actively removing DLR? License: Microsoft Public License Available as: source Not sure about: Project: Visual Basic 10 Developer: Microsoft URL: http://msdn.microsoft.com/en-us/vbasic/default.aspx Version: 10 State: under development? DLR state: planned? License: ? Available as: binaries only? Project: Managed JScript Developer: Microsoft URL: http://blogs.msdn.com/jscript/archive/2007/05/04/managed-jscript-announced.aspx Version: 1 State: mature DLR state: ? License: ? Available as: binaries only? Also, what about F# and J#? I'm also working with a couple of groups who are actively developing additional DLR languages, including a graphical data flow language, and a proper tail-call recursion implementation of Scheme (using continuation-passing style). More on those here soon, I hope. If you have additions or corrections to the above list, please let us know. Thanks! -Doug From curt at hagenlocher.org Thu Jan 8 17:20:31 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 8 Jan 2009 08:20:31 -0800 Subject: [IronPython] DLR Languages? In-Reply-To: <49661C56.8090502@brynmawr.edu> References: <49661C56.8090502@brynmawr.edu> Message-ID: Here's what I know: 1. I've heard that Don Syme has been thinking about DLR integration for F#, but nothing has been announced.2. According to http://msdn.microsoft.com/en-us/vjsharp/default.aspx, J# is "retired" so I don't think you can expect any further versions. 3. There aren't any firm plans yet for the future of Javascript on the DLR. 4. In Visual Studio 2010, VB.NET will have the same level of support for the DLR as C#. There were at least two different people working on an "IronLua", but I think that both projects are stalled. On Thu, Jan 8, 2009 at 7:31 AM, Douglas S. Blank wrote: > Hello all, > > (This might not be the right place for this question...) What are the > current DLR languages, and their states? I'm wondering about those early > stabs, ones under development, from MS and others. I'm especially interested > in those that can be run cross-platform. I'd like to see a list of > resources, like: > > Project: IronPython > Developer: Microsoft > URL: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython > Version: 2.0 > State: mature > DLR State: current > License: Microsoft Public License > Available as: source, binaries > > Project: IronRuby > Developer: Microsoft > URL: http://www.ironruby.net/ > Version: 1.0 alpha 2, source only > State: active development > DLR State: current > License: Microsoft Public License > Available as: source > > Project: IronScheme > Developer: leppie > URL: http://www.codeplex.com/IronScheme > Version: 1.0 beta 1 (Oct 2008) > DLR state: early adopter; actively removing DLR? > License: Microsoft Public License > Available as: source > > Not sure about: > > Project: Visual Basic 10 > Developer: Microsoft > URL: http://msdn.microsoft.com/en-us/vbasic/default.aspx > Version: 10 > State: under development? > DLR state: planned? > License: ? > Available as: binaries only? > > Project: Managed JScript > Developer: Microsoft > URL: > http://blogs.msdn.com/jscript/archive/2007/05/04/managed-jscript-announced.aspx > Version: 1 > State: mature > DLR state: ? > License: ? > Available as: binaries only? > > Also, what about F# and J#? > > I'm also working with a couple of groups who are actively developing > additional DLR languages, including a graphical data flow language, and a > proper tail-call recursion implementation of Scheme (using > continuation-passing style). More on those here soon, I hope. > > If you have additions or corrections to the above list, please let us know. > > Thanks! > > -Doug > _______________________________________________ > 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 Thu Jan 8 17:21:13 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 8 Jan 2009 08:21:13 -0800 Subject: [IronPython] DLR Languages? In-Reply-To: References: <49661C56.8090502@brynmawr.edu> Message-ID: (In case it's not obvious, the IronLua efforts were not at Microsoft.) On Thu, Jan 8, 2009 at 8:20 AM, Curt Hagenlocher wrote: > Here's what I know: > > 1. I've heard that Don Syme has been thinking about DLR integration for F#, > but nothing has been announced.2. According to > http://msdn.microsoft.com/en-us/vjsharp/default.aspx, J# is "retired" so I > don't think you can expect any further versions. > 3. There aren't any firm plans yet for the future of Javascript on the DLR. > 4. In Visual Studio 2010, VB.NET will have the same level of support for > the DLR as C#. > > There were at least two different people working on an "IronLua", but I > think that both projects are stalled. > > On Thu, Jan 8, 2009 at 7:31 AM, Douglas S. Blank wrote: > >> Hello all, >> >> (This might not be the right place for this question...) What are the >> current DLR languages, and their states? I'm wondering about those early >> stabs, ones under development, from MS and others. I'm especially interested >> in those that can be run cross-platform. I'd like to see a list of >> resources, like: >> >> Project: IronPython >> Developer: Microsoft >> URL: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython >> Version: 2.0 >> State: mature >> DLR State: current >> License: Microsoft Public License >> Available as: source, binaries >> >> Project: IronRuby >> Developer: Microsoft >> URL: http://www.ironruby.net/ >> Version: 1.0 alpha 2, source only >> State: active development >> DLR State: current >> License: Microsoft Public License >> Available as: source >> >> Project: IronScheme >> Developer: leppie >> URL: http://www.codeplex.com/IronScheme >> Version: 1.0 beta 1 (Oct 2008) >> DLR state: early adopter; actively removing DLR? >> License: Microsoft Public License >> Available as: source >> >> Not sure about: >> >> Project: Visual Basic 10 >> Developer: Microsoft >> URL: http://msdn.microsoft.com/en-us/vbasic/default.aspx >> Version: 10 >> State: under development? >> DLR state: planned? >> License: ? >> Available as: binaries only? >> >> Project: Managed JScript >> Developer: Microsoft >> URL: >> http://blogs.msdn.com/jscript/archive/2007/05/04/managed-jscript-announced.aspx >> Version: 1 >> State: mature >> DLR state: ? >> License: ? >> Available as: binaries only? >> >> Also, what about F# and J#? >> >> I'm also working with a couple of groups who are actively developing >> additional DLR languages, including a graphical data flow language, and a >> proper tail-call recursion implementation of Scheme (using >> continuation-passing style). More on those here soon, I hope. >> >> If you have additions or corrections to the above list, please let us >> know. >> >> Thanks! >> >> -Doug >> _______________________________________________ >> 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 Thu Jan 8 17:33:50 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 8 Jan 2009 08:33:50 -0800 Subject: [IronPython] platform.system() == "cli" In-Reply-To: <200901081520.15651.oren@held.org.il> References: <200901081520.15651.oren@held.org.il> Message-ID: This is by design. The platform is not the same as the operating system. Jython does something similar. How are you trying to use this? On Thu, Jan 8, 2009 at 5:20 AM, Oren Held wrote: > Hi Guys, > > The following calls return "cli" instead of, what I would expect, "win32" > or > something simliar: > platform.system() > sys.platform > > I'm aware that it's not a new issue (it was mentioned here and there), but > I > still couldn't figure out why this behaviour is preserved.. Shouldn't it be > changed? > > 10x > > - Oren > > > _______________________________________________ > 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 dblank at brynmawr.edu Thu Jan 8 17:36:37 2009 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Thu, 08 Jan 2009 11:36:37 -0500 Subject: [IronPython] DLR Languages? In-Reply-To: References: <49661C56.8090502@brynmawr.edu> Message-ID: <49662B95.9020104@brynmawr.edu> Curt Hagenlocher wrote: > Here's what I know: > > 1. I've heard that Don Syme has been thinking about DLR integration for > F#, but nothing has been announced. > 2. According to http://msdn.microsoft.com/en-us/vjsharp/default.aspx, J# > is "retired" so I don't think you can expect any further versions. > 3. There aren't any firm plans yet for the future of Javascript on the DLR. > 4. In Visual Studio 2010, VB.NET will have the same > level of support for the DLR as C#. Curt, Thanks for the feedback... this is very useful. Can you elaborate on what you mean regarding "same level of support for the DLR as C#"? Does that mean that VB won't be a dynamic language, but can use the DLR (eg, to host other languages)? Also, it seems that a language that looked similar to C# or Java (or VB for that matter) could be implemented fairly straightforwardly using the DLR tools. Does anyone know of a project like that (that doesn't need to implement all of Java/C#/VB but just the main syntax/semantics)? Any big hang-ups in implementing such a (made-up) language? -Doug > There were at least two different people working on an "IronLua", but I > think that both projects are stalled. > > On Thu, Jan 8, 2009 at 7:31 AM, Douglas S. Blank > wrote: > > Hello all, > > (This might not be the right place for this question...) What are > the current DLR languages, and their states? I'm wondering about > those early stabs, ones under development, from MS and others. I'm > especially interested in those that can be run cross-platform. I'd > like to see a list of resources, like: > > Project: IronPython > Developer: Microsoft > URL: http://www.codeplex.com/Wiki/View.aspx?ProjectName=IronPython > Version: 2.0 > State: mature > DLR State: current > License: Microsoft Public License > Available as: source, binaries > > Project: IronRuby > Developer: Microsoft > URL: http://www.ironruby.net/ > Version: 1.0 alpha 2, source only > State: active development > DLR State: current > License: Microsoft Public License > Available as: source > > Project: IronScheme > Developer: leppie > URL: http://www.codeplex.com/IronScheme > Version: 1.0 beta 1 (Oct 2008) > DLR state: early adopter; actively removing DLR? > License: Microsoft Public License > Available as: source > > Not sure about: > > Project: Visual Basic 10 > Developer: Microsoft > URL: http://msdn.microsoft.com/en-us/vbasic/default.aspx > Version: 10 > State: under development? > DLR state: planned? > License: ? > Available as: binaries only? > > Project: Managed JScript > Developer: Microsoft > URL: > http://blogs.msdn.com/jscript/archive/2007/05/04/managed-jscript-announced.aspx > Version: 1 > State: mature > DLR state: ? > License: ? > Available as: binaries only? > > Also, what about F# and J#? > > I'm also working with a couple of groups who are actively developing > additional DLR languages, including a graphical data flow language, > and a proper tail-call recursion implementation of Scheme (using > continuation-passing style). More on those here soon, I hope. > > If you have additions or corrections to the above list, please let > us know. > > Thanks! > > -Doug > _______________________________________________ > 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 slide.o.mix at gmail.com Thu Jan 8 18:04:33 2009 From: slide.o.mix at gmail.com (Slide) Date: Thu, 8 Jan 2009 10:04:33 -0700 Subject: [IronPython] DLR Languages? In-Reply-To: <49662B95.9020104@brynmawr.edu> References: <49661C56.8090502@brynmawr.edu> <49662B95.9020104@brynmawr.edu> Message-ID: >> I'm also working with a couple of groups who are actively developing >> additional DLR languages, including a graphical data flow language, >> and a proper tail-call recursion implementation of Scheme (using >> continuation-passing style). More on those here soon, I hope. >> >> If you have additions or corrections to the above list, please let >> us know. >> >> Thanks! >> >> -Doug >> _______________________________________________ I was looking at implementing a scripting language based on the syntax of C#, I was planning on calling it D-flat (music geeks rejoice). I haven't made a ton of progress yet, basically just got a parser setup, now I need to implement the AST generation from the parser. slide From curt at hagenlocher.org Thu Jan 8 18:33:15 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 8 Jan 2009 09:33:15 -0800 Subject: [IronPython] DLR Languages? In-Reply-To: <49662B95.9020104@brynmawr.edu> References: <49661C56.8090502@brynmawr.edu> <49662B95.9020104@brynmawr.edu> Message-ID: On Thu, Jan 8, 2009 at 8:36 AM, Douglas S. Blank wrote: > > Thanks for the feedback... this is very useful. Can you elaborate on what > you mean regarding "same level of support for the DLR as C#"? Does that mean > that VB won't be a dynamic language, but can use the DLR (eg, to host other > languages)? When talking specifics, it's important to identify exactly what's meant by "dynamic language". VB.NET has always been a dynamic language -- at least as a consumer. It uses static resolution when possible and tries to use dynamic resolution if necessary. But the only kinds of dynamic resolution it supported in the past were reflection (against .NET types) and IDispatch (against COM objects). DLR integration means that it will also use the DLR IDynamicObject mechanism for dynamic method resolution. This will allow interoperability with objects created by DLR-based language implementations. I don't think that VB.NET allows you to dynamically modify types by adding or replacing members -- whether they're data or code. But I've hardly ever used the language. > Also, it seems that a language that looked similar to C# or Java (or VB for > that matter) could be implemented fairly straightforwardly using the DLR > tools. Does anyone know of a project like that (that doesn't need to > implement all of Java/C#/VB but just the main syntax/semantics)? Any big > hang-ups in implementing such a (made-up) language? I expect that we'll be seeing more and more examples of DLR-based languages over the next year. -- Curt Hagenlocher curt at hagenlocher.org From dinov at microsoft.com Thu Jan 8 21:12:43 2009 From: dinov at microsoft.com (Dino Viehland) Date: Thu, 8 Jan 2009 12:12:43 -0800 Subject: [IronPython] Weird performance issue In-Reply-To: <350E7D38B6D819428718949920EC23555704BD08E4@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <2679f6510901060607r3ad0bc1am4bb6701905f264df@mail.gmail.com> <350E7D38B6D819428718949920EC23555704BD08E4@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <350E7D38B6D819428718949920EC23555704D087BF@NA-EXMSG-C102.redmond.corp.microsoft.com> Ok, I've looked at this more closely now and I believe I have a fix. I've also discovered that changes in the DLR make this much better as well in the 2.1 branch. But the numbers I get are: 2.0: 59.9065353243 2.1: 4.28863087116 2.1 + dict fixes: 1.22241745833 These numbers are quite dependent upon the number of types that have been seen for hashing and equality. In 2.0 increasing the number of types will cause the long running loop to become progressively worse. In 2.1 we're smart enough to re-organize the L2 cache based upon the most recently used items which makes this much faster. W/ my changes the dictionaries are smarter about managing call sites based upon their type of keys. My guess is we can add my dictionary fix to 2.0 but back porting all of the call site changes might be too much. Here's my repro: import System class x(object): pass data = [1, 1.0, 1L, 1.0, 'abc', 1L, frozenset(), xrange(2), frozenset(), BaseException(), ord, type, True, x(), System.Collections.ArrayList(), System.Collections.Hashtable(), System, KeyError('x'), AttributeError('foo'), Warning(), 1L] d = {} for i in data: d[i] = 0 i in d del d[i] import time start = time.clock() data = data[-5:] x = {} for i in xrange(100000): for val in data: x[val] = 0 val in x del x[val] end = time.clock() print end - start From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Tuesday, January 06, 2009 11:25 AM To: glenn.k.jones+ipy at gmail.com; Discussion of IronPython Subject: Re: [IronPython] Weird performance issue I think we are thrashing the hash code call site in CommonDictionaryStorage.HashSite._HashSite. Alternately it could be the equals call site in PythonContext._equalRetBoolSite. Similar to the property issue you can look at the call site object and see if it's going to the fixed read-only EmptyRuleSet. We can probably add 2 sites which are per-dictionary but we might need to do something more clever as that could regress general dictionary perf. The DLR team is going to be looking into general issues with understanding what's going on with call sites. Yesterday I pointed out performance investigations as being something important for them to look at. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Glenn Jones Sent: Tuesday, January 06, 2009 6:07 AM To: Discussion of IronPython Subject: [IronPython] Weird performance issue Hi all, More from the Resolver One upgrade: We are seeing several performance failures in our tests, which we expect because the performance profile of IPy2 is different to IPy1. There is one that is perplexing and we hope that someone can give us some insight into possible causes for us to investigate. One of our performance tests only fails when it is preceded by other tests. There is (as far as we can tell) no shared state between the tests. After much poking around, we discovered that replacing a set with a list caused the performance to improve from ~700ms down to ~100ms. We have been unable get a minimal repro, so far. Here's a little more detail on the how the code works: class Thing(object): def run(arg1, arg2): * do some stuff s = set() * do stuff that populates s return list(s) We create a Thing and call run so that the set contains an entry, if we then create a new Thing and call the run method it takes 10 times longer than expected. If we change s = set to s = [] (and convert s.add to s.append, where appropriate), and do the same as above, the second call to run behaves as we expect. There is (at least in our code) nothing shared between the first call to run and the second call. Does anyone have any ideas about where we can look to work out what's happening? Any suggestions for ways to diagnose this? Thanks Glenn & Kamil -------------- next part -------------- An HTML attachment was scrubbed... URL: From oren at held.org.il Thu Jan 8 23:01:29 2009 From: oren at held.org.il (Oren Held) Date: Fri, 09 Jan 2009 00:01:29 +0200 Subject: [IronPython] platform.system() == "cli" In-Reply-To: References: <200901081520.15651.oren@held.org.il> Message-ID: <200901090001.30094.oren@held.org.il> Hi, In my code, I have a section which is not cross platform, thus I'm checking the OS name to call the matching OS-specific calls. In all Unices, using platform.system() returned the OS name just fine. Is there a better way for getting the OS name on both CPython & IronPython? 10x! - Oren On Thursday 08 January 2009 18:33:50 Curt Hagenlocher wrote: > This is by design. The platform is not the same as the operating system. > Jython does something similar. > How are you trying to use this? > > On Thu, Jan 8, 2009 at 5:20 AM, Oren Held wrote: > > Hi Guys, > > > > The following calls return "cli" instead of, what I would expect, "win32" > > or > > something simliar: > > platform.system() > > sys.platform > > > > I'm aware that it's not a new issue (it was mentioned here and there), > > but I > > still couldn't figure out why this behaviour is preserved.. Shouldn't it > > be changed? > > > > 10x > > > > - Oren > > > > > > _______________________________________________ > > Users mailing list > > Users at lists.ironpython.com > > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From curt at hagenlocher.org Thu Jan 8 23:28:49 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 8 Jan 2009 14:28:49 -0800 Subject: [IronPython] platform.system() == "cli" In-Reply-To: <200901090001.30094.oren@held.org.il> References: <200901081520.15651.oren@held.org.il> <200901090001.30094.oren@held.org.il> Message-ID: On Thu, Jan 8, 2009 at 2:01 PM, Oren Held wrote: > > In my code, I have a section which is not cross platform, thus I'm checking > the OS name to call the matching OS-specific calls. > > In all Unices, using platform.system() returned the OS name just fine. Is there > a better way for getting the OS name on both CPython & IronPython? IronPython is different enough from CPython on Win32 that it seems odd to me for something to work under both, but to fail on IronPython under Mono. If you don't care about supporting Mono, you could say sys.platform in ('win32', 'cli'). If Mono support matters, then I don't know any straightforward way to do this. I think you could check for a platform of 'cli' and then look at System.Environment.OSVersion. -- Curt Hagenlocher curt at hagenlocher.org From oren at held.org.il Fri Jan 9 00:02:15 2009 From: oren at held.org.il (Oren Held) Date: Fri, 09 Jan 2009 01:02:15 +0200 Subject: [IronPython] platform.system() == "cli" In-Reply-To: References: <200901081520.15651.oren@held.org.il> <200901090001.30094.oren@held.org.il> Message-ID: <200901090102.15668.oren@held.org.il> On Friday 09 January 2009 00:28:49 Curt Hagenlocher wrote: > On Thu, Jan 8, 2009 at 2:01 PM, Oren Held wrote: > > In my code, I have a section which is not cross platform, thus I'm > > checking the OS name to call the matching OS-specific calls. > > > > In all Unices, using platform.system() returned the OS name just fine. Is > > there a better way for getting the OS name on both CPython & IronPython? > > IronPython is different enough from CPython on Win32 that it seems odd > to me for something to work under both, but to fail on IronPython > under Mono. > > If you don't care about supporting Mono, you could say > sys.platform in ('win32', 'cli'). > If Mono support matters, then I don't know any straightforward way to > do this. I think you could check for a platform of 'cli' and then > look at System.Environment.OSVersion. Thanks for your reply. Just to clarify: my script messes with system configurations. For example, if it's Solaris, I read the /etc/mnttab file, if it's Linux, I read the /etc/mtab file. On windows, I might ask the registry or read some other file. This is a the case in which the OS name DOES matter, while the Python implementation doesn't. - Oren From fuzzyman at voidspace.org.uk Fri Jan 9 00:38:14 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 08 Jan 2009 23:38:14 +0000 Subject: [IronPython] Weird performance issue In-Reply-To: <350E7D38B6D819428718949920EC23555704D087BF@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <2679f6510901060607r3ad0bc1am4bb6701905f264df@mail.gmail.com> <350E7D38B6D819428718949920EC23555704BD08E4@NA-EXMSG-C102.redmond.corp.microsoft.com> <350E7D38B6D819428718949920EC23555704D087BF@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <49668E66.6000200@voidspace.org.uk> Hi Dino, This could be at the root of *several* of the really odd performance issues we've been having with our IronPython 2 port. That is quite an improvement and mirrors the kind of behaviour we see. Can we get a patch against the 2.0 source code for your dictionary fix? On the other hand, what do we lose by moving to the 2.1 branch? Obviously this is less tested (in the wild) code, but we have pretty comprehensive tests. 2.1 is also a bit of a Python 2.5 / 2.6 hybrid at the moment I guess - are there any potential gotchas? Michael Dino Viehland wrote: > > Ok, I?ve looked at this more closely now and I believe I have a fix. > I?ve also discovered that changes in the DLR make this much better as > well in the 2.1 branch. But the numbers I get are: > > 2.0: 59.9065353243 > > 2.1: 4.28863087116 > > 2.1 + dict fixes: 1.22241745833 > > These numbers are quite dependent upon the number of types that have > been seen for hashing and equality. In 2.0 increasing the number of > types will cause the long running loop to become progressively worse. > In 2.1 we?re smart enough to re-organize the L2 cache based upon the > most recently used items which makes this much faster. W/ my changes > the dictionaries are smarter about managing call sites based upon > their type of keys. > > My guess is we can add my dictionary fix to 2.0 but back porting all > of the call site changes might be too much. > > Here?s my repro: > > import System > > class x(object): > > pass > > data = [1, 1.0, 1L, 1.0, 'abc', 1L, frozenset(), xrange(2), > frozenset(), BaseException(), ord, type, True, x(), > System.Collections.ArrayList(), System.Collections.Hashtable(), > System, KeyError('x'), AttributeError('foo'), Warning(), 1L] > > d = {} > > for i in data: > > d[i] = 0 > > i in d > > del d[i] > > import time > > start = time.clock() > > data = data[-5:] > > x = {} > > for i in xrange(100000): > > for val in data: > > x[val] = 0 > > val in x > > del x[val] > > end = time.clock() > > print end - start > > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Dino Viehland > *Sent:* Tuesday, January 06, 2009 11:25 AM > *To:* glenn.k.jones+ipy at gmail.com; Discussion of IronPython > *Subject:* Re: [IronPython] Weird performance issue > > I think we are thrashing the hash code call site in > CommonDictionaryStorage.HashSite._HashSite. Alternately it could be > the equals call site in PythonContext._equalRetBoolSite. Similar to > the property issue you can look at the call site object and see if > it?s going to the fixed read-only EmptyRuleSet. > > We can probably add 2 sites which are per-dictionary but we might need > to do something more clever as that could regress general dictionary perf. > > The DLR team is going to be looking into general issues with > understanding what?s going on with call sites. Yesterday I pointed out > performance investigations as being something important for them to > look at. > > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Glenn Jones > *Sent:* Tuesday, January 06, 2009 6:07 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] Weird performance issue > > Hi all, > > More from the Resolver One upgrade: > We are seeing several performance failures in our tests, which we > expect because the performance profile of IPy2 is different to IPy1. > There is one that is perplexing and we hope that someone can give us > some insight into possible causes for us to investigate. > > One of our performance tests only fails when it is preceded by other > tests. There is (as far as we can tell) no shared state between the > tests. After much poking around, we discovered that replacing a set > with a list caused the performance to improve from ~700ms down to > ~100ms. We have been unable get a minimal repro, so far. Here's a > little more detail on the how the code works: > > class Thing(object): > def run(arg1, arg2): > * do some stuff > s = set() > * do stuff that populates s > return list(s) > > We create a Thing and call run so that the set contains an entry, if > we then create a new Thing and call the run method it takes 10 times > longer than expected. > If we change s = set to s = [] (and convert s.add to s.append, where > appropriate), and do the same as above, the second call to run behaves > as we expect. There is (at least in our code) nothing shared between > the first call to run and the second call. > > Does anyone have any ideas about where we can look to work out what's > happening? Any suggestions for ways to diagnose this? > > Thanks > Glenn & Kamil > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 dinov at microsoft.com Fri Jan 9 01:03:36 2009 From: dinov at microsoft.com (Dino Viehland) Date: Thu, 8 Jan 2009 16:03:36 -0800 Subject: [IronPython] Weird performance issue In-Reply-To: <49668E66.6000200@voidspace.org.uk> References: <2679f6510901060607r3ad0bc1am4bb6701905f264df@mail.gmail.com> <350E7D38B6D819428718949920EC23555704BD08E4@NA-EXMSG-C102.redmond.corp.microsoft.com> <350E7D38B6D819428718949920EC23555704D087BF@NA-EXMSG-C102.redmond.corp.microsoft.com> <49668E66.6000200@voidspace.org.uk> Message-ID: <350E7D38B6D819428718949920EC23555704D08980@NA-EXMSG-C102.redmond.corp.microsoft.com> I'm going to back port this perf fixes + the property perf fixes to 2.0.1. I was planning on doing this tomorrow. Moving to 2.1 shouldn't be painful. The biggest gotcha is a large number of renames that have happened in the DLR inner layer (Microsoft.Scripting.Core). The good news is those shouldn't effect Python code - only other DLR languages which are interoperating w/ IronPython. The outer layer, with the hosting APIs, should all still be the same. It is a 2.5/2.6 hybrid but the potentially breaking changes (for example the parser changes) have remained under the -X:Python26 option. The bad news is that option will eventually go away. Right now we're working towards getting 2.1 to run against the 2.6 standard library while at the same time keeping it running against 2.5. There are some breaking changes in 2.6 - for example slicing has been "fixed" in some subtle places and so at some point those will get put in and it'll be hard to make them dependent upon a switch. So once we get switched over and running all the 2.6 tests then that option will go away forcing the 2.6 behavior upon you. Where we believe the features are non-disruptive (say the new string formatting APIs) the feature isn't controlled by the -X:Python26 option. Other than that I'd just say the biggest factor is churn and release dates. 2.1 is undergoing active development but we also continue to gate our check-ins on passing our test suite. Our tentative planning is that we won't finish 2.1 until the 2nd half of this year. So ultimately you lose some degree of stability for a reasonable chunk of time. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Thursday, January 08, 2009 3:38 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Weird performance issue > > Hi Dino, > > This could be at the root of *several* of the really odd performance > issues we've been having with our IronPython 2 port. That is quite an > improvement and mirrors the kind of behaviour we see. > > Can we get a patch against the 2.0 source code for your dictionary fix? > > On the other hand, what do we lose by moving to the 2.1 branch? > Obviously this is less tested (in the wild) code, but we have pretty > comprehensive tests. 2.1 is also a bit of a Python 2.5 / 2.6 hybrid at > the moment I guess - are there any potential gotchas? > > Michael > > Dino Viehland wrote: > > > > Ok, I've looked at this more closely now and I believe I have a fix. > > I've also discovered that changes in the DLR make this much better as > > well in the 2.1 branch. But the numbers I get are: > > > > 2.0: 59.9065353243 > > > > 2.1: 4.28863087116 > > > > 2.1 + dict fixes: 1.22241745833 > > > > These numbers are quite dependent upon the number of types that have > > been seen for hashing and equality. In 2.0 increasing the number of > > types will cause the long running loop to become progressively worse. > > In 2.1 we're smart enough to re-organize the L2 cache based upon the > > most recently used items which makes this much faster. W/ my changes > > the dictionaries are smarter about managing call sites based upon > > their type of keys. > > > > My guess is we can add my dictionary fix to 2.0 but back porting all > > of the call site changes might be too much. > > > > Here's my repro: > > > > import System > > > > class x(object): > > > > pass > > > > data = [1, 1.0, 1L, 1.0, 'abc', 1L, frozenset(), xrange(2), > > frozenset(), BaseException(), ord, type, True, x(), > > System.Collections.ArrayList(), System.Collections.Hashtable(), > > System, KeyError('x'), AttributeError('foo'), Warning(), 1L] > > > > d = {} > > > > for i in data: > > > > d[i] = 0 > > > > i in d > > > > del d[i] > > > > import time > > > > start = time.clock() > > > > data = data[-5:] > > > > x = {} > > > > for i in xrange(100000): > > > > for val in data: > > > > x[val] = 0 > > > > val in x > > > > del x[val] > > > > end = time.clock() > > > > print end - start > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Dino > Viehland > > *Sent:* Tuesday, January 06, 2009 11:25 AM > > *To:* glenn.k.jones+ipy at gmail.com; Discussion of IronPython > > *Subject:* Re: [IronPython] Weird performance issue > > > > I think we are thrashing the hash code call site in > > CommonDictionaryStorage.HashSite._HashSite. Alternately it could be > > the equals call site in PythonContext._equalRetBoolSite. Similar to > > the property issue you can look at the call site object and see if > > it's going to the fixed read-only EmptyRuleSet. > > > > We can probably add 2 sites which are per-dictionary but we might > need > > to do something more clever as that could regress general dictionary > perf. > > > > The DLR team is going to be looking into general issues with > > understanding what's going on with call sites. Yesterday I pointed > out > > performance investigations as being something important for them to > > look at. > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Glenn > Jones > > *Sent:* Tuesday, January 06, 2009 6:07 AM > > *To:* Discussion of IronPython > > *Subject:* [IronPython] Weird performance issue > > > > Hi all, > > > > More from the Resolver One upgrade: > > We are seeing several performance failures in our tests, which we > > expect because the performance profile of IPy2 is different to IPy1. > > There is one that is perplexing and we hope that someone can give us > > some insight into possible causes for us to investigate. > > > > One of our performance tests only fails when it is preceded by other > > tests. There is (as far as we can tell) no shared state between the > > tests. After much poking around, we discovered that replacing a set > > with a list caused the performance to improve from ~700ms down to > > ~100ms. We have been unable get a minimal repro, so far. Here's a > > little more detail on the how the code works: > > > > class Thing(object): > > def run(arg1, arg2): > > * do some stuff > > s = set() > > * do stuff that populates s > > return list(s) > > > > We create a Thing and call run so that the set contains an entry, if > > we then create a new Thing and call the run method it takes 10 times > > longer than expected. > > If we change s = set to s = [] (and convert s.add to s.append, where > > appropriate), and do the same as above, the second call to run > behaves > > as we expect. There is (at least in our code) nothing shared between > > the first call to run and the second call. > > > > Does anyone have any ideas about where we can look to work out what's > > happening? Any suggestions for ways to diagnose this? > > > > Thanks > > Glenn & Kamil > > > > --------------------------------------------------------------------- > --- > > > > _______________________________________________ > > 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 jdhardy at gmail.com Fri Jan 9 01:12:41 2009 From: jdhardy at gmail.com (Jeff Hardy) Date: Thu, 8 Jan 2009 17:12:41 -0700 Subject: [IronPython] platform.system() == "cli" In-Reply-To: <200901090001.30094.oren@held.org.il> References: <200901081520.15651.oren@held.org.il> <200901090001.30094.oren@held.org.il> Message-ID: On Thu, Jan 8, 2009 at 3:01 PM, Oren Held wrote: > In all Unices, using platform.system() returned the OS name just fine. Is there > a better way for getting the OS name on both CPython & IronPython? os.name is probably what you're looking for, although I don't know how it behaves on *nix (it return 'nt' on Windows). - Jeff From dinov at microsoft.com Fri Jan 9 01:15:59 2009 From: dinov at microsoft.com (Dino Viehland) Date: Thu, 8 Jan 2009 16:15:59 -0800 Subject: [IronPython] platform.system() == "cli" In-Reply-To: References: <200901081520.15651.oren@held.org.il> <200901090001.30094.oren@held.org.il> Message-ID: <350E7D38B6D819428718949920EC23555704D08991@NA-EXMSG-C102.redmond.corp.microsoft.com> It'll return "posix" if the .NET implementation reports System.Environment.OSVersion.Platform as Unix. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > Sent: Thursday, January 08, 2009 4:13 PM > To: Discussion of IronPython > Subject: Re: [IronPython] platform.system() == "cli" > > On Thu, Jan 8, 2009 at 3:01 PM, Oren Held wrote: > > In all Unices, using platform.system() returned the OS name just > fine. Is there > > a better way for getting the OS name on both CPython & IronPython? > > os.name is probably what you're looking for, although I don't know how > it behaves on *nix (it return 'nt' on Windows). > > - Jeff > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kristian.jaksch at gmail.com Sun Jan 11 18:32:50 2009 From: kristian.jaksch at gmail.com (xkrja) Date: Sun, 11 Jan 2009 09:32:50 -0800 (PST) Subject: [IronPython] Problem loading IronPython Silverlight app Message-ID: <21401718.post@talk.nabble.com> I don't know if this is the right place for this question but I give it a try: I have an IronPython app made for Silverlight 2 and I have problems to get it to load properly on the web page. There are several JavaScripts in the HTML-page together with the SL2 and that seems to cause problems. In 30% or so of the times I start up the application (from VS Web Dev express and Chiron) the SL2 will not load. The error says: InitializeError- Invalid or malformed application: Check manifest As I said, this happens approx 30% of the times I run the web page. I assume it is because of the Javascript on the page and since it is executed asynchronously I think it might interfere with the loading of the SL2 object. So now I want to load the SL2 app using JavaScript instead of the but I can't get it to work. My idea is that if I use Javascript to load the SL2 app, then I can configure it to be loaded last and hopefully it won't interfere with any of the other scripts on the page. Maybe this idea is completely wrong so please correct me if you think so! Anyway, my questions: 1) Do I need to pre-build the application's app.xap file in order to load it with JavaScript? I can't get it to load the app using Javascript if I just use the "/b" extension in the "start options" of Chiron (in VS Web dev express). BUT if I use a pre-built .xap file (from another application) it works. 2) If I need a pre-built .xap-file, how do I do that properly? I tried using chiron.exe /x:app/app.xap and it gives me a .xap-file but it doesn't work. All files seems to be in it but strangely it doesn't work. Thanks for any help that can get me on the right track! -- View this message in context: http://www.nabble.com/Problem-loading-IronPython-Silverlight-app-tp21401718p21401718.html Sent from the IronPython mailing list archive at Nabble.com. From vkhaskel at hotmail.com Sun Jan 11 23:02:55 2009 From: vkhaskel at hotmail.com (Vadim Khaskel) Date: Sun, 11 Jan 2009 22:02:55 +0000 Subject: [IronPython] IronPython in Visual Studio 2008 Pro Message-ID: Hello, I have Visual Studio 2008 Pro, how to integrate IronPython with the studio? Thanks for help, Vadim _________________________________________________________________ Windows Live?: Keep your life in sync. http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t1_allup_howitworks_012009 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kristian.jaksch at gmail.com Mon Jan 12 13:43:10 2009 From: kristian.jaksch at gmail.com (xkrja) Date: Mon, 12 Jan 2009 04:43:10 -0800 (PST) Subject: [IronPython] IronPython to JavaScript Message-ID: <21413681.post@talk.nabble.com> I'm trying to call javascript from IronPython (via Silverlight 2) but I can' get it to work properly. I looked at this example: http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 It's explained very clearly but when I try to run my code I get a System Error: SystemError: Object reference not set to an instance of an object. I just inserted the lines of code found on the example page in my IronPyton code: event = ScriptableEvent() # This must also be registered HtmlPage.RegisterScriptableObject("event", event) args = ScriptableEventArgs() args.val = 'some string' event.OnEvent(args) #This gives me a System Error I create a C# .dll as explained in the example and add a reference to it. The source is below: using System; using System.Windows.Browser; namespace Scriptable { [ScriptableTypeAttribute] public class ScriptableForString { [ScriptableMemberAttribute] public string method(string value) { return this._method(value); } public virtual string _method(string value) { return "override me"; } } [ScriptableType] public class ScriptableEvent { [ScriptableMember] public event EventHandler Event; public virtual void OnEvent(ScriptableEventArgs e) { Event(this, e); } } [ScriptableTypeAttribute] public class ScriptableEventArgs : EventArgs { private string _val; [ScriptableMemberAttribute] public string val { get { return _val; } set { _val = value; } } } } Can anyone explain what I'm doing wrong? Thanks for any help! -- View this message in context: http://www.nabble.com/IronPython-to-JavaScript-tp21413681p21413681.html Sent from the IronPython mailing list archive at Nabble.com. From dinov at microsoft.com Mon Jan 12 18:42:44 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 12 Jan 2009 09:42:44 -0800 Subject: [IronPython] IronPython in Visual Studio 2008 Pro In-Reply-To: References: Message-ID: <350E7D38B6D819428718949920EC23555704D09076@NA-EXMSG-C102.redmond.corp.microsoft.com> You want to look at IronPython Studio: http://www.codeplex.com/IronPythonStudio Note it's really pre-beta quality so you may or may not find the experience acceptable. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Vadim Khaskel Sent: Sunday, January 11, 2009 2:03 PM To: users at lists.ironpython.com Subject: [IronPython] IronPython in Visual Studio 2008 Pro Hello, I have Visual Studio 2008 Pro, how to integrate IronPython with the studio? Thanks for help, Vadim ________________________________ Windows Live(tm): Keep your life in sync. See how it works. -------------- next part -------------- An HTML attachment was scrubbed... URL: From laurionb at service.exchange.microsoft.com Mon Jan 12 19:13:11 2009 From: laurionb at service.exchange.microsoft.com (Laurion Burchall) Date: Mon, 12 Jan 2009 18:13:11 +0000 Subject: [IronPython] Announcing esedb, a dbm interface to the Esent database engine Message-ID: <98511B3BD104B14BB532FD95828D69B50DF4D8CD@BL2SDF0102MB001.namsdf01.sdf.exchangelabs.com> I've added the esedb module (esedb.zip) to the release page of the ManagedEsent CodePlex project (http://www.codeplex.com/ManagedEsent/Release/ProjectReleases.aspx). This is still under development and I'm interested in comments, feedback and suggestions on how to do things better in Python. What is Esent? Esent is the Windows database engine. It is used by the Active Directory and several smaller applications on Windows clients (e.g. Windows Update). The same code is also used by Microsoft Exchange as their database engine. The unmanaged API is documented on MSDN and there is a managed interop layer on code plex. What is esedb? The esedb module uses the Esent interop layer to provide a persisted key/data store in a dbm-like way. The zip file contains the managed interop DLL and the Python module. The code uses the esent DLL which is part of Windows. This code will work on Windows XP on up (it won't work on Windows 2000). That does mean that this module will only work on Windows. >>> x = esedb.open('test.db', mode='n') >>> x['a'] = 'somedata' >>> x['a'] 'somedata' >>> x.has_key('b') False >>> x['b'] = 'somemoredata' >>> x['c'] = 'deleteme' >>> del x['c'] >>> x.keys() ['a', 'b'] >>> x.values() ['somedata', 'somemoredata'] >>> x.close() thanks, --Laurion -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Mon Jan 12 22:24:09 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Mon, 12 Jan 2009 13:24:09 -0800 Subject: [IronPython] Problem loading IronPython Silverlight app In-Reply-To: <21401718.post@talk.nabble.com> References: <21401718.post@talk.nabble.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B469C@NA-EXMSG-C116.redmond.corp.microsoft.com> > xkrja wrote: > I have an IronPython app made for Silverlight 2 and I have problems to > get it to load properly on the web page. There are several JavaScripts > in the HTML-page together with the SL2 and that seems to cause > problems. In 30% or so of the times I start up the application (from > VS Web Dev express and Chiron) the SL2 will not load. The error says: > > InitializeError- Invalid or malformed application: Check manifest > > As I said, this happens approx 30% of the times I run the web page. I > assume it is because of the Javascript on the page and since it is > executed asynchronously I think it might interfere with the loading > of the SL2 object. There shouldn't be an issue loading a Silverlight application with other Javascript that does things on document.ready. This error seems like something to do with the browser trying to load the XAP file before Chiron has a chance to create it. That error message only happens if the there is something wrong with the loaded manifest file. > So now I want to load the SL2 app using JavaScript instead of the but > I > can't get it to work. My idea is that if I use Javascript to load the > SL2 > app, then I can configure it to be loaded last and hopefully it won't > interfere with any of the other scripts on the page. Maybe this idea is > completely wrong so please correct me if you think so! I still don't see how it could be interfering with other scripts on the page; it's just a tag, and if has its own
then it won't touch the rest of the page. Unless your Silverlight app looks at the DOM as well. In that case, you need to be checking for HtmlPage.DocumentReady (or something like that). Loading it with javascript will work as well, but how are you going about doing that? I personally would use the Silverlight.js file in the Silverlight SDK (c:\program files\microsoft sdks\silverlight), but you could just do it by hand too. > Anyway, my questions: > > 1) Do I need to pre-build the application's app.xap file in order to > load it with JavaScript? I can't get it to load the app using > Javascript if I just use the "/b" extension in the "start options" > of Chiron (in VS Web dev express). BUT if I use a pre-built .xap file > (from another application) it works. No need for a pre-build XAP, if Chiron is the web server. When Chiron gets a request for http://localhost:2060/myapp/app.xap, it looks for a directory "\myapp\app", and if it exists Chiron does the equivalent of /zipdlr in memory, and returns the data as the response. When running Chiron /b, does Chiron log a request of the xap? > 2) If I need a pre-built .xap-file, how do I do that properly? I tried > using > > chiron.exe /x:app/app.xap > > and it gives me a .xap-file but it doesn't work. All files seems to be > in it but strangely it doesn't work. When you run "Chiron.exe /?" it will tell you that /xap just XAPs the contents of a folder, while /zipdlr will generate the AppManifest.xaml if needed, and stick the DLR/Language assemblies in the XAP, if needed, on top of xaping the directory as well. So, you need Chiron.exe /z:path\to\app.xap. > Thanks for any help that can get me on the right track! Let me know if you have any other questions. For more Silverlight+DLR specific issues, you can as on this discussion list: http://www.codeplex.com/sdlsdk/Thread/List.aspx. If you still can't get it to work, please try to create a small reproduction of the issue and open a bug here: http://www.codeplex.com/sdlsdk/WorkItem/List.aspx, and I'll investigate. ~Jimmy From fuzzyman at voidspace.org.uk Mon Jan 12 22:27:49 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 12 Jan 2009 21:27:49 +0000 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <21413681.post@talk.nabble.com> References: <21413681.post@talk.nabble.com> Message-ID: <496BB5D5.30800@voidspace.org.uk> xkrja wrote: > I'm trying to call javascript from IronPython (via Silverlight 2) but I can' > get it to work properly. I looked at this example: > > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 > > It's explained very clearly but when I try to run my code I get a System > Error: > > SystemError: Object reference not set to an instance of an object. > > I just inserted the lines of code found on the example page in my IronPyton > code: > > event = ScriptableEvent() > > # This must also be registered > HtmlPage.RegisterScriptableObject("event", event) > > args = ScriptableEventArgs() > args.val = 'some string' > event.OnEvent(args) #This gives me a System Error > > I create a C# .dll as explained in the example and add a reference to it. > The source is below: > > using System; > using System.Windows.Browser; > > namespace Scriptable > { > > [ScriptableTypeAttribute] > public class ScriptableForString > { > [ScriptableMemberAttribute] > public string method(string value) > { return this._method(value); } > > public virtual string _method(string value) > { return "override me"; } > } > > [ScriptableType] > public class ScriptableEvent > { > [ScriptableMember] > public event EventHandler Event; > > public virtual void OnEvent(ScriptableEventArgs e) > { > Event(this, e); > } > } > > [ScriptableTypeAttribute] > public class ScriptableEventArgs : EventArgs > { > private string _val; > > [ScriptableMemberAttribute] > public string val > { > get { return _val; } > set { _val = value; } > } > } > } > > Can anyone explain what I'm doing wrong? > > Thanks for any help! > > Hmmm... do you have any Javascript hooking up to the event? If you don't, try hooking up to it and see if it makes any difference. The same code works for me. :-) Michael -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From kristian.jaksch at gmail.com Tue Jan 13 08:19:23 2009 From: kristian.jaksch at gmail.com (Kristian Jaksch) Date: Tue, 13 Jan 2009 08:19:23 +0100 Subject: [IronPython] Problem loading IronPython Silverlight app In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B469C@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <21401718.post@talk.nabble.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B469C@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <1dab55500901122319o61fafafaq2b62fde910cfa222@mail.gmail.com> Thanks for the reply! It seems like the problem was that the SL2 application tried to connect to the DOM during startup. I can find an alternative solution to that so it won't be a problem. I haven't been able to reproduce the problem so I think it's fixed. Thanks very much! 2009/1/12 Jimmy Schementi : >> xkrja wrote: >> I have an IronPython app made for Silverlight 2 and I have problems to >> get it to load properly on the web page. There are several JavaScripts >> in the HTML-page together with the SL2 and that seems to cause >> problems. In 30% or so of the times I start up the application (from >> VS Web Dev express and Chiron) the SL2 will not load. The error says: >> >> InitializeError- Invalid or malformed application: Check manifest >> >> As I said, this happens approx 30% of the times I run the web page. I >> assume it is because of the Javascript on the page and since it is >> executed asynchronously I think it might interfere with the loading >> of the SL2 object. > > There shouldn't be an issue loading a Silverlight application with other Javascript that does things on document.ready. This error seems like something to do with the browser trying to load the XAP file before Chiron has a chance to create it. That error message only happens if the there is something wrong with the loaded manifest file. > >> So now I want to load the SL2 app using JavaScript instead of the but >> I >> can't get it to work. My idea is that if I use Javascript to load the >> SL2 >> app, then I can configure it to be loaded last and hopefully it won't >> interfere with any of the other scripts on the page. Maybe this idea is >> completely wrong so please correct me if you think so! > > I still don't see how it could be interfering with other scripts on the page; it's just a tag, and if has its own
then it won't touch the rest of the page. Unless your Silverlight app looks at the DOM as well. In that case, you need to be checking for HtmlPage.DocumentReady (or something like that). Loading it with javascript will work as well, but how are you going about doing that? I personally would use the Silverlight.js file in the Silverlight SDK (c:\program files\microsoft sdks\silverlight), but you could just do it by hand too. > >> Anyway, my questions: >> >> 1) Do I need to pre-build the application's app.xap file in order to >> load it with JavaScript? I can't get it to load the app using >> Javascript if I just use the "/b" extension in the "start options" >> of Chiron (in VS Web dev express). BUT if I use a pre-built .xap file >> (from another application) it works. > > No need for a pre-build XAP, if Chiron is the web server. When Chiron gets a request for http://localhost:2060/myapp/app.xap, it looks for a directory "\myapp\app", and if it exists Chiron does the equivalent of /zipdlr in memory, and returns the data as the response. When running Chiron /b, does Chiron log a request of the xap? > >> 2) If I need a pre-built .xap-file, how do I do that properly? I tried >> using >> >> chiron.exe /x:app/app.xap >> >> and it gives me a .xap-file but it doesn't work. All files seems to be >> in it but strangely it doesn't work. > > When you run "Chiron.exe /?" it will tell you that /xap just XAPs the contents of a folder, while /zipdlr will generate the AppManifest.xaml if needed, and stick the DLR/Language assemblies in the XAP, if needed, on top of xaping the directory as well. So, you need Chiron.exe /z:path\to\app.xap. > >> Thanks for any help that can get me on the right track! > > Let me know if you have any other questions. For more Silverlight+DLR specific issues, you can as on this discussion list: http://www.codeplex.com/sdlsdk/Thread/List.aspx. > > If you still can't get it to work, please try to create a small reproduction of the issue and open a bug here: http://www.codeplex.com/sdlsdk/WorkItem/List.aspx, and I'll investigate. > > ~Jimmy > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From kristian.jaksch at gmail.com Tue Jan 13 09:59:48 2009 From: kristian.jaksch at gmail.com (Kristian Jaksch) Date: Tue, 13 Jan 2009 09:59:48 +0100 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <496BB5D5.30800@voidspace.org.uk> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> Message-ID: <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> Thanks for the reply! No, I can't get it to work with Javascript either. I added the script below to my page: I'm not sure about the exact translation of the error message (It's in swedish) but it's something like: "Error: Invalid pointer" I guess it has something to do with the error I receive in my "app.py" file as I described previously. I made a minimal app.py file to test it again but I still receive the same error. This file also test to get a string from Javascript to Ironpython and that works just fine. Below is my complete file: import clr, sys clr.AddReferenceToFile("Scriptable.dll") from System.Windows import Application from System.Windows.Browser import * from System.Windows.Controls import * from System.Windows import Input from Scriptable import * class GetFromEditor(ScriptableForString): def _method(self, string): root.message.Text = string #return new_string GetFromEditor = GetFromEditor() root = Application.Current.LoadRootVisual(UserControl(), "app.xaml") HtmlPage.RegisterScriptableObject("GetFromEditor", GetFromEditor) event = ScriptableEvent() # This must also be registered HtmlPage.RegisterScriptableObject("event", event) args = ScriptableEventArgs() args.val = 'some string' event.OnEvent(args) It must be something I'm missing but I just can't see what it could be. Do you know of any good example were this approach is used? Thanks again! 2009/1/12 Michael Foord : > xkrja wrote: >> >> I'm trying to call javascript from IronPython (via Silverlight 2) but I >> can' >> get it to work properly. I looked at this example: >> >> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 >> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 >> It's explained very clearly but when I try to run my code I get a System >> Error: >> >> SystemError: Object reference not set to an instance of an object. >> >> I just inserted the lines of code found on the example page in my >> IronPyton >> code: >> >> event = ScriptableEvent() >> >> # This must also be registered >> HtmlPage.RegisterScriptableObject("event", event) >> >> args = ScriptableEventArgs() >> args.val = 'some string' >> event.OnEvent(args) #This gives me a System Error >> >> I create a C# .dll as explained in the example and add a reference to it. >> The source is below: >> >> using System; >> using System.Windows.Browser; >> >> namespace Scriptable >> { >> >> [ScriptableTypeAttribute] >> public class ScriptableForString >> { >> [ScriptableMemberAttribute] >> public string method(string value) >> { return this._method(value); } >> >> public virtual string _method(string value) >> { return "override me"; } >> } >> >> [ScriptableType] >> public class ScriptableEvent >> { >> [ScriptableMember] >> public event EventHandler Event; >> >> public virtual void OnEvent(ScriptableEventArgs e) >> { >> Event(this, e); >> } >> } >> >> [ScriptableTypeAttribute] >> public class ScriptableEventArgs : EventArgs >> { >> private string _val; >> >> [ScriptableMemberAttribute] >> public string val >> { >> get { return _val; } >> set { _val = value; } >> } >> } >> } >> >> Can anyone explain what I'm doing wrong? >> Thanks for any help! >> >> > > Hmmm... do you have any Javascript hooking up to the event? If you don't, > try hooking up to it and see if it makes any difference. > > The same code works for me. :-) > > Michael > > -- > 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 Marty.Nelson at symyx.com Tue Jan 13 18:05:19 2009 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Tue, 13 Jan 2009 09:05:19 -0800 Subject: [IronPython] Problems moving to IP 2.0 Release Message-ID: <515335F32AA04440B3DE6FEA1993E9AD03DB4B89@srv-be-101.Symyx-IC.symyx.com> I've got file version 2.0.11020.0 of IronPython and IronPython.Modules in my GAC and can't get them out. :-( (Looks like release version is 2.0.11121.0). I've tried gacutil /uf, but it claims it is need by a Windows Installer. Any suggestions? (Oh, and BTW - what was up with the Microsoft.Scripting moving from 1.0.0.0 in pre-release to 0.9.0.0 in release?) Thanks, - Marty ======= Notice: This e-mail message, together with any attachments, contains information of Symyx Technologies, Inc. or any of its affiliates or subsidiaries that may be confidential, proprietary, copyrighted, privileged and/or protected work product, and is meant solely for the intended recipient. If you are not the intended recipient, and have received this message in error, please contact the sender immediately, permanently delete the original and any copies of this email and any attachments thereto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed Jan 14 00:01:49 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 13 Jan 2009 23:01:49 +0000 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> Message-ID: <496D1D5D.8020602@voidspace.org.uk> Ahhh... there is a detail I missed out in that article. You can only hook up the Javascript function after the Silverlight control has loaded. This is *possibly* the cause of your problems. I do the hooking up in an onload function: function onload() { control = document.getElementById('SilverlightPlugin'); control.Content.setCode.Event = setCode; } You pass this function in the online parameter in the Silverlight object element: Hopefully this sorts out the problem for you. Michael Foord Kristian Jaksch wrote: > Thanks for the reply! > > No, I can't get it to work with Javascript either. I added the script > below to my page: > > > > I'm not sure about the exact translation of the error message (It's in > swedish) but it's something like: > > "Error: Invalid pointer" > > I guess it has something to do with the error I receive in my "app.py" > file as I described previously. > > I made a minimal app.py file to test it again but I still receive the > same error. This file also test to get a string from Javascript to > Ironpython and that works just fine. Below is my complete file: > > > import clr, sys > > clr.AddReferenceToFile("Scriptable.dll") > > from System.Windows import Application > from System.Windows.Browser import * > from System.Windows.Controls import * > from System.Windows import Input > from Scriptable import * > > > class GetFromEditor(ScriptableForString): > def _method(self, string): > root.message.Text = string > #return new_string > > GetFromEditor = GetFromEditor() > > root = Application.Current.LoadRootVisual(UserControl(), "app.xaml") > > HtmlPage.RegisterScriptableObject("GetFromEditor", GetFromEditor) > > > event = ScriptableEvent() > > # This must also be registered > HtmlPage.RegisterScriptableObject("event", event) > > args = ScriptableEventArgs() > args.val = 'some string' > event.OnEvent(args) > > > It must be something I'm missing but I just can't see what it could > be. Do you know of any good example were this approach is used? > > Thanks again! > > > 2009/1/12 Michael Foord : > >> xkrja wrote: >> >>> I'm trying to call javascript from IronPython (via Silverlight 2) but I >>> can' >>> get it to work properly. I looked at this example: >>> >>> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 >>> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 >>> It's explained very clearly but when I try to run my code I get a System >>> Error: >>> >>> SystemError: Object reference not set to an instance of an object. >>> >>> I just inserted the lines of code found on the example page in my >>> IronPyton >>> code: >>> >>> event = ScriptableEvent() >>> >>> # This must also be registered >>> HtmlPage.RegisterScriptableObject("event", event) >>> >>> args = ScriptableEventArgs() >>> args.val = 'some string' >>> event.OnEvent(args) #This gives me a System Error >>> >>> I create a C# .dll as explained in the example and add a reference to it. >>> The source is below: >>> >>> using System; >>> using System.Windows.Browser; >>> >>> namespace Scriptable >>> { >>> >>> [ScriptableTypeAttribute] >>> public class ScriptableForString >>> { >>> [ScriptableMemberAttribute] >>> public string method(string value) >>> { return this._method(value); } >>> >>> public virtual string _method(string value) >>> { return "override me"; } >>> } >>> >>> [ScriptableType] >>> public class ScriptableEvent >>> { >>> [ScriptableMember] >>> public event EventHandler Event; >>> >>> public virtual void OnEvent(ScriptableEventArgs e) >>> { >>> Event(this, e); >>> } >>> } >>> >>> [ScriptableTypeAttribute] >>> public class ScriptableEventArgs : EventArgs >>> { >>> private string _val; >>> >>> [ScriptableMemberAttribute] >>> public string val >>> { >>> get { return _val; } >>> set { _val = value; } >>> } >>> } >>> } >>> >>> Can anyone explain what I'm doing wrong? >>> Thanks for any help! >>> >>> >>> >> Hmmm... do you have any Javascript hooking up to the event? If you don't, >> try hooking up to it and see if it makes any difference. >> >> The same code works for me. :-) >> >> Michael >> >> -- >> 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 >> >> > _______________________________________________ > 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 stephen at theleengs.com Wed Jan 14 00:58:27 2009 From: stephen at theleengs.com (Stephen Ng) Date: Tue, 13 Jan 2009 15:58:27 -0800 Subject: [IronPython] Embedding Powershell and Write-Host Message-ID: <86122ad70901131558m542ed7bct32140c408c970cd8@mail.gmail.com> I'm using the following code to embed Powershell into IronPython. I hope to eventually replace almost all of my (large) Powershell script with IronPython. from System.Management.Automation.Runspaces import RunspaceFactory the_runspace = RunspaceFactory.CreateRunspace() the_runspace.Open() ri = RunspaceInvoke(the_runspace) out = ri.Invoke('. .\myscript.ps1') I'm able to pass variables back and forth using the_runspace.SessionStateProxy.Get/SetVariable, which is really cool. My problem is that any calls to Write-Host fail with "Cannot invoke this function becasue the current host does not implement it." Of course I can remove all the Write-Host's, but I really depend on them for status information about how my script is running, and not having access to console output makes my script much harder to debug. This post: http://decav.co m/blogs/andre/a rchive/2008/05/ 01/invoking-pow ershell-scripts -from-an-applic ation.aspx says "To get around this, you can remove *write-host* from your scripts and just have them write single lines, or you can implement a simple *PSHost* (although this is a bit harder than it sounds)." What does "just have them write single lines mean?" Any pointers on how I can get this working under IronPython? Thanks, Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Wed Jan 14 01:06:19 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 13 Jan 2009 16:06:19 -0800 Subject: [IronPython] Embedding Powershell and Write-Host In-Reply-To: <86122ad70901131558m542ed7bct32140c408c970cd8@mail.gmail.com> References: <86122ad70901131558m542ed7bct32140c408c970cd8@mail.gmail.com> Message-ID: You might find this link helpful. It was the second hit when googling "implement pshost", and the author talks about integration between IronRuby and PowerShell. http://bartdesmet.net/blogs/bart/archive/2008/07/06/windows-powershell-through-ironruby-writing-a-custom-pshost.aspx On Tue, Jan 13, 2009 at 3:58 PM, Stephen Ng wrote: > I'm using the following code to embed Powershell into IronPython. I hope > to eventually replace almost all of my (large) Powershell script with > IronPython. > > from System.Management.Automation.Runspaces import RunspaceFactory > the_runspace = RunspaceFactory.CreateRunspace() > the_runspace.Open() > ri = RunspaceInvoke(the_runspace) > out = ri.Invoke('. .\myscript.ps1') > > I'm able to pass variables back and forth using > the_runspace.SessionStateProxy.Get/SetVariable, which is really cool. > > My problem is that any calls to Write-Host fail with "Cannot invoke this > function becasue the current host does not implement it." Of course I can > remove all the Write-Host's, but I really depend on them for status > information about how my script is running, and not having access to console > output makes my script much harder to debug. > > This post: http://decav.co > m/blogs/andre/a > rchive/2008/05/ > 01/invoking-pow > ershell-scripts > -from-an-applic > ation.aspx says > "To get around this, you can remove *write-host* from your scripts and > just have them write single lines, or you can implement a simple *PSHost* (although > this is a bit harder than it sounds)." > > What does "just have them write single lines mean?" Any pointers on how I > can get this working under IronPython? > > Thanks, > > Steve > > _______________________________________________ > 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 Jan 14 01:11:42 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 14 Jan 2009 00:11:42 +0000 Subject: [IronPython] Hosting IronPython in Powershell In-Reply-To: <86122ad70812301614y3264700dx73dbe363ef4968da@mail.gmail.com> References: <86122ad70812291916gca274ebwa83f01a61bc542e5@mail.gmail.com> <86122ad70812301239w1cc675a9r8159907b4066b3ea@mail.gmail.com> <495A893B.5060704@voidspace.org.uk> <86122ad70812301614y3264700dx73dbe363ef4968da@mail.gmail.com> Message-ID: <496D2DBE.3010306@voidspace.org.uk> Sorry for the late reply Stephen - I'm really bogged down in the last phases of copy editing. Did you get this sorted? Michael Stephen Ng wrote: > Thanks for the help.... I'll get the pdf version of the book this > weekend and read up to try to get more of a clue. Am I using > Invoke-GenericMethod correctly? > > PS C:\Program Files\IronPython 2.0> & 'C:\Program Files\IronPython > 2.0\Invoke-GenericMethod.ps1' $py Execute String '3' > Exception calling "Invoke" with "2" argument(s): "Exception has been > thrown by the target of an invocation." > At C:\Program Files\IronPython 2.0\Invoke-GenericMethod.ps1:96 char:30 > + $newMethod.Invoke( <<<< $instance, $methodParameters) > PS C:\Program Files\IronPython 2.0> & 'C:\Program Files\IronPython > 2.0\Invoke-GenericMethod.ps1' $py Execute String 'print 3' > Exception calling "Invoke" with "2" argument(s): "Exception has been > thrown by the target of an invocation." > At C:\Program Files\IronPython 2.0\Invoke-GenericMethod.ps1:96 char:30 > + $newMethod.Invoke( <<<< $instance, $methodParameters) > ------------------------------------------------------------------------ > > _______________________________________________ > 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 curt at hagenlocher.org Wed Jan 14 01:19:14 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 13 Jan 2009 16:19:14 -0800 Subject: [IronPython] Problems moving to IP 2.0 Release In-Reply-To: <515335F32AA04440B3DE6FEA1993E9AD03DB4B89@srv-be-101.Symyx-IC.symyx.com> References: <515335F32AA04440B3DE6FEA1993E9AD03DB4B89@srv-be-101.Symyx-IC.symyx.com> Message-ID: Did you run the installer for an earlier beta of IronPython 2.0? If so, try uninstalling first. The DLR team didn't finalize their version number until fairly recently, so we just made up the "1.0" :). 0.9 is the official version number for the currently-released DLR. On Tue, Jan 13, 2009 at 9:05 AM, Marty Nelson wrote: > I've got file version 2.0.11020.0 of IronPython and IronPython.Modules in > my GAC and can't get them out. L (Looks like release version is > 2.0.11121.0). > > > > I've tried gacutil /uf, but it claims it is need by a Windows Installer. > Any suggestions? > > > > (Oh, and BTW ? what was up with the Microsoft.Scripting moving from 1.0.0.0 > in pre-release to 0.9.0.0 in release?) > > > > > > Thanks, > > > > - Marty > > > ======= > Notice: This e-mail message, together with any attachments, contains > information of Symyx Technologies, Inc. or any of its affiliates or > subsidiaries that may be confidential, proprietary, copyrighted, > privileged and/or protected work product, and is meant solely for > the intended recipient. If you are not the intended recipient, and > have received this message in error, please contact the sender > immediately, permanently delete the original and any copies of this > email and any attachments thereto. > > _______________________________________________ > 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 Marty.Nelson at symyx.com Wed Jan 14 02:07:33 2009 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Tue, 13 Jan 2009 17:07:33 -0800 Subject: [IronPython] Problems moving to IP 2.0 Release In-Reply-To: References: <515335F32AA04440B3DE6FEA1993E9AD03DB4B89@srv-be-101.Symyx-IC.symyx.com> Message-ID: <515335F32AA04440B3DE6FEA1993E9AD03DB4DCF@srv-be-101.Symyx-IC.symyx.com> I don't see anything under Control Panel > Add/Remove Programs. ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 13, 2009 4:19 PM To: Discussion of IronPython Subject: Re: [IronPython] Problems moving to IP 2.0 Release Did you run the installer for an earlier beta of IronPython 2.0? If so, try uninstalling first. The DLR team didn't finalize their version number until fairly recently, so we just made up the "1.0" :). 0.9 is the official version number for the currently-released DLR. On Tue, Jan 13, 2009 at 9:05 AM, Marty Nelson wrote: I've got file version 2.0.11020.0 of IronPython and IronPython.Modules in my GAC and can't get them out. :-( (Looks like release version is 2.0.11121.0). I've tried gacutil /uf, but it claims it is need by a Windows Installer. Any suggestions? (Oh, and BTW - what was up with the Microsoft.Scripting moving from 1.0.0.0 in pre-release to 0.9.0.0 in release?) Thanks, - Marty ======= Notice: This e-mail message, together with any attachments, contains information of Symyx Technologies, Inc. or any of its affiliates or subsidiaries that may be confidential, proprietary, copyrighted, privileged and/or protected work product, and is meant solely for the intended recipient. If you are not the intended recipient, and have received this message in error, please contact the sender immediately, permanently delete the original and any copies of this email and any attachments thereto. _______________________________________________ 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 stephen at theleengs.com Wed Jan 14 02:09:17 2009 From: stephen at theleengs.com (Stephen Ng) Date: Tue, 13 Jan 2009 17:09:17 -0800 Subject: [IronPython] Hosting IronPython in Powershell In-Reply-To: <496D2DBE.3010306@voidspace.org.uk> References: <86122ad70812291916gca274ebwa83f01a61bc542e5@mail.gmail.com> <86122ad70812301239w1cc675a9r8159907b4066b3ea@mail.gmail.com> <495A893B.5060704@voidspace.org.uk> <86122ad70812301614y3264700dx73dbe363ef4968da@mail.gmail.com> <496D2DBE.3010306@voidspace.org.uk> Message-ID: <86122ad70901131709h111fd2ecs29a348e0141d2c4c@mail.gmail.com> I never solved this, but decided to go the other way and host powershell inside IronPython instead. Thanks, Steve On Tue, Jan 13, 2009 at 4:11 PM, Michael Foord wrote: > Sorry for the late reply Stephen - I'm really bogged down in the last > phases of copy editing. Did you get this sorted? > > Michael > > Stephen Ng wrote: > >> Thanks for the help.... I'll get the pdf version of the book this weekend >> and read up to try to get more of a clue. Am I using Invoke-GenericMethod >> correctly? >> >> PS C:\Program Files\IronPython 2.0> & 'C:\Program Files\IronPython >> 2.0\Invoke-GenericMethod.ps1' $py Execute String '3' >> Exception calling "Invoke" with "2" argument(s): "Exception has been >> thrown by the target of an invocation." >> At C:\Program Files\IronPython 2.0\Invoke-GenericMethod.ps1:96 char:30 >> + $newMethod.Invoke( <<<< $instance, $methodParameters) >> PS C:\Program Files\IronPython 2.0> & 'C:\Program Files\IronPython >> 2.0\Invoke-GenericMethod.ps1' $py Execute String 'print 3' >> Exception calling "Invoke" with "2" argument(s): "Exception has been >> thrown by the target of an invocation." >> At C:\Program Files\IronPython 2.0\Invoke-GenericMethod.ps1:96 char:30 >> + $newMethod.Invoke( <<<< $instance, $methodParameters) >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stephen at theleengs.com Wed Jan 14 02:11:32 2009 From: stephen at theleengs.com (Stephen Ng) Date: Tue, 13 Jan 2009 17:11:32 -0800 Subject: [IronPython] Embedding Powershell and Write-Host In-Reply-To: References: <86122ad70901131558m542ed7bct32140c408c970cd8@mail.gmail.com> Message-ID: <86122ad70901131711p1e2feef1nb0aaf3273a61976f@mail.gmail.com> Ouch, I guess I have to write some C#! There's no way to do this all in IronPython? Steve On Tue, Jan 13, 2009 at 4:06 PM, Curt Hagenlocher wrote: > You might find this link helpful. It was the second hit when googling > "implement pshost", and the author talks about integration between IronRuby > and PowerShell. > > http://bartdesmet.net/blogs/bart/archive/2008/07/06/windows-powershell-through-ironruby-writing-a-custom-pshost.aspx > > On Tue, Jan 13, 2009 at 3:58 PM, Stephen Ng wrote: > >> I'm using the following code to embed Powershell into IronPython. I hope >> to eventually replace almost all of my (large) Powershell script with >> IronPython. >> >> from System.Management.Automation.Runspaces import RunspaceFactory >> the_runspace = RunspaceFactory.CreateRunspace() >> the_runspace.Open() >> ri = RunspaceInvoke(the_runspace) >> out = ri.Invoke('. .\myscript.ps1') >> >> I'm able to pass variables back and forth using >> the_runspace.SessionStateProxy.Get/SetVariable, which is really cool. >> >> My problem is that any calls to Write-Host fail with "Cannot invoke this >> function becasue the current host does not implement it." Of course I can >> remove all the Write-Host's, but I really depend on them for status >> information about how my script is running, and not having access to console >> output makes my script much harder to debug. >> >> This post: http://decav.co >> m/blogs/andre/a >> rchive/2008/05/ >> 01/invoking-pow >> ershell-scripts >> -from-an-applic >> ation.aspx says >> "To get around this, you can remove *write-host* from your scripts and >> just have them write single lines, or you can implement a simple *PSHost* (although >> this is a bit harder than it sounds)." >> >> What does "just have them write single lines mean?" Any pointers on how I >> can get this working under IronPython? >> >> Thanks, >> >> Steve >> >> _______________________________________________ >> 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 curt at hagenlocher.org Wed Jan 14 02:35:23 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 13 Jan 2009 17:35:23 -0800 Subject: [IronPython] Embedding Powershell and Write-Host In-Reply-To: <86122ad70901131711p1e2feef1nb0aaf3273a61976f@mail.gmail.com> References: <86122ad70901131558m542ed7bct32140c408c970cd8@mail.gmail.com> <86122ad70901131711p1e2feef1nb0aaf3273a61976f@mail.gmail.com> Message-ID: Looking at the definitions of the C# classes in that blog entry and given that you're hosting PowerShell inside of IronPython, I see no reason why you wouldn't be able to implement the derived types in Python itself. But the link seems to do a pretty good job of giving minimal implementations for both classes. On Tue, Jan 13, 2009 at 5:11 PM, Stephen Ng wrote: > Ouch, I guess I have to write some C#! > There's no way to do this all in IronPython? > > Steve > > > On Tue, Jan 13, 2009 at 4:06 PM, Curt Hagenlocher wrote: > >> You might find this link helpful. It was the second hit when googling >> "implement pshost", and the author talks about integration between IronRuby >> and PowerShell. >> >> http://bartdesmet.net/blogs/bart/archive/2008/07/06/windows-powershell-through-ironruby-writing-a-custom-pshost.aspx >> >> On Tue, Jan 13, 2009 at 3:58 PM, Stephen Ng wrote: >> >>> I'm using the following code to embed Powershell into IronPython. I hope >>> to eventually replace almost all of my (large) Powershell script with >>> IronPython. >>> >>> from System.Management.Automation.Runspaces import RunspaceFactory >>> the_runspace = RunspaceFactory.CreateRunspace() >>> the_runspace.Open() >>> ri = RunspaceInvoke(the_runspace) >>> out = ri.Invoke('. .\myscript.ps1') >>> >>> I'm able to pass variables back and forth using >>> the_runspace.SessionStateProxy.Get/SetVariable, which is really cool. >>> >>> My problem is that any calls to Write-Host fail with "Cannot invoke this >>> function becasue the current host does not implement it." Of course I can >>> remove all the Write-Host's, but I really depend on them for status >>> information about how my script is running, and not having access to console >>> output makes my script much harder to debug. >>> >>> This post: http://decav.co >>> m/blogs/andre/a >>> rchive/2008/05/ >>> 01/invoking-pow >>> ershell-scripts >>> -from-an-applic >>> ation.aspx says >>> "To get around this, you can remove *write-host* from your scripts and >>> just have them write single lines, or you can implement a simple *PSHost >>> * (although this is a bit harder than it sounds)." >>> >>> What does "just have them write single lines mean?" Any pointers on how >>> I can get this working under IronPython? >>> >>> Thanks, >>> >>> Steve >>> >>> _______________________________________________ >>> 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 curt at hagenlocher.org Wed Jan 14 02:36:34 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 13 Jan 2009 17:36:34 -0800 Subject: [IronPython] Problems moving to IP 2.0 Release In-Reply-To: <515335F32AA04440B3DE6FEA1993E9AD03DB4DCF@srv-be-101.Symyx-IC.symyx.com> References: <515335F32AA04440B3DE6FEA1993E9AD03DB4B89@srv-be-101.Symyx-IC.symyx.com> <515335F32AA04440B3DE6FEA1993E9AD03DB4DCF@srv-be-101.Symyx-IC.symyx.com> Message-ID: Well, it was a long shot because the installer doesn't touch the GAC. Can you give us the precise error message (including error number, if any)? On Tue, Jan 13, 2009 at 5:07 PM, Marty Nelson wrote: > I don't see anything under Control Panel > Add/Remove Programs. > > > ------------------------------ > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Curt Hagenlocher > *Sent:* Tuesday, January 13, 2009 4:19 PM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] Problems moving to IP 2.0 Release > > > > Did you run the installer for an earlier beta of IronPython 2.0? If so, > try uninstalling first. > > > > The DLR team didn't finalize their version number until fairly recently, so > we just made up the "1.0" :). 0.9 is the official version number for the > currently-released DLR. > > On Tue, Jan 13, 2009 at 9:05 AM, Marty Nelson > wrote: > > I've got file version 2.0.11020.0 of IronPython and IronPython.Modules in > my GAC and can't get them out. L (Looks like release version is > 2.0.11121.0). > > > > I've tried gacutil /uf, but it claims it is need by a Windows Installer. > Any suggestions? > > > > (Oh, and BTW ? what was up with the Microsoft.Scripting moving from 1.0.0.0 > in pre-release to 0.9.0.0 in release?) > > > > > > Thanks, > > > > - Marty > > > > ======= > Notice: This e-mail message, together with any attachments, contains > information of Symyx Technologies, Inc. or any of its affiliates or > subsidiaries that may be confidential, proprietary, copyrighted, > privileged and/or protected work product, and is meant solely for > the intended recipient. If you are not the intended recipient, and > have received this message in error, please contact the sender > immediately, permanently delete the original and any copies of this > email and any attachments thereto. > > > _______________________________________________ > 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 laurionb at service.exchange.microsoft.com Wed Jan 14 04:43:07 2009 From: laurionb at service.exchange.microsoft.com (Laurion Burchall) Date: Wed, 14 Jan 2009 03:43:07 +0000 Subject: [IronPython] Getting a traceback stack in IronPython 2.0 Message-ID: <98511B3BD104B14BB532FD95828D69B50DF568D7@BL2SDF0102MB001.namsdf01.sdf.exchangelabs.com> I'm upgrading our internal test framework from IronPython 1.X to 2.X. Getting a good stack trace from an exception is eluding me. The old code looks like this: try: # runs the test except Exception, e: failCount += 1 PrintTestOutcome(testCount, False, testFullName, e.ToString()) What is the 2.X equivalent? By default e.ToString() gives the ugly 'real' callstack. In a test program e.clsException did the right thing, but that only appears sometimg (if System is imported?) and when used in the test framework gave the .NET callstack instead of line number in Python scripts. Any suggestions? thanks, --Laurion -------------- next part -------------- An HTML attachment was scrubbed... URL: From daftspaniel at gmail.com Wed Jan 14 08:54:16 2009 From: daftspaniel at gmail.com (Davy Mitchell) Date: Wed, 14 Jan 2009 07:54:16 +0000 Subject: [IronPython] IP1.1.2 - Exception Catching Message-ID: <20253b0c0901132354t45960c16sd9fc2295b37092e8@mail.gmail.com> Hi List, Sorry if this is a bit basic but has got me puzzled. I am running a simple script to configure IIS using System.DirectoryServices and it has been running well for months. The whole thing is wrapped in a try i.e. try: ... except Exception, inst: ... # write to log file. I've had a single execution (trying to reproduce) that caused the script to stop mid-way thru but not record any exception. Now it could be the logging failed somehow but I am wondering if 'except Exception, inst' is a suitable catch all?? Thanks, Davy Mitchell -------------- next part -------------- An HTML attachment was scrubbed... URL: From christian.muirhead at resolversystems.com Wed Jan 14 13:11:16 2009 From: christian.muirhead at resolversystems.com (Christian Muirhead) Date: Wed, 14 Jan 2009 12:11:16 +0000 Subject: [IronPython] IP1.1.2 - Exception Catching In-Reply-To: <20253b0c0901132354t45960c16sd9fc2295b37092e8@mail.gmail.com> References: <20253b0c0901132354t45960c16sd9fc2295b37092e8@mail.gmail.com> Message-ID: <496DD664.90200@resolversystems.com> Davy Mitchell wrote: > I am running a simple script to configure IIS using > System.DirectoryServices and it has been running well for months. > The whole thing is wrapped in a try i.e. > > try: > ... > except Exception, inst: > ... # write to log file. > > I've had a single execution (trying to reproduce) that caused the script > to stop mid-way thru but not record any exception. Now it could be the > logging failed somehow but I am wondering if 'except Exception, inst' is > a suitable catch all?? > Just to add - we've seen this a few times as well. Our distributed build script very occasionally dies with an IronPython Console crash dialog despite try/excepts around all of the threads of execution. It took a long time to actually see what the error was - it looks like it was a .NET file system exception resulting from a call to shutil.copyfile (unfortunately I didn't manage to grab the text). The traceback was from .Flush - we're copying files over a network which occasionally goes away, so that would make sense. (This is also IP 1.1.2 - haven't tried this with IP 2.) Christian -- Christian Muirhead Resolver Systems christian.muirhead at resolversystems.com Resolver Systems Ltd 17a Clerkenwell Road, London EC1M 5RD, UK VAT No.: GB 893 5643 79 Registered in England and Wales as company number 5467329. Registered address: 843 Finchley Road, London NW11 8NA, UK From kristian.jaksch at gmail.com Wed Jan 14 13:15:16 2009 From: kristian.jaksch at gmail.com (Kristian Jaksch) Date: Wed, 14 Jan 2009 13:15:16 +0100 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <496D1D5D.8020602@voidspace.org.uk> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> <496D1D5D.8020602@voidspace.org.uk> Message-ID: <1dab55500901140415u39298362n231f6245aef3132d@mail.gmail.com> Thanks again for the reply. I must be getting something seriously wrong. I did what you said and I don't get any Javascript error but I still get the same error as before from Ironpython: "SystemError: Object reference not set to an instance of an object." I looked at the source code of your Web IDE and tried to understand how you did it there. You are hooking up a button click with the SetExample() function and that works just fine but if I try to call the SetExample() directly from the "_method()" function in the RefreshExamples class, then I get the same error as above. Below I show what I mean (it's your code a bit modified): setCode = ScriptableEvent() load = Load() def SetExample(name): args = ScriptableEventArgs() args.code = 'TESTING' setCode.OnEvent(args) #SystemError: Object reference not set to an instance of an object. class RefreshExamples(Scriptable): def _method(self): SetExample('browserDOM') #THIS DOESN'T WORK (It makes the call but gives the error above) refresh = RefreshExamples() HtmlPage.RegisterScriptableObject("codeChange", codeChange) HtmlPage.RegisterScriptableObject("refresh", refresh) HtmlPage.RegisterScriptableObject("load", load) HtmlPage.RegisterScriptableObject("setCode", setCode) # Default example HtmlPage.Document.code.value = examples.browserDOM root = Canvas() refresh._method() Application.Current.RootVisual = root Have I misunderstood this completely or shouldn't it be possible to directly call the SetExample()? Please bear in mind that I've only been programming Ironpython a couple of months :-) Mustn't these errors only depend on IronPython and have nothing to do with the JavaScript? I mean, first is the Silverlight app built, and this error occurs at that time so Javascript can't have any part in the errors? I know it's much to ask for but would it be possible for me to send you the minimalistic test website I have so you maybe can have a quick look at it? Or if you maybe have a as small as possible project I can have a look at. Again, thanks for all your help! 2009/1/14 Michael Foord : > Ahhh... there is a detail I missed out in that article. You can only hook up > the Javascript function after the Silverlight control has loaded. This is > *possibly* the cause of your problems. > > I do the hooking up in an onload function: > > > function onload() { > control = document.getElementById('SilverlightPlugin'); > control.Content.setCode.Event = setCode; > } > > You pass this function in the online parameter in the Silverlight object > element: > > data="data:application/x-silverlight," type="application/x-silverlight-2" > width="450" height="540"> > > > > > Hopefully this sorts out the problem for you. > > Michael Foord > > Kristian Jaksch wrote: >> >> Thanks for the reply! >> >> No, I can't get it to work with Javascript either. I added the script >> below to my page: >> >> >> >> I'm not sure about the exact translation of the error message (It's in >> swedish) but it's something like: >> >> "Error: Invalid pointer" >> >> I guess it has something to do with the error I receive in my "app.py" >> file as I described previously. >> >> I made a minimal app.py file to test it again but I still receive the >> same error. This file also test to get a string from Javascript to >> Ironpython and that works just fine. Below is my complete file: >> >> >> import clr, sys >> >> clr.AddReferenceToFile("Scriptable.dll") >> >> from System.Windows import Application >> from System.Windows.Browser import * >> from System.Windows.Controls import * >> from System.Windows import Input >> from Scriptable import * >> >> >> class GetFromEditor(ScriptableForString): >> def _method(self, string): >> root.message.Text = string >> #return new_string >> >> GetFromEditor = GetFromEditor() >> >> root = Application.Current.LoadRootVisual(UserControl(), "app.xaml") >> >> HtmlPage.RegisterScriptableObject("GetFromEditor", GetFromEditor) >> >> >> event = ScriptableEvent() >> >> # This must also be registered >> HtmlPage.RegisterScriptableObject("event", event) >> >> args = ScriptableEventArgs() >> args.val = 'some string' >> event.OnEvent(args) >> >> >> It must be something I'm missing but I just can't see what it could >> be. Do you know of any good example were this approach is used? >> >> Thanks again! >> >> >> 2009/1/12 Michael Foord : >> >>> >>> xkrja wrote: >>> >>>> >>>> I'm trying to call javascript from IronPython (via Silverlight 2) but I >>>> can' >>>> get it to work properly. I looked at this example: >>>> >>>> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 >>>> http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id10 >>>> It's explained very clearly but when I try to run my code I get a System >>>> Error: >>>> >>>> SystemError: Object reference not set to an instance of an object. >>>> >>>> I just inserted the lines of code found on the example page in my >>>> IronPyton >>>> code: >>>> >>>> event = ScriptableEvent() >>>> >>>> # This must also be registered >>>> HtmlPage.RegisterScriptableObject("event", event) >>>> >>>> args = ScriptableEventArgs() >>>> args.val = 'some string' >>>> event.OnEvent(args) #This gives me a System Error >>>> >>>> I create a C# .dll as explained in the example and add a reference to >>>> it. >>>> The source is below: >>>> >>>> using System; >>>> using System.Windows.Browser; >>>> >>>> namespace Scriptable >>>> { >>>> >>>> [ScriptableTypeAttribute] >>>> public class ScriptableForString >>>> { >>>> [ScriptableMemberAttribute] >>>> public string method(string value) >>>> { return this._method(value); } >>>> >>>> public virtual string _method(string value) >>>> { return "override me"; } >>>> } >>>> >>>> [ScriptableType] >>>> public class ScriptableEvent >>>> { >>>> [ScriptableMember] >>>> public event EventHandler Event; >>>> >>>> public virtual void OnEvent(ScriptableEventArgs e) >>>> { >>>> Event(this, e); >>>> } >>>> } >>>> >>>> [ScriptableTypeAttribute] >>>> public class ScriptableEventArgs : EventArgs >>>> { >>>> private string _val; >>>> >>>> [ScriptableMemberAttribute] >>>> public string val >>>> { >>>> get { return _val; } >>>> set { _val = value; } >>>> } >>>> } >>>> } >>>> >>>> Can anyone explain what I'm doing wrong? >>>> Thanks for any help! >>>> >>>> >>>> >>> >>> Hmmm... do you have any Javascript hooking up to the event? If you don't, >>> try hooking up to it and see if it makes any difference. >>> >>> The same code works for me. :-) >>> >>> Michael >>> >>> -- >>> 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 >>> >>> >> >> _______________________________________________ >> 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 daftspaniel at gmail.com Wed Jan 14 13:18:07 2009 From: daftspaniel at gmail.com (Davy Mitchell) Date: Wed, 14 Jan 2009 12:18:07 +0000 Subject: [IronPython] IP1.1.2 - Exception Catching In-Reply-To: <496DD664.90200@resolversystems.com> References: <20253b0c0901132354t45960c16sd9fc2295b37092e8@mail.gmail.com> <496DD664.90200@resolversystems.com> Message-ID: <20253b0c0901140418t4a29e6bdu6713d9b3e0048562@mail.gmail.com> Thanks for the reply Christian. I have tracked down my issue - only occurring on French 2003 :-) Unable to translate bytes [E9] at index 16 from specified code page to Unicode. Which is fair enough so I can toughen up the logging and move on. Thanks, Davy Mitchell On Wed, Jan 14, 2009 at 12:11 PM, Christian Muirhead < christian.muirhead at resolversystems.com> wrote: > Davy Mitchell wrote: > >> I am running a simple script to configure IIS using >> System.DirectoryServices and it has been running well for months. >> The whole thing is wrapped in a try i.e. >> >> try: >> ... >> except Exception, inst: >> ... # write to log file. >> >> I've had a single execution (trying to reproduce) that caused the script >> to stop mid-way thru but not record any exception. Now it could be the >> logging failed somehow but I am wondering if 'except Exception, inst' is a >> suitable catch all?? >> >> > Just to add - we've seen this a few times as well. Our distributed build > script very occasionally dies with an IronPython Console crash dialog > despite try/excepts around all of the threads of execution. It took a long > time to actually see what the error was - it looks like it was a .NET file > system exception resulting from a call to shutil.copyfile (unfortunately I > didn't manage to grab the text). The traceback was from .Flush - > we're copying files over a network which occasionally goes away, so that > would make sense. > > (This is also IP 1.1.2 - haven't tried this with IP 2.) > > Christian > > -- > Christian Muirhead > Resolver Systems > christian.muirhead at resolversystems.com > > > Resolver Systems Ltd > 17a Clerkenwell Road, London EC1M 5RD, UK > VAT No.: GB 893 5643 79 Registered in England and Wales as company number > 5467329. > Registered address: 843 Finchley Road, London NW11 8NA, UK > _______________________________________________ > 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 Jan 14 15:34:02 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 14 Jan 2009 14:34:02 +0000 Subject: [IronPython] Hosting IronPython in Powershell In-Reply-To: <86122ad70901131709h111fd2ecs29a348e0141d2c4c@mail.gmail.com> References: <86122ad70812291916gca274ebwa83f01a61bc542e5@mail.gmail.com> <86122ad70812301239w1cc675a9r8159907b4066b3ea@mail.gmail.com> <495A893B.5060704@voidspace.org.uk> <86122ad70812301614y3264700dx73dbe363ef4968da@mail.gmail.com> <496D2DBE.3010306@voidspace.org.uk> <86122ad70901131709h111fd2ecs29a348e0141d2c4c@mail.gmail.com> Message-ID: <496DF7DA.7000205@voidspace.org.uk> Stephen Ng wrote: > I never solved this, but decided to go the other way and host > powershell inside IronPython instead. OK - I'll try and have a look at it during the weekend anyway. Deadline for copy-editing the last of the manuscript is Friday. Michael > > Thanks, > > Steve > > On Tue, Jan 13, 2009 at 4:11 PM, Michael Foord > > wrote: > > Sorry for the late reply Stephen - I'm really bogged down in the > last phases of copy editing. Did you get this sorted? > > Michael > > Stephen Ng wrote: > > Thanks for the help.... I'll get the pdf version of the book > this weekend and read up to try to get more of a clue. Am I > using Invoke-GenericMethod correctly? > > PS C:\Program Files\IronPython 2.0> & 'C:\Program > Files\IronPython 2.0\Invoke-GenericMethod.ps1' $py Execute > String '3' > Exception calling "Invoke" with "2" argument(s): "Exception > has been thrown by the target of an invocation." > At C:\Program Files\IronPython 2.0\Invoke-GenericMethod.ps1:96 > char:30 > + $newMethod.Invoke( <<<< $instance, > $methodParameters) > PS C:\Program Files\IronPython 2.0> & 'C:\Program > Files\IronPython 2.0\Invoke-GenericMethod.ps1' $py Execute > String 'print 3' > Exception calling "Invoke" with "2" argument(s): "Exception > has been thrown by the target of an invocation." > At C:\Program Files\IronPython 2.0\Invoke-GenericMethod.ps1:96 > char:30 > + $newMethod.Invoke( <<<< $instance, > $methodParameters) > ------------------------------------------------------------------------ > > _______________________________________________ > 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 > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From Marty.Nelson at symyx.com Wed Jan 14 15:35:10 2009 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Wed, 14 Jan 2009 06:35:10 -0800 Subject: [IronPython] Problems moving to IP 2.0 Release In-Reply-To: References: <515335F32AA04440B3DE6FEA1993E9AD03DB4B89@srv-be-101.Symyx-IC.symyx.com><515335F32AA04440B3DE6FEA1993E9AD03DB4DCF@srv-be-101.Symyx-IC.symyx.com> Message-ID: <515335F32AA04440B3DE6FEA1993E9AD03DB4E3F@srv-be-101.Symyx-IC.symyx.com> Ok, I just installed the new ones and they replaced the existing entries: C:\Program Files\Microsoft Visual Studio 8\VC>gacutil /i "C:\Program Files\IronPython 2.0\IronPython.dll" We use the GAC because we have older components written against IP1.1 that we have not yet updated, so we need to run 1.1 and 2.0 side-by-side. ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 13, 2009 5:37 PM To: Discussion of IronPython Subject: Re: [IronPython] Problems moving to IP 2.0 Release Well, it was a long shot because the installer doesn't touch the GAC. Can you give us the precise error message (including error number, if any)? On Tue, Jan 13, 2009 at 5:07 PM, Marty Nelson wrote: I don't see anything under Control Panel > Add/Remove Programs. ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 13, 2009 4:19 PM To: Discussion of IronPython Subject: Re: [IronPython] Problems moving to IP 2.0 Release Did you run the installer for an earlier beta of IronPython 2.0? If so, try uninstalling first. The DLR team didn't finalize their version number until fairly recently, so we just made up the "1.0" :). 0.9 is the official version number for the currently-released DLR. On Tue, Jan 13, 2009 at 9:05 AM, Marty Nelson wrote: I've got file version 2.0.11020.0 of IronPython and IronPython.Modules in my GAC and can't get them out. :-( (Looks like release version is 2.0.11121.0). I've tried gacutil /uf, but it claims it is need by a Windows Installer. Any suggestions? (Oh, and BTW - what was up with the Microsoft.Scripting moving from 1.0.0.0 in pre-release to 0.9.0.0 in release?) Thanks, - Marty ======= Notice: This e-mail message, together with any attachments, contains information of Symyx Technologies, Inc. or any of its affiliates or subsidiaries that may be confidential, proprietary, copyrighted, privileged and/or protected work product, and is meant solely for the intended recipient. If you are not the intended recipient, and have received this message in error, please contact the sender immediately, permanently delete the original and any copies of this email and any attachments thereto. _______________________________________________ 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 dan.eloff at gmail.com Wed Jan 14 16:28:07 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 14 Jan 2009 10:28:07 -0500 Subject: [IronPython] Problem loading IronPython Silverlight app In-Reply-To: <1dab55500901122319o61fafafaq2b62fde910cfa222@mail.gmail.com> References: <21401718.post@talk.nabble.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B469C@NA-EXMSG-C116.redmond.corp.microsoft.com> <1dab55500901122319o61fafafaq2b62fde910cfa222@mail.gmail.com> Message-ID: <4817b6fc0901140728h54b16a8ey57a60d38f9d0fec8@mail.gmail.com> On Tue, Jan 13, 2009 at 2:19 AM, Kristian Jaksch wrote: > Thanks for the reply! > > It seems like the problem was that the SL2 application tried to > connect to the DOM during startup. I can find an alternative solution > to that so it won't be a problem. I haven't been able to reproduce the > problem so I think it's fixed. > > Thanks very much! > Remember to first check if HtmlPage.IsEnabled is True, otherwise your DOM manipulations will likely fail. -Dan From dan.eloff at gmail.com Wed Jan 14 16:34:24 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 14 Jan 2009 10:34:24 -0500 Subject: [IronPython] Getting a traceback stack in IronPython 2.0 In-Reply-To: <98511B3BD104B14BB532FD95828D69B50DF568D7@BL2SDF0102MB001.namsdf01.sdf.exchangelabs.com> References: <98511B3BD104B14BB532FD95828D69B50DF568D7@BL2SDF0102MB001.namsdf01.sdf.exchangelabs.com> Message-ID: <4817b6fc0901140734h6f615ffdn22ff91c8278ac301@mail.gmail.com> I use this code: from Microsoft.Scripting.Hosting import ExceptionOperations from IronPython.Hosting import Python engine = Python.CreateEngine() exc_service = engine.GetService[ExceptionOperations]() traceback = exc_service.FormatException(e.clsException) -Dan On Tue, Jan 13, 2009 at 10:43 PM, Laurion Burchall wrote: > I'm upgrading our internal test framework from IronPython 1.X to 2.X. > Getting a good stack trace from an exception is eluding me. The old code > looks like this: > > try: > # runs the test > except Exception, e: > failCount += 1 > PrintTestOutcome(testCount, False, testFullName, e.ToString()) > What is the 2.X equivalent? By default e.ToString() gives the ugly 'real' > callstack. In a test program e.clsException did the right thing, but that > only appears sometimg (if System is imported?) and when used in the test > framework gave the .NET callstack instead of line number in Python scripts. > > Any suggestions? > > thanks, > --Laurion > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From Jimmy.Schementi at microsoft.com Wed Jan 14 20:08:22 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 14 Jan 2009 11:08:22 -0800 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <1dab55500901140415u39298362n231f6245aef3132d@mail.gmail.com> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> <496D1D5D.8020602@voidspace.org.uk> <1dab55500901140415u39298362n231f6245aef3132d@mail.gmail.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5005@NA-EXMSG-C116.redmond.corp.microsoft.com> A MINIMAL reproduction of the error would be appropriate =) > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Kristian Jaksch > Sent: Wednesday, January 14, 2009 4:15 AM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython to JavaScript > > Thanks again for the reply. > > I must be getting something seriously wrong. I did what you said and I > don't get any Javascript error but I still get the same error as > before from Ironpython: > > "SystemError: Object reference not set to an instance of an object." > > I looked at the source code of your Web IDE and tried to understand > how you did it there. You are hooking up a button click with the > SetExample() function and that works just fine but if I try to call > the SetExample() directly from the "_method()" function in the > RefreshExamples class, then I get the same error as above. Below I > show what I mean (it's your code a bit modified): > > > setCode = ScriptableEvent() > load = Load() > > > def SetExample(name): > args = ScriptableEventArgs() > args.code = 'TESTING' > setCode.OnEvent(args) #SystemError: Object reference not set to > an instance of an object. > > > class RefreshExamples(Scriptable): > def _method(self): > SetExample('browserDOM') #THIS DOESN'T WORK (It makes the > call but gives the error above) > > > refresh = RefreshExamples() > > HtmlPage.RegisterScriptableObject("codeChange", codeChange) > HtmlPage.RegisterScriptableObject("refresh", refresh) > HtmlPage.RegisterScriptableObject("load", load) > HtmlPage.RegisterScriptableObject("setCode", setCode) > > # Default example > HtmlPage.Document.code.value = examples.browserDOM > > root = Canvas() > refresh._method() > > > Application.Current.RootVisual = root > > > Have I misunderstood this completely or shouldn't it be possible to > directly call the SetExample()? Please bear in mind that I've only > been programming Ironpython a couple of months :-) > > Mustn't these errors only depend on IronPython and have nothing to do > with the JavaScript? I mean, first is the Silverlight app built, and > this error occurs at that time so Javascript can't have any part in > the errors? > > I know it's much to ask for but would it be possible for me to send > you the minimalistic test website I have so you maybe can have a quick > look at it? Or if you maybe have a as small as possible project I can > have a look at. > > Again, thanks for all your help! > > > > 2009/1/14 Michael Foord : > > Ahhh... there is a detail I missed out in that article. You can only > hook up > > the Javascript function after the Silverlight control has loaded. > This is > > *possibly* the cause of your problems. > > > > I do the hooking up in an onload function: > > > > > > function onload() { > > control = > document.getElementById('SilverlightPlugin'); > > control.Content.setCode.Event = setCode; > > } > > > > You pass this function in the online parameter in the Silverlight > object > > element: > > > > > data="data:application/x-silverlight," type="application/x- > silverlight-2" > > width="450" height="540"> > > > > > > > > > > Hopefully this sorts out the problem for you. > > > > Michael Foord > > > > Kristian Jaksch wrote: > >> > >> Thanks for the reply! > >> > >> No, I can't get it to work with Javascript either. I added the > script > >> below to my page: > >> > >> > >> > >> I'm not sure about the exact translation of the error message (It's > in > >> swedish) but it's something like: > >> > >> "Error: Invalid pointer" > >> > >> I guess it has something to do with the error I receive in my > "app.py" > >> file as I described previously. > >> > >> I made a minimal app.py file to test it again but I still receive > the > >> same error. This file also test to get a string from Javascript to > >> Ironpython and that works just fine. Below is my complete file: > >> > >> > >> import clr, sys > >> > >> clr.AddReferenceToFile("Scriptable.dll") > >> > >> from System.Windows import Application > >> from System.Windows.Browser import * > >> from System.Windows.Controls import * > >> from System.Windows import Input > >> from Scriptable import * > >> > >> > >> class GetFromEditor(ScriptableForString): > >> def _method(self, string): > >> root.message.Text = string > >> #return new_string > >> > >> GetFromEditor = GetFromEditor() > >> > >> root = Application.Current.LoadRootVisual(UserControl(), "app.xaml") > >> > >> HtmlPage.RegisterScriptableObject("GetFromEditor", GetFromEditor) > >> > >> > >> event = ScriptableEvent() > >> > >> # This must also be registered > >> HtmlPage.RegisterScriptableObject("event", event) > >> > >> args = ScriptableEventArgs() > >> args.val = 'some string' > >> event.OnEvent(args) > >> > >> > >> It must be something I'm missing but I just can't see what it could > >> be. Do you know of any good example were this approach is used? > >> > >> Thanks again! > >> > >> > >> 2009/1/12 Michael Foord : > >> > >>> > >>> xkrja wrote: > >>> > >>>> > >>>> I'm trying to call javascript from IronPython (via Silverlight 2) > but I > >>>> can' > >>>> get it to work properly. I looked at this example: > >>>> > >>>> > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id1 > 0 > >>>> > http://www.voidspace.org.uk/ironpython/silverlight/scriptable.shtml#id1 > 0 > >>>> It's explained very clearly but when I try to run my code I get a > System > >>>> Error: > >>>> > >>>> SystemError: Object reference not set to an instance of an object. > >>>> > >>>> I just inserted the lines of code found on the example page in my > >>>> IronPyton > >>>> code: > >>>> > >>>> event = ScriptableEvent() > >>>> > >>>> # This must also be registered > >>>> HtmlPage.RegisterScriptableObject("event", event) > >>>> > >>>> args = ScriptableEventArgs() > >>>> args.val = 'some string' > >>>> event.OnEvent(args) #This gives me a System Error > >>>> > >>>> I create a C# .dll as explained in the example and add a reference > to > >>>> it. > >>>> The source is below: > >>>> > >>>> using System; > >>>> using System.Windows.Browser; > >>>> > >>>> namespace Scriptable > >>>> { > >>>> > >>>> [ScriptableTypeAttribute] > >>>> public class ScriptableForString > >>>> { > >>>> [ScriptableMemberAttribute] > >>>> public string method(string value) > >>>> { return this._method(value); } > >>>> > >>>> public virtual string _method(string value) > >>>> { return "override me"; } > >>>> } > >>>> > >>>> [ScriptableType] > >>>> public class ScriptableEvent > >>>> { > >>>> [ScriptableMember] > >>>> public event EventHandler Event; > >>>> > >>>> public virtual void OnEvent(ScriptableEventArgs e) > >>>> { > >>>> Event(this, e); > >>>> } > >>>> } > >>>> > >>>> [ScriptableTypeAttribute] > >>>> public class ScriptableEventArgs : EventArgs > >>>> { > >>>> private string _val; > >>>> > >>>> [ScriptableMemberAttribute] > >>>> public string val > >>>> { > >>>> get { return _val; } > >>>> set { _val = value; } > >>>> } > >>>> } > >>>> } > >>>> > >>>> Can anyone explain what I'm doing wrong? > >>>> Thanks for any help! > >>>> > >>>> > >>>> > >>> > >>> Hmmm... do you have any Javascript hooking up to the event? If you > don't, > >>> try hooking up to it and see if it makes any difference. > >>> > >>> The same code works for me. :-) > >>> > >>> Michael > >>> > >>> -- > >>> 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 > >>> > >>> > >> > >> _______________________________________________ > >> 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 > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kristian.jaksch at gmail.com Wed Jan 14 23:04:07 2009 From: kristian.jaksch at gmail.com (Kristian Jaksch) Date: Wed, 14 Jan 2009 23:04:07 +0100 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5005@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> <496D1D5D.8020602@voidspace.org.uk> <1dab55500901140415u39298362n231f6245aef3132d@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5005@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <1dab55500901141404n78edc71bn5bce5c7b46453568@mail.gmail.com> Ok, here we go. I attach a MINIMAL sample for you guys :-) It should just send a string from python to javascript and an alert message should show the string. As I said. It must be something obvious I'm missing out here but my brain is locked for further thinking... Anyway, thanks! 2009/1/14 Jimmy Schementi : > A MINIMAL reproduction of the error would be appropriate =) > -------------- next part -------------- A non-text attachment was scrubbed... Name: jsCallTest.zip Type: application/zip Size: 147803 bytes Desc: not available URL: From Jimmy.Schementi at microsoft.com Wed Jan 14 23:11:41 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 14 Jan 2009 14:11:41 -0800 Subject: [IronPython] IronPython to JavaScript In-Reply-To: <1dab55500901141404n78edc71bn5bce5c7b46453568@mail.gmail.com> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> <496D1D5D.8020602@voidspace.org.uk> <1dab55500901140415u39298362n231f6245aef3132d@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5005@NA-EXMSG-C116.redmond.corp.microsoft.com> <1dab55500901141404n78edc71bn5bce5c7b46453568@mail.gmail.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5157@NA-EXMSG-C116.redmond.corp.microsoft.com> Thanks, I'll take a look at it. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Kristian Jaksch > Sent: Wednesday, January 14, 2009 2:04 PM > To: Discussion of IronPython > Subject: Re: [IronPython] IronPython to JavaScript > > Ok, here we go. I attach a MINIMAL sample for you guys :-) > > It should just send a string from python to javascript and an alert > message should show the string. > > As I said. It must be something obvious I'm missing out here but my > brain is locked for further thinking... > > Anyway, thanks! > > > 2009/1/14 Jimmy Schementi : > > A MINIMAL reproduction of the error would be appropriate =) > > From jklimek at gmail.com Thu Jan 15 15:00:06 2009 From: jklimek at gmail.com (John Klimek) Date: Thu, 15 Jan 2009 09:00:06 -0500 Subject: [IronPython] Can I compile IronPython code into bytecode? Message-ID: Instead of giving users the sourcecode to my python scripts (.py), can I compile them into bytecode? (.pyc files I think?) Sent from my mobile phone. Please excuse any grammatical or spelling errors. From curt at hagenlocher.org Thu Jan 15 15:19:54 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 15 Jan 2009 06:19:54 -0800 Subject: [IronPython] Can I compile IronPython code into bytecode? In-Reply-To: References: Message-ID: No, but you can compile them into dlls and/or exes using the pyc.py precompiler sample. On Thu, Jan 15, 2009 at 6:00 AM, John Klimek wrote: > Instead of giving users the sourcecode to my python scripts (.py), can I > compile them into bytecode? (.pyc files I think?) > > Sent from my mobile phone. Please excuse any grammatical or spelling > errors. > _______________________________________________ > 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 dfugate at microsoft.com Thu Jan 15 17:51:41 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Thu, 15 Jan 2009 08:51:41 -0800 Subject: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 Message-ID: Some of you may have noticed that IronPython bugs on CodePlex previously assigned to the "2.1" release are now assigned to "2.6". We've simply renamed the 2.1 release of IronPython to 2.6 to reflect upon the fact that the next major release of IronPython will be largely compatible with CPython 2.6. All details about IP 2.1 that were previously discussed on Harry Pierson's blog (see http://devhawk.net/2008/07/17/IronPython+Post+20+Roadmap.aspx) still apply to IP 2.6. We're doing this simple name change to help eliminate confusion about IronPython's compatibility with various CPython and Jython releases. David Fugate Microsoft - IronPython http://knowbody.livejournal.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From renaud.durand.it at gmail.com Thu Jan 15 18:13:47 2009 From: renaud.durand.it at gmail.com (Renaud Durand) Date: Thu, 15 Jan 2009 18:13:47 +0100 Subject: [IronPython] Issues with System members when using pyc.py Message-ID: <8c5392700901150913u8c7a8a8j1d2c174a494b18d7@mail.gmail.com> Hi, I'm new at IronPython and i'm trying to compile a small app using pyc.py. When launched with the interpreter there's no issue. But when I launch the executable I get this : > Unhandled Exception: System.MissingMemberException: 'namespace#' object has no attribute 'DateTime' or this while importing pySerial : > Unhandled Exception: System.MissingMemberException: 'namespace#' object has no attribute 'Array' and > Unhandled Exception: System.MissingMemberException: 'namespace#' object has no attribute 'IO' Does someone have an idea ? Where am I wrong ? Thanks. -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Thu Jan 15 19:12:58 2009 From: dinov at microsoft.com (Dino Viehland) Date: Thu, 15 Jan 2009 10:12:58 -0800 Subject: [IronPython] Issues with System members when using pyc.py In-Reply-To: <8c5392700901150913u8c7a8a8j1d2c174a494b18d7@mail.gmail.com> References: <8c5392700901150913u8c7a8a8j1d2c174a494b18d7@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704DFC392@NA-EXMSG-C102.redmond.corp.microsoft.com> This is a bug - we're not adding references to mscorlib/System.dll when we run your app. You can just: import clr clr.AddReference('mscorlib') clr.AddReference('System') to your program. Alternately you could modify pyc.py to send these two strings in the references array to InitializeModule but that's more complex. I've filed a bug: http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20623 From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Renaud Durand Sent: Thursday, January 15, 2009 9:14 AM To: users at lists.ironpython.com Subject: [IronPython] Issues with System members when using pyc.py Hi, I'm new at IronPython and i'm trying to compile a small app using pyc.py. When launched with the interpreter there's no issue. But when I launch the executable I get this : > Unhandled Exception: System.MissingMemberException: 'namespace#' object has no attribute 'DateTime' or this while importing pySerial : > Unhandled Exception: System.MissingMemberException: 'namespace#' object has no attribute 'Array' and > Unhandled Exception: System.MissingMemberException: 'namespace#' object has no attribute 'IO' Does someone have an idea ? Where am I wrong ? Thanks. -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From slide.o.mix at gmail.com Thu Jan 15 20:14:49 2009 From: slide.o.mix at gmail.com (Slide) Date: Thu, 15 Jan 2009 12:14:49 -0700 Subject: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 In-Reply-To: References: Message-ID: On Thu, Jan 15, 2009 at 9:51 AM, Dave Fugate wrote: > Some of you may have noticed that IronPython bugs on CodePlex previously > assigned to the "2.1" release are now assigned to "2.6". We've simply > renamed the 2.1 release of IronPython to 2.6 to reflect upon the fact that > the next major release of IronPython will be largely compatible with CPython > 2.6. All details about IP 2.1 that were previously discussed on Harry > Pierson's blog (see > http://devhawk.net/2008/07/17/IronPython+Post+20+Roadmap.aspx) still apply > to IP 2.6. We're doing this simple name change to help eliminate confusion > about IronPython's compatibility with various CPython and Jython releases. > > > > David Fugate > > Microsoft - IronPython > Personally, I think this is a great move! Thanks, slide From fuzzyman at voidspace.org.uk Thu Jan 15 20:54:12 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 15 Jan 2009 19:54:12 +0000 Subject: [IronPython] Issues with System members when using pyc.py In-Reply-To: <350E7D38B6D819428718949920EC23555704DFC392@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <8c5392700901150913u8c7a8a8j1d2c174a494b18d7@mail.gmail.com> <350E7D38B6D819428718949920EC23555704DFC392@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <496F9464.3070000@voidspace.org.uk> Dino Viehland wrote: > > This is a bug ? we?re not adding references to mscorlib/System.dll > when we run your app. You can just: > > import clr > > clr.AddReference(?mscorlib?) > > clr.AddReference(?System?) > > to your program. Alternately you could modify pyc.py to send these two > strings in the references array to InitializeModule but that?s more > complex. I?ve filed a bug: > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20623 > Ahhh... that decision not to do this by default bites again. :-) Michael > > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Renaud Durand > *Sent:* Thursday, January 15, 2009 9:14 AM > *To:* users at lists.ironpython.com > *Subject:* [IronPython] Issues with System members when using pyc.py > > Hi, > > I'm new at IronPython and i'm trying to compile a small app using pyc.py. > When launched with the interpreter there's no issue. But when I launch > the executable I get this : > > > Unhandled Exception: System.MissingMemberException: 'namespace#' > object has no attribute 'DateTime' > > or this while importing pySerial : > > > Unhandled Exception: System.MissingMemberException: 'namespace#' > object has no attribute 'Array' > and > > Unhandled Exception: System.MissingMemberException: 'namespace#' > object has no attribute 'IO' > > Does someone have an idea ? Where am I wrong ? > > Thanks. > > -- > Renaud Durand > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 fuzzyman at voidspace.org.uk Thu Jan 15 20:54:41 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 15 Jan 2009 19:54:41 +0000 Subject: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 In-Reply-To: References: Message-ID: <496F9481.6050807@voidspace.org.uk> Slide wrote: > On Thu, Jan 15, 2009 at 9:51 AM, Dave Fugate wrote: > >> Some of you may have noticed that IronPython bugs on CodePlex previously >> assigned to the "2.1" release are now assigned to "2.6". We've simply >> renamed the 2.1 release of IronPython to 2.6 to reflect upon the fact that >> the next major release of IronPython will be largely compatible with CPython >> 2.6. All details about IP 2.1 that were previously discussed on Harry >> Pierson's blog (see >> http://devhawk.net/2008/07/17/IronPython+Post+20+Roadmap.aspx) still apply >> to IP 2.6. We're doing this simple name change to help eliminate confusion >> about IronPython's compatibility with various CPython and Jython releases. >> >> >> >> David Fugate >> >> Microsoft - IronPython >> >> > > > Personally, I think this is a great move! > +1 from me too. :-) Michael > Thanks, > > slide > _______________________________________________ > 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 kfarmer at thuban.org Fri Jan 16 04:22:46 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Thu, 15 Jan 2009 19:22:46 -0800 Subject: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 In-Reply-To: <496F9481.6050807@voidspace.org.uk> References: <496F9481.6050807@voidspace.org.uk> Message-ID: Hear hear.. I was hoping this would happen. Is it expected, then, that IP versioning will be something like .[..]? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Thursday, January 15, 2009 11:55 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 Slide wrote: > On Thu, Jan 15, 2009 at 9:51 AM, Dave Fugate wrote: > >> Some of you may have noticed that IronPython bugs on CodePlex previously >> assigned to the "2.1" release are now assigned to "2.6". We've simply >> renamed the 2.1 release of IronPython to 2.6 to reflect upon the fact that >> the next major release of IronPython will be largely compatible with CPython >> 2.6. All details about IP 2.1 that were previously discussed on Harry >> Pierson's blog (see >> http://devhawk.net/2008/07/17/IronPython+Post+20+Roadmap.aspx) still apply >> to IP 2.6. We're doing this simple name change to help eliminate confusion >> about IronPython's compatibility with various CPython and Jython releases. >> >> >> >> David Fugate >> >> Microsoft - IronPython >> >> > > > Personally, I think this is a great move! > +1 from me too. :-) Michael > Thanks, > > slide > _______________________________________________ > 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 neraun at gmail.com Fri Jan 16 10:05:10 2009 From: neraun at gmail.com (Renaud Durand) Date: Fri, 16 Jan 2009 10:05:10 +0100 Subject: [IronPython] Issues with System members when using pyc.py In-Reply-To: <496F9464.3070000@voidspace.org.uk> References: <8c5392700901150913u8c7a8a8j1d2c174a494b18d7@mail.gmail.com> <350E7D38B6D819428718949920EC23555704DFC392@NA-EXMSG-C102.redmond.corp.microsoft.com> <496F9464.3070000@voidspace.org.uk> Message-ID: <8c5392700901160105v4f36b1f9w6e6285f883ae92dc@mail.gmail.com> Thanks a lot. The mailing list is working much better than the issue-tracker on CodePlex. I won't hesitate to report other issues that I'll notice. I already have an idea... 2009/1/15 Michael Foord > Dino Viehland wrote: > >> >> This is a bug ? we're not adding references to mscorlib/System.dll when we >> run your app. You can just: >> >> import clr >> >> clr.AddReference('mscorlib') >> >> clr.AddReference('System') >> >> to your program. Alternately you could modify pyc.py to send these two >> strings in the references array to InitializeModule but that's more complex. >> I've filed a bug: >> http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20623 >> >> > Ahhh... that decision not to do this by default bites again. :-) > > Michael > >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Renaud Durand >> *Sent:* Thursday, January 15, 2009 9:14 AM >> *To:* users at lists.ironpython.com >> *Subject:* [IronPython] Issues with System members when using pyc.py >> >> Hi, >> >> I'm new at IronPython and i'm trying to compile a small app using pyc.py. >> When launched with the interpreter there's no issue. But when I launch the >> executable I get this : >> >> > Unhandled Exception: System.MissingMemberException: 'namespace#' object >> has no attribute 'DateTime' >> >> or this while importing pySerial : >> >> > Unhandled Exception: System.MissingMemberException: 'namespace#' object >> has no attribute 'Array' >> and >> > Unhandled Exception: System.MissingMemberException: 'namespace#' object >> has no attribute 'IO' >> >> Does someone have an idea ? Where am I wrong ? >> >> Thanks. >> >> -- >> Renaud Durand >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 > -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From stefanglimberg at gmail.com Fri Jan 16 10:58:10 2009 From: stefanglimberg at gmail.com (Stefan Glimberg) Date: Fri, 16 Jan 2009 10:58:10 +0100 Subject: [IronPython] Property information Message-ID: <92f42b610901160158g3d168e35j158f6fe6bb3d84f4@mail.gmail.com> Hello, I am creating a Silverlight application using C# and underlying python classes. In the C# code, I would like to access information about any methods defined in the python code. The python classes inherit from my own C# classes, but the only type information availible is from the C# class, not the python class. I get a python class inheriting my own 'Component' and its type like this: Compoenent c = ScriptEngine.GetVariable(Scope, mInstanceName); Type t = c.GetType(); Calling fx. t.GetMembers() only returns members from the C# Component calss, nothing from the python class. Is there any way to access the methods defined in the python class also? - Glimberg From renaud.durand.it at gmail.com Fri Jan 16 11:06:03 2009 From: renaud.durand.it at gmail.com (Renaud Durand) Date: Fri, 16 Jan 2009 11:06:03 +0100 Subject: [IronPython] os Module in programs compiled with pyc Message-ID: <8c5392700901160206o7cc7cc1bw618154fccf1fc576@mail.gmail.com> Hi all, I have several issues but I will respect the 1 problem/1 thread rule. My exe file is in a folder with all required DLLs. When I'm trying to import the os module I get this: > Unhandled Exception: IronPython.Runtime.Exceptions.ImportException: No module named os It works fine with other "Standard python library" modules like 'sys'. Are'nt all the modules in IronPython/Lib folder included in IronPython DLLs ? Currently I am using a workaround compiling the os module with my program and it works. Any idea ? Thanks. -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From orestis at resolversystems.com Fri Jan 16 11:19:29 2009 From: orestis at resolversystems.com (Orestis Markou) Date: Fri, 16 Jan 2009 10:19:29 +0000 Subject: [IronPython] os Module in programs compiled with pyc In-Reply-To: <8c5392700901160206o7cc7cc1bw618154fccf1fc576@mail.gmail.com> References: <8c5392700901160206o7cc7cc1bw618154fccf1fc576@mail.gmail.com> Message-ID: <49705F31.9050500@resolversystems.com> The sys module is special as it's built-in, whereas os is just a python module. Try importing other modules such as shutil or unittest to see if the plain standard library works. IronPython doesn't compile the standard library for you - it ships with it as normal python source, when installed from the msi. I thought that it would add its Lib to sys.path but I may be wrong. Try printing sys.path and see if there is any indication of this. Orestis Renaud Durand wrote: > Hi all, > > I have several issues but I will respect the 1 problem/1 thread rule. > > My exe file is in a folder with all required DLLs. When I'm trying to > import the os module I get this: > > > Unhandled Exception: IronPython.Runtime.Exceptions.ImportException: > No module named os > > It works fine with other "Standard python library" modules like 'sys'. > Are'nt all the modules in IronPython/Lib folder included in IronPython > DLLs ? > Currently I am using a workaround compiling the os module with my > program and it works. > > Any idea ? > > Thanks. > > -- > Renaud Durand > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Orestis Markou Software Engineer, Resolver Systems Ltd. orestis at resolversystems.com +44 (0) 20 7253 6372 From fuzzyman at voidspace.org.uk Fri Jan 16 11:24:00 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 16 Jan 2009 10:24:00 +0000 Subject: [IronPython] os Module in programs compiled with pyc In-Reply-To: <8c5392700901160206o7cc7cc1bw618154fccf1fc576@mail.gmail.com> References: <8c5392700901160206o7cc7cc1bw618154fccf1fc576@mail.gmail.com> Message-ID: <49706040.2060902@voidspace.org.uk> Renaud Durand wrote: > Hi all, > > I have several issues but I will respect the 1 problem/1 thread rule. > > My exe file is in a folder with all required DLLs. When I'm trying to > import the os module I get this: > > > Unhandled Exception: IronPython.Runtime.Exceptions.ImportException: > No module named os > > It works fine with other "Standard python library" modules like 'sys'. > Are'nt all the modules in IronPython/Lib folder included in IronPython > DLLs ? > Currently I am using a workaround compiling the os module with my > program and it works. > That's the correct solution not a workaround. Pyc doesn't compile standard library modules unless you tell it to. As Orestis says, sys is an oddity being a built-in module. Michael > Any idea ? > > Thanks. > > -- > Renaud Durand > ------------------------------------------------------------------------ > > _______________________________________________ > 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 curt at hagenlocher.org Fri Jan 16 16:53:23 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 16 Jan 2009 07:53:23 -0800 Subject: [IronPython] Property information In-Reply-To: <92f42b610901160158g3d168e35j158f6fe6bb3d84f4@mail.gmail.com> References: <92f42b610901160158g3d168e35j158f6fe6bb3d84f4@mail.gmail.com> Message-ID: There is no one-to-one correspondence between Python types and CLR types. In fact, there really can't be (at least in the default case) because their respective types work totally differently. You'll need to use the ObjectOperations API to access your Python methods: engine.Operations.GetMember(object, "methodname") will return a delegate to the method. engine.Operations.InvokeMember(object, "methodname", arg1, arg2, ...) will execute a method. On Fri, Jan 16, 2009 at 1:58 AM, Stefan Glimberg wrote: > Hello, > > I am creating a Silverlight application using C# and underlying python > classes. In the C# code, I would like to access information about any > methods defined in the python code. The python classes inherit from my > own C# classes, but the only type information availible is from the C# > class, not the python class. > I get a python class inheriting my own 'Component' and its type like this: > > Compoenent c = ScriptEngine.GetVariable(Scope, mInstanceName); > Type t = c.GetType(); > > Calling fx. t.GetMembers() only returns members from the C# Component > calss, nothing from the python class. > Is there any way to access the methods defined in the python class also? > > - Glimberg > _______________________________________________ > 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 stephen at theleengs.com Fri Jan 16 17:04:57 2009 From: stephen at theleengs.com (Stephen Ng) Date: Fri, 16 Jan 2009 08:04:57 -0800 Subject: [IronPython] Embedding Powershell and Write-Host In-Reply-To: References: <86122ad70901131558m542ed7bct32140c408c970cd8@mail.gmail.com> <86122ad70901131711p1e2feef1nb0aaf3273a61976f@mail.gmail.com> Message-ID: <86122ad70901160804o28f1095dr3c21b403fcbc9792@mail.gmail.com> My VC .NET is apparently too old to do this :-(. But then I realized that I could get close enough by: 1. moving the main loop of my program from Powershell to Python 2. Rewriting Write-Host to stuff strings into a global: $global_log_messages = '' function Write-Host($s) { Set-Variable -Name 'global_log_messages' -Value ($global_log_messages + ` "`n" + $s) -Scope global } 3. Periodically dumping the log messages from my IronPython code: VAR_LOG_MESSAGES = 'global_log_messages' def PrintLogMessages(session_state_proxy, logger=sys.stdout): logger.write(session_state_proxy.GetVariable(VAR_LOG_MESSAGES) + '\n') session_state_proxy.SetVariable(VAR_LOG_MESSAGES, '') Let me know if you see a better way.... Steve On Tue, Jan 13, 2009 at 5:35 PM, Curt Hagenlocher wrote: > Looking at the definitions of the C# classes in that blog entry and given > that you're hosting PowerShell inside of IronPython, I see no reason why you > wouldn't be able to implement the derived types in Python itself. But the > link seems to do a pretty good job of giving minimal implementations for > both classes. > > > On Tue, Jan 13, 2009 at 5:11 PM, Stephen Ng wrote: > >> Ouch, I guess I have to write some C#! >> There's no way to do this all in IronPython? >> >> Steve >> >> >> On Tue, Jan 13, 2009 at 4:06 PM, Curt Hagenlocher wrote: >> >>> You might find this link helpful. It was the second hit when googling >>> "implement pshost", and the author talks about integration between IronRuby >>> and PowerShell. >>> >>> http://bartdesmet.net/blogs/bart/archive/2008/07/06/windows-powershell-through-ironruby-writing-a-custom-pshost.aspx >>> >>> On Tue, Jan 13, 2009 at 3:58 PM, Stephen Ng wrote: >>> >>>> I'm using the following code to embed Powershell into IronPython. I >>>> hope to eventually replace almost all of my (large) Powershell script with >>>> IronPython. >>>> >>>> from System.Management.Automation.Runspaces import RunspaceFactory >>>> the_runspace = RunspaceFactory.CreateRunspace() >>>> the_runspace.Open() >>>> ri = RunspaceInvoke(the_runspace) >>>> out = ri.Invoke('. .\myscript.ps1') >>>> >>>> I'm able to pass variables back and forth using >>>> the_runspace.SessionStateProxy.Get/SetVariable, which is really cool. >>>> >>>> My problem is that any calls to Write-Host fail with "Cannot invoke this >>>> function becasue the current host does not implement it." Of course I can >>>> remove all the Write-Host's, but I really depend on them for status >>>> information about how my script is running, and not having access to console >>>> output makes my script much harder to debug. >>>> >>>> This post: http://decav.co >>>> m/blogs/andre/a >>>> rchive/2008/05/ >>>> 01/invoking-pow >>>> ershell-scripts >>>> -from-an-applic >>>> ation.aspx says >>>> "To get around this, you can remove *write-host* from your scripts and >>>> just have them write single lines, or you can implement a simple * >>>> PSHost* (although this is a bit harder than it sounds)." >>>> >>>> What does "just have them write single lines mean?" Any pointers on how >>>> I can get this working under IronPython? >>>> >>>> Thanks, >>>> >>>> Steve >>>> >>>> _______________________________________________ >>>> 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 dan.eloff at gmail.com Fri Jan 16 20:18:03 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Fri, 16 Jan 2009 14:18:03 -0500 Subject: [IronPython] Odd tracebacks In-Reply-To: <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> Message-ID: <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> This extraneous stack trace seems to happen on every exception. I've confirmed that it's an IronPython problem, not silverlight. It only ever consists of these two, and the debugger confirms that they aren't called on the error path. at pairwise in game/utils\functions.py, line 46 at __getattr__ in game\models\__init__.py, line 145 It's baffling. I tried again to make a repro, using duplicates of these two functions, in the same package structure, but failed. I'm going to try putting break points into the IronPython exception formatting code and running under the debugger later today. I'd really appreciate if I had some function names or places where I should put break points, because I have no idea. I'll have to dig through the IronPython code for hours to find appropriate places. Thanks, -Dan From dinov at microsoft.com Fri Jan 16 21:10:29 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 16 Jan 2009 12:10:29 -0800 Subject: [IronPython] Odd tracebacks In-Reply-To: <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704EC59A0@NA-EXMSG-C102.redmond.corp.microsoft.com> Good places to look would be: ExceptionHelpers.UpdateStackTrace is where the frame should be remembered PythonOps.CreateTraceBack should be where we actually pull the current set of frames for exceptions and build up the stack trace ScriptingRuntimeHelpers.GetDynamicStackFrames is where we actually figure out the frames associated with a particular exception. Those can come from either a thread static or the exception object it's self. I'd guess the bug is somehow related to the thread static (ExceptionHelpers.DynamicStackFrames) tracking extra frames and not being cleared at some appropriate time. I look forward to seeing what you find :) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff Sent: Friday, January 16, 2009 11:18 AM To: Discussion of IronPython Subject: Re: [IronPython] Odd tracebacks This extraneous stack trace seems to happen on every exception. I've confirmed that it's an IronPython problem, not silverlight. It only ever consists of these two, and the debugger confirms that they aren't called on the error path. at pairwise in game/utils\functions.py, line 46 at __getattr__ in game\models\__init__.py, line 145 It's baffling. I tried again to make a repro, using duplicates of these two functions, in the same package structure, but failed. I'm going to try putting break points into the IronPython exception formatting code and running under the debugger later today. I'd really appreciate if I had some function names or places where I should put break points, because I have no idea. I'll have to dig through the IronPython code for hours to find appropriate places. Thanks, -Dan _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Andreas.Rotaru at gmail.com Sat Jan 17 14:21:21 2009 From: Andreas.Rotaru at gmail.com (Rotaru) Date: Sat, 17 Jan 2009 05:21:21 -0800 (PST) Subject: [IronPython] Using WPF with IronPython Message-ID: <21516366.post@talk.nabble.com> Hallo, I created a anolog clock with WPF/XAML, which shows the current datetime. The clockhands are updated by a timer, which sends a new event for every second. Until now, everything worked fine. As next I put the whole clock design into a controltemplate, which allows it to use the clock as a button. Although this worked fine, the clockhands don't move anymore. I found out, that adding a DependencyProperty to the custom control will solve this problem. But the implementation of it doesn't seems to be that easy. Can somebody help me? I attached the Ironpython script to the message. Thanks in advance http://www.nabble.com/file/p21516366/Program.py Program.py -- View this message in context: http://www.nabble.com/Using-WPF-with-IronPython-tp21516366p21516366.html Sent from the IronPython mailing list archive at Nabble.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan.eloff at gmail.com Sat Jan 17 21:26:36 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Sat, 17 Jan 2009 15:26:36 -0500 Subject: [IronPython] Odd tracebacks In-Reply-To: <350E7D38B6D819428718949920EC23555704EC59A0@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> <350E7D38B6D819428718949920EC23555704EC59A0@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4817b6fc0901171226x31ac6600n878d81b2f0dbcf30@mail.gmail.com> Well it seems that certain code that is run with exec will create the bad frames which then gets attached to subsequent exceptions. It isn't related to the Microsoft.Scripting.Silverlight code, but it could still be silverlight specific. Actually I'm highly suspicious of the big block of code in GetDyanmicStackFrames that seems to be for filtering bad frames out, which is ifdefed out for silverlight. Do you remember why that part isn't used for silverlight? I'll keep digging and see if I find anything more concrete. Thanks, -Dan On Fri, Jan 16, 2009 at 3:10 PM, Dino Viehland wrote: > Good places to look would be: > ExceptionHelpers.UpdateStackTrace is where the frame should be remembered > PythonOps.CreateTraceBack should be where we actually pull the current set of frames for exceptions and build up the stack trace > ScriptingRuntimeHelpers.GetDynamicStackFrames is where we actually figure out the frames associated with a particular exception. Those can come from either a thread static or the exception object it's self. > > I'd guess the bug is somehow related to the thread static (ExceptionHelpers.DynamicStackFrames) tracking extra frames and not being cleared at some appropriate time. I look forward to seeing what you find :) > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff > Sent: Friday, January 16, 2009 11:18 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Odd tracebacks > > This extraneous stack trace seems to happen on every exception. I've > confirmed that it's an IronPython problem, not silverlight. It only > ever consists of these two, and the debugger confirms that they aren't > called on the error path. > > at pairwise in game/utils\functions.py, line 46 > at __getattr__ in game\models\__init__.py, line 145 > > It's baffling. I tried again to make a repro, using duplicates of > these two functions, in the same package structure, but failed. I'm > going to try putting break points into the IronPython exception > formatting code and running under the debugger later today. I'd really > appreciate if I had some function names or places where I should put > break points, because I have no idea. I'll have to dig through the > IronPython code for hours to find appropriate places. > > Thanks, > -Dan > _______________________________________________ > 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 fuzzyman at voidspace.org.uk Sat Jan 17 21:28:50 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 17 Jan 2009 20:28:50 +0000 Subject: [IronPython] Odd tracebacks In-Reply-To: <4817b6fc0901171226x31ac6600n878d81b2f0dbcf30@mail.gmail.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> <350E7D38B6D819428718949920EC23555704EC59A0@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901171226x31ac6600n878d81b2f0dbcf30@mail.gmail.com> Message-ID: <49723F82.2020907@voidspace.org.uk> Dan Eloff wrote: > Well it seems that certain code that is run with exec will create the > bad frames which then gets attached to subsequent exceptions. It isn't > related to the Microsoft.Scripting.Silverlight code, but it could > still be silverlight specific. Actually I'm highly suspicious of the > big block of code in GetDyanmicStackFrames that seems to be for > filtering bad frames out, which is ifdefed out for silverlight. Do you > remember why that part isn't used for silverlight? I'll keep digging > and see if I find anything more concrete. > FWIW (which may not be much) we used to see a very similar problem in IronPython 1. We fixed it by adding an explicit sys.exc_clear whenever we handled exceptions and needed a reliable traceback. Michael > Thanks, > -Dan > > On Fri, Jan 16, 2009 at 3:10 PM, Dino Viehland wrote: > >> Good places to look would be: >> ExceptionHelpers.UpdateStackTrace is where the frame should be remembered >> PythonOps.CreateTraceBack should be where we actually pull the current set of frames for exceptions and build up the stack trace >> ScriptingRuntimeHelpers.GetDynamicStackFrames is where we actually figure out the frames associated with a particular exception. Those can come from either a thread static or the exception object it's self. >> >> I'd guess the bug is somehow related to the thread static (ExceptionHelpers.DynamicStackFrames) tracking extra frames and not being cleared at some appropriate time. I look forward to seeing what you find :) >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff >> Sent: Friday, January 16, 2009 11:18 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] Odd tracebacks >> >> This extraneous stack trace seems to happen on every exception. I've >> confirmed that it's an IronPython problem, not silverlight. It only >> ever consists of these two, and the debugger confirms that they aren't >> called on the error path. >> >> at pairwise in game/utils\functions.py, line 46 >> at __getattr__ in game\models\__init__.py, line 145 >> >> It's baffling. I tried again to make a repro, using duplicates of >> these two functions, in the same package structure, but failed. I'm >> going to try putting break points into the IronPython exception >> formatting code and running under the debugger later today. I'd really >> appreciate if I had some function names or places where I should put >> break points, because I have no idea. I'll have to dig through the >> IronPython code for hours to find appropriate places. >> >> Thanks, >> -Dan >> _______________________________________________ >> 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 > -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From dinov at microsoft.com Sat Jan 17 21:42:21 2009 From: dinov at microsoft.com (Dino Viehland) Date: Sat, 17 Jan 2009 12:42:21 -0800 Subject: [IronPython] Odd tracebacks In-Reply-To: <4817b6fc0901171226x31ac6600n878d81b2f0dbcf30@mail.gmail.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> <350E7D38B6D819428718949920EC23555704EC59A0@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901171226x31ac6600n878d81b2f0dbcf30@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704EC5BE2@NA-EXMSG-C102.redmond.corp.microsoft.com> I think it is because new StackTrace(exception) requires or required trust at one point in time (same reason for the catch of MemberAccessException). Looking at mscorlib now it would seem that StackTrace(e) is now SecuritySafeCritical so I think we should be able to enable that code for Silverlight as well. > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Dan Eloff > Sent: Saturday, January 17, 2009 12:27 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Odd tracebacks > > Well it seems that certain code that is run with exec will create the > bad frames which then gets attached to subsequent exceptions. It isn't > related to the Microsoft.Scripting.Silverlight code, but it could > still be silverlight specific. Actually I'm highly suspicious of the > big block of code in GetDyanmicStackFrames that seems to be for > filtering bad frames out, which is ifdefed out for silverlight. Do you > remember why that part isn't used for silverlight? I'll keep digging > and see if I find anything more concrete. > > Thanks, > -Dan > > On Fri, Jan 16, 2009 at 3:10 PM, Dino Viehland > wrote: > > Good places to look would be: > > ExceptionHelpers.UpdateStackTrace is where the frame should be > remembered > > PythonOps.CreateTraceBack should be where we actually pull the > current set of frames for exceptions and build up the stack trace > > ScriptingRuntimeHelpers.GetDynamicStackFrames is where we > actually figure out the frames associated with a particular exception. > Those can come from either a thread static or the exception object it's > self. > > > > I'd guess the bug is somehow related to the thread static > (ExceptionHelpers.DynamicStackFrames) tracking extra frames and not > being cleared at some appropriate time. I look forward to seeing what > you find :) > > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Dan Eloff > > Sent: Friday, January 16, 2009 11:18 AM > > To: Discussion of IronPython > > Subject: Re: [IronPython] Odd tracebacks > > > > This extraneous stack trace seems to happen on every exception. I've > > confirmed that it's an IronPython problem, not silverlight. It only > > ever consists of these two, and the debugger confirms that they > aren't > > called on the error path. > > > > at pairwise in game/utils\functions.py, line 46 > > at __getattr__ in game\models\__init__.py, line 145 > > > > It's baffling. I tried again to make a repro, using duplicates of > > these two functions, in the same package structure, but failed. I'm > > going to try putting break points into the IronPython exception > > formatting code and running under the debugger later today. I'd > really > > appreciate if I had some function names or places where I should put > > break points, because I have no idea. I'll have to dig through the > > IronPython code for hours to find appropriate places. > > > > Thanks, > > -Dan > > _______________________________________________ > > 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 dan.eloff at gmail.com Sun Jan 18 07:00:25 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Sun, 18 Jan 2009 01:00:25 -0500 Subject: [IronPython] Odd tracebacks In-Reply-To: <350E7D38B6D819428718949920EC23555704EC5BE2@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <4817b6fc0901011118vb55577dx7ed8b4f98f68e54f@mail.gmail.com> <350E7D38B6D819428718949920EC235557046B6C0D@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901050912l6ead9923n8265114abb71b8e7@mail.gmail.com> <4817b6fc0901161118n407238fbifdfc241e90cfbe3f@mail.gmail.com> <350E7D38B6D819428718949920EC23555704EC59A0@NA-EXMSG-C102.redmond.corp.microsoft.com> <4817b6fc0901171226x31ac6600n878d81b2f0dbcf30@mail.gmail.com> <350E7D38B6D819428718949920EC23555704EC5BE2@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4817b6fc0901172200t7900075bqa8dec19f4280fdbf@mail.gmail.com> On Sat, Jan 17, 2009 at 3:42 PM, Dino Viehland wrote: > I think it is because new StackTrace(exception) requires or required trust at one point in time (same reason for the catch of MemberAccessException). > > Looking at mscorlib now it would seem that StackTrace(e) is now SecuritySafeCritical so I think we should be able to enable that code for Silverlight as well. > Looks like my hunch is correct, I commented out the #if !SILVERLIGHT part of GetDynamicStackFrames, and the problem goes away. I also removed the try/catch as you pointed out. Thanks for the tips, it wouldn't have been easy without knowing what to look for and where to look for it. Cheers, -Dan From sh at defuze.org Sun Jan 18 11:43:31 2009 From: sh at defuze.org (Sylvain Hellegouarch) Date: Sun, 18 Jan 2009 11:43:31 +0100 Subject: [IronPython] Compiling IP2 on mono Message-ID: <497307D3.6050403@defuze.org> Hi folks, I've tried following Seo's steps [1] for compiling IP2 on the current mono trunk but it keeps failing with the next error: sylvain at localhost:~/download/IronPython-2.0/Src$ nant NAnt 0.86 (Build 0.86.2898.0; beta1; 08/12/2007) Copyright (C) 2001-2007 Gerry Shaw http://nant.sourceforge.net Buildfile: file:///home/sylvain/download/IronPython-2.0/Src/IronPython.build Target framework: Mono 2.0 Profile [csc] Compiling 200 files to '/home/sylvain/download/IronPython-2.0/Src/Microsoft.Scripting.Core.dll'. [csc] /home/sylvain/download/IronPython-2.0/Src/Microsoft.Scripting.Core/Actions/MetaObjectExtensions.cs(20,27): error CS0234: The type or namespace name `Generation' does not exist in the namespace `Microsoft.Scripting'. Are you missing an assembly reference? [csc] /home/sylvain/download/IronPython-2.0/Src/Microsoft.Scripting.Core/Actions/MetaObjectExtensions.cs(20,27): error CS0234: The type or namespace name `Generation' does not exist in the namespace `Microsoft.Scripting'. Are you missing an assembly reference? [csc] Compilation failed: 2 error(s), 0 warnings BUILD FAILED - 0 non-fatal error(s), 2 warning(s) /home/sylvain/download/IronPython-2.0/Src/IronPython.build(3,6): External Program Failed: /usr/local/lib/mono/2.0/gmcs.exe (return code was 1) Total time: 1.2 seconds Has anyone got an idea? Cheers, - Sylvain [1] http://www.nabble.com/IronPython-2.0-RC-2-on-Mono-td20889619.html From sanxiyn at gmail.com Mon Jan 19 01:11:06 2009 From: sanxiyn at gmail.com (Seo Sanghyeon) Date: Mon, 19 Jan 2009 09:11:06 +0900 Subject: [IronPython] Compiling IP2 on mono In-Reply-To: <497307D3.6050403@defuze.org> References: <497307D3.6050403@defuze.org> Message-ID: <5b0248170901181611u74c5b4bpe85073b328aa3184@mail.gmail.com> 2009/1/18 Sylvain Hellegouarch : > Hi folks, > > I've tried following Seo's steps [1] for compiling IP2 on the current mono > trunk but it keeps failing with the next error: > > sylvain at localhost:~/download/IronPython-2.0/Src$ nant > NAnt 0.86 (Build 0.86.2898.0; beta1; 08/12/2007) > Copyright (C) 2001-2007 Gerry Shaw > http://nant.sourceforge.net > > Buildfile: file:///home/sylvain/download/IronPython-2.0/Src/IronPython.build > Target framework: Mono 2.0 Profile > > [csc] Compiling 200 files to > '/home/sylvain/download/IronPython-2.0/Src/Microsoft.Scripting.Core.dll'. > [csc] > /home/sylvain/download/IronPython-2.0/Src/Microsoft.Scripting.Core/Actions/MetaObjectExtensions.cs(20,27): > error CS0234: The type or namespace name `Generation' does not exist in the > namespace `Microsoft.Scripting'. Are you missing an assembly reference? > [csc] > /home/sylvain/download/IronPython-2.0/Src/Microsoft.Scripting.Core/Actions/MetaObjectExtensions.cs(20,27): > error CS0234: The type or namespace name `Generation' does not exist in the > namespace `Microsoft.Scripting'. Are you missing an assembly reference? > [csc] Compilation failed: 2 error(s), 0 warnings Did you apply patch-exthack? That should get rid of this namespace import. -- Seo Sanghyeon From tno at vizrt.com Mon Jan 19 14:55:46 2009 From: tno at vizrt.com (TommyN) Date: Mon, 19 Jan 2009 05:55:46 -0800 (PST) Subject: [IronPython] Stop script execution/unload script Message-ID: <21542133.post@talk.nabble.com> Hi, I've been testing using IronPython as an embedded script language in a small C# application. I have added some code to a winform buttons Click event with code like this: def hello(s, e): MessageBox.Show('Clicked ' + s.Name) Button1.Click += hello; This works fine, but the problem is that if I modify the script code at run-time and call: source.Engine.Runtime.Shutdown(); source = engine.CreateScriptSourceFromString(....); .. source.Execute(..) I suddenly have 2 scripts running at the same time, and the messagebox is displayed twice. How should I go about properly stopping/unloading the first instance of the script so only the latest script will be executed? Any pointers would be greatly appreciated! -Tommy -- View this message in context: http://www.nabble.com/Stop-script-execution-unload-script-tp21542133p21542133.html Sent from the IronPython mailing list archive at Nabble.com. From curt at hagenlocher.org Mon Jan 19 15:22:11 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Mon, 19 Jan 2009 06:22:11 -0800 Subject: [IronPython] Stop script execution/unload script In-Reply-To: <21542133.post@talk.nabble.com> References: <21542133.post@talk.nabble.com> Message-ID: Your intuition that you're running a kind of script that can be stopped is leading you astray. :) When you program in IronPython, it's very much like programming in C# -- the objects you create will stay alive until they are garbage collected or the program ends. So to unhook the delegate from the event, you need to do the same thing from IronPython that you would have done from C#: Button1.Click -= hello. I believe that Runtime.Shutdown() will call any "atexit" methods you defined from Python, so you can use this to perform cleanup. On Mon, Jan 19, 2009 at 5:55 AM, TommyN wrote: > > Hi, > > I've been testing using IronPython as an embedded script language in a > small > C# application. I have added some code to a winform buttons Click event > with > code like this: > > def hello(s, e): > MessageBox.Show('Clicked ' + s.Name) > Button1.Click += hello; > > > This works fine, but the problem is that if I modify the script code at > run-time and call: > > source.Engine.Runtime.Shutdown(); > source = engine.CreateScriptSourceFromString(....); > .. > source.Execute(..) > > I suddenly have 2 scripts running at the same time, and the messagebox is > displayed twice. > How should I go about properly stopping/unloading the first instance of the > script so only the latest script will be executed? > > Any pointers would be greatly appreciated! > -Tommy > > -- > View this message in context: > http://www.nabble.com/Stop-script-execution-unload-script-tp21542133p21542133.html > Sent from the IronPython mailing list archive at Nabble.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 caglartoklu at gmail.com Mon Jan 19 22:32:22 2009 From: caglartoklu at gmail.com (Caglar Toklu) Date: Mon, 19 Jan 2009 13:32:22 -0800 (PST) Subject: [IronPython] App.config file if there are more than one program instance Message-ID: <21545853.post@talk.nabble.com> Hi to all, We are developing our product depending on another DLL acting as Database Layer. I have searched this forum and found the following posts: http://www.nabble.com/-IronPython--Application.config-td14159166.html#a14159166 http://www.nabble.com/app.config-for-ipy-script--td20756955.html#a20756955 They are both fine, and they suggest that placing an ipy.exe.config file next to ipy.exe. I have tried it and it worked fine. But, I have more than one application running on the same computer, and I need to have two different config files for them. So I have come up with the following solution [candidate] : Distributing an IronPython binary distribution [IronPython-2.0-Bin.zip] with each of them and calling the interpreter assigned to them. In this case, I can have two different (or as many as required) IronPython instances running in different directories with proper ipy.exe.config files. But, now I am stuck that IronPython could not find the modules such as ConfigParser and os. Is there a way to overcome this problem. Any help or ideas are appreciated, thank you in advance. Caglar Toklu -- View this message in context: http://www.nabble.com/App.config-file-if-there-are-more-than-one-program-instance-tp21545853p21545853.html Sent from the IronPython mailing list archive at Nabble.com. From dinov at microsoft.com Mon Jan 19 22:33:14 2009 From: dinov at microsoft.com (Dino Viehland) Date: Mon, 19 Jan 2009 13:33:14 -0800 Subject: [IronPython] Stop script execution/unload script In-Reply-To: References: <21542133.post@talk.nabble.com> Message-ID: <350E7D38B6D819428718949920EC23555704EC5F50@NA-EXMSG-C102.redmond.corp.microsoft.com> An alternate plan would be to run your script in another app domain. Then you can just unload the app domain and all shared state will be cleared. The hosting APIs make this pretty easy to do as well. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Monday, January 19, 2009 6:22 AM To: Discussion of IronPython Subject: Re: [IronPython] Stop script execution/unload script Your intuition that you're running a kind of script that can be stopped is leading you astray. :) When you program in IronPython, it's very much like programming in C# -- the objects you create will stay alive until they are garbage collected or the program ends. So to unhook the delegate from the event, you need to do the same thing from IronPython that you would have done from C#: Button1.Click -= hello. I believe that Runtime.Shutdown() will call any "atexit" methods you defined from Python, so you can use this to perform cleanup. On Mon, Jan 19, 2009 at 5:55 AM, TommyN > wrote: Hi, I've been testing using IronPython as an embedded script language in a small C# application. I have added some code to a winform buttons Click event with code like this: def hello(s, e): MessageBox.Show('Clicked ' + s.Name) Button1.Click += hello; This works fine, but the problem is that if I modify the script code at run-time and call: source.Engine.Runtime.Shutdown(); source = engine.CreateScriptSourceFromString(....); .. source.Execute(..) I suddenly have 2 scripts running at the same time, and the messagebox is displayed twice. How should I go about properly stopping/unloading the first instance of the script so only the latest script will be executed? Any pointers would be greatly appreciated! -Tommy -- View this message in context: http://www.nabble.com/Stop-script-execution-unload-script-tp21542133p21542133.html Sent from the IronPython mailing list archive at Nabble.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 Mon Jan 19 22:34:39 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 19 Jan 2009 21:34:39 +0000 Subject: [IronPython] App.config file if there are more than one program instance In-Reply-To: <21545853.post@talk.nabble.com> References: <21545853.post@talk.nabble.com> Message-ID: <4974F1EF.302@voidspace.org.uk> Caglar Toklu wrote: > Hi to all, > > We are developing our product depending on another DLL acting as Database > Layer. I have searched this forum and found the following posts: > > http://www.nabble.com/-IronPython--Application.config-td14159166.html#a14159166 > http://www.nabble.com/app.config-for-ipy-script--td20756955.html#a20756955 > > They are both fine, and they suggest that placing an ipy.exe.config file > next to ipy.exe. I have tried it and it worked fine. But, I have more than > one application running on the same computer, and I need to have two > different config files for them. > > So I have come up with the following solution [candidate] : Distributing an > IronPython binary distribution [IronPython-2.0-Bin.zip] with each of them > and calling the interpreter assigned to them. In this case, I can have two > different (or as many as required) IronPython instances running in different > directories with proper ipy.exe.config files. But, now I am stuck that > IronPython could not find the modules such as ConfigParser and os. Is there > a way to overcome this problem. > > Any help or ideas are appreciated, thank you in advance. > > Caglar Toklu > > Creating a custom executable that sets up sys.path and runs your script (using the IP hosting API) is basically trivial. That way you have your own exe to create the manifest for. (You could even use the Pyc compiler to do this.) Alternatively your entry Python script could manually add to sys.path as the first thing it does - so that your imports work. All the best, Michael Foord -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From caglartoklu at gmail.com Mon Jan 19 23:14:16 2009 From: caglartoklu at gmail.com (Caglar Toklu) Date: Tue, 20 Jan 2009 00:14:16 +0200 Subject: [IronPython] App.config file if there are more than one program instance In-Reply-To: <4974F1EF.302@voidspace.org.uk> References: <21545853.post@talk.nabble.com> <4974F1EF.302@voidspace.org.uk> Message-ID: Hi Michael, I have just applied the second solution of yours and it worked perfectly. My entry script is adding the paths. (I have installed an IronPython instance using the MSI installer so that I have the libraries.) Then in another directory, say C:\\MyApp1, my entry script does the following: import sys sys.path.append('C:\\Program Files\\IronPython 2.0\\Lib') sys.path.append('C:\\Program Files\\IronPython 2.0') sys.path.append('C:\\Program Files\\IronPython 2.0\\lib\\site-packages') ..... ..... Also, I have placed an binary IronPython distibution in C:\\MyApp1 which includes an ipy.exe and an ipy.exe.config file with only settings for App1. By this way I can have as many IronPython applications running on the same computer with different application configuration files. Thank you very much for your answer, it is very appreciated. Best regards, Caglar Toklu On Mon, Jan 19, 2009 at 11:34 PM, Michael Foord wrote: > Creating a custom executable that sets up sys.path and runs your script > (using the IP hosting API) is basically trivial. That way you have your own > exe to create the manifest for. (You could even use the Pyc compiler to do > this.) > > Alternatively your entry Python script could manually add to sys.path as the > first thing it does - so that your imports work. > > All the best, > > Michael Foord > > -- > 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 fuzzyman at voidspace.org.uk Tue Jan 20 13:45:14 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 20 Jan 2009 12:45:14 +0000 Subject: [IronPython] IronPython, stack frames and pdb Message-ID: <4975C75A.8030103@voidspace.org.uk> Hello Dino, Curt et al., If stack frames are implemented as an option in IronPython it would be *really* nice to enable sys.set_trace when they are on. Plus any other APIs not currently implemented that are needed by pdb. Doing CPython development again I've been reminded how insanely useful pdb is. :-) What would be really nice is to enable stack frames on a per engine / runtime basis so that we could allow the setting of break-points and debugging of Resolver One user code. Michael -- http://www.ironpythoninaction.com/ From dblank at brynmawr.edu Tue Jan 20 14:00:13 2009 From: dblank at brynmawr.edu (Douglas Blank) Date: Tue, 20 Jan 2009 08:00:13 -0500 (EST) Subject: [IronPython] IronPython, stack frames and pdb In-Reply-To: <4975C75A.8030103@voidspace.org.uk> Message-ID: <1757830888.1859601232456413526.JavaMail.root@ganesh.brynmawr.edu> ----- Michael Foord wrote: > Hello Dino, Curt et al., > > If stack frames are implemented as an option in IronPython it would be > *really* nice to enable sys.set_trace when they are on. Plus any other > APIs not currently implemented that are needed by pdb. Doing CPython > development again I've been reminded how insanely useful pdb is. :-) > > What would be really nice is to enable stack frames on a per engine / > runtime basis so that we could allow the setting of break-points and > debugging of Resolver One user code. 1++ This would be excellent! I also wonder if there is an trace API that could be shared with other languages, and worked into the DLR? This would be very nice for our educational infrastructure we are building. -Doug > Michael From dan.eloff at gmail.com Tue Jan 20 15:56:27 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Tue, 20 Jan 2009 09:56:27 -0500 Subject: [IronPython] IronPython, stack frames and pdb In-Reply-To: <4975C75A.8030103@voidspace.org.uk> References: <4975C75A.8030103@voidspace.org.uk> Message-ID: <4817b6fc0901200656i27c032adp879845c743b24410@mail.gmail.com> That would be absolutely awesome. On Tue, Jan 20, 2009 at 7:45 AM, Michael Foord wrote: > Hello Dino, Curt et al., > > If stack frames are implemented as an option in IronPython it would be > *really* nice to enable sys.set_trace when they are on. Plus any other APIs > not currently implemented that are needed by pdb. Doing CPython development > again I've been reminded how insanely useful pdb is. :-) > > What would be really nice is to enable stack frames on a per engine / > runtime basis so that we could allow the setting of break-points and > debugging of Resolver One user code. > > Michael > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From renaud.durand.it at gmail.com Tue Jan 20 16:32:48 2009 From: renaud.durand.it at gmail.com (Renaud Durand) Date: Tue, 20 Jan 2009 16:32:48 +0100 Subject: [IronPython] Embedding IronPython 2.0 Message-ID: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> Hi, I want to use IronPython function through C#. To do It, I found a tutorial at http://www.ironpython.info/index.php/Hosting_IronPython_2. But the code does not seem to be updated for IronPython 2.0. the code is : using System; using IronPython.Hosting; using IronPython.Runtime; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; namespace EmbeddedCalculator { public class Engine { private ScriptEngine engine; public Engine() { engine = PythonEngine.CurrentEngine; } public string calculate(string input) { try { ScriptSource source = engine.CreateScriptSourceFromString(input, "py"); return source.Execute().ToString(); } catch { return "Error"; } } } } // End of code When I try to compile it in visual studio, the compiler could not find the name "PythonEngine". I have added all the references to the needed libraries. So, what am I missing ? Thank you :-). -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Tue Jan 20 16:41:42 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 20 Jan 2009 07:41:42 -0800 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> Message-ID: I believe this was valid for a long-ago alpha. For the 2.0 release, you'll want to create an engine by sayingengine = Python.CreateEngine() On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand wrote: > Hi, > > I want to use IronPython function through C#. To do It, I found a tutorial > at http://www.ironpython.info/index.php/Hosting_IronPython_2. > But the code does not seem to be updated for IronPython 2.0. > > the code is : > > using System; > using IronPython.Hosting; > using IronPython.Runtime; > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > namespace EmbeddedCalculator > { > public class Engine > { > private ScriptEngine engine; > > public Engine() > { > engine = PythonEngine.CurrentEngine; > } > > public string calculate(string input) > { > try > { > ScriptSource source = > engine.CreateScriptSourceFromString(input, "py"); > return source.Execute().ToString(); > } > catch > { > return "Error"; > } > } > > } > } > // End of code > > When I try to compile it in visual studio, the compiler could not find the > name "PythonEngine". I have added all the references to > the needed libraries. So, what am I missing ? > > > Thank you :-). > > -- > Renaud Durand > > _______________________________________________ > 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 neraun at gmail.com Tue Jan 20 17:04:14 2009 From: neraun at gmail.com (Renaud Durand) Date: Tue, 20 Jan 2009 17:04:14 +0100 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> Message-ID: <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> Ok, Thank you. Does anyone know where could I find an IronPython Assembly documentation and/or up to date tutorials ? Thank you again. 2009/1/20 Curt Hagenlocher > I believe this was valid for a long-ago alpha. For the 2.0 release, you'll > want to create an engine by saying engine = Python.CreateEngine() > > On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand > wrote: > >> Hi, >> >> I want to use IronPython function through C#. To do It, I found a tutorial >> at http://www.ironpython.info/index.php/Hosting_IronPython_2. >> But the code does not seem to be updated for IronPython 2.0. >> >> the code is : >> >> using System; >> using IronPython.Hosting; >> using IronPython.Runtime; >> using Microsoft.Scripting; >> using Microsoft.Scripting.Hosting; >> >> namespace EmbeddedCalculator >> { >> public class Engine >> { >> private ScriptEngine engine; >> >> public Engine() >> { >> engine = PythonEngine.CurrentEngine; >> } >> >> public string calculate(string input) >> { >> try >> { >> ScriptSource source = >> engine.CreateScriptSourceFromString(input, "py"); >> return source.Execute().ToString(); >> } >> catch >> { >> return "Error"; >> } >> } >> >> } >> } >> // End of code >> >> When I try to compile it in visual studio, the compiler could not find the >> name "PythonEngine". I have added all the references to >> the needed libraries. So, what am I missing ? >> >> >> Thank you :-). >> >> -- >> Renaud Durand >> >> _______________________________________________ >> 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 > > -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Tue Jan 20 17:37:39 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 20 Jan 2009 16:37:39 +0000 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> Message-ID: <4975FDD3.1040501@voidspace.org.uk> Renaud Durand wrote: > Ok, Thank you. > > Does anyone know where could I find an IronPython Assembly > documentation and/or up to date tutorials ? These tutorials are up to date - except for the one specified as being for IP1: http://www.voidspace.org.uk/ironpython/embedding.shtml Michael > > Thank you again. > > 2009/1/20 Curt Hagenlocher > > > I believe this was valid for a long-ago alpha. For the 2.0 > release, you'll want to create an engine by saying > engine = Python.CreateEngine() > > On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand @gmail.com > wrote: > > Hi, > > I want to use IronPython function through C#. To do It, I > found a tutorial at > http://www.ironpython.info/index.php/Hosting_IronPython_2. > But the code does not seem to be updated for IronPython 2.0. > > the code is : > > using System; > using IronPython.Hosting; > using IronPython.Runtime; > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > namespace EmbeddedCalculator > { > public class Engine > { > private ScriptEngine engine; > > public Engine() > { > engine = PythonEngine.CurrentEngine; > } > > public string calculate(string input) > { > try > { > ScriptSource source = > engine.CreateScriptSourceFromString(input, "py"); > return source.Execute().ToString(); > } > catch > { > return "Error"; > } > } > > } > } > // End of code > > When I try to compile it in visual studio, the compiler could > not find the name "PythonEngine". I have added all the > references to > the needed libraries. So, what am I missing ? > > > Thank you :-). > > -- > Renaud Durand > > _______________________________________________ > 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 > > > > > -- > Renaud Durand > ------------------------------------------------------------------------ > > _______________________________________________ > 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 dan.eloff at gmail.com Tue Jan 20 18:38:34 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Tue, 20 Jan 2009 12:38:34 -0500 Subject: [IronPython] On the topic of exceptions and tracebacks Message-ID: <4817b6fc0901200938y631310b3x91b1c5f47cffbae@mail.gmail.com> Has anyone experienced something like this before? I'm wondering if it's not as narrow in scope as I originally thought. http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=19821 -Dan From dfugate at microsoft.com Tue Jan 20 22:04:57 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Tue, 20 Jan 2009 13:04:57 -0800 Subject: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 In-Reply-To: References: <496F9481.6050807@voidspace.org.uk> Message-ID: The assembly versioning plan isn't quite set in stone, but does indeed look similar to what you mention. will correspond to the patch level of the IronPython release (e.g., it would be "1" for IronPython 2.0.1) and from you'll be able to immediately tell if the release is an Alpha, Beta, or alternatively the date when a release candidate or final version was produced. Dave -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Keith J. Farmer Sent: Thursday, January 15, 2009 7:23 PM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 Hear hear.. I was hoping this would happen. Is it expected, then, that IP versioning will be something like .[..]? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Thursday, January 15, 2009 11:55 AM To: Discussion of IronPython Subject: Re: [IronPython] IronPython 2.1 Renamed to IronPython 2.6 Slide wrote: > On Thu, Jan 15, 2009 at 9:51 AM, Dave Fugate wrote: > >> Some of you may have noticed that IronPython bugs on CodePlex previously >> assigned to the "2.1" release are now assigned to "2.6". We've simply >> renamed the 2.1 release of IronPython to 2.6 to reflect upon the fact that >> the next major release of IronPython will be largely compatible with CPython >> 2.6. All details about IP 2.1 that were previously discussed on Harry >> Pierson's blog (see >> http://devhawk.net/2008/07/17/IronPython+Post+20+Roadmap.aspx) still apply >> to IP 2.6. We're doing this simple name change to help eliminate confusion >> about IronPython's compatibility with various CPython and Jython releases. >> >> >> >> David Fugate >> >> Microsoft - IronPython >> >> > > > Personally, I think this is a great move! > +1 from me too. :-) Michael > Thanks, > > slide > _______________________________________________ > 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 _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From brafales at tango04.net Wed Jan 21 14:24:36 2009 From: brafales at tango04.net (=?ISO-8859-1?Q?Bernat_R=E0fales_Mulet?=) Date: Wed, 21 Jan 2009 14:24:36 +0100 Subject: [IronPython] cannot access protected member without a python subclass Message-ID: <49772214.9010304@tango04.net> Hello, I'm trying to add scripting to an existing application in C#. My approach is to provide some Wrapper classes, that are instantiated and then passed to a python engine scope via the SetVariable method of the scope class. The problem is that one of those wrappers has a public property with the get and set methods, but when I try to access the property in the Python Script I get this error: cannot access protected member ElementID without a python subclass of Serie. The Serie class is simple: using System; using System.Collections.Generic; using System.Text; namespace Tango04.DashBoard.Scripting.Wrappers { class Serie { public string Name { get; set; } public string ElementID { get; set; } } } The Python code I use is as simple as this: ShowSerie = Serie.ElementID != 'somestring' I instantiate a Serie object, fill it with the data, and then pass it as a variable to the script. Anyone knows what I'm doing wrong? Thanks! -------------- next part -------------- A non-text attachment was scrubbed... Name: brafales.vcf Type: text/x-vcard Size: 351 bytes Desc: not available URL: From Marty.Nelson at symyx.com Wed Jan 21 15:30:29 2009 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Wed, 21 Jan 2009 06:30:29 -0800 Subject: [IronPython] cannot access protected member without a pythonsubclass In-Reply-To: <49772214.9010304@tango04.net> References: <49772214.9010304@tango04.net> Message-ID: <515335F32AA04440B3DE6FEA1993E9AD03E14DF4@srv-be-101.Symyx-IC.symyx.com> Your class is internal, do you mean "public class Serie"? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Bernat R?fales Mulet Sent: Wednesday, January 21, 2009 5:25 AM To: users at lists.ironpython.com Subject: [IronPython] cannot access protected member without a pythonsubclass Hello, I'm trying to add scripting to an existing application in C#. My approach is to provide some Wrapper classes, that are instantiated and then passed to a python engine scope via the SetVariable method of the scope class. The problem is that one of those wrappers has a public property with the get and set methods, but when I try to access the property in the Python Script I get this error: cannot access protected member ElementID without a python subclass of Serie. The Serie class is simple: using System; using System.Collections.Generic; using System.Text; namespace Tango04.DashBoard.Scripting.Wrappers { class Serie { public string Name { get; set; } public string ElementID { get; set; } } } The Python code I use is as simple as this: ShowSerie = Serie.ElementID != 'somestring' I instantiate a Serie object, fill it with the data, and then pass it as a variable to the script. Anyone knows what I'm doing wrong? Thanks! ======= Notice: This e-mail message, together with any attachments, contains information of Symyx Technologies, Inc. or any of its affiliates or subsidiaries that may be confidential, proprietary, copyrighted, privileged and/or protected work product, and is meant solely for the intended recipient. If you are not the intended recipient, and have received this message in error, please contact the sender immediately, permanently delete the original and any copies of this email and any attachments thereto. From brafales at tango04.net Wed Jan 21 16:01:46 2009 From: brafales at tango04.net (=?ISO-8859-1?Q?Bernat_R=E0fales_Mulet?=) Date: Wed, 21 Jan 2009 16:01:46 +0100 Subject: [IronPython] cannot access protected member without a pythonsubclass In-Reply-To: <515335F32AA04440B3DE6FEA1993E9AD03E14DF4@srv-be-101.Symyx-IC.symyx.com> References: <49772214.9010304@tango04.net> <515335F32AA04440B3DE6FEA1993E9AD03E14DF4@srv-be-101.Symyx-IC.symyx.com> Message-ID: <497738DA.3010304@tango04.net> That solved the problem, I usually use internal unless its necessary to make something public, I didn't realize that the IronPython code is executed from another assembly. Thanks! Marty Nelson wrote: > Your class is internal, do you mean "public class Serie"? > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Bernat R?fales Mulet > Sent: Wednesday, January 21, 2009 5:25 AM > To: users at lists.ironpython.com > Subject: [IronPython] cannot access protected member without a pythonsubclass > > Hello, > > I'm trying to add scripting to an existing application in C#. My > approach is to provide some Wrapper classes, that are instantiated and > then passed to a python engine scope via the SetVariable method of the > scope class. The problem is that one of those wrappers has a public > property with the get and set methods, but when I try to access the > property in the Python Script I get this error: > cannot access protected member ElementID without a python subclass of Serie. > > The Serie class is simple: > > using System; > using System.Collections.Generic; > using System.Text; > > namespace Tango04.DashBoard.Scripting.Wrappers > { > class Serie > { > public string Name { get; set; } > public string ElementID { get; set; } > } > } > > The Python code I use is as simple as this: > ShowSerie = Serie.ElementID != 'somestring' > > I instantiate a Serie object, fill it with the data, and then pass it as > a variable to the script. > > Anyone knows what I'm doing wrong? > > Thanks! > > ======= > Notice: This e-mail message, together with any attachments, contains > information of Symyx Technologies, Inc. or any of its affiliates or > subsidiaries that may be confidential, proprietary, copyrighted, > privileged and/or protected work product, and is meant solely for > the intended recipient. If you are not the intended recipient, and > have received this message in error, please contact the sender > immediately, permanently delete the original and any copies of this > email and any attachments thereto. > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -------------- next part -------------- A non-text attachment was scrubbed... Name: brafales.vcf Type: text/x-vcard Size: 351 bytes Desc: not available URL: From renaud.durand.it at gmail.com Wed Jan 21 16:17:40 2009 From: renaud.durand.it at gmail.com (Renaud Durand) Date: Wed, 21 Jan 2009 16:17:40 +0100 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. Message-ID: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> Hi again, I'm trying to call a python function from C#. I found out through a tutorial how to do it from a Python source file but I would like to do it from a compiled assembly. Some elements are missing. I think it is something like below but this does not work: eng = Python.CreateEngine() Assembly interpreter = Assembly.Load("interpreter"); eng.runtime.LoadAssembly(interpreter); ScriptScope scope = eng.CreateScope(); //Get the interpretMapping function Func interpretMapping; interpretMapping = scope.GetVariable>("interpretMapping"); ObjectOperations ops = eng.Operations; //Get the interpItem returned by function. object item = interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); //Get the display Method object method = ops.GetMember(item, "display"); ops.Call(method); Thank you... Again :-) -- Renaud Durand EPITA Student -------------- next part -------------- An HTML attachment was scrubbed... URL: From empirebuilder at gmail.com Wed Jan 21 16:23:14 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Wed, 21 Jan 2009 17:23:14 +0200 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> Message-ID: <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> I think you have to import the function - loading the assembly alone is not enough. On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand wrote: > Hi again, > > I'm trying to call a python function from C#. I found out through a > tutorial how to do it from > a Python source file but I would like to do it from a compiled assembly. > Some elements are missing. > I think it is something like below but this does not work: > > eng = Python.CreateEngine() > Assembly interpreter = Assembly.Load("interpreter"); > eng.runtime.LoadAssembly(interpreter); > > ScriptScope scope = eng.CreateScope(); > > //Get the interpretMapping function > Func interpretMapping; > interpretMapping = scope.GetVariable object>>("interpretMapping"); > ObjectOperations ops = eng.Operations; > > //Get the interpItem returned by function. > object item = > interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); > //Get the display Method > object method = ops.GetMember(item, "display"); > ops.Call(method); > > Thank you... Again :-) > > -- > Renaud Durand > EPITA Student > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From neraun at gmail.com Wed Jan 21 16:45:03 2009 From: neraun at gmail.com (Renaud Durand) Date: Wed, 21 Jan 2009 16:45:03 +0100 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> Message-ID: <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> Ok, but how ? 2009/1/21 Dody Gunawinata > I think you have to import the function - loading the assembly alone is not > enough. > > On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand > wrote: > >> Hi again, >> >> I'm trying to call a python function from C#. I found out through a >> tutorial how to do it from >> a Python source file but I would like to do it from a compiled assembly. >> Some elements are missing. >> I think it is something like below but this does not work: >> >> eng = Python.CreateEngine() >> Assembly interpreter = Assembly.Load("interpreter"); >> eng.runtime.LoadAssembly(interpreter); >> >> ScriptScope scope = eng.CreateScope(); >> >> //Get the interpretMapping function >> Func interpretMapping; >> interpretMapping = scope.GetVariable> object>>("interpretMapping"); >> ObjectOperations ops = eng.Operations; >> >> //Get the interpItem returned by function. >> object item = >> interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); >> //Get the display Method >> object method = ops.GetMember(item, "display"); >> ops.Call(method); >> >> Thank you... Again :-) >> >> -- >> Renaud Durand >> EPITA Student >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- > nomadlife.org > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Wed Jan 21 17:08:30 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 21 Jan 2009 08:08:30 -0800 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> You need to do: eng.ExecuteFile('myfile.py', scope); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Renaud Durand Sent: Wednesday, January 21, 2009 7:45 AM To: dody at nomadlife.org; Discussion of IronPython Subject: Re: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. Ok, but how ? 2009/1/21 Dody Gunawinata > I think you have to import the function - loading the assembly alone is not enough. On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand @gmail.com> wrote: Hi again, I'm trying to call a python function from C#. I found out through a tutorial how to do it from a Python source file but I would like to do it from a compiled assembly. Some elements are missing. I think it is something like below but this does not work: eng = Python.CreateEngine() Assembly interpreter = Assembly.Load("interpreter"); eng.runtime.LoadAssembly(interpreter); ScriptScope scope = eng.CreateScope(); //Get the interpretMapping function Func interpretMapping; interpretMapping = scope.GetVariable>("interpretMapping"); ObjectOperations ops = eng.Operations; //Get the interpItem returned by function. object item = interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); //Get the display Method object method = ops.GetMember(item, "display"); ops.Call(method); Thank you... Again :-) -- Renaud Durand EPITA Student _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- nomadlife.org _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed Jan 21 17:08:51 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 21 Jan 2009 16:08:51 +0000 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> Message-ID: <49774893.80402@voidspace.org.uk> Renaud Durand wrote: > Ok, but how ? In the code you showed you create an empty scope and then attempt to fech a variable from it - something doomed to failure... Where does the assembly 'interpreter' come from? If it is compiled IronPython code then the filename will correspond to a module name (the namespace) - so if you execute 'from module import interpretMapping' in the scope you have created, you will then be able to fetch the module. If it is compiled IronPython code then you may need to do something else other than load it with the LoadAssembly API. Can't remember off the top of my head what the API to use is? Something like the following should work: eng.GetClrModule().AddReference(interpreter); Michael > > 2009/1/21 Dody Gunawinata > > > I think you have to import the function - loading the assembly > alone is not enough. > > On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand @gmail.com > wrote: > > Hi again, > > I'm trying to call a python function from C#. I found out > through a tutorial how to do it from > a Python source file but I would like to do it from a compiled > assembly. Some elements are missing. > I think it is something like below but this does not work: > > eng = Python.CreateEngine() > Assembly interpreter = Assembly.Load("interpreter"); > eng.runtime.LoadAssembly(interpreter); > > ScriptScope scope = eng.CreateScope(); > > //Get the interpretMapping function > Func interpretMapping; > interpretMapping = scope.GetVariable object>>("interpretMapping"); > ObjectOperations ops = eng.Operations; > > //Get the interpItem returned by function. > object item = > interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); > //Get the display Method > object method = ops.GetMember(item, "display"); > ops.Call(method); > > Thank you... Again :-) > > -- > Renaud Durand > EPITA Student > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > nomadlife.org > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > Renaud Durand > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From fuzzyman at voidspace.org.uk Wed Jan 21 17:10:06 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 21 Jan 2009 16:10:06 +0000 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <497748DE.9040409@voidspace.org.uk> Dino Viehland wrote: > > You need to do: > > eng.ExecuteFile(?myfile.py?, scope); > Uhm... yeah - or that. :-) Michael > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Renaud Durand > *Sent:* Wednesday, January 21, 2009 7:45 AM > *To:* dody at nomadlife.org; Discussion of IronPython > *Subject:* Re: [IronPython] Calling a Python function (compiled into > an assembly) from C# using delegates. > > Ok, but how ? > > 2009/1/21 Dody Gunawinata > > > I think you have to import the function - loading the assembly alone > is not enough. > > On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand @gmail.com > wrote: > > Hi again, > > I'm trying to call a python function from C#. I found out through > a tutorial how to do it from > a Python source file but I would like to do it from a compiled > assembly. Some elements are missing. > I think it is something like below but this does not work: > > eng = Python.CreateEngine() > Assembly interpreter = Assembly.Load("interpreter"); > eng.runtime.LoadAssembly(interpreter); > > ScriptScope scope = eng.CreateScope(); > > //Get the interpretMapping function > Func interpretMapping; > interpretMapping = scope.GetVariable object>>("interpretMapping"); > ObjectOperations ops = eng.Operations; > > //Get the interpItem returned by function. > object item = > interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); > //Get the display Method > object method = ops.GetMember(item, "display"); > ops.Call(method); > > Thank you... Again :-) > > -- > Renaud Durand > EPITA Student > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > nomadlife.org > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > Renaud Durand > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From neraun at gmail.com Wed Jan 21 17:11:50 2009 From: neraun at gmail.com (Renaud Durand) Date: Wed, 21 Jan 2009 17:11:50 +0100 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> That is the point. I don't want to do that from a file but from an Assembly (dll). 2009/1/21 Dino Viehland > You need to do: > > > > eng.ExecuteFile('myfile.py', scope); > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Renaud Durand > *Sent:* Wednesday, January 21, 2009 7:45 AM > *To:* dody at nomadlife.org; Discussion of IronPython > *Subject:* Re: [IronPython] Calling a Python function (compiled into an > assembly) from C# using delegates. > > > > Ok, but how ? > > 2009/1/21 Dody Gunawinata > > I think you have to import the function - loading the assembly alone is not > enough. > > On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand > wrote: > > Hi again, > > I'm trying to call a python function from C#. I found out through a > tutorial how to do it from > a Python source file but I would like to do it from a compiled assembly. > Some elements are missing. > I think it is something like below but this does not work: > > eng = Python.CreateEngine() > Assembly interpreter = Assembly.Load("interpreter"); > eng.runtime.LoadAssembly(interpreter); > > ScriptScope scope = eng.CreateScope(); > > //Get the interpretMapping function > Func interpretMapping; > interpretMapping = scope.GetVariable object>>("interpretMapping"); > ObjectOperations ops = eng.Operations; > > //Get the interpItem returned by function. > object item = > interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); > //Get the display Method > object method = ops.GetMember(item, "display"); > ops.Call(method); > > Thank you... Again :-) > > -- > Renaud Durand > EPITA Student > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > nomadlife.org > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > Renaud Durand > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From empirebuilder at gmail.com Wed Jan 21 17:15:16 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Wed, 21 Jan 2009 18:15:16 +0200 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> Message-ID: <8cd017b80901210815t424ea0fes6c3d94dbc90d8319@mail.gmail.com> string cmd = @"from xxx import yy"; eng.CreateScriptSourceFromString(cmd).Execute(--fill in default scope here--) //then go one fetching the function On Wed, Jan 21, 2009 at 6:11 PM, Renaud Durand wrote: > That is the point. I don't want to do that from a file but from an Assembly > (dll). > > 2009/1/21 Dino Viehland > > You need to do: >> >> >> >> eng.ExecuteFile('myfile.py', scope); >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Renaud Durand >> *Sent:* Wednesday, January 21, 2009 7:45 AM >> *To:* dody at nomadlife.org; Discussion of IronPython >> *Subject:* Re: [IronPython] Calling a Python function (compiled into an >> assembly) from C# using delegates. >> >> >> >> Ok, but how ? >> >> 2009/1/21 Dody Gunawinata >> >> I think you have to import the function - loading the assembly alone is >> not enough. >> >> On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand > gmail.com> wrote: >> >> Hi again, >> >> I'm trying to call a python function from C#. I found out through a >> tutorial how to do it from >> a Python source file but I would like to do it from a compiled assembly. >> Some elements are missing. >> I think it is something like below but this does not work: >> >> eng = Python.CreateEngine() >> Assembly interpreter = Assembly.Load("interpreter"); >> eng.runtime.LoadAssembly(interpreter); >> >> ScriptScope scope = eng.CreateScope(); >> >> //Get the interpretMapping function >> Func interpretMapping; >> interpretMapping = scope.GetVariable> object>>("interpretMapping"); >> ObjectOperations ops = eng.Operations; >> >> //Get the interpItem returned by function. >> object item = >> interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); >> //Get the display Method >> object method = ops.GetMember(item, "display"); >> ops.Call(method); >> >> Thank you... Again :-) >> >> -- >> Renaud Durand >> EPITA Student >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> >> >> -- >> nomadlife.org >> >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> >> >> -- >> Renaud Durand >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- > Renaud Durand > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed Jan 21 17:20:36 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 21 Jan 2009 16:20:36 +0000 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8cd017b80901210815t424ea0fes6c3d94dbc90d8319@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> <8cd017b80901210815t424ea0fes6c3d94dbc90d8319@mail.gmail.com> Message-ID: <49774B54.4010908@voidspace.org.uk> Dody Gunawinata wrote: > string cmd = @"from xxx import yy"; > > eng.CreateScriptSourceFromString(cmd).Execute(--fill in default scope > here--) It will need to be: eng.CreateScriptSourceFromString(cmd, SourceCodeKind.Statements).Execute(scope) But I'm pretty sure he will also need to use a different API for loading the assembly, assuming it is from compiled IronPython code rather than just an ordinary .NET assembly. Michael > > //then go one fetching the function > > On Wed, Jan 21, 2009 at 6:11 PM, Renaud Durand > wrote: > > That is the point. I don't want to do that from a file but from an > Assembly (dll). > > 2009/1/21 Dino Viehland > > > You need to do: > > > > eng.ExecuteFile('myfile.py', scope); > > > > *From:* users-bounces at lists.ironpython.com > > [mailto:users-bounces at lists.ironpython.com > ] *On Behalf Of > *Renaud Durand > *Sent:* Wednesday, January 21, 2009 7:45 AM > *To:* dody at nomadlife.org ; > Discussion of IronPython > *Subject:* Re: [IronPython] Calling a Python function > (compiled into an assembly) from C# using delegates. > > > > Ok, but how ? > > 2009/1/21 Dody Gunawinata > > > I think you have to import the function - loading the assembly > alone is not enough. > > On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand > @gmail.com > > wrote: > > Hi again, > > I'm trying to call a python function from C#. I found out > through a tutorial how to do it from > a Python source file but I would like to do it from a > compiled assembly. Some elements are missing. > I think it is something like below but this does not work: > > eng = Python.CreateEngine() > Assembly interpreter = > Assembly.Load("interpreter"); > eng.runtime.LoadAssembly(interpreter); > > ScriptScope scope = eng.CreateScope(); > > //Get the interpretMapping function > Func interpretMapping; > interpretMapping = > scope.GetVariable>("interpretMapping"); > ObjectOperations ops = eng.Operations; > > //Get the interpItem returned by function. > object item = > interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); > //Get the display Method > object method = ops.GetMember(item, "display"); > ops.Call(method); > > Thank you... Again :-) > > -- > Renaud Durand > EPITA Student > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > nomadlife.org > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > Renaud Durand > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > Renaud Durand > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > nomadlife.org > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From empirebuilder at gmail.com Wed Jan 21 17:28:57 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Wed, 21 Jan 2009 18:28:57 +0200 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <49774B54.4010908@voidspace.org.uk> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> <8cd017b80901210815t424ea0fes6c3d94dbc90d8319@mail.gmail.com> <49774B54.4010908@voidspace.org.uk> Message-ID: <8cd017b80901210828w32010c90kf89ee24f327c28e3@mail.gmail.com> hmm..why would an IronPython assembly be different from a static language assembly? Wouldn't that negates the main point of the CLR? Dody G. On Wed, Jan 21, 2009 at 6:20 PM, Michael Foord wrote: > Dody Gunawinata wrote: > >> string cmd = @"from xxx import yy"; >> >> eng.CreateScriptSourceFromString(cmd).Execute(--fill in default scope >> here--) >> > It will need to be: > > eng.CreateScriptSourceFromString(cmd, > SourceCodeKind.Statements).Execute(scope) > > But I'm pretty sure he will also need to use a different API for loading > the assembly, assuming it is from compiled IronPython code rather than just > an ordinary .NET assembly. > > Michael > > >> //then go one fetching the function >> >> On Wed, Jan 21, 2009 at 6:11 PM, Renaud Durand > neraun at gmail.com>> wrote: >> >> That is the point. I don't want to do that from a file but from an >> Assembly (dll). >> >> 2009/1/21 Dino Viehland > > >> >> You need to do: >> >> >> eng.ExecuteFile('myfile.py', scope); >> >> >> *From:* users-bounces at lists.ironpython.com >> >> [mailto:users-bounces at lists.ironpython.com >> ] *On Behalf Of >> *Renaud Durand >> *Sent:* Wednesday, January 21, 2009 7:45 AM >> *To:* dody at nomadlife.org ; >> Discussion of IronPython >> *Subject:* Re: [IronPython] Calling a Python function >> (compiled into an assembly) from C# using delegates. >> >> >> Ok, but how ? >> >> 2009/1/21 Dody Gunawinata > > >> >> I think you have to import the function - loading the assembly >> alone is not enough. >> >> On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand >> @gmail.com >> >> > wrote: >> >> Hi again, >> >> I'm trying to call a python function from C#. I found out >> through a tutorial how to do it from >> a Python source file but I would like to do it from a >> compiled assembly. Some elements are missing. >> I think it is something like below but this does not work: >> >> eng = Python.CreateEngine() >> Assembly interpreter = >> Assembly.Load("interpreter"); >> eng.runtime.LoadAssembly(interpreter); >> ScriptScope scope = >> eng.CreateScope(); >> >> //Get the interpretMapping function >> Func interpretMapping; >> interpretMapping = >> scope.GetVariable>("interpretMapping"); >> ObjectOperations ops = eng.Operations; >> >> //Get the interpItem returned by function. >> object item = >> >> interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); >> //Get the display Method >> object method = ops.GetMember(item, "display"); >> ops.Call(method); >> >> Thank you... Again :-) >> >> -- Renaud Durand >> EPITA Student >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> >> >> -- nomadlife.org >> >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> >> >> -- Renaud Durand >> >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> >> >> -- Renaud Durand >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> >> >> >> -- >> nomadlife.org >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Wed Jan 21 17:46:54 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Wed, 21 Jan 2009 08:46:54 -0800 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8cd017b80901210828w32010c90kf89ee24f327c28e3@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> <8cd017b80901210815t424ea0fes6c3d94dbc90d8319@mail.gmail.com> <49774B54.4010908@voidspace.org.uk> <8cd017b80901210828w32010c90kf89ee24f327c28e3@mail.gmail.com> Message-ID: This is very much worth doing: generate an assembly by precompiling a Python source file and then look at the result using Reflector. On Wed, Jan 21, 2009 at 8:28 AM, Dody Gunawinata wrote: > hmm..why would an IronPython assembly be different from a static language > assembly? Wouldn't that negates the main point of the CLR? > > Dody G. > > On Wed, Jan 21, 2009 at 6:20 PM, Michael Foord wrote: > >> Dody Gunawinata wrote: >> >>> string cmd = @"from xxx import yy"; >>> >>> eng.CreateScriptSourceFromString(cmd).Execute(--fill in default scope >>> here--) >>> >> It will need to be: >> >> eng.CreateScriptSourceFromString(cmd, >> SourceCodeKind.Statements).Execute(scope) >> >> But I'm pretty sure he will also need to use a different API for loading >> the assembly, assuming it is from compiled IronPython code rather than just >> an ordinary .NET assembly. >> >> Michael >> >> >>> //then go one fetching the function >>> >>> On Wed, Jan 21, 2009 at 6:11 PM, Renaud Durand >> neraun at gmail.com>> wrote: >>> >>> That is the point. I don't want to do that from a file but from an >>> Assembly (dll). >>> >>> 2009/1/21 Dino Viehland >> > >>> >>> You need to do: >>> >>> >>> eng.ExecuteFile('myfile.py', scope); >>> >>> >>> *From:* users-bounces at lists.ironpython.com >>> >>> [mailto:users-bounces at lists.ironpython.com >>> ] *On Behalf Of >>> *Renaud Durand >>> *Sent:* Wednesday, January 21, 2009 7:45 AM >>> *To:* dody at nomadlife.org ; >>> Discussion of IronPython >>> *Subject:* Re: [IronPython] Calling a Python function >>> (compiled into an assembly) from C# using delegates. >>> >>> >>> Ok, but how ? >>> >>> 2009/1/21 Dody Gunawinata >> > >>> >>> I think you have to import the function - loading the assembly >>> alone is not enough. >>> >>> On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand >>> @gmail.com >>> >>> > wrote: >>> >>> Hi again, >>> >>> I'm trying to call a python function from C#. I found out >>> through a tutorial how to do it from >>> a Python source file but I would like to do it from a >>> compiled assembly. Some elements are missing. >>> I think it is something like below but this does not work: >>> >>> eng = Python.CreateEngine() >>> Assembly interpreter = >>> Assembly.Load("interpreter"); >>> eng.runtime.LoadAssembly(interpreter); >>> ScriptScope scope = >>> eng.CreateScope(); >>> >>> //Get the interpretMapping function >>> Func interpretMapping; >>> interpretMapping = >>> scope.GetVariable>("interpretMapping"); >>> ObjectOperations ops = eng.Operations; >>> >>> //Get the interpItem returned by function. >>> object item = >>> >>> interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); >>> //Get the display Method >>> object method = ops.GetMember(item, "display"); >>> ops.Call(method); >>> >>> Thank you... Again :-) >>> >>> -- Renaud Durand >>> EPITA Student >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >> > >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- nomadlife.org >>> >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- Renaud Durand >>> >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- Renaud Durand >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >>> >>> >>> -- >>> nomadlife.org >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >> >> > > > -- > nomadlife.org > > > _______________________________________________ > 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 Wed Jan 21 17:58:06 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 21 Jan 2009 08:58:06 -0800 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704FB76C1@NA-EXMSG-C102.redmond.corp.microsoft.com> Oh, I see, in that case you want: eng.ImportModule("mymodule"); ImportModule is an extension method declared in the Python class so alternately you can do: Python.ImportModule(eng, "myModule"); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Renaud Durand Sent: Wednesday, January 21, 2009 8:12 AM To: Discussion of IronPython Subject: Re: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. That is the point. I don't want to do that from a file but from an Assembly (dll). 2009/1/21 Dino Viehland > You need to do: eng.ExecuteFile('myfile.py', scope); From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Renaud Durand Sent: Wednesday, January 21, 2009 7:45 AM To: dody at nomadlife.org; Discussion of IronPython Subject: Re: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. Ok, but how ? 2009/1/21 Dody Gunawinata > I think you have to import the function - loading the assembly alone is not enough. On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand @gmail.com> wrote: Hi again, I'm trying to call a python function from C#. I found out through a tutorial how to do it from a Python source file but I would like to do it from a compiled assembly. Some elements are missing. I think it is something like below but this does not work: eng = Python.CreateEngine() Assembly interpreter = Assembly.Load("interpreter"); eng.runtime.LoadAssembly(interpreter); ScriptScope scope = eng.CreateScope(); //Get the interpretMapping function Func interpretMapping; interpretMapping = scope.GetVariable>("interpretMapping"); ObjectOperations ops = eng.Operations; //Get the interpItem returned by function. object item = interpretMapping("649AC0165011B1E8F726AC54C911000000000000000000000000000000000000"); //Get the display Method object method = ops.GetMember(item, "display"); ops.Call(method); Thank you... Again :-) -- Renaud Durand EPITA Student _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- nomadlife.org _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Renaud Durand _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From neraun at gmail.com Wed Jan 21 21:52:03 2009 From: neraun at gmail.com (Renaud Durand) Date: Wed, 21 Jan 2009 21:52:03 +0100 Subject: [IronPython] Calling a Python function (compiled into an assembly) from C# using delegates. In-Reply-To: <350E7D38B6D819428718949920EC23555704FB76C1@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <8c5392700901210717x4bebcaf4r25db4b8dc7fc8c3f@mail.gmail.com> <8cd017b80901210723t599ee2eehaab29f77fdc3ca7a@mail.gmail.com> <8c5392700901210745w1f69663as5f8b8edff144ef28@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7663@NA-EXMSG-C102.redmond.corp.microsoft.com> <8c5392700901210811u69b1fd5cs48f43e6522402a43@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB76C1@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <8c5392700901211252x421098aeq46701b191cbc5d40@mail.gmail.com> I have found something that works, thanks to you :-). Given an IronPython assembly "mymodule.dll" with the function "myFunction" eng = Python.CreateEngine() eng.runtime.LoadAssembly(Assembly.Load("mymodule")); ScriptScope scope = eng.CreateScope(); cmd = "from mymodule import myFunction" eng.CreateScriptSourceFromString(cmd).Execute(scope); //Get the interpretMapping function Func myFunction; interpretMapping = scope.GetVariable>("myFunction"); ObjectOperations ops = eng.Operations; object bar = myFunction("foo"); object method = ops.GetMember(item, "myMethod"); ops.Call(method); Thanks for your patience and your answers. -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From marc at saegesser.org Wed Jan 21 23:40:25 2009 From: marc at saegesser.org (Marc Saegesser) Date: Wed, 21 Jan 2009 16:40:25 -0600 Subject: [IronPython] Remoting broken in 2.0? Message-ID: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> I've been using 2.0b3 for quite some time with good results. I just tried to move to the final 2.0 release and ran into a fatal problem. I use .Net Remoting and when I try to create a proxy to a well known object using System.Activator.GetObject() I get the following error: SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. The only change was going from 2.0b3 to 2.0. I think this is the same problem reported in item 470 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) in June of 2006. Any ideas on how to get around the problem? Marc From dinov at microsoft.com Thu Jan 22 00:27:33 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 21 Jan 2009 15:27:33 -0800 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> This is related to 470 but is slightly different. But in both cases the CLR is lying to us and telling us your object does implement the interface but it really doesn't (or I'm assuming that's the case, maybe whatever you're doing Activator.CreateInstance does implement the interface). But now we're blowing up before the interface cast on the remote side because Expression trees aren't serializable (whereas before we were blowing up on the other side of the remote call because the remote object doesn't actually implement the interface). The workaround at the bottom of that bug should work for you. You can create a local "typed proxy" object which goes through the type object to get members instead of the instance. That should avoid the interface check and you should be able to talk to the remote object. For convenience here's the typed proxy object: class typedproxy(object): __slots__ = ['obj', 'proxyType'] def __init__(self, obj, proxyType): self.obj = obj self.proxyType = proxyType def __getattribute__(self, attr): proxyType = object.__getattribute__(self, 'proxyType') obj = object.__getattribute__(self, 'obj') return getattr(proxyType, attr).__get__(obj, proxyType) test = typedproxy(System.Activator.GetObject(RemoteTest, 'http://localhost:8000/RemoteTest'), RemoteTest) If that doesn't work let us know. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc Saegesser Sent: Wednesday, January 21, 2009 2:40 PM To: users Subject: [IronPython] Remoting broken in 2.0? I've been using 2.0b3 for quite some time with good results. I just tried to move to the final 2.0 release and ran into a fatal problem. I use .Net Remoting and when I try to create a proxy to a well known object using System.Activator.GetObject() I get the following error: SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. The only change was going from 2.0b3 to 2.0. I think this is the same problem reported in item 470 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) in June of 2006. Any ideas on how to get around the problem? Marc _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From marc at saegesser.org Thu Jan 22 00:45:36 2009 From: marc at saegesser.org (Marc Saegesser) Date: Wed, 21 Jan 2009 17:45:36 -0600 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> I was already using the typedproxy stuff in my code running under 2.0b3 and my code looks just like the sample code you showed. It works great in 2.0b3, but throws an exception in 2.0. The class it's complaining about, ParameterExpression, really isn't serializable according to the documentation. So the question is why is 2.0 trying to serialize a ParameterExpression when 2.0b3 wasn't? My remote object doesn't do anything with Linq or expressions so I'm not sure where it's coming from. Marc On Wed, Jan 21, 2009 at 5:27 PM, Dino Viehland wrote: > This is related to 470 but is slightly different. But in both cases the CLR is lying to us and telling us your object does implement the interface but it really doesn't (or I'm assuming that's the case, maybe whatever you're doing Activator.CreateInstance does implement the interface). But now we're blowing up before the interface cast on the remote side because Expression trees aren't serializable (whereas before we were blowing up on the other side of the remote call because the remote object doesn't actually implement the interface). > > The workaround at the bottom of that bug should work for you. You can create a local "typed proxy" object which goes through the type object to get members instead of the instance. That should avoid the interface check and you should be able to talk to the remote object. For convenience here's the typed proxy object: > > class typedproxy(object): > __slots__ = ['obj', 'proxyType'] > def __init__(self, obj, proxyType): > self.obj = obj > self.proxyType = proxyType > > def __getattribute__(self, attr): > proxyType = object.__getattribute__(self, 'proxyType') > obj = object.__getattribute__(self, 'obj') > return getattr(proxyType, attr).__get__(obj, proxyType) > > > > test = typedproxy(System.Activator.GetObject(RemoteTest, 'http://localhost:8000/RemoteTest'), RemoteTest) > > > If that doesn't work let us know. > > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > Sent: Wednesday, January 21, 2009 2:40 PM > To: users > Subject: [IronPython] Remoting broken in 2.0? > > I've been using 2.0b3 for quite some time with good results. I just > tried to move to the final 2.0 release and ran into a fatal problem. > I use .Net Remoting and when I try to create a proxy to a well known > object using System.Activator.GetObject() I get the following error: > > SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in > Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35' is not marked as serializable. > > The only change was going from 2.0b3 to 2.0. > > I think this is the same problem reported in item 470 > (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) > in June of 2006. > > Any ideas on how to get around the problem? > > Marc > _______________________________________________ > 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 Thu Jan 22 00:57:13 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 21 Jan 2009 15:57:13 -0800 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704FB7A5F@NA-EXMSG-C102.redmond.corp.microsoft.com> Can you run w/ -X:ExceptionDetail to get the full stack trace? It's presumably trying to serialize it for a call to IDynamicObject which has a GetMetaObject(Expression e) method on it. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc Saegesser Sent: Wednesday, January 21, 2009 3:46 PM To: Discussion of IronPython Subject: Re: [IronPython] Remoting broken in 2.0? I was already using the typedproxy stuff in my code running under 2.0b3 and my code looks just like the sample code you showed. It works great in 2.0b3, but throws an exception in 2.0. The class it's complaining about, ParameterExpression, really isn't serializable according to the documentation. So the question is why is 2.0 trying to serialize a ParameterExpression when 2.0b3 wasn't? My remote object doesn't do anything with Linq or expressions so I'm not sure where it's coming from. Marc On Wed, Jan 21, 2009 at 5:27 PM, Dino Viehland wrote: > This is related to 470 but is slightly different. But in both cases the CLR is lying to us and telling us your object does implement the interface but it really doesn't (or I'm assuming that's the case, maybe whatever you're doing Activator.CreateInstance does implement the interface). But now we're blowing up before the interface cast on the remote side because Expression trees aren't serializable (whereas before we were blowing up on the other side of the remote call because the remote object doesn't actually implement the interface). > > The workaround at the bottom of that bug should work for you. You can create a local "typed proxy" object which goes through the type object to get members instead of the instance. That should avoid the interface check and you should be able to talk to the remote object. For convenience here's the typed proxy object: > > class typedproxy(object): > __slots__ = ['obj', 'proxyType'] > def __init__(self, obj, proxyType): > self.obj = obj > self.proxyType = proxyType > > def __getattribute__(self, attr): > proxyType = object.__getattribute__(self, 'proxyType') > obj = object.__getattribute__(self, 'obj') > return getattr(proxyType, attr).__get__(obj, proxyType) > > > > test = typedproxy(System.Activator.GetObject(RemoteTest, 'http://localhost:8000/RemoteTest'), RemoteTest) > > > If that doesn't work let us know. > > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > Sent: Wednesday, January 21, 2009 2:40 PM > To: users > Subject: [IronPython] Remoting broken in 2.0? > > I've been using 2.0b3 for quite some time with good results. I just > tried to move to the final 2.0 release and ran into a fatal problem. > I use .Net Remoting and when I try to create a proxy to a well known > object using System.Activator.GetObject() I get the following error: > > SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in > Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35' is not marked as serializable. > > The only change was going from 2.0b3 to 2.0. > > I think this is the same problem reported in item 470 > (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) > in June of 2006. > > Any ideas on how to get around the problem? > > Marc > _______________________________________________ > 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 marc at saegesser.org Thu Jan 22 02:21:12 2009 From: marc at saegesser.org (Marc Saegesser) Date: Wed, 21 Jan 2009 19:21:12 -0600 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <350E7D38B6D819428718949920EC23555704FB7A5F@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A5F@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <5235940e0901211721n1b0703afl823900a7a3b96a5b@mail.gmail.com> Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. Server stack trace: at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFor matterConverter converter, ObjectWriter objectWriter) at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatt erConverter converter, ObjectWriter objectWriter) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SerializeMessage(IMessage msg, ITransportHeaders& headers, Stream& stream) at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Microsoft.Scripting.Actions.IDynamicObject.GetMetaObject(Expression parameter) at Microsoft.Scripting.Actions.MetaObject.ObjectToMetaObject(Object argValue, Expression parameterExpression) at Microsoft.Scripting.Actions.MetaAction.Bind[T](Object[] args) at Microsoft.Scripting.Actions.CallSite`1.CreateNewRule(Rule`1 originalMonomorphicRule, Object[] args) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at S$2.Initialize$17() at _stub_$226##76(Closure , CallSite , CodeContext , Object ) at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 target, CallSite site, Object[] args) at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite site, T0 arg0, T1 arg1) at $224##74(Closure , Scope , LanguageContext ) at Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression code, Scope scope) at Microsoft.Scripting.ScriptCode.Run(Scope scope) at IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.b__0() SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializab le. Marc On Wed, Jan 21, 2009 at 5:57 PM, Dino Viehland wrote: > Can you run w/ -X:ExceptionDetail to get the full stack trace? > > It's presumably trying to serialize it for a call to IDynamicObject which has a GetMetaObject(Expression e) method on it. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > Sent: Wednesday, January 21, 2009 3:46 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Remoting broken in 2.0? > > I was already using the typedproxy stuff in my code running under > 2.0b3 and my code looks just like the sample code you showed. It > works great in 2.0b3, but throws an exception in 2.0. > > The class it's complaining about, ParameterExpression, really isn't > serializable according to the documentation. So the question is why > is 2.0 trying to serialize a ParameterExpression when 2.0b3 wasn't? > My remote object doesn't do anything with Linq or expressions so I'm > not sure where it's coming from. > > > Marc > > > > On Wed, Jan 21, 2009 at 5:27 PM, Dino Viehland wrote: >> This is related to 470 but is slightly different. But in both cases the CLR is lying to us and telling us your object does implement the interface but it really doesn't (or I'm assuming that's the case, maybe whatever you're doing Activator.CreateInstance does implement the interface). But now we're blowing up before the interface cast on the remote side because Expression trees aren't serializable (whereas before we were blowing up on the other side of the remote call because the remote object doesn't actually implement the interface). >> >> The workaround at the bottom of that bug should work for you. You can create a local "typed proxy" object which goes through the type object to get members instead of the instance. That should avoid the interface check and you should be able to talk to the remote object. For convenience here's the typed proxy object: >> >> class typedproxy(object): >> __slots__ = ['obj', 'proxyType'] >> def __init__(self, obj, proxyType): >> self.obj = obj >> self.proxyType = proxyType >> >> def __getattribute__(self, attr): >> proxyType = object.__getattribute__(self, 'proxyType') >> obj = object.__getattribute__(self, 'obj') >> return getattr(proxyType, attr).__get__(obj, proxyType) >> >> >> >> test = typedproxy(System.Activator.GetObject(RemoteTest, 'http://localhost:8000/RemoteTest'), RemoteTest) >> >> >> If that doesn't work let us know. >> >> >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marc Saegesser >> Sent: Wednesday, January 21, 2009 2:40 PM >> To: users >> Subject: [IronPython] Remoting broken in 2.0? >> >> I've been using 2.0b3 for quite some time with good results. I just >> tried to move to the final 2.0 release and ran into a fatal problem. >> I use .Net Remoting and when I try to create a proxy to a well known >> object using System.Activator.GetObject() I get the following error: >> >> SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in >> Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, >> PublicKeyToken=31bf3856ad364e35' is not marked as serializable. >> >> The only change was going from 2.0b3 to 2.0. >> >> I think this is the same problem reported in item 470 >> (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) >> in June of 2006. >> >> Any ideas on how to get around the problem? >> >> Marc >> _______________________________________________ >> 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 dinov at microsoft.com Thu Jan 22 03:21:02 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 21 Jan 2009 18:21:02 -0800 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <5235940e0901211721n1b0703afl823900a7a3b96a5b@mail.gmail.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A5F@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211721n1b0703afl823900a7a3b96a5b@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC23555704FB7AD3@NA-EXMSG-C102.redmond.corp.microsoft.com> I believe I have a solution but I don't know if it's ideal, if it'll break other things, or if there are also other spots that need to be updated.. I'll need to talk to the DLR team about it and hopefully they can figure those things out :). But if you're willing to compile from source you can download the IronPython 2 source code and edit MetaObject.cs. The changes are easy, just add: interface IRemotingMarker { } In the MetaObject class definition. Then add: IRemotingMarker irm = argValue as IRemotingMarker; if(irm != null) { // remote object, don't check for other interfaces. return new ParameterMetaObject(parameterExpression, argValue); } At the beginning of ObjectToMetaObject. That'll detect remote objects and avoid going down the failing code path. I'll ping the DLR team now and get the issue on a future DLR design discussion. If this does turn out to be the right solution (or close to it) we can fix this in 2.0.1. Thanks for the report! > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > Sent: Wednesday, January 21, 2009 5:21 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Remoting broken in 2.0? > > Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly > 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35' is not marked as serializable. > > Server stack trace: > at > System.Runtime.Serialization.FormatterServices.InternalGetSerializableM > embers(RuntimeType > type) > at > System.Runtime.Serialization.FormatterServices.GetSerializableMembers(T > ype > type, StreamingContext context) > at > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemb > erInfo() > at > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSeri > alize(Object > obj, ISurrogateSelector surrogateSelector, StreamingContext context, > SerObjectInfoInit serObjectInfoInit, IFor > matterConverter converter, ObjectWriter objectWriter) > at > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serializ > e(Object > obj, ISurrogateSelector surrogateSelector, StreamingContext context, > SerObjectInfoInit serObjectInfoInit, IFormatt > erConverter converter, ObjectWriter objectWriter) > at > System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(O > bject > graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) > at > System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serializ > e(Stream > serializationStream, Object graph, Header[] headers, Boolean fCheck) > at > System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SerializeMes > sage(IMessage > msg, ITransportHeaders& headers, Stream& stream) > at > System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessM > essage(IMessage > msg) > > Exception rethrown at [0]: > at > System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage > reqMsg, IMessage retMsg) > at > System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& > msgData, Int32 type) > at > Microsoft.Scripting.Actions.IDynamicObject.GetMetaObject(Expression > parameter) > at Microsoft.Scripting.Actions.MetaObject.ObjectToMetaObject(Object > argValue, Expression parameterExpression) > at Microsoft.Scripting.Actions.MetaAction.Bind[T](Object[] args) > at Microsoft.Scripting.Actions.CallSite`1.CreateNewRule(Rule`1 > originalMonomorphicRule, Object[] args) > at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] > args) > at > Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet] > (CallSite > site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at S$2.Initialize$17() > at _stub_$226##76(Closure , CallSite , CodeContext , Object ) > at Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 > target, CallSite site, Object[] args) > at Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] > args) > at > Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallS > ite > site, T0 arg0, T1 arg1) > at $224##74(Closure , Scope , LanguageContext ) > at > Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpr > ession > code, Scope scope) > at Microsoft.Scripting.ScriptCode.Run(Scope scope) > at > IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1. ion>b__0() > SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in > Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, > PublicKeyToken=31bf3856ad364e35' is not marked as serializab > le. > Marc > > > > On Wed, Jan 21, 2009 at 5:57 PM, Dino Viehland > wrote: > > Can you run w/ -X:ExceptionDetail to get the full stack trace? > > > > It's presumably trying to serialize it for a call to IDynamicObject > which has a GetMetaObject(Expression e) method on it. > > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > > Sent: Wednesday, January 21, 2009 3:46 PM > > To: Discussion of IronPython > > Subject: Re: [IronPython] Remoting broken in 2.0? > > > > I was already using the typedproxy stuff in my code running under > > 2.0b3 and my code looks just like the sample code you showed. It > > works great in 2.0b3, but throws an exception in 2.0. > > > > The class it's complaining about, ParameterExpression, really isn't > > serializable according to the documentation. So the question is why > > is 2.0 trying to serialize a ParameterExpression when 2.0b3 wasn't? > > My remote object doesn't do anything with Linq or expressions so I'm > > not sure where it's coming from. > > > > > > Marc > > > > > > > > On Wed, Jan 21, 2009 at 5:27 PM, Dino Viehland > wrote: > >> This is related to 470 but is slightly different. But in both cases > the CLR is lying to us and telling us your object does implement the > interface but it really doesn't (or I'm assuming that's the case, maybe > whatever you're doing Activator.CreateInstance does implement the > interface). But now we're blowing up before the interface cast on the > remote side because Expression trees aren't serializable (whereas > before we were blowing up on the other side of the remote call because > the remote object doesn't actually implement the interface). > >> > >> The workaround at the bottom of that bug should work for you. You > can create a local "typed proxy" object which goes through the type > object to get members instead of the instance. That should avoid the > interface check and you should be able to talk to the remote object. > For convenience here's the typed proxy object: > >> > >> class typedproxy(object): > >> __slots__ = ['obj', 'proxyType'] > >> def __init__(self, obj, proxyType): > >> self.obj = obj > >> self.proxyType = proxyType > >> > >> def __getattribute__(self, attr): > >> proxyType = object.__getattribute__(self, 'proxyType') > >> obj = object.__getattribute__(self, 'obj') > >> return getattr(proxyType, attr).__get__(obj, proxyType) > >> > >> > >> > >> test = typedproxy(System.Activator.GetObject(RemoteTest, > 'http://localhost:8000/RemoteTest'), RemoteTest) > >> > >> > >> If that doesn't work let us know. > >> > >> > >> > >> -----Original Message----- > >> From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > >> Sent: Wednesday, January 21, 2009 2:40 PM > >> To: users > >> Subject: [IronPython] Remoting broken in 2.0? > >> > >> I've been using 2.0b3 for quite some time with good results. I just > >> tried to move to the final 2.0 release and ran into a fatal problem. > >> I use .Net Remoting and when I try to create a proxy to a well known > >> object using System.Activator.GetObject() I get the following error: > >> > >> SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' > in > >> Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, > Culture=neutral, > >> PublicKeyToken=31bf3856ad364e35' is not marked as serializable. > >> > >> The only change was going from 2.0b3 to 2.0. > >> > >> I think this is the same problem reported in item 470 > >> > (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) > >> in June of 2006. > >> > >> Any ideas on how to get around the problem? > >> > >> Marc > >> _______________________________________________ > >> 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 From dinov at microsoft.com Thu Jan 22 03:33:57 2009 From: dinov at microsoft.com (Dino Viehland) Date: Wed, 21 Jan 2009 18:33:57 -0800 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <350E7D38B6D819428718949920EC23555704FB7AD3@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A5F@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211721n1b0703afl823900a7a3b96a5b@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7AD3@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <350E7D38B6D819428718949920EC23555704FB7AD7@NA-EXMSG-C102.redmond.corp.microsoft.com> I discovered System.Runtime.Remoting.RemotingServices.IsTransparentProxy(), it might be better to call that on argValue instead of doing the interface check. if (System.Runtime.Remoting.RemotingServices.IsTransparentProxy(argValue)) { return new ParameterMetaObject(parameterExpression, argValue); } > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Dino Viehland > Sent: Wednesday, January 21, 2009 6:21 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Remoting broken in 2.0? > > I believe I have a solution but I don't know if it's ideal, if it'll > break other things, or if there are also other spots that need to be > updated.. I'll need to talk to the DLR team about it and hopefully > they can figure those things out :). But if you're willing to compile > from source you can download the IronPython 2 source code and edit > MetaObject.cs. The changes are easy, just add: > > interface IRemotingMarker { > } > > In the MetaObject class definition. Then add: > > IRemotingMarker irm = argValue as IRemotingMarker; > if(irm != null) { > // remote object, don't check for other interfaces. > return new ParameterMetaObject(parameterExpression, > argValue); > } > > At the beginning of ObjectToMetaObject. > > That'll detect remote objects and avoid going down the failing code > path. I'll ping the DLR team now and get the issue on a future DLR > design discussion. If this does turn out to be the right solution (or > close to it) we can fix this in 2.0.1. Thanks for the report! > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com [mailto:users- > > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > > Sent: Wednesday, January 21, 2009 5:21 PM > > To: Discussion of IronPython > > Subject: Re: [IronPython] Remoting broken in 2.0? > > > > Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly > > 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, > > PublicKeyToken=31bf3856ad364e35' is not marked as serializable. > > > > Server stack trace: > > at > > > System.Runtime.Serialization.FormatterServices.InternalGetSerializableM > > embers(RuntimeType > > type) > > at > > > System.Runtime.Serialization.FormatterServices.GetSerializableMembers(T > > ype > > type, StreamingContext context) > > at > > > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemb > > erInfo() > > at > > > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSeri > > alize(Object > > obj, ISurrogateSelector surrogateSelector, StreamingContext context, > > SerObjectInfoInit serObjectInfoInit, IFor > > matterConverter converter, ObjectWriter objectWriter) > > at > > > System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serializ > > e(Object > > obj, ISurrogateSelector surrogateSelector, StreamingContext context, > > SerObjectInfoInit serObjectInfoInit, IFormatt > > erConverter converter, ObjectWriter objectWriter) > > at > > > System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(O > > bject > > graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) > > at > > > System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serializ > > e(Stream > > serializationStream, Object graph, Header[] headers, Boolean fCheck) > > at > > > System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SerializeMes > > sage(IMessage > > msg, ITransportHeaders& headers, Stream& stream) > > at > > > System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessM > > essage(IMessage > > msg) > > > > Exception rethrown at [0]: > > at > > > System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage > > reqMsg, IMessage retMsg) > > at > > System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& > > msgData, Int32 type) > > at > > Microsoft.Scripting.Actions.IDynamicObject.GetMetaObject(Expression > > parameter) > > at > Microsoft.Scripting.Actions.MetaObject.ObjectToMetaObject(Object > > argValue, Expression parameterExpression) > > at Microsoft.Scripting.Actions.MetaAction.Bind[T](Object[] args) > > at Microsoft.Scripting.Actions.CallSite`1.CreateNewRule(Rule`1 > > originalMonomorphicRule, Object[] args) > > at > Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] > > args) > > at > > > Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet] > > (CallSite > > site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) > > at S$2.Initialize$17() > > at _stub_$226##76(Closure , CallSite , CodeContext , Object ) > > at > Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 > > target, CallSite site, Object[] args) > > at > Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] > > args) > > at > > > Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallS > > ite > > site, T0 arg0, T1 arg1) > > at $224##74(Closure , Scope , LanguageContext ) > > at > > > Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpr > > ession > > code, Scope scope) > > at Microsoft.Scripting.ScriptCode.Run(Scope scope) > > at > > > IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1. > ion>b__0() > > SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in > > Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, > > PublicKeyToken=31bf3856ad364e35' is not marked as serializab > > le. > > Marc > > > > > > > > On Wed, Jan 21, 2009 at 5:57 PM, Dino Viehland > > wrote: > > > Can you run w/ -X:ExceptionDetail to get the full stack trace? > > > > > > It's presumably trying to serialize it for a call to IDynamicObject > > which has a GetMetaObject(Expression e) method on it. > > > > > > -----Original Message----- > > > From: users-bounces at lists.ironpython.com [mailto:users- > > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > > > Sent: Wednesday, January 21, 2009 3:46 PM > > > To: Discussion of IronPython > > > Subject: Re: [IronPython] Remoting broken in 2.0? > > > > > > I was already using the typedproxy stuff in my code running under > > > 2.0b3 and my code looks just like the sample code you showed. It > > > works great in 2.0b3, but throws an exception in 2.0. > > > > > > The class it's complaining about, ParameterExpression, really isn't > > > serializable according to the documentation. So the question is > why > > > is 2.0 trying to serialize a ParameterExpression when 2.0b3 wasn't? > > > My remote object doesn't do anything with Linq or expressions so > I'm > > > not sure where it's coming from. > > > > > > > > > Marc > > > > > > > > > > > > On Wed, Jan 21, 2009 at 5:27 PM, Dino Viehland > > > wrote: > > >> This is related to 470 but is slightly different. But in both > cases > > the CLR is lying to us and telling us your object does implement the > > interface but it really doesn't (or I'm assuming that's the case, > maybe > > whatever you're doing Activator.CreateInstance does implement the > > interface). But now we're blowing up before the interface cast on > the > > remote side because Expression trees aren't serializable (whereas > > before we were blowing up on the other side of the remote call > because > > the remote object doesn't actually implement the interface). > > >> > > >> The workaround at the bottom of that bug should work for you. You > > can create a local "typed proxy" object which goes through the type > > object to get members instead of the instance. That should avoid the > > interface check and you should be able to talk to the remote object. > > For convenience here's the typed proxy object: > > >> > > >> class typedproxy(object): > > >> __slots__ = ['obj', 'proxyType'] > > >> def __init__(self, obj, proxyType): > > >> self.obj = obj > > >> self.proxyType = proxyType > > >> > > >> def __getattribute__(self, attr): > > >> proxyType = object.__getattribute__(self, 'proxyType') > > >> obj = object.__getattribute__(self, 'obj') > > >> return getattr(proxyType, attr).__get__(obj, proxyType) > > >> > > >> > > >> > > >> test = typedproxy(System.Activator.GetObject(RemoteTest, > > 'http://localhost:8000/RemoteTest'), RemoteTest) > > >> > > >> > > >> If that doesn't work let us know. > > >> > > >> > > >> > > >> -----Original Message----- > > >> From: users-bounces at lists.ironpython.com [mailto:users- > > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser > > >> Sent: Wednesday, January 21, 2009 2:40 PM > > >> To: users > > >> Subject: [IronPython] Remoting broken in 2.0? > > >> > > >> I've been using 2.0b3 for quite some time with good results. I > just > > >> tried to move to the final 2.0 release and ran into a fatal > problem. > > >> I use .Net Remoting and when I try to create a proxy to a well > known > > >> object using System.Activator.GetObject() I get the following > error: > > >> > > >> SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' > > in > > >> Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, > > Culture=neutral, > > >> PublicKeyToken=31bf3856ad364e35' is not marked as serializable. > > >> > > >> The only change was going from 2.0b3 to 2.0. > > >> > > >> I think this is the same problem reported in item 470 > > >> > > > (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) > > >> in June of 2006. > > >> > > >> Any ideas on how to get around the problem? > > >> > > >> Marc > > >> _______________________________________________ > > >> 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 From marc at saegesser.org Thu Jan 22 03:46:50 2009 From: marc at saegesser.org (Marc Saegesser) Date: Wed, 21 Jan 2009 20:46:50 -0600 Subject: [IronPython] Remoting broken in 2.0? In-Reply-To: <350E7D38B6D819428718949920EC23555704FB7AD7@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <5235940e0901211440g18d7da66h8e3313830c289a22@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A36@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211545u56233677nb88438a7a654a522@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7A5F@NA-EXMSG-C102.redmond.corp.microsoft.com> <5235940e0901211721n1b0703afl823900a7a3b96a5b@mail.gmail.com> <350E7D38B6D819428718949920EC23555704FB7AD3@NA-EXMSG-C102.redmond.corp.microsoft.com> <350E7D38B6D819428718949920EC23555704FB7AD7@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <5235940e0901211846q1b196eeax3065cdbabebb7dd8@mail.gmail.com> Excellent! That did the trick. Marc On Wed, Jan 21, 2009 at 8:33 PM, Dino Viehland wrote: > I discovered System.Runtime.Remoting.RemotingServices.IsTransparentProxy(), it might be better to call that on argValue instead of doing the interface check. > > if (System.Runtime.Remoting.RemotingServices.IsTransparentProxy(argValue)) { > return new ParameterMetaObject(parameterExpression, argValue); > } > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Dino Viehland >> Sent: Wednesday, January 21, 2009 6:21 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] Remoting broken in 2.0? >> >> I believe I have a solution but I don't know if it's ideal, if it'll >> break other things, or if there are also other spots that need to be >> updated.. I'll need to talk to the DLR team about it and hopefully >> they can figure those things out :). But if you're willing to compile >> from source you can download the IronPython 2 source code and edit >> MetaObject.cs. The changes are easy, just add: >> >> interface IRemotingMarker { >> } >> >> In the MetaObject class definition. Then add: >> >> IRemotingMarker irm = argValue as IRemotingMarker; >> if(irm != null) { >> // remote object, don't check for other interfaces. >> return new ParameterMetaObject(parameterExpression, >> argValue); >> } >> >> At the beginning of ObjectToMetaObject. >> >> That'll detect remote objects and avoid going down the failing code >> path. I'll ping the DLR team now and get the issue on a future DLR >> design discussion. If this does turn out to be the right solution (or >> close to it) we can fix this in 2.0.1. Thanks for the report! >> >> > -----Original Message----- >> > From: users-bounces at lists.ironpython.com [mailto:users- >> > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser >> > Sent: Wednesday, January 21, 2009 5:21 PM >> > To: Discussion of IronPython >> > Subject: Re: [IronPython] Remoting broken in 2.0? >> > >> > Type 'Microsoft.Linq.Expressions.ParameterExpression' in Assembly >> > 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, >> > PublicKeyToken=31bf3856ad364e35' is not marked as serializable. >> > >> > Server stack trace: >> > at >> > >> System.Runtime.Serialization.FormatterServices.InternalGetSerializableM >> > embers(RuntimeType >> > type) >> > at >> > >> System.Runtime.Serialization.FormatterServices.GetSerializableMembers(T >> > ype >> > type, StreamingContext context) >> > at >> > >> System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemb >> > erInfo() >> > at >> > >> System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSeri >> > alize(Object >> > obj, ISurrogateSelector surrogateSelector, StreamingContext context, >> > SerObjectInfoInit serObjectInfoInit, IFor >> > matterConverter converter, ObjectWriter objectWriter) >> > at >> > >> System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serializ >> > e(Object >> > obj, ISurrogateSelector surrogateSelector, StreamingContext context, >> > SerObjectInfoInit serObjectInfoInit, IFormatt >> > erConverter converter, ObjectWriter objectWriter) >> > at >> > >> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(O >> > bject >> > graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) >> > at >> > >> System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serializ >> > e(Stream >> > serializationStream, Object graph, Header[] headers, Boolean fCheck) >> > at >> > >> System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SerializeMes >> > sage(IMessage >> > msg, ITransportHeaders& headers, Stream& stream) >> > at >> > >> System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessM >> > essage(IMessage >> > msg) >> > >> > Exception rethrown at [0]: >> > at >> > >> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage >> > reqMsg, IMessage retMsg) >> > at >> > System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& >> > msgData, Int32 type) >> > at >> > Microsoft.Scripting.Actions.IDynamicObject.GetMetaObject(Expression >> > parameter) >> > at >> Microsoft.Scripting.Actions.MetaObject.ObjectToMetaObject(Object >> > argValue, Expression parameterExpression) >> > at Microsoft.Scripting.Actions.MetaAction.Bind[T](Object[] args) >> > at Microsoft.Scripting.Actions.CallSite`1.CreateNewRule(Rule`1 >> > originalMonomorphicRule, Object[] args) >> > at >> Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] >> > args) >> > at >> > >> Microsoft.Scripting.Actions.UpdateDelegates.Update4[T,T0,T1,T2,T3,TRet] >> > (CallSite >> > site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) >> > at S$2.Initialize$17() >> > at _stub_$226##76(Closure , CallSite , CodeContext , Object ) >> > at >> Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4 >> > target, CallSite site, Object[] args) >> > at >> Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] >> > args) >> > at >> > >> Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallS >> > ite >> > site, T0 arg0, T1 arg1) >> > at $224##74(Closure , Scope , LanguageContext ) >> > at >> > >> Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpr >> > ession >> > code, Scope scope) >> > at Microsoft.Scripting.ScriptCode.Run(Scope scope) >> > at >> > >> IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.> > ion>b__0() >> > SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' in >> > Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, Culture=neutral, >> > PublicKeyToken=31bf3856ad364e35' is not marked as serializab >> > le. >> > Marc >> > >> > >> > >> > On Wed, Jan 21, 2009 at 5:57 PM, Dino Viehland >> > wrote: >> > > Can you run w/ -X:ExceptionDetail to get the full stack trace? >> > > >> > > It's presumably trying to serialize it for a call to IDynamicObject >> > which has a GetMetaObject(Expression e) method on it. >> > > >> > > -----Original Message----- >> > > From: users-bounces at lists.ironpython.com [mailto:users- >> > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser >> > > Sent: Wednesday, January 21, 2009 3:46 PM >> > > To: Discussion of IronPython >> > > Subject: Re: [IronPython] Remoting broken in 2.0? >> > > >> > > I was already using the typedproxy stuff in my code running under >> > > 2.0b3 and my code looks just like the sample code you showed. It >> > > works great in 2.0b3, but throws an exception in 2.0. >> > > >> > > The class it's complaining about, ParameterExpression, really isn't >> > > serializable according to the documentation. So the question is >> why >> > > is 2.0 trying to serialize a ParameterExpression when 2.0b3 wasn't? >> > > My remote object doesn't do anything with Linq or expressions so >> I'm >> > > not sure where it's coming from. >> > > >> > > >> > > Marc >> > > >> > > >> > > >> > > On Wed, Jan 21, 2009 at 5:27 PM, Dino Viehland >> >> > wrote: >> > >> This is related to 470 but is slightly different. But in both >> cases >> > the CLR is lying to us and telling us your object does implement the >> > interface but it really doesn't (or I'm assuming that's the case, >> maybe >> > whatever you're doing Activator.CreateInstance does implement the >> > interface). But now we're blowing up before the interface cast on >> the >> > remote side because Expression trees aren't serializable (whereas >> > before we were blowing up on the other side of the remote call >> because >> > the remote object doesn't actually implement the interface). >> > >> >> > >> The workaround at the bottom of that bug should work for you. You >> > can create a local "typed proxy" object which goes through the type >> > object to get members instead of the instance. That should avoid the >> > interface check and you should be able to talk to the remote object. >> > For convenience here's the typed proxy object: >> > >> >> > >> class typedproxy(object): >> > >> __slots__ = ['obj', 'proxyType'] >> > >> def __init__(self, obj, proxyType): >> > >> self.obj = obj >> > >> self.proxyType = proxyType >> > >> >> > >> def __getattribute__(self, attr): >> > >> proxyType = object.__getattribute__(self, 'proxyType') >> > >> obj = object.__getattribute__(self, 'obj') >> > >> return getattr(proxyType, attr).__get__(obj, proxyType) >> > >> >> > >> >> > >> >> > >> test = typedproxy(System.Activator.GetObject(RemoteTest, >> > 'http://localhost:8000/RemoteTest'), RemoteTest) >> > >> >> > >> >> > >> If that doesn't work let us know. >> > >> >> > >> >> > >> >> > >> -----Original Message----- >> > >> From: users-bounces at lists.ironpython.com [mailto:users- >> > bounces at lists.ironpython.com] On Behalf Of Marc Saegesser >> > >> Sent: Wednesday, January 21, 2009 2:40 PM >> > >> To: users >> > >> Subject: [IronPython] Remoting broken in 2.0? >> > >> >> > >> I've been using 2.0b3 for quite some time with good results. I >> just >> > >> tried to move to the final 2.0 release and ran into a fatal >> problem. >> > >> I use .Net Remoting and when I try to create a proxy to a well >> known >> > >> object using System.Activator.GetObject() I get the following >> error: >> > >> >> > >> SystemError: Type 'Microsoft.Linq.Expressions.ParameterExpression' >> > in >> > >> Assembly 'Microsoft.Scripting.Core, Version=0.9.0.0, >> > Culture=neutral, >> > >> PublicKeyToken=31bf3856ad364e35' is not marked as serializable. >> > >> >> > >> The only change was going from 2.0b3 to 2.0. >> > >> >> > >> I think this is the same problem reported in item 470 >> > >> >> > >> (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=470) >> > >> in June of 2006. >> > >> >> > >> Any ideas on how to get around the problem? >> > >> >> > >> Marc >> > >> _______________________________________________ >> > >> 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 > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From samuelt at gmail.com Thu Jan 22 17:59:28 2009 From: samuelt at gmail.com (Samuel Tjokrosoesilo) Date: Thu, 22 Jan 2009 10:59:28 -0600 Subject: [IronPython] Question on instantiating a .NET class in Python and pass the instantiated object back to C# Message-ID: Forgive me if this has been asked before. I already went through the archive and could not find any answer to this. Basically, the idea is to be able to define a class in C#. Then in Python, make a reference to the C# library and instantiate an object based on this class. Then as requested by C# through IronPython, this object reference is then passed back to be used/manipulated in C#. The error/issue I'm having is the casting of the object (passed from Python) to the C# class. (last part of the code below) Funny thing is that when I put a breakpoint on Visual Studio, I'm able to cast these objects in the Watch Window, but only when the code actually runs it fails with exception as below: Microsoft.Scripting.ArgumentTypeException: Expected DLRProto1_Extensions.Test03.CastTestObject, got DLRProto1_Extensions.Test03.CastTestObject Unable to cast object of type 'DLRProto1_Extensions.Test03.CastTestObject' to type 'DLRProto1_Extensions.Test03.CastTestObject'. I won't include the initialization of the engine and scope as they have been taken care by the base class. // C# library public class CastTestObject { private int cnt; private int limit; public CastTestObject() { cnt = 0; limit = 1000; } public void IncrementCount() { cnt++; } } # Python script import clr clr.AddReferenceToFile("DLRProto1_Extensions.dll") from DLRProto1_Extensions.Test03 import CastTestObject cto = CastTestObject() print cto def returnTestObject(): cto2 = CastTestObject() return cto2 // C# code manipulation below string script = ReadScript("Scenarios\\test03.py"); CompileAndExecute(script); CastTestObject ctoObject; // does not work, but works in Watch Window in Debug Mode ctoObject = ScrScope.GetVariable("cto"); // cast does not work, but works in Watch Window in Debug Mode object cObject = ScrEngine.Execute("returnTestObject()", ScrScope); ctoObject = (CastTestObject) cObject; //fails here with the exception above Any help is greatly appreciated. Thank you. Samuel -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Thu Jan 22 18:18:49 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Thu, 22 Jan 2009 09:18:49 -0800 Subject: [IronPython] Question on instantiating a .NET class in Python and pass the instantiated object back to C# In-Reply-To: References: Message-ID: The error "unable to cast object of type X to type X" is generally the result of an assembly loader issue. If you're using the hosting interface and want to get a reference to the hosting assembly, don't use "clr.AddReferenceToFile" -- you'll end up with the same assembly loaded twice. I think "clr.AddReference" might be okay, but the best choice is for the hosting C# code to inject itself directly into the ScriptRuntime by saying something like this: runtime.LoadAssembly(typeof(CastTestObject).Assembly) On Thu, Jan 22, 2009 at 8:59 AM, Samuel Tjokrosoesilo wrote: > Forgive me if this has been asked before. I already went through the > archive and could not find any answer to this. > > Basically, the idea is to be able to define a class in C#. > Then in Python, make a reference to the C# library and instantiate an > object based on this class. > Then as requested by C# through IronPython, this object reference is then > passed back to be used/manipulated in C#. > > The error/issue I'm having is the casting of the object (passed from > Python) to the C# class. (last part of the code below) > Funny thing is that when I put a breakpoint on Visual Studio, I'm able to > cast these objects in the Watch Window, but only when the code actually runs > it fails with exception as below: > Microsoft.Scripting.ArgumentTypeException: Expected > DLRProto1_Extensions.Test03.CastTestObject, got > DLRProto1_Extensions.Test03.CastTestObject > Unable to cast object of type > 'DLRProto1_Extensions.Test03.CastTestObject' to type > 'DLRProto1_Extensions.Test03.CastTestObject'. > > I won't include the initialization of the engine and scope as they have > been taken care by the base class. > > // C# library > public class CastTestObject > { > private int cnt; > private int limit; > public CastTestObject() > { > cnt = 0; > limit = 1000; > } > public void IncrementCount() > { > cnt++; > } > } > > # Python script > import clr > clr.AddReferenceToFile("DLRProto1_Extensions.dll") > from DLRProto1_Extensions.Test03 import CastTestObject > cto = CastTestObject() > print cto > def returnTestObject(): > cto2 = CastTestObject() > return cto2 > > // C# code manipulation below > string script = ReadScript("Scenarios\\test03.py"); > CompileAndExecute(script); > > CastTestObject ctoObject; > // does not work, but works in Watch Window in Debug Mode > ctoObject = ScrScope.GetVariable("cto"); > > // cast does not work, but works in Watch Window in Debug Mode > object cObject = ScrEngine.Execute("returnTestObject()", ScrScope); > ctoObject = (CastTestObject) cObject; //fails here with the exception above > > Any help is greatly appreciated. > > Thank you. > > Samuel > > _______________________________________________ > 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 Thu Jan 22 18:37:04 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Thu, 22 Jan 2009 18:37:04 +0100 Subject: [IronPython] Wake Up World! Meet the New Boss, Same as the Old Boss? Message-ID: <20090122173722.YQJT128.aarprv06.charter.net@ixgqg> If you want to know who the real establishment is in America and around the world, the real power behind the so-called ?military-industrial complex?, the real maleficent power that has led this world to inexorable conflict, war, hatreds, destruction of real human values, morality, conscience ? it is the global media establishment. This same media witnessed the Zionist slaughter of 1,300 people in Gaza, and the maiming of 6,000 more, half of them women and children. More than 20,000 homes and buildings were destroyed or damaged and thousands became homeless. This horrendous mass slaughter of Palestinians is compared to the loss of 3 Israeli civilians. Yet, the media never dare to call this slaughter exactly what it is: terrorism on a horrendous scale! This same American and global media has not informed the American people or the people of the world of the damning truth about Barack Obama. In truth, Obama is a complete creation of extremist Jewish Zionists and he has already begun to serve Israel by his top appointments. The Jewish-dominated media in America is promoting the Obama inauguration as akin to the Second Coming of Jesus Christ. (If you question Jewish control of the media read Who Runs the Media? and you will find documentation proving the Jewish control being far greater than you might suspect) The rest of the world?s powerful media (Which also has a powerful Jewish presence in the UK, France, Spain, Sweden, Russia, and the rest of Europe) takes its cues from the NY/Hollywood media axis, and presents Obama as kind of a superhuman agent of real change. In fact, it is a Huge Lie! Obama is completely controlled by the same forces that have controlled George Bush, so much so that The Chicago Tribune quotes leading Jews bragging that Obama is so in the hands of the Zionists that he is ?the first Jewish President.? Obama received about 80 percent of the Jewish vote in the United States! The Three critical things that made Obama President: 1)Jewish political influence Obama?s chief handler is David Axelrod, a radical Jewish Zionist whose previous claim to fame was the fact that he was the Zionist political hit man against Illinois Senator Charles Percy, who was not deemed to be pro-Israel enough. (He was only 99.9 percent Israel?s lackey, not the required 100 percent) Obama went to Israel and made sure he pronounced himself even more radically pro-Zionist than Bush or McCain. 2) Massive amounts of Jewish money Obama?s campaign was kicked in high gear by Jewish Hollywood and financial moguls. In just one of the early fundraising parties in Hollywood by Spielberg, Geffen and Katzenburg it raised over a million dollars for Obama. Obama raised more money than any political candidate in American history and his biggest contributors were overwhelmingly Jewish activists, Jewish international finance and banking firms and Jewish globalists. His largest single contributor was the international Jewish Banking firm of Goldman Sachs. He received more money from the same international bankers that ripped off trillions of dollars in the recent economic scandals than even John McCain. Is a man totally under the power of the most powerful financial organizations in the entire world, really an agent of ?change?? 3) Overwhelming positive support in the Jewish-dominated media By a large margin, Jewish-owned media officially endorsed Obama, and that is not counting tens of thousands of positive articles by Jewish; owned publications and pundits. Obama?s first act as President-elect was to appoint a Jewish extremist, dual citizen, Rahm Emmanuel, as his chief of staff. As the people of Gaza were slaughtered, Obama would not make a single statement to stop this murder and maiming of thousands of innocents! Israel, very carefully timed its terrorist attack on Gaza to be in the remaining days of the Bush Administration. The day before Obama?s inauguration Israel announced that it would be completely out of Gaza by the time Obama took his oath of office. Why? Before Obama took office, Israel could make this terrorist slaughter against Palestinians and Obama would still be perceived as having clean hands. Because Obama is completely under their control, they want him to have an image of fairness, honor and peacefulness, and as representing a new direction of American policy, as he begins to deal with the Mideast turmoil. Since he is Israel?s boy in the White House, what better scenario could they have than a President perceived as practically the Second Coming, of high moral conviction, and dedicated to fairness, but who is actually bound hand-and-foot to the Zionist agenda, just as the last president?s have been. Talk about a perfect shill. And the game is working, for even many Palestinians are filled with hope that the new President will work to end their long suffering. With an almost godlike positive image around the world, a Barack Obama who is in reality controlled by Israel, is a much bigger danger than was even George Bush. We know what Bush is, but too many Americans and other peoples around the world are falling for the lies about the new ?savior? of the world: Barack Obama. He already says we are to put thousands of new troops in Afghanistan and has rattled the sabers against Iran. Obama with highest positive image (created by media) in the world is in a more dangerous position to lead us into catastrophic wars than George Bush ever was. Jewish screenwriters in Hollywood couldn?t have written a better script for the Zionist agenda than what is being played out on inauguration day, USA. Of course, why should they write it, they did it. God save America, God save the Palestinians, God save peace and justice in the world! ?david duke Source: http://www.davidduke.com/general/wake-up-world-meet-the-new-boss-same-as-the-old-boss_7225.html ------ You or someone using your email adress is currently subscribed to the Lawrence Auster Newletter. If you wish to unsubscribe from our mailing list, please let us know by calling to 1 212 865 1284 Thanks, Lawrence Auster, 238 W 101 St Apt. 3B New York, NY 10025 Contact: lawrence.auster at att.net ------ From kfarmer at thuban.org Thu Jan 22 18:37:04 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Thu, 22 Jan 2009 18:37:04 +0100 Subject: [IronPython] Wake Up World! Meet the New Boss, Same as the Old Boss? Message-ID: <20090122173721.YQJJ128.aarprv06.charter.net@ixgqg> If you want to know who the real establishment is in America and around the world, the real power behind the so-called ?military-industrial complex?, the real maleficent power that has led this world to inexorable conflict, war, hatreds, destruction of real human values, morality, conscience ? it is the global media establishment. This same media witnessed the Zionist slaughter of 1,300 people in Gaza, and the maiming of 6,000 more, half of them women and children. More than 20,000 homes and buildings were destroyed or damaged and thousands became homeless. This horrendous mass slaughter of Palestinians is compared to the loss of 3 Israeli civilians. Yet, the media never dare to call this slaughter exactly what it is: terrorism on a horrendous scale! This same American and global media has not informed the American people or the people of the world of the damning truth about Barack Obama. In truth, Obama is a complete creation of extremist Jewish Zionists and he has already begun to serve Israel by his top appointments. The Jewish-dominated media in America is promoting the Obama inauguration as akin to the Second Coming of Jesus Christ. (If you question Jewish control of the media read Who Runs the Media? and you will find documentation proving the Jewish control being far greater than you might suspect) The rest of the world?s powerful media (Which also has a powerful Jewish presence in the UK, France, Spain, Sweden, Russia, and the rest of Europe) takes its cues from the NY/Hollywood media axis, and presents Obama as kind of a superhuman agent of real change. In fact, it is a Huge Lie! Obama is completely controlled by the same forces that have controlled George Bush, so much so that The Chicago Tribune quotes leading Jews bragging that Obama is so in the hands of the Zionists that he is ?the first Jewish President.? Obama received about 80 percent of the Jewish vote in the United States! The Three critical things that made Obama President: 1)Jewish political influence Obama?s chief handler is David Axelrod, a radical Jewish Zionist whose previous claim to fame was the fact that he was the Zionist political hit man against Illinois Senator Charles Percy, who was not deemed to be pro-Israel enough. (He was only 99.9 percent Israel?s lackey, not the required 100 percent) Obama went to Israel and made sure he pronounced himself even more radically pro-Zionist than Bush or McCain. 2) Massive amounts of Jewish money Obama?s campaign was kicked in high gear by Jewish Hollywood and financial moguls. In just one of the early fundraising parties in Hollywood by Spielberg, Geffen and Katzenburg it raised over a million dollars for Obama. Obama raised more money than any political candidate in American history and his biggest contributors were overwhelmingly Jewish activists, Jewish international finance and banking firms and Jewish globalists. His largest single contributor was the international Jewish Banking firm of Goldman Sachs. He received more money from the same international bankers that ripped off trillions of dollars in the recent economic scandals than even John McCain. Is a man totally under the power of the most powerful financial organizations in the entire world, really an agent of ?change?? 3) Overwhelming positive support in the Jewish-dominated media By a large margin, Jewish-owned media officially endorsed Obama, and that is not counting tens of thousands of positive articles by Jewish; owned publications and pundits. Obama?s first act as President-elect was to appoint a Jewish extremist, dual citizen, Rahm Emmanuel, as his chief of staff. As the people of Gaza were slaughtered, Obama would not make a single statement to stop this murder and maiming of thousands of innocents! Israel, very carefully timed its terrorist attack on Gaza to be in the remaining days of the Bush Administration. The day before Obama?s inauguration Israel announced that it would be completely out of Gaza by the time Obama took his oath of office. Why? Before Obama took office, Israel could make this terrorist slaughter against Palestinians and Obama would still be perceived as having clean hands. Because Obama is completely under their control, they want him to have an image of fairness, honor and peacefulness, and as representing a new direction of American policy, as he begins to deal with the Mideast turmoil. Since he is Israel?s boy in the White House, what better scenario could they have than a President perceived as practically the Second Coming, of high moral conviction, and dedicated to fairness, but who is actually bound hand-and-foot to the Zionist agenda, just as the last president?s have been. Talk about a perfect shill. And the game is working, for even many Palestinians are filled with hope that the new President will work to end their long suffering. With an almost godlike positive image around the world, a Barack Obama who is in reality controlled by Israel, is a much bigger danger than was even George Bush. We know what Bush is, but too many Americans and other peoples around the world are falling for the lies about the new ?savior? of the world: Barack Obama. He already says we are to put thousands of new troops in Afghanistan and has rattled the sabers against Iran. Obama with highest positive image (created by media) in the world is in a more dangerous position to lead us into catastrophic wars than George Bush ever was. Jewish screenwriters in Hollywood couldn?t have written a better script for the Zionist agenda than what is being played out on inauguration day, USA. Of course, why should they write it, they did it. God save America, God save the Palestinians, God save peace and justice in the world! ?david duke Source: http://www.davidduke.com/general/wake-up-world-meet-the-new-boss-same-as-the-old-boss_7225.html ------ You or someone using your email adress is currently subscribed to the Lawrence Auster Newletter. If you wish to unsubscribe from our mailing list, please let us know by calling to 1 212 865 1284 Thanks, Lawrence Auster, 238 W 101 St Apt. 3B New York, NY 10025 Contact: lawrence.auster at att.net ------ From samuelt at gmail.com Thu Jan 22 18:47:55 2009 From: samuelt at gmail.com (Samuel Tjokrosoesilo) Date: Thu, 22 Jan 2009 11:47:55 -0600 Subject: [IronPython] Question on instantiating a .NET class in Python and pass the instantiated object back to C# In-Reply-To: References: Message-ID: Sweet. I loaded them using the LoadAssembly in C# and voila the casting works. Thanks Curt for the prompt reply. Samuel On Thu, Jan 22, 2009 at 11:18 AM, Curt Hagenlocher wrote: > The error "unable to cast object of type X to type X" is generally the > result of an assembly loader issue. If you're using the hosting interface > and want to get a reference to the hosting assembly, don't use > "clr.AddReferenceToFile" -- you'll end up with the same assembly loaded > twice. I think "clr.AddReference" might be okay, but the best choice is for > the hosting C# code to inject itself directly into the ScriptRuntime by > saying something like this: > runtime.LoadAssembly(typeof(CastTestObject).Assembly) > > On Thu, Jan 22, 2009 at 8:59 AM, Samuel Tjokrosoesilo > wrote: > >> Forgive me if this has been asked before. I already went through the >> archive and could not find any answer to this. >> >> Basically, the idea is to be able to define a class in C#. >> Then in Python, make a reference to the C# library and instantiate an >> object based on this class. >> Then as requested by C# through IronPython, this object reference is then >> passed back to be used/manipulated in C#. >> >> The error/issue I'm having is the casting of the object (passed from >> Python) to the C# class. (last part of the code below) >> Funny thing is that when I put a breakpoint on Visual Studio, I'm able to >> cast these objects in the Watch Window, but only when the code actually runs >> it fails with exception as below: >> Microsoft.Scripting.ArgumentTypeException: Expected >> DLRProto1_Extensions.Test03.CastTestObject, got >> DLRProto1_Extensions.Test03.CastTestObject >> Unable to cast object of type >> 'DLRProto1_Extensions.Test03.CastTestObject' to type >> 'DLRProto1_Extensions.Test03.CastTestObject'. >> >> I won't include the initialization of the engine and scope as they have >> been taken care by the base class. >> >> // C# library >> public class CastTestObject >> { >> private int cnt; >> private int limit; >> public CastTestObject() >> { >> cnt = 0; >> limit = 1000; >> } >> public void IncrementCount() >> { >> cnt++; >> } >> } >> >> # Python script >> import clr >> clr.AddReferenceToFile("DLRProto1_Extensions.dll") >> from DLRProto1_Extensions.Test03 import CastTestObject >> cto = CastTestObject() >> print cto >> def returnTestObject(): >> cto2 = CastTestObject() >> return cto2 >> >> // C# code manipulation below >> string script = ReadScript("Scenarios\\test03.py"); >> CompileAndExecute(script); >> >> CastTestObject ctoObject; >> // does not work, but works in Watch Window in Debug Mode >> ctoObject = ScrScope.GetVariable("cto"); >> >> // cast does not work, but works in Watch Window in Debug Mode >> object cObject = ScrEngine.Execute("returnTestObject()", ScrScope); >> ctoObject = (CastTestObject) cObject; //fails here with the exception >> above >> >> Any help is greatly appreciated. >> >> Thank you. >> >> Samuel >> >> _______________________________________________ >> 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 Thu Jan 22 19:28:40 2009 From: kfarmer at thuban.org (Keith J. Farmer) Date: Thu, 22 Jan 2009 10:28:40 -0800 Subject: [IronPython] Wake Up World! Meet the New Boss, Same as the Old Boss? In-Reply-To: <20090122173721.YQJJ128.aarprv06.charter.net@ixgqg> References: <20090122173721.YQJJ128.aarprv06.charter.net@ixgqg> Message-ID: For any number of reasons, this isn't from me. Looking at the headers, it isn't even any of my servers. Thanks, Curt, for pinging me. Isn't the Internet grand? :P For this morning's fun, the originating IP still appears to be connected. Have at it :) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Keith J. Farmer Sent: Thursday, January 22, 2009 9:37 AM To: users at lists.ironpython.com Subject: [IronPython] Wake Up World! Meet the New Boss, Same as the Old Boss? From sheetal_gophane at persistent.co.in Fri Jan 23 09:28:59 2009 From: sheetal_gophane at persistent.co.in (Sheetal Gophane) Date: Fri, 23 Jan 2009 13:58:59 +0530 Subject: [IronPython] Sorting CSV file Message-ID: <005e01c97d34$a47014f0$ed503ed0$@co.in> Hi All, I have csv file in following format LogTime,ApetClientID,OperationName,Status,StartTime,Duration 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 I want to sort this file on the basis of first field i.e. LogTime Any pointers,how to do this? Thanks in advance. Thanks & Regards, Sheetal DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Fri Jan 23 14:16:13 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 23 Jan 2009 13:16:13 +0000 Subject: [IronPython] Sorting CSV file In-Reply-To: <005e01c97d34$a47014f0$ed503ed0$@co.in> References: <005e01c97d34$a47014f0$ed503ed0$@co.in> Message-ID: <4979C31D.8020108@voidspace.org.uk> Sheetal Gophane wrote: > > Hi All, > > > > I have csv file in following format > > LogTime,ApetClientID,OperationName,Status,StartTime,Duration > > 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 > > 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 > > 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 > > 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 > > 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 > > 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 > > > > I want to sort this file on the basis of first field i.e. LogTime > > Any pointers,how to do this? > What have you tried so far? Michael Foord > Thanks in advance. > > > > Thanks & Regards, > > Sheetal > > > > DISCLAIMER ========== This e-mail may contain privileged and > confidential information which is the property of Persistent Systems > Ltd. It is intended only for the use of the individual or entity to > which it is addressed. If you are not the intended recipient, you are > not authorized to read, retain, copy, print, distribute or use this > message. If you have received this communication in error, please > notify the sender and delete all copies of this message. Persistent > Systems Ltd. does not accept any liability for virus infected mails. > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From empirebuilder at gmail.com Fri Jan 23 14:21:56 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Fri, 23 Jan 2009 15:21:56 +0200 Subject: [IronPython] Sorting CSV file In-Reply-To: <005e01c97d34$a47014f0$ed503ed0$@co.in> References: <005e01c97d34$a47014f0$ed503ed0$@co.in> Message-ID: <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> 1. Define a class to hold individual data2. Go through every single line 3. Split based on ',' and insert the values to the object and add them to the list 4. Sort the list based on the fields you want. On Fri, Jan 23, 2009 at 10:28 AM, Sheetal Gophane < sheetal_gophane at persistent.co.in> wrote: > Hi All, > > > > I have csv file in following format > > LogTime,ApetClientID,OperationName,Status,StartTime,Duration > > 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 > > 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 > > 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 > > 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 > > 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 > > 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 > > > > I want to sort this file on the basis of first field i.e. LogTime > > Any pointers,how to do this? > > Thanks in advance. > > > > Thanks & Regards, > > Sheetal > > > > DISCLAIMER ========== This e-mail may contain privileged and confidential > information which is the property of Persistent Systems Ltd. It is intended > only for the use of the individual or entity to which it is addressed. If > you are not the intended recipient, you are not authorized to read, retain, > copy, print, distribute or use this message. If you have received this > communication in error, please notify the sender and delete all copies of > this message. Persistent Systems Ltd. does not accept any liability for > virus infected mails. > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From slide.o.mix at gmail.com Fri Jan 23 15:11:41 2009 From: slide.o.mix at gmail.com (Slide) Date: Fri, 23 Jan 2009 07:11:41 -0700 Subject: [IronPython] Sorting CSV file In-Reply-To: <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> References: <005e01c97d34$a47014f0$ed503ed0$@co.in> <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> Message-ID: On Fri, Jan 23, 2009 at 6:21 AM, Dody Gunawinata wrote: > 1. Define a class to hold individual data > 2. Go through every single line > 3. Split based on ',' and insert the values to the object and add them to > the list > 4. Sort the list based on the fields you want. > On Fri, Jan 23, 2009 at 10:28 AM, Sheetal Gophane > wrote: >> >> Hi All, >> >> >> >> I have csv file in following format >> >> LogTime,ApetClientID,OperationName,Status,StartTime,Duration >> >> 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 >> >> 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 >> >> 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 >> >> 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 >> >> 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 >> >> 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 >> >> >> >> I want to sort this file on the basis of first field i.e. LogTime >> >> Any pointers,how to do this? >> >> Thanks in advance. >> >> >> >> Thanks & Regards, >> >> Sheetal >> >> >> Why not use the csv module from the standard library? Should be simple to read the lines in using the CSVReader and have it already split for you. I'd recommend reading it into a dict and then sorting the dict based on that field as was already mentioned. From fuzzyman at voidspace.org.uk Fri Jan 23 15:28:19 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 23 Jan 2009 14:28:19 +0000 Subject: [IronPython] Sorting CSV file In-Reply-To: References: <005e01c97d34$a47014f0$ed503ed0$@co.in> <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> Message-ID: <4979D403.9050303@voidspace.org.uk> Slide wrote: > On Fri, Jan 23, 2009 at 6:21 AM, Dody Gunawinata > wrote: > >> 1. Define a class to hold individual data >> 2. Go through every single line >> 3. Split based on ',' and insert the values to the object and add them to >> the list >> 4. Sort the list based on the fields you want. >> On Fri, Jan 23, 2009 at 10:28 AM, Sheetal Gophane >> wrote: >> >>> Hi All, >>> >>> >>> >>> I have csv file in following format >>> >>> LogTime,ApetClientID,OperationName,Status,StartTime,Duration >>> >>> 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 >>> >>> 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 >>> >>> 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 >>> >>> 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 >>> >>> 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 >>> >>> 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 >>> >>> >>> >>> I want to sort this file on the basis of first field i.e. LogTime >>> >>> Any pointers,how to do this? >>> >>> Thanks in advance. >>> >>> >>> >>> Thanks & Regards, >>> >>> Sheetal >>> >>> >>> >>> > > > Why not use the csv module from the standard library? Should be simple > to read the lines in using the CSVReader and have it already split for > you. I'd recommend reading it into a dict and then sorting the dict > based on that field as was already mentioned. > Isn't the standard library csv module dependent on a C extension? There are recipes here for reading a CSV with a .NET library and IronPython: http://www.ironpython.info/index.php/Reading_CSV_Files http://www.ironpython.info/index.php/Talk:Reading_CSV_Files Michael > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From slide.o.mix at gmail.com Fri Jan 23 16:45:12 2009 From: slide.o.mix at gmail.com (Slide) Date: Fri, 23 Jan 2009 08:45:12 -0700 Subject: [IronPython] Sorting CSV file In-Reply-To: <4979D403.9050303@voidspace.org.uk> References: <005e01c97d34$a47014f0$ed503ed0$@co.in> <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> <4979D403.9050303@voidspace.org.uk> Message-ID: On Fri, Jan 23, 2009 at 7:28 AM, Michael Foord wrote: > Slide wrote: >> >> On Fri, Jan 23, 2009 at 6:21 AM, Dody Gunawinata >> wrote: >> >>> >>> 1. Define a class to hold individual data >>> 2. Go through every single line >>> 3. Split based on ',' and insert the values to the object and add them to >>> the list >>> 4. Sort the list based on the fields you want. >>> On Fri, Jan 23, 2009 at 10:28 AM, Sheetal Gophane >>> wrote: >>> >>>> >>>> Hi All, >>>> >>>> >>>> >>>> I have csv file in following format >>>> >>>> LogTime,ApetClientID,OperationName,Status,StartTime,Duration >>>> >>>> 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 >>>> >>>> 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 >>>> >>>> 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 >>>> >>>> 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 >>>> >>>> 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 >>>> >>>> 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 >>>> >>>> >>>> >>>> I want to sort this file on the basis of first field i.e. LogTime >>>> >>>> Any pointers,how to do this? >>>> >>>> Thanks in advance. >>>> >>>> >>>> >>>> Thanks & Regards, >>>> >>>> Sheetal >>>> >>>> >>>> >>>> >> >> >> Why not use the csv module from the standard library? Should be simple >> to read the lines in using the CSVReader and have it already split for >> you. I'd recommend reading it into a dict and then sorting the dict >> based on that field as was already mentioned. >> > > Isn't the standard library csv module dependent on a C extension? > > There are recipes here for reading a CSV with a .NET library and IronPython: > http://www.ironpython.info/index.php/Reading_CSV_Files > http://www.ironpython.info/index.php/Talk:Reading_CSV_Files > > Michael > > Ah, could be, although I thought I had used it in IronPython before, but I could be thinking of something else. slide -- slide-o-blog http://slide-o-blog.blogspot.com/ From antonio.piteira at wtvision.com Fri Jan 23 17:45:34 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Fri, 23 Jan 2009 16:45:34 -0000 Subject: [IronPython] IronPython 2.0 Errors... Message-ID: <002a01c97d7a$032c5950$09850bf0$@piteira@wtvision.com> Hi, I?m trying get all runtime errors without actually executing the code. I can get all syntax errors using the parser, but runtime errors like ?import ys? and stuff like that I?, not able to. Is there any way to do this? Thanks, Vision -------------- next part -------------- An HTML attachment was scrubbed... URL: From slide.o.mix at gmail.com Fri Jan 23 17:49:45 2009 From: slide.o.mix at gmail.com (Slide) Date: Fri, 23 Jan 2009 09:49:45 -0700 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <-402690530396885114@unknownmsgid> References: <-402690530396885114@unknownmsgid> Message-ID: On Fri, Jan 23, 2009 at 9:45 AM, Ant?nio Piteira wrote: > Hi, > > > > I'm trying get all runtime errors without actually executing the code. I can > get all syntax errors using the parser, but runtime errors like "import ys" > and stuff like that I', not able to. > > Is there any way to do this? > > > > Thanks, > > Vision > Those things are run-time errors (failed imports et al). You would possibly look at the parse tree for any imports and determine if the modules to be imported exist, but that sounds like a lot of trouble :) slide From curt at hagenlocher.org Fri Jan 23 17:52:43 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 23 Jan 2009 08:52:43 -0800 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <-402690530396885114@unknownmsgid> References: <-402690530396885114@unknownmsgid> Message-ID: Are you familiar with "the halting problem"? :) ( http://en.wikipedia.org/wiki/Halting_problem) The only reliable way to find if a particular program returns a runtime error is to execute the program. For limited, targeted cases, (such as importing modules) you could write an analyzer program which would be *often* right -- but I could create a program that tricks your analyzer into reporting a problem where none exists. Consider this: import sys sys.modules['foo'] = type(sys)('foo') import foo Your static analyzer would have a tough time recognizing that this program would not raise a runtime error. On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira < antonio.piteira at wtvision.com> wrote: > Hi, > > > > I'm trying get all runtime errors without actually executing the code. I > can get all syntax errors using the parser, but runtime errors like "import > ys" and stuff like that I', not able to. > > Is there any way to do this? > > > > Thanks, > > Vision > > _______________________________________________ > 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 antonio.piteira at wtvision.com Fri Jan 23 18:14:04 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Fri, 23 Jan 2009 17:14:04 -0000 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: References: <-402690530396885114@unknownmsgid> Message-ID: <4979fadf.0a04d00a.12c9.7e70@mx.google.com> I get it, I?m not really surprised I was hoping that maybe there was a way to use scriptSource.Compile(options,errorTracker), or something like that, and get the errors from errorTracker or some kind of sink. Very much apreciated for your time. ??????????????????__________________________________________________________ _________________________________________________________ Are you familiar with "the halting problem"? :) ( http://en.wikipedia.org/wiki/Halting_problem) The only reliable way to find if a particular program returns a runtime error is to execute the program. For limited, targeted cases, (such as importing modules) you could write an analyzer program which would be *often* right -- but I could create a program that tricks your analyzer into reporting a problem where none exists. Consider this: import sys sys.modules['foo'] = type(sys)('foo') import foo Your static analyzer would have a tough time recognizing that this program would not raise a runtime error. ??????????????????__________________________________________________________ _________________________________________________________ Those things are run-time errors (failed imports et al). You would possibly look at the parse tree for any imports and determine if the modules to be imported exist, but that sounds like a lot of trouble :) slide ??????????????????__________________________________________________________ _________________________________________________________ On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira wrote: Hi, I'm trying get all runtime errors without actually executing the code. I can get all syntax errors using the parser, but runtime errors like "import ys" and stuff like that I', not able to. Is there any way to do this? Thanks, Vision _______________________________________________ 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 empirebuilder at gmail.com Fri Jan 23 19:03:32 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Fri, 23 Jan 2009 20:03:32 +0200 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <4979fadf.0a04d00a.12c9.7e70@mx.google.com> References: <-402690530396885114@unknownmsgid> <4979fadf.0a04d00a.12c9.7e70@mx.google.com> Message-ID: <8cd017b80901231003x39487511pc038c6f03982eec8@mail.gmail.com> Don't you think PythonException or related classes would be sufficient? On Fri, Jan 23, 2009 at 7:14 PM, Ant?nio Piteira < antonio.piteira at wtvision.com> wrote: > I get it, I'm not really surprised? I was hoping that maybe there was a > way to use scriptSource.Compile(options,errorTracker), or something like > that, and get the errors from errorTracker or some kind of sink. > > > > Very much apreciated for your time. > > > > > ??????????????????___________________________________________________________________________________________________________________ > > > > > > Are you familiar with "the halting problem"? :) ( > http://en.wikipedia.org/wiki/Halting_problem) > > > > The only reliable way to find if a particular program returns a runtime > error is to execute the program. For limited, targeted cases, (such as > importing modules) you could write an analyzer program which would be > *often* right -- but I could create a program that tricks your analyzer > into reporting a problem where none exists. Consider this: > > > > import sys > > sys.modules['foo'] = type(sys)('foo') > > import foo > > > > Your static analyzer would have a tough time recognizing that this program > would not raise a runtime error. > > > > > ??????????????????___________________________________________________________________________________________________________________ > > > > Those things are run-time errors (failed imports et al). You would > > possibly look at the parse tree for any imports and determine if the > > modules to be imported exist, but that sounds like a lot of trouble :) > > > > slide > > > ??????????????????___________________________________________________________________________________________________________________ > > > > > > On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira < > antonio.piteira at wtvision.com> wrote: > > Hi, > > > > I'm trying get all runtime errors without actually executing the code. I > can get all syntax errors using the parser, but runtime errors like "import > ys" and stuff like that I', not able to. > > Is there any way to do this? > > > > Thanks, > > Vision > > > _______________________________________________ > 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 > > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From antonio.piteira at wtvision.com Fri Jan 23 19:19:18 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Fri, 23 Jan 2009 18:19:18 -0000 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <8cd017b80901231003x39487511pc038c6f03982eec8@mail.gmail.com> References: <-402690530396885114@unknownmsgid> <4979fadf.0a04d00a.12c9.7e70@mx.google.com> <8cd017b80901231003x39487511pc038c6f03982eec8@mail.gmail.com> Message-ID: <497a0a2a.09a8100a.4f4a.ffffed5a@mx.google.com> Those classes probably won?t be triggered unless I execute the code. Consider this sample code: import sys,clr clr.AddReference(?System.Windows.Forms?) from System.Windows.Forms import * frm = Form() frm.Show() #some error here, after the show If I execute the code the form will still be shown and only then I would be able to catch the error. What I want is to catch the errors without showing the form (considering this code). Thanks for your cooperation Don't you think PythonException or related classes would be sufficient? On Fri, Jan 23, 2009 at 7:14 PM, Ant?nio Piteira wrote: I get it, I'm not really surprised I was hoping that maybe there was a way to use scriptSource.Compile(options,errorTracker), or something like that, and get the errors from errorTracker or some kind of sink. Very much apreciated for your time. ??????????????????__________________________________________________________ _________________________________________________________ Are you familiar with "the halting problem"? :) ( http://en.wikipedia.org/wiki/Halting_problem) The only reliable way to find if a particular program returns a runtime error is to execute the program. For limited, targeted cases, (such as importing modules) you could write an analyzer program which would be *often* right -- but I could create a program that tricks your analyzer into reporting a problem where none exists. Consider this: import sys sys.modules['foo'] = type(sys)('foo') import foo Your static analyzer would have a tough time recognizing that this program would not raise a runtime error. ??????????????????__________________________________________________________ _________________________________________________________ Those things are run-time errors (failed imports et al). You would possibly look at the parse tree for any imports and determine if the modules to be imported exist, but that sounds like a lot of trouble :) slide ??????????????????__________________________________________________________ _________________________________________________________ On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira wrote: Hi, I'm trying get all runtime errors without actually executing the code. I can get all syntax errors using the parser, but runtime errors like "import ys" and stuff like that I', not able to. Is there any way to do this? Thanks, Vision _______________________________________________ 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 -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From empirebuilder at gmail.com Fri Jan 23 19:31:40 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Fri, 23 Jan 2009 20:31:40 +0200 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <497a0a2a.09a8100a.4f4a.ffffed5a@mx.google.com> References: <-402690530396885114@unknownmsgid> <4979fadf.0a04d00a.12c9.7e70@mx.google.com> <8cd017b80901231003x39487511pc038c6f03982eec8@mail.gmail.com> <497a0a2a.09a8100a.4f4a.ffffed5a@mx.google.com> Message-ID: <8cd017b80901231031s435428ebmf443f1a1e92102be@mail.gmail.com> There may be a way to execute the show form without actually displaying it to the user - there must be some AppDomain magic available to be used somewhere. The code needs to be executed one way or another and what you are suggesting I think falls into the static verifier category which is a whole another ballgame. On Fri, Jan 23, 2009 at 8:19 PM, Ant?nio Piteira < antonio.piteira at wtvision.com> wrote: > Those classes probably won't be triggered unless I execute the code. > > > > Consider this sample code: > > > > import sys,clr > > clr.AddReference("System.Windows.Forms") > > from System.Windows.Forms import * > > > > frm = Form() > > frm.Show() > > > > ?#some error here, after the show > > > > If I execute the code the form will still be shown and only then I would be > able to catch the error. > > What I want is to catch the errors without showing the form (considering > this code). > > > > Thanks for your cooperation > > > > > > > > > > Don't you think PythonException or related classes would be sufficient? > > On Fri, Jan 23, 2009 at 7:14 PM, Ant?nio Piteira < > antonio.piteira at wtvision.com> wrote: > > I get it, I'm not really surprised? I was hoping that maybe there was a way > to use scriptSource.Compile(options,errorTracker), or something like that, > and get the errors from errorTracker or some kind of sink. > > > > Very much apreciated for your time. > > > > > ??????????????????___________________________________________________________________________________________________________________ > > > > > > Are you familiar with "the halting problem"? :) ( > http://en.wikipedia.org/wiki/Halting_problem) > > > > The only reliable way to find if a particular program returns a runtime > error is to execute the program. For limited, targeted cases, (such as > importing modules) you could write an analyzer program which would be > *often* right -- but I could create a program that tricks your analyzer > into reporting a problem where none exists. Consider this: > > > > import sys > > sys.modules['foo'] = type(sys)('foo') > > import foo > > > > Your static analyzer would have a tough time recognizing that this program > would not raise a runtime error. > > > > > ??????????????????___________________________________________________________________________________________________________________ > > > > Those things are run-time errors (failed imports et al). You would > > possibly look at the parse tree for any imports and determine if the > > modules to be imported exist, but that sounds like a lot of trouble :) > > > > slide > > > ??????????????????___________________________________________________________________________________________________________________ > > > > > > On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira < > antonio.piteira at wtvision.com> wrote: > > Hi, > > > > I'm trying get all runtime errors without actually executing the code. I > can get all syntax errors using the parser, but runtime errors like "import > ys" and stuff like that I', not able to. > > Is there any way to do this? > > > > Thanks, > > Vision > > > _______________________________________________ > 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 > > > > > -- > nomadlife.org > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From sheetal_gophane at persistent.co.in Sat Jan 24 07:13:46 2009 From: sheetal_gophane at persistent.co.in (Sheetal Gophane) Date: Sat, 24 Jan 2009 11:43:46 +0530 Subject: [IronPython] Sorting CSV file In-Reply-To: References: <005e01c97d34$a47014f0$ed503ed0$@co.in> <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> <4979D403.9050303@voidspace.org.uk> Message-ID: <003001c97dea$ead27490$c0775db0$@co.in> Thank you all for your suggestions. I followed the following way 1.Define a class 2.In class overwrite __cmp__ function. 3.While reading file populate class object and append it in array. 4.Call array.sort() method. Internally it calls __cmp__ function. Thanks, Sheetal -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Friday, January 23, 2009 9:15 PM To: Discussion of IronPython Subject: Re: [IronPython] Sorting CSV file On Fri, Jan 23, 2009 at 7:28 AM, Michael Foord wrote: > Slide wrote: >> >> On Fri, Jan 23, 2009 at 6:21 AM, Dody Gunawinata >> wrote: >> >>> >>> 1. Define a class to hold individual data >>> 2. Go through every single line >>> 3. Split based on ',' and insert the values to the object and add them to >>> the list >>> 4. Sort the list based on the fields you want. >>> On Fri, Jan 23, 2009 at 10:28 AM, Sheetal Gophane >>> wrote: >>> >>>> >>>> Hi All, >>>> >>>> >>>> >>>> I have csv file in following format >>>> >>>> LogTime,ApetClientID,OperationName,Status,StartTime,Duration >>>> >>>> 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 >>>> >>>> 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 >>>> >>>> 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 >>>> >>>> 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 >>>> >>>> 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 >>>> >>>> 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 >>>> >>>> >>>> >>>> I want to sort this file on the basis of first field i.e. LogTime >>>> >>>> Any pointers,how to do this? >>>> >>>> Thanks in advance. >>>> >>>> >>>> >>>> Thanks & Regards, >>>> >>>> Sheetal >>>> >>>> >>>> >>>> >> >> >> Why not use the csv module from the standard library? Should be simple >> to read the lines in using the CSVReader and have it already split for >> you. I'd recommend reading it into a dict and then sorting the dict >> based on that field as was already mentioned. >> > > Isn't the standard library csv module dependent on a C extension? > > There are recipes here for reading a CSV with a .NET library and IronPython: > http://www.ironpython.info/index.php/Reading_CSV_Files > http://www.ironpython.info/index.php/Talk:Reading_CSV_Files > > Michael > > Ah, could be, although I thought I had used it in IronPython before, but I could be thinking of something else. slide -- 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 DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. From sjmachin at lexicon.net Sat Jan 24 13:56:02 2009 From: sjmachin at lexicon.net (John Machin) Date: Sat, 24 Jan 2009 23:56:02 +1100 Subject: [IronPython] Sorting CSV file In-Reply-To: <003001c97dea$ead27490$c0775db0$@co.in> References: <005e01c97d34$a47014f0$ed503ed0$@co.in> <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> <4979D403.9050303@voidspace.org.uk> <003001c97dea$ead27490$c0775db0$@co.in> Message-ID: <497B0FE2.5060901@lexicon.net> On 24/01/2009 5:13 PM, Sheetal Gophane wrote: > Thank you all for your suggestions. > I followed the following way > 1.Define a class > 2.In class overwrite __cmp__ function. > 3.While reading file populate class object and append it in array. > 4.Call array.sort() method. Internally it calls __cmp__ function. > > > > Thanks, > Sheetal > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Friday, January 23, 2009 9:15 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Sorting CSV file > > On Fri, Jan 23, 2009 at 7:28 AM, Michael Foord > wrote: >> Slide wrote: >>> On Fri, Jan 23, 2009 at 6:21 AM, Dody Gunawinata >>> wrote: >>> >>>> 1. Define a class to hold individual data >>>> 2. Go through every single line >>>> 3. Split based on ',' and insert the values to the object and add them > to >>>> the list >>>> 4. Sort the list based on the fields you want. >>>> On Fri, Jan 23, 2009 at 10:28 AM, Sheetal Gophane >>>> wrote: >>>> >>>>> Hi All, >>>>> >>>>> >>>>> >>>>> I have csv file in following format >>>>> >>>>> LogTime,ApetClientID,OperationName,Status,StartTime,Duration >>>>> >>>>> 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 >>>>> >>>>> 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 >>>>> >>>>> 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 >>>>> >>>>> 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 >>>>> >>>>> 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 >>>>> >>>>> 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 >>>>> >>>>> >>>>> >>>>> I want to sort this file on the basis of first field i.e. LogTime >>>>> >>>>> Any pointers,how to do this? >>>>> >>>>> Thanks in advance. >>>>> >>>>> >>>>> >>>>> Thanks & Regards, >>>>> >>>>> Sheetal >>>>> >>>>> >>>>> >>>>> >>> >>> Why not use the csv module from the standard library? Should be simple >>> to read the lines in using the CSVReader and have it already split for >>> you. I'd recommend reading it into a dict and then sorting the dict >>> based on that field as was already mentioned. >>> >> Isn't the standard library csv module dependent on a C extension? >> >> There are recipes here for reading a CSV with a .NET library and > IronPython: >> http://www.ironpython.info/index.php/Reading_CSV_Files >> http://www.ironpython.info/index.php/Talk:Reading_CSV_Files >> >> Michael >> >> > > > Ah, could be, although I thought I had used it in IronPython before, > but I could be thinking of something else. > > slide > > From sjmachin at lexicon.net Sat Jan 24 14:47:40 2009 From: sjmachin at lexicon.net (John Machin) Date: Sun, 25 Jan 2009 00:47:40 +1100 Subject: [IronPython] Sorting CSV file In-Reply-To: <003001c97dea$ead27490$c0775db0$@co.in> References: <005e01c97d34$a47014f0$ed503ed0$@co.in> <8cd017b80901230521o221ce1b4j31a4c74da5224da@mail.gmail.com> <4979D403.9050303@voidspace.org.uk> <003001c97dea$ead27490$c0775db0$@co.in> Message-ID: <497B1BFC.7010601@lexicon.net> Sorry about the empty reply just then; finger trouble :-( On 24/01/2009 5:13 PM, Sheetal Gophane wrote: > Thank you all for your suggestions. > I followed the following way > 1.Define a class > 2.In class overwrite __cmp__ function. > 3.While reading file populate class object and append it in array. > 4.Call array.sort() method. Internally it calls __cmp__ function. That is rather a long cumbersome way around it. Why not use the facilities that are built into the sort method, like the cmp argument, or (better) the key argument? See http://www.python.org/doc/2.4.2/lib/typesseq-mutable.html Here's a demonstration; tested with IronPython 2.0 and Python 2.5 8<--- import StringIO csv_data = """LogTime,ApetClientID,OperationName,Status,StartTime,Duration 2009-01-07/10:41:03,1,fun1,1,2009-01-07/10:41:02,314.8173162 2009-01-07/10:41:03,1,Login,0,2009-01-07/10:41:02,618.2695007 2009-01-07/10:41:03,1,Login,1,2009-01-07/10:40:52,10997.29274 2009-01-07/10:41:04,1,fun2,1,2009-01-07/10:41:03,364.0241288 2009-01-07/10:41:04,1,DoLogin,1,2009-01-07/10:40:52,11248.42243 2009-01-07/10:41:04,1,fun3,1,2009-01-07/10:41:03,1197.179181 """ def display(header, rows): print header for row in rows: print ','.join(row) f = StringIO.StringIO(csv_data) # f simulates a file object as returned by the open() builtin. heading = f.next().rstrip() data = [line.rstrip().split(',') for line in f] # Sorting on the first column is boring -- it's already sorted. # Let's sort on OperationName: guff = data[:] # taking a copy guff.sort(cmp=lambda x, y: cmp(x[2], y[2])) print "OperationName -- cmp" display(heading, guff) # Better [read the manual to find out why] guff = data[:] # taking a copy guff.sort(key=lambda x: x[2]) print "OperationName -- key" display(heading, guff) # simulate SQL: ORDER BY OperationName, Duration DESC guff = data[:] # taking a copy guff.sort( key=lambda x: (x[2], -float(x[5]))) print "OperationName, Duration DESC -- key" display(heading, guff) 8<--- HTH, John From kristian.jaksch at gmail.com Sun Jan 25 19:28:31 2009 From: kristian.jaksch at gmail.com (Kristian) Date: Sun, 25 Jan 2009 10:28:31 -0800 (PST) Subject: [IronPython] IronPython to JavaScript In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5157@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <21413681.post@talk.nabble.com> <496BB5D5.30800@voidspace.org.uk> <1dab55500901130059k6c7f42b0t99c4d799e205bf06@mail.gmail.com> <496D1D5D.8020602@voidspace.org.uk> <1dab55500901140415u39298362n231f6245aef3132d@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5005@NA-EXMSG-C116.redmond.corp.microsoft.com> <1dab55500901141404n78edc71bn5bce5c7b46453568@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BDF1B5157@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: Just curios... Has anyone had time to look at my sample yet? On Jan 14, 11:11?pm, Jimmy Schementi wrote: > Thanks, I'll take a look at it. > > > > > -----Original Message----- > > From: users-boun... at lists.ironpython.com [mailto:users- > > boun... at lists.ironpython.com] On Behalf Of Kristian Jaksch > > Sent: Wednesday, January 14, 2009 2:04 PM > > To: Discussion of IronPython > > Subject: Re: [IronPython] IronPython to JavaScript > > > Ok, here we go. I attach a MINIMAL sample for you guys :-) > > > It should just send a string from python to javascript and an alert > > message should show the string. > > > As I said. It must be something obvious I'm missing out here but my > > brain is locked for further thinking... > > > Anyway, thanks! > > > 2009/1/14 Jimmy Schementi : > > > A MINIMAL reproduction of the error would be appropriate =) > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dfugate at microsoft.com Mon Jan 26 21:29:35 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Mon, 26 Jan 2009 12:29:35 -0800 Subject: [IronPython] Help Decide Which IronPython Bugs Get Fixed for 2.0.1 Message-ID: As we plan on releasing IP 2.0.1 next month, this is a good opportunity to remind everyone that we primarily choose bugs to fix in patch releases based on the number of CodePlex votes the bugs have. In other words, if there's any particular IronPython bug you'd like to see fixed for 2.0.1, please vote for it on http://www.codeplex.com/IronPython/WorkItem/AdvancedList.aspx in the next couple of days. Thanks, The IronPython Team -------------- next part -------------- An HTML attachment was scrubbed... URL: From Kyle.Howland-Rose at aar.com.au Mon Jan 26 23:28:23 2009 From: Kyle.Howland-Rose at aar.com.au (Howland-Rose, Kyle) Date: Tue, 27 Jan 2009 09:28:23 +1100 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <4979fadf.0a04d00a.12c9.7e70@mx.google.com> References: <-402690530396885114@unknownmsgid> <4979fadf.0a04d00a.12c9.7e70@mx.google.com> Message-ID: Hi Antonio, Have you tried http://pychecker.sourceforge.net/? PyChecker attempts to report what would be compiler errors in compiled languages. I don't know whether it works with IronPython. Kyle ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ant?nio Piteira Sent: Saturday, 24 January 2009 4:14 AM To: users at lists.ironpython.com Subject: Re: [IronPython] IronPython 2.0 Errors... I get it, I'm not really surprised... I was hoping that maybe there was a way to use scriptSource.Compile(options,errorTracker), or something like that, and get the errors from errorTracker or some kind of sink. Very much apreciated for your time. ??????????????????___________________________________________________________________________________________________________________ Are you familiar with "the halting problem"? :) (http://en.wikipedia.org/wiki/Halting_problem) The only reliable way to find if a particular program returns a runtime error is to execute the program. For limited, targeted cases, (such as importing modules) you could write an analyzer program which would be *often* right -- but I could create a program that tricks your analyzer into reporting a problem where none exists. Consider this: import sys sys.modules['foo'] = type(sys)('foo') import foo Your static analyzer would have a tough time recognizing that this program would not raise a runtime error. ??????????????????___________________________________________________________________________________________________________________ Those things are run-time errors (failed imports et al). You would possibly look at the parse tree for any imports and determine if the modules to be imported exist, but that sounds like a lot of trouble :) slide ??????????????????___________________________________________________________________________________________________________________ On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira wrote: Hi, I'm trying get all runtime errors without actually executing the code. I can get all syntax errors using the parser, but runtime errors like "import ys" and stuff like that I', not able to. Is there any way to do this? Thanks, Vision _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ************************************************************************ Allens Arthur Robinson online: http://www.aar.com.au This email is confidential and may be subject to legal or other professional privilege. It is also subject to copyright. If you have received it in error, confidentiality and privilege are not waived and you must not disclose or use the information in it. Please notify the sender by return email and delete it from your system. Any personal information in this email must be handled in accordance with the Privacy Act 1988 (Cth). ************************************************************************* -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Tue Jan 27 00:08:06 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 26 Jan 2009 23:08:06 +0000 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: References: <-402690530396885114@unknownmsgid> <4979fadf.0a04d00a.12c9.7e70@mx.google.com> Message-ID: <497E4256.1000908@voidspace.org.uk> Howland-Rose, Kyle wrote: > Hi Antonio, > Have you tried http://pychecker.sourceforge.net/? > PyChecker attempts to report what would be compiler errors in compiled > languages. I don't know whether it works with IronPython. > PyLint works without having to import the code - so even though you run it under CPython it on IronPython code. http://www.logilab.org/project/pylint Another possibility is pyflakes which has the advantage of being very fast. http://divmod.org/trac/wiki/DivmodPyflakes Michael > Kyle > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Ant?nio Piteira > *Sent:* Saturday, 24 January 2009 4:14 AM > *To:* users at lists.ironpython.com > *Subject:* Re: [IronPython] IronPython 2.0 Errors... > > I get it, I?m not really surprised? I was hoping that maybe there was > a way to use scriptSource.Compile(options,errorTracker), or something > like that, and get the errors from errorTracker or some kind of sink. > > Very much apreciated for your time. > > ??????????????????___________________________________________________________________________________________________________________ > > Are you familiar with "the halting problem"? :) > (http://en.wikipedia.org/wiki/Halting_problem) > > > The only reliable way to find if a particular program returns a > runtime error is to execute the program. For limited, targeted cases, > (such as importing modules) you could write an analyzer program which > would be *often* right -- but I could create a program that tricks > your analyzer into reporting a problem where none exists. Consider this: > > import sys > > sys.modules['foo'] = type(sys)('foo') > > import foo > > Your static analyzer would have a tough time recognizing that this > program would not raise a runtime error. > > ??????????????????___________________________________________________________________________________________________________________ > > Those things are run-time errors (failed imports et al). You would > > possibly look at the parse tree for any imports and determine if the > > modules to be imported exist, but that sounds like a lot of trouble :) > > slide > > ??????????????????___________________________________________________________________________________________________________________ > > On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira > > > wrote: > > Hi, > > I'm trying get all runtime errors without actually executing the code. > I can get all syntax errors using the parser, but runtime errors like > "import ys" and stuff like that I', not able to. > > Is there any way to do this? > > Thanks, > > Vision > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > ************************************************************************ > > Allens Arthur Robinson online: http://www.aar.com.au > > This email is confidential and may be subject to legal or other > professional privilege. It is also subject to copyright. If you have > received it in error, confidentiality and privilege are not waived and > you must not disclose or use the information in it. Please notify the > sender by return email and delete it from your system. Any personal > information in this email must be handled in accordance with the > Privacy Act 1988 (Cth). > > ************************************************************************* > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 antonio.piteira at wtvision.com Tue Jan 27 13:57:04 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Tue, 27 Jan 2009 12:57:04 -0000 Subject: [IronPython] IronPython 2.0 Errors... In-Reply-To: <497E4256.1000908@voidspace.org.uk> References: <-402690530396885114@unknownmsgid> <4979fadf.0a04d00a.12c9.7e70@mx.google.com> <497E4256.1000908@voidspace.org.uk> Message-ID: <497f04a2.1c07d00a.033e.ffffe29f@mx.google.com> That?s great, new possibilities are always welcome. Thanks guys I will give it a try and let you know later on. ---------------------------------------------------------------------------- ------ Howland-Rose, Kyle wrote: > Hi Antonio, > Have you tried http://pychecker.sourceforge.net/? > PyChecker attempts to report what would be compiler errors in compiled > languages. I don't know whether it works with IronPython. > PyLint works without having to import the code - so even though you run it under CPython it on IronPython code. http://www.logilab.org/project/pylint Another possibility is pyflakes which has the advantage of being very fast. http://divmod.org/trac/wiki/DivmodPyflakes Michael > Kyle > > ------------------------------------------------------------------------ > *From:* users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] *On Behalf Of *Ant?nio Piteira > *Sent:* Saturday, 24 January 2009 4:14 AM > *To:* users at lists.ironpython.com > *Subject:* Re: [IronPython] IronPython 2.0 Errors... > > I get it, I?m not really surprised I was hoping that maybe there was > a way to use scriptSource.Compile(options,errorTracker), or something > like that, and get the errors from errorTracker or some kind of sink. > > Very much apreciated for your time. > > ??????????????????__________________________________________________________ _________________________________________________________ > > Are you familiar with "the halting problem"? :) > (http://en.wikipedia.org/wiki/Halting_problem) > > > The only reliable way to find if a particular program returns a > runtime error is to execute the program. For limited, targeted cases, > (such as importing modules) you could write an analyzer program which > would be *often* right -- but I could create a program that tricks > your analyzer into reporting a problem where none exists. Consider this: > > import sys > > sys.modules['foo'] = type(sys)('foo') > > import foo > > Your static analyzer would have a tough time recognizing that this > program would not raise a runtime error. > > ??????????????????__________________________________________________________ _________________________________________________________ > > Those things are run-time errors (failed imports et al). You would > > possibly look at the parse tree for any imports and determine if the > > modules to be imported exist, but that sounds like a lot of trouble :) > > slide > > ??????????????????__________________________________________________________ _________________________________________________________ > > On Fri, Jan 23, 2009 at 8:45 AM, Ant?nio Piteira > > > wrote: > > Hi, > > I'm trying get all runtime errors without actually executing the code. > I can get all syntax errors using the parser, but runtime errors like > "import ys" and stuff like that I', not able to. > > Is there any way to do this? > > Thanks, > > Vision > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > ************************************************************************ > > Allens Arthur Robinson online: http://www.aar.com.au > > This email is confidential and may be subject to legal or other > professional privilege. It is also subject to copyright. If you have > received it in error, confidentiality and privilege are not waived and > you must not disclose or use the information in it. Please notify the > sender by return email and delete it from your system. Any personal > information in this email must be handled in accordance with the > Privacy Act 1988 (Cth). > > ************************************************************************* > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 renaud.durand.it at gmail.com Tue Jan 27 18:12:01 2009 From: renaud.durand.it at gmail.com (Renaud Durand) Date: Tue, 27 Jan 2009 18:12:01 +0100 Subject: [IronPython] slow import time Message-ID: <8c5392700901270912t5667891ev17284409235a9e49@mail.gmail.com> Hi, I know it must be a recurrent question. But why IronPython startup time is so long ? I have a Winforms App that takes around 15s to start. The first import starts at about 10s, so importing modules takes about 5 seconds. I Know that the 10 first seconds seem to be incompressible... But is there something I should do or not do to reduce the import time ? Thank you. -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at microsoft.com Tue Jan 27 18:55:29 2009 From: dinov at microsoft.com (Dino Viehland) Date: Tue, 27 Jan 2009 09:55:29 -0800 Subject: [IronPython] slow import time In-Reply-To: <8c5392700901270912t5667891ev17284409235a9e49@mail.gmail.com> References: <8c5392700901270912t5667891ev17284409235a9e49@mail.gmail.com> Message-ID: <350E7D38B6D819428718949920EC2355571285E51F@NA-EXMSG-C102.redmond.corp.microsoft.com> Precompilation (see the pyc.py sample) + ngen is the best story here right now. The time is mostly spent compiling IL to native code. We're also working on fixing that on our side (which hopefully will make it into 2.6, but it's available in the source drops today under the -X:AdaptiveCompilation command line option). Other big costs include reflection (we do a lot of it) and creating new base types for subclasses of .NET types - both of which we also hope to try and address for the next release. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Renaud Durand Sent: Tuesday, January 27, 2009 9:12 AM To: Discussion of IronPython Subject: [IronPython] slow import time Hi, I know it must be a recurrent question. But why IronPython startup time is so long ? I have a Winforms App that takes around 15s to start. The first import starts at about 10s, so importing modules takes about 5 seconds. I Know that the 10 first seconds seem to be incompressible... But is there something I should do or not do to reduce the import time ? Thank you. -- Renaud Durand -------------- next part -------------- An HTML attachment was scrubbed... URL: From Steven.Janofsky at webloyalty.com Tue Jan 27 20:14:31 2009 From: Steven.Janofsky at webloyalty.com (Janofsky, Steven) Date: Tue, 27 Jan 2009 14:14:31 -0500 Subject: [IronPython] import issue Message-ID: Does anyone know why the following gives 'No module named re' error: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); ScriptSource src = engine.CreateScriptSourceFromString( "import re", Microsoft.Scripting.SourceCodeKind.Statements ); src.Execute( scope ); This transmission may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you, users at lists.ironpython.com, are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Tue Jan 27 20:17:04 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 27 Jan 2009 11:17:04 -0800 Subject: [IronPython] import issue In-Reply-To: References: Message-ID: The most likely explanation is that you're missing a reference to IronPython.Modules.dll. On Tue, Jan 27, 2009 at 11:14 AM, Janofsky, Steven < Steven.Janofsky at webloyalty.com> wrote: > Does anyone know why the following gives 'No module named re' error: > > > > ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); > > ScriptScope scope = engine.CreateScope(); > > ScriptSource src = engine.CreateScriptSourceFromString( "import re", > Microsoft.Scripting.SourceCodeKind.Statements ); > > src.Execute( scope ); > > This transmission may contain information that is privileged, confidential > and exempt from disclosure under applicable law. If you, > users at lists.ironpython.com, are not the intended recipient, you are hereby > notified that any disclosure, copying, distribution, or use of the > information contained herein (including any reliance thereon) is STRICTLY > PROHIBITED. If you received this transmission in error, please immediately > contact the sender and destroy the material in its entirety, whether in > electronic or hard copy format. [clavin.webloyalty.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 Tomas.Matousek at microsoft.com Tue Jan 27 22:04:55 2009 From: Tomas.Matousek at microsoft.com (Tomas Matousek) Date: Tue, 27 Jan 2009 13:04:55 -0800 Subject: [IronPython] import issue In-Reply-To: References: Message-ID: BTW, I've submitted a change recently (it should be already available on CodePlex) that allows you to simplify the below code to: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); engine.Execute("import re", scope); or if you don't need to inspect the scope you can omit it as well: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); engine.Execute("import re"); The Execute method now uses SourceCodeKind.AutoDetect as a default value. Python parser recognizes this new value and parses the code regardless of whether it is an expression, a single statement or multiple statements. The value returned by Execute is either the value of the expression (if the code is in fact an expression), the value of the last expression statement (if available) or null otherwise. You can still use an explicit parameter to CreateScriptSourceFromString that restricts the kind to expression, statement, etc. Tomas From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 27, 2009 11:17 AM To: Discussion of IronPython Subject: Re: [IronPython] import issue The most likely explanation is that you're missing a reference to IronPython.Modules.dll. On Tue, Jan 27, 2009 at 11:14 AM, Janofsky, Steven wrote: Does anyone know why the following gives 'No module named re' error: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); ScriptSource src = engine.CreateScriptSourceFromString( "import re", Microsoft.Scripting.SourceCodeKind.Statements ); src.Execute( scope ); This transmission may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you, users at lists.ironpython.com, are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. [clavin.webloyalty.com] _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jslutter at reactorzero.com Wed Jan 28 04:52:57 2009 From: jslutter at reactorzero.com (Jeff Slutter) Date: Tue, 27 Jan 2009 22:52:57 -0500 Subject: [IronPython] Printing an object out as a string Message-ID: <497FD699.4030801@reactorzero.com> Given an object, how can I go about printing out that object as a string representing the object in Python syntax? I need something a little more powerful than just object.ToString() I need something like how the interactive console reports the result of the statement. For instance: a = [0,1,2] b = [a,8,9] If I pass 'b' to a function in C#, like: void SomeFunction( object obj ) { string objStr = ConvertToString( obj ); Console.Write( objStr ); } it would print out: [[0,1,2],8,9] Obviously ToString() will work for simple things, but once I try to use lists or dictionaries it no longer works. Thank you, Jeff From Jimmy.Schementi at microsoft.com Wed Jan 28 04:55:56 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Tue, 27 Jan 2009 19:55:56 -0800 Subject: [IronPython] Printing an object out as a string In-Reply-To: <497FD699.4030801@reactorzero.com> References: <497FD699.4030801@reactorzero.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284BE64EE37E@NA-EXMSG-C116.redmond.corp.microsoft.com> repr([0,1,2]) > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Jeff Slutter > Sent: Tuesday, January 27, 2009 7:53 PM > To: Discussion of IronPython > Subject: [IronPython] Printing an object out as a string > > Given an object, how can I go about printing out that object as a > string > representing the object in Python syntax? > > I need something a little more powerful than just object.ToString() > > I need something like how the interactive console reports the result of > the statement. > > For instance: > > a = [0,1,2] > b = [a,8,9] > > If I pass 'b' to a function in C#, like: > > void SomeFunction( object obj ) > { > string objStr = ConvertToString( obj ); > Console.Write( objStr ); > } > > it would print out: > [[0,1,2],8,9] > > Obviously ToString() will work for simple things, but once I try to use > lists or dictionaries it no longer works. > > Thank you, > Jeff > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From curt at hagenlocher.org Wed Jan 28 05:13:06 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 27 Jan 2009 20:13:06 -0800 Subject: [IronPython] Printing an object out as a string In-Reply-To: <497FD699.4030801@reactorzero.com> References: <497FD699.4030801@reactorzero.com> Message-ID: If you're willing to live on the bleeding edge and build from the latest sources, it turns out that Tomas just added this functionality to the hosting interfaces yesterday. ObjectOperations.Format(obj) should return a string that matches what the REPL would have printed. On Tue, Jan 27, 2009 at 7:52 PM, Jeff Slutter wrote: > Given an object, how can I go about printing out that object as a string > representing the object in Python syntax? > > I need something a little more powerful than just object.ToString() > > I need something like how the interactive console reports the result of > the statement. > > For instance: > > a = [0,1,2] > b = [a,8,9] > > If I pass 'b' to a function in C#, like: > > void SomeFunction( object obj ) > { > string objStr = ConvertToString( obj ); > Console.Write( objStr ); > } > > it would print out: > [[0,1,2],8,9] > > Obviously ToString() will work for simple things, but once I try to use > lists or dictionaries it no longer works. > > Thank you, > Jeff > _______________________________________________ > 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 Tomas.Matousek at microsoft.com Wed Jan 28 05:14:40 2009 From: Tomas.Matousek at microsoft.com (Tomas Matousek) Date: Tue, 27 Jan 2009 20:14:40 -0800 Subject: [IronPython] Printing an object out as a string In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A3284BE64EE37E@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <497FD699.4030801@reactorzero.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284BE64EE37E@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: If you need to call it from C# app you can use engine.ObjectOperations.Format(obj) where "engine" could be created like this: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); ObjectOperations::Format calls "repr". Tomas -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jimmy Schementi Sent: Tuesday, January 27, 2009 7:56 PM To: Discussion of IronPython Subject: Re: [IronPython] Printing an object out as a string repr([0,1,2]) > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Jeff Slutter > Sent: Tuesday, January 27, 2009 7:53 PM > To: Discussion of IronPython > Subject: [IronPython] Printing an object out as a string > > Given an object, how can I go about printing out that object as a > string > representing the object in Python syntax? > > I need something a little more powerful than just object.ToString() > > I need something like how the interactive console reports the result of > the statement. > > For instance: > > a = [0,1,2] > b = [a,8,9] > > If I pass 'b' to a function in C#, like: > > void SomeFunction( object obj ) > { > string objStr = ConvertToString( obj ); > Console.Write( objStr ); > } > > it would print out: > [[0,1,2],8,9] > > Obviously ToString() will work for simple things, but once I try to use > lists or dictionaries it no longer works. > > Thank you, > Jeff > _______________________________________________ > 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 jslutter at reactorzero.com Wed Jan 28 05:41:10 2009 From: jslutter at reactorzero.com (Jeff Slutter) Date: Tue, 27 Jan 2009 23:41:10 -0500 Subject: [IronPython] Printing an object out as a string In-Reply-To: References: <497FD699.4030801@reactorzero.com> Message-ID: <497FE1E6.1090407@reactorzero.com> Curt Hagenlocher wrote: > If you're willing to live on the bleeding edge and build from the latest > sources, it turns out that Tomas just added this functionality to the > hosting interfaces yesterday. ObjectOperations.Format(obj) should return > a string that matches what the REPL would have printed. I have no problem with living on the bleeding edge. But I realized why repr wasn't working so well for me: In a nutshell, I need to get the Python function call string that was made (including arguments), for logging purposes. The functions are in my C# code, the calls are made from Python. I can get the name of the function through some means, but the arguments are the part I've having a hard time with. I can make the assumption that the arguments being passed into the function have a textual representation. So, if I have a function in C# like: void MyFunc( IEnumerable someList ) { string someListAsStr = SomeMagicFunction(someList); Log( someListAsStr ); } and in Python I call it like: a = [0,1,2] MyFunc( a ) I want to log the string "[0,1,2]" repr wasn't working for me, I believe, because once I get inside MyFunc, IronPython has wrapped and converted the PythonList into this IEnumerable I have. So, repr was giving me something not so pretty. Will the new Format function give me what I want? Or should I continue down a different path? Thanks, Jeff From sh at defuze.org Wed Jan 28 15:15:18 2009 From: sh at defuze.org (Sylvain Hellegouarch) Date: Wed, 28 Jan 2009 15:15:18 +0100 (CET) Subject: [IronPython] XMPP support in IronPython 2 Message-ID: <59853.195.101.247.164.1233152118.squirrel@mail1.webfaction.com> Hi all, I am glad to announce that IronPython 2 is now capable of running my XMPP Python library: headstock [1]. .NET has already an excellent XMPP SDK called agsXMPP [2] that is a native .NET/C# framework. However I'm a Python developers at heart and I had started quite a while ago writing my own XMPP library in Python using the most excellent Kamaelia framework (designed for concurrency). For a while IronPython had severe shortcomings that prevented it running simple Kamaelia applications. Today I was able to run a simplechat demo using a vanilla IP2 on Windows with only one single modification to the logging module (thanks Seo). To be honest I didn't expect it to go through :) The chat demo is simple enough but means more complex examples using XMPP PubSub will work as well (they are all based on the same framework). Now this isn't production ready or anything. For instance the TLS support is broken (hopefully something easy enough to fix) so you won't be able to connect to Google Talk for now. Moreover I'm not sure the code is that fast considering how I had to simulate an incremental XML parser [3] atop System.Xml (this allows for a XML stream to be parsed without requiring the full document or even fragment to be read first). This is a great news for me because it means i'll be able to move ahead with more work using IronPython 2. Thanks again, - Sylvain [1] http://trac.defuze.org/wiki/headstock#RunningthesimplechatdemoonIronPython2 [2] http://www.ag-software.de/index.php?page=agsxmpp-sdk [3] https://svn.defuze.org/oss/bridge/bridge/parser/bridge_dotnet.py -- Sylvain Hellegouarch http://www.defuze.org From curt at hagenlocher.org Wed Jan 28 18:37:02 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Wed, 28 Jan 2009 09:37:02 -0800 Subject: [IronPython] Printing an object out as a string In-Reply-To: <497FE1E6.1090407@reactorzero.com> References: <497FD699.4030801@reactorzero.com> <497FE1E6.1090407@reactorzero.com> Message-ID: If you're doing the logging from within C#, then there's no way to recover the originally-passed Python object if the binder has had to perform a conversion -- as it will have in this case. On Tue, Jan 27, 2009 at 8:41 PM, Jeff Slutter wrote: > Curt Hagenlocher wrote: > > If you're willing to live on the bleeding edge and build from the latest > > sources, it turns out that Tomas just added this functionality to the > > hosting interfaces yesterday. ObjectOperations.Format(obj) should return > > a string that matches what the REPL would have printed. > > I have no problem with living on the bleeding edge. But I realized why > repr wasn't working so well for me: > > In a nutshell, I need to get the Python function call string that was > made (including arguments), for logging purposes. The functions are in > my C# code, the calls are made from Python. > > I can get the name of the function through some means, but the arguments > are the part I've having a hard time with. I can make the assumption > that the arguments being passed into the function have a textual > representation. > > So, if I have a function in C# like: > > void MyFunc( IEnumerable someList ) > { > string someListAsStr = SomeMagicFunction(someList); > Log( someListAsStr ); > } > > > and in Python I call it like: > > a = [0,1,2] > MyFunc( a ) > > > I want to log the string "[0,1,2]" > > repr wasn't working for me, I believe, because once I get inside MyFunc, > IronPython has wrapped and converted the PythonList into this > IEnumerable I have. So, repr was giving me something not so pretty. > > Will the new Format function give me what I want? Or should I continue > down a different path? > > Thanks, > Jeff > _______________________________________________ > 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 william at resolversystems.com Thu Jan 29 12:43:04 2009 From: william at resolversystems.com (William Reade) Date: Thu, 29 Jan 2009 11:43:04 +0000 Subject: [IronPython] Ironclad 0.8 released Message-ID: <49819648.4000206@resolversystems.com> Hi all I'm delighted to announce the release of Ironclad v0.8 -- the all-singing, all-dancing CPython API compatibility layer for IronPython -- available now from http://code.google.com/p/ironclad/ . Notable improvements over the last release include: * Ironclad is now a neatly self-contained package -- just copy to your site-packages and 'import ironclad'. * No more silly requirement to call ironclad.shutdown() when you're finished. * A few performance improvements. * Over 900 NumPy tests now pass: in fact, almost all the tests from the core, fft, lib, linalg, ma, oldnumeric and random subpackages. * Over half the .pyds distributed with CPython 2.5 now import cleanly; some of them appear to actually work, including _hashlib and _elementtree. Ironclad grows more stable and mature with every release, and I urge IronPython users to try it out and share their impressions: feedback, whether positive or negative, is always welcomed. Cheers William From dans at houmus.org Thu Jan 29 13:37:01 2009 From: dans at houmus.org (Dan Shechter) Date: Thu, 29 Jan 2009 14:37:01 +0200 Subject: [IronPython] Ironclad 0.8 released In-Reply-To: <49819648.4000206@resolversystems.com> References: <49819648.4000206@resolversystems.com> Message-ID: <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> Congratulations... Is x64 fully supported? Shechter. On 29/01/2009, at 13:43, William Reade wrote: > Hi all > > I'm delighted to announce the release of Ironclad v0.8 -- the all- > singing, all-dancing CPython API compatibility layer for IronPython > -- available now from http://code.google.com/p/ironclad/ . Notable > improvements over the last release include: > > * Ironclad is now a neatly self-contained package -- just copy to > your site-packages and 'import ironclad'. > * No more silly requirement to call ironclad.shutdown() when you're > finished. > * A few performance improvements. > * Over 900 NumPy tests now pass: in fact, almost all the tests from > the core, fft, lib, linalg, ma, oldnumeric and random subpackages. > * Over half the .pyds distributed with CPython 2.5 now import > cleanly; some of them appear to actually work, including _hashlib > and _elementtree. > > Ironclad grows more stable and mature with every release, and I urge > IronPython users to try it out and share their impressions: > feedback, whether positive or negative, is always welcomed. > > Cheers > William > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From william at resolversystems.com Thu Jan 29 14:12:34 2009 From: william at resolversystems.com (William Reade) Date: Thu, 29 Jan 2009 13:12:34 +0000 Subject: [IronPython] Ironclad 0.8 released In-Reply-To: <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> Message-ID: <4981AB42.2000201@resolversystems.com> Still no x64, although the necessary supporting changes are gradually creeping in. I can't give you a timescale, I'm afraid, but every person who asks me about it pushes it up my priority list :-). Dan Shechter wrote: > Congratulations... > > Is x64 fully supported? > > Shechter. > > On 29/01/2009, at 13:43, William Reade > wrote: > >> Hi all >> >> I'm delighted to announce the release of Ironclad v0.8 -- the >> all-singing, all-dancing CPython API compatibility layer for >> IronPython -- available now from http://code.google.com/p/ironclad/ . >> Notable improvements over the last release include: >> >> * Ironclad is now a neatly self-contained package -- just copy to >> your site-packages and 'import ironclad'. >> * No more silly requirement to call ironclad.shutdown() when you're >> finished. >> * A few performance improvements. >> * Over 900 NumPy tests now pass: in fact, almost all the tests from >> the core, fft, lib, linalg, ma, oldnumeric and random subpackages. >> * Over half the .pyds distributed with CPython 2.5 now import >> cleanly; some of them appear to actually work, including _hashlib and >> _elementtree. >> >> Ironclad grows more stable and mature with every release, and I urge >> IronPython users to try it out and share their impressions: feedback, >> whether positive or negative, is always welcomed. >> >> Cheers >> William >> _______________________________________________ >> 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 empirebuilder at gmail.com Thu Jan 29 15:06:11 2009 From: empirebuilder at gmail.com (Dody Gunawinata) Date: Thu, 29 Jan 2009 16:06:11 +0200 Subject: [IronPython] Ironclad 0.8 released In-Reply-To: <4981AB42.2000201@resolversystems.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> Message-ID: <8cd017b80901290606g5ef23a6ajdb070500da124ec7@mail.gmail.com> One more encouragement :) x64 support is important now that people are migrating to Windows Server 2008 hypervisor VMs to run the web application. Dody G. On Thu, Jan 29, 2009 at 3:12 PM, William Reade wrote: > Still no x64, although the necessary supporting changes are gradually > creeping in. I can't give you a timescale, I'm afraid, but every person who > asks me about it pushes it up my priority list :-). > > > Dan Shechter wrote: > >> Congratulations... >> >> Is x64 fully supported? >> >> Shechter. >> >> On 29/01/2009, at 13:43, William Reade >> wrote: >> >> Hi all >>> >>> I'm delighted to announce the release of Ironclad v0.8 -- the >>> all-singing, all-dancing CPython API compatibility layer for IronPython -- >>> available now from http://code.google.com/p/ironclad/ . Notable >>> improvements over the last release include: >>> >>> * Ironclad is now a neatly self-contained package -- just copy to your >>> site-packages and 'import ironclad'. >>> * No more silly requirement to call ironclad.shutdown() when you're >>> finished. >>> * A few performance improvements. >>> * Over 900 NumPy tests now pass: in fact, almost all the tests from the >>> core, fft, lib, linalg, ma, oldnumeric and random subpackages. >>> * Over half the .pyds distributed with CPython 2.5 now import cleanly; >>> some of them appear to actually work, including _hashlib and _elementtree. >>> >>> Ironclad grows more stable and mature with every release, and I urge >>> IronPython users to try it out and share their impressions: feedback, >>> whether positive or negative, is always welcomed. >>> >>> Cheers >>> William >>> _______________________________________________ >>> 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 > -- nomadlife.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Thu Jan 29 15:07:18 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 29 Jan 2009 14:07:18 +0000 Subject: [IronPython] Ironclad 0.8 released In-Reply-To: <8cd017b80901290606g5ef23a6ajdb070500da124ec7@mail.gmail.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> <8cd017b80901290606g5ef23a6ajdb070500da124ec7@mail.gmail.com> Message-ID: <4981B816.8020103@voidspace.org.uk> Dody Gunawinata wrote: > One more encouragement :) > > x64 support is important now that people are migrating to Windows > Server 2008 hypervisor VMs to run the web application. Contributions welcomed. :-) Michael > > Dody G. > > On Thu, Jan 29, 2009 at 3:12 PM, William Reade > > wrote: > > Still no x64, although the necessary supporting changes are > gradually creeping in. I can't give you a timescale, I'm afraid, > but every person who asks me about it pushes it up my priority > list :-). > > > Dan Shechter wrote: > > Congratulations... > > Is x64 fully supported? > > Shechter. > > On 29/01/2009, at 13:43, William Reade > > wrote: > > Hi all > > I'm delighted to announce the release of Ironclad v0.8 -- > the all-singing, all-dancing CPython API compatibility > layer for IronPython -- available now from > http://code.google.com/p/ironclad/ . Notable improvements > over the last release include: > > * Ironclad is now a neatly self-contained package -- just > copy to your site-packages and 'import ironclad'. > * No more silly requirement to call ironclad.shutdown() > when you're finished. > * A few performance improvements. > * Over 900 NumPy tests now pass: in fact, almost all the > tests from the core, fft, lib, linalg, ma, oldnumeric and > random subpackages. > * Over half the .pyds distributed with CPython 2.5 now > import cleanly; some of them appear to actually work, > including _hashlib and _elementtree. > > Ironclad grows more stable and mature with every release, > and I urge IronPython users to try it out and share their > impressions: feedback, whether positive or negative, is > always welcomed. > > Cheers > William > _______________________________________________ > 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 > > > > > -- > nomadlife.org > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 jslutter at reactorzero.com Thu Jan 29 19:24:03 2009 From: jslutter at reactorzero.com (Jeff Slutter) Date: Thu, 29 Jan 2009 13:24:03 -0500 Subject: [IronPython] Handling the import of scripts Message-ID: <4981F443.9010409@reactorzero.com> If there a way for me to intercept when IronPython wants to import a script, so I can provide the script text through my own ways. I have a situation where my Python files are not files on the disk, but packed into a zip file. When I go to run a script I can get the source to IronPython to run, but, if that script imports another script that is also in the zip file, I would like to go through my methods of resolving the file, loading it, and passing it back to IronPython. -Jeff From Jimmy.Schementi at microsoft.com Thu Jan 29 19:39:10 2009 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Thu, 29 Jan 2009 10:39:10 -0800 Subject: [IronPython] Handling the import of scripts In-Reply-To: <4981F443.9010409@reactorzero.com> References: <4981F443.9010409@reactorzero.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284BE64EEB02@NA-EXMSG-C116.redmond.corp.microsoft.com> I'm not sure of a way directly from IronPython, but if you're hosting IronPython you can define your own PlatformAdaptationLayer, which is used to re-define platformy things like import. Here's some info on how to do that: http://www.mail-archive.com/users at lists.ironpython.com/msg06079.html. And here's the PlatformAdaptationLayer I use in AgDLR, for looking in a zip file when import is called: http://github.com/jschementi/agdlr/blob/61ee0134167a546a55cf138ef63edc5d7eb4b830/src/Microsoft.Scripting.Silverlight/BrowserPAL.cs ~js > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Jeff Slutter > Sent: Thursday, January 29, 2009 10:24 AM > To: Discussion of IronPython > Subject: [IronPython] Handling the import of scripts > > If there a way for me to intercept when IronPython wants to import a > script, so I can provide the script text through my own ways. I have a > situation where my Python files are not files on the disk, but packed > into a zip file. When I go to run a script I can get the source to > IronPython to run, but, if that script imports another script that is > also in the zip file, I would like to go through my methods of > resolving > the file, loading it, and passing it back to IronPython. > > -Jeff > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dfugate at microsoft.com Thu Jan 29 20:03:04 2009 From: dfugate at microsoft.com (Dave Fugate) Date: Thu, 29 Jan 2009 11:03:04 -0800 Subject: [IronPython] Handling the import of scripts In-Reply-To: <4981F443.9010409@reactorzero.com> References: <4981F443.9010409@reactorzero.com> Message-ID: Look into using sys.path_hooks and sys.meta_path (see http://www.python.org/dev/peps/pep-0302/). Dave -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Slutter Sent: Thursday, January 29, 2009 10:24 AM To: Discussion of IronPython Subject: [IronPython] Handling the import of scripts If there a way for me to intercept when IronPython wants to import a script, so I can provide the script text through my own ways. I have a situation where my Python files are not files on the disk, but packed into a zip file. When I go to run a script I can get the source to IronPython to run, but, if that script imports another script that is also in the zip file, I would like to go through my methods of resolving the file, loading it, and passing it back to IronPython. -Jeff _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Steven.Janofsky at webloyalty.com Thu Jan 29 23:37:18 2009 From: Steven.Janofsky at webloyalty.com (Janofsky, Steven) Date: Thu, 29 Jan 2009 17:37:18 -0500 Subject: [IronPython] import issue In-Reply-To: References: Message-ID: After adding a reference to IronPython.Modules.dll assembly, it seemed to work. This is the structure of my app: Service.exe Which contains a reference to Assembly1 Which contains a reference to Assembly2 Which contains a reference to Assembly3 that has a reference to IronPython.dll and IronPython.Modules.dll For some reason, I had to add IronPython.dll and IronPython.Modules.dll assemblies to Service.exe. Any ideas why? ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 27, 2009 2:17 PM To: Discussion of IronPython Subject: Re: [IronPython] import issue The most likely explanation is that you're missing a reference to IronPython.Modules.dll. On Tue, Jan 27, 2009 at 11:14 AM, Janofsky, Steven wrote: Does anyone know why the following gives 'No module named re' error: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); ScriptSource src = engine.CreateScriptSourceFromString( "import re", Microsoft.Scripting.SourceCodeKind.Statements ); src.Execute( scope ); This transmission may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you, users at lists.ironpython.com, are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. [clavin.webloyalty.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 dan.eloff at gmail.com Fri Jan 30 01:38:13 2009 From: dan.eloff at gmail.com (Dan Eloff) Date: Thu, 29 Jan 2009 19:38:13 -0500 Subject: [IronPython] IronPython, stack frames and pdb In-Reply-To: <4975C75A.8030103@voidspace.org.uk> References: <4975C75A.8030103@voidspace.org.uk> Message-ID: <4817b6fc0901291638r5ec34786l44e23f6ef533b4a@mail.gmail.com> Vote on it here: http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20905 -Dan On Tue, Jan 20, 2009 at 7:45 AM, Michael Foord wrote: > Hello Dino, Curt et al., > > If stack frames are implemented as an option in IronPython it would be > *really* nice to enable sys.set_trace when they are on. Plus any other APIs > not currently implemented that are needed by pdb. Doing CPython development > again I've been reminded how insanely useful pdb is. :-) > > What would be really nice is to enable stack frames on a per engine / > runtime basis so that we could allow the setting of break-points and > debugging of Resolver One user code. > > Michael > > -- > http://www.ironpythoninaction.com/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From ddicato at microsoft.com Fri Jan 30 02:34:56 2009 From: ddicato at microsoft.com (David DiCato) Date: Thu, 29 Jan 2009 17:34:56 -0800 Subject: [IronPython] import issue In-Reply-To: References: Message-ID: IronPython.dll represents IronPython's core functionality, including the compiler and runtime elements such as builtin types and exceptions. IronPython.Modules.dll can be thought of as a portion of the standard lib; it contains most of the builtin modules such as re that would be imported from IronPython. HTH From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Janofsky, Steven Sent: Thursday, January 29, 2009 2:37 PM To: Discussion of IronPython Subject: Re: [IronPython] import issue After adding a reference to IronPython.Modules.dll assembly, it seemed to work. This is the structure of my app: Service.exe Which contains a reference to Assembly1 Which contains a reference to Assembly2 Which contains a reference to Assembly3 that has a reference to IronPython.dll and IronPython.Modules.dll For some reason, I had to add IronPython.dll and IronPython.Modules.dll assemblies to Service.exe. Any ideas why? ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Tuesday, January 27, 2009 2:17 PM To: Discussion of IronPython Subject: Re: [IronPython] import issue The most likely explanation is that you're missing a reference to IronPython.Modules.dll. On Tue, Jan 27, 2009 at 11:14 AM, Janofsky, Steven > wrote: Does anyone know why the following gives 'No module named re' error: ScriptEngine engine = IronPython.Hosting.Python.CreateEngine(); ScriptScope scope = engine.CreateScope(); ScriptSource src = engine.CreateScriptSourceFromString( "import re", Microsoft.Scripting.SourceCodeKind.Statements ); src.Execute( scope ); This transmission may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you, users at lists.ironpython.com, are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. [clavin.webloyalty.com] _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com This transmission may contain information that is privileged, confidential and exempt from disclosure under applicable law. If you, users at lists.ironpython.com, are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. [clavin.webloyalty.com] -------------- next part -------------- An HTML attachment was scrubbed... URL: From seob at gmx.ch Fri Jan 30 16:32:09 2009 From: seob at gmx.ch (Severin) Date: Fri, 30 Jan 2009 16:32:09 +0100 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: <4975FDD3.1040501@voidspace.org.uk> References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> Message-ID: Hello, I'm digging out this thread again. I'm trying to run python scripts from C# using the DLR. Simple examples work, namely if I have just one function in one python file. How does it work when one python file imports from another python file? I get "No module named x" ImportExceptions when trying to compile these python files. I compile the main-file with 'CreateScriptSourceFromFile'. May be I am using the wrong approach in general. What I have is a bunch of python files that I used with CPython directly so far. Now I want to extend my program with C# (since database handling is much more convenient there) and I want to use the python files that I already have. What is the best approach for this scenario? Thanks for any kind of hint. Severin On Tue, Jan 20, 2009 at 5:37 PM, Michael Foord wrote: > Renaud Durand wrote: > >> Ok, Thank you. >> >> Does anyone know where could I find an IronPython Assembly documentation >> and/or up to date tutorials ? >> > > These tutorials are up to date - except for the one specified as being for > IP1: > > http://www.voidspace.org.uk/ironpython/embedding.shtml > > Michael > >> >> Thank you again. >> >> 2009/1/20 Curt Hagenlocher > curt at hagenlocher.org>> >> >> I believe this was valid for a long-ago alpha. For the 2.0 >> release, you'll want to create an engine by saying >> engine = Python.CreateEngine() >> >> On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand > @gmail.com > wrote: >> >> Hi, >> >> I want to use IronPython function through C#. To do It, I >> found a tutorial at >> http://www.ironpython.info/index.php/Hosting_IronPython_2. >> But the code does not seem to be updated for IronPython 2.0. >> >> the code is : >> >> using System; >> using IronPython.Hosting; >> using IronPython.Runtime; >> using Microsoft.Scripting; >> using Microsoft.Scripting.Hosting; >> >> namespace EmbeddedCalculator >> { >> public class Engine >> { >> private ScriptEngine engine; >> >> public Engine() >> { >> engine = PythonEngine.CurrentEngine; >> } >> >> public string calculate(string input) >> { >> try >> { >> ScriptSource source = >> engine.CreateScriptSourceFromString(input, "py"); >> return source.Execute().ToString(); >> } >> catch >> { >> return "Error"; >> } >> } >> >> } >> } >> // End of code >> >> When I try to compile it in visual studio, the compiler could >> not find the name "PythonEngine". I have added all the >> references to >> the needed libraries. So, what am I missing ? >> >> >> Thank you :-). >> >> -- Renaud Durand >> >> _______________________________________________ >> 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 >> >> >> >> >> -- >> Renaud Durand >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Fri Jan 30 16:56:25 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 30 Jan 2009 15:56:25 +0000 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> Message-ID: <49832329.80909@voidspace.org.uk> Severin wrote: > Hello, > > I'm digging out this thread again. > > I'm trying to run python scripts from C# using the DLR. > > Simple examples work, namely if I have just one function in one python > file. > > How does it work when one python file imports from another python > file? I get "No module named x" ImportExceptions when trying to > compile these python files. If you're running them from '.py' source files then you aren't compiling them - you're just executing them from an embedded environment. The import machinery should work exactly the same as for CPython, but you may need to setup the initial sys.path depending on how you are executing the scripts. You probably need to use the engine.SetSearchPaths method passing in an array with the path to the directory containing the top level Python file (adding any other directories that you need to be able to import from). HTH Michael > > I compile the main-file with 'CreateScriptSourceFromFile'. > > > May be I am using the wrong approach in general. What I have is a > bunch of python files that I used with CPython directly so far. Now I > want to extend my program with C# (since database handling is much > more convenient there) and I want to use the python files that I > already have. > > What is the best approach for this scenario? > > Thanks for any kind of hint. > > Severin > > On Tue, Jan 20, 2009 at 5:37 PM, Michael Foord > > wrote: > > Renaud Durand wrote: > > Ok, Thank you. > > Does anyone know where could I find an IronPython Assembly > documentation and/or up to date tutorials ? > > > These tutorials are up to date - except for the one specified as > being for IP1: > > http://www.voidspace.org.uk/ironpython/embedding.shtml > > Michael > > > Thank you again. > > 2009/1/20 Curt Hagenlocher >> > > > I believe this was valid for a long-ago alpha. For the 2.0 > release, you'll want to create an engine by saying > engine = Python.CreateEngine() > > On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand > > @gmail.com > > wrote: > > Hi, > > I want to use IronPython function through C#. To do It, I > found a tutorial at > http://www.ironpython.info/index.php/Hosting_IronPython_2. > But the code does not seem to be updated for IronPython > 2.0. > > the code is : > > using System; > using IronPython.Hosting; > using IronPython.Runtime; > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > namespace EmbeddedCalculator > { > public class Engine > { > private ScriptEngine engine; > > public Engine() > { > engine = PythonEngine.CurrentEngine; > } > > public string calculate(string input) > { > try > { > ScriptSource source = > engine.CreateScriptSourceFromString(input, "py"); > return source.Execute().ToString(); > } > catch > { > return "Error"; > } > } > > } > } > // End of code > > When I try to compile it in visual studio, the compiler > could > not find the name "PythonEngine". I have added all the > references to > the needed libraries. So, what am I missing ? > > > Thank you :-). > > -- Renaud Durand > > _______________________________________________ > 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 > > > > > -- > Renaud Durand > ------------------------------------------------------------------------ > > > > _______________________________________________ > 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 > > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From seob at gmx.ch Fri Jan 30 18:01:47 2009 From: seob at gmx.ch (Severin) Date: Fri, 30 Jan 2009 18:01:47 +0100 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: <49832329.80909@voidspace.org.uk> References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> Message-ID: Good point! I forgot that I was having the *.py files in a subdirectory. Is it also possible to set the 'current' directory for the engine? For instance I would like to have the engine living in a subfolder of my project and then all path's would be relative to this subfolder. thank you, Severin On Fri, Jan 30, 2009 at 4:56 PM, Michael Foord wrote: > Severin wrote: > >> Hello, >> >> I'm digging out this thread again. >> >> I'm trying to run python scripts from C# using the DLR. >> >> Simple examples work, namely if I have just one function in one python >> file. >> >> How does it work when one python file imports from another python file? I >> get "No module named x" ImportExceptions when trying to compile these python >> files. >> > > If you're running them from '.py' source files then you aren't compiling > them - you're just executing them from an embedded environment. > > The import machinery should work exactly the same as for CPython, but you > may need to setup the initial sys.path depending on how you are executing > the scripts. > > You probably need to use the engine.SetSearchPaths method passing in an > array with the path to the directory containing the top level Python file > (adding any other directories that you need to be able to import from). > > HTH > > Michael > > >> I compile the main-file with 'CreateScriptSourceFromFile'. >> >> >> May be I am using the wrong approach in general. What I have is a bunch of >> python files that I used with CPython directly so far. Now I want to extend >> my program with C# (since database handling is much more convenient there) >> and I want to use the python files that I already have. >> >> What is the best approach for this scenario? >> >> Thanks for any kind of hint. >> >> Severin >> >> On Tue, Jan 20, 2009 at 5:37 PM, Michael Foord > fuzzyman at voidspace.org.uk>> wrote: >> >> Renaud Durand wrote: >> >> Ok, Thank you. >> >> Does anyone know where could I find an IronPython Assembly >> documentation and/or up to date tutorials ? >> >> >> These tutorials are up to date - except for the one specified as >> being for IP1: >> >> http://www.voidspace.org.uk/ironpython/embedding.shtml >> >> Michael >> >> >> Thank you again. >> >> 2009/1/20 Curt Hagenlocher > > >> >> >> >> >> I believe this was valid for a long-ago alpha. For the 2.0 >> release, you'll want to create an engine by saying >> engine = Python.CreateEngine() >> >> On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand >> >> @gmail.com >> > wrote: >> >> Hi, >> >> I want to use IronPython function through C#. To do It, I >> found a tutorial at >> http://www.ironpython.info/index.php/Hosting_IronPython_2. >> But the code does not seem to be updated for IronPython >> 2.0. >> >> the code is : >> >> using System; >> using IronPython.Hosting; >> using IronPython.Runtime; >> using Microsoft.Scripting; >> using Microsoft.Scripting.Hosting; >> >> namespace EmbeddedCalculator >> { >> public class Engine >> { >> private ScriptEngine engine; >> >> public Engine() >> { >> engine = PythonEngine.CurrentEngine; >> } >> >> public string calculate(string input) >> { >> try >> { >> ScriptSource source = >> engine.CreateScriptSourceFromString(input, "py"); >> return source.Execute().ToString(); >> } >> catch >> { >> return "Error"; >> } >> } >> >> } >> } >> // End of code >> >> When I try to compile it in visual studio, the compiler >> could >> not find the name "PythonEngine". I have added all the >> references to >> the needed libraries. So, what am I missing ? >> >> >> Thank you :-). >> >> -- Renaud Durand >> >> _______________________________________________ >> 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 >> >> >> >> >> -- Renaud Durand >> >> ------------------------------------------------------------------------ >> >> >> >> _______________________________________________ >> 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 >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 kristian.jaksch at gmail.com Fri Jan 30 18:08:58 2009 From: kristian.jaksch at gmail.com (Kristian) Date: Fri, 30 Jan 2009 09:08:58 -0800 (PST) Subject: [IronPython] Overflow error with C# dll Message-ID: <14bc5818-eccc-46df-8539-b3fba2f9c0ec@y1g2000pra.googlegroups.com> I've created a C# dll that I call from Ironpython (Silverlight) application. I receive an Overflow error when I call it but I can't see that anything is wrong. Everything works as expected. The error is below: "OverflowError: Arithmetic operation resulted in an overflow." But when I call the same dll from a C#-project I don't get any errors. The method I call in the dll is the below: "public int[,] CalculatePlotSettings(double canvasWidth, double canvasHeight, double[] values)" I make the call as it looks below: p = Plot() coords = p.CalculatePlotSettings(root._parentCanvas.ActualWidth, root._parentCanvas.ActualHeight, array) The "array" is of type "System.Array.CreateInstance(System.Double, 50)" Does anyone have a clue why this error occurs? Thanks for help! From slide.o.mix at gmail.com Fri Jan 30 18:16:19 2009 From: slide.o.mix at gmail.com (Slide) Date: Fri, 30 Jan 2009 10:16:19 -0700 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> Message-ID: On Fri, Jan 30, 2009 at 10:01 AM, Severin wrote: > Good point! I forgot that I was having the *.py files in a subdirectory. > Is it also possible to set the 'current' directory for the engine? > For instance I would like to have the engine living in a subfolder of my > project and then all path's would be relative to this subfolder. > thank you, > Severin You could add the subdirectory to sys.path. slide From seob at gmx.ch Fri Jan 30 18:28:43 2009 From: seob at gmx.ch (Severin) Date: Fri, 30 Jan 2009 18:28:43 +0100 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> Message-ID: yes, thats what I did. but then I have relative path's in the python code. to open a file for instance. lets say ./py is my subdirectory. there I have a settings.ini and a main.py file. adding ./py to the path I am able to run main.py with the DLR but not doing something like open('settings.ini','r') in the python code. so basically what I want is that calling os.getcwd() returns the ./py subdirectory. well, I try to change the current working directory in the python code (or just put the python files in the main directory). this should do the job, but is not really nice. I guess the whole thing is a hack anyway :) Severin On Fri, Jan 30, 2009 at 6:16 PM, Slide wrote: > On Fri, Jan 30, 2009 at 10:01 AM, Severin wrote: > > Good point! I forgot that I was having the *.py files in a subdirectory. > > Is it also possible to set the 'current' directory for the engine? > > For instance I would like to have the engine living in a subfolder of my > > project and then all path's would be relative to this subfolder. > > thank you, > > Severin > > > > You could add the subdirectory to sys.path. > > slide > _______________________________________________ > 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 Fri Jan 30 18:29:22 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 30 Jan 2009 17:29:22 +0000 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> Message-ID: <498338F2.9090502@voidspace.org.uk> Severin wrote: > Good point! I forgot that I was having the *.py files in a subdirectory. > > Is it also possible to set the 'current' directory for the engine? > > For instance I would like to have the engine living in a subfolder of > my project and then all path's would be relative to this subfolder. > Windows only has a concept of a current directory per process (actually technically per drive per process but never mind). Changing your current directory in your host app will change it for all contained engines... Any of your Python scripts changing the current directory will also change it for the host app. For Python scripts in general (not just IronPython) it is much better to do relative path resolution yourself, relative to the current __file__ or sys.executable (which you are likely to need to set in a hosted environment). All the best, Michael > thank you, > Severin > > On Fri, Jan 30, 2009 at 4:56 PM, Michael Foord > > wrote: > > Severin wrote: > > Hello, > > I'm digging out this thread again. > > I'm trying to run python scripts from C# using the DLR. > > Simple examples work, namely if I have just one function in > one python file. > > How does it work when one python file imports from another > python file? I get "No module named x" ImportExceptions when > trying to compile these python files. > > > If you're running them from '.py' source files then you aren't > compiling them - you're just executing them from an embedded > environment. > > The import machinery should work exactly the same as for CPython, > but you may need to setup the initial sys.path depending on how > you are executing the scripts. > > You probably need to use the engine.SetSearchPaths method passing > in an array with the path to the directory containing the top > level Python file (adding any other directories that you need to > be able to import from). > > HTH > > Michael > > > I compile the main-file with 'CreateScriptSourceFromFile'. > > > May be I am using the wrong approach in general. What I have > is a bunch of python files that I used with CPython directly > so far. Now I want to extend my program with C# (since > database handling is much more convenient there) and I want to > use the python files that I already have. > > What is the best approach for this scenario? > > Thanks for any kind of hint. > > Severin > > On Tue, Jan 20, 2009 at 5:37 PM, Michael Foord > > >> wrote: > > Renaud Durand wrote: > > Ok, Thank you. > > Does anyone know where could I find an IronPython Assembly > documentation and/or up to date tutorials ? > > > These tutorials are up to date - except for the one > specified as > being for IP1: > > http://www.voidspace.org.uk/ironpython/embedding.shtml > > Michael > > > Thank you again. > > 2009/1/20 Curt Hagenlocher > > > > >>> > > > I believe this was valid for a long-ago alpha. For > the 2.0 > release, you'll want to create an engine by saying > engine = Python.CreateEngine() > > On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand > > > @gmail.com > > > wrote: > > Hi, > > I want to use IronPython function through C#. To > do It, I > found a tutorial at > > http://www.ironpython.info/index.php/Hosting_IronPython_2. > But the code does not seem to be updated for > IronPython > 2.0. > > the code is : > > using System; > using IronPython.Hosting; > using IronPython.Runtime; > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > namespace EmbeddedCalculator > { > public class Engine > { > private ScriptEngine engine; > > public Engine() > { > engine = PythonEngine.CurrentEngine; > } > > public string calculate(string input) > { > try > { > ScriptSource source = > engine.CreateScriptSourceFromString(input, "py"); > return source.Execute().ToString(); > } > catch > { > return "Error"; > } > } > > } > } > // End of code > > When I try to compile it in visual studio, the > compiler > could > not find the name "PythonEngine". I have added > all the > references to > the needed libraries. So, what am I missing ? > > > Thank you :-). > > -- Renaud Durand > > _______________________________________________ > 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 > > > > > -- Renaud Durand > > ------------------------------------------------------------------------ > > > > _______________________________________________ > 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 > > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 fuzzyman at voidspace.org.uk Fri Jan 30 18:31:28 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 30 Jan 2009 17:31:28 +0000 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> Message-ID: <49833970.8040400@voidspace.org.uk> Severin wrote: > yes, thats what I did. > > > but then I have relative path's in the python code. to open a file for > instance. > > lets say ./py is my subdirectory. > > there I have a settings.ini and a main.py file. adding ./py to the > path I am able to run main.py with the DLR but not doing something > like open('settings.ini','r') in the python code. Have a function that does the path relivatisation for you. The call can then be: open(getpath('settings.ini'),'r') or even: open_from('settings.ini','r') > > so basically what I want is that calling os.getcwd() returns the ./py > subdirectory. > > well, I try to change the current working directory in the python code > (or just put the python files in the main directory). this should do > the job, but is not really nice. I guess the whole thing is a hack > anyway :) Well - running Python code from a hosted environment need not be a hack. But depending on the current directory probably is... Michael > > Severin > > On Fri, Jan 30, 2009 at 6:16 PM, Slide > wrote: > > On Fri, Jan 30, 2009 at 10:01 AM, Severin wrote: > > Good point! I forgot that I was having the *.py files in a > subdirectory. > > Is it also possible to set the 'current' directory for the engine? > > For instance I would like to have the engine living in a > subfolder of my > > project and then all path's would be relative to this subfolder. > > thank you, > > Severin > > > > You could add the subdirectory to sys.path. > > slide > _______________________________________________ > 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 slide.o.mix at gmail.com Fri Jan 30 18:34:48 2009 From: slide.o.mix at gmail.com (Slide) Date: Fri, 30 Jan 2009 10:34:48 -0700 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> Message-ID: You could also make the files in the subdirectory a module and write a __init__.py to import the other items. On Fri, Jan 30, 2009 at 10:28 AM, Severin wrote: > yes, thats what I did. > > but then I have relative path's in the python code. to open a file for > instance. > lets say ./py is my subdirectory. > there I have a settings.ini and a main.py file. adding ./py to the path I am > able to run main.py with the DLR but not doing something like > open('settings.ini','r') in the python code. > so basically what I want is that calling os.getcwd() returns the ./py > subdirectory. > well, I try to change the current working directory in the python code (or > just put the python files in the main directory). this should do the job, > but is not really nice. I guess the whole thing is a hack anyway :) > Severin > On Fri, Jan 30, 2009 at 6:16 PM, Slide wrote: >> >> On Fri, Jan 30, 2009 at 10:01 AM, Severin wrote: >> > Good point! I forgot that I was having the *.py files in a subdirectory. >> > Is it also possible to set the 'current' directory for the engine? >> > For instance I would like to have the engine living in a subfolder of my >> > project and then all path's would be relative to this subfolder. >> > thank you, >> > Severin >> >> >> >> You could add the subdirectory to sys.path. >> >> slide >> _______________________________________________ >> 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/ From seob at gmx.ch Fri Jan 30 18:39:21 2009 From: seob at gmx.ch (Severin) Date: Fri, 30 Jan 2009 18:39:21 +0100 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: <498338F2.9090502@voidspace.org.uk> References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> <498338F2.9090502@voidspace.org.uk> Message-ID: Ok, that's very helpful. I didn't know that. Thanks, Severin On Fri, Jan 30, 2009 at 6:29 PM, Michael Foord wrote: > Severin wrote: > >> Good point! I forgot that I was having the *.py files in a subdirectory. >> >> Is it also possible to set the 'current' directory for the engine? >> >> For instance I would like to have the engine living in a subfolder of my >> project and then all path's would be relative to this subfolder. >> >> > Windows only has a concept of a current directory per process (actually > technically per drive per process but never mind). Changing your current > directory in your host app will change it for all contained engines... Any > of your Python scripts changing the current directory will also change it > for the host app. > > For Python scripts in general (not just IronPython) it is much better to do > relative path resolution yourself, relative to the current __file__ or > sys.executable (which you are likely to need to set in a hosted > environment). > > All the best, > > Michael > > > > thank you, >> Severin >> >> >> On Fri, Jan 30, 2009 at 4:56 PM, Michael Foord > fuzzyman at voidspace.org.uk>> wrote: >> >> Severin wrote: >> >> Hello, >> >> I'm digging out this thread again. >> >> I'm trying to run python scripts from C# using the DLR. >> >> Simple examples work, namely if I have just one function in >> one python file. >> >> How does it work when one python file imports from another >> python file? I get "No module named x" ImportExceptions when >> trying to compile these python files. >> >> >> If you're running them from '.py' source files then you aren't >> compiling them - you're just executing them from an embedded >> environment. >> >> The import machinery should work exactly the same as for CPython, >> but you may need to setup the initial sys.path depending on how >> you are executing the scripts. >> >> You probably need to use the engine.SetSearchPaths method passing >> in an array with the path to the directory containing the top >> level Python file (adding any other directories that you need to >> be able to import from). >> >> HTH >> >> Michael >> >> >> I compile the main-file with 'CreateScriptSourceFromFile'. >> >> >> May be I am using the wrong approach in general. What I have >> is a bunch of python files that I used with CPython directly >> so far. Now I want to extend my program with C# (since >> database handling is much more convenient there) and I want to >> use the python files that I already have. >> >> What is the best approach for this scenario? >> >> Thanks for any kind of hint. >> >> Severin >> >> On Tue, Jan 20, 2009 at 5:37 PM, Michael Foord >> >> > >> wrote: >> >> Renaud Durand wrote: >> >> Ok, Thank you. >> >> Does anyone know where could I find an IronPython Assembly >> documentation and/or up to date tutorials ? >> >> >> These tutorials are up to date - except for the one >> specified as >> being for IP1: >> >> http://www.voidspace.org.uk/ironpython/embedding.shtml >> >> Michael >> >> >> Thank you again. >> >> 2009/1/20 Curt Hagenlocher > >> > > > >> >> >> > >>> >> >> >> I believe this was valid for a long-ago alpha. For >> the 2.0 >> release, you'll want to create an engine by saying >> engine = Python.CreateEngine() >> >> On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand >> >> >> @gmail.com >> >> > wrote: >> >> Hi, >> >> I want to use IronPython function through C#. To >> do It, I >> found a tutorial at >> >> http://www.ironpython.info/index.php/Hosting_IronPython_2. >> But the code does not seem to be updated for >> IronPython >> 2.0. >> >> the code is : >> >> using System; >> using IronPython.Hosting; >> using IronPython.Runtime; >> using Microsoft.Scripting; >> using Microsoft.Scripting.Hosting; >> >> namespace EmbeddedCalculator >> { >> public class Engine >> { >> private ScriptEngine engine; >> >> public Engine() >> { >> engine = PythonEngine.CurrentEngine; >> } >> >> public string calculate(string input) >> { >> try >> { >> ScriptSource source = >> engine.CreateScriptSourceFromString(input, "py"); >> return source.Execute().ToString(); >> } >> catch >> { >> return "Error"; >> } >> } >> >> } >> } >> // End of code >> >> When I try to compile it in visual studio, the >> compiler >> could >> not find the name "PythonEngine". I have added >> all the >> references to >> the needed libraries. So, what am I missing ? >> >> >> Thank you :-). >> >> -- Renaud Durand >> >> _______________________________________________ >> 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 >> >> >> >> >> -- Renaud Durand >> >> ------------------------------------------------------------------------ >> >> >> >> _______________________________________________ >> 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 >> >> >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 slide.o.mix at gmail.com Fri Jan 30 18:48:37 2009 From: slide.o.mix at gmail.com (Slide) Date: Fri, 30 Jan 2009 10:48:37 -0700 Subject: [IronPython] Embedding IronPython 2.0 In-Reply-To: References: <8c5392700901200732k6abdaf0wc673601b42ed7837@mail.gmail.com> <8c5392700901200804k1a0e0977m6252eebb9b88aea4@mail.gmail.com> <4975FDD3.1040501@voidspace.org.uk> <49832329.80909@voidspace.org.uk> <498338F2.9090502@voidspace.org.uk> Message-ID: http://www.network-theory.co.uk/docs/pytut/Packages.html That will explain better. slide On Fri, Jan 30, 2009 at 10:39 AM, Severin wrote: > Ok, that's very helpful. > I didn't know that. > Thanks, > Severin > > On Fri, Jan 30, 2009 at 6:29 PM, Michael Foord > wrote: >> >> Severin wrote: >>> >>> Good point! I forgot that I was having the *.py files in a subdirectory. >>> >>> Is it also possible to set the 'current' directory for the engine? >>> >>> For instance I would like to have the engine living in a subfolder of my >>> project and then all path's would be relative to this subfolder. >>> >> >> Windows only has a concept of a current directory per process (actually >> technically per drive per process but never mind). Changing your current >> directory in your host app will change it for all contained engines... Any >> of your Python scripts changing the current directory will also change it >> for the host app. >> >> For Python scripts in general (not just IronPython) it is much better to >> do relative path resolution yourself, relative to the current __file__ or >> sys.executable (which you are likely to need to set in a hosted >> environment). >> >> All the best, >> >> Michael >> >> >> >>> thank you, >>> Severin >>> >>> On Fri, Jan 30, 2009 at 4:56 PM, Michael Foord >> > wrote: >>> >>> Severin wrote: >>> >>> Hello, >>> >>> I'm digging out this thread again. >>> >>> I'm trying to run python scripts from C# using the DLR. >>> >>> Simple examples work, namely if I have just one function in >>> one python file. >>> >>> How does it work when one python file imports from another >>> python file? I get "No module named x" ImportExceptions when >>> trying to compile these python files. >>> >>> >>> If you're running them from '.py' source files then you aren't >>> compiling them - you're just executing them from an embedded >>> environment. >>> >>> The import machinery should work exactly the same as for CPython, >>> but you may need to setup the initial sys.path depending on how >>> you are executing the scripts. >>> >>> You probably need to use the engine.SetSearchPaths method passing >>> in an array with the path to the directory containing the top >>> level Python file (adding any other directories that you need to >>> be able to import from). >>> >>> HTH >>> >>> Michael >>> >>> >>> I compile the main-file with 'CreateScriptSourceFromFile'. >>> >>> >>> May be I am using the wrong approach in general. What I have >>> is a bunch of python files that I used with CPython directly >>> so far. Now I want to extend my program with C# (since >>> database handling is much more convenient there) and I want to >>> use the python files that I already have. >>> >>> What is the best approach for this scenario? >>> >>> Thanks for any kind of hint. >>> >>> Severin >>> >>> On Tue, Jan 20, 2009 at 5:37 PM, Michael Foord >>> >>> >> >> wrote: >>> >>> Renaud Durand wrote: >>> >>> Ok, Thank you. >>> >>> Does anyone know where could I find an IronPython Assembly >>> documentation and/or up to date tutorials ? >>> >>> >>> These tutorials are up to date - except for the one >>> specified as >>> being for IP1: >>> >>> http://www.voidspace.org.uk/ironpython/embedding.shtml >>> >>> Michael >>> >>> >>> Thank you again. >>> >>> 2009/1/20 Curt Hagenlocher >> >>> >> > >> >>> >>> >> >>> >>> >>> >>> I believe this was valid for a long-ago alpha. For >>> the 2.0 >>> release, you'll want to create an engine by saying >>> engine = Python.CreateEngine() >>> >>> On Tue, Jan 20, 2009 at 7:32 AM, Renaud Durand >>> >>> >>> @gmail.com >>> >>> > wrote: >>> >>> Hi, >>> >>> I want to use IronPython function through C#. To >>> do It, I >>> found a tutorial at >>> >>> http://www.ironpython.info/index.php/Hosting_IronPython_2. >>> But the code does not seem to be updated for >>> IronPython >>> 2.0. >>> >>> the code is : >>> >>> using System; >>> using IronPython.Hosting; >>> using IronPython.Runtime; >>> using Microsoft.Scripting; >>> using Microsoft.Scripting.Hosting; >>> >>> namespace EmbeddedCalculator >>> { >>> public class Engine >>> { >>> private ScriptEngine engine; >>> >>> public Engine() >>> { >>> engine = PythonEngine.CurrentEngine; >>> } >>> >>> public string calculate(string input) >>> { >>> try >>> { >>> ScriptSource source = >>> engine.CreateScriptSourceFromString(input, "py"); >>> return source.Execute().ToString(); >>> } >>> catch >>> { >>> return "Error"; >>> } >>> } >>> >>> } >>> } >>> // End of code >>> >>> When I try to compile it in visual studio, the >>> compiler >>> could >>> not find the name "PythonEngine". I have added >>> all the >>> references to >>> the needed libraries. So, what am I missing ? >>> >>> >>> Thank you :-). >>> >>> -- Renaud Durand >>> >>> _______________________________________________ >>> 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 >>> >>> >>> >>> >>> -- Renaud Durand >>> >>> ------------------------------------------------------------------------ >>> >>> >>> >>> _______________________________________________ >>> 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 >>> >>> >>> >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> 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 > > -- slide-o-blog http://slide-o-blog.blogspot.com/ From tom.wright at resolversystems.com Fri Jan 30 19:34:05 2009 From: tom.wright at resolversystems.com (Tom Wright) Date: Fri, 30 Jan 2009 18:34:05 +0000 Subject: [IronPython] Two engines and clr.AddReference don't work together. In-Reply-To: <4981AB42.2000201@resolversystems.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> Message-ID: <4983481D.60305@resolversystems.com> Hi, Having two engines in the same AppDomain causes interesting behaviour when trying trying to add references. Only the sys.path of the first engine that was created seems to be taken into account when calling clr.AddReference, the second sys.path is ignored. See http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20921 for more details and a repro. Tom Wright Resolver Systems Ltd. From curt at hagenlocher.org Fri Jan 30 19:39:57 2009 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 30 Jan 2009 10:39:57 -0800 Subject: [IronPython] Two engines and clr.AddReference don't work together. In-Reply-To: <4983481D.60305@resolversystems.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> <4983481D.60305@resolversystems.com> Message-ID: How do we love thee, Fusion? Let me count the ways... On Fri, Jan 30, 2009 at 10:34 AM, Tom Wright wrote: > Hi, > > Having two engines in the same AppDomain causes interesting behaviour when > trying trying to add references. > > Only the sys.path of the first engine that was created seems to be taken > into account when calling clr.AddReference, the second sys.path is ignored. > > See http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20921for more details and a repro. > > Tom Wright > Resolver Systems Ltd. > _______________________________________________ > 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 Jan 30 19:53:42 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 30 Jan 2009 10:53:42 -0800 Subject: [IronPython] Two engines and clr.AddReference don't work together. In-Reply-To: <4983481D.60305@resolversystems.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> <4983481D.60305@resolversystems.com> Message-ID: <350E7D38B6D819428718949920EC23555712BA4941@NA-EXMSG-C102.redmond.corp.microsoft.com> You're right that it worked in 1.0 - but of course in 1.0 we would also end up with an arbitrary ordering between engines. For example you could have: Engine 1: Sys.path = C:\ Contains "Foo.dll" Engine 2: Sys.Path = D:\ Contains "Foo.dll" Which Foo.dll gets loaded? :) Unfortunately we don't necessarily know what engine is actually making the request. We can certainly go back to the 1.0 behavior in the mean time but I believe this will be truly fixed when we get better control over this in some future version of the CLR. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tom Wright Sent: Friday, January 30, 2009 10:34 AM To: Discussion of IronPython Subject: [IronPython] Two engines and clr.AddReference don't work together. Hi, Having two engines in the same AppDomain causes interesting behaviour when trying trying to add references. Only the sys.path of the first engine that was created seems to be taken into account when calling clr.AddReference, the second sys.path is ignored. See http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20921 for more details and a repro. Tom Wright Resolver Systems Ltd. _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Sat Jan 31 00:29:52 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 30 Jan 2009 23:29:52 +0000 Subject: [IronPython] Two engines and clr.AddReference don't work together. In-Reply-To: <350E7D38B6D819428718949920EC23555712BA4941@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> <4983481D.60305@resolversystems.com> <350E7D38B6D819428718949920EC23555712BA4941@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <49838D70.80904@voidspace.org.uk> Dino Viehland wrote: > You're right that it worked in 1.0 - but of course in 1.0 we would also end up with an arbitrary ordering between engines. For example you could have: > > Engine 1: > Sys.path = C:\ > Contains "Foo.dll" > > Engine 2: > Sys.Path = D:\ > Contains "Foo.dll" > > Which Foo.dll gets loaded? :) Unfortunately we don't necessarily know what engine is actually making the request. We can certainly go back to the 1.0 behavior in the mean time but I believe this will be truly fixed when we get better control over this in some future version of the CLR. > Unfortunately the current behaviour breaks certain Resolver One functionality. With IronPython 1 users could put assemblies their spreadsheet systems depended on in the same directory as the spreadsheet and it 'just worked', which isn't the case with the IronPython 2 port. Even if it isn't always guaranteed to be correct, the old behaviour was much better for us. :-) Thanks Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tom Wright > Sent: Friday, January 30, 2009 10:34 AM > To: Discussion of IronPython > Subject: [IronPython] Two engines and clr.AddReference don't work together. > > Hi, > > Having two engines in the same AppDomain causes interesting behaviour > when trying trying to add references. > > Only the sys.path of the first engine that was created seems to be taken > into account when calling clr.AddReference, the second sys.path is ignored. > > See > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20921 > for more details and a repro. > > Tom Wright > Resolver Systems Ltd. > _______________________________________________ > 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 dinov at microsoft.com Sat Jan 31 00:35:56 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 30 Jan 2009 15:35:56 -0800 Subject: [IronPython] Two engines and clr.AddReference don't work together. In-Reply-To: <49838D70.80904@voidspace.org.uk> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> <4983481D.60305@resolversystems.com> <350E7D38B6D819428718949920EC23555712BA4941@NA-EXMSG-C102.redmond.corp.microsoft.com> <49838D70.80904@voidspace.org.uk> Message-ID: <350E7D38B6D819428718949920EC23555712BA4B06@NA-EXMSG-C102.redmond.corp.microsoft.com> Yep, and I'm happy to move back to the old behavior - being consistent w/ ourselves and broken seems better than being inconsistent w/ ourselves and broken :) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, January 30, 2009 3:30 PM To: Discussion of IronPython Subject: Re: [IronPython] Two engines and clr.AddReference don't work together. Dino Viehland wrote: > You're right that it worked in 1.0 - but of course in 1.0 we would also end up with an arbitrary ordering between engines. For example you could have: > > Engine 1: > Sys.path = C:\ > Contains "Foo.dll" > > Engine 2: > Sys.Path = D:\ > Contains "Foo.dll" > > Which Foo.dll gets loaded? :) Unfortunately we don't necessarily know what engine is actually making the request. We can certainly go back to the 1.0 behavior in the mean time but I believe this will be truly fixed when we get better control over this in some future version of the CLR. > Unfortunately the current behaviour breaks certain Resolver One functionality. With IronPython 1 users could put assemblies their spreadsheet systems depended on in the same directory as the spreadsheet and it 'just worked', which isn't the case with the IronPython 2 port. Even if it isn't always guaranteed to be correct, the old behaviour was much better for us. :-) Thanks Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tom Wright > Sent: Friday, January 30, 2009 10:34 AM > To: Discussion of IronPython > Subject: [IronPython] Two engines and clr.AddReference don't work together. > > Hi, > > Having two engines in the same AppDomain causes interesting behaviour > when trying trying to add references. > > Only the sys.path of the first engine that was created seems to be taken > into account when calling clr.AddReference, the second sys.path is ignored. > > See > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20921 > for more details and a repro. > > Tom Wright > Resolver Systems Ltd. > _______________________________________________ > 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 _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Sat Jan 31 00:37:25 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 30 Jan 2009 23:37:25 +0000 Subject: [IronPython] Two engines and clr.AddReference don't work together. In-Reply-To: <350E7D38B6D819428718949920EC23555712BA4B06@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <49819648.4000206@resolversystems.com> <3841BB92-8FBB-4BD5-97E0-35A7C2116D70@houmus.org> <4981AB42.2000201@resolversystems.com> <4983481D.60305@resolversystems.com> <350E7D38B6D819428718949920EC23555712BA4941@NA-EXMSG-C102.redmond.corp.microsoft.com> <49838D70.80904@voidspace.org.uk> <350E7D38B6D819428718949920EC23555712BA4B06@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <49838F35.5030608@voidspace.org.uk> Dino Viehland wrote: > Yep, and I'm happy to move back to the old behavior - being consistent w/ ourselves and broken seems better than being inconsistent w/ ourselves and broken :) > Better a foolish consistency than uhm... the opposite. :-) Michael > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord > Sent: Friday, January 30, 2009 3:30 PM > To: Discussion of IronPython > Subject: Re: [IronPython] Two engines and clr.AddReference don't work together. > > Dino Viehland wrote: > >> You're right that it worked in 1.0 - but of course in 1.0 we would also end up with an arbitrary ordering between engines. For example you could have: >> >> Engine 1: >> Sys.path = C:\ >> Contains "Foo.dll" >> >> Engine 2: >> Sys.Path = D:\ >> Contains "Foo.dll" >> >> Which Foo.dll gets loaded? :) Unfortunately we don't necessarily know what engine is actually making the request. We can certainly go back to the 1.0 behavior in the mean time but I believe this will be truly fixed when we get better control over this in some future version of the CLR. >> >> > > Unfortunately the current behaviour breaks certain Resolver One > functionality. With IronPython 1 users could put assemblies their > spreadsheet systems depended on in the same directory as the spreadsheet > and it 'just worked', which isn't the case with the IronPython 2 port. > > Even if it isn't always guaranteed to be correct, the old behaviour was > much better for us. :-) > > Thanks > > Michael > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tom Wright >> Sent: Friday, January 30, 2009 10:34 AM >> To: Discussion of IronPython >> Subject: [IronPython] Two engines and clr.AddReference don't work together. >> >> Hi, >> >> Having two engines in the same AppDomain causes interesting behaviour >> when trying trying to add references. >> >> Only the sys.path of the first engine that was created seems to be taken >> into account when calling clr.AddReference, the second sys.path is ignored. >> >> See >> http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20921 >> for more details and a repro. >> >> Tom Wright >> Resolver Systems Ltd. >> _______________________________________________ >> 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 > > > _______________________________________________ > 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 fuzzyman at voidspace.org.uk Sat Jan 31 01:38:06 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 31 Jan 2009 00:38:06 +0000 Subject: [IronPython] Optimised tail calls Message-ID: <49839D6E.2060405@voidspace.org.uk> Hello all, It occurs to me; CPython doesn't have optimised tail calls, but no reason that IronPython shouldn't! Please vote up: http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=20927 :-) Michael -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog From jslutter at reactorzero.com Sat Jan 31 03:02:26 2009 From: jslutter at reactorzero.com (Jeff Slutter) Date: Fri, 30 Jan 2009 21:02:26 -0500 Subject: [IronPython] Redirecting stdout/stderr, but with context Message-ID: <4983B132.7060706@reactorzero.com> I have a bit of a problem that I'm not sure how to solve. In my application, I have multiple documents, and each can possibly be performing script operations that print text out via the "print" function. I have one "script output" window, which, only shows the output of whichever is the active document's script (each document has its own ScriptScope). When you switch the active document, the "script output window" refreshes displaying the stdout/stderr text for its script. For each document, I keep a buffer of the text. I redirected stdout/stderr by setting sys.stdout and sys.stderr to an instance of a class I wrote that has the "write" function in it. The problem is, sys.stdout is shared across all of the scopes. So, when I set it for one scope, it changes for all ScriptScopes. I can't figure out a way to pass along the information about which document the stdout output should go to. Is there any way to solve this problem? Or will I have to ban my users from using print and stdout and go with a custom function? Note: Each ScriptScope does have a variable that is the document it belongs to, so I know that information in the script. The problem is, print just goes right to sys.stdout and sys.stdout is shared. Also, keep in mind it is entirely possible for an inactive document to be printing out something. In that case I still need to get the string to be printed, but I'm only storing it at that point (and skipping the output to my textbox). help! Thanks, Jeff From dinov at microsoft.com Sat Jan 31 03:07:35 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 30 Jan 2009 18:07:35 -0800 Subject: [IronPython] Redirecting stdout/stderr, but with context In-Reply-To: <4983B132.7060706@reactorzero.com> References: <4983B132.7060706@reactorzero.com> Message-ID: <350E7D38B6D819428718949920EC23555712BA4B61@NA-EXMSG-C102.redmond.corp.microsoft.com> You can always provide your own stream which is aware of what the current output window is. It could store this in a thread static or just some variable that you update whenever the active window changes. You can set that via ScriptRuntime.IO.OutputStream. You could conceptually do the exact same thing from Python just by setting sys.stdout to a file-like object which knows what the current output window is. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Slutter Sent: Friday, January 30, 2009 6:02 PM To: Discussion of IronPython Subject: [IronPython] Redirecting stdout/stderr, but with context I have a bit of a problem that I'm not sure how to solve. In my application, I have multiple documents, and each can possibly be performing script operations that print text out via the "print" function. I have one "script output" window, which, only shows the output of whichever is the active document's script (each document has its own ScriptScope). When you switch the active document, the "script output window" refreshes displaying the stdout/stderr text for its script. For each document, I keep a buffer of the text. I redirected stdout/stderr by setting sys.stdout and sys.stderr to an instance of a class I wrote that has the "write" function in it. The problem is, sys.stdout is shared across all of the scopes. So, when I set it for one scope, it changes for all ScriptScopes. I can't figure out a way to pass along the information about which document the stdout output should go to. Is there any way to solve this problem? Or will I have to ban my users from using print and stdout and go with a custom function? Note: Each ScriptScope does have a variable that is the document it belongs to, so I know that information in the script. The problem is, print just goes right to sys.stdout and sys.stdout is shared. Also, keep in mind it is entirely possible for an inactive document to be printing out something. In that case I still need to get the string to be printed, but I'm only storing it at that point (and skipping the output to my textbox). help! Thanks, Jeff _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jslutter at reactorzero.com Sat Jan 31 03:41:28 2009 From: jslutter at reactorzero.com (Jeff Slutter) Date: Fri, 30 Jan 2009 21:41:28 -0500 Subject: [IronPython] Redirecting stdout/stderr, but with context In-Reply-To: <350E7D38B6D819428718949920EC23555712BA4B61@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <4983B132.7060706@reactorzero.com> <350E7D38B6D819428718949920EC23555712BA4B61@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4983BA58.40403@reactorzero.com> Dino Viehland wrote: > You can always provide your own stream which is aware of what the current output window is. It could store this in a thread static or just some variable that you update whenever the active window changes. You can set that via ScriptRuntime.IO.OutputStream. You could conceptually do the exact same thing from Python just by setting sys.stdout to a file-like object which knows what the current output window is. This is what I'm doing right now and that's where I'm having my problem. I don't think this is a solvable problem since the output stream is shared by all ScriptScopes, just as the output stream for System.Console.WriteLine is the same across the process. In a nutshell, I have this: class Document { void AppendOutput( string text ) { m_buffer.Add(text); } List m_buffer; } class ConsoleWindow: Form { public void WriteOutput( string text, Document doc ) { doc.AppendOutput( text ); if( doc == m_currentDisplayingDoc ) { textBox.Text += text; } } } class DocWriter { public DocWriter( ConsoleWindow console, Document doc ) { m_console = console; m_document = doc; } public void write(string text) { m_console.WriteOutput( text, m_document ); } ConsoleWindow m_console; Document m_document; } void OnDocumentActivate(Document doc) { DocWriter writer = new DocWrite(guiConsole, doc); object sysObj = doc.scope.GetVariable("sys"); m_engine.Operations.SetMember(sysObj, "stdout", writer); m_engine.Operations.SetMember(sysObj, "stderr", writer); } The problem is: If there is a script running on DocumentA, that is streaming output, and then I switch to DocumentB while DocumentA continues to run - the output for DocumentA starts appearing in the console window for DocumentB as if it was for B. This is because sysout is system wide and if I change it while DocumentA is writing, then it starts outputting to the new stream that was set (and that was registered with DocumentB). -Jeff From dinov at microsoft.com Sat Jan 31 03:45:01 2009 From: dinov at microsoft.com (Dino Viehland) Date: Fri, 30 Jan 2009 18:45:01 -0800 Subject: [IronPython] Redirecting stdout/stderr, but with context In-Reply-To: <4983BA58.40403@reactorzero.com> References: <4983B132.7060706@reactorzero.com> <350E7D38B6D819428718949920EC23555712BA4B61@NA-EXMSG-C102.redmond.corp.microsoft.com> <4983BA58.40403@reactorzero.com> Message-ID: <350E7D38B6D819428718949920EC23555712BA4B65@NA-EXMSG-C102.redmond.corp.microsoft.com> Can you run each document on its own thread? Oh, it also looks like we actually flow CodeContext through to the caller. So you could do something like: class MyFile { public void write(CodeContext context, string data) { Scope curScope = context.Scope; // this gives you the module you're running in // handle write here keyed off of the scope object } } And replace sys.stdout with that. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Slutter Sent: Friday, January 30, 2009 6:41 PM To: Discussion of IronPython Subject: Re: [IronPython] Redirecting stdout/stderr, but with context Dino Viehland wrote: > You can always provide your own stream which is aware of what the current output window is. It could store this in a thread static or just some variable that you update whenever the active window changes. You can set that via ScriptRuntime.IO.OutputStream. You could conceptually do the exact same thing from Python just by setting sys.stdout to a file-like object which knows what the current output window is. This is what I'm doing right now and that's where I'm having my problem. I don't think this is a solvable problem since the output stream is shared by all ScriptScopes, just as the output stream for System.Console.WriteLine is the same across the process. In a nutshell, I have this: class Document { void AppendOutput( string text ) { m_buffer.Add(text); } List m_buffer; } class ConsoleWindow: Form { public void WriteOutput( string text, Document doc ) { doc.AppendOutput( text ); if( doc == m_currentDisplayingDoc ) { textBox.Text += text; } } } class DocWriter { public DocWriter( ConsoleWindow console, Document doc ) { m_console = console; m_document = doc; } public void write(string text) { m_console.WriteOutput( text, m_document ); } ConsoleWindow m_console; Document m_document; } void OnDocumentActivate(Document doc) { DocWriter writer = new DocWrite(guiConsole, doc); object sysObj = doc.scope.GetVariable("sys"); m_engine.Operations.SetMember(sysObj, "stdout", writer); m_engine.Operations.SetMember(sysObj, "stderr", writer); } The problem is: If there is a script running on DocumentA, that is streaming output, and then I switch to DocumentB while DocumentA continues to run - the output for DocumentA starts appearing in the console window for DocumentB as if it was for B. This is because sysout is system wide and if I change it while DocumentA is writing, then it starts outputting to the new stream that was set (and that was registered with DocumentB). -Jeff _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jslutter at reactorzero.com Sat Jan 31 04:17:53 2009 From: jslutter at reactorzero.com (Jeff Slutter) Date: Fri, 30 Jan 2009 22:17:53 -0500 Subject: [IronPython] Redirecting stdout/stderr, but with context In-Reply-To: <350E7D38B6D819428718949920EC23555712BA4B65@NA-EXMSG-C102.redmond.corp.microsoft.com> References: <4983B132.7060706@reactorzero.com> <350E7D38B6D819428718949920EC23555712BA4B61@NA-EXMSG-C102.redmond.corp.microsoft.com> <4983BA58.40403@reactorzero.com> <350E7D38B6D819428718949920EC23555712BA4B65@NA-EXMSG-C102.redmond.corp.microsoft.com> Message-ID: <4983C2E1.9000600@reactorzero.com> Aha! That looks like exactly what I need! It will take some tweaking of the code, but this should give me the information I need to route things properly. Now, I just need to find out if I can do something similar for System.Console, but I can live with it if I can't for that one. Python output was the one I *really* needed. Thanks Dino! Dino Viehland wrote: > Can you run each document on its own thread? > > Oh, it also looks like we actually flow CodeContext through to the caller. So you could do something like: > > class MyFile { > public void write(CodeContext context, string data) { > Scope curScope = context.Scope; // this gives you the module you're running in > > // handle write here keyed off of the scope object > } > } > > And replace sys.stdout with that. From fuzzyman at voidspace.org.uk Sat Jan 31 13:58:48 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 31 Jan 2009 12:58:48 +0000 Subject: [IronPython] Redirecting stdout/stderr, but with context In-Reply-To: <4983B132.7060706@reactorzero.com> References: <4983B132.7060706@reactorzero.com> Message-ID: <49844B08.9020507@voidspace.org.uk> Jeff Slutter wrote: > I have a bit of a problem that I'm not sure how to solve. In my > application, I have multiple documents, and each can possibly be > performing script operations that print text out via the "print" > function. I have one "script output" window, which, only shows the > output of whichever is the active document's script (each document has > its own ScriptScope). > > When you switch the active document, the "script output window" > refreshes displaying the stdout/stderr text for its script. For each > document, I keep a buffer of the text. > > I redirected stdout/stderr by setting sys.stdout and sys.stderr to an > instance of a class I wrote that has the "write" function in it. The > problem is, sys.stdout is shared across all of the scopes. So, when I > set it for one scope, it changes for all ScriptScopes. > > We solve this problem by using separate engines. That way we can set the output / error streams separately per engine (runtime actually I think). The engines also share less state this way - which may or may not be what you want. Michael > I can't figure out a way to pass along the information about which > document the stdout output should go to. > > Is there any way to solve this problem? Or will I have to ban my users > from using print and stdout and go with a custom function? > > Note: Each ScriptScope does have a variable that is the document it > belongs to, so I know that information in the script. The problem is, > print just goes right to sys.stdout and sys.stdout is shared. Also, keep > in mind it is entirely possible for an inactive document to be printing > out something. In that case I still need to get the string to be > printed, but I'm only storing it at that point (and skipping the output > to my textbox). > > help! > > Thanks, > Jeff > _______________________________________________ > 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 antonio.piteira at wtvision.com Sat Jan 31 15:08:49 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Sat, 31 Jan 2009 14:08:49 -0000 Subject: [IronPython] Problem with time module in IronPython 2.0 Message-ID: <000301c983ad$7043c440$50cb4cc0$@piteira@wtvision.com> http://www.wtvision.com/Mail/2007/logo_wTVision.gif www.wtvision.com Tel: +351 21 831 06 86 Fax: +351 21 831 06 81 email: info at wtvision.com Est?dios Grupo TV Travessa da Fonte de Cima, n? 2 Asseiceira Grande 2665 ?618 Venda do Pinheiro Hi, In Ironpython 1.x I could easily import time and do stuff like time.sleep(x), but since I?ve changed to IronPython 2.0 I?m unable to do this. I always get ?No module named time?. I have IronPython hosted in an application and I?ve already tried to append python libs path too. Any ideas?! Ant?nio Piteira Project Development Director email: antonio.piteira at wtvision.com mobile: +351 93 449 19 74 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.gif Type: application/octet-stream Size: 4677 bytes Desc: not available URL: From fuzzyman at voidspace.org.uk Sat Jan 31 15:27:06 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 31 Jan 2009 14:27:06 +0000 Subject: [IronPython] Problem with time module in IronPython 2.0 In-Reply-To: <000301c983ad$7043c440$50cb4cc0$@piteira@wtvision.com> References: <000301c983ad$7043c440$50cb4cc0$@piteira@wtvision.com> Message-ID: <49845FBA.1090306@voidspace.org.uk> Hello Antonio, I've used the time module fine from IronPython 2 (you can confirm this by installing IP 2 from the msi installer). I suspect you have not correctly set sys.path for your hosted code. Print sys.path from inside the hosted environment and confirm that the directory containing the time module is there. All the best, Michael Foord Ant?nio Piteira wrote: > > *http://www.wtvision.com/Mail/2007/logo_wTVision.gif* > ** > > > > > *www.wtvision.com ** > Tel: +351 21 831 06 86 > Fax: +351 21 831 06 81 > email: **info at wtvision.com *** > > > > *Est?dios Grupo TV > > Travessa da Fonte de Cima, n? 2 > Asseiceira Grande > 2665 **?618 Venda do Pinheiro** * > > * * > > * * > > * * > > > > Hi, > > In Ironpython 1.x I could easily import time and do stuff like > time.sleep(x), but since I?ve changed to IronPython 2.0 I?m unable to > do this. I always get ?No module named time?. > > I have IronPython hosted in an application and I?ve already tried to > append python libs path too. > > Any ideas?! > > * * > > * * > > > > > ** > > > * * > > > > > *Ant?nio Piteira** > Project Development > Director > email: antonio.piteira at wtvision.com > mobile: +351 93 449 19 74 * > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 antonio.piteira at wtvision.com Sat Jan 31 16:59:35 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Sat, 31 Jan 2009 15:59:35 -0000 Subject: [IronPython] Problem with time module in IronPython 2.0 In-Reply-To: <49845FBA.1090306@voidspace.org.uk> References: <000301c983ad$7043c440$50cb4cc0$@piteira@wtvision.com> <49845FBA.1090306@voidspace.org.uk> Message-ID: <49847569.0506d00a.2a96.0ab7@mx.google.com> Hello Michael, Thank you for your reply. I've done sys.path.append("c:\CPython26\lib")... shouldn't this work? ---------------------------------------------------------------------------- ---------------------- Hello Antonio, I've used the time module fine from IronPython 2 (you can confirm this by installing IP 2 from the msi installer). I suspect you have not correctly set sys.path for your hosted code. Print sys.path from inside the hosted environment and confirm that the directory containing the time module is there. All the best, Michael Foord Ant?nio Piteira wrote: > > *http://www.wtvision.com/Mail/2007/logo_wTVision.gif* > ** > > > > > *www.wtvision.com ** > Tel: +351 21 831 06 86 > Fax: +351 21 831 06 81 > email: **info at wtvision.com *** > > > > *Est?dios Grupo TV > > Travessa da Fonte de Cima, n? 2 > Asseiceira Grande > 2665 **?618 Venda do Pinheiro** * > > * * > > * * > > * * > > > > Hi, > > In Ironpython 1.x I could easily import time and do stuff like > time.sleep(x), but since I?ve changed to IronPython 2.0 I?m unable to > do this. I always get ?No module named time?. > > I have IronPython hosted in an application and I?ve already tried to > append python libs path too. > > Any ideas?! > > * * > > * * > > > > > ** > > > * * > > > > > *Ant?nio Piteira** > Project Development > Director > email: antonio.piteira at wtvision.com > mobile: +351 93 449 19 74 * > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 antonio.piteira at wtvision.com Sat Jan 31 17:17:28 2009 From: antonio.piteira at wtvision.com (=?iso-8859-1?Q?Ant=F3nio_Piteira?=) Date: Sat, 31 Jan 2009 16:17:28 -0000 Subject: [IronPython] Problem with time module in IronPython 2.0 In-Reply-To: <49845FBA.1090306@voidspace.org.uk> References: <000301c983ad$7043c440$50cb4cc0$@piteira@wtvision.com> <49845FBA.1090306@voidspace.org.uk> Message-ID: <4984799b.03e9300a.4a61.0637@mx.google.com> Hi Michael, I discovered what was wrong, you were right, I thought the libs where in some place and I was wrong. Thank you for your time. ------------------------------------------------------------------ Hello Antonio, I've used the time module fine from IronPython 2 (you can confirm this by installing IP 2 from the msi installer). I suspect you have not correctly set sys.path for your hosted code. Print sys.path from inside the hosted environment and confirm that the directory containing the time module is there. All the best, Michael Foord Ant?nio Piteira wrote: > > *http://www.wtvision.com/Mail/2007/logo_wTVision.gif* > ** > > > > > *www.wtvision.com ** > Tel: +351 21 831 06 86 > Fax: +351 21 831 06 81 > email: **info at wtvision.com *** > > > > *Est?dios Grupo TV > > Travessa da Fonte de Cima, n? 2 > Asseiceira Grande > 2665 **?618 Venda do Pinheiro** * > > * * > > * * > > * * > > > > Hi, > > In Ironpython 1.x I could easily import time and do stuff like > time.sleep(x), but since I?ve changed to IronPython 2.0 I?m unable to > do this. I always get ?No module named time?. > > I have IronPython hosted in an application and I?ve already tried to > append python libs path too. > > Any ideas?! > > * * > > * * > > > > > ** > > > * * > > > > > *Ant?nio Piteira** > Project Development > Director > email: antonio.piteira at wtvision.com > mobile: +351 93 449 19 74 * > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 fuzzyman at voidspace.org.uk Sat Jan 31 20:35:29 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 31 Jan 2009 19:35:29 +0000 Subject: [IronPython] Problem with time module in IronPython 2.0 In-Reply-To: <49847569.0506d00a.2a96.0ab7@mx.google.com> References: <000301c983ad$7043c440$50cb4cc0$@piteira@wtvision.com> <49845FBA.1090306@voidspace.org.uk> <49847569.0506d00a.2a96.0ab7@mx.google.com> Message-ID: <4984A801.3080405@voidspace.org.uk> Ant?nio Piteira wrote: > Hello Michael, > > Thank you for your reply. > > I've done sys.path.append("c:\CPython26\lib")... shouldn't this work? > I think you have solved your problem now - but for IronPython 2 you should be using the standard library for Python 2.5 and *not* the 2.6 one, and if you have strings with backslashes in them you must make them raw strings or use double backslashes. All the best, Michael > ---------------------------------------------------------------------------- > ---------------------- > > Hello Antonio, > > I've used the time module fine from IronPython 2 (you can confirm this > by installing IP 2 from the msi installer). I suspect you have not > correctly set sys.path for your hosted code. Print sys.path from inside > the hosted environment and confirm that the directory containing the > time module is there. > > All the best, > > Michael Foord > > Ant?nio Piteira wrote: > >> *http://www.wtvision.com/Mail/2007/logo_wTVision.gif* >> ** >> >> >> >> >> *www.wtvision.com ** >> Tel: +351 21 831 06 86 >> Fax: +351 21 831 06 81 >> email: **info at wtvision.com *** >> >> >> >> *Est?dios Grupo TV >> >> > ,-9.230719&saddr=Unknown+road+%4038.937584,+-9.230719&daddr=&mra=mr&sll=38.9 > 35778,-9.226456&sspn=0.033849,0.080338&ie=UTF8&ll=38.935778,-9.226456&spn=0. > 033849,0.080338&t=h&z=14> > > >> Travessa da Fonte de Cima, n? 2 >> Asseiceira Grande >> 2665 **?618 Venda do Pinheiro** * >> >> * * >> >> * * >> >> * * >> >> >> >> Hi, >> >> In Ironpython 1.x I could easily import time and do stuff like >> time.sleep(x), but since I?ve changed to IronPython 2.0 I?m unable to >> do this. I always get ?No module named time?. >> >> I have IronPython hosted in an application and I?ve already tried to >> append python libs path too. >> >> Any ideas?! >> >> * * >> >> * * >> >> >> >> >> ** >> >> >> * * >> >> >> >> >> *Ant?nio Piteira** >> Project Development >> Director >> email: antonio.piteira at wtvision.com >> mobile: +351 93 449 19 74 * >> >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> 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 fuzzyman at voidspace.org.uk Sat Jan 31 22:07:40 2009 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 31 Jan 2009 21:07:40 +0000 Subject: [IronPython] IronPython at PyCon 2009 Message-ID: <4984BD9C.4040506@voidspace.org.uk> The talk schedule has gone up for for PyCon 2009 in Chicago. There are three talks on IronPython, plus a tutorial on the Wednesday before the conference. The conference dates are: * March 25-26th Tutorial Days * March 27-29th Conference * March 30th - April 2nd Development Sprints Jim Hugunin is one of the invited speakers, so his talk doesn't yet appear on the schedule - but his usual talk is "IronPython the Road Ahead". I've blogged about all the talks, plus the tutorial that Jonathan Hartley and I will be giving, on IronPython URLs. http://ironpython-urls.blogspot.com/2009/01/ironpython-at-pycon-2009.html All the best, Michael Foord -- http://www.ironpythoninaction.com/ http://www.voidspace.org.uk/blog