From dfugate at microsoft.com Fri May 2 18:35:56 2008 From: dfugate at microsoft.com (Dave Fugate) Date: Fri, 2 May 2008 09:35:56 -0700 Subject: [IronPython] Announcing IronPython 2.0 Beta 2 In-Reply-To: <2C734460517A154B8E98AC8BA98D49A15DCFD2BBB4@NA-EXMSG-C105.redmond.corp.microsoft.com> References: <2C734460517A154B8E98AC8BA98D49A15DCFD2B336@NA-EXMSG-C105.redmond.corp.microsoft.com> <2C734460517A154B8E98AC8BA98D49A15DCFD2BBB4@NA-EXMSG-C105.redmond.corp.microsoft.com> Message-ID: Hello IronPython Community, We're pleased to announce the release of IronPython 2.0 Beta 2. In addition to the usual bug fixes (~25 reported on CodePlex and ~50 reported internally), this release has been partially focused on improving the performance of IronPython, in particular startup perf. Another focus of this release was improving upon our traceback support which had regressed quite a bit in 2.0B1 and had largely been broken in the 2.0 Alphas. Our traceback support should now be superior to that of IronPython 1.1! We've also made a minor change to our packaging by adding a Microsoft.Scripting.Core.dll in addition to the Microsoft.Scripting.dll that's been around since the start of 2.0. We are doing this purely as an architectural layering cleanup. Microsoft.Scripting.Core contains DLR features that are essential to building dynamic languages. Microsoft.Scripting will contain language implementation helpers that can either be re-used (e.g., BigInts) or copied (possibly e.g., the default binder). This process is all about our work to get the DLR architecture right and shouldn't have any noticeable IronPython impact except that there's now one more DLL to include in any package. As a consequence of the new DLL, the deprecated file IronPython2005.sln is broken. This is the last release that will include this .sln file in the source zip file. Of course the Visual Studio 2008 version of this file, IronPython.sln, still builds. The following CodePlex Work Items have been closed since IronPython 2.0 Beta 1 was released: * 15835 FromImportStatement relative path not working * 15832 parser is not validating FromImportStatement syntax * 15793 dynamically bound __getattribute__ is overwritten after modifying __bases__ * 15752 derived __getattribute__ causes stack overflow * 16057 BY DESIGN: Sublist parameter gets lost by Parser * 15522 (Ipy2a8) Problems in module "dis" * 15598 BY DESIGN: Problems with ScriptEngine.Execute on 2.0 Alpha 8 * 16077 incorrect parsing of numeric literal __index__() call * 945 Pickling exceptions with clsException in dict fails * 15803 cPickle fails to load pickled object from submodule * 15882 __delitem__ broken w/ tuple arguments * 11923 Exception tracebacks lose line numbers after reload() * 2409 Default exception dumper should get line info out of traceback * 15715 dir(dict.fromkeys) fails with a cast-related TypeError after calls to dir(dict) * 13820 __getattribute__ called for magic methods * 7429 traceback support inside generator and nested try inside except block * 15884 MAJOR REGRESSION: stack traces of simple errors missing file names, line numbers, etc * 8291 Tracebacks from compiled code objects dissimilar from CPython * 11922 AssertionError is printed with an extraneous "None" * 7766 __builtins__ should be module for main script, dictionary for other modules * 5803 when __add__ failed * 2912 traceback's don't get created if exception is caught in same frame * 6210 RawDecode method fails to return the string according the right encoding * 13687 2.0 alpha 5: Registering c#-written methods as event handlers from ironpy throws TypeError: object is not callable. * 11283 SyntaxError doesnt get lineno (or other properties) when created by user code * 15746 DUPLICATE: ipyw.exe without any parameters crash ( IronPython 2.0 Beta 1 ) We'd like to thank everyone in the community who reported these: kevgu, oldman, christmas, brucec, scottw, fuzzyman, haibo, Seo Sanghyeon, grizlupo, J. Merrill, perhaps, antont, 05031972, Jason Ferrara, Matt Beckius, and Davy Mitchell. Also, we've closed the following bugs that were reported internally: * 148394 Trivial: Exception messages are not directed to sys.stderr * 148481 Trivial: IronPythonConsole.exe with '-' : no response * 148651 Possible race conditions during lock-unprotected reads from Dictionary<,> * 149018 Trivial: Python25: new api - deque.remove * 151051 In CPython, divmod does not try on __floordiv__ and __mod__ * 151094 Misc binary operation bugs * 221344 Perf: Shootout/fasta is 74% worse when running IronPython 2.0 vs. IronPython 1.1 * 250921 Add more IronPython tests for property sets WRT value types * 299898 test_coercion.py fails with method "test_cmptypes()" when the two objects to be compared are not the same type in 32bit vista * 301601 IP2.0 raise a syntaxError instead of an indentationError when exec("foo()\n bar()\n") * 314124 Implementing __coerce__ cause endless loop * 314140 __eq__ threw AttributeError in IronPython but didn't in CPython * 314459 gc.collect() always return 0 and can't have argument * 314879 AttributeError: 'module' object has no attribute '__debug__' * 314898 NotImplementedError for co_lnotab. * 316130 heapq.heapreplace(None,None) throw a AttributeError instead of TypeError * 316148 sometimes nlargest(n, iterable) not equal to sorted(iterable, reverse=True)[:n] * 316520 it is different for func_defaults between Ironpython and Cpython. * 316523 it is different for func_dict between Ironpython and Cpython * 317194 AttributeError: 'file' object has no attribute 'mode' * 319014 it is different between Ironpython and Cpython when exec "dict({}, {})" * 319028 AttributeError: 'dictproxy' object has no attribute 'items' * 319487 Instances of Set dosen't provide update() operation in IronPython * 320078 Trivial: TypeError: hex() argument cannot be converted to hex * 320514 ImportError: No module named _functools * 321852 Trivial: KeyError: __module__ * 323570 startfile() can take two argument in cpython2.5 * 325377 dict silently swallows exceptions when a key's __cmp__ method throws * 359635 "unknow command line:" in the output of "ipy.exe /help" * 360510 some properties of func_code is not implemented * 360987 None has a extra attribute '__module__' * 361443 Re-enable test_traceback_cpy_20 * 363019 yield statement must add an return value against Ironpython. but Cpython don't need. * 364736 compiling "from . import a" throw syntax error * 364746 Can't from __future__ import absolute_import * 365068 __getslice__(self, i, j): gets different result between IrpnPython and CPython with UserList object * 365242 excise __getattribute__ from derived new-style type * 365367 sys.path_hooks is not implemented * 369111 Ipy should try to use base type defined special operators * 372549 Non-string attributes are not being added to a dictionary in interactive mode * 400941 REGRESSION: Re-enable merged modules which contain both a .NET namespace and a normal module You can download IronPython 2.0 Beta 2 at: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=11566 The IronPython Team NOTES ToyScript, a small scripting language built on top of the DLR, is merely a DLR sample and not some new scripting language Microsoft has created. Also, ToyScript is not intended to be distributed with IronPython on a permanent basis. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Fri May 2 18:40:59 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 02 May 2008 17:40:59 +0100 Subject: [IronPython] Announcing IronPython 2.0 Beta 2 In-Reply-To: References: <2C734460517A154B8E98AC8BA98D49A15DCFD2B336@NA-EXMSG-C105.redmond.corp.microsoft.com> <2C734460517A154B8E98AC8BA98D49A15DCFD2BBB4@NA-EXMSG-C105.redmond.corp.microsoft.com> Message-ID: <481B441B.5000208@voidspace.org.uk> w00t! I wonder if all my hosting samples are broken... :-) Michael Dave Fugate wrote: > > Hello IronPython Community, > > We?re pleased to announce the release of IronPython 2.0 Beta 2. In > addition to the usual bug fixes (~25 reported on CodePlex and ~50 > reported internally), this release has been partially focused on > improving the performance of IronPython, in particular startup perf. > Another focus of this release was improving upon our traceback support > which had regressed quite a bit in 2.0B1 and had largely been broken > in the 2.0 Alphas. Our traceback support should now be superior to > that of IronPython 1.1! > > We?ve also made a minor change to our packaging by adding a > Microsoft.Scripting.Core.dll in addition to the > Microsoft.Scripting.dll that?s been around since the start of 2.0. We > are doing this purely as an architectural layering cleanup. > Microsoft.Scripting.Core contains DLR features that are essential to > building dynamic languages. Microsoft.Scripting will contain language > implementation helpers that can either be re-used (e.g., BigInts) or > copied (possibly e.g., the default binder). This process is all about > our work to get the DLR architecture right and shouldn?t have any > noticeable IronPython impact except that there?s now one more DLL to > include in any package. > > As a consequence of the new DLL, the deprecated file > IronPython2005.sln is broken. This is the last release that will > include this .sln file in the source zip file. Of course the Visual > Studio 2008 version of this file, IronPython.sln, still builds. > > The following CodePlex Work Items have been closed since IronPython > 2.0 Beta 1 was released: > > ? 15835 FromImportStatement relative path not working > > ? 15832 parser is not validating FromImportStatement syntax > > ? 15793 dynamically bound __getattribute__ is overwritten after > modifying __bases__ > > ? 15752 derived __getattribute__ causes stack overflow > > ? 16057 BY DESIGN: Sublist parameter gets lost by Parser > > ? 15522 (Ipy2a8) Problems in module "dis" > > ? 15598 BY DESIGN: Problems with ScriptEngine.Execute on 2.0 Alpha 8 > > ? 16077 incorrect parsing of numeric literal __index__() call > > ? 945 Pickling exceptions with clsException in dict fails > > ? 15803 cPickle fails to load pickled object from submodule > > ? 15882 __delitem__ broken w/ tuple arguments > > ? 11923 Exception tracebacks lose line numbers after reload() > > ? 2409 Default exception dumper should get line info out of traceback > > ? 15715 dir(dict.fromkeys) fails with a cast-related TypeError after > calls to dir(dict) > > ? 13820 __getattribute__ called for magic methods > > ? 7429 traceback support inside generator and nested try inside except > block > > ? 15884 MAJOR REGRESSION: stack traces of simple errors missing file > names, line numbers, etc > > ? 8291 Tracebacks from compiled code objects dissimilar from CPython > > ? 11922 AssertionError is printed with an extraneous "None" > > ? 7766 __builtins__ should be module for main script, dictionary for > other modules > > ? 5803 when __add__ failed > > ? 2912 traceback's don't get created if exception is caught in same frame > > ? 6210 RawDecode method fails to return the string according the right > encoding > > ? 13687 2.0 alpha 5: Registering c#-written methods as event handlers > from ironpy throws TypeError: object is not callable. > > ? 11283 SyntaxError doesnt get lineno (or other properties) when > created by user code > > ? 15746 DUPLICATE: ipyw.exe without any parameters crash ( IronPython > 2.0 Beta 1 ) > > We?d like to thank everyone in the community who reported these: > kevgu, oldman, christmas, brucec, scottw, fuzzyman, haibo, Seo > Sanghyeon, grizlupo, J. Merrill, perhaps, antont, 05031972, Jason > Ferrara, Matt Beckius, and Davy Mitchell. > > Also, we?ve closed the following bugs that were reported internally: > > ? 148394 Trivial: Exception messages are not directed to sys.stderr > > ? 148481 Trivial: IronPythonConsole.exe with '-' : no response > > ? 148651 Possible race conditions during lock-unprotected reads from > Dictionary<,> > > ? 149018 Trivial: Python25: new api - deque.remove > > ? 151051 In CPython, divmod does not try on __floordiv__ and __mod__ > > ? 151094 Misc binary operation bugs > > ? 221344 Perf: Shootout/fasta is 74% worse when running IronPython 2.0 > vs. IronPython 1.1 > > ? 250921 Add more IronPython tests for property sets WRT value types > > ? 299898 test_coercion.py fails with method "test_cmptypes()" when the > two objects to be compared are not the same type in 32bit vista > > ? 301601 IP2.0 raise a syntaxError instead of an indentationError when > exec("foo()\n bar()\n") > > ? 314124 Implementing __coerce__ cause endless loop > > ? 314140 __eq__ threw AttributeError in IronPython but didn't in CPython > > ? 314459 gc.collect() always return 0 and can't have argument > > ? 314879 AttributeError: 'module' object has no attribute '__debug__' > > ? 314898 NotImplementedError for co_lnotab. > > ? 316130 heapq.heapreplace(None,None) throw a AttributeError instead > of TypeError > > ? 316148 sometimes nlargest(n, iterable) not equal to sorted(iterable, > reverse=True)[:n] > > ? 316520 it is different for func_defaults between Ironpython and > Cpython. > > ? 316523 it is different for func_dict between Ironpython and Cpython > > ? 317194 AttributeError: 'file' object has no attribute 'mode' > > ? 319014 it is different between Ironpython and Cpython when exec > "dict({}, {})" > > ? 319028 AttributeError: 'dictproxy' object has no attribute 'items' > > ? 319487 Instances of Set dosen't provide update() operation in > IronPython > > ? 320078 Trivial: TypeError: hex() argument cannot be converted to hex > > ? 320514 ImportError: No module named _functools > > ? 321852 Trivial: KeyError: __module__ > > ? 323570 startfile() can take two argument in cpython2.5 > > ? 325377 dict silently swallows exceptions when a key's __cmp__ method > throws > > ? 359635 "unknow command line:" in the output of "ipy.exe /help" > > ? 360510 some properties of func_code is not implemented > > ? 360987 None has a extra attribute '__module__' > > ? 361443 Re-enable test_traceback_cpy_20 > > ? 363019 yield statement must add an return value against Ironpython. > but Cpython don't need. > > ? 364736 compiling "from . import a" throw syntax error > > ? 364746 Can't from __future__ import absolute_import > > ? 365068 __getslice__(self, i, j): gets different result between > IrpnPython and CPython with UserList object > > ? 365242 excise __getattribute__ from derived new-style type > > ? 365367 sys.path_hooks is not implemented > > ? 369111 Ipy should try to use base type defined special operators > > ? 372549 Non-string attributes are not being added to a dictionary in > interactive mode > > ? 400941 REGRESSION: Re-enable merged modules which contain both a > .NET namespace and a normal module > > You can download IronPython 2.0 Beta 2 at: > http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=11566 > > > > The IronPython Team > > NOTES > > ToyScript, a small scripting language built on top of the DLR, is > merely a DLR sample and not some new scripting language Microsoft has > created. Also, ToyScript is not intended to be distributed with > IronPython on a permanent basis. > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From daftspaniel at gmail.com Fri May 2 21:49:01 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Fri, 2 May 2008 20:49:01 +0100 Subject: [IronPython] WPF Question Message-ID: <20253b0c0805021249y697456f7y5d37d391d0ab2626@mail.gmail.com> First - yay a new release well done ;-) Now a WPF Question... I am using a listbox and in VB.net used TheLisbox.SelectedItem.Content to get the string selected. Try this with IronPython (and after an impressively long traceback) the error is 'AttributeError: 'str' object has no attribute 'Content''. So IP has converted the 'Object' of SelectedItem straight to a string - handy for me but shouldn't it be a ListBoxItem? Thanks, Davy -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Sat May 3 02:59:43 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 2 May 2008 17:59:43 -0700 Subject: [IronPython] Unexpected error in 2.0B2 Message-ID: The following code works for me under B1, but throws an exception under B2: import clr import System name = System.Reflection.AssemblyName() name.Name = 'Test' assemblyBuilder = System.AppDomain.CurrentDomain.DefineDynamicAssembly(name, System.Reflection.Emit.AssemblyBuilderAccess.Run) The stack trace is, of course, entirely inside the CLR. Traceback (most recent call last): File "", line 1, in File "mscorlib", line unknown, in DefineDynamicAssembly File "mscorlib", line unknown, in InternalDefineDynamicAssembly File "mscorlib", line unknown, in nCreateDynamicAssembly File "mscorlib", line unknown, in CheckGrantSetHelper SystemError: Object reference not set to an instance of an object. Unfortunately, nCreateDynamicAssembly is an InternalCall, so I can't see exactly what it's doing. The only object reference in CheckGrantSetHelper is to a PermissionSet, presumably one of the three that are passed to nCreateDynamicAssembly. Based on the methods higher in the stack, I expect that all three PermissionSets passed to nCreateDynamicAssembly are null, but this would have been true under B1 as well. Have there been security-related changes made that could cause this problem? -- Curt Hagenlocher curt at hagenlocher.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.stephen.barnard at gmail.com Sat May 3 03:07:45 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Fri, 2 May 2008 18:07:45 -0700 Subject: [IronPython] [ironpython] running an ironpython script with .net 3.5 Message-ID: IPy is compiled against the .NET 2.0.x libraries: IronPython project: C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll IronPython.Modules: C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll And both reference Microsoft.Scripting, which references Microsoft.Scripting.Core: C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Configuration.dll etc. ___________________________ Matthew Barnard (pri) m.stephen.barnard at gmail.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.stephen.barnard at gmail.com Sat May 3 03:30:52 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Fri, 2 May 2008 18:30:52 -0700 Subject: [IronPython] List Message-ID: Is the following the only way to create a generic containing a python class? from System.Collections.Generic import List from System import Type class Foo: >>class stuff<< l = List[Type.GetType(Foo())]() I assume this is the nature of dynamic typing, but is there a way to get the type from the classobj, and not an instance? -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Sat May 3 04:46:55 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 2 May 2008 19:46:55 -0700 Subject: [IronPython] WPF Question In-Reply-To: <20253b0c0805021249y697456f7y5d37d391d0ab2626@mail.gmail.com> References: <20253b0c0805021249y697456f7y5d37d391d0ab2626@mail.gmail.com> Message-ID: If you add strings to the Items collection, then SelectedItem will contain strings. If you want the ListBoxItem, you have to do something like this: listbox.ItemContainerGenerator.ContainerFromIndex(listbox.SelectedIndex) This is true for both VB and IronPython because it's a function of the WPF control. On Fri, May 2, 2008 at 12:49 PM, Davy Mitchell wrote: > First - yay a new release well done ;-) > > Now a WPF Question... > > I am using a listbox and in VB.net used TheLisbox.SelectedItem.Content to > get the string selected. > > Try this with IronPython (and after an impressively long traceback) the > error is 'AttributeError: 'str' object has no attribute 'Content''. > > So IP has converted the 'Object' of SelectedItem straight to a string - > handy for me but shouldn't it be a ListBoxItem? > > Thanks, > Davy > > -- > Davy Mitchell > Blog - http://www.latedecember.co.uk/sites/personal/davy/ > Twitter - http://twitter.com/daftspaniel > Skype - daftspaniel http://needgod.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 Sat May 3 04:52:30 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 2 May 2008 19:52:30 -0700 Subject: [IronPython] List In-Reply-To: References: Message-ID: This will get you a CLR type directly from your class object: class foo(object): pass theType = clr.GetClrType(foo) What use do you have for creating a generic with the resulting (dynamically-generated) type? On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard wrote: > Is the following the only way to create a generic containing a python > class? > > > from System.Collections.Generic import List > from System import Type > > class Foo: > >>class stuff<< > > l = List[Type.GetType(Foo())]() > > > I assume this is the nature of dynamic typing, but is there a way to get > the type from the classobj, and not an instance? > > _______________________________________________ > 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 m.stephen.barnard at gmail.com Sat May 3 06:58:41 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Fri, 2 May 2008 21:58:41 -0700 Subject: [IronPython] List In-Reply-To: References: Message-ID: Thanks Curt, in C# I use generics (list & dict) containing class instances quite often. Is there a caveat to the dynamic typing that I'm missing? On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher wrote: > This will get you a CLR type directly from your class object: > > class foo(object): > pass > theType = clr.GetClrType(foo) > > What use do you have for creating a generic with the resulting > (dynamically-generated) type? > > On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard < > m.stephen.barnard at gmail.com> wrote: > > > Is the following the only way to create a generic containing a python > > class? > > > > > > from System.Collections.Generic import List > > from System import Type > > > > class Foo: > > >>class stuff<< > > > > l = List[Type.GetType(Foo())]() > > > > > > I assume this is the nature of dynamic typing, but is there a way to get > > the type from the classobj, and not an instance? > > > > _______________________________________________ > > 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 > > -- ___________________________ Matthew Barnard 602 540 0652 -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Sat May 3 07:17:13 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 2 May 2008 22:17:13 -0700 Subject: [IronPython] List In-Reply-To: References: Message-ID: Well in the example I gave, the type of class foo would genrally be something like IronPython.NewTypes.System.Object_1$2. There's not going to be any "native" CLR code to which you can pass a List, and if you're passing the data to other Python code, you may as well do it as a Python list or tuple. It's the "dynamic" thing to do :). List isn't even type-safe for Python classes because IronPython maintains a cache of generated types and will reuse a type it has previously generated for any new class you define that's compatible with a previously-defined class. On Fri, May 2, 2008 at 9:58 PM, Matthew Barnard wrote: > Thanks Curt, in C# I use generics (list & dict) containing class instances > quite often. Is there a caveat to the dynamic typing that I'm missing? > > > > On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher > wrote: > > > This will get you a CLR type directly from your class object: > > > > class foo(object): > > pass > > theType = clr.GetClrType(foo) > > > > What use do you have for creating a generic with the resulting > > (dynamically-generated) type? > > > > On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard < > > m.stephen.barnard at gmail.com> wrote: > > > > > Is the following the only way to create a generic containing a python > > > class? > > > > > > > > > from System.Collections.Generic import List > > > from System import Type > > > > > > class Foo: > > > >>class stuff<< > > > > > > l = List[Type.GetType(Foo())]() > > > > > > > > > I assume this is the nature of dynamic typing, but is there a way to > > > get the type from the classobj, and not an instance? > > > > > > _______________________________________________ > > > 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 > > > > > > > -- > ___________________________ > Matthew Barnard > 602 540 0652 > _______________________________________________ > 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 m.stephen.barnard at gmail.com Sat May 3 07:30:28 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Fri, 2 May 2008 22:30:28 -0700 Subject: [IronPython] List In-Reply-To: References: Message-ID: Ahhh interesting. It doesn't look good for remoting then ;) On Fri, May 2, 2008 at 10:17 PM, Curt Hagenlocher wrote: > Well in the example I gave, the type of class foo would genrally be > something like IronPython.NewTypes.System.Object_1$2. There's not going to > be any "native" CLR code to which you can pass a > List, and if you're passing the data > to other Python code, you may as well do it as a Python list or tuple. It's > the "dynamic" thing to do :). > > List isn't even type-safe for > Python classes because IronPython maintains a cache of generated types and > will reuse a type it has previously generated for any new class you define > that's compatible with a previously-defined class. > > > On Fri, May 2, 2008 at 9:58 PM, Matthew Barnard < > m.stephen.barnard at gmail.com> wrote: > > > Thanks Curt, in C# I use generics (list & dict) containing class > > instances quite often. Is there a caveat to the dynamic typing that I'm > > missing? > > > > > > > > On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher > > wrote: > > > > > This will get you a CLR type directly from your class object: > > > > > > class foo(object): > > > pass > > > theType = clr.GetClrType(foo) > > > > > > What use do you have for creating a generic with the resulting > > > (dynamically-generated) type? > > > > > > On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard < > > > m.stephen.barnard at gmail.com> wrote: > > > > > > > Is the following the only way to create a generic containing a > > > > python class? > > > > > > > > > > > > from System.Collections.Generic import List > > > > from System import Type > > > > > > > > class Foo: > > > > >>class stuff<< > > > > > > > > l = List[Type.GetType(Foo())]() > > > > > > > > > > > > I assume this is the nature of dynamic typing, but is there a way to > > > > get the type from the classobj, and not an instance? > > > > > > > > _______________________________________________ > > > > 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 > > > > > > > > > > > > -- > > ___________________________ > > Matthew Barnard > > 602 540 0652 > > _______________________________________________ > > 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 > > -- ___________________________ Matthew Barnard 602 540 0652 -------------- next part -------------- An HTML attachment was scrubbed... URL: From kfarmer at thuban.org Sat May 3 07:50:02 2008 From: kfarmer at thuban.org (Keith J. Farmer) Date: Fri, 2 May 2008 22:50:02 -0700 Subject: [IronPython] Announcing IronPython 2.0 Beta 2 In-Reply-To: <481B441B.5000208@voidspace.org.uk> References: <2C734460517A154B8E98AC8BA98D49A15DCFD2B336@NA-EXMSG-C105.redmond.corp.microsoft.com> <2C734460517A154B8E98AC8BA98D49A15DCFD2BBB4@NA-EXMSG-C105.redmond.corp.microsoft.com> <481B441B.5000208@voidspace.org.uk> Message-ID: IronPython.csproj appears to be referencing missing files: Error 12 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\AdapterDict.cs' could not be opened ('Unspecified error ') IronPython Error 8 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\ErrorCodes.cs' could not be opened ('Unspecified error ') IronPython Error 3 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\ModuleOptions.cs' could not be opened ('Unspecified error ') IronPython Error 16 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\PythonCompilerOptions.cs' could not be opened ('Unspecified error ') IronPython Error 15 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\ResourceFile.cs' could not be opened ('Unspecified error ') IronPython Error 14 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\CoreReflectedTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 1 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\ExtensibleType.cs' could not be opened ('Unspecified error ') IronPython Error 4 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\OldInstanceTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 7 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\OpsReflectedType.cs' could not be opened ('Unspecified error ') IronPython Error 2 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonModuleOps.cs' could not be opened ('Unspecified error ') IronPython Error 9 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 11 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeExtender.cs' could not be opened ('Unspecified error ') IronPython Error 10 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeExtender.Generated.cs' could not be opened ('Unspecified error ') IronPython Error 17 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeGetAttributeSlot.cs' could not be opened ('Unspecified error ') IronPython Error 6 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\ReflectedTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 13 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\TypeHelpers.cs' could not be opened ('Unspecified error ') IronPython Error 5 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\UserType.cs' could not be opened ('Unspecified error ') IronPython -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, May 02, 2008 9:41 AM To: Discussion of IronPython Subject: Re: [IronPython] Announcing IronPython 2.0 Beta 2 w00t! I wonder if all my hosting samples are broken... :-) Michael Dave Fugate wrote: > > Hello IronPython Community, > > We're pleased to announce the release of IronPython 2.0 Beta 2. In > addition to the usual bug fixes (~25 reported on CodePlex and ~50 > reported internally), this release has been partially focused on > improving the performance of IronPython, in particular startup perf. > Another focus of this release was improving upon our traceback support > which had regressed quite a bit in 2.0B1 and had largely been broken > in the 2.0 Alphas. Our traceback support should now be superior to > that of IronPython 1.1! > > We've also made a minor change to our packaging by adding a > Microsoft.Scripting.Core.dll in addition to the > Microsoft.Scripting.dll that's been around since the start of 2.0. We > are doing this purely as an architectural layering cleanup. > Microsoft.Scripting.Core contains DLR features that are essential to > building dynamic languages. Microsoft.Scripting will contain language > implementation helpers that can either be re-used (e.g., BigInts) or > copied (possibly e.g., the default binder). This process is all about > our work to get the DLR architecture right and shouldn't have any > noticeable IronPython impact except that there's now one more DLL to > include in any package. > > As a consequence of the new DLL, the deprecated file > IronPython2005.sln is broken. This is the last release that will > include this .sln file in the source zip file. Of course the Visual > Studio 2008 version of this file, IronPython.sln, still builds. > > The following CodePlex Work Items have been closed since IronPython > 2.0 Beta 1 was released: > > * 15835 FromImportStatement relative path not working > > * 15832 parser is not validating FromImportStatement syntax > > * 15793 dynamically bound __getattribute__ is overwritten after > modifying __bases__ > > * 15752 derived __getattribute__ causes stack overflow > > * 16057 BY DESIGN: Sublist parameter gets lost by Parser > > * 15522 (Ipy2a8) Problems in module "dis" > > * 15598 BY DESIGN: Problems with ScriptEngine.Execute on 2.0 Alpha 8 > > * 16077 incorrect parsing of numeric literal __index__() call > > * 945 Pickling exceptions with clsException in dict fails > > * 15803 cPickle fails to load pickled object from submodule > > * 15882 __delitem__ broken w/ tuple arguments > > * 11923 Exception tracebacks lose line numbers after reload() > > * 2409 Default exception dumper should get line info out of traceback > > * 15715 dir(dict.fromkeys) fails with a cast-related TypeError after > calls to dir(dict) > > * 13820 __getattribute__ called for magic methods > > * 7429 traceback support inside generator and nested try inside except > block > > * 15884 MAJOR REGRESSION: stack traces of simple errors missing file > names, line numbers, etc > > * 8291 Tracebacks from compiled code objects dissimilar from CPython > > * 11922 AssertionError is printed with an extraneous "None" > > * 7766 __builtins__ should be module for main script, dictionary for > other modules > > * 5803 when __add__ failed > > * 2912 traceback's don't get created if exception is caught in same frame > > * 6210 RawDecode method fails to return the string according the right > encoding > > * 13687 2.0 alpha 5: Registering c#-written methods as event handlers > from ironpy throws TypeError: object is not callable. > > * 11283 SyntaxError doesnt get lineno (or other properties) when > created by user code > > * 15746 DUPLICATE: ipyw.exe without any parameters crash ( IronPython > 2.0 Beta 1 ) > > We'd like to thank everyone in the community who reported these: > kevgu, oldman, christmas, brucec, scottw, fuzzyman, haibo, Seo > Sanghyeon, grizlupo, J. Merrill, perhaps, antont, 05031972, Jason > Ferrara, Matt Beckius, and Davy Mitchell. > > Also, we've closed the following bugs that were reported internally: > > * 148394 Trivial: Exception messages are not directed to sys.stderr > > * 148481 Trivial: IronPythonConsole.exe with '-' : no response > > * 148651 Possible race conditions during lock-unprotected reads from > Dictionary<,> > > * 149018 Trivial: Python25: new api - deque.remove > > * 151051 In CPython, divmod does not try on __floordiv__ and __mod__ > > * 151094 Misc binary operation bugs > > * 221344 Perf: Shootout/fasta is 74% worse when running IronPython 2.0 > vs. IronPython 1.1 > > * 250921 Add more IronPython tests for property sets WRT value types > > * 299898 test_coercion.py fails with method "test_cmptypes()" when the > two objects to be compared are not the same type in 32bit vista > > * 301601 IP2.0 raise a syntaxError instead of an indentationError when > exec("foo()\n bar()\n") > > * 314124 Implementing __coerce__ cause endless loop > > * 314140 __eq__ threw AttributeError in IronPython but didn't in CPython > > * 314459 gc.collect() always return 0 and can't have argument > > * 314879 AttributeError: 'module' object has no attribute '__debug__' > > * 314898 NotImplementedError for co_lnotab. > > * 316130 heapq.heapreplace(None,None) throw a AttributeError instead > of TypeError > > * 316148 sometimes nlargest(n, iterable) not equal to sorted(iterable, > reverse=True)[:n] > > * 316520 it is different for func_defaults between Ironpython and > Cpython. > > * 316523 it is different for func_dict between Ironpython and Cpython > > * 317194 AttributeError: 'file' object has no attribute 'mode' > > * 319014 it is different between Ironpython and Cpython when exec > "dict({}, {})" > > * 319028 AttributeError: 'dictproxy' object has no attribute 'items' > > * 319487 Instances of Set dosen't provide update() operation in > IronPython > > * 320078 Trivial: TypeError: hex() argument cannot be converted to hex > > * 320514 ImportError: No module named _functools > > * 321852 Trivial: KeyError: __module__ > > * 323570 startfile() can take two argument in cpython2.5 > > * 325377 dict silently swallows exceptions when a key's __cmp__ method > throws > > * 359635 "unknow command line:" in the output of "ipy.exe /help" > > * 360510 some properties of func_code is not implemented > > * 360987 None has a extra attribute '__module__' > > * 361443 Re-enable test_traceback_cpy_20 > > * 363019 yield statement must add an return value against Ironpython. > but Cpython don't need. > > * 364736 compiling "from . import a" throw syntax error > > * 364746 Can't from __future__ import absolute_import > > * 365068 __getslice__(self, i, j): gets different result between > IrpnPython and CPython with UserList object > > * 365242 excise __getattribute__ from derived new-style type > > * 365367 sys.path_hooks is not implemented > > * 369111 Ipy should try to use base type defined special operators > > * 372549 Non-string attributes are not being added to a dictionary in > interactive mode > > * 400941 REGRESSION: Re-enable merged modules which contain both a > .NET namespace and a normal module > > You can download IronPython 2.0 Beta 2 at: > http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPyt hon&ReleaseId=11566 > > > > The IronPython Team > > NOTES > > ToyScript, a small scripting language built on top of the DLR, is > merely a DLR sample and not some new scripting language Microsoft has > created. Also, ToyScript is not intended to be distributed with > IronPython on a permanent basis. > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 sls at iinet.net.au Sat May 3 07:50:58 2008 From: sls at iinet.net.au (Paul Turbett) Date: Sat, 03 May 2008 13:50:58 +0800 Subject: [IronPython] List In-Reply-To: References: Message-ID: <481BFD42.4010502@iinet.net.au> No, not really. I recently looked into serializing IPY class instances from C# in a hosting environment. I got it to work using some custom serialization code. Look into ISerializationSurrogate - I made a class that derives from it to make a custom Python object serializer. The python engine still needs the python class type to be define and "compiled" to be able to re-build the objects. It's a bit curly and ugly, and I'm still not sure what gotchas are lying in wait :) L8r, Paul Matthew Barnard wrote: > Ahhh interesting. It doesn't look good for remoting then ;) > > > On Fri, May 2, 2008 at 10:17 PM, Curt Hagenlocher > > wrote: > > Well in the example I gave, the type of class foo would genrally > be something like IronPython.NewTypes.System.Object_1$2. There's > not going to be any "native" CLR code to which you can pass a > List, and if you're passing > the data to other Python code, you may as well do it as a Python > list or tuple. It's the "dynamic" thing to do :). > > List isn't even type-safe > for Python classes because IronPython maintains a cache of > generated types and will reuse a type it has previously generated > for any new class you define that's compatible with a > previously-defined class. > > > On Fri, May 2, 2008 at 9:58 PM, Matthew Barnard > > > wrote: > > Thanks Curt, in C# I use generics (list & dict) containing > class instances quite often. Is there a caveat to the dynamic > typing that I'm missing? > > > > On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher > > wrote: > > This will get you a CLR type directly from your class object: > > class foo(object): > pass > theType = clr.GetClrType(foo) > > What use do you have for creating a generic with the > resulting (dynamically-generated) type? > > On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard > > wrote: > > Is the following the only way to create a generic > containing a python class? > > > from System.Collections.Generic import List > from System import Type > > class Foo: > >>class stuff<< > > l = List[Type.GetType(Foo())]() > > > I assume this is the nature of dynamic typing, but is > there a way to get the type from the classobj, and not > an instance? > > _______________________________________________ > 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 > > > > > -- > ___________________________ > Matthew Barnard > 602 540 0652 > _______________________________________________ > 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 > > > > > -- > ___________________________ > Matthew Barnard > 602 540 0652 > ------------------------------------------------------------------------ > > _______________________________________________ > 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 Sat May 3 07:52:14 2008 From: kfarmer at thuban.org (Keith J. Farmer) Date: Fri, 2 May 2008 22:52:14 -0700 Subject: [IronPython] Announcing IronPython 2.0 Beta 2 In-Reply-To: References: <2C734460517A154B8E98AC8BA98D49A15DCFD2B336@NA-EXMSG-C105.redmond.corp.microsoft.com> <2C734460517A154B8E98AC8BA98D49A15DCFD2BBB4@NA-EXMSG-C105.redmond.corp.microsoft.com><481B441B.5000208@voidspace.org.uk> Message-ID: ... which was fixed in the last half hour or so, I see. :) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Keith J. Farmer Sent: Friday, May 02, 2008 10:50 PM To: Discussion of IronPython Subject: Re: [IronPython] Announcing IronPython 2.0 Beta 2 IronPython.csproj appears to be referencing missing files: Error 12 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\AdapterDict.cs' could not be opened ('Unspecified error ') IronPython Error 8 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\ErrorCodes.cs' could not be opened ('Unspecified error ') IronPython Error 3 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\ModuleOptions.cs' could not be opened ('Unspecified error ') IronPython Error 16 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\PythonCompilerOptions.cs' could not be opened ('Unspecified error ') IronPython Error 15 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Hosti ng\ResourceFile.cs' could not be opened ('Unspecified error ') IronPython Error 14 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\CoreReflectedTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 1 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\ExtensibleType.cs' could not be opened ('Unspecified error ') IronPython Error 4 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\OldInstanceTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 7 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\OpsReflectedType.cs' could not be opened ('Unspecified error ') IronPython Error 2 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonModuleOps.cs' could not be opened ('Unspecified error ') IronPython Error 9 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 11 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeExtender.cs' could not be opened ('Unspecified error ') IronPython Error 10 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeExtender.Generated.cs' could not be opened ('Unspecified error ') IronPython Error 17 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\PythonTypeGetAttributeSlot.cs' could not be opened ('Unspecified error ') IronPython Error 6 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\ReflectedTypeBuilder.cs' could not be opened ('Unspecified error ') IronPython Error 13 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\TypeHelpers.cs' could not be opened ('Unspecified error ') IronPython Error 5 Source file 'C:\Users\kfarmer\Workspace\Sandbox\IronPython_Main\Src\IronPython\Runti me\Types\UserType.cs' could not be opened ('Unspecified error ') IronPython -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, May 02, 2008 9:41 AM To: Discussion of IronPython Subject: Re: [IronPython] Announcing IronPython 2.0 Beta 2 w00t! I wonder if all my hosting samples are broken... :-) Michael Dave Fugate wrote: > > Hello IronPython Community, > > We're pleased to announce the release of IronPython 2.0 Beta 2. In > addition to the usual bug fixes (~25 reported on CodePlex and ~50 > reported internally), this release has been partially focused on > improving the performance of IronPython, in particular startup perf. > Another focus of this release was improving upon our traceback support > which had regressed quite a bit in 2.0B1 and had largely been broken > in the 2.0 Alphas. Our traceback support should now be superior to > that of IronPython 1.1! > > We've also made a minor change to our packaging by adding a > Microsoft.Scripting.Core.dll in addition to the > Microsoft.Scripting.dll that's been around since the start of 2.0. We > are doing this purely as an architectural layering cleanup. > Microsoft.Scripting.Core contains DLR features that are essential to > building dynamic languages. Microsoft.Scripting will contain language > implementation helpers that can either be re-used (e.g., BigInts) or > copied (possibly e.g., the default binder). This process is all about > our work to get the DLR architecture right and shouldn't have any > noticeable IronPython impact except that there's now one more DLL to > include in any package. > > As a consequence of the new DLL, the deprecated file > IronPython2005.sln is broken. This is the last release that will > include this .sln file in the source zip file. Of course the Visual > Studio 2008 version of this file, IronPython.sln, still builds. > > The following CodePlex Work Items have been closed since IronPython > 2.0 Beta 1 was released: > > * 15835 FromImportStatement relative path not working > > * 15832 parser is not validating FromImportStatement syntax > > * 15793 dynamically bound __getattribute__ is overwritten after > modifying __bases__ > > * 15752 derived __getattribute__ causes stack overflow > > * 16057 BY DESIGN: Sublist parameter gets lost by Parser > > * 15522 (Ipy2a8) Problems in module "dis" > > * 15598 BY DESIGN: Problems with ScriptEngine.Execute on 2.0 Alpha 8 > > * 16077 incorrect parsing of numeric literal __index__() call > > * 945 Pickling exceptions with clsException in dict fails > > * 15803 cPickle fails to load pickled object from submodule > > * 15882 __delitem__ broken w/ tuple arguments > > * 11923 Exception tracebacks lose line numbers after reload() > > * 2409 Default exception dumper should get line info out of traceback > > * 15715 dir(dict.fromkeys) fails with a cast-related TypeError after > calls to dir(dict) > > * 13820 __getattribute__ called for magic methods > > * 7429 traceback support inside generator and nested try inside except > block > > * 15884 MAJOR REGRESSION: stack traces of simple errors missing file > names, line numbers, etc > > * 8291 Tracebacks from compiled code objects dissimilar from CPython > > * 11922 AssertionError is printed with an extraneous "None" > > * 7766 __builtins__ should be module for main script, dictionary for > other modules > > * 5803 when __add__ failed > > * 2912 traceback's don't get created if exception is caught in same frame > > * 6210 RawDecode method fails to return the string according the right > encoding > > * 13687 2.0 alpha 5: Registering c#-written methods as event handlers > from ironpy throws TypeError: object is not callable. > > * 11283 SyntaxError doesnt get lineno (or other properties) when > created by user code > > * 15746 DUPLICATE: ipyw.exe without any parameters crash ( IronPython > 2.0 Beta 1 ) > > We'd like to thank everyone in the community who reported these: > kevgu, oldman, christmas, brucec, scottw, fuzzyman, haibo, Seo > Sanghyeon, grizlupo, J. Merrill, perhaps, antont, 05031972, Jason > Ferrara, Matt Beckius, and Davy Mitchell. > > Also, we've closed the following bugs that were reported internally: > > * 148394 Trivial: Exception messages are not directed to sys.stderr > > * 148481 Trivial: IronPythonConsole.exe with '-' : no response > > * 148651 Possible race conditions during lock-unprotected reads from > Dictionary<,> > > * 149018 Trivial: Python25: new api - deque.remove > > * 151051 In CPython, divmod does not try on __floordiv__ and __mod__ > > * 151094 Misc binary operation bugs > > * 221344 Perf: Shootout/fasta is 74% worse when running IronPython 2.0 > vs. IronPython 1.1 > > * 250921 Add more IronPython tests for property sets WRT value types > > * 299898 test_coercion.py fails with method "test_cmptypes()" when the > two objects to be compared are not the same type in 32bit vista > > * 301601 IP2.0 raise a syntaxError instead of an indentationError when > exec("foo()\n bar()\n") > > * 314124 Implementing __coerce__ cause endless loop > > * 314140 __eq__ threw AttributeError in IronPython but didn't in CPython > > * 314459 gc.collect() always return 0 and can't have argument > > * 314879 AttributeError: 'module' object has no attribute '__debug__' > > * 314898 NotImplementedError for co_lnotab. > > * 316130 heapq.heapreplace(None,None) throw a AttributeError instead > of TypeError > > * 316148 sometimes nlargest(n, iterable) not equal to sorted(iterable, > reverse=True)[:n] > > * 316520 it is different for func_defaults between Ironpython and > Cpython. > > * 316523 it is different for func_dict between Ironpython and Cpython > > * 317194 AttributeError: 'file' object has no attribute 'mode' > > * 319014 it is different between Ironpython and Cpython when exec > "dict({}, {})" > > * 319028 AttributeError: 'dictproxy' object has no attribute 'items' > > * 319487 Instances of Set dosen't provide update() operation in > IronPython > > * 320078 Trivial: TypeError: hex() argument cannot be converted to hex > > * 320514 ImportError: No module named _functools > > * 321852 Trivial: KeyError: __module__ > > * 323570 startfile() can take two argument in cpython2.5 > > * 325377 dict silently swallows exceptions when a key's __cmp__ method > throws > > * 359635 "unknow command line:" in the output of "ipy.exe /help" > > * 360510 some properties of func_code is not implemented > > * 360987 None has a extra attribute '__module__' > > * 361443 Re-enable test_traceback_cpy_20 > > * 363019 yield statement must add an return value against Ironpython. > but Cpython don't need. > > * 364736 compiling "from . import a" throw syntax error > > * 364746 Can't from __future__ import absolute_import > > * 365068 __getslice__(self, i, j): gets different result between > IrpnPython and CPython with UserList object > > * 365242 excise __getattribute__ from derived new-style type > > * 365367 sys.path_hooks is not implemented > > * 369111 Ipy should try to use base type defined special operators > > * 372549 Non-string attributes are not being added to a dictionary in > interactive mode > > * 400941 REGRESSION: Re-enable merged modules which contain both a > .NET namespace and a normal module > > You can download IronPython 2.0 Beta 2 at: > http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPyt hon&ReleaseId=11566 > > > > The IronPython Team > > NOTES > > ToyScript, a small scripting language built on top of the DLR, is > merely a DLR sample and not some new scripting language Microsoft has > created. Also, ToyScript is not intended to be distributed with > IronPython on a permanent basis. > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 jdhardy at gmail.com Sat May 3 08:20:16 2008 From: jdhardy at gmail.com (Jeff Hardy) Date: Sat, 3 May 2008 00:20:16 -0600 Subject: [IronPython] SCons on IronPython 2.0B2 Message-ID: Hi all, SCons now 'works' on IronPython 2.0b2. I can compile a very simple C++ project, but there are a few caveats: * no registry module, so no tool detection. The SConscript needs to import the environment to find any tools. * Need a dummy signal module (attached) * Need a subprocess module (http://www.ironpython.info/index.php/The_subprocess_module) * There are a few small oddities, so the attached patch to SCons is required. Relevant IronPython bugs have been filed, of course :) I have opened SCons issue #2043 to track all of this. I hope I've included all of the details. The signal and subprocess modules need to be in the IronPython\Lib directory (or somewhere in IRONPYTHONPATH). Obviously, the Python 2.5 standard library must be available as well. I don't think the patch should be included in its current condition; I'm not 100% sure all the changes work with pure Python. It's pretty simple to block stuff off with sys.platform == 'cli', though. I'm going to try to push it a little harder now, but this is a good first start. -Jeff -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: scons-ipy-20080503.patch URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: signal.py URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: hello.c URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: SConstruct URL: From dinov at exchange.microsoft.com Sat May 3 08:35:12 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 2 May 2008 23:35:12 -0700 Subject: [IronPython] List In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012B27AD8299@DF-GRTDANE-MSG.exchange.corp.microsoft.com> "List isn't even type-safe for Python classes because IronPython maintains a cache of generated types and will reuse a type it has previously generated for any new class you define that's compatible with a previously-defined class." This has always been a lingering thought in the back of my head - I've been wondering how long it'd be until it came up. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Curt Hagenlocher Sent: Friday, May 02, 2008 10:17 PM To: Discussion of IronPython Subject: Re: [IronPython] List Well in the example I gave, the type of class foo would genrally be something like IronPython.NewTypes.System.Object_1$2. There's not going to be any "native" CLR code to which you can pass a List, and if you're passing the data to other Python code, you may as well do it as a Python list or tuple. It's the "dynamic" thing to do :). List isn't even type-safe for Python classes because IronPython maintains a cache of generated types and will reuse a type it has previously generated for any new class you define that's compatible with a previously-defined class. On Fri, May 2, 2008 at 9:58 PM, Matthew Barnard > wrote: Thanks Curt, in C# I use generics (list & dict) containing class instances quite often. Is there a caveat to the dynamic typing that I'm missing? On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher > wrote: This will get you a CLR type directly from your class object: class foo(object): pass theType = clr.GetClrType(foo) What use do you have for creating a generic with the resulting (dynamically-generated) type? On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard > wrote: Is the following the only way to create a generic containing a python class? from System.Collections.Generic import List from System import Type class Foo: >>class stuff<< l = List[Type.GetType(Foo())]() I assume this is the nature of dynamic typing, but is there a way to get the type from the classobj, and not an instance? _______________________________________________ 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 -- ___________________________ Matthew Barnard 602 540 0652 _______________________________________________ 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 taozuhong at qq.com Sat May 3 08:39:30 2008 From: taozuhong at qq.com (=?ISO-8859-1?B?QW5keS5UYW8=?=) Date: Sat, 3 May 2008 14:39:30 +0800 Subject: [IronPython] Announcing IronPython 2.0 Beta 2 Message-ID: maybe that is a bug: the detail as follow: private void btnExecute_Click(object sender, EventArgs e) { try { ScriptRuntimeSetup runtimeSetup = new ScriptRuntimeSetup(true); ScriptRuntime ScriptRuntime = ScriptRuntime.Create(runtimeSetup); ScriptRuntime.GlobalOptions.DebugMode = true; ScriptEngine scriptEngine = ScriptRuntime.GetEngine("py"); scriptEngine.CreateScriptSourceFromString(txtScriptSource.Text).Execute(); // this line will be throw out a exception scriptEngine.CreateScriptSourceFromString(txtScriptSource.Text, SourceCodeKind.Statements).Execute(); //this line OK //m_RemoteScript.ExecuteCode(txtScriptSource.Text); } catch(Exception ee) { MessageBox.Show(ee.Message); } } -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: IronPython_2.0B2.JPG Type: application/octet-stream Size: 33306 bytes Desc: not available URL: From dinov at exchange.microsoft.com Sat May 3 08:49:41 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 2 May 2008 23:49:41 -0700 Subject: [IronPython] SCons on IronPython 2.0B2 In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012B27AD829A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Is "no registry module" _winreg or is it something else? The good news here might be that Srivatsn has implemented this for Beta 3 (along w/ cmath) but it didn't quite make it into b2. Let us know if we end up pushing any bugs to statuses you don't like. BTW are all the bugs you've opened related to SCons or are some other issues? I'd also not mind seeing a bug calling for a dummy signal module :). And of course thanks for the update! -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy Sent: Friday, May 02, 2008 11:20 PM To: Discussion of IronPython; dev at scons.tigris.org Subject: [IronPython] SCons on IronPython 2.0B2 Hi all, SCons now 'works' on IronPython 2.0b2. I can compile a very simple C++ project, but there are a few caveats: * no registry module, so no tool detection. The SConscript needs to import the environment to find any tools. * Need a dummy signal module (attached) * Need a subprocess module (http://www.ironpython.info/index.php/The_subprocess_module) * There are a few small oddities, so the attached patch to SCons is required. Relevant IronPython bugs have been filed, of course :) I have opened SCons issue #2043 to track all of this. I hope I've included all of the details. The signal and subprocess modules need to be in the IronPython\Lib directory (or somewhere in IRONPYTHONPATH). Obviously, the Python 2.5 standard library must be available as well. I don't think the patch should be included in its current condition; I'm not 100% sure all the changes work with pure Python. It's pretty simple to block stuff off with sys.platform == 'cli', though. I'm going to try to push it a little harder now, but this is a good first start. -Jeff From dinov at exchange.microsoft.com Sat May 3 09:15:11 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sat, 3 May 2008 00:15:11 -0700 Subject: [IronPython] List In-Reply-To: <481BFD42.4010502@iinet.net.au> References: <481BFD42.4010502@iinet.net.au> Message-ID: <7AD436E4270DD54A94238001769C2227012B27AD829C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I think ultimately we want to unify pickle and .NET serialization so that this works seamless. That'd be that ISerializable object's would get a magically _reduce__ or __reduce_ex__ methods (and appropriate __new__ methods I guess). Also Python classes that implement the protocols for pickling would also be serializable. I've opened a task to track this (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16415) but I agree with your assessment - currently remoting of Python objects doesn't look very feasible. I'd encourage you and anyone else to vote on this if you're interested in us providing this natively. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Paul Turbett Sent: Friday, May 02, 2008 10:51 PM To: Discussion of IronPython Subject: Re: [IronPython] List No, not really. I recently looked into serializing IPY class instances from C# in a hosting environment. I got it to work using some custom serialization code. Look into ISerializationSurrogate - I made a class that derives from it to make a custom Python object serializer. The python engine still needs the python class type to be define and "compiled" to be able to re-build the objects. It's a bit curly and ugly, and I'm still not sure what gotchas are lying in wait :) L8r, Paul Matthew Barnard wrote: Ahhh interesting. It doesn't look good for remoting then ;) On Fri, May 2, 2008 at 10:17 PM, Curt Hagenlocher > wrote: Well in the example I gave, the type of class foo would genrally be something like IronPython.NewTypes.System.Object_1$2. There's not going to be any "native" CLR code to which you can pass a List, and if you're passing the data to other Python code, you may as well do it as a Python list or tuple. It's the "dynamic" thing to do :). List isn't even type-safe for Python classes because IronPython maintains a cache of generated types and will reuse a type it has previously generated for any new class you define that's compatible with a previously-defined class. On Fri, May 2, 2008 at 9:58 PM, Matthew Barnard > wrote: Thanks Curt, in C# I use generics (list & dict) containing class instances quite often. Is there a caveat to the dynamic typing that I'm missing? On Fri, May 2, 2008 at 7:52 PM, Curt Hagenlocher > wrote: This will get you a CLR type directly from your class object: class foo(object): pass theType = clr.GetClrType(foo) What use do you have for creating a generic with the resulting (dynamically-generated) type? On Fri, May 2, 2008 at 6:30 PM, Matthew Barnard > wrote: Is the following the only way to create a generic containing a python class? from System.Collections.Generic import List from System import Type class Foo: >>class stuff<< l = List[Type.GetType(Foo())]() I assume this is the nature of dynamic typing, but is there a way to get the type from the classobj, and not an instance? _______________________________________________ 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 -- ___________________________ Matthew Barnard 602 540 0652 _______________________________________________ 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 -- ___________________________ Matthew Barnard 602 540 0652 ________________________________ _______________________________________________ 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 jdhardy at gmail.com Sat May 3 09:39:44 2008 From: jdhardy at gmail.com (Jeff Hardy) Date: Sat, 3 May 2008 01:39:44 -0600 Subject: [IronPython] SCons on IronPython 2.0B2 In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012B27AD829A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Hi Dino, Yeah, _winreg is what's missing. Good to hear that it will be coming soon! Not every bug I've filed is related to SCons (some are Trac-related, and maybe even a couple from elsewhere). I've just been testing random apps (primarily WSGI-enabled webapps), seeing what breaks, and filing bugs. What's the best way to push up the priority of a bug? Codeplex comments? Mailing list? I know of a few that are set for 2.1 that I'd like to see sooner. -Jeff On Sat, May 3, 2008 at 12:49 AM, Dino Viehland wrote: > Is "no registry module" _winreg or is it something else? The good news here might be that Srivatsn has implemented this for Beta 3 (along w/ cmath) but it didn't quite make it into b2. > > Let us know if we end up pushing any bugs to statuses you don't like. BTW are all the bugs you've opened related to SCons or are some other issues? I'd also not mind seeing a bug calling for a dummy signal module :). > > And of course thanks for the update! > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > Sent: Friday, May 02, 2008 11:20 PM > To: Discussion of IronPython; dev at scons.tigris.org > Subject: [IronPython] SCons on IronPython 2.0B2 > > Hi all, > SCons now 'works' on IronPython 2.0b2. I can compile a very simple C++ project, but there are a few caveats: > * no registry module, so no tool detection. The SConscript needs to import the environment to find any tools. > * Need a dummy signal module (attached) > * Need a subprocess module > (http://www.ironpython.info/index.php/The_subprocess_module) > * There are a few small oddities, so the attached patch to SCons is required. Relevant IronPython bugs have been filed, of course :) > > I have opened SCons issue #2043 to track all of this. I hope I've included all of the details. The signal and subprocess modules need to be in the IronPython\Lib directory (or somewhere in IRONPYTHONPATH). > Obviously, the Python 2.5 standard library must be available as well. > > I don't think the patch should be included in its current condition; I'm not 100% sure all the changes work with pure Python. It's pretty simple to block stuff off with sys.platform == 'cli', though. > > I'm going to try to push it a little harder now, but this is a good first start. > > -Jeff > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe at scons.tigris.org > For additional commands, e-mail: dev-help at scons.tigris.org > > From m.stephen.barnard at gmail.com Sat May 3 10:41:14 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Sat, 3 May 2008 01:41:14 -0700 Subject: [IronPython] Announcing IronPython 2.0 Beta 2 In-Reply-To: References: Message-ID: This is the expected behavior. CreateScriptSourceFromString(string) defaults to SourceCodeKind.Expression (ScriptEngine.cs) ------------------------------------------ public ScriptSource/*!*/ CreateScriptSourceFromString(string/*!*/ code) { ContractUtils.RequiresNotNull(code, "code"); return CreateScriptSource(new SourceStringContentProvider(code), null, SourceCodeKind.Expression); } ---------------------------------------------- On Fri, May 2, 2008 at 11:39 PM, Andy.Tao wrote: > maybe that is a bug: > > > the detail as follow: > private void btnExecute_Click(object sender, EventArgs e) > { > try > { > ScriptRuntimeSetup runtimeSetup = new ScriptRuntimeSetup(true); > ScriptRuntime ScriptRuntime = ScriptRuntime.Create(runtimeSetup); > ScriptRuntime.GlobalOptions.DebugMode = true; > > ScriptEngine scriptEngine = ScriptRuntime.GetEngine("py"); > > scriptEngine.CreateScriptSourceFromString(txtScriptSource.Text).Execute(); > // this line will be throw out a exception > scriptEngine.CreateScriptSourceFromString(txtScriptSource.Text, > SourceCodeKind.Statements).Execute(); //this line OK > > > //m_RemoteScript.ExecuteCode(txtScriptSource.Text); > } > catch(Exception ee) > { > MessageBox.Show(ee.Message); > } > } > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- ___________________________ Matthew Barnard 602 540 0652 -------------- next part -------------- An HTML attachment was scrubbed... URL: From sakesun at boonthavorn.com Sat May 3 11:22:17 2008 From: sakesun at boonthavorn.com (=?utf-8?B?IOC5gOC4quC4geC4quC4o+C4o+C4hOC5jA==?=) Date: Sat, 3 May 2008 16:22:17 +0700 Subject: [IronPython] Unexpected error in 2.0B2 Message-ID: <54863.1209806537@boonthavorn.com> Hi, I'm going to post exactly the same issue. I also have similar (but not exact) problem with B1. But I cannot reproduce here. It looks like IP2 have done something special with System.Reflection ----- Original Message ----- From: "Curt Hagenlocher" curt at hagenlocher.org To: "Discussion of IronPython" users at lists.ironpython.com Sent: Sat 03/05/08 7:59 AM Subject: Re: [IronPython] Unexpected error in 2.0B2 The following code works for me under B1, but throws an exception under B2: import clr import System name = System.Reflection.AssemblyName() name.Name = 'Test' assemblyBuilder = System.AppDomain.CurrentDomain.DefineDynamicAssembly(name, System.Reflection.Emit.AssemblyBuilderAccess.Run) The stack trace is, of course, entirely inside the CLR. Traceback (most recent call last): File "", line 1, in File "mscorlib", line unknown, in DefineDynamicAssembly File "mscorlib", line unknown, in InternalDefineDynamicAssembly File "mscorlib", line unknown, in nCreateDynamicAssembly File "mscorlib", line unknown, in CheckGrantSetHelper SystemError: Object reference not set to an instance of an object. ------------------------- Boonthavorn Ceramic Co.,Ltd. Information Technology Department (Technic Section) -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan.eloff at gmail.com Sat May 3 20:58:21 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Sat, 3 May 2008 13:58:21 -0500 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs Message-ID: <4817b6fc0805031158h58cea392p1f770e5f5eff934d@mail.gmail.com> Trying to build the new Beta 2 "Silverlight Debug" but it references a file that does not exist either in the Silverlight SDK or IronPython. How can I fix this? Thanks, -Dan From daftspaniel at gmail.com Sat May 3 22:03:05 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Sat, 3 May 2008 21:03:05 +0100 Subject: [IronPython] WPF Question In-Reply-To: References: <20253b0c0805021249y697456f7y5d37d391d0ab2626@mail.gmail.com> Message-ID: <20253b0c0805031303s48a4b29duf1957b2361f2a0cb@mail.gmail.com> Thanks Curt - turns out the selected listbox entry in the VB app was a ListBoxItem (added in the designer),so of course they would be different. I forgot to check the XAML file... Doh! :-) Davy On Sat, May 3, 2008 at 3:46 AM, Curt Hagenlocher wrote: > If you add strings to the Items collection, then SelectedItem will contain > strings. If you want the ListBoxItem, you have to do something like this: > listbox.ItemContainerGenerator.ContainerFromIndex(listbox.SelectedIndex) > > This is true for both VB and IronPython because it's a function of the WPF > control. > > On Fri, May 2, 2008 at 12:49 PM, Davy Mitchell > wrote: > > > First - yay a new release well done ;-) > > > > Now a WPF Question... > > > > I am using a listbox and in VB.net used TheLisbox.SelectedItem.Content > > to get the string selected. > > > > Try this with IronPython (and after an impressively long traceback) the > > error is 'AttributeError: 'str' object has no attribute 'Content''. > > > > So IP has converted the 'Object' of SelectedItem straight to a string - > > handy for me but shouldn't it be a ListBoxItem? > > > > Thanks, > > Davy > > > > -- > > Davy Mitchell > > Blog - http://www.latedecember.co.uk/sites/personal/davy/ > > Twitter - http://twitter.com/daftspaniel > > Skype - daftspaniel http://needgod.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 > > -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Sat May 3 22:15:11 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sat, 3 May 2008 13:15:11 -0700 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: <4817b6fc0805031158h58cea392p1f770e5f5eff934d@mail.gmail.com> Message-ID: Good question; right now there's not an easy answer, since Microsoft.Scripting.Silverlight is not packaged with IronPython ... i.e. IronPython on http://codeplex.com/ironpython is only ensured to work on the Desktop. The IronPython version on http://codeplex.com/sdlsdk will always work with the current released version of Silverlight. However, sdlsdk does not get updated as often as ironpython, and there's kind of a good reason for that. As we're working on IronPython, we need it to stay working with internal builds of Silverlight. Also keeping it working with the public Silverlight bits at the same time would be significantly harder, as we'd need to have a branch for IronPython+DLR+SLBeta1 and backporting all our work to there to make sure it still works. It's the tradeoff of either releasing IronPython working when Silverlight releases, or having every release of IronPython always work on the current version of Silverlight. If we also shipped the Microsoft.Scripting.Silverlight that correspond to each IronPython release, it could just work with the public SL release. We'd need it to be tested though, and I'm not sure how much free time Dave has. =) I agree, it's a little confusing to see the "Silverlight Debug/Release" builds and have them not work. We should remove it if it won't build. So, does this piss you off? Personally I like that we're able to ship Python immediately with a new version of SL, but I'd like to know what you folks think. ~js On 5/3/08 11:58 AM, "Dan Eloff" wrote: Trying to build the new Beta 2 "Silverlight Debug" but it references a file that does not exist either in the Silverlight SDK or IronPython. How can I fix this? Thanks, -Dan _______________________________________________ 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 Sun May 4 01:28:59 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Sat, 3 May 2008 18:28:59 -0500 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: References: <4817b6fc0805031158h58cea392p1f770e5f5eff934d@mail.gmail.com> Message-ID: <4817b6fc0805031628g15901bd6w30f70b67c12535d@mail.gmail.com> > So, does this piss you off? Personally I like that we're able to ship > Python immediately with a new version of SL, but I'd like to know what you > folks think. > You are right, I'd rather you folks spend your energy working for the next release than backporting for people who want to mix releases. It is very nice to have IronPython released on the same schedule with Silverlight. Right now this doesn't bother me much, because I know Silverlight beta 2 is probably coming in May, and it will no doubt bundle IPY beta 2 or better. However, Silverlight RTM won't come out until late summer, and Silverlight 3 could be a long time from now. I have no doubt I'll be wishing I could use the newer version of IronPython with the released version of Silverlight along the line, but I don't see any easy way for you folks to deal with this. I think this is probably acceptable. The IronPython team sometimes backports very important fixes to the previous stable version, and this would probably work with the same version of Silverlight that aforementioned previous stable version works with. -Dan From Jimmy.Schementi at microsoft.com Sun May 4 01:45:27 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sat, 3 May 2008 16:45:27 -0700 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: <4817b6fc0805031628g15901bd6w30f70b67c12535d@mail.gmail.com> Message-ID: On 5/3/08 4:28 PM, "Dan Eloff" wrote: > Right now this doesn't bother me much, because I know Silverlight beta > 2 is probably coming in May, and it will no doubt bundle IPY beta 2 or > better. The IronPython version in current Silverlight builds is pretty much the same as IronPython Beta2, and we're only going to be moving targeted bugs fixes into SL from now until SL Beta2 ships. > However, Silverlight RTM won't come out until late summer, and > Silverlight 3 could be a long time from now. I have no doubt I'll be > wishing I could use the newer version of IronPython with the released > version of Silverlight along the line, but I don't see any easy way > for you folks to deal with this. We're going to have to make this happen one way or another. After SL2 ships, we'll most likely keep stuff working on SL2. The synchronization with Silverlight is simply so we can keep stuff working while the platform underneath us moves. Once it stabilizes we can then rev on top of it. ~js From fuzzyman at voidspace.org.uk Sun May 4 01:48:08 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 04 May 2008 00:48:08 +0100 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: References: Message-ID: <481CF9B8.4010407@voidspace.org.uk> Jimmy Schementi wrote: > On 5/3/08 4:28 PM, "Dan Eloff" wrote: > >> Right now this doesn't bother me much, because I know Silverlight beta >> 2 is probably coming in May, and it will no doubt bundle IPY beta 2 or >> better. >> > > The IronPython version in current Silverlight builds is pretty much the same > as IronPython Beta2, and we're only going to be moving targeted bugs fixes > into SL from now until SL Beta2 ships. > > >> However, Silverlight RTM won't come out until late summer, and >> Silverlight 3 could be a long time from now. I have no doubt I'll be >> wishing I could use the newer version of IronPython with the released >> version of Silverlight along the line, but I don't see any easy way >> for you folks to deal with this. >> > > We're going to have to make this happen one way or another. After SL2 ships, > we'll most likely keep stuff working on SL2. The synchronization with > Silverlight is simply so we can keep stuff working while the platform > underneath us moves. Once it stabilizes we can then rev on top of it. > Will there be no updated release of Dynamic Silverlight before Silverlight beta 2? Michael Foord http://www.ironpythoninaction.com/ > ~js > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From Jimmy.Schementi at microsoft.com Sun May 4 02:13:47 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sat, 3 May 2008 17:13:47 -0700 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: <481CF9B8.4010407@voidspace.org.uk> Message-ID: On 5/3/08 4:48 PM, "Michael Foord" wrote: > Jimmy Schementi wrote: >> On 5/3/08 4:28 PM, "Dan Eloff" wrote: >> >>> Right now this doesn't bother me much, because I know Silverlight beta >>> 2 is probably coming in May, and it will no doubt bundle IPY beta 2 or >>> better. >>> >> >> The IronPython version in current Silverlight builds is pretty much the same >> as IronPython Beta2, and we're only going to be moving targeted bugs fixes >> into SL from now until SL Beta2 ships. >> >> >>> However, Silverlight RTM won't come out until late summer, and >>> Silverlight 3 could be a long time from now. I have no doubt I'll be >>> wishing I could use the newer version of IronPython with the released >>> version of Silverlight along the line, but I don't see any easy way >>> for you folks to deal with this. >>> >> >> We're going to have to make this happen one way or another. After SL2 ships, >> we'll most likely keep stuff working on SL2. The synchronization with >> Silverlight is simply so we can keep stuff working while the platform >> underneath us moves. Once it stabilizes we can then rev on top of it. >> > > Will there be no updated release of Dynamic Silverlight before > Silverlight beta 2? > In the next couple days I'm updating Dynamic Silverlight to include Managed JScript (finally), but I'm not planning on revving the IronPython/IronRuby/DLR bits. It's less than a month before SL Beta2 is released, which is why no updated release between Beta1 and Beta2 seemed to make sense. Agree? To be honest though, this might be really easy to do. If you download Dynamic Silverlight from http://codeplex.com/sdlsdk, replace the IronPython and DLR source with the IronPython Beta2 source, the only build breaks will probably be in Microsoft.Scripting.Silverlight (mostly DLR API changes). If anyone wants to give it a shot, let me know. If you get it working (runs all the current Beta1 IronPython/IronRuby samples), feel free to send it my way. If we have time we can run our tests over it, and if all is green I'll put it up on codeplex (with additional credits, of course). ~js > Michael Foord > http://www.ironpythoninaction.com/ >> ~js >> >> _______________________________________________ >> 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 Jimmy.Schementi at microsoft.com Sun May 4 10:23:40 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sun, 4 May 2008 01:23:40 -0700 Subject: [IronPython] The story of Ruby and Python in Silverlight In-Reply-To: <47D442A8.1040507@voidspace.org.uk> References: <47D3CD22.8050406@voidspace.org.uk> <41d7f4a90803090512x4410a82at5cb9fd21162ffdc9@mail.gmail.com>, <6f4025010803090519s6ba309efve0522b6dbd1a01e4@mail.gmail.com> <7AD436E4270DD54A94238001769C2227011CF5A826FE@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <47D442A8.1040507@voidspace.org.uk> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284580380336@NA-EXMSG-C116.redmond.corp.microsoft.com> http://lists.ironpython.com/pipermail/users-ironpython.com/2008-March/006559.html This is a really old thread from Michael on the IronPython Discussions list, but while looking through old mail I found it and realized no one ever directly replied to it. I read it over, and it made me realize something; we rarely talk about "why" things happen at Microsoft on the "outside" ... we just throw code over the wall and expect you to understand the "why" yourself. Granted, the IronPython/IronRuby team is much better at including you, but you all are still in the dark about why things are the way they are in Silverlight. Let me fix that ... http://blog.jimmy.schementi.com/2008/05/story-of-ruby-and-python-in-silverlight.html This is my story of taking dynamic languages from Silverlight 1.1 Alpha to Silverlight 2. Hopefully it clears up some confusion about why things are the way they are, why they're better off this way, and what we need to do to make it even better. Enjoy, and please let me know what you think of the current state of Silverlight+Dynamic Languages in the comments. ~Jimmy From fuzzyman at voidspace.org.uk Sun May 4 21:11:39 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 04 May 2008 20:11:39 +0100 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: References: Message-ID: <481E0A6B.5070709@voidspace.org.uk> Jimmy Schementi wrote: > On 5/3/08 4:48 PM, "Michael Foord" wrote: > >> Jimmy Schementi wrote: >> >>> On 5/3/08 4:28 PM, "Dan Eloff" wrote: >>> >>> >>>> Right now this doesn't bother me much, because I know Silverlight beta >>>> 2 is probably coming in May, and it will no doubt bundle IPY beta 2 or >>>> better. >>>> >>>> >>> The IronPython version in current Silverlight builds is pretty much the same >>> as IronPython Beta2, and we're only going to be moving targeted bugs fixes >>> into SL from now until SL Beta2 ships. >>> >>> >>> >>>> However, Silverlight RTM won't come out until late summer, and >>>> Silverlight 3 could be a long time from now. I have no doubt I'll be >>>> wishing I could use the newer version of IronPython with the released >>>> version of Silverlight along the line, but I don't see any easy way >>>> for you folks to deal with this. >>>> >>>> >>> We're going to have to make this happen one way or another. After SL2 ships, >>> we'll most likely keep stuff working on SL2. The synchronization with >>> Silverlight is simply so we can keep stuff working while the platform >>> underneath us moves. Once it stabilizes we can then rev on top of it. >>> >>> >> Will there be no updated release of Dynamic Silverlight before >> Silverlight beta 2? >> >> > > In the next couple days I'm updating Dynamic Silverlight to include Managed > JScript (finally), but I'm not planning on revving the > IronPython/IronRuby/DLR bits. It's less than a month before SL Beta2 is > released, which is why no updated release between Beta1 and Beta2 seemed to > make sense. Agree? > Well, to quote a 'certain' blog entry: "We wanted to get the new language bits to you quicker than Silverlight releases." :-) > To be honest though, this might be really easy to do. If you download > Dynamic Silverlight from http://codeplex.com/sdlsdk, replace the IronPython > and DLR source with the IronPython Beta2 source, the only build breaks will > probably be in Microsoft.Scripting.Silverlight (mostly DLR API changes). If > anyone wants to give it a shot, let me know. If you get it working (runs all > the current Beta1 IronPython/IronRuby samples), feel free to send it my way. > If we have time we can run our tests over it, and if all is green I'll put > it up on codeplex (with additional credits, of course). > > I should have a copy of VS 2008 arriving 'soon' and will give this a go. All the best, Michael Foord > ~js > > >> Michael Foord >> http://www.ironpythoninaction.com/ >> >>> ~js >>> >>> _______________________________________________ >>> 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 Jimmy.Schementi at microsoft.com Sun May 4 22:19:39 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Sun, 4 May 2008 13:19:39 -0700 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: <481E0A6B.5070709@voidspace.org.uk> Message-ID: On 5/4/08 12:11 PM, "Michael Foord" wrote: > > Well, to quote a 'certain' blog entry: > > "We wanted to get the new language bits to you quicker than Silverlight > releases." > > :-) > This is definitely true post SLBeta2. My fault for not conveying that there would be no interm release before SLBeta2. But by end of May we'll have a release out that works with SLBeta2. >>>>> Once it (SL) stabilizes we can then rev on top of it. So yeah, post beta2 we'll come up with a way to rev the versions on top of the current released version of SL. > I should have a copy of VS 2008 arriving 'soon' and will give this a go. Great =) ~js From curt at hagenlocher.org Mon May 5 06:45:58 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Sun, 4 May 2008 21:45:58 -0700 Subject: [IronPython] Unexpected error in 2.0B2 In-Reply-To: References: Message-ID: Interestingly, the code works correctly when the flag -X:SaveAssemblies is used. It also doesn't happen if the same code exists in an external assembly that's called by IronPython. This suggests that the issue is in the dynamic code generation in the DLR and is not directly related to any kind of CAS issues, but I haven't yet been able to find any code changes that could explain the different behavior. On Fri, May 2, 2008 at 5:59 PM, Curt Hagenlocher wrote: > The following code works for me under B1, but throws an exception under > B2: > > import clr > import System > name = System.Reflection.AssemblyName() > name.Name = 'Test' > assemblyBuilder = > System.AppDomain.CurrentDomain.DefineDynamicAssembly(name, > System.Reflection.Emit.AssemblyBuilderAccess.Run) > > The stack trace is, of course, entirely inside the CLR. > > Traceback (most recent call last): > File "", line 1, in > File "mscorlib", line unknown, in DefineDynamicAssembly > File "mscorlib", line unknown, in InternalDefineDynamicAssembly > File "mscorlib", line unknown, in nCreateDynamicAssembly > File "mscorlib", line unknown, in CheckGrantSetHelper > SystemError: Object reference not set to an instance of an object. > > Unfortunately, nCreateDynamicAssembly is an InternalCall, so I can't see > exactly what it's doing. The only object reference in CheckGrantSetHelper > is to a PermissionSet, presumably one of the three that are passed to > nCreateDynamicAssembly. Based on the methods higher in the stack, I expect > that all three PermissionSets passed to nCreateDynamicAssembly are null, but > this would have been true under B1 as well. > > Have there been security-related changes made that could cause this > problem? > > -- > Curt Hagenlocher > curt at hagenlocher.org > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dan.eloff at gmail.com Mon May 5 12:58:05 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Mon, 5 May 2008 05:58:05 -0500 Subject: [IronPython] No ToString? Message-ID: <4817b6fc0805050358u7f1e7e53g65ee1c92ab186aa6@mail.gmail.com> A dictionary has an integer value, it goes into third party code, at which point the dictionary very likely goes through some kind of copy so that modifications to it will not affect the original. Before going into thrid party code, d[key].ToString() works, but on the copied dictionary, newd[key].ToString() raises: AttributeError: 'int' object has no attribute 'ToString' So I'm curious now, how can that happen? Before and after it seems the value is . How does int get .ToString() in the first place, and why does it seem to be possible to lose it? Thanks, -Dan From curt at hagenlocher.org Mon May 5 14:35:30 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Mon, 5 May 2008 05:35:30 -0700 Subject: [IronPython] No ToString? In-Reply-To: <4817b6fc0805050358u7f1e7e53g65ee1c92ab186aa6@mail.gmail.com> References: <4817b6fc0805050358u7f1e7e53g65ee1c92ab186aa6@mail.gmail.com> Message-ID: This is a function of whether or not you've imported "clr" into the module. Until you import clr, int objects will only have the methods of a Python int. PS f:\IronPython-2.0B2> .\ipy.exe IronPython 2.0 Beta (2.0.0.2000) on .NET 2.0.50727.1434 Copyright (c) Microsoft Corporation. All rights reserved. >>> a = 42 >>> len(dir(a)) 54 >>> import clr >>> len(dir(a)) 65 >>> This is a property of the current module and not of the objects that you've passed to it. If "x.py" contains "def n(x): return len(dir(x))" and "y.py" contains "import clr" followed by the same function, you get the following output from using them: PS f:\IronPython-2.0B2> .\ipy.exe IronPython 2.0 Beta (2.0.0.2000) on .NET 2.0.50727.1434 Copyright (c) Microsoft Corporation. All rights reserved. >>> import x, y >>> a = 42 >>> y.n(a) 65 >>> x.n(a) 54 >>> So the solution is for you to add an "import clr" at the top of the module where you're trying to use "ToString". On Mon, May 5, 2008 at 3:58 AM, Dan Eloff wrote: > A dictionary has an integer value, it goes into third party code, at > which point the dictionary very likely goes through some kind of copy > so that modifications to it will not affect the original. > > Before going into thrid party code, d[key].ToString() works, but on > the copied dictionary, newd[key].ToString() raises: > > AttributeError: 'int' object has no attribute 'ToString' > > So I'm curious now, how can that happen? Before and after it seems the > value is . How does int get .ToString() in the first > place, and why does it seem to be possible to lose it? > > Thanks, > -Dan > _______________________________________________ > 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 May 5 15:43:53 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Mon, 5 May 2008 08:43:53 -0500 Subject: [IronPython] StaticResources + DLR + Silverlight Message-ID: <4817b6fc0805050643g61cf500fy91c17510b5661c6a@mail.gmail.com> I notice if you use C#/VB, you have in your main xaml file. In there you can place resources that can be used from anywhere in your other xaml files. Using the {StaticResource foo} markup extension. If you are using a dynamic language, there is no equivalent (please correct me if I'm wrong), most examples I've seen use . The trouble is placing your resources in makes them off limit to {StaticResource foo} in any other xaml files (again please correct me if I'm wrong) So I find myself in a nightmare of duplicating resources across files and setting styles in code from Application.Current.RootVisual.Resources['foo'], neither of which is pleasant. Are there really no better alternatives? -Dan From m_tayseer82 at yahoo.com Mon May 5 16:41:36 2008 From: m_tayseer82 at yahoo.com (Mohammad Tayseer) Date: Mon, 5 May 2008 07:41:36 -0700 (PDT) Subject: [IronPython] No ToString? Message-ID: <8342.78771.qm@web31107.mail.mud.yahoo.com> >> From: Curt Hagenlocher \ >> >> So the solution is for you to add an "import clr" at the top of the module where you're trying to use "ToString". or you can use str(dic[key]) Mohammad Tayseer http://spellcoder.com/blogs/tayseer ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Mon May 5 19:08:28 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 05 May 2008 18:08:28 +0100 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: References: Message-ID: <481F3F0C.2050007@voidspace.org.uk> Jimmy Schementi wrote: > On 5/4/08 12:11 PM, "Michael Foord" wrote: > >> Well, to quote a 'certain' blog entry: >> >> "We wanted to get the new language bits to you quicker than Silverlight >> releases." >> >> :-) >> >> > > This is definitely true post SLBeta2. My fault for not conveying that there > would be no interm release before SLBeta2. But by end of May we'll have a > release out that works with SLBeta2. > Ah well. There are exciting changes for Silverlight in IronPython that I am eagerly awaiting... At least this gives me a nice quote to prod you with post SLBeta2. ;-) It was a great blog entry by the way: many thanks. Posting something like that along with the new release, or shortly after, would have been a good thing. As you say, often the 'why' matters. > >>>>>> Once it (SL) stabilizes we can then rev on top of it. >>>>>> > > So yeah, post beta2 we'll come up with a way to rev the versions on top of > the current released version of SL. > > Well - posting revisions as quickly as the IronRuby guys are pushing to the Rubyforge repository would be fine. (Even revisions that haven't gone through your whole test machinery - at least this way you could get fast(er) community feedback on changes.) Ah well, I can dream... Michael Foord http://www.ironpythoninaction.com/ >> I should have a copy of VS 2008 arriving 'soon' and will give this a go. >> > > Great =) > > ~js > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dinov at exchange.microsoft.com Mon May 5 19:57:10 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 5 May 2008 10:57:10 -0700 Subject: [IronPython] SCons on IronPython 2.0B2 In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012B27AD829A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B27AD8398@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Generally speaking the more information we have about a bug the better we can make the call on it. The most important thing I'd suggest adding is what scenario the bug is blocking. For example if you reported 5 Trac related bugs and 5 SCons related bugs and we fixed 3 Trac bugs and 2 SCons bugs that might not be quite as useful as fixing 5 SCons bugs. So just identifying the scenario will help us drive end-to-end scenarios to completion rather than fixing a bunch of random bugs which might not end up enabling anything! But in general some insight into how we triage bugs might be useful. Generally speaking we 1st prioritize bugs in the core runtime - that includes the parser, compiler, and core data types. Basically anything in IronPython.dll and everything in IronPython.Modules.dll gets a lower priority. Part of that is that we want to be as true to the core language as possible and therefore those fixes are viewed as more important. The other part of that is that we hope to open up IronPython.Modules.dll and allow user contributions. >From there I'd say the next thing we look at is votes and priority. Votes are of course easy to understand - I'd suggest sending your bug reports to the mailing list as well so that you can get that number bumped up. I'm guessing not everyone is subscribed to the RSS feed of IronPython bug reports like I am so it's likely that people don't see the issues even if they'd be interested in seeing them get fixed. Priority is of course harder to understand. I already mentioned modules which we tend to look at as a lower priority. We also tend to look at negative scenarios (e.g. exception messages, wrong exception, etc...) as having a lower priority - sometimes that's the wrong call as certain frameworks have heavy reliance upon the negative scenarios working correctly. From there it's largely a gut-call based upon what everyone sitting around doing the triage thinks. Usually if anyone thinks we should raise the priority we do - so on that point I'd suggest indicating what priority you think the bug should have as well. If everyone always said high priority we'd be back to coming up w/ the levels entirely ourselves but if discretion is used we'd likely respect the proposed priorities. Finally I don't know how much being set to 2.1 matters. The real release to watch out for is Future. Those are bugs we don't think we can get to anytime soon due to deep architectural issues. If something's been moved to 2.1 then it's more the case that we think this can wait and that's an easy decision to reverse. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy Sent: Saturday, May 03, 2008 12:40 AM To: Discussion of IronPython Subject: Re: [IronPython] SCons on IronPython 2.0B2 Hi Dino, Yeah, _winreg is what's missing. Good to hear that it will be coming soon! Not every bug I've filed is related to SCons (some are Trac-related, and maybe even a couple from elsewhere). I've just been testing random apps (primarily WSGI-enabled webapps), seeing what breaks, and filing bugs. What's the best way to push up the priority of a bug? Codeplex comments? Mailing list? I know of a few that are set for 2.1 that I'd like to see sooner. -Jeff On Sat, May 3, 2008 at 12:49 AM, Dino Viehland wrote: > Is "no registry module" _winreg or is it something else? The good news here might be that Srivatsn has implemented this for Beta 3 (along w/ cmath) but it didn't quite make it into b2. > > Let us know if we end up pushing any bugs to statuses you don't like. BTW are all the bugs you've opened related to SCons or are some other issues? I'd also not mind seeing a bug calling for a dummy signal module :). > > And of course thanks for the update! > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > Sent: Friday, May 02, 2008 11:20 PM > To: Discussion of IronPython; dev at scons.tigris.org > Subject: [IronPython] SCons on IronPython 2.0B2 > > Hi all, > SCons now 'works' on IronPython 2.0b2. I can compile a very simple C++ project, but there are a few caveats: > * no registry module, so no tool detection. The SConscript needs to import the environment to find any tools. > * Need a dummy signal module (attached) > * Need a subprocess module > (http://www.ironpython.info/index.php/The_subprocess_module) > * There are a few small oddities, so the attached patch to SCons is required. Relevant IronPython bugs have been filed, of course :) > > I have opened SCons issue #2043 to track all of this. I hope I've included all of the details. The signal and subprocess modules need to be in the IronPython\Lib directory (or somewhere in IRONPYTHONPATH). > Obviously, the Python 2.5 standard library must be available as well. > > I don't think the patch should be included in its current condition; I'm not 100% sure all the changes work with pure Python. It's pretty simple to block stuff off with sys.platform == 'cli', though. > > I'm going to try to push it a little harder now, but this is a good first start. > > -Jeff > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe at scons.tigris.org > For additional commands, e-mail: dev-help at scons.tigris.org > > _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dan.eloff at gmail.com Mon May 5 20:01:11 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Mon, 5 May 2008 13:01:11 -0500 Subject: [IronPython] No ToString? In-Reply-To: References: <4817b6fc0805050358u7f1e7e53g65ee1c92ab186aa6@mail.gmail.com> Message-ID: <4817b6fc0805051101h5bc96361k152b8acd8a58168f@mail.gmail.com> On Mon, May 5, 2008 at 7:35 AM, Curt Hagenlocher wrote: > This is a function of whether or not you've imported "clr" into the module. > Until you import clr, int objects will only have the methods of a Python > int. Thanks, I added an import clr to the top and it works just great. -Dan From Jimmy.Schementi at microsoft.com Mon May 5 23:34:06 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Mon, 5 May 2008 14:34:06 -0700 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: <481F3F0C.2050007@voidspace.org.uk> References: <481F3F0C.2050007@voidspace.org.uk> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A32845803807F4@NA-EXMSG-C116.redmond.corp.microsoft.com> > Michael Foord wrote: > > Ah well. There are exciting changes for Silverlight in IronPython that > I > am eagerly awaiting... > > At least this gives me a nice quote to prod you with post SLBeta2. ;-) That it does. We're having talks today over email about how to align all this stuff and get builds out that always work on the released version of SL. > It was a great blog entry by the way: many thanks. Posting something > like that along with the new release, or shortly after, would have been > a good thing. As you say, often the 'why' matters. Very true, consider it a rookie mistake. =P If I had only seen that email earlier ... > Well - posting revisions as quickly as the IronRuby guys are pushing to > the Rubyforge repository would be fine. (Even revisions that haven't > gone through your whole test machinery - at least this way you could > get > fast(er) community feedback on changes.) Ah well, I can dream... Yep, very true. The tough part is having the language's repositories be "buildable" on the currently released version of SL; where our test infrastructure makes sure we build against a semi-daily build of SL. Post SL Beta2 we may just freeze the Silverlight version we build against to Beta2. Like I said, me and some other folks are trying to figure out the least painful way to do this. ~js From fuzzyman at voidspace.org.uk Mon May 5 23:35:37 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 05 May 2008 22:35:37 +0100 Subject: [IronPython] Missing Merlin\Main\Hosts\Silverlight\SilverlightVersion.cs In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A32845803807F4@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <481F3F0C.2050007@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A32845803807F4@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <481F7DA9.2080800@voidspace.org.uk> Cool. It sounds like it is in good hands. :-) Michael Jimmy Schementi wrote: >> Michael Foord wrote: >> >> Ah well. There are exciting changes for Silverlight in IronPython that >> I >> am eagerly awaiting... >> >> At least this gives me a nice quote to prod you with post SLBeta2. ;-) >> > > That it does. We're having talks today over email about how to align all this stuff and get builds out that always work on the released version of SL. > > >> It was a great blog entry by the way: many thanks. Posting something >> like that along with the new release, or shortly after, would have been >> a good thing. As you say, often the 'why' matters. >> > > Very true, consider it a rookie mistake. =P If I had only seen that email earlier ... > > >> Well - posting revisions as quickly as the IronRuby guys are pushing to >> the Rubyforge repository would be fine. (Even revisions that haven't >> gone through your whole test machinery - at least this way you could >> get >> fast(er) community feedback on changes.) Ah well, I can dream... >> > > Yep, very true. The tough part is having the language's repositories be "buildable" on the currently released version of SL; where our test infrastructure makes sure we build against a semi-daily build of SL. > > Post SL Beta2 we may just freeze the Silverlight version we build against to Beta2. Like I said, me and some other folks are trying to figure out the least painful way to do this. > > ~js > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From jdhardy at gmail.com Tue May 6 01:49:59 2008 From: jdhardy at gmail.com (Jeff Hardy) Date: Mon, 5 May 2008 17:49:59 -0600 Subject: [IronPython] SCons on IronPython 2.0B2 In-Reply-To: <7AD436E4270DD54A94238001769C2227012B27AD8398@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012B27AD829A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012B27AD8398@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Hi Dino, Thanks for all the information! I find it helpful when filing bugs to know how the team prioritizes bugs, what they look for, etc. It makes it easier to game the system :) WRT negative conditions, these can be the worst to deal with because they often mask the real issue; the app is resilient enough to catch an error, but then fails during the error handling. The first task when testing a new app is usually making sure that the error handling works, even before any features can be tested. I'll keep up my crazy crusade of testing random apps as long as you guys keep fixing the bugs that are filed. The quality of each release is constantly improving, and that's really good news for fans of Python. You guys are doing a fantastic job! Now, about community contributions... :) -Jeff On Mon, May 5, 2008 at 11:57 AM, Dino Viehland wrote: > Generally speaking the more information we have about a bug the better we can make the call on it. The most important thing I'd suggest adding is what scenario the bug is blocking. For example if you reported 5 Trac related bugs and 5 SCons related bugs and we fixed 3 Trac bugs and 2 SCons bugs that might not be quite as useful as fixing 5 SCons bugs. So just identifying the scenario will help us drive end-to-end scenarios to completion rather than fixing a bunch of random bugs which might not end up enabling anything! > > But in general some insight into how we triage bugs might be useful. Generally speaking we 1st prioritize bugs in the core runtime - that includes the parser, compiler, and core data types. Basically anything in IronPython.dll and everything in IronPython.Modules.dll gets a lower priority. Part of that is that we want to be as true to the core language as possible and therefore those fixes are viewed as more important. The other part of that is that we hope to open up IronPython.Modules.dll and allow user contributions. > > >From there I'd say the next thing we look at is votes and priority. Votes are of course easy to understand - I'd suggest sending your bug reports to the mailing list as well so that you can get that number bumped up. I'm guessing not everyone is subscribed to the RSS feed of IronPython bug reports like I am so it's likely that people don't see the issues even if they'd be interested in seeing them get fixed. Priority is of course harder to understand. I already mentioned modules which we tend to look at as a lower priority. We also tend to look at negative scenarios (e.g. exception messages, wrong exception, etc...) as having a lower priority - sometimes that's the wrong call as certain frameworks have heavy reliance upon the negative scenarios working correctly. From there it's largely a gut-call based upon what everyone sitting around doing the triage thinks. Usually if anyone thinks we should raise the priority we do - so on that point I'd suggest indicating what p > riority you think the bug should have as well. If everyone always said high priority we'd be back to coming up w/ the levels entirely ourselves but if discretion is used we'd likely respect the proposed priorities. > > Finally I don't know how much being set to 2.1 matters. The real release to watch out for is Future. Those are bugs we don't think we can get to anytime soon due to deep architectural issues. If something's been moved to 2.1 then it's more the case that we think this can wait and that's an easy decision to reverse. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > > Sent: Saturday, May 03, 2008 12:40 AM > To: Discussion of IronPython > Subject: Re: [IronPython] SCons on IronPython 2.0B2 > > Hi Dino, > Yeah, _winreg is what's missing. Good to hear that it will be coming soon! > > Not every bug I've filed is related to SCons (some are Trac-related, > and maybe even a couple from elsewhere). I've just been testing random > apps (primarily WSGI-enabled webapps), seeing what breaks, and filing > bugs. > > What's the best way to push up the priority of a bug? Codeplex > comments? Mailing list? I know of a few that are set for 2.1 that I'd > like to see sooner. > > -Jeff > > > On Sat, May 3, 2008 at 12:49 AM, Dino Viehland > wrote: > > Is "no registry module" _winreg or is it something else? The good news here might be that Srivatsn has implemented this for Beta 3 (along w/ cmath) but it didn't quite make it into b2. > > > > Let us know if we end up pushing any bugs to statuses you don't like. BTW are all the bugs you've opened related to SCons or are some other issues? I'd also not mind seeing a bug calling for a dummy signal module :). > > > > And of course thanks for the update! > > > > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > > Sent: Friday, May 02, 2008 11:20 PM > > To: Discussion of IronPython; dev at scons.tigris.org > > Subject: [IronPython] SCons on IronPython 2.0B2 > > > > Hi all, > > SCons now 'works' on IronPython 2.0b2. I can compile a very simple C++ project, but there are a few caveats: > > * no registry module, so no tool detection. The SConscript needs to import the environment to find any tools. > > * Need a dummy signal module (attached) > > * Need a subprocess module > > (http://www.ironpython.info/index.php/The_subprocess_module) > > * There are a few small oddities, so the attached patch to SCons is required. Relevant IronPython bugs have been filed, of course :) > > > > I have opened SCons issue #2043 to track all of this. I hope I've included all of the details. The signal and subprocess modules need to be in the IronPython\Lib directory (or somewhere in IRONPYTHONPATH). > > Obviously, the Python 2.5 standard library must be available as well. > > > > I don't think the patch should be included in its current condition; I'm not 100% sure all the changes work with pure Python. It's pretty simple to block stuff off with sys.platform == 'cli', though. > > > > I'm going to try to push it a little harder now, but this is a good first start. > > > > -Jeff > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe at scons.tigris.org > > For additional commands, e-mail: dev-help at scons.tigris.org > > > > > _______________________________________________ > 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 Jimmy.Schementi at microsoft.com Tue May 6 09:04:23 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Tue, 6 May 2008 00:04:23 -0700 Subject: [IronPython] StaticResources + DLR + Silverlight In-Reply-To: <4817b6fc0805050643g61cf500fy91c17510b5661c6a@mail.gmail.com> References: <4817b6fc0805050643g61cf500fy91c17510b5661c6a@mail.gmail.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A3284580380A77@NA-EXMSG-C116.redmond.corp.microsoft.com> Dan, It's a very good question, and I'm a little embarrassed not to have a solution for you. Give me some time to poke around and find the best way to do this. ~js > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Dan Eloff > Sent: Monday, May 05, 2008 6:44 AM > To: Discussion of IronPython > Subject: [IronPython] StaticResources + DLR + Silverlight > > I notice if you use C#/VB, you have in your main xaml > file. In there you can place resources that can be used from anywhere > in your other xaml files. Using the {StaticResource foo} markup > extension. > > If you are using a dynamic language, there is no > equivalent (please correct me if I'm wrong), most examples I've seen > use . > > The trouble is placing your resources in makes > them off limit to {StaticResource foo} in any other xaml files (again > please correct me if I'm wrong) > > So I find myself in a nightmare of duplicating resources across files > and setting styles in code from > Application.Current.RootVisual.Resources['foo'], neither of which is > pleasant. Are there really no better alternatives? > > -Dan > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Tue May 6 17:21:31 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 6 May 2008 08:21:31 -0700 Subject: [IronPython] SCons on IronPython 2.0B2 In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012B27AD829A@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012B27AD8398@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B2805D5C9@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Yeah, I agree that negative conditions sometimes are extremely important - and we don't reject them all :) So if it's important for an app to work it'd be good to point that out. Thanks for all the bugs! -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy Sent: Monday, May 05, 2008 4:50 PM To: Discussion of IronPython Subject: Re: [IronPython] SCons on IronPython 2.0B2 Hi Dino, Thanks for all the information! I find it helpful when filing bugs to know how the team prioritizes bugs, what they look for, etc. It makes it easier to game the system :) WRT negative conditions, these can be the worst to deal with because they often mask the real issue; the app is resilient enough to catch an error, but then fails during the error handling. The first task when testing a new app is usually making sure that the error handling works, even before any features can be tested. I'll keep up my crazy crusade of testing random apps as long as you guys keep fixing the bugs that are filed. The quality of each release is constantly improving, and that's really good news for fans of Python. You guys are doing a fantastic job! Now, about community contributions... :) -Jeff On Mon, May 5, 2008 at 11:57 AM, Dino Viehland wrote: > Generally speaking the more information we have about a bug the better we can make the call on it. The most important thing I'd suggest adding is what scenario the bug is blocking. For example if you reported 5 Trac related bugs and 5 SCons related bugs and we fixed 3 Trac bugs and 2 SCons bugs that might not be quite as useful as fixing 5 SCons bugs. So just identifying the scenario will help us drive end-to-end scenarios to completion rather than fixing a bunch of random bugs which might not end up enabling anything! > > But in general some insight into how we triage bugs might be useful. Generally speaking we 1st prioritize bugs in the core runtime - that includes the parser, compiler, and core data types. Basically anything in IronPython.dll and everything in IronPython.Modules.dll gets a lower priority. Part of that is that we want to be as true to the core language as possible and therefore those fixes are viewed as more important. The other part of that is that we hope to open up IronPython.Modules.dll and allow user contributions. > > >From there I'd say the next thing we look at is votes and priority. Votes are of course easy to understand - I'd suggest sending your bug reports to the mailing list as well so that you can get that number bumped up. I'm guessing not everyone is subscribed to the RSS feed of IronPython bug reports like I am so it's likely that people don't see the issues even if they'd be interested in seeing them get fixed. Priority is of course harder to understand. I already mentioned modules which we tend to look at as a lower priority. We also tend to look at negative scenarios (e.g. exception messages, wrong exception, etc...) as having a lower priority - sometimes that's the wrong call as certain frameworks have heavy reliance upon the negative scenarios working correctly. From there it's largely a gut-call based upon what everyone sitting around doing the triage thinks. Usually if anyone thinks we should raise the priority we do - so on that point I'd suggest indicating what p > riority you think the bug should have as well. If everyone always said high priority we'd be back to coming up w/ the levels entirely ourselves but if discretion is used we'd likely respect the proposed priorities. > > Finally I don't know how much being set to 2.1 matters. The real release to watch out for is Future. Those are bugs we don't think we can get to anytime soon due to deep architectural issues. If something's been moved to 2.1 then it's more the case that we think this can wait and that's an easy decision to reverse. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > > Sent: Saturday, May 03, 2008 12:40 AM > To: Discussion of IronPython > Subject: Re: [IronPython] SCons on IronPython 2.0B2 > > Hi Dino, > Yeah, _winreg is what's missing. Good to hear that it will be coming soon! > > Not every bug I've filed is related to SCons (some are Trac-related, > and maybe even a couple from elsewhere). I've just been testing random > apps (primarily WSGI-enabled webapps), seeing what breaks, and filing > bugs. > > What's the best way to push up the priority of a bug? Codeplex > comments? Mailing list? I know of a few that are set for 2.1 that I'd > like to see sooner. > > -Jeff > > > On Sat, May 3, 2008 at 12:49 AM, Dino Viehland > wrote: > > Is "no registry module" _winreg or is it something else? The good news here might be that Srivatsn has implemented this for Beta 3 (along w/ cmath) but it didn't quite make it into b2. > > > > Let us know if we end up pushing any bugs to statuses you don't like. BTW are all the bugs you've opened related to SCons or are some other issues? I'd also not mind seeing a bug calling for a dummy signal module :). > > > > And of course thanks for the update! > > > > > > -----Original Message----- > > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Jeff Hardy > > Sent: Friday, May 02, 2008 11:20 PM > > To: Discussion of IronPython; dev at scons.tigris.org > > Subject: [IronPython] SCons on IronPython 2.0B2 > > > > Hi all, > > SCons now 'works' on IronPython 2.0b2. I can compile a very simple C++ project, but there are a few caveats: > > * no registry module, so no tool detection. The SConscript needs to import the environment to find any tools. > > * Need a dummy signal module (attached) > > * Need a subprocess module > > (http://www.ironpython.info/index.php/The_subprocess_module) > > * There are a few small oddities, so the attached patch to SCons is required. Relevant IronPython bugs have been filed, of course :) > > > > I have opened SCons issue #2043 to track all of this. I hope I've included all of the details. The signal and subprocess modules need to be in the IronPython\Lib directory (or somewhere in IRONPYTHONPATH). > > Obviously, the Python 2.5 standard library must be available as well. > > > > I don't think the patch should be included in its current condition; I'm not 100% sure all the changes work with pure Python. It's pretty simple to block stuff off with sys.platform == 'cli', though. > > > > I'm going to try to push it a little harder now, but this is a good first start. > > > > -Jeff > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: dev-unsubscribe at scons.tigris.org > > For additional commands, e-mail: dev-help at scons.tigris.org > > > > > _______________________________________________ > 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 matt_tomblin at hotmail.com Tue May 6 18:19:47 2008 From: matt_tomblin at hotmail.com (Matt Tomblin) Date: Tue, 6 May 2008 17:19:47 +0100 Subject: [IronPython] How do I connect to a WCF service... Message-ID: I have a WCF service that I wrote in C#. This is hosted as a windows service and I can happily connect to it from a C# client by adding a service reference to the aforementioned service within the (using VS 2008) client project. I would like to connect to the same serivce via IronPython if possible. If I execute an IronPython script on the local machine where the service exists I am able to use "clr" etc in to add a reference to the *.dll and utilize the service in that manner without issue. i.e. import clrclr.AddReferenceToFileAndPath("\serviceName.dll")import serviceNameLibclient = serviceNameLib.service()client.doSomethingFromService() However, my goal is to connect to the service that is running like I am doing in the C# client example (using the service reference add functionality) and not directly to the assembly. I guess the issue is related to the fact that the service reference add invokes the svcutil which generates all that lovely code for the C# app in order for me to simply connect the C# client to the service. I have been experimenting in IronPython but my lack of knowledge in both Python and WCF in general has stumped me and I don't seem to be able to find anything online that has an example of an IronPython client in this regard. My expermintation has been along the lines of: import clr clr.AddReferenceToFileAndPath("\serviceName.dll") clr.AddReference("System") clr.AddReference("System.ServiceModel") import System import System.ServiceModel import serviceNameLib uri = System.Uri("http://
:8080/serviceName") binding = System.ServiceModel.WSHttpBinding() host = System.ServiceModel.ServiceHost(type(serviceNameLib.service)) host.AddServiceEndpoint(serviceNameLib.Iservice, binding, uri) The contract name 'serviceNameLib.Iservice' could not be found in the list of contracts implemented by the service 'IronPython.Runtime.Types.ReflectedType'. The final line (in red) is the error I get. Obviously I am missing something large or perhaps it simply isn't possible the way I am trying to do it. If anyone can put me out of my coding misery it would be appreciated. cheers _________________________________________________________________ All new Live Search at Live.com http://clk.atdmt.com/UKM/go/msnnkmgl0010000006ukm/direct/01/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From curt at hagenlocher.org Wed May 7 04:32:33 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 6 May 2008 19:32:33 -0700 Subject: [IronPython] socket support in 1.1.2 In-Reply-To: <48120A1F.1010004@voidspace.org.uk> References: <4811EFE4.7060605@voidspace.org.uk> <4811F7CA.2010003@voidspace.org.uk> <48120A1F.1010004@voidspace.org.uk> Message-ID: Well, Dino tells me that they can't accept any contributions from outside Microsoft. So in order to best serve the IronPython community, I've taken the arguably extreme step of joining the IronPython team as a developer just to be able to commit this change. Afterwards, I expect to stick around for a while and work on Visual Studio integration. I still expect to be working on my "wrapper" project after hours -- I've been quiet about it recently largely because I got sidetracked by an attempt to add p/invoke support. Expect something new in the next week or so. On Fri, Apr 25, 2008 at 9:43 AM, Michael Foord wrote: > Curt Hagenlocher wrote: > > > > I've attached a patch against 1.1.1 that (I think) fixes this. It > > works for my test case, anyway. > > > > > > We currently ship Microsoft binaries rather than compiling from source - > so we'd rather wait for 1.1.2 than patch at this stage... but thanks. > > Michael -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed May 7 10:06:17 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 07 May 2008 09:06:17 +0100 Subject: [IronPython] socket support in 1.1.2 In-Reply-To: References: <4811EFE4.7060605@voidspace.org.uk> <4811F7CA.2010003@voidspace.org.uk> <48120A1F.1010004@voidspace.org.uk> Message-ID: <482162F9.8060606@voidspace.org.uk> Curt Hagenlocher wrote: > Well, Dino tells me that they can't accept any contributions from > outside Microsoft. So in order to best serve the IronPython > community, I've taken the arguably extreme step of joining the > IronPython team as a developer just to be able to commit this change. > Afterwards, I expect to stick around for a while and work on Visual > Studio integration. That's a subtle announcement Curt. Congratulations to you and the ongoing success of IronPython! :-D (I'm interested in the progress of Coils as well - and have an interesting idea for it, but I need to finish my book first...) Michael Foord > > I still expect to be working on my "wrapper" project after hours -- > I've been quiet about it recently largely because I got sidetracked by > an attempt to add p/invoke support. Expect something new in the next > week or so. > > On Fri, Apr 25, 2008 at 9:43 AM, Michael Foord > > wrote: > > Curt Hagenlocher wrote: > > > > I've attached a patch against 1.1.1 that (I think) fixes this. It > > works for my test case, anyway. > > > > > > We currently ship Microsoft binaries rather than compiling from > source - > so we'd rather wait for 1.1.2 than patch at this stage... but thanks. > > Michael > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dan.eloff at gmail.com Wed May 7 19:54:11 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 7 May 2008 12:54:11 -0500 Subject: [IronPython] Some minor int/long bugs Message-ID: <4817b6fc0805071054k747d01b5n1b0e3efc5c947245@mail.gmail.com> I found this difference between IronPython and CPython in struct: CPython >>> struct.unpack('I','\xedd\x02\x00') (156909,) IronPython 2.0b1 >>> struct.unpack('I','\xedd\x02\x00') (156909L,) It seems that even although unpack('I', '\xff'*4) has to be a long, for values of sys.maxint or below, CPython always returns an int. Python ints and longs behave very similarily, so most of the time this matters little. Enter bug #2. ToString(format) doesn't work on python longs, but it will work on python ints (as long as clr is imported.) I would suggest that because sometimes it does matter whether you have an int or a long, it would be best to fix the discrepancy in struct. As for supporting ToString(format) on longs, I don't see this as being easy or high priority, perhaps it would be enough to implement it by converting the long to System.Decimal, and just using it's ToString(format) which works perfectly. I will report these on Codeplex. -Dan From Shri.Borde at microsoft.com Wed May 7 23:52:35 2008 From: Shri.Borde at microsoft.com (Shri Borde) Date: Wed, 7 May 2008 14:52:35 -0700 Subject: [IronPython] Welcome Curt to the IronPython team In-Reply-To: <482162F9.8060606@voidspace.org.uk> References: <4811EFE4.7060605@voidspace.org.uk> <4811F7CA.2010003@voidspace.org.uk> <48120A1F.1010004@voidspace.org.uk> <482162F9.8060606@voidspace.org.uk> Message-ID: <50B69702CA6E6D4E849D30CD4989AB8EE7AC60C60F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> That was subtle indeed. So to fix that, I am pleased to welcome Curt to the IronPython team. Curt has been active in both the IronPython and IronRuby mailing lists, and we are excited to have him officially be working on these projects. Curt already has a fix in socket support which he should be checking in shortly. This might be the second-fastest checkin for a new dev. Dino had checked in as part of his interview even before he joined the team, but I can't really hold this against Curt since we couldn't accept his patches before :) Curt will be spending sometime initially on IronRuby too. Thanks, Shri Want to work on IronPython, IronRuby, F#? Visit http://blogs.msdn.com/ironpython -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Wednesday, May 07, 2008 1:06 AM To: Discussion of IronPython Subject: Re: [IronPython] socket support in 1.1.2 Curt Hagenlocher wrote: > Well, Dino tells me that they can't accept any contributions from > outside Microsoft. So in order to best serve the IronPython > community, I've taken the arguably extreme step of joining the > IronPython team as a developer just to be able to commit this change. > Afterwards, I expect to stick around for a while and work on Visual > Studio integration. That's a subtle announcement Curt. Congratulations to you and the ongoing success of IronPython! :-D (I'm interested in the progress of Coils as well - and have an interesting idea for it, but I need to finish my book first...) Michael Foord > > I still expect to be working on my "wrapper" project after hours -- > I've been quiet about it recently largely because I got sidetracked by > an attempt to add p/invoke support. Expect something new in the next > week or so. > > On Fri, Apr 25, 2008 at 9:43 AM, Michael Foord > > wrote: > > Curt Hagenlocher wrote: > > > > I've attached a patch against 1.1.1 that (I think) fixes this. It > > works for my test case, anyway. > > > > > > We currently ship Microsoft binaries rather than compiling from > source - > so we'd rather wait for 1.1.2 than patch at this stage... but thanks. > > Michael > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kfarmer at thuban.org Thu May 8 04:09:14 2008 From: kfarmer at thuban.org (Keith J. Farmer) Date: Wed, 7 May 2008 19:09:14 -0700 Subject: [IronPython] Welcome Curt to the IronPython team Message-ID: <005301c8b0b0$7f149d81$080a010a@circlecross.home> Yay Curt! -----Original Message----- From: Shri Borde Sent: Wednesday, 07 May, 2008 14:52 To: Discussion of IronPython Cc: ironruby-core at rubyforge.org Subject: [IronPython] Welcome Curt to the IronPython team That was subtle indeed. So to fix that, I am pleased to welcome Curt to the IronPython team. Curt has been active in both the IronPython and IronRuby mailing lists, and we are excited to have him officially be working on these projects. Curt already has a fix in socket support which he should be checking in shortly. This might be the second-fastest checkin for a new dev. Dino had checked in as part of his interview even before he joined the team, but I can't really hold this against Curt since we couldn't accept his patches before :) Curt will be spending sometime initially on IronRuby too. Thanks, Shri Want to work on IronPython, IronRuby, F#? Visit http://blogs.msdn.com/ironpython -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Wednesday, May 07, 2008 1:06 AM To: Discussion of IronPython Subject: Re: [IronPython] socket support in 1.1.2 Curt Hagenlocher wrote: > Well, Dino tells me that they can't accept any contributions from > outside Microsoft. So in order to best serve the IronPython > community, I've taken the arguably extreme step of joining the > IronPython team as a developer just to be able to commit this change. > Afterwards, I expect to stick around for a while and work on Visual > Studio integration. That's a subtle announcement Curt. Congratulations to you and the ongoing success of IronPython! :-D (I'm interested in the progress of Coils as well - and have an interesting idea for it, but I need to finish my book first...) Michael Foord > > I still expect to be working on my "wrapper" project after hours -- > I've been quiet about it recently largely because I got sidetracked by > an attempt to add p/invoke support. Expect something new in the next > week or so. > > On Fri, Apr 25, 2008 at 9:43 AM, Michael Foord > > wrote: > > Curt Hagenlocher wrote: > > > > I've attached a patch against 1.1.1 that (I think) fixes this. It > > works for my test case, anyway. > > > > > > We currently ship Microsoft binaries rather than compiling from > source - > so we'd rather wait for 1.1.2 than patch at this stage... but thanks. > > Michael > > ------------------------------------------------------------------------ > > _______________________________________________ > 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 christian.muirhead at resolversystems.com Fri May 9 12:06:46 2008 From: christian.muirhead at resolversystems.com (Christian Muirhead) Date: Fri, 09 May 2008 11:06:46 +0100 Subject: [IronPython] Updating WebServices samples Message-ID: <48242236.2010100@resolversystems.com> Hi - I'm writing something about using web services from IronPython at the moment, and Michael pointed me at the WebServices samples from IP 1.0.1. (here: http://www.codeplex.com/IronPython/Release/ProjectReleases.aspx?ReleaseId=47) Is there any chance that someone has updated these to work with the IP2 architecture? If not, how much work would people expect it to be? The errors I saw when I quickly tried to compile the C# were primarily about not being able to find the IAttributesInjector and ICallable interfaces - do these exist in the same form in the new architecture? Thanks, Christian -- Christian Muirhead Senior Developer Resolver Systems christian.muirhead at resolversystems.com We're hiring! http://www.resolversystems.com/jobs/ 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 sakesun at boonthavorn.com Fri May 9 12:13:20 2008 From: sakesun at boonthavorn.com (Sakesun Roykiattisak) Date: Fri, 09 May 2008 17:13:20 +0700 Subject: [IronPython] Any known clr-interop concurrency issue ? Message-ID: Hi, I'm currently trouble-shooting concurrency issue in my IP server-application. I suspect that IP(1.1.1) has issue that concurrent calls to static method with certain argument-type can cause corruption. I'm going to try making a demonstration project tonight. However, to save my time, I wonder if there are any already known concurrency issue in IP 1.1.1 ? Or if anybody have some hint for me to find the exact problem ? Thanks. From sanxiyn at gmail.com Fri May 9 15:39:02 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Fri, 9 May 2008 22:39:02 +0900 Subject: [IronPython] Updating WebServices samples In-Reply-To: <48242236.2010100@resolversystems.com> References: <48242236.2010100@resolversystems.com> Message-ID: <5b0248170805090639h66e87bdaj941fb913c017fcbe@mail.gmail.com> 2008/5/9 Christian Muirhead : > Is there any chance that someone has updated these to work with the IP2 > architecture? If not, how much work would people expect it to be? The errors > I saw when I quickly tried to compile the C# were primarily about not being > able to find the IAttributesInjector and ICallable interfaces - do these > exist in the same form in the new architecture? I think IAttributesInjector -- which was hacky, IMO -- has been replaced by defining GetBoundMember method and marking the method with SpecialNameAttribute. Details are here: http://blogs.msdn.com/srivatsn/archive/2008/04/12/turning-your-net-object-models-dynamic-for-ironpython.aspx -- Seo Sanghyeon From dinov at exchange.microsoft.com Fri May 9 17:46:47 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 9 May 2008 08:46:47 -0700 Subject: [IronPython] Updating WebServices samples In-Reply-To: <5b0248170805090639h66e87bdaj941fb913c017fcbe@mail.gmail.com> References: <48242236.2010100@resolversystems.com> <5b0248170805090639h66e87bdaj941fb913c017fcbe@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B2805DE5D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> And ICallable is the same - you can now mark a method w/ SpecialName and call it "Call" and it'll be invoked when you're calling the object. You can even have multiple overloads, all strongly typed, etc... -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Friday, May 09, 2008 6:39 AM To: Discussion of IronPython Subject: Re: [IronPython] Updating WebServices samples 2008/5/9 Christian Muirhead : > Is there any chance that someone has updated these to work with the IP2 > architecture? If not, how much work would people expect it to be? The errors > I saw when I quickly tried to compile the C# were primarily about not being > able to find the IAttributesInjector and ICallable interfaces - do these > exist in the same form in the new architecture? I think IAttributesInjector -- which was hacky, IMO -- has been replaced by defining GetBoundMember method and marking the method with SpecialNameAttribute. Details are here: http://blogs.msdn.com/srivatsn/archive/2008/04/12/turning-your-net-object-models-dynamic-for-ironpython.aspx -- Seo Sanghyeon _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Fri May 9 17:55:39 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 9 May 2008 08:55:39 -0700 Subject: [IronPython] Any known clr-interop concurrency issue ? In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012B2805DE61@DF-GRTDANE-MSG.exchange.corp.microsoft.com> There shouldn't be any issues here or at least we haven't had any reported and it's not obvious what it could be. One thing to consider if you're coming from a CPython background is that IronPython doesn't have a global interpreter lock and therefore there won't be any implicit locking done for you. In the case of static methods that shouldn't matter much because .NET design guidelines state that all static methods should be thread safe. The only other thing I could think of is that it's somehow related to value types or reference types given that you said it's related to argument-types - maybe re-using and mutating the same boxed value type? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sakesun Roykiattisak Sent: Friday, May 09, 2008 3:13 AM To: users at lists.ironpython.com Subject: [IronPython] Any known clr-interop concurrency issue ? Hi, I'm currently trouble-shooting concurrency issue in my IP server-application. I suspect that IP(1.1.1) has issue that concurrent calls to static method with certain argument-type can cause corruption. I'm going to try making a demonstration project tonight. However, to save my time, I wonder if there are any already known concurrency issue in IP 1.1.1 ? Or if anybody have some hint for me to find the exact problem ? Thanks. _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Jimmy.Schementi at microsoft.com Fri May 9 18:33:02 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Fri, 9 May 2008 09:33:02 -0700 Subject: [IronPython] Updating WebServices samples In-Reply-To: <7AD436E4270DD54A94238001769C2227012B2805DE5D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: I'm actually using this stuff in a talk next month, so I guess someone has to get it working. =P Christian , if you are working on this, by all means continue, otherwise when I make progress I'll let you know ~js On 5/9/08 8:46 AM, "Dino Viehland" wrote: And ICallable is the same - you can now mark a method w/ SpecialName and call it "Call" and it'll be invoked when you're calling the object. You can even have multiple overloads, all strongly typed, etc... -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Friday, May 09, 2008 6:39 AM To: Discussion of IronPython Subject: Re: [IronPython] Updating WebServices samples 2008/5/9 Christian Muirhead : > Is there any chance that someone has updated these to work with the IP2 > architecture? If not, how much work would people expect it to be? The errors > I saw when I quickly tried to compile the C# were primarily about not being > able to find the IAttributesInjector and ICallable interfaces - do these > exist in the same form in the new architecture? I think IAttributesInjector -- which was hacky, IMO -- has been replaced by defining GetBoundMember method and marking the method with SpecialNameAttribute. Details are here: http://blogs.msdn.com/srivatsn/archive/2008/04/12/turning-your-net-object-models-dynamic-for-ironpython.aspx -- Seo Sanghyeon _______________________________________________ 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 Marty.Nelson at symyx.com Fri May 9 18:51:59 2008 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Fri, 9 May 2008 09:51:59 -0700 Subject: [IronPython] How to nest ScriptScopes In-Reply-To: <515335F32AA04440B3DE6FEA1993E9AD02891246@srv-be-101.Symyx-IC.symyx.com> References: <515335F32AA04440B3DE6FEA1993E9AD02891246@srv-be-101.Symyx-IC.symyx.com> Message-ID: <515335F32AA04440B3DE6FEA1993E9AD0289125C@srv-be-101.Symyx-IC.symyx.com> I've gone over the 2.0 B2 source code, but I'm not clear how I might create nested ScriptScopes using the API in C# One of the tests in EngineTests.cs uses "from published_context_test import x" but this is only one variable, and I'd rather do it from the C# setup side anyway. I noticed that Scope, which ScriptScope contains, has the ability to take a parent Scope, but I'm not clear how I would do this. It seems not to be exposed via ScriptScope. We are using IronPython as a script based extension mechanism for our C# application, my interest is to have a set of established scopes that I can populate with the variables of current application objects at the appropriate level for the current script. Thanks, Marty Nelson ======= 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 dinov at exchange.microsoft.com Fri May 9 18:58:52 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 9 May 2008 09:58:52 -0700 Subject: [IronPython] How to nest ScriptScopes In-Reply-To: <515335F32AA04440B3DE6FEA1993E9AD0289125C@srv-be-101.Symyx-IC.symyx.com> References: <515335F32AA04440B3DE6FEA1993E9AD02891246@srv-be-101.Symyx-IC.symyx.com> <515335F32AA04440B3DE6FEA1993E9AD0289125C@srv-be-101.Symyx-IC.symyx.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B2805DE8F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> It's not really intended that you nest the scopes yourself - usually the scopes only get nested when you have a closure. And then we'll burn references into the parent scopes tuple's directly so we might not even see nested variables (although in some cases we might due a full runtime lookup and see them). Instead of nesting them can you have a ScriptScope that contains other ScriptScope's? In other words your inner most level is just a collection of ScriptScope's which you publish under some well known name into the outer level. Then users can dot through them: outermost = new ScriptScope(); innermost = new ScriptScope(); innermost.SetVariable("somevalue", 3); outermost.SetVariable("next", innermost); then run in outermost. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson Sent: Friday, May 09, 2008 9:52 AM To: users at lists.ironpython.com Subject: [IronPython] How to nest ScriptScopes I've gone over the 2.0 B2 source code, but I'm not clear how I might create nested ScriptScopes using the API in C# One of the tests in EngineTests.cs uses "from published_context_test import x" but this is only one variable, and I'd rather do it from the C# setup side anyway. I noticed that Scope, which ScriptScope contains, has the ability to take a parent Scope, but I'm not clear how I would do this. It seems not to be exposed via ScriptScope. We are using IronPython as a script based extension mechanism for our C# application, my interest is to have a set of established scopes that I can populate with the variables of current application objects at the appropriate level for the current script. Thanks, Marty Nelson ======= 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 Marty.Nelson at symyx.com Fri May 9 19:43:47 2008 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Fri, 9 May 2008 10:43:47 -0700 Subject: [IronPython] How to nest ScriptScopes In-Reply-To: <7AD436E4270DD54A94238001769C2227012B2805DE8F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <515335F32AA04440B3DE6FEA1993E9AD02891246@srv-be-101.Symyx-IC.symyx.com><515335F32AA04440B3DE6FEA1993E9AD0289125C@srv-be-101.Symyx-IC.symyx.com> <7AD436E4270DD54A94238001769C2227012B2805DE8F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <515335F32AA04440B3DE6FEA1993E9AD0289125F@srv-be-101.Symyx-IC.symyx.com> That seems to work, although I used inner to execute (see below). [TestMethod] public void TestMethod1() { var outerscope = _env.CreateScope(); var innerscope = _env.CreateScope(); int outerInput = 3; int innerInput = 2; outerscope.SetVariable("value", outerInput); innerscope.SetVariable("outer", outerscope); innerscope.SetVariable("value", innerInput); _pe.CreateScriptSourceFromString("result = outer.value + value", SourceCodeKind.Statements) .Execute(innerscope); var result = innerscope.GetVariable("result"); Assert.AreEqual(outerInput + innerInput, result); object ignore; Assert.IsFalse(outerscope.TryGetVariable("result", out ignore)); } I'd prefer not to have the dot notation (I know in my sample I had conflicting variable names, but I don't expect that to be the case. It's more a layering of available variables) . Is there some python function I could write that would go through the outerscope and create variables at the inner scope using the name? Or I'm I making this harder than it needs to be? See below, where I just copied the variables. [TestMethod] public void TestMethod2() { var outerscope = _env.CreateScope(); var innerscope = _env.CreateScope(); int outerInput = 3; int innerInput = 2; outerscope.SetVariable("foo", outerInput); foreach (string name in outerscope.VariableNames) { innerscope.SetVariable(name, outerscope.GetVariable(name)); } innerscope.SetVariable("bar", innerInput); _pe.CreateScriptSourceFromString("result = foo + bar", SourceCodeKind.Statements) .Execute(innerscope); var result = innerscope.GetVariable("result"); Assert.AreEqual(outerInput + innerInput, result); object ignore; Assert.IsFalse(outerscope.TryGetVariable("result", out ignore)); } Also, what does "when you have a closure" mean? ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Friday, May 09, 2008 9:59 AM To: Discussion of IronPython Subject: Re: [IronPython] How to nest ScriptScopes It's not really intended that you nest the scopes yourself - usually the scopes only get nested when you have a closure. And then we'll burn references into the parent scopes tuple's directly so we might not even see nested variables (although in some cases we might due a full runtime lookup and see them). Instead of nesting them can you have a ScriptScope that contains other ScriptScope's? In other words your inner most level is just a collection of ScriptScope's which you publish under some well known name into the outer level. Then users can dot through them: outermost = new ScriptScope(); innermost = new ScriptScope(); innermost.SetVariable("somevalue", 3); outermost.SetVariable("next", innermost); then run in outermost. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson Sent: Friday, May 09, 2008 9:52 AM To: users at lists.ironpython.com Subject: [IronPython] How to nest ScriptScopes I've gone over the 2.0 B2 source code, but I'm not clear how I might create nested ScriptScopes using the API in C# One of the tests in EngineTests.cs uses "from published_context_test import x" but this is only one variable, and I'd rather do it from the C# setup side anyway. I noticed that Scope, which ScriptScope contains, has the ability to take a parent Scope, but I'm not clear how I would do this. It seems not to be exposed via ScriptScope. We are using IronPython as a script based extension mechanism for our C# application, my interest is to have a set of established scopes that I can populate with the variables of current application objects at the appropriate level for the current script. Thanks, Marty Nelson ======= 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 seshapv at microsoft.com Fri May 9 20:16:09 2008 From: seshapv at microsoft.com (Seshadri Pillailokam Vijayaraghavan) Date: Fri, 9 May 2008 11:16:09 -0700 Subject: [IronPython] How to nest ScriptScopes In-Reply-To: <515335F32AA04440B3DE6FEA1993E9AD0289125F@srv-be-101.Symyx-IC.symyx.com> References: <515335F32AA04440B3DE6FEA1993E9AD02891246@srv-be-101.Symyx-IC.symyx.com><515335F32AA04440B3DE6FEA1993E9AD0289125C@srv-be-101.Symyx-IC.symyx.com> <7AD436E4270DD54A94238001769C2227012B2805DE8F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <515335F32AA04440B3DE6FEA1993E9AD0289125F@srv-be-101.Symyx-IC.symyx.com> Message-ID: <4F06AAB8EC03C349A5D6D0A797C4881C40AABDB685@NA-EXMSG-C112.redmond.corp.microsoft.com> You can use C# extension methods to copy the variables without cluttering up the code too much Here's what the code would look like... internal static class Extensions{ internal static void SetOuter(this ScriptScope scope, ScriptScope outerScope) { scope.SetVariable("outer", outerScope); foreach (string name in outerScope.VariableNames) { scope.SetVariable(name, outerScope.GetVariable(name)); } } internal static ScriptScope GetOuter(this ScriptScope scope) { return scope.GetVariable("outer"); } } You can then invoke it like this : innerScope.SetOuter(outerScope); Hope that helps sesh From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson Sent: Friday, May 09, 2008 10:44 AM To: Discussion of IronPython Subject: Re: [IronPython] How to nest ScriptScopes That seems to work, although I used inner to execute (see below). [TestMethod] public void TestMethod1() { var outerscope = _env.CreateScope(); var innerscope = _env.CreateScope(); int outerInput = 3; int innerInput = 2; outerscope.SetVariable("value", outerInput); innerscope.SetVariable("outer", outerscope); innerscope.SetVariable("value", innerInput); _pe.CreateScriptSourceFromString("result = outer.value + value", SourceCodeKind.Statements) .Execute(innerscope); var result = innerscope.GetVariable("result"); Assert.AreEqual(outerInput + innerInput, result); object ignore; Assert.IsFalse(outerscope.TryGetVariable("result", out ignore)); } I'd prefer not to have the dot notation (I know in my sample I had conflicting variable names, but I don't expect that to be the case. It's more a layering of available variables) . Is there some python function I could write that would go through the outerscope and create variables at the inner scope using the name? Or I'm I making this harder than it needs to be? See below, where I just copied the variables. [TestMethod] public void TestMethod2() { var outerscope = _env.CreateScope(); var innerscope = _env.CreateScope(); int outerInput = 3; int innerInput = 2; outerscope.SetVariable("foo", outerInput); foreach (string name in outerscope.VariableNames) { innerscope.SetVariable(name, outerscope.GetVariable(name)); } innerscope.SetVariable("bar", innerInput); _pe.CreateScriptSourceFromString("result = foo + bar", SourceCodeKind.Statements) .Execute(innerscope); var result = innerscope.GetVariable("result"); Assert.AreEqual(outerInput + innerInput, result); object ignore; Assert.IsFalse(outerscope.TryGetVariable("result", out ignore)); } Also, what does "when you have a closure" mean? ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Friday, May 09, 2008 9:59 AM To: Discussion of IronPython Subject: Re: [IronPython] How to nest ScriptScopes It's not really intended that you nest the scopes yourself - usually the scopes only get nested when you have a closure. And then we'll burn references into the parent scopes tuple's directly so we might not even see nested variables (although in some cases we might due a full runtime lookup and see them). Instead of nesting them can you have a ScriptScope that contains other ScriptScope's? In other words your inner most level is just a collection of ScriptScope's which you publish under some well known name into the outer level. Then users can dot through them: outermost = new ScriptScope(); innermost = new ScriptScope(); innermost.SetVariable("somevalue", 3); outermost.SetVariable("next", innermost); then run in outermost. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson Sent: Friday, May 09, 2008 9:52 AM To: users at lists.ironpython.com Subject: [IronPython] How to nest ScriptScopes I've gone over the 2.0 B2 source code, but I'm not clear how I might create nested ScriptScopes using the API in C# One of the tests in EngineTests.cs uses "from published_context_test import x" but this is only one variable, and I'd rather do it from the C# setup side anyway. I noticed that Scope, which ScriptScope contains, has the ability to take a parent Scope, but I'm not clear how I would do this. It seems not to be exposed via ScriptScope. We are using IronPython as a script based extension mechanism for our C# application, my interest is to have a set of established scopes that I can populate with the variables of current application objects at the appropriate level for the current script. Thanks, Marty Nelson ======= 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 Marty.Nelson at symyx.com Fri May 9 20:39:05 2008 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Fri, 9 May 2008 11:39:05 -0700 Subject: [IronPython] How to nest ScriptScopes In-Reply-To: <4F06AAB8EC03C349A5D6D0A797C4881C40AABDB685@NA-EXMSG-C112.redmond.corp.microsoft.com> References: <515335F32AA04440B3DE6FEA1993E9AD02891246@srv-be-101.Symyx-IC.symyx.com><515335F32AA04440B3DE6FEA1993E9AD0289125C@srv-be-101.Symyx-IC.symyx.com><7AD436E4270DD54A94238001769C2227012B2805DE8F@DF-GRTDANE-MSG.exchange.corp.microsoft.com><515335F32AA04440B3DE6FEA1993E9AD0289125F@srv-be-101.Symyx-IC.symyx.com> <4F06AAB8EC03C349A5D6D0A797C4881C40AABDB685@NA-EXMSG-C112.redmond.corp.microsoft.com> Message-ID: <515335F32AA04440B3DE6FEA1993E9AD02891264@srv-be-101.Symyx-IC.symyx.com> Yes, that would be a good logical next step for such code. As far as the concept of the approach, it seems like I have two approaches for producing both and outer. notation and import of outer into inner. It seems that functions that I add to outer are returned as variables as well, which is a nice thing :-) I did notice the "__builtins__" variable, should I avoid copying this? ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Seshadri Pillailokam Vijayaraghavan Sent: Friday, May 09, 2008 11:16 AM To: Discussion of IronPython Subject: Re: [IronPython] How to nest ScriptScopes You can use C# extension methods to copy the variables without cluttering up the code too much Here's what the code would look like... internal static class Extensions{ internal static void SetOuter(this ScriptScope scope, ScriptScope outerScope) { scope.SetVariable("outer", outerScope); foreach (string name in outerScope.VariableNames) { scope.SetVariable(name, outerScope.GetVariable(name)); } } internal static ScriptScope GetOuter(this ScriptScope scope) { return scope.GetVariable("outer"); } } You can then invoke it like this : innerScope.SetOuter(outerScope); Hope that helps sesh From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson Sent: Friday, May 09, 2008 10:44 AM To: Discussion of IronPython Subject: Re: [IronPython] How to nest ScriptScopes That seems to work, although I used inner to execute (see below). [TestMethod] public void TestMethod1() { var outerscope = _env.CreateScope(); var innerscope = _env.CreateScope(); int outerInput = 3; int innerInput = 2; outerscope.SetVariable("value", outerInput); innerscope.SetVariable("outer", outerscope); innerscope.SetVariable("value", innerInput); _pe.CreateScriptSourceFromString("result = outer.value + value", SourceCodeKind.Statements) .Execute(innerscope); var result = innerscope.GetVariable("result"); Assert.AreEqual(outerInput + innerInput, result); object ignore; Assert.IsFalse(outerscope.TryGetVariable("result", out ignore)); } I'd prefer not to have the dot notation (I know in my sample I had conflicting variable names, but I don't expect that to be the case. It's more a layering of available variables) . Is there some python function I could write that would go through the outerscope and create variables at the inner scope using the name? Or I'm I making this harder than it needs to be? See below, where I just copied the variables. [TestMethod] public void TestMethod2() { var outerscope = _env.CreateScope(); var innerscope = _env.CreateScope(); int outerInput = 3; int innerInput = 2; outerscope.SetVariable("foo", outerInput); foreach (string name in outerscope.VariableNames) { innerscope.SetVariable(name, outerscope.GetVariable(name)); } innerscope.SetVariable("bar", innerInput); _pe.CreateScriptSourceFromString("result = foo + bar", SourceCodeKind.Statements) .Execute(innerscope); var result = innerscope.GetVariable("result"); Assert.AreEqual(outerInput + innerInput, result); object ignore; Assert.IsFalse(outerscope.TryGetVariable("result", out ignore)); } Also, what does "when you have a closure" mean? ________________________________ From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dino Viehland Sent: Friday, May 09, 2008 9:59 AM To: Discussion of IronPython Subject: Re: [IronPython] How to nest ScriptScopes It's not really intended that you nest the scopes yourself - usually the scopes only get nested when you have a closure. And then we'll burn references into the parent scopes tuple's directly so we might not even see nested variables (although in some cases we might due a full runtime lookup and see them). Instead of nesting them can you have a ScriptScope that contains other ScriptScope's? In other words your inner most level is just a collection of ScriptScope's which you publish under some well known name into the outer level. Then users can dot through them: outermost = new ScriptScope(); innermost = new ScriptScope(); innermost.SetVariable("somevalue", 3); outermost.SetVariable("next", innermost); then run in outermost. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Marty Nelson Sent: Friday, May 09, 2008 9:52 AM To: users at lists.ironpython.com Subject: [IronPython] How to nest ScriptScopes I've gone over the 2.0 B2 source code, but I'm not clear how I might create nested ScriptScopes using the API in C# One of the tests in EngineTests.cs uses "from published_context_test import x" but this is only one variable, and I'd rather do it from the C# setup side anyway. I noticed that Scope, which ScriptScope contains, has the ability to take a parent Scope, but I'm not clear how I would do this. It seems not to be exposed via ScriptScope. We are using IronPython as a script based extension mechanism for our C# application, my interest is to have a set of established scopes that I can populate with the variables of current application objects at the appropriate level for the current script. Thanks, Marty Nelson ======= 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 dblank at brynmawr.edu Sat May 10 05:25:27 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Fri, 9 May 2008 23:25:27 -0400 (EDT) Subject: [IronPython] Hosting IP2 Beta2 in Mono? Message-ID: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> Does anyone have an example of IronPython2 Beta2 Hosting in C# working with Mono 1.9? I think I have all of the pieces in place, but get an error that ScriptRuntime can not be found on build. Any pointers appreciated! -Doug -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From curt at hagenlocher.org Sat May 10 05:37:49 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Fri, 9 May 2008 20:37:49 -0700 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> Message-ID: We added Microsoft.Scripting.Core.dll in Beta2; you'll probably need to add a reference to that. On Fri, May 9, 2008 at 8:25 PM, Douglas S. Blank wrote: > Does anyone have an example of IronPython2 Beta2 Hosting in C# working > with Mono 1.9? I think I have all of the pieces in place, but get an error > that ScriptRuntime can not be found on build. > > Any pointers appreciated! > > -Doug > > -- > Douglas S. Blank > Associate Professor, Bryn Mawr College > http://cs.brynmawr.edu/~dblank/ > Office: 610 526 6501 > > _______________________________________________ > 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 Sat May 10 16:03:19 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Sat, 10 May 2008 10:03:19 -0400 (EDT) Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> Message-ID: <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> On Fri, May 9, 2008 11:37 pm, Curt Hagenlocher said: > We added Microsoft.Scripting.Core.dll in Beta2; you'll probably need to > add > a reference to that. Curt, thanks for the quick feedback! You are right, and now I need to figure out how to make that happen. Seo, et al: any chance of updating the IPCE build to work with IP2Beta2? It looks like the Microsoft.Scripting.Core.dll requirement isn't going away, so it won't be wasted effort. (Or someone point me in the right direction, and I'll try to do it). I did try using the MS .dll's directly from CodePlex in Mono, and it almost works. It builds fine, but *looks* like there is a bug that prevents Mono from evaluating some statements (like "import sys"). The stack trace from inside my c# code is below. If you think it is something else, please let me know. I'd also be interested in other options to using IP2B2 (other than retreating to an earlier IP). I fairly new to all of this, so maybe I am missing something obvious. -Doug System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The method should be static. Parameter name: method at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method, Boolean throwOnBindFailure) [0x00000] at System.Delegate.CreateDelegate (System.Type type, System.Reflection.MethodInfo method) [0x00000] at Microsoft.Scripting.Utils.InvokeHelper`3[Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]],Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object],Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]]]..ctor (System.Reflection.MethodInfo ) [0x00000] at <0x00000> at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[]) at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] at System.Activator.CreateInstance (System.Type type, BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x00000] at System.Activator.CreateInstance (System.Type type, System.Object[] args, System.Object[] activationAttributes) [0x00000] at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] at Microsoft.Scripting.Utils.ReflectedCaller.SlowCreate (System.Reflection.MethodInfo info, System.Reflection.ParameterInfo[] pis) [0x00000] at Microsoft.Scripting.Utils.ReflectedCaller.FastCreate (System.Reflection.MethodInfo target, System.Reflection.ParameterInfo[] pi) [0x00000] at Microsoft.Scripting.Utils.ReflectedCaller.Create (System.Reflection.MethodInfo info) [0x00000] > On Fri, May 9, 2008 at 8:25 PM, Douglas S. Blank > wrote: > >> Does anyone have an example of IronPython2 Beta2 Hosting in C# working >> with Mono 1.9? I think I have all of the pieces in place, but get an >> error >> that ScriptRuntime can not be found on build. >> >> Any pointers appreciated! >> >> -Doug >> >> -- >> Douglas S. Blank >> Associate Professor, Bryn Mawr College >> http://cs.brynmawr.edu/~dblank/ >> Office: 610 526 6501 >> >> _______________________________________________ >> 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 > -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From daftspaniel at gmail.com Sun May 11 12:16:41 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Sun, 11 May 2008 11:16:41 +0100 Subject: [IronPython] Downloader in Silverlight2 Message-ID: <20253b0c0805110316h747ca89eg9d17dbdbcd966d18@mail.gmail.com> Hi List, I am trying out Silverlight examples ( http://www.voidspace.org.uk/python/weblog/arch_d7_2007_08_18.shtml#e799) and this line is failing in Silverlight 2 from System.Windows import Downloader ImportException: Cannot import name Downloader Can't seem to find any docs on this? Guess it is to do with security? Thanks, Davy Mitchell -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Sun May 11 12:19:36 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 11 May 2008 11:19:36 +0100 Subject: [IronPython] Downloader in Silverlight2 In-Reply-To: <20253b0c0805110316h747ca89eg9d17dbdbcd966d18@mail.gmail.com> References: <20253b0c0805110316h747ca89eg9d17dbdbcd966d18@mail.gmail.com> Message-ID: <4826C838.6000301@voidspace.org.uk> Hello Davy, Downloader is gone, gone, gone.... Use WebClient instead. http://www.voidspace.org.uk/ironpython/silverlight/silverlight_api.shtml#accessing-server-resources-with-the-webclient Michael Davy Mitchell wrote: > Hi List, > > I am trying out Silverlight examples > (http://www.voidspace.org.uk/python/weblog/arch_d7_2007_08_18.shtml#e799) > and this line is failing in Silverlight 2 > > from System.Windows import Downloader > > > ImportException: Cannot import name Downloader > > > Can't seem to find any docs on this? Guess it is to do with security? > > Thanks, > Davy Mitchell > > -- > Davy Mitchell > Blog - http://www.latedecember.co.uk/sites/personal/davy/ > Twitter - http://twitter.com/daftspaniel > Skype - daftspaniel http://needgod.com > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From daftspaniel at gmail.com Sun May 11 12:26:22 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Sun, 11 May 2008 11:26:22 +0100 Subject: [IronPython] Downloader in Silverlight2 In-Reply-To: <4826C838.6000301@voidspace.org.uk> References: <20253b0c0805110316h747ca89eg9d17dbdbcd966d18@mail.gmail.com> <4826C838.6000301@voidspace.org.uk> Message-ID: <20253b0c0805110326mde0b052m5cc3954d6d6319c7@mail.gmail.com> Thanks! On Sun, May 11, 2008 at 11:19 AM, Michael Foord wrote: > Hello Davy, > > Downloader is gone, gone, gone.... > > Use WebClient instead. > > > http://www.voidspace.org.uk/ironpython/silverlight/silverlight_api.shtml#accessing-server-resources-with-the-webclient > > Michael > > Davy Mitchell wrote: > >> Hi List, >> >> I am trying out Silverlight examples ( >> http://www.voidspace.org.uk/python/weblog/arch_d7_2007_08_18.shtml#e799) >> and this line is failing in Silverlight 2 >> >> from System.Windows import Downloader >> >> >> ImportException: Cannot import name Downloader >> >> >> Can't seem to find any docs on this? Guess it is to do with security? >> >> Thanks, >> Davy Mitchell >> >> -- >> Davy Mitchell >> Blog - http://www.latedecember.co.uk/sites/personal/davy/ >> Twitter - http://twitter.com/daftspaniel >> Skype - daftspaniel http://needgod.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 > -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Sun May 11 15:39:56 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 11 May 2008 14:39:56 +0100 Subject: [IronPython] SelectionLength on Silverlight TextBox Message-ID: <4826F72C.6040003@voidspace.org.uk> Hello all, Just to save you all the pain I have just been through, SelectionLength is broken when subclassing the Silverlight TextBox or WatermarkedTextBox and using it in Safari on the Mac. :-) Michael http://www.ironpythoninaction.com/ From dan.eloff at gmail.com Sun May 11 16:38:05 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Sun, 11 May 2008 09:38:05 -0500 Subject: [IronPython] StaticResources + DLR + Silverlight In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A3284580380A77@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <4817b6fc0805050643g61cf500fy91c17510b5661c6a@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284580380A77@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <4817b6fc0805110738y3b1c7c70mdf373d7c95a7d7b1@mail.gmail.com> Ok, I think I have discovered an answer to this one. I haven't tested it because I no longer use xaml files for anything but resources, but it *should* work. Make a xaml file for just application level resources, it should simply consist of a . Use XamlReader.Load() to read it, now you have a dictionary of your global styles and things. Programmatically merge that dictionary into the Application.Current.Resources dictionary. If that works, you should be able to use {StaticResource } to refer to your resources from anywhere. But bottom line is XAML cannot use Python objects and controls, so for anything but the very simple, it soon becomes a liability. I've made a module that simplifies the process of creating controls in Python (which I hope to place in the IronPython cookbook soon.) Here's an example: x.Canvas(Width=400, Height=400)( x.Rectangle(Width=200, Height=200, Canvas_Top=100, Canvas_Left=100, Fill=x.VerticalGradient([(x.Colors.DarkTurquoise, 0), (x.Color('#4169e1'), 1)]) ) It's about half the size of the equivalent xaml, but no static error checking, and very little in the way of auto completion and intellisense, so I consider it about a wash. The advantage is that you can now use Python controls and objects, and you can use anything python has to offer, like loops, closures, or conditionals, when constructing your interface. -Dan On Tue, May 6, 2008 at 2:04 AM, Jimmy Schementi wrote: > Dan, > > It's a very good question, and I'm a little embarrassed not to have a solution for you. Give me some time to poke around and find the best way to do this. > > ~js > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users- >> bounces at lists.ironpython.com] On Behalf Of Dan Eloff >> Sent: Monday, May 05, 2008 6:44 AM >> To: Discussion of IronPython >> Subject: [IronPython] StaticResources + DLR + Silverlight >> >> I notice if you use C#/VB, you have in your main xaml >> file. In there you can place resources that can be used from anywhere >> in your other xaml files. Using the {StaticResource foo} markup >> extension. >> >> If you are using a dynamic language, there is no >> equivalent (please correct me if I'm wrong), most examples I've seen >> use . >> >> The trouble is placing your resources in makes >> them off limit to {StaticResource foo} in any other xaml files (again >> please correct me if I'm wrong) >> >> So I find myself in a nightmare of duplicating resources across files >> and setting styles in code from >> Application.Current.RootVisual.Resources['foo'], neither of which is >> pleasant. Are there really no better alternatives? >> >> -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 dan.eloff at gmail.com Sun May 11 21:22:30 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Sun, 11 May 2008 14:22:30 -0500 Subject: [IronPython] StaticResources + DLR + Silverlight In-Reply-To: <4817b6fc0805110738y3b1c7c70mdf373d7c95a7d7b1@mail.gmail.com> References: <4817b6fc0805050643g61cf500fy91c17510b5661c6a@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A3284580380A77@NA-EXMSG-C116.redmond.corp.microsoft.com> <4817b6fc0805110738y3b1c7c70mdf373d7c95a7d7b1@mail.gmail.com> Message-ID: <4817b6fc0805111222s195cb8daq9d5ced812206781e@mail.gmail.com> Well it would probably work if you could iterate over the keys of a ResourceDictionary like you can in WPF. Maybe that will be fixed before 2.0 RTM? -Dan On Sun, May 11, 2008 at 9:38 AM, Dan Eloff wrote: > Ok, I think I have discovered an answer to this one. I haven't tested > it because I no longer use xaml files for anything but resources, but > it *should* work. Make a xaml file for just application level > resources, it should simply consist of a . Use > XamlReader.Load() to read it, now you have a dictionary of your global > styles and things. Programmatically merge that dictionary into the > Application.Current.Resources dictionary. If that works, you should be > able to use {StaticResource } to refer to your resources from > anywhere. > > But bottom line is XAML cannot use Python objects and controls, so for > anything but the very simple, it soon becomes a liability. I've made a > module that simplifies the process of creating controls in Python > (which I hope to place in the IronPython cookbook soon.) > > Here's an example: > > x.Canvas(Width=400, Height=400)( > x.Rectangle(Width=200, Height=200, Canvas_Top=100, Canvas_Left=100, > > Fill=x.VerticalGradient([(x.Colors.DarkTurquoise, 0), > (x.Color('#4169e1'), 1)]) > ) > > It's about half the size of the equivalent xaml, but no static error > checking, and very little in the way of auto completion and > intellisense, so I consider it about a wash. The advantage is that you > can now use Python controls and objects, and you can use anything > python has to offer, like loops, closures, or conditionals, when > constructing your interface. > > -Dan > > On Tue, May 6, 2008 at 2:04 AM, Jimmy Schementi > wrote: >> Dan, >> >> It's a very good question, and I'm a little embarrassed not to have a solution for you. Give me some time to poke around and find the best way to do this. >> >> ~js >> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users- >>> bounces at lists.ironpython.com] On Behalf Of Dan Eloff >>> Sent: Monday, May 05, 2008 6:44 AM >>> To: Discussion of IronPython >>> Subject: [IronPython] StaticResources + DLR + Silverlight >>> >>> I notice if you use C#/VB, you have in your main xaml >>> file. In there you can place resources that can be used from anywhere >>> in your other xaml files. Using the {StaticResource foo} markup >>> extension. >>> >>> If you are using a dynamic language, there is no >>> equivalent (please correct me if I'm wrong), most examples I've seen >>> use . >>> >>> The trouble is placing your resources in makes >>> them off limit to {StaticResource foo} in any other xaml files (again >>> please correct me if I'm wrong) >>> >>> So I find myself in a nightmare of duplicating resources across files >>> and setting styles in code from >>> Application.Current.RootVisual.Resources['foo'], neither of which is >>> pleasant. Are there really no better alternatives? >>> >>> -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 Mon May 12 09:58:28 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 12 May 2008 08:58:28 +0100 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors Message-ID: <4827F8A4.7020504@voidspace.org.uk> Hello guys, I have a problem with catching network errors raised by HttpWebRequest in Silverlight. (Not necessarily an IronPython specific question - but you guys are so intelligent you are always the first place I turn...) HttpWebRequest uses an async model for fetching resources. If there is a problem (triggered usually by a slow response from the server), then it can happen *after* I have made the request - but before my callback is invoked. This gives me nowhere to catch the exception, as effectively it happens 'inside Silverlight'. I wondered if there was a solution... ? def callback(asyncResult): ... uri = Uri(some_url) req = HttpWebRequest.Create(uri) req.BeginGetResponse(AsyncCallback(callback), object()) The error occurs after BeginGetResponse, but before calback. Any ideas for catching it? Michael Foord http://www.ironpythoninaction.com/ From Jimmy.Schementi at microsoft.com Mon May 12 10:17:05 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Mon, 12 May 2008 01:17:05 -0700 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <4827F8A4.7020504@voidspace.org.uk> References: <4827F8A4.7020504@voidspace.org.uk> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> The actual type returned by HttpWebRequest.Create() is a BrowserHttpWebRequest, but it's internal (not sure why). Anyway, it has a ProgressFailed event you can hook. PS. If you REALLY want synchronous downloading, just hack on XMLHttpRequest def download(url): request = HtmlPage.Window.CreateInstance("XMLHttpRequest") request.Invoke("open", "GET", url, false) # false means synchronous request.Invoke("send", "") return request.GetProperty("responseText") :) ~js ________________________________________ From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord [fuzzyman at voidspace.org.uk] Sent: Monday, May 12, 2008 12:58 AM To: Discussion of IronPython Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors Hello guys, I have a problem with catching network errors raised by HttpWebRequest in Silverlight. (Not necessarily an IronPython specific question - but you guys are so intelligent you are always the first place I turn...) HttpWebRequest uses an async model for fetching resources. If there is a problem (triggered usually by a slow response from the server), then it can happen *after* I have made the request - but before my callback is invoked. This gives me nowhere to catch the exception, as effectively it happens 'inside Silverlight'. I wondered if there was a solution... ? def callback(asyncResult): ... uri = Uri(some_url) req = HttpWebRequest.Create(uri) req.BeginGetResponse(AsyncCallback(callback), object()) The error occurs after BeginGetResponse, but before calback. Any ideas for catching it? Michael Foord http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From christian.muirhead at resolversystems.com Mon May 12 12:50:19 2008 From: christian.muirhead at resolversystems.com (Christian Muirhead) Date: Mon, 12 May 2008 11:50:19 +0100 Subject: [IronPython] Updating WebServices samples In-Reply-To: References: Message-ID: <482820EB.8030104@resolversystems.com> Jimmy Schementi wrote: > I?m actually using this stuff in a talk next month, so I guess *someone* > has to get it working. =P Christian , if you are working on this, by all > means continue, otherwise when I make progress I?ll let you know > Fair enough! :) Well, I had a go at doing this in the weekend, and after a bit of mucking around implementing GetCustomMember and Call methods, I realised that all I really need is the WsdlProvider part. And then that a lot of the stuff the WsdlProvider is doing (adding properties to the code dom for the to-be-generated assembly to enable access to types defined in the WSDL) is much easier done in Python than in C#. So I did that instead. The interface is different - something like this: >>> import wsdlprovider as wsdl >>> url = 'http://www.dotnetjunkies.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx' >>> math = wsdl.GetWebServiceAssembly(url) >>> ws = math.MathService() >>> ws.Add(40, 2.5) 42.5 It turned out that modifying the CodeDom wasn't really necessary - if you return the assembly instead of the proxy type, you can just treat it as a module, and the constructors for parameters to service methods are available already. And if you don't already know the name of the proxy type, you can use wsdlprovider.FindProxyType, which rummages through the assembly to find something that inherits from SoapHttpClientProtocol. It doesn't unify the interfaces as much as they were in the C# code, but that's not that important for the stuff I'm writing. There were a couple of questions that occurred to me when I was doing it in C# (before I remembered that I'd rather code in Python). * While I can replace attribute injectors with GetCustomMember and friends in classes that I'm defining (like WebServiceHelper), DynamicWebServiceHelpers also registers injectors for string (for pluralisation) and XmlElement (convenient child element access). This is a bit like C#'s extension methods (or if I'm feeling uncharitable, Ruby class monkeypatching, since I don't think it's namespaced). How would I get this effect (particularly for the SimpleXmlHelper stuff) in IP2? (Although given the rubyesqueness, maybe I wouldn't want it! ;) In Python, I guess I'd create a transparent wrapper for XmlElement that delegates from __getattr__ (for real XmlElement attributes) and then falls back to the cleverness allowing named child element access. But that wouldn't automatically affect every XmlElement - I'd have to manually wrap any elements as I returned them from my wrapper. * The properties that WsdlProvider adds to the CodeDom before generating an assembly are implemented using a call to Ops.GetDynamicTypeFromType. I couldn't work out the corresponding call in IP2. How would I do that? I haven't tried to port the SimpleXmlHelper and pluralisation to Python yet - it's less useful to me. Not sure what the focus of your talk is, Jimmy, but hopefully this is some help? Cheers, Christian > ~js > > On 5/9/08 8:46 AM, "Dino Viehland" wrote: > > And ICallable is the same - you can now mark a method w/ SpecialName > and call it "Call" and it'll be invoked when you're calling the > object. You can even have multiple overloads, all strongly typed, > etc... > > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo > Sent: Friday, May 09, 2008 6:39 AM > To: Discussion of IronPython > Subject: Re: [IronPython] Updating WebServices samples > > 2008/5/9 Christian Muirhead : > > Is there any chance that someone has updated these to work with > the IP2 > > architecture? If not, how much work would people expect it to be? > The errors > > I saw when I quickly tried to compile the C# were primarily about > not being > > able to find the IAttributesInjector and ICallable interfaces - do > these > > exist in the same form in the new architecture? > > I think IAttributesInjector -- which was hacky, IMO -- has been > replaced by defining GetBoundMember method and marking the method with > SpecialNameAttribute. > > Details are here: > http://blogs.msdn.com/srivatsn/archive/2008/04/12/turning-your-net-object-models-dynamic-for-ironpython.aspx > > -- > Seo Sanghyeon > _______________________________________________ > 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 -- Christian Muirhead Senior Developer Resolver Systems christian.muirhead at resolversystems.com We're hiring! http://www.resolversystems.com/jobs/ 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 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: wsdlprovider.py URL: From sakesun at boonthavorn.com Mon May 12 14:00:32 2008 From: sakesun at boonthavorn.com (Sakesun Roykiattisak) Date: Mon, 12 May 2008 19:00:32 +0700 Subject: [IronPython] Any known clr-interop concurrency issue ? In-Reply-To: <7AD436E4270DD54A94238001769C2227012B2805DE61@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012B2805DE61@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Oh.. You were right. It's a bug in my vendor framework. IronPython is totally safe in multithread environment. Thanks. On Fri, 09 May 2008 22:55:39 +0700, Dino Viehland wrote: > There shouldn't be any issues here or at least we haven't had any > reported and it's not obvious what it could be. From fuzzyman at voidspace.org.uk Mon May 12 15:40:03 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 12 May 2008 14:40:03 +0100 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <482848B3.6060605@voidspace.org.uk> Jimmy Schementi wrote: > The actual type returned by HttpWebRequest.Create() is a BrowserHttpWebRequest, but it's internal (not sure why). Anyway, it has a ProgressFailed event you can hook. > > Ok - I'll try that. Thanks Jimmy. > PS. If you REALLY want synchronous downloading, just hack on XMLHttpRequest > > def download(url): > request = HtmlPage.Window.CreateInstance("XMLHttpRequest") > request.Invoke("open", "GET", url, false) # false means synchronous > request.Invoke("send", "") > return request.GetProperty("responseText") > > :) > > Is that cross-browser? Thanks Michael http://www.ironpythoninaction.com/ > ~js > ________________________________________ > From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord [fuzzyman at voidspace.org.uk] > Sent: Monday, May 12, 2008 12:58 AM > To: Discussion of IronPython > Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors > > Hello guys, > > I have a problem with catching network errors raised by HttpWebRequest > in Silverlight. (Not necessarily an IronPython specific question - but > you guys are so intelligent you are always the first place I turn...) > > HttpWebRequest uses an async model for fetching resources. If there is a > problem (triggered usually by a slow response from the server), then it > can happen *after* I have made the request - but before my callback is > invoked. This gives me nowhere to catch the exception, as effectively it > happens 'inside Silverlight'. I wondered if there was a solution... ? > > > def callback(asyncResult): > ... > > uri = Uri(some_url) > req = HttpWebRequest.Create(uri) > > req.BeginGetResponse(AsyncCallback(callback), object()) > > The error occurs after BeginGetResponse, but before calback. Any ideas > for catching it? > > Michael Foord > http://www.ironpythoninaction.com/ > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From fuzzyman at voidspace.org.uk Mon May 12 15:41:56 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 12 May 2008 14:41:56 +0100 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <482848B3.6060605@voidspace.org.uk> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> <482848B3.6060605@voidspace.org.uk> Message-ID: <48284924.3060703@voidspace.org.uk> Michael Foord wrote: > [snip..] >> PS. If you REALLY want synchronous downloading, just hack on >> XMLHttpRequest >> >> def download(url): >> request = HtmlPage.Window.CreateInstance("XMLHttpRequest") >> request.Invoke("open", "GET", url, false) # false means synchronous >> request.Invoke("send", "") >> return request.GetProperty("responseText") >> >> :) >> >> > > Is that cross-browser? > Well, it works on Firefox. Cool. Michael > Thanks > > Michael > http://www.ironpythoninaction.com/ > > > >> ~js >> ________________________________________ >> From: users-bounces at lists.ironpython.com >> [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord >> [fuzzyman at voidspace.org.uk] >> Sent: Monday, May 12, 2008 12:58 AM >> To: Discussion of IronPython >> Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors >> >> Hello guys, >> >> I have a problem with catching network errors raised by HttpWebRequest >> in Silverlight. (Not necessarily an IronPython specific question - but >> you guys are so intelligent you are always the first place I turn...) >> >> HttpWebRequest uses an async model for fetching resources. If there is a >> problem (triggered usually by a slow response from the server), then it >> can happen *after* I have made the request - but before my callback is >> invoked. This gives me nowhere to catch the exception, as effectively it >> happens 'inside Silverlight'. I wondered if there was a solution... ? >> >> >> def callback(asyncResult): >> ... >> >> uri = Uri(some_url) >> req = HttpWebRequest.Create(uri) >> >> req.BeginGetResponse(AsyncCallback(callback), object()) >> >> The error occurs after BeginGetResponse, but before calback. Any ideas >> for catching it? >> >> Michael Foord >> http://www.ironpythoninaction.com/ >> >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Jimmy.Schementi at microsoft.com Mon May 12 22:05:15 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Mon, 12 May 2008 13:05:15 -0700 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <48284924.3060703@voidspace.org.uk> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> <482848B3.6060605@voidspace.org.uk> <48284924.3060703@voidspace.org.uk> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A32845804CAD4D@NA-EXMSG-C116.redmond.corp.microsoft.com> > >> def download(url): > >> request = HtmlPage.Window.CreateInstance("XMLHttpRequest") > >> request.Invoke("open", "GET", url, false) # false means > synchronous > >> request.Invoke("send", "") > >> return request.GetProperty("responseText") > >> > >> :) > >> > >> > > > > Is that cross-browser? > > > > Well, it works on Firefox. Cool. > > Michael > Works in IE7-8 as well. There's of course cases while using XMLHttpRequest where you have to do browser-specific things, but this little chunk of code will work cross-browser From fuzzyman at voidspace.org.uk Mon May 12 23:10:50 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 12 May 2008 22:10:50 +0100 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A32845804CAD4D@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> <482848B3.6060605@voidspace.org.uk> <48284924.3060703@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A32845804CAD4D@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <4828B25A.5030904@voidspace.org.uk> Jimmy Schementi wrote: >>>> def download(url): >>>> request = HtmlPage.Window.CreateInstance("XMLHttpRequest") >>>> request.Invoke("open", "GET", url, false) # false means >>>> >> synchronous >> >>>> request.Invoke("send", "") >>>> return request.GetProperty("responseText") >>>> >>>> :) >>>> >>>> >>>> >>> Is that cross-browser? >>> >>> >> Well, it works on Firefox. Cool. >> >> Michael >> >> > > Works in IE7-8 as well. There's of course cases while using XMLHttpRequest where you have to do browser-specific things, but this little chunk of code will work cross-browser > Unfortunately my use case is for doing a cross-domain POST, so XMLHttpRequest doesn't work at all. I'll try and get HttpBrowserRequest working. Michael http://www.ironpythoninaction.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From ben2004uk at googlemail.com Tue May 13 13:47:59 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Tue, 13 May 2008 12:47:59 +0100 Subject: [IronPython] DLR: ScriptIO Readonly on ScriptRuntime Message-ID: Hello, I'm currently playing around with some code involing the ScriptRuntime and executing code blocks of code. What I want, is to be able to redirect the output from the script. For example, if a user types Print 'Hello World' I want it to be redirected to my outputting stream. To start with, I looked at the hosting spec. On the ScriptRuntime class, it says there are InputStreams, OutputStreams and ErrorStreams (pg 30) - great, just want I want! http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf However, looking at Assembly: Microsoft.Scripting.Core, Version=1.0.0.2000, ScriptRuntime does not have these properties. It does however have a ScriptIO property for the ScriptIO class which contains all of the streams nicely encapsulated. However, this variable is readonly and only has a getter on the property. Is there any reason for this? What is the recommended approach now in order to get access to the output? I was hoping I would be able to create my own ScriptIO class and assign this to the engine. Any advice on this would be great! Thanks Ben Hall Blog.BenHall.me.uk From dinov at exchange.microsoft.com Tue May 13 18:20:40 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 13 May 2008 09:20:40 -0700 Subject: [IronPython] DLR: ScriptIO Readonly on ScriptRuntime In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012B282260C4@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Bill's still working on getting the hosting spec up to date but hopefully there'll be a refresh soon. For ScriptIO you can call the Set* methods on the ScriptIO object directly - SetOutput, SetErrorOutput, SetInput. There's various overloads that take streams or text writers so that you can provide both binary output or text output - for example if you're a web server and you want to have a language that supports printing a JPG. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall Sent: Tuesday, May 13, 2008 4:48 AM To: Discussion of IronPython Subject: [IronPython] DLR: ScriptIO Readonly on ScriptRuntime Hello, I'm currently playing around with some code involing the ScriptRuntime and executing code blocks of code. What I want, is to be able to redirect the output from the script. For example, if a user types Print 'Hello World' I want it to be redirected to my outputting stream. To start with, I looked at the hosting spec. On the ScriptRuntime class, it says there are InputStreams, OutputStreams and ErrorStreams (pg 30) - great, just want I want! http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf However, looking at Assembly: Microsoft.Scripting.Core, Version=1.0.0.2000, ScriptRuntime does not have these properties. It does however have a ScriptIO property for the ScriptIO class which contains all of the streams nicely encapsulated. However, this variable is readonly and only has a getter on the property. Is there any reason for this? What is the recommended approach now in order to get access to the output? I was hoping I would be able to create my own ScriptIO class and assign this to the engine. Any advice on this would be great! Thanks Ben Hall Blog.BenHall.me.uk _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From ben2004uk at googlemail.com Tue May 13 23:24:25 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Tue, 13 May 2008 22:24:25 +0100 Subject: [IronPython] DLR: ScriptIO Readonly on ScriptRuntime In-Reply-To: <7AD436E4270DD54A94238001769C2227012B282260C4@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012B282260C4@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Wow! Can't believe I missed those methods, i'll have another look at using those now. Sorry :) Thanks Ben On Tue, May 13, 2008 at 5:20 PM, Dino Viehland wrote: > Bill's still working on getting the hosting spec up to date but hopefully there'll be a refresh soon. > > For ScriptIO you can call the Set* methods on the ScriptIO object directly - SetOutput, SetErrorOutput, SetInput. There's various overloads that take streams or text writers so that you can provide both binary output or text output - for example if you're a web server and you want to have a language that supports printing a JPG. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall > Sent: Tuesday, May 13, 2008 4:48 AM > To: Discussion of IronPython > Subject: [IronPython] DLR: ScriptIO Readonly on ScriptRuntime > > Hello, > > I'm currently playing around with some code involing the ScriptRuntime > and executing code blocks of code. What I want, is to be able to > redirect the output from the script. For example, if a user types > Print 'Hello World' I want it to be redirected to my outputting > stream. > > To start with, I looked at the hosting spec. On the ScriptRuntime > class, it says there are InputStreams, OutputStreams and ErrorStreams > (pg 30) - great, just want I want! > http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf > > However, looking at Assembly: Microsoft.Scripting.Core, > Version=1.0.0.2000, ScriptRuntime does not have these properties. > > It does however have a ScriptIO property for the ScriptIO class which > contains all of the streams nicely encapsulated. However, this > variable is readonly and only has a getter on the property. Is there > any reason for this? What is the recommended approach now in order to > get access to the output? I was hoping I would be able to create my > own ScriptIO class and assign this to the engine. > > Any advice on this would be great! > > Thanks > > Ben Hall > Blog.BenHall.me.uk > _______________________________________________ > 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 m.stephen.barnard at gmail.com Wed May 14 02:38:40 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Tue, 13 May 2008 17:38:40 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker Message-ID: The C# sample runs as expected, displaying 'Started. Finished.', but the ipy does nothing. Can someone enlighten me as to the difference? I assume it is something to do with the way functions are represented in ipy vs. what methodinvoker is looking for, but I'm honestly lost. C#: class foo { public void start() { Console.WriteLine("Started."); Thread.Sleep(2000); } public void finish(IAsyncResult r) { Console.WriteLine("Finished."); } } class Program { static void Main(string[] args) { foo bar = new foo(); MethodInvoker mi = new MethodInvoker(bar.start); mi.BeginInvoke(new AsyncCallback(bar.finish), null); Console.ReadLine(); } } IPY: import clr clr.AddReferenceByPartialName('System.Windows.Forms') from System import AsyncCallback from System.Threading import Thread from System.Windows.Forms import MethodInvoker class foo: def start(self): print 'Started.' Thread.Sleep(2000) def finish(self, r): print 'Finished.' bar = foo() mi = MethodInvoker(bar.start) mi.BeginInvoke(AsyncCallback(bar.finish), None) ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Wed May 14 04:05:20 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 13 May 2008 19:05:20 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Where'd the call to Console.ReadLine go? That's the reason you don't see Finished printing... On 1.1 and 2.0B2 from the console or in a file w/ a call to Console.ReadLine or raw_input I end up seeing finished getting printed. We're simply exiting before the asynchronous operation but that doesn't fully answer the question - started is still never printing! Stranger yet you can call mi() directly showing the delegate is clearly created correctly and working. Anyway, I'll have to look at it closer - it might require windbg to figure out what's going wrong here. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Tuesday, May 13, 2008 5:39 PM To: IronPython List Subject: [IronPython] System.Windows.Forms.MethodInvoker The C# sample runs as expected, displaying 'Started. Finished.', but the ipy does nothing. Can someone enlighten me as to the difference? I assume it is something to do with the way functions are represented in ipy vs. what methodinvoker is looking for, but I'm honestly lost. C#: class foo { public void start() { Console.WriteLine("Started."); Thread.Sleep(2000); } public void finish(IAsyncResult r) { Console.WriteLine("Finished."); } } class Program { static void Main(string[] args) { foo bar = new foo(); MethodInvoker mi = new MethodInvoker(bar.start); mi.BeginInvoke(new AsyncCallback(bar.finish), null); Console.ReadLine(); } } IPY: import clr clr.AddReferenceByPartialName('System.Windows.Forms') from System import AsyncCallback from System.Threading import Thread from System.Windows.Forms import MethodInvoker class foo: def start(self): print 'Started.' Thread.Sleep(2000) def finish(self, r): print 'Finished.' bar = foo() mi = MethodInvoker(bar.start) mi.BeginInvoke(AsyncCallback(bar.finish), None) ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.stephen.barnard at gmail.com Wed May 14 05:41:58 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Tue, 13 May 2008 20:41:58 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker In-Reply-To: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Ah- good catch Dino. Didn't see a "Started," so I failed to notice the "Finished." was actually printing ;) It appears that, as with the bit of code that provoked this test, start() is not being executed by BeginInvoke. Thread.Sleep(20000) still drops to "Finished" as soon as the script starts. And my assembly skills are nonexistant; you're on your own with windbg. On Tue, May 13, 2008 at 7:05 PM, Dino Viehland wrote: > Where'd the call to Console.ReadLine go? That's the reason you don't see > Finished printing? On 1.1 and 2.0B2 from the console or in a file w/ a call > to Console.ReadLine or raw_input I end up seeing finished getting printed. > We're simply exiting before the asynchronous operation but that doesn't > fully answer the question ? started is still never printing! Stranger yet > you can call mi() directly showing the delegate is clearly created correctly > and working. Anyway, I'll have to look at it closer ? it might require > windbg to figure out what's going wrong here. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Matthew Barnard > *Sent:* Tuesday, May 13, 2008 5:39 PM > *To:* IronPython List > *Subject:* [IronPython] System.Windows.Forms.MethodInvoker > > > > The C# sample runs as expected, displaying 'Started. Finished.', but the > ipy does nothing. > Can someone enlighten me as to the difference? I assume it is something to > do with the way functions are represented in ipy vs. what methodinvoker is > looking for, > but I'm honestly lost. > > C#: > > class foo > { > public void start() > { > Console.WriteLine("Started."); > Thread.Sleep(2000); > } > > public void finish(IAsyncResult r) > { > Console.WriteLine("Finished."); > } > } > > class Program > { > static void Main(string[] args) > { > foo bar = new foo(); > > MethodInvoker mi = new MethodInvoker(bar.start); > mi.BeginInvoke(new AsyncCallback(bar.finish), null); > > Console.ReadLine(); > } > } > > > IPY: > > import clr > > clr.AddReferenceByPartialName('System.Windows.Forms') > > from System import AsyncCallback > from System.Threading import Thread > from System.Windows.Forms import MethodInvoker > > class foo: > def start(self): > print 'Started.' > Thread.Sleep(2000) > > def finish(self, r): > print 'Finished.' > > bar = foo() > mi = MethodInvoker(bar.start) > mi.BeginInvoke(AsyncCallback(bar.finish), None) > > > ___________________________ > Matthew Barnard > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.stephen.barnard at gmail.com Wed May 14 10:01:03 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Wed, 14 May 2008 01:01:03 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: I spent a good amount of time prodding like an awkward schoolboy at the framework with windbg. Everything is fine from the point of the BeginInvoke thread is created to the point where the function is being looked up. The framework spends a good deal of time rooting around in a MethodTable and looks up and calls a constructor for whatever it found there. This was the last thing I saw it doing before raising an Access Violation, though I was looking at the TV whilst stepping so I'm sure I missed something critical. And now I can sleep. On Tue, May 13, 2008 at 8:41 PM, Matthew Barnard < m.stephen.barnard at gmail.com> wrote: > Ah- good catch Dino. Didn't see a "Started," so I failed to notice the > "Finished." was actually printing ;) > It appears that, as with the bit of code that provoked this test, start() > is not being executed by BeginInvoke. > Thread.Sleep(20000) still drops to "Finished" as soon as the script starts. > > And my assembly skills are nonexistant; you're on your own with windbg. > > > On Tue, May 13, 2008 at 7:05 PM, Dino Viehland < > dinov at exchange.microsoft.com> wrote: > >> Where'd the call to Console.ReadLine go? That's the reason you don't >> see Finished printing? On 1.1 and 2.0B2 from the console or in a file w/ a >> call to Console.ReadLine or raw_input I end up seeing finished getting >> printed. We're simply exiting before the asynchronous operation but that >> doesn't fully answer the question ? started is still never printing! >> Stranger yet you can call mi() directly showing the delegate is clearly >> created correctly and working. Anyway, I'll have to look at it closer ? it >> might require windbg to figure out what's going wrong here. >> >> >> >> *From:* users-bounces at lists.ironpython.com [mailto: >> users-bounces at lists.ironpython.com] *On Behalf Of *Matthew Barnard >> *Sent:* Tuesday, May 13, 2008 5:39 PM >> *To:* IronPython List >> *Subject:* [IronPython] System.Windows.Forms.MethodInvoker >> >> >> >> The C# sample runs as expected, displaying 'Started. Finished.', but the >> ipy does nothing. >> Can someone enlighten me as to the difference? I assume it is something to >> do with the way functions are represented in ipy vs. what methodinvoker is >> looking for, >> but I'm honestly lost. >> >> C#: >> >> class foo >> { >> public void start() >> { >> Console.WriteLine("Started."); >> Thread.Sleep(2000); >> } >> >> public void finish(IAsyncResult r) >> { >> Console.WriteLine("Finished."); >> } >> } >> >> class Program >> { >> static void Main(string[] args) >> { >> foo bar = new foo(); >> >> MethodInvoker mi = new MethodInvoker(bar.start); >> mi.BeginInvoke(new AsyncCallback(bar.finish), null); >> >> Console.ReadLine(); >> } >> } >> >> >> IPY: >> >> import clr >> >> clr.AddReferenceByPartialName('System.Windows.Forms') >> >> from System import AsyncCallback >> from System.Threading import Thread >> from System.Windows.Forms import MethodInvoker >> >> class foo: >> def start(self): >> print 'Started.' >> Thread.Sleep(2000) >> >> def finish(self, r): >> print 'Finished.' >> >> bar = foo() >> mi = MethodInvoker(bar.start) >> mi.BeginInvoke(AsyncCallback(bar.finish), None) >> >> >> ___________________________ >> Matthew Barnard >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > -- > ___________________________ > Matthew Barnard -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.aurel at gmail.com Wed May 14 13:54:05 2008 From: ben.aurel at gmail.com (Ben Aurel) Date: Wed, 14 May 2008 13:54:05 +0200 Subject: [IronPython] error when 'import os' Message-ID: <482AD2DD.1030305@gmail.com> hi I've a simple script that involves the creation of a file. The script doesn't run because it can't import the 'os' module. It's the same message when I try to import it at the interactive shell: --- IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> import os Traceback (most recent call last): ImportError: No module named os --- replacing 'os' with 'nt' gives me the same error. Any ideas what I'm doing wrong here? thanks a lot ben From curt at hagenlocher.org Wed May 14 14:00:45 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Wed, 14 May 2008 05:00:45 -0700 Subject: [IronPython] error when 'import os' In-Reply-To: <482AD2DD.1030305@gmail.com> References: <482AD2DD.1030305@gmail.com> Message-ID: We're not distributing the standard Python library with IronPython right now, so to load os.py, you'd need a copy from the standard distribution or download Seo's IronPython Community Edition from http://fepy.sourceforge.net/. "nt" is a different matter because it's built into the IronPython.dll, so I'm not sure why you might be getting the same error from "nt". On a plain vanilla "installation" of 1.1.1 that I just recently downloaded from CodePlex, I get the following: PS F:\IronPython-1.1.1> .\ipy.exe IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.1434 Copyright (c) Microsoft Corporation. All rights reserved. >>> import nt >>> You get the same error as in the example below? On Wed, May 14, 2008 at 4:54 AM, Ben Aurel wrote: > hi > > I've a simple script that involves the creation of a file. The script > doesn't run because it can't import the 'os' module. It's the same message > when I try to import it at the interactive shell: > --- > IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import os > Traceback (most recent call last): > ImportError: No module named os > --- > > replacing 'os' with 'nt' gives me the same error. > > Any ideas what I'm doing wrong here? > > thanks a lot > ben > > > _______________________________________________ > 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 ben2004uk at googlemail.com Wed May 14 14:00:48 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Wed, 14 May 2008 13:00:48 +0100 Subject: [IronPython] error when 'import os' In-Reply-To: <482AD2DD.1030305@gmail.com> References: <482AD2DD.1030305@gmail.com> Message-ID: Hi, os is within the Python Standard Libraries, as such you will need to install Python 2.5 and add the path to your sys.path variable. You can download python from http://www.python.org/download/releases/2.5.2/ I mentioned this at the end of my blog post last night http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html Hope this helps Ben On Wed, May 14, 2008 at 12:54 PM, Ben Aurel wrote: > hi > > I've a simple script that involves the creation of a file. The script > doesn't run because it can't import the 'os' module. It's the same message > when I try to import it at the interactive shell: > --- > IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. > >>> import os > Traceback (most recent call last): > ImportError: No module named os > --- > > replacing 'os' with 'nt' gives me the same error. > > Any ideas what I'm doing wrong here? > > thanks a lot > ben > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From ben.aurel at gmail.com Wed May 14 14:06:55 2008 From: ben.aurel at gmail.com (Ben Aurel) Date: Wed, 14 May 2008 14:06:55 +0200 Subject: [IronPython] no input display with 'raw_input()' Message-ID: <482AD5DF.6050104@gmail.com> hi Using the following statement in CPython: fname = raw_input('Enter filename: ') I can see what I'm typing. >>> Enter filename: MyTextFi... This is not the case with the same code on IronPython. It doesn't show me my input while typing. Thanks Ben From daftspaniel at gmail.com Wed May 14 15:28:04 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Wed, 14 May 2008 14:28:04 +0100 Subject: [IronPython] Slightly OT: VBX Release? Message-ID: <20253b0c0805140628h708d2aaw3ccc5ccf020c1a64@mail.gmail.com> Hi List, Sorry if this is OT slightly but Jim showing off a VBX console (CLR VB I guess) in a screen cast got me interested. Is there a public release of this or is it coming soon? Thanks, Davy -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben.aurel at gmail.com Wed May 14 17:13:10 2008 From: ben.aurel at gmail.com (Ben Aurel) Date: Wed, 14 May 2008 17:13:10 +0200 Subject: [IronPython] 2 Basic question about IronPython and dyn. langs in general Message-ID: <482B0186.9080009@gmail.com> hi I have two questions on two different subject but anyhow connected. Also I have to admit that I could probably find the answers myself. But I'm quite new to all that things and I have a lot to catch up to... If I understand correctly the are 2 main advantages when it comes to dynamic languages: + Objects doesn't have to be typed be the developer (saves time, makes code shorter and better readable code) + Code is interpreted (no compilation step during development, source dont have to be compiled for the target machines before deployment) which implies the 2 following disadvantages - Writing a lot of tests to catch potential runtime errors (no compile time) - Slower than native code Questions: 1. Why belong the terms "untyped" and "interpreted" somehow together? Why can't the type inference that has to be done at runtime not be done at compiletime. I think the runtime interpreter has to compile the python bytecode to native code somehow - no? Why isn't there a possibility to *compile* python/ruby/perl/... code to native code at the first place? 2. I've read about, that it is possible to compile Python Code to msil with IronPython. Unfortunately I'm not yet at the point where this run on my machine (macosx). So I do have to ask you: Is such a dll/exe the same as I would compile it from c#? Does similar language constructs (eg. for loop, class object creation) the same performance? Thanks in advance. Ben One of the list members - Ben Hall - pointed me at one of his blog posts [1]. http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html From ben2004uk at googlemail.com Wed May 14 17:56:24 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Wed, 14 May 2008 16:56:24 +0100 Subject: [IronPython] 2 Basic question about IronPython and dyn. langs in general In-Reply-To: <482B0186.9080009@gmail.com> References: <482B0186.9080009@gmail.com> Message-ID: I'll try to do my best to answer this. 1) Because a large is dynamically typed, doesn't mean you can't do any verification on the code. Michael Foord told me about PyFlakes (http://divmod.org/projects/pyflakes) and PyLint (http://pypi.python.org/pypi/pylint) which can do static analysis on the code to identity protential problems. 2) If by native code you mean something like C++, then I expect so. Most languages are slower than C++, and it comes down to CPU cycles vs Developer Cycles. I'm sure developers are much more productive in Python than C++. Guess it depends on your application, but Python is running on lots of high performance systems so I don't really think its a problem. 3) Not sure if I understand your question. You can compile Python into bytecode. Compiled Python code are .pyc, http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html In 1.0, there was a sample of how to do this: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423 However, at the moment this is not supported in 2.0 (http://lists.whatwg.org/pipermail/users-ironpython.com/2008-February/006507.html) Ben On Wed, May 14, 2008 at 4:13 PM, Ben Aurel wrote: > hi > I have two questions on two different subject but anyhow connected. Also I > have to admit that I could probably find the answers myself. But I'm quite > new to all that things and I have a lot to catch up to... > > If I understand correctly the are 2 main advantages when it comes to dynamic > languages: > + Objects doesn't have to be typed be the developer > (saves time, makes code shorter and better readable code) > + Code is interpreted > (no compilation step during development, source dont have to be compiled > for the target machines before deployment) > > which implies the 2 following disadvantages > - Writing a lot of tests to catch potential runtime errors (no compile time) > - Slower than native code > > Questions: > > 1. Why belong the terms "untyped" and "interpreted" somehow together? Why > can't the type inference that has to be done at runtime not be done at > compiletime. I think the runtime interpreter has to compile the python > bytecode to native code somehow - no? > Why isn't there a possibility to *compile* python/ruby/perl/... code to > native code at the first place? > > 2. I've read about, that it is possible to compile Python Code to msil with > IronPython. Unfortunately I'm not yet at the point where this run on my > machine (macosx). So I do have to ask you: Is such a dll/exe the same as I > would compile it from c#? Does similar language constructs (eg. for loop, > class object creation) the same performance? > > Thanks in advance. > Ben > > > > One of the list members - Ben Hall - pointed me at one of his blog posts > [1]. > > > > > > http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dinov at exchange.microsoft.com Wed May 14 18:15:35 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 14 May 2008 09:15:35 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B282263E0@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Ok I took a look at this and I believe this is a CLR bug - windbg was really just useful for showing the exception which VS wasn't doing for me. I've included the simple repro below which doesn't require IronPython. The issue is that when we have a dynamic method closed over the 1st parameter the remoting stack thinks we have the wrong number of arguments. It then dutifily tries to report an error but it AVs because the method has no declaring type because it's a dynamic method! So it's a bit of a double bug. There's also the fact that the process isn't getting ripped when this happens so someone's probably swallowing an exception they're not supposed to - a triple bug! I've sent this off to the CLR team to have them take a look. Unless they have a clever workaround this like means it won't work until the CLR is fixed :(. using System; using System.Reflection; using System.Reflection.Emit; using System.Globalization; class Test { delegate void MyDelegate(); public static void Main(string[]args) { DynamicMethod test = new DynamicMethod("Hello", typeof(void), new Type[]{typeof(string)}, typeof(string).Module); MethodInfo writeString = typeof(Console).GetMethod("WriteLine", new Type[]{typeof(string)}); ILGenerator il = test.GetILGenerator(256); il.Emit(OpCodes.Ldarg_0); il.EmitCall(OpCodes.Call, writeString, null); il.Emit(OpCodes.Ret); MyDelegate dlg = (MyDelegate) test.CreateDelegate(typeof(MyDelegate), "Hello World!"); dlg.BeginInvoke(new AsyncCallback(Finished), null); Console.ReadLine(); } public static void Finished(IAsyncResult ar) { } } From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Wednesday, May 14, 2008 1:01 AM To: Discussion of IronPython Subject: Re: [IronPython] System.Windows.Forms.MethodInvoker I spent a good amount of time prodding like an awkward schoolboy at the framework with windbg. Everything is fine from the point of the BeginInvoke thread is created to the point where the function is being looked up. The framework spends a good deal of time rooting around in a MethodTable and looks up and calls a constructor for whatever it found there. This was the last thing I saw it doing before raising an Access Violation, though I was looking at the TV whilst stepping so I'm sure I missed something critical. And now I can sleep. On Tue, May 13, 2008 at 8:41 PM, Matthew Barnard > wrote: Ah- good catch Dino. Didn't see a "Started," so I failed to notice the "Finished." was actually printing ;) It appears that, as with the bit of code that provoked this test, start() is not being executed by BeginInvoke. Thread.Sleep(20000) still drops to "Finished" as soon as the script starts. And my assembly skills are nonexistant; you're on your own with windbg. On Tue, May 13, 2008 at 7:05 PM, Dino Viehland > wrote: Where'd the call to Console.ReadLine go? That's the reason you don't see Finished printing... On 1.1 and 2.0B2 from the console or in a file w/ a call to Console.ReadLine or raw_input I end up seeing finished getting printed. We're simply exiting before the asynchronous operation but that doesn't fully answer the question - started is still never printing! Stranger yet you can call mi() directly showing the delegate is clearly created correctly and working. Anyway, I'll have to look at it closer - it might require windbg to figure out what's going wrong here. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Tuesday, May 13, 2008 5:39 PM To: IronPython List Subject: [IronPython] System.Windows.Forms.MethodInvoker The C# sample runs as expected, displaying 'Started. Finished.', but the ipy does nothing. Can someone enlighten me as to the difference? I assume it is something to do with the way functions are represented in ipy vs. what methodinvoker is looking for, but I'm honestly lost. C#: class foo { public void start() { Console.WriteLine("Started."); Thread.Sleep(2000); } public void finish(IAsyncResult r) { Console.WriteLine("Finished."); } } class Program { static void Main(string[] args) { foo bar = new foo(); MethodInvoker mi = new MethodInvoker(bar.start); mi.BeginInvoke(new AsyncCallback(bar.finish), null); Console.ReadLine(); } } IPY: import clr clr.AddReferenceByPartialName('System.Windows.Forms') from System import AsyncCallback from System.Threading import Thread from System.Windows.Forms import MethodInvoker class foo: def start(self): print 'Started.' Thread.Sleep(2000) def finish(self, r): print 'Finished.' bar = foo() mi = MethodInvoker(bar.start) mi.BeginInvoke(AsyncCallback(bar.finish), None) ___________________________ Matthew Barnard _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- ___________________________ Matthew Barnard -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Wed May 14 18:18:33 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 14 May 2008 09:18:33 -0700 Subject: [IronPython] no input display with 'raw_input()' In-Reply-To: <482AD5DF.6050104@gmail.com> References: <482AD5DF.6050104@gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B282263E1@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Can you give us more info about what version and where you're running? This works for me on both 1.1.1 and 2.0B2: IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.1434 Copyright (c) Microsoft Corporation. All rights reserved. >>> raw_input("Foo: ") Foo: abc 'abc' >>> >>> ^Z 9:17:50.94 C:\Product\4\Merlin\Main > C:\Product\Released\IronPython-2.0B2\ipy.exe IronPython 2.0 Beta (2.0.0.2000) on .NET 2.0.50727.1434 Copyright (c) Microsoft Corporation. All rights reserved. >>> raw_input("Foo: ") Foo: abc 'abc' >>> -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Aurel Sent: Wednesday, May 14, 2008 5:07 AM To: IronPython Subject: [IronPython] no input display with 'raw_input()' hi Using the following statement in CPython: fname = raw_input('Enter filename: ') I can see what I'm typing. >>> Enter filename: MyTextFi... This is not the case with the same code on IronPython. It doesn't show me my input while typing. Thanks Ben _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From Jimmy.Schementi at microsoft.com Wed May 14 19:27:58 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 14 May 2008 10:27:58 -0700 Subject: [IronPython] Slightly OT: VBX Release? In-Reply-To: <20253b0c0805140628h708d2aaw3ccc5ccf020c1a64@mail.gmail.com> References: <20253b0c0805140628h708d2aaw3ccc5ccf020c1a64@mail.gmail.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A328458056898B@NA-EXMSG-C116.redmond.corp.microsoft.com> VBx was an implementation of Visual Basic on the DLR. It was first meant to be in Silverlight, but the VB team decided they'd rather put VB.NET in Silverlight rather than build a new implementation up from scratch. So, VBx is on hold. ~js From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Davy Mitchell Sent: Wednesday, May 14, 2008 6:28 AM To: Discussion of IronPython Subject: [IronPython] Slightly OT: VBX Release? Hi List, Sorry if this is OT slightly but Jim showing off a VBX console (CLR VB I guess) in a screen cast got me interested. Is there a public release of this or is it coming soon? Thanks, Davy -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.stephen.barnard at gmail.com Wed May 14 20:47:36 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Wed, 14 May 2008 11:47:36 -0700 Subject: [IronPython] 2 Basic question about IronPython and dyn. langs in general In-Reply-To: References: <482B0186.9080009@gmail.com> Message-ID: First, I would like to ask anyone with more experience than myself (which is not much) to comment on the validity of this test. I'm sure there are multitudes of differences I am not aware of that would make these results misleading. 2) IronPython Studio does indeed compile ipy code to MSIL, though I'm not clear on how. The executable generated by IPy Studio contains MUCH more code than the C# exe. Comparing a for loop between IPy and C# leads me to the following: Because python's for loops are actually foreach loops (for i in list), I am using a foreach loop in C# as well. Also, because C# has no native type akin to a python list (list resembles a List<> more than anything), I am using List for both, and iterating through it. I have initialized each List<> outside of the test() method and added [0,1] to both. static void test() { foreach (int i in lst) { } } def test(): for i in lst: pass The MSIL for the C# can be seen at http://www.nomorepasting.com/getpaste.php?pasteid=15742&seen=true&numbered=on and the MSIL for the IPy can be seen at http://www.nomorepasting.com/getpaste.php?pasteid=15741&seen=true&numbered=on both showing instructions only and with proper wrapping. Counting instructions only, the IPy generated 14 instructions more than the C# in order to achieve what, in a practical situation (as in, how you would actually use each), is the same code. Looking at the bigger picture, however, the difference in generated bytecode between the C# application and the IPy application is VAST. Again, in a practical sense, both are written in the same manner. That is, if you were to write two applications to accomplish the same task, this is typically how it would be accomplished. It is clear to see that the standard bare-bones C# application produces far less bytecode than the standard bare-bones IPy application. Please, correct me if I'm wrong. This is the extent of my knowledge. On Wed, May 14, 2008 at 8:56 AM, Ben Hall wrote: > I'll try to do my best to answer this. > > 1) Because a large is dynamically typed, doesn't mean you can't do any > verification on the code. Michael Foord told me about PyFlakes > (http://divmod.org/projects/pyflakes) and PyLint > (http://pypi.python.org/pypi/pylint) which can do static analysis on > the code to identity protential problems. > > 2) If by native code you mean something like C++, then I expect so. > Most languages are slower than C++, and it comes down to CPU cycles > vs Developer Cycles. I'm sure developers are much more productive in > Python than C++. Guess it depends on your application, but Python is > running on lots of high performance systems so I don't really think > its a problem. > > 3) Not sure if I understand your question. You can compile Python into > bytecode. Compiled Python code are .pyc, > > http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html > > In 1.0, there was a sample of how to do this: > > http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423 > > However, at the moment this is not supported in 2.0 > ( > http://lists.whatwg.org/pipermail/users-ironpython.com/2008-February/006507.html > ) > > Ben > > > > On Wed, May 14, 2008 at 4:13 PM, Ben Aurel wrote: > > hi > > I have two questions on two different subject but anyhow connected. Also > I > > have to admit that I could probably find the answers myself. But I'm > quite > > new to all that things and I have a lot to catch up to... > > > > If I understand correctly the are 2 main advantages when it comes to > dynamic > > languages: > > + Objects doesn't have to be typed be the developer > > (saves time, makes code shorter and better readable code) > > + Code is interpreted > > (no compilation step during development, source dont have to be > compiled > > for the target machines before deployment) > > > > which implies the 2 following disadvantages > > - Writing a lot of tests to catch potential runtime errors (no compile > time) > > - Slower than native code > > > > Questions: > > > > 1. Why belong the terms "untyped" and "interpreted" somehow together? Why > > can't the type inference that has to be done at runtime not be done at > > compiletime. I think the runtime interpreter has to compile the python > > bytecode to native code somehow - no? > > Why isn't there a possibility to *compile* python/ruby/perl/... code to > > native code at the first place? > > > > 2. I've read about, that it is possible to compile Python Code to msil > with > > IronPython. Unfortunately I'm not yet at the point where this run on my > > machine (macosx). So I do have to ask you: Is such a dll/exe the same as > I > > would compile it from c#? Does similar language constructs (eg. for loop, > > class object creation) the same performance? > > > > Thanks in advance. > > Ben > > > > > > > > One of the list members - Ben Hall - pointed me at one of his blog posts > > [1]. > > > > > > > > > > > > > http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html > > > > _______________________________________________ > > 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 > -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From m.stephen.barnard at gmail.com Wed May 14 20:58:42 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Wed, 14 May 2008 11:58:42 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker In-Reply-To: <7AD436E4270DD54A94238001769C2227012B282263E0@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012B282263E0@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Great, thanks Dino! Very glad to see that I was having a legitimate problem, and not just doing something stupid. So I take from your reproduction that this is an issue of ALL asynchronous delegate invocation; is there a method to do this without manually writing my own threaded invoker? On Wed, May 14, 2008 at 9:15 AM, Dino Viehland wrote: > Ok I took a look at this and I believe this is a CLR bug ? windbg was > really just useful for showing the exception which VS wasn't doing for me. > I've included the simple repro below which doesn't require IronPython. The > issue is that when we have a dynamic method closed over the 1st parameter > the remoting stack thinks we have the wrong number of arguments. It then > dutifily tries to report an error but it AVs because the method has no > declaring type because it's a dynamic method! So it's a bit of a double > bug. There's also the fact that the process isn't getting ripped when this > happens so someone's probably swallowing an exception they're not supposed > to ? a triple bug! > > > > I've sent this off to the CLR team to have them take a look. Unless they > have a clever workaround this like means it won't work until the CLR is > fixed L. > > > > using System; > > using System.Reflection; > > using System.Reflection.Emit; > > using System.Globalization; > > > > class Test { > > > > delegate void MyDelegate(); > > > > public static void Main(string[]args) { > > DynamicMethod test = new DynamicMethod("Hello", > > typeof(void), > > new Type[]{typeof(string)}, > > typeof(string).Module); > > > > MethodInfo writeString = typeof(Console).GetMethod("WriteLine", > > new Type[]{typeof(string)}); > > > > ILGenerator il = test.GetILGenerator(256); > > il.Emit(OpCodes.Ldarg_0); > > il.EmitCall(OpCodes.Call, writeString, null); > > il.Emit(OpCodes.Ret); > > > > MyDelegate dlg = (MyDelegate) > test.CreateDelegate(typeof(MyDelegate), "Hello World!"); > > dlg.BeginInvoke(new AsyncCallback(Finished), null); > > Console.ReadLine(); > > } > > > > public static void Finished(IAsyncResult ar) { > > } > > } > > > > > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Matthew Barnard > *Sent:* Wednesday, May 14, 2008 1:01 AM > *To:* Discussion of IronPython > *Subject:* Re: [IronPython] System.Windows.Forms.MethodInvoker > > > > I spent a good amount of time prodding like an awkward schoolboy at the > framework with windbg. > Everything is fine from the point of the BeginInvoke thread is created to > the point where the function is being looked up. > The framework spends a good deal of time rooting around in a MethodTable > and looks up and calls a constructor for whatever it found there. > This was the last thing I saw it doing before raising an Access Violation, > though I was looking at the TV whilst stepping so I'm sure I missed > something critical. > And now I can sleep. > > On Tue, May 13, 2008 at 8:41 PM, Matthew Barnard < > m.stephen.barnard at gmail.com> wrote: > > Ah- good catch Dino. Didn't see a "Started," so I failed to notice the > "Finished." was actually printing ;) > It appears that, as with the bit of code that provoked this test, start() > is not being executed by BeginInvoke. > Thread.Sleep(20000) still drops to "Finished" as soon as the script starts. > > And my assembly skills are nonexistant; you're on your own with windbg. > > On Tue, May 13, 2008 at 7:05 PM, Dino Viehland < > dinov at exchange.microsoft.com> wrote: > > Where'd the call to Console.ReadLine go? That's the reason you don't > see Finished printing? On 1.1 and 2.0B2 from the console or in a file w/ a > call to Console.ReadLine or raw_input I end up seeing finished getting > printed. We're simply exiting before the asynchronous operation but that > doesn't fully answer the question ? started is still never printing! > Stranger yet you can call mi() directly showing the delegate is clearly > created correctly and working. Anyway, I'll have to look at it closer ? it > might require windbg to figure out what's going wrong here. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Matthew Barnard > *Sent:* Tuesday, May 13, 2008 5:39 PM > *To:* IronPython List > *Subject:* [IronPython] System.Windows.Forms.MethodInvoker > > > > The C# sample runs as expected, displaying 'Started. Finished.', but the > ipy does nothing. > Can someone enlighten me as to the difference? I assume it is something to > do with the way functions are represented in ipy vs. what methodinvoker is > looking for, > but I'm honestly lost. > > C#: > > class foo > { > public void start() > { > Console.WriteLine("Started."); > Thread.Sleep(2000); > } > > public void finish(IAsyncResult r) > { > Console.WriteLine("Finished."); > } > } > > class Program > { > static void Main(string[] args) > { > foo bar = new foo(); > > MethodInvoker mi = new MethodInvoker(bar.start); > mi.BeginInvoke(new AsyncCallback(bar.finish), null); > > Console.ReadLine(); > } > } > > > IPY: > > import clr > > clr.AddReferenceByPartialName('System.Windows.Forms') > > from System import AsyncCallback > from System.Threading import Thread > from System.Windows.Forms import MethodInvoker > > class foo: > def start(self): > print 'Started.' > Thread.Sleep(2000) > > def finish(self, r): > print 'Finished.' > > bar = foo() > mi = MethodInvoker(bar.start) > mi.BeginInvoke(AsyncCallback(bar.finish), None) > > > ___________________________ > Matthew Barnard > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > > -- > ___________________________ > Matthew Barnard > > > > > -- > ___________________________ > Matthew Barnard > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Wed May 14 22:07:13 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 14 May 2008 13:07:13 -0700 Subject: [IronPython] System.Windows.Forms.MethodInvoker In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012B282262F2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012B282263E0@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B2822648F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Good question - this seems to be a reasonable work around, have a C# class like: using System; using System.Windows.Forms; public class DelegateTest { public static MethodInvoker MakeDelegate(Delegate dlg) { return new MethodInvoker(((MethodInvoker)dlg).Invoke); } } And then you can do: x = DelegateTest.MakeDelegate(MethodInvoker(mi.Invoke)) x.BeginInvoke(AsyncCallback(bar.finish), None) That's just wrapping the delegate in a normal delegate so you avoid doing a synchronous invoke on the dynamic method delegate and the asynchronous invoke on the "normal" method. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Wednesday, May 14, 2008 11:59 AM To: Discussion of IronPython Subject: Re: [IronPython] System.Windows.Forms.MethodInvoker Great, thanks Dino! Very glad to see that I was having a legitimate problem, and not just doing something stupid. So I take from your reproduction that this is an issue of ALL asynchronous delegate invocation; is there a method to do this without manually writing my own threaded invoker? On Wed, May 14, 2008 at 9:15 AM, Dino Viehland > wrote: Ok I took a look at this and I believe this is a CLR bug - windbg was really just useful for showing the exception which VS wasn't doing for me. I've included the simple repro below which doesn't require IronPython. The issue is that when we have a dynamic method closed over the 1st parameter the remoting stack thinks we have the wrong number of arguments. It then dutifily tries to report an error but it AVs because the method has no declaring type because it's a dynamic method! So it's a bit of a double bug. There's also the fact that the process isn't getting ripped when this happens so someone's probably swallowing an exception they're not supposed to - a triple bug! I've sent this off to the CLR team to have them take a look. Unless they have a clever workaround this like means it won't work until the CLR is fixed :(. using System; using System.Reflection; using System.Reflection.Emit; using System.Globalization; class Test { delegate void MyDelegate(); public static void Main(string[]args) { DynamicMethod test = new DynamicMethod("Hello", typeof(void), new Type[]{typeof(string)}, typeof(string).Module); MethodInfo writeString = typeof(Console).GetMethod("WriteLine", new Type[]{typeof(string)}); ILGenerator il = test.GetILGenerator(256); il.Emit(OpCodes.Ldarg_0); il.EmitCall(OpCodes.Call, writeString, null); il.Emit(OpCodes.Ret); MyDelegate dlg = (MyDelegate) test.CreateDelegate(typeof(MyDelegate), "Hello World!"); dlg.BeginInvoke(new AsyncCallback(Finished), null); Console.ReadLine(); } public static void Finished(IAsyncResult ar) { } } From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Wednesday, May 14, 2008 1:01 AM To: Discussion of IronPython Subject: Re: [IronPython] System.Windows.Forms.MethodInvoker I spent a good amount of time prodding like an awkward schoolboy at the framework with windbg. Everything is fine from the point of the BeginInvoke thread is created to the point where the function is being looked up. The framework spends a good deal of time rooting around in a MethodTable and looks up and calls a constructor for whatever it found there. This was the last thing I saw it doing before raising an Access Violation, though I was looking at the TV whilst stepping so I'm sure I missed something critical. And now I can sleep. On Tue, May 13, 2008 at 8:41 PM, Matthew Barnard > wrote: Ah- good catch Dino. Didn't see a "Started," so I failed to notice the "Finished." was actually printing ;) It appears that, as with the bit of code that provoked this test, start() is not being executed by BeginInvoke. Thread.Sleep(20000) still drops to "Finished" as soon as the script starts. And my assembly skills are nonexistant; you're on your own with windbg. On Tue, May 13, 2008 at 7:05 PM, Dino Viehland > wrote: Where'd the call to Console.ReadLine go? That's the reason you don't see Finished printing... On 1.1 and 2.0B2 from the console or in a file w/ a call to Console.ReadLine or raw_input I end up seeing finished getting printed. We're simply exiting before the asynchronous operation but that doesn't fully answer the question - started is still never printing! Stranger yet you can call mi() directly showing the delegate is clearly created correctly and working. Anyway, I'll have to look at it closer - it might require windbg to figure out what's going wrong here. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Tuesday, May 13, 2008 5:39 PM To: IronPython List Subject: [IronPython] System.Windows.Forms.MethodInvoker The C# sample runs as expected, displaying 'Started. Finished.', but the ipy does nothing. Can someone enlighten me as to the difference? I assume it is something to do with the way functions are represented in ipy vs. what methodinvoker is looking for, but I'm honestly lost. C#: class foo { public void start() { Console.WriteLine("Started."); Thread.Sleep(2000); } public void finish(IAsyncResult r) { Console.WriteLine("Finished."); } } class Program { static void Main(string[] args) { foo bar = new foo(); MethodInvoker mi = new MethodInvoker(bar.start); mi.BeginInvoke(new AsyncCallback(bar.finish), null); Console.ReadLine(); } } IPY: import clr clr.AddReferenceByPartialName('System.Windows.Forms') from System import AsyncCallback from System.Threading import Thread from System.Windows.Forms import MethodInvoker class foo: def start(self): print 'Started.' Thread.Sleep(2000) def finish(self, r): print 'Finished.' bar = foo() mi = MethodInvoker(bar.start) mi.BeginInvoke(AsyncCallback(bar.finish), None) ___________________________ Matthew Barnard _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- ___________________________ Matthew Barnard -- ___________________________ Matthew Barnard _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From dinov at exchange.microsoft.com Wed May 14 22:10:12 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 14 May 2008 13:10:12 -0700 Subject: [IronPython] 2 Basic question about IronPython and dyn. langs in general In-Reply-To: References: <482B0186.9080009@gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012B28226494@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Yep, the additional code is all there to deal with the dynamic typing. There's another significant difference though and that's when you declare classes. C# will generate a class exactly like how you specifiy it but IronPython will generate a subclass of whatever your base type is, it will override all of the virtual methods on it, and then turn any of those invocations into a lookup in a dictionary and an invoke of the resulting member. The actual generated class won't contain any of the members you define and it also won't have a parameterless constructor. That breaks certain scenarios where tools expect to find the real class or expect to be able to create instances of some class. Ipy studio contains some code to be closer to C# but it's one big hack. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Matthew Barnard Sent: Wednesday, May 14, 2008 11:48 AM To: Discussion of IronPython Subject: Re: [IronPython] 2 Basic question about IronPython and dyn. langs in general First, I would like to ask anyone with more experience than myself (which is not much) to comment on the validity of this test. I'm sure there are multitudes of differences I am not aware of that would make these results misleading. 2) IronPython Studio does indeed compile ipy code to MSIL, though I'm not clear on how. The executable generated by IPy Studio contains MUCH more code than the C# exe. Comparing a for loop between IPy and C# leads me to the following: Because python's for loops are actually foreach loops (for i in list), I am using a foreach loop in C# as well. Also, because C# has no native type akin to a python list (list resembles a List<> more than anything), I am using List for both, and iterating through it. I have initialized each List<> outside of the test() method and added [0,1] to both. static void test() { foreach (int i in lst) { } } def test(): for i in lst: pass The MSIL for the C# can be seen at http://www.nomorepasting.com/getpaste.php?pasteid=15742&seen=true&numbered=on and the MSIL for the IPy can be seen at http://www.nomorepasting.com/getpaste.php?pasteid=15741&seen=true&numbered=on both showing instructions only and with proper wrapping. Counting instructions only, the IPy generated 14 instructions more than the C# in order to achieve what, in a practical situation (as in, how you would actually use each), is the same code. Looking at the bigger picture, however, the difference in generated bytecode between the C# application and the IPy application is VAST. Again, in a practical sense, both are written in the same manner. That is, if you were to write two applications to accomplish the same task, this is typically how it would be accomplished. It is clear to see that the standard bare-bones C# application produces far less bytecode than the standard bare-bones IPy application. Please, correct me if I'm wrong. This is the extent of my knowledge. On Wed, May 14, 2008 at 8:56 AM, Ben Hall > wrote: I'll try to do my best to answer this. 1) Because a large is dynamically typed, doesn't mean you can't do any verification on the code. Michael Foord told me about PyFlakes (http://divmod.org/projects/pyflakes) and PyLint (http://pypi.python.org/pypi/pylint) which can do static analysis on the code to identity protential problems. 2) If by native code you mean something like C++, then I expect so. Most languages are slower than C++, and it comes down to CPU cycles vs Developer Cycles. I'm sure developers are much more productive in Python than C++. Guess it depends on your application, but Python is running on lots of high performance systems so I don't really think its a problem. 3) Not sure if I understand your question. You can compile Python into bytecode. Compiled Python code are .pyc, http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html In 1.0, there was a sample of how to do this: http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423 However, at the moment this is not supported in 2.0 (http://lists.whatwg.org/pipermail/users-ironpython.com/2008-February/006507.html) Ben On Wed, May 14, 2008 at 4:13 PM, Ben Aurel > wrote: > hi > I have two questions on two different subject but anyhow connected. Also I > have to admit that I could probably find the answers myself. But I'm quite > new to all that things and I have a lot to catch up to... > > If I understand correctly the are 2 main advantages when it comes to dynamic > languages: > + Objects doesn't have to be typed be the developer > (saves time, makes code shorter and better readable code) > + Code is interpreted > (no compilation step during development, source dont have to be compiled > for the target machines before deployment) > > which implies the 2 following disadvantages > - Writing a lot of tests to catch potential runtime errors (no compile time) > - Slower than native code > > Questions: > > 1. Why belong the terms "untyped" and "interpreted" somehow together? Why > can't the type inference that has to be done at runtime not be done at > compiletime. I think the runtime interpreter has to compile the python > bytecode to native code somehow - no? > Why isn't there a possibility to *compile* python/ruby/perl/... code to > native code at the first place? > > 2. I've read about, that it is possible to compile Python Code to msil with > IronPython. Unfortunately I'm not yet at the point where this run on my > machine (macosx). So I do have to ask you: Is such a dll/exe the same as I > would compile it from c#? Does similar language constructs (eg. for loop, > class object creation) the same performance? > > Thanks in advance. > Ben > > > > One of the list members - Ben Hall - pointed me at one of his blog posts > [1]. > > > > > > http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html > > _______________________________________________ > 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 -- ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From cemasoniv at gmail.com Wed May 14 22:18:27 2008 From: cemasoniv at gmail.com (Charles Mason) Date: Wed, 14 May 2008 16:18:27 -0400 Subject: [IronPython] 2 Basic question about IronPython and dyn. langs in general In-Reply-To: References: <482B0186.9080009@gmail.com> Message-ID: <3290753a0805141318m27afcea2y741c92db8ecdad00@mail.gmail.com> I think the reason for the size increase (like Dino mentioned) is to handle the dynamicity of the language. "for i in lst" is not exactly foreach( int i in lst ) The equivelent code is something more along the lines of: iterator = lst.__iter__() while (i = iterator.next()) doesn't raise exception StopIteration: use i There's probably other checks that go on to make sure the iterator returned is proper and all that. C On Wed, May 14, 2008 at 2:47 PM, Matthew Barnard < m.stephen.barnard at gmail.com> wrote: > First, I would like to ask anyone with more experience than myself (which > is not much) to comment on the validity of this test. > I'm sure there are multitudes of differences I am not aware of that would > make these results misleading. > > 2) IronPython Studio does indeed compile ipy code to MSIL, though I'm not > clear on how. > The executable generated by IPy Studio contains MUCH more code than the C# > exe. > > Comparing a for loop between IPy and C# leads me to the following: > Because python's for loops are actually foreach loops (for i in list), I am > using a foreach loop in C# as well. > Also, because C# has no native type akin to a python list (list resembles a > List<> more than anything), > I am using List for both, and iterating through it. I have initialized > each List<> outside of the test() method > and added [0,1] to both. > > static void test() > { > foreach (int i in lst) > { > } > } > > def test(): > for i in lst: > pass > > The MSIL for the C# can be seen at > http://www.nomorepasting.com/getpaste.php?pasteid=15742&seen=true&numbered=on > and the MSIL for the IPy can be seen at > http://www.nomorepasting.com/getpaste.php?pasteid=15741&seen=true&numbered=on > both showing instructions only and with proper wrapping. > > Counting instructions only, the IPy generated 14 instructions more than the > C# in order to achieve what, in a practical situation (as in, how you would > actually use each), is the same code. > > Looking at the bigger picture, however, the difference in generated > bytecode between the C# application and the IPy application is VAST. Again, > in a practical sense, both are written in the same manner. That is, if you > were to write two applications to accomplish the same task, this is > typically how it would be accomplished. It is clear to see that the standard > bare-bones C# application produces far less bytecode than the standard > bare-bones IPy application. > > Please, correct me if I'm wrong. This is the extent of my knowledge. > > > > > > On Wed, May 14, 2008 at 8:56 AM, Ben Hall > wrote: > >> I'll try to do my best to answer this. >> >> 1) Because a large is dynamically typed, doesn't mean you can't do any >> verification on the code. Michael Foord told me about PyFlakes >> (http://divmod.org/projects/pyflakes) and PyLint >> (http://pypi.python.org/pypi/pylint) which can do static analysis on >> the code to identity protential problems. >> >> 2) If by native code you mean something like C++, then I expect so. >> Most languages are slower than C++, and it comes down to CPU cycles >> vs Developer Cycles. I'm sure developers are much more productive in >> Python than C++. Guess it depends on your application, but Python is >> running on lots of high performance systems so I don't really think >> its a problem. >> >> 3) Not sure if I understand your question. You can compile Python into >> bytecode. Compiled Python code are .pyc, >> >> http://www.network-theory.co.uk/docs/pytut/CompiledPythonfiles.html >> >> In 1.0, there was a sample of how to do this: >> >> http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=IronPython&ReleaseId=423 >> >> However, at the moment this is not supported in 2.0 >> ( >> http://lists.whatwg.org/pipermail/users-ironpython.com/2008-February/006507.html >> ) >> >> Ben >> >> >> >> On Wed, May 14, 2008 at 4:13 PM, Ben Aurel wrote: >> > hi >> > I have two questions on two different subject but anyhow connected. Also >> I >> > have to admit that I could probably find the answers myself. But I'm >> quite >> > new to all that things and I have a lot to catch up to... >> > >> > If I understand correctly the are 2 main advantages when it comes to >> dynamic >> > languages: >> > + Objects doesn't have to be typed be the developer >> > (saves time, makes code shorter and better readable code) >> > + Code is interpreted >> > (no compilation step during development, source dont have to be >> compiled >> > for the target machines before deployment) >> > >> > which implies the 2 following disadvantages >> > - Writing a lot of tests to catch potential runtime errors (no compile >> time) >> > - Slower than native code >> > >> > Questions: >> > >> > 1. Why belong the terms "untyped" and "interpreted" somehow together? >> Why >> > can't the type inference that has to be done at runtime not be done at >> > compiletime. I think the runtime interpreter has to compile the python >> > bytecode to native code somehow - no? >> > Why isn't there a possibility to *compile* python/ruby/perl/... code to >> > native code at the first place? >> > >> > 2. I've read about, that it is possible to compile Python Code to msil >> with >> > IronPython. Unfortunately I'm not yet at the point where this run on my >> > machine (macosx). So I do have to ask you: Is such a dll/exe the same as >> I >> > would compile it from c#? Does similar language constructs (eg. for >> loop, >> > class object creation) the same performance? >> > >> > Thanks in advance. >> > Ben >> > >> > >> > >> > One of the list members - Ben Hall - pointed me at one of his blog posts >> > [1]. >> > >> > >> > >> > >> > >> > >> http://blog.benhall.me.uk/2008/05/ironpython-classes-within-separate.html >> > >> > _______________________________________________ >> > 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 >> > > > > -- > ___________________________ > Matthew Barnard > _______________________________________________ > 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 gmail.com Wed May 14 22:48:46 2008 From: fuzzyman at gmail.com (Michael Foord) Date: Wed, 14 May 2008 13:48:46 -0700 (PDT) Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <530a79a6-0bce-471b-843e-10db132795c9@k13g2000hse.googlegroups.com> On May 12, 9:17?am, Jimmy Schementi wrote: > The actual type returned by HttpWebRequest.Create() is a BrowserHttpWebRequest, but it's internal (not sure why). Anyway, it has a ProgressFailed event you can hook. Hello Jimmy, As far as I can tell it *doesn't* have the 'ProgressFailed' event. I need to make cross-domain POST, and although the request gets made successfully I'm getting a COM Arg Exception everytime (I think because the server is slow to respond). This is screwing me at the moment. FYI - when I execute the following code in Silverlight: from System.Net import WebRequest from System import Uri u = Uri('http://www.v.com') req = WebRequest.Create(u) print req.ProgressFailed I get the following exception: Traceback (most recent call last): File "None", line 6, in AttributeError: 'BrowserHttpWebRequest' object has no attribute 'ProgressFailed' All the best, Michael Foord http://www.ironpythoninaction.com/ > > PS. If you REALLY want synchronous downloading, just hack on XMLHttpRequest > > def download(url): > ? ? request = HtmlPage.Window.CreateInstance("XMLHttpRequest") > ? ? request.Invoke("open", "GET", url, false) # false means synchronous > ? ? request.Invoke("send", "") > ? ? return request.GetProperty("responseText") > > :) > > ~js > ________________________________________ > From: users-boun... at lists.ironpython.com [users-boun... at lists.ironpython.com] On Behalf Of Michael Foord [fuzzy... at voidspace.org.uk] > Sent: Monday, May 12, 2008 12:58 AM > To: Discussion of IronPython > Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors > > Hello guys, > > I have a problem with catching network errors raised by HttpWebRequest > in Silverlight. (Not necessarily an IronPython specific question - but > you guys are so intelligent you are always the first place I turn...) > > HttpWebRequest uses an async model for fetching resources. If there is a > problem (triggered usually by a slow response from the server), then it > can happen *after* I have made the request - but before my callback is > invoked. This gives me nowhere to catch the exception, as effectively it > happens 'inside Silverlight'. I wondered if there was a solution... ? > > def callback(asyncResult): > ? ? ... > > uri = Uri(some_url) > req = HttpWebRequest.Create(uri) > > req.BeginGetResponse(AsyncCallback(callback), object()) > > The error occurs after BeginGetResponse, but before calback. Any ideas > for catching it? > > Michael Foordhttp://www.ironpythoninaction.com/ > > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com From m.stephen.barnard at gmail.com Wed May 14 23:27:04 2008 From: m.stephen.barnard at gmail.com (Matthew Barnard) Date: Wed, 14 May 2008 14:27:04 -0700 Subject: [IronPython] protected set { } Message-ID: public abstract class Object { protected string weakName = string.Empty; public string WeakName { get { return this.weakName; } protected set { this.weakName = value; } } } public class Derived { public Derived() { this.WeakName = "Hello"; } } In C#: Derived obj = new Derived(); Console.WriteLine(obj.WeakName) Hello obj.WeakName = "Fail"; The property or indexer 'Object.WeakName' cannot be used in this context because the set accessor is inaccessible In IPy: >>> obj = Derived() >>> obj.WeakName = 'Succeed' >>> obj.WeakName 'Succeed' Is this expected behavior? ___________________________ Matthew Barnard -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed May 14 23:37:03 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 14 May 2008 22:37:03 +0100 Subject: [IronPython] protected set { } In-Reply-To: References: Message-ID: <482B5B7F.9040809@voidspace.org.uk> Matthew Barnard wrote: > public abstract class Object > { > protected string weakName = string.Empty; > > public string WeakName > { > get { return this.weakName; } > protected set { this.weakName = value; } > } > } > > public class Derived > { > public Derived() > { > this.WeakName = "Hello"; > } > } > > In C#: > Derived obj = new Derived(); > Console.WriteLine(obj.WeakName) > Hello > obj.WeakName = "Fail"; > The property or indexer 'Object.WeakName' cannot be used in this > context because the set accessor is inaccessible > > In IPy: > >>> obj = Derived() > >>> obj.WeakName = 'Succeed' > >>> obj.WeakName > 'Succeed' > > Is this expected behavior? Yes. Michael Foord > > ___________________________ > Matthew Barnard > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From fuzzyman at voidspace.org.uk Wed May 14 23:54:43 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 14 May 2008 22:54:43 +0100 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <530a79a6-0bce-471b-843e-10db132795c9@k13g2000hse.googlegroups.com> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> <530a79a6-0bce-471b-843e-10db132795c9@k13g2000hse.googlegroups.com> Message-ID: <482B5FA3.6070506@voidspace.org.uk> Michael Foord wrote: > On May 12, 9:17 am, Jimmy Schementi > wrote: > >> The actual type returned by HttpWebRequest.Create() is a BrowserHttpWebRequest, but it's internal (not sure why). Anyway, it has a ProgressFailed event you can hook. >> > > Hello Jimmy, > > As far as I can tell it *doesn't* have the 'ProgressFailed' event. > The actual failure I see is: Exception: [Arg_COMException] Arguments: Debugging resource strings are unavailable. Often the key and arguments provide sufficient information to diagnose the problem. See http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.1&File=mscorlib.dll&Key=Arg_COMException This is using Safari. As I'm developing on the Mac I can't use debugging, nor can I test in Firefox because of the bug in Chiron. It looks like some people have similar errors: http://silverlight.net/forums/p/12500/40967.aspx#40967 and a guy in the comments here: http://www.cameronalbert.com/post/2008/03/HttpWebRequest-Helper-for-Silverlight-2.aspx All the best, Michael Foord http://www.ironpythoninaction.com/ > I need to make cross-domain POST, and although the request gets made > successfully I'm getting a COM Arg Exception everytime (I think > because the server is slow to respond). This is screwing me at the > moment. > > FYI - when I execute the following code in Silverlight: > > from System.Net import WebRequest > from System import Uri > > u = Uri('http://www.v.com') > req = WebRequest.Create(u) > print req.ProgressFailed > > I get the following exception: > > Traceback (most recent call last): > File "None", line 6, in > AttributeError: 'BrowserHttpWebRequest' object has no attribute > 'ProgressFailed' > > All the best, > > Michael Foord > http://www.ironpythoninaction.com/ > > >> PS. If you REALLY want synchronous downloading, just hack on XMLHttpRequest >> >> def download(url): >> request = HtmlPage.Window.CreateInstance("XMLHttpRequest") >> request.Invoke("open", "GET", url, false) # false means synchronous >> request.Invoke("send", "") >> return request.GetProperty("responseText") >> >> :) >> >> ~js >> ________________________________________ >> From: users-boun... at lists.ironpython.com [users-boun... at lists.ironpython.com] On Behalf Of Michael Foord [fuzzy... at voidspace.org.uk] >> Sent: Monday, May 12, 2008 12:58 AM >> To: Discussion of IronPython >> Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors >> >> Hello guys, >> >> I have a problem with catching network errors raised by HttpWebRequest >> in Silverlight. (Not necessarily an IronPython specific question - but >> you guys are so intelligent you are always the first place I turn...) >> >> HttpWebRequest uses an async model for fetching resources. If there is a >> problem (triggered usually by a slow response from the server), then it >> can happen *after* I have made the request - but before my callback is >> invoked. This gives me nowhere to catch the exception, as effectively it >> happens 'inside Silverlight'. I wondered if there was a solution... ? >> >> def callback(asyncResult): >> ... >> >> uri = Uri(some_url) >> req = HttpWebRequest.Create(uri) >> >> req.BeginGetResponse(AsyncCallback(callback), object()) >> >> The error occurs after BeginGetResponse, but before calback. Any ideas >> for catching it? >> >> Michael Foordhttp://www.ironpythoninaction.com/ >> >> _______________________________________________ >> Users mailing list >> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From fuzzyman at voidspace.org.uk Wed May 14 23:58:05 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 14 May 2008 22:58:05 +0100 Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors In-Reply-To: <482B5FA3.6070506@voidspace.org.uk> References: <4827F8A4.7020504@voidspace.org.uk> <5283CA0A4168DF4FBBD71AE9ECA5A328457FE34E1D@NA-EXMSG-C116.redmond.corp.microsoft.com> <530a79a6-0bce-471b-843e-10db132795c9@k13g2000hse.googlegroups.com> <482B5FA3.6070506@voidspace.org.uk> Message-ID: <482B606D.60205@voidspace.org.uk> Michael Foord wrote: > Michael Foord wrote: >> On May 12, 9:17 am, Jimmy Schementi >> wrote: >> >>> The actual type returned by HttpWebRequest.Create() is a >>> BrowserHttpWebRequest, but it's internal (not sure why). Anyway, it >>> has a ProgressFailed event you can hook. >>> >> >> Hello Jimmy, >> >> As far as I can tell it *doesn't* have the 'ProgressFailed' event. >> > > The actual failure I see is: > > Exception: [Arg_COMException] > Arguments: > Debugging resource strings are unavailable. Often the key and > arguments provide sufficient information to diagnose the problem. See > http://go.microsoft.com/fwlink/?linkid=106663&Version=2.0.30226.1&File=mscorlib.dll&Key=Arg_COMException > > > Sorry for the noise. This one is actually for the sake of google (and all who sail in her). Exception at MS.Internal.XcpImports.GetDownloaderBytes(IntPtr element, IntPtr& outBytes, Int32& outSize) at MS.Internal.InternalWebRequest.GetResponseStream() at System.Net.BrowserHttpWebRequest.Completed(Object sender, EventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) Michael > This is using Safari. As I'm developing on the Mac I can't use > debugging, nor can I test in Firefox because of the bug in Chiron. > > It looks like some people have similar errors: > > http://silverlight.net/forums/p/12500/40967.aspx#40967 > > and a guy in the comments here: > > > http://www.cameronalbert.com/post/2008/03/HttpWebRequest-Helper-for-Silverlight-2.aspx > > > All the best, > > Michael Foord > http://www.ironpythoninaction.com/ > >> I need to make cross-domain POST, and although the request gets made >> successfully I'm getting a COM Arg Exception everytime (I think >> because the server is slow to respond). This is screwing me at the >> moment. >> >> FYI - when I execute the following code in Silverlight: >> >> from System.Net import WebRequest >> from System import Uri >> >> u = Uri('http://www.v.com') >> req = WebRequest.Create(u) >> print req.ProgressFailed >> >> I get the following exception: >> >> Traceback (most recent call last): >> File "None", line 6, in >> AttributeError: 'BrowserHttpWebRequest' object has no attribute >> 'ProgressFailed' >> >> All the best, >> >> Michael Foord >> http://www.ironpythoninaction.com/ >> >> >>> PS. If you REALLY want synchronous downloading, just hack on >>> XMLHttpRequest >>> >>> def download(url): >>> request = HtmlPage.Window.CreateInstance("XMLHttpRequest") >>> request.Invoke("open", "GET", url, false) # false means synchronous >>> request.Invoke("send", "") >>> return request.GetProperty("responseText") >>> >>> :) >>> >>> ~js >>> ________________________________________ >>> From: users-boun... at lists.ironpython.com >>> [users-boun... at lists.ironpython.com] On Behalf Of Michael Foord >>> [fuzzy... at voidspace.org.uk] >>> Sent: Monday, May 12, 2008 12:58 AM >>> To: Discussion of IronPython >>> Subject: [IronPython] Silverlight and Catching HttpWebRequest Errors >>> >>> Hello guys, >>> >>> I have a problem with catching network errors raised by HttpWebRequest >>> in Silverlight. (Not necessarily an IronPython specific question - but >>> you guys are so intelligent you are always the first place I turn...) >>> >>> HttpWebRequest uses an async model for fetching resources. If there >>> is a >>> problem (triggered usually by a slow response from the server), then it >>> can happen *after* I have made the request - but before my callback is >>> invoked. This gives me nowhere to catch the exception, as >>> effectively it >>> happens 'inside Silverlight'. I wondered if there was a solution... ? >>> >>> def callback(asyncResult): >>> ... >>> >>> uri = Uri(some_url) >>> req = HttpWebRequest.Create(uri) >>> >>> req.BeginGetResponse(AsyncCallback(callback), object()) >>> >>> The error occurs after BeginGetResponse, but before calback. Any ideas >>> for catching it? >>> >>> Michael Foordhttp://www.ironpythoninaction.com/ >>> >>> _______________________________________________ >>> Users mailing list >>> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> _______________________________________________ >>> Users mailing list >>> Us... at lists.ironpython.comhttp://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >>> >> _______________________________________________ >> 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 exchange.microsoft.com Thu May 15 02:12:22 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 14 May 2008 17:12:22 -0700 Subject: [IronPython] protected set { } In-Reply-To: <482B5B7F.9040809@voidspace.org.uk> References: <482B5B7F.9040809@voidspace.org.uk> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF038EA@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Note while this is the current behavior we actually want to introduce a breaking change in 2.0 that alters this. What we really want to do is not expose all protected members but instead only expose protected members after you've subclassed the type. So Derived().WeakName = 'abc' would still fail, but: class x(Derived): pass x().WeakName = 'abc' would work. One reason is that it makes a little more sense - another reason is we can't actually enable the current behavior in Silverlight at all because it requires full trust. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Wednesday, May 14, 2008 2:37 PM To: Discussion of IronPython Subject: Re: [IronPython] protected set { } Matthew Barnard wrote: > public abstract class Object > { > protected string weakName = string.Empty; > > public string WeakName > { > get { return this.weakName; } > protected set { this.weakName = value; } > } > } > > public class Derived > { > public Derived() > { > this.WeakName = "Hello"; > } > } > > In C#: > Derived obj = new Derived(); > Console.WriteLine(obj.WeakName) > Hello > obj.WeakName = "Fail"; > The property or indexer 'Object.WeakName' cannot be used in this > context because the set accessor is inaccessible > > In IPy: > >>> obj = Derived() > >>> obj.WeakName = 'Succeed' > >>> obj.WeakName > 'Succeed' > > Is this expected behavior? Yes. Michael Foord > > ___________________________ > Matthew Barnard > ------------------------------------------------------------------------ > > _______________________________________________ > 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 sanxiyn at gmail.com Thu May 15 04:27:58 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Thu, 15 May 2008 11:27:58 +0900 Subject: [IronPython] 2 Basic question about IronPython and dyn. langs in general In-Reply-To: <482B0186.9080009@gmail.com> References: <482B0186.9080009@gmail.com> Message-ID: <5b0248170805141927w654712c6re33bcafb34a4ec1@mail.gmail.com> 2008/5/15 Ben Aurel : > 2. I've read about, that it is possible to compile Python Code to msil with > IronPython. Unfortunately I'm not yet at the point where this run on my > machine (macosx). So I do have to ask you: Is such a dll/exe the same as I > would compile it from c#? Does similar language constructs (eg. for loop, > class object creation) the same performance? You can run IronPython on Mac OS X with Mono. -- Seo Sanghyeon From sakesun at boonthavorn.com Thu May 15 10:09:35 2008 From: sakesun at boonthavorn.com (Sakesun Roykiattisak) Date: Thu, 15 May 2008 15:09:35 +0700 Subject: [IronPython] Should DBNull treat as false ? Message-ID: Should DBNull treat as False ? Just a thought. From daftspaniel at gmail.com Thu May 15 10:48:37 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Thu, 15 May 2008 09:48:37 +0100 Subject: [IronPython] Should DBNull treat as false ? In-Reply-To: References: Message-ID: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> DBNull is a type. Appears all .Net types evaluate to False. e.g. from System import DBNull, Char print Char==True print DBNull==True both will print False. On Thu, May 15, 2008 at 9:09 AM, Sakesun Roykiattisak < sakesun at boonthavorn.com> wrote: > > Should DBNull treat as False ? > > Just a thought. > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From sakesun at boonthavorn.com Thu May 15 10:50:20 2008 From: sakesun at boonthavorn.com (Sakesun Roykiattisak) Date: Thu, 15 May 2008 15:50:20 +0700 Subject: [IronPython] Should DBNull treat as false ? In-Reply-To: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> References: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> Message-ID: Actually, I mean DBNull.Value >>> bool(System.DBNull.Value) True On Thu, 15 May 2008 15:48:37 +0700, Davy Mitchell wrote: > DBNull is a type. Appears all .Net types evaluate to False. > e.g. > from System import DBNull, Char > print Char==True > print DBNull==True > > both will print False. > > On Thu, May 15, 2008 at 9:09 AM, Sakesun Roykiattisak < > sakesun at boonthavorn.com> wrote: > >> >> Should DBNull treat as False ? >> >> Just a thought. >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > From sakesun at boonthavorn.com Thu May 15 12:51:28 2008 From: sakesun at boonthavorn.com (Sakesun Roykiattisak) Date: Thu, 15 May 2008 17:51:28 +0700 Subject: [IronPython] Should DBNull treat as false ? In-Reply-To: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> References: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> Message-ID: Some disambitguity is needed here. when eval("a == True") is False does not implied "a" is False. "a" is just not equal to True. All .NET types actually consider "nonzero" which in turn will be treat as True in conditional expression. >>> if System.DBNull: print 'I am something' ... I am something >>> >>> if None: print "This won't show anything" ... >>> What I'm asking here is whether should DBNull.Value be considered as False in conditional expression. On Thu, 15 May 2008 15:48:37 +0700, Davy Mitchell wrote: > DBNull is a type. Appears all .Net types evaluate to False. > e.g. > from System import DBNull, Char > print Char==True > print DBNull==True > > both will print False. > > On Thu, May 15, 2008 at 9:09 AM, Sakesun Roykiattisak < > sakesun at boonthavorn.com> wrote: > >> >> Should DBNull treat as False ? >> >> Just a thought. >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > From daftspaniel at gmail.com Thu May 15 20:24:14 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Thu, 15 May 2008 19:24:14 +0100 Subject: [IronPython] Slightly OT: VBX Release? In-Reply-To: <5283CA0A4168DF4FBBD71AE9ECA5A328458056898B@NA-EXMSG-C116.redmond.corp.microsoft.com> References: <20253b0c0805140628h708d2aaw3ccc5ccf020c1a64@mail.gmail.com> <5283CA0A4168DF4FBBD71AE9ECA5A328458056898B@NA-EXMSG-C116.redmond.corp.microsoft.com> Message-ID: <20253b0c0805151124o31bddf4xce9931580bee2e50@mail.gmail.com> Thanks Jimmy - that's interesting to know. Guess it builds more of a case for IronPython :-) !! Davy On Wed, May 14, 2008 at 6:27 PM, Jimmy Schementi < Jimmy.Schementi at microsoft.com> wrote: > VBx was an implementation of Visual Basic on the DLR. It was first meant > to be in Silverlight, but the VB team decided they'd rather put VB.NET in > Silverlight rather than build a new implementation up from scratch. So, VBx > is on hold. > > > > ~js > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Davy Mitchell > *Sent:* Wednesday, May 14, 2008 6:28 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] Slightly OT: VBX Release? > > > > Hi List, > > Sorry if this is OT slightly but Jim showing off a VBX console (CLR VB I > guess) in a screen cast got me interested. > > Is there a public release of this or is it coming soon? > > Thanks, > Davy > > -- > Davy Mitchell > Blog - http://www.latedecember.co.uk/sites/personal/davy/ > Twitter - http://twitter.com/daftspaniel > Skype - daftspaniel http://needgod.com > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From daftspaniel at gmail.com Thu May 15 20:41:49 2008 From: daftspaniel at gmail.com (Davy Mitchell) Date: Thu, 15 May 2008 19:41:49 +0100 Subject: [IronPython] Should DBNull treat as false ? In-Reply-To: References: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> Message-ID: <20253b0c0805151141i5c3283bbm8696f5a32b06008f@mail.gmail.com> Hi there, I *think* this may be related to the Closed issue http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=14605 Dino stated at the time (with the last point being relevant here): "....NET conventions say that enum's should generally have a zero value (FxCop CA1008 :)). Because of that we can safely define __nonzero__ on enums and have that return true/false based upon if the value is zero/non-zero. Otherwise Python says all expressions otherwise defined return true," So I think the behaviour is correct though slightly counter intuitive in the case of Null. Cheers, Davy On Thu, May 15, 2008 at 11:51 AM, Sakesun Roykiattisak < sakesun at boonthavorn.com> wrote: > > Some disambitguity is needed here. > > when eval("a == True") is False does not implied "a" is False. > "a" is just not equal to True. > > All .NET types actually consider "nonzero" which in turn will be treat as > True in conditional expression. > > > if System.DBNull: print 'I am something' >>>> >>> ... > I am something > >> >>>> > > if None: print "This won't show anything" >>>> >>> ... > >> >>>> > What I'm asking here is whether should DBNull.Value be considered as False > in conditional expression. > > > > On Thu, 15 May 2008 15:48:37 +0700, Davy Mitchell > wrote: > > DBNull is a type. Appears all .Net types evaluate to False. >> e.g. >> from System import DBNull, Char >> print Char==True >> print DBNull==True >> >> both will print False. >> >> On Thu, May 15, 2008 at 9:09 AM, Sakesun Roykiattisak < >> sakesun at boonthavorn.com> wrote: >> >> >>> Should DBNull treat as False ? >>> >>> Just a thought. >>> _______________________________________________ >>> 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 > -- Davy Mitchell Blog - http://www.latedecember.co.uk/sites/personal/davy/ Twitter - http://twitter.com/daftspaniel Skype - daftspaniel http://needgod.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Thu May 15 23:14:44 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 15 May 2008 22:14:44 +0100 Subject: [IronPython] [Fwd: [Ironruby-core] ironruby in action is available in EAP] Message-ID: <482CA7C4.4050800@voidspace.org.uk> I thought this might be of interest... -------- Original Message -------- Subject: [Ironruby-core] ironruby in action is available in EAP Date: Fri, 16 May 2008 08:56:25 +1200 From: Ivan Porto Carrero Reply-To: ironruby-core at rubyforge.org To: ironruby-core at rubyforge.org Hi My book for manning went into EAP. http://manning.com/carrero Cheers Ivan _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core From ivan at flanders.co.nz Thu May 15 23:17:11 2008 From: ivan at flanders.co.nz (Ivan Porto Carrero) Date: Fri, 16 May 2008 09:17:11 +1200 Subject: [IronPython] [Fwd: [Ironruby-core] ironruby in action is available in EAP] In-Reply-To: <482CA7C4.4050800@voidspace.org.uk> References: <482CA7C4.4050800@voidspace.org.uk> Message-ID: thanks I was getting to that.. still having breakfast :) On Fri, May 16, 2008 at 9:14 AM, Michael Foord wrote: > I thought this might be of interest... > > -------- Original Message -------- > Subject: [Ironruby-core] ironruby in action is available in EAP > Date: Fri, 16 May 2008 08:56:25 +1200 > From: Ivan Porto Carrero > Reply-To: ironruby-core at rubyforge.org > To: ironruby-core at rubyforge.org > > > > Hi > > My book for manning went into EAP. > > http://manning.com/carrero > > Cheers > Ivan > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > _______________________________________________ > 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 sakesun at boonthavorn.com Fri May 16 06:18:16 2008 From: sakesun at boonthavorn.com (Sakesun Roykiattisak) Date: Fri, 16 May 2008 11:18:16 +0700 Subject: [IronPython] print is not thread safe ? Message-ID: Hi, Just found that the "print" statement is not thread-safe (IP 1.1.1). I variably get various "ValueError" like "Count cannot be less than zero. Parameter name: count" in my multi-thread app. The problem can be suppressed by replace "print" with "System.Console.WriteLine" Perhaps I should try proper logging module. Regards From fuzzyman at voidspace.org.uk Fri May 16 10:06:58 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 16 May 2008 09:06:58 +0100 Subject: [IronPython] print is not thread safe ? In-Reply-To: References: Message-ID: <482D40A2.4000609@voidspace.org.uk> Sakesun Roykiattisak wrote: > > Hi, > > Just found that the "print" statement is not thread-safe (IP > 1.1.1). I variably > get various "ValueError" like "Count cannot be less than zero. > Parameter name: count" > in my multi-thread app. > FWIW we've sometimes seen this, although it is hard to reproduce reliably. 'print' really ought to be thread safe... Michael Foord http://www.ironpythoninaction.com/ > The problem can be suppressed by replace "print" with > "System.Console.WriteLine" > > Perhaps I should try proper logging module. > > Regards > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Fri May 16 17:22:21 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 16 May 2008 08:22:21 -0700 Subject: [IronPython] print is not thread safe ? In-Reply-To: <482D40A2.4000609@voidspace.org.uk> References: <482D40A2.4000609@voidspace.org.uk> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF03C81@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I think this really means that file is not thread safe. I agree that it should be thread safe, I've opened CodePlex bug 16623 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16623) to track the issue. Thanks for the report! -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Friday, May 16, 2008 1:07 AM To: Discussion of IronPython Subject: Re: [IronPython] print is not thread safe ? Sakesun Roykiattisak wrote: > > Hi, > > Just found that the "print" statement is not thread-safe (IP > 1.1.1). I variably > get various "ValueError" like "Count cannot be less than zero. > Parameter name: count" > in my multi-thread app. > FWIW we've sometimes seen this, although it is hard to reproduce reliably. 'print' really ought to be thread safe... Michael Foord http://www.ironpythoninaction.com/ > The problem can be suppressed by replace "print" with > "System.Console.WriteLine" > > Perhaps I should try proper logging module. > > Regards > _______________________________________________ > 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 ben2004uk at googlemail.com Sat May 17 02:27:35 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Sat, 17 May 2008 01:27:35 +0100 Subject: [IronPython] Loading IronPython assemblies dynamatically Message-ID: Hello, I have an interesting problem and I was wondering if you would be able to help. I am trying to load the IronPython assemblies dynamically (IronPython.dll and IronPython.Modules.dll), and what I am doing is this: Assembly.LoadFile(Path.Combine(Settings.BinDirectory, assembly)); I'm then creating the Runtime and the Engine after the assemblies have loaded. But when I try runtime.GetEngine I get the following exception: ----> System.IO.FileNotFoundException : Could not load file or assembly 'IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.Scripting.Runtime.ScriptDomainManager.LanguageRegistration.LoadLanguageContext(ScriptDomainManager manager) at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageContext(Type type) at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngine(Type languageContextType) Ok, so I hooked up to the Assembly Resolve event, and when I get to get the engine it fires off. Assembly name passed into the AssemblyResolve event is: IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35 However, the assembly I am loading is this: IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Same with Modules: IronPython.Modules, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35 After I reload the assembly (using the same Assembly.Load) everything works fine! Why is this? I would prefer not to have to load my assemblies twice. These the assemblies I downloaded from CodePlex. Thanks Ben From Marty.Nelson at symyx.com Sat May 17 02:44:29 2008 From: Marty.Nelson at symyx.com (Marty Nelson) Date: Fri, 16 May 2008 17:44:29 -0700 Subject: [IronPython] Loading IronPython assemblies dynamatically In-Reply-To: References: Message-ID: <515335F32AA04440B3DE6FEA1993E9AD03269772@srv-be-101.Symyx-IC.symyx.com> Probably has to do with binding context. This means that assemblies loaded via LoadFile, LoadFrom and Load don't necessarily "see" assemblies loaded in other contexts. See http://blogs.msdn.com/suzcook/archive/2003/05/29/57143.aspx for more info. You also might try just changing to LoadFrom, LoadFile doesn't use Fusion at all (see http://blogs.msdn.com/suzcook/archive/2003/09/19/loadfile-vs-loadfrom.as px). We actually include the following code on AssemblyResolve to bridge contexts: foreach (Assembly loadedAssembly in AppDomain.CurrentDomain.GetAssemblies()) { if (loadedAssembly.FullName == assemblyFullName) { return loadedAssembly; } } -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall Sent: Friday, May 16, 2008 5:28 PM To: Discussion of IronPython Subject: [IronPython] Loading IronPython assemblies dynamatically Hello, I have an interesting problem and I was wondering if you would be able to help. I am trying to load the IronPython assemblies dynamically (IronPython.dll and IronPython.Modules.dll), and what I am doing is this: Assembly.LoadFile(Path.Combine(Settings.BinDirectory, assembly)); I'm then creating the Runtime and the Engine after the assemblies have loaded. But when I try runtime.GetEngine I get the following exception: ----> System.IO.FileNotFoundException : Could not load file or assembly 'IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. at Microsoft.Scripting.Runtime.ScriptDomainManager.LanguageRegistration.Loa dLanguageContext(ScriptDomainManager manager) at Microsoft.Scripting.Runtime.ScriptDomainManager.GetLanguageContext(Type type) at Microsoft.Scripting.Hosting.ScriptRuntime.GetEngine(Type languageContextType) Ok, so I hooked up to the Assembly Resolve event, and when I get to get the engine it fires off. Assembly name passed into the AssemblyResolve event is: IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35 However, the assembly I am loading is this: IronPython, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Same with Modules: IronPython.Modules, Version=2.0.0.2000, Culture=neutral, PublicKeyToken=31bf3856ad364e35 After I reload the assembly (using the same Assembly.Load) everything works fine! Why is this? I would prefer not to have to load my assemblies twice. These the assemblies I downloaded from CodePlex. Thanks Ben _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com ======= 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 ben2004uk at googlemail.com Sat May 17 03:09:05 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Sat, 17 May 2008 02:09:05 +0100 Subject: [IronPython] Custom Host - Import CLR fails Message-ID: Hi, After getting Python code to work successfully, I decided to quickly import the CLR and access some .Net objects. At this point my code blew up. The code I tried to execute was "import clr". Exception is this: Unhandled Exception System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Scripting.Utils.SlowReflectedCaller.InvokeInstance(Object instance, Object[] args) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext context, CallSite`1 site, Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update5[T0,T1,T2,T3,T4,TRet](CallSite site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level) at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext context, String fullName, Int32 level) at Initialize##1(Closure , CodeContext ) at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope) at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Execute(Scope scope) at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code) at MyApp.Engine.ScriptExecutor.ExecuteStatement(String code) After a bit of search, I found that you don't load mscorlib for us. I have tried 3 different ways to import the assemblies everyone says I need to load: ScriptRuntime runtime = ScriptRuntime.Create(); ScriptEngine engine = runtime.GetEngine(); LanguageContext Language = HostingHelpers.GetLanguageContext(engine); Language.DomainManager.LoadAssembly(typeof(string).Assembly); Language.DomainManager.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); runtime.LoadAssembly(typeof(string).Assembly); runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); Assembly assem = Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); engine.Runtime.LoadAssembly(assem); To execute the code, I do this: ScriptScope source = Engine.CreateScope(); source.Execute(code); However nothing, I still get the exception. Any suggestions on where I am going wrong? Thanks Ben Hall Blog.BenHall.me.uk From dinov at exchange.microsoft.com Sat May 17 04:01:45 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 16 May 2008 19:01:45 -0700 Subject: [IronPython] Custom Host - Import CLR fails In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF03EB7@DF-GRTDANE-MSG.exchange.corp.microsoft.com> This works for me in IronPython 2.0B2: using System; using System.Reflection; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; class Test { public static void Main(string[]args) { ScriptRuntime runtime = ScriptRuntime.Create(); ScriptEngine engine = runtime.GetEngine("py"); runtime.LoadAssembly(typeof(string).Assembly); runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); Assembly assem = Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); engine.Runtime.LoadAssembly(assem); //ScriptSource code = engine.CreateScriptSourceFromString("import clr\n", SourceCodeKind.File); ScriptScope source = engine.CreateScope(); source.Execute("import clr\nprint clr\nimport System\nSystem.Console.WriteLine('hello world')\n"); } } It prints: hello world Do you still get an exception with this code? I also realize you were trying to load them dynamically on another thread but it might be worth pointing out this doesn't actually end up w/ any dependencies on IronPython.dll or IronPython.Modules.dll as written. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall Sent: Friday, May 16, 2008 6:09 PM To: Discussion of IronPython Subject: [IronPython] Custom Host - Import CLR fails Hi, After getting Python code to work successfully, I decided to quickly import the CLR and access some .Net objects. At this point my code blew up. The code I tried to execute was "import clr". Exception is this: Unhandled Exception System.NullReferenceException: Object reference not set to an instance of an object. at Microsoft.Scripting.Utils.SlowReflectedCaller.InvokeInstance(Object instance, Object[] args) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext context, CallSite`1 site, Object[] args) at Microsoft.Scripting.Actions.UpdateDelegates.Update5[T0,T1,T2,T3,T4,TRet](CallSite site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) at IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level) at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext context, String fullName, Int32 level) at Initialize##1(Closure , CodeContext ) at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope) at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Execute(Scope scope) at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code) at MyApp.Engine.ScriptExecutor.ExecuteStatement(String code) After a bit of search, I found that you don't load mscorlib for us. I have tried 3 different ways to import the assemblies everyone says I need to load: ScriptRuntime runtime = ScriptRuntime.Create(); ScriptEngine engine = runtime.GetEngine(); LanguageContext Language = HostingHelpers.GetLanguageContext(engine); Language.DomainManager.LoadAssembly(typeof(string).Assembly); Language.DomainManager.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); runtime.LoadAssembly(typeof(string).Assembly); runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); Assembly assem = Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); engine.Runtime.LoadAssembly(assem); To execute the code, I do this: ScriptScope source = Engine.CreateScope(); source.Execute(code); However nothing, I still get the exception. Any suggestions on where I am going wrong? Thanks Ben Hall Blog.BenHall.me.uk _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From ben2004uk at googlemail.com Sat May 17 16:51:18 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Sat, 17 May 2008 15:51:18 +0100 Subject: [IronPython] Custom Host - Import CLR fails In-Reply-To: <7AD436E4270DD54A94238001769C2227012BBFF03EB7@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BBFF03EB7@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Hi Dino, Thanks for your reply. Spent all day trying to debug the problem. I have the code working in a POC, I have it working in my UI but my unit tests are failing. The exception being raised is (different to before): Unhandled Exception System.TypeInitializationException: The type initializer for 'IronPython.Runtime.Importer' threw an exception. ---> System.InvalidProgramException: Common Language Runtime detected an invalid program. at Microsoft.Scripting.Actions.CallSiteFactory.CreateSimpleCallSite[T0,T1,T2,T3,T4,T5,R](ActionBinder binder) at IronPython.Runtime.Importer.MakeImportSite() at IronPython.Runtime.Importer..cctor() --- End of inner exception stack trace --- at IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level) at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext context, String fullName, Int32 level) at Initialize##1(Closure , CodeContext ) at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope) at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Execute(Scope scope) at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code) Information wrote to Debug window: 'ProcessInvocation.exe' (Managed): Loaded 'Snippets' 'ProcessInvocation.exe' (Managed): Loaded 'Snippets' 'ProcessInvocation.exe' (Managed): Loaded 'Anonymously Hosted DynamicMethods Assembly' A first chance exception of type 'System.TypeInitializationException' occurred in Unknown Module. Any tips on how I can get to the bottom of this? Thanks Ben On Sat, May 17, 2008 at 3:01 AM, Dino Viehland wrote: > This works for me in IronPython 2.0B2: > > using System; > using System.Reflection; > > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > class Test { > public static void Main(string[]args) { > ScriptRuntime runtime = ScriptRuntime.Create(); > ScriptEngine engine = runtime.GetEngine("py"); > > runtime.LoadAssembly(typeof(string).Assembly); > runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > > Assembly assem = Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); > engine.Runtime.LoadAssembly(assem); > > //ScriptSource code = engine.CreateScriptSourceFromString("import clr\n", SourceCodeKind.File); > ScriptScope source = engine.CreateScope(); > source.Execute("import clr\nprint clr\nimport System\nSystem.Console.WriteLine('hello world')\n"); > > } > } > > It prints: > > > hello world > > Do you still get an exception with this code? I also realize you were trying to load them dynamically on another thread but it might be worth pointing out this doesn't actually end up w/ any dependencies on IronPython.dll or IronPython.Modules.dll as written. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall > Sent: Friday, May 16, 2008 6:09 PM > To: Discussion of IronPython > Subject: [IronPython] Custom Host - Import CLR fails > > Hi, > > After getting Python code to work successfully, I decided to quickly > import the CLR and access some .Net objects. At this point my code > blew up. > The code I tried to execute was "import clr". > > Exception is this: > > Unhandled Exception System.NullReferenceException: Object reference > not set to an instance of an object. > at Microsoft.Scripting.Utils.SlowReflectedCaller.InvokeInstance(Object > instance, Object[] args) > at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext > context, CallSite`1 site, Object[] args) > at Microsoft.Scripting.Actions.UpdateDelegates.Update5[T0,T1,T2,T3,T4,TRet](CallSite > site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 > arg4) > at Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext > context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) > at IronPython.Runtime.Importer.Import(CodeContext context, String > fullName, PythonTuple from, Int32 level) > at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext > context, String fullName, Int32 level) > at Initialize##1(Closure , CodeContext ) > at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean > tryEvaluate) > at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean tryEvaluate) > at Microsoft.Scripting.ScriptCode.Run(Scope scope) > at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) > at Microsoft.Scripting.SourceUnit.Execute(Scope scope) > at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code) > at MyApp.Engine.ScriptExecutor.ExecuteStatement(String code) > > After a bit of search, I found that you don't load mscorlib for us. > > I have tried 3 different ways to import the assemblies everyone says I > need to load: > > ScriptRuntime runtime = ScriptRuntime.Create(); > ScriptEngine engine = runtime.GetEngine(); > > LanguageContext Language = > HostingHelpers.GetLanguageContext(engine); > Language.DomainManager.LoadAssembly(typeof(string).Assembly); > Language.DomainManager.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > > runtime.LoadAssembly(typeof(string).Assembly); > runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > > Assembly assem = > Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); > engine.Runtime.LoadAssembly(assem); > > To execute the code, I do this: > ScriptScope source = Engine.CreateScope(); > source.Execute(code); > > However nothing, I still get the exception. > > Any suggestions on where I am going wrong? > > Thanks > > Ben Hall > Blog.BenHall.me.uk > _______________________________________________ > 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 exchange.microsoft.com Sat May 17 19:51:24 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Sat, 17 May 2008 10:51:24 -0700 Subject: [IronPython] Custom Host - Import CLR fails In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BBFF03EB7@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF03EE1@DF-GRTDANE-MSG.exchange.corp.microsoft.com> This indicates we're generating invalid IL. The best way to debug this is to enable the SaveAssemblies option which will cause us to save the code to disk. Programmatically you can do this via Snippets.Shared.SaveSnippets = true. When the process is finished you should then call Snippets.Shared.Dump() which will write the assemblies to disk. From there you can run peverify on the assemblies and report back what the invalid IL is and what the verification error is. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall Sent: Saturday, May 17, 2008 7:51 AM To: Discussion of IronPython Subject: Re: [IronPython] Custom Host - Import CLR fails Hi Dino, Thanks for your reply. Spent all day trying to debug the problem. I have the code working in a POC, I have it working in my UI but my unit tests are failing. The exception being raised is (different to before): Unhandled Exception System.TypeInitializationException: The type initializer for 'IronPython.Runtime.Importer' threw an exception. ---> System.InvalidProgramException: Common Language Runtime detected an invalid program. at Microsoft.Scripting.Actions.CallSiteFactory.CreateSimpleCallSite[T0,T1,T2,T3,T4,T5,R](ActionBinder binder) at IronPython.Runtime.Importer.MakeImportSite() at IronPython.Runtime.Importer..cctor() --- End of inner exception stack trace --- at IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level) at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext context, String fullName, Int32 level) at Initialize##1(Closure , CodeContext ) at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean tryEvaluate) at Microsoft.Scripting.ScriptCode.Run(Scope scope) at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) at Microsoft.Scripting.SourceUnit.Execute(Scope scope) at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code) Information wrote to Debug window: 'ProcessInvocation.exe' (Managed): Loaded 'Snippets' 'ProcessInvocation.exe' (Managed): Loaded 'Snippets' 'ProcessInvocation.exe' (Managed): Loaded 'Anonymously Hosted DynamicMethods Assembly' A first chance exception of type 'System.TypeInitializationException' occurred in Unknown Module. Any tips on how I can get to the bottom of this? Thanks Ben On Sat, May 17, 2008 at 3:01 AM, Dino Viehland wrote: > This works for me in IronPython 2.0B2: > > using System; > using System.Reflection; > > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > class Test { > public static void Main(string[]args) { > ScriptRuntime runtime = ScriptRuntime.Create(); > ScriptEngine engine = runtime.GetEngine("py"); > > runtime.LoadAssembly(typeof(string).Assembly); > runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > > Assembly assem = Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); > engine.Runtime.LoadAssembly(assem); > > //ScriptSource code = engine.CreateScriptSourceFromString("import clr\n", SourceCodeKind.File); > ScriptScope source = engine.CreateScope(); > source.Execute("import clr\nprint clr\nimport System\nSystem.Console.WriteLine('hello world')\n"); > > } > } > > It prints: > > > hello world > > Do you still get an exception with this code? I also realize you were trying to load them dynamically on another thread but it might be worth pointing out this doesn't actually end up w/ any dependencies on IronPython.dll or IronPython.Modules.dll as written. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall > Sent: Friday, May 16, 2008 6:09 PM > To: Discussion of IronPython > Subject: [IronPython] Custom Host - Import CLR fails > > Hi, > > After getting Python code to work successfully, I decided to quickly > import the CLR and access some .Net objects. At this point my code > blew up. > The code I tried to execute was "import clr". > > Exception is this: > > Unhandled Exception System.NullReferenceException: Object reference > not set to an instance of an object. > at Microsoft.Scripting.Utils.SlowReflectedCaller.InvokeInstance(Object > instance, Object[] args) > at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext > context, CallSite`1 site, Object[] args) > at Microsoft.Scripting.Actions.UpdateDelegates.Update5[T0,T1,T2,T3,T4,TRet](CallSite > site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 > arg4) > at Microsoft.Scripting.Actions.DynamicSite`6.Invoke(CodeContext > context, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4) > at IronPython.Runtime.Importer.Import(CodeContext context, String > fullName, PythonTuple from, Int32 level) > at IronPython.Runtime.Operations.PythonOps.ImportTop(CodeContext > context, String fullName, Int32 level) > at Initialize##1(Closure , CodeContext ) > at Microsoft.Scripting.ScriptCode.Run(CodeContext context, Boolean > tryEvaluate) > at Microsoft.Scripting.ScriptCode.Run(Scope scope, Boolean tryEvaluate) > at Microsoft.Scripting.ScriptCode.Run(Scope scope) > at Microsoft.Scripting.SourceUnit.Execute(Scope scope, ErrorSink errorSink) > at Microsoft.Scripting.SourceUnit.Execute(Scope scope) > at Microsoft.Scripting.Hosting.ScriptScope.Execute(String code) > at MyApp.Engine.ScriptExecutor.ExecuteStatement(String code) > > After a bit of search, I found that you don't load mscorlib for us. > > I have tried 3 different ways to import the assemblies everyone says I > need to load: > > ScriptRuntime runtime = ScriptRuntime.Create(); > ScriptEngine engine = runtime.GetEngine(); > > LanguageContext Language = > HostingHelpers.GetLanguageContext(engine); > Language.DomainManager.LoadAssembly(typeof(string).Assembly); > Language.DomainManager.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > > runtime.LoadAssembly(typeof(string).Assembly); > runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly); > > Assembly assem = > Assembly.GetAssembly(Type.GetType("System.Text.StringBuilder")); > engine.Runtime.LoadAssembly(assem); > > To execute the code, I do this: > ScriptScope source = Engine.CreateScope(); > source.Execute(code); > > However nothing, I still get the exception. > > Any suggestions on where I am going wrong? > > Thanks > > Ben Hall > Blog.BenHall.me.uk > _______________________________________________ > 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 Sat May 17 20:46:33 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 17 May 2008 19:46:33 +0100 Subject: [IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' Message-ID: <482F2809.5040600@voidspace.org.uk> This is cool. I have a checkbox in my silverlight UI. I have a code path that does: if self.remember_me.IsChecked: PutStored(username, password) The *second* time through this code path it blows up with the exception below. I can fix it by changing the test to: if self.remember_me.IsChecked == True: PutStored(username, password) Which works fine, but I thought you might be interested. :-) Full traceback below... ArgumentException: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' ArgumentException at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg, Label ifFalse) at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext context) at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext context) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext callerContext, Object site, T& target, RuleSet`1& rules, StandardRule`1 rule) at Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext callerContext, Object[] args, Boolean execute, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext context, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules) at Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext context, T0 arg0) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2 site, CodeContext context, T0 arg0) at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, T0 arg0) at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object ) at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, T0 arg0) at S$3.onLogin$18(Closure , Object self, Object sender, Object event) at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object arg1, Object arg2, Object arg3) at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object instance, Object[] args) at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method, Object instance, Object[] parameters) at Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context, Expression expression) at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object site, CodeContext context, Object[] args) at Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext callerContext, Object[] args, Boolean execute, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext context, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules) at Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5 site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , Object , Object ) at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2) at System.Void(Object, RoutedEventArgs), using PythonBinder##183(Closure , Object , RoutedEventArgs ) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object sender, MouseButtonEventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) ? Hide Debugging Output Michael Foord http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Sun May 18 13:18:36 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 18 May 2008 12:18:36 +0100 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files Message-ID: <4830108C.6010807@voidspace.org.uk> Hello guys, I've been following the instructions on Jimmy's blog entry about packaging Silverlight applications: http://blog.jimmy.schementi.com/2008/05/story-of-ruby-and-python-in-silverlight.html I'm trying to get the application assemblies stored outside the 'xap' file, by using the urlprefix configuration in 'Chiron.exe.config'. As described in Jimmy's blog, I add the following line to the 'appSettings' element of the config file: This actually causes Chiron to generate the following in the manifest file: Which seems wrong. :-) I guess it is just a bug in Chiron... (or I am doing something wrong.) Michael Foord http://www.ironpythoninaction.com/ From cjac at colliertech.org Sun May 18 20:13:57 2008 From: cjac at colliertech.org (C.J. Adams-Collier) Date: Sun, 18 May 2008 18:13:57 +0000 Subject: [IronPython] [Ironruby-core] Code Review: RubyLibsAndYaml In-Reply-To: References: Message-ID: <1211134437.4502.34.camel@norseth> Hey folks, Does there exist a formal code review process for the Iron* languages and/or the DLR? Have you considered using a tool to ease gathering of review feedback? http://www.review-board.org/ - VMWare, Christian Hammond http://reviews.review-board.org/dashboard/ svn checkout http://reviewboard.googlecode.com/svn/trunk/reviewboard http://codereview.appspot.com/ - Google, Guido van Rossum Cheers, C.J. On Sat, 2008-05-17 at 21:47 -0700, Tomas Matousek wrote: > tfpt review /shelveset:RubyLibsAndYaml;REDMOND\tomat > > Adjusts class-initializer generator to enable generating initializers for multiple libraries within a single assembly. > Also enables extending existing Ruby modules and classes that are defined in C# libraries (previously only CLR classes could have been extended). For example, the following class adds additional methods on Kernel module: > > [RubyModule(Extends = typeof(Kernel))] > public static class MyKernelOps { > [RubyMethod("foo")] > public static void Foo() { ... } > } > > The type specified in Extends parameter is the C# class defining the module/class. > > Enables to group C# classes and modules into Ruby libraries (e.g. thread, socket, openssl, yaml, etc.). Each library is identified by a root namespace. All Ruby classes and modules of the assembly defined within the namespace are considered parts of the library. The shelveset updates namespaces in IronRuby.Libraries.dll to group classes by library: > > Ruby.Builtins > Ruby.StandardLibrary.Threading > Ruby.StandardLibrary.Sockets > Ruby.StandardLibrary.OpenSsl > Ruby.StandardLibrary.Digest > Ruby.StandardLibrary.Zlib > > The list of namespaces that define libraries within an assembly is passed to the generator: > > ClassInitGenerator IronRuby.Libraries.dll /libraries:Ruby.Builtins;Ruby.StandardLibrary.Threading;Ruby.StandardLibrary.Sockets;Ruby.StandardLibrary.OpenSsl;Ruby.StandardLibrary.Digest;Ruby.StandardLibrary.Zlib /out:Initializers.Generated.cs > > The mapping from Ruby library name to the assembly and namespace is established via .rb files: > > thread.rb: > load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.Threading' > > openssl.rb: > load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.OpenSsl' > > etc. > > (Kernel#load_assembly now takes an optional second argument identifying the library to load by its root namespace). > > The files are included in the solution and their build action is set to "copy if new", which means they are copied to the output directory during the build. ir.exe includes the directory it is located in into the load paths list ($:), so the .rb files copied there are found by the standard Ruby require/load mechanism. > > Tomas > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From sanxiyn at gmail.com Mon May 19 06:16:40 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Mon, 19 May 2008 13:16:40 +0900 Subject: [IronPython] Regular expression option using (?...) syntax is not applied Message-ID: <5b0248170805182116s5a0f54fcne4db4a7e0327645e@mail.gmail.com> IronPython 2.0 Beta 2. >>> import re >>> re.compile(r'^bar', re.M).search('foo\nbar') is not None True >>> re.compile(r'^bar(?m)').search('foo\nbar') is not None False Two expressions should produce the same result. This blocks Jinja, a Python template engine. -- Seo Sanghyeon From ronnie.maor at gmail.com Mon May 19 10:47:07 2008 From: ronnie.maor at gmail.com (Ronnie Maor) Date: Mon, 19 May 2008 11:47:07 +0300 Subject: [IronPython] precision problem with Int64 Message-ID: <2fd6b9d0805190147n28f7ade3pa5d2bf76819981ca@mail.gmail.com> Hi all, Is the following a known bug? (IPy 1.1.1) >>> import System >>> n = 8591464408876390743 >>> x = System.Int64(n) >>> x 8591464408876390400L >>> y = System.Int64(str(n)) >>> y 8591464408876390743L >>> x == y False n is positive and contained in 63 bits, so there shouldn't even be signed/unsigned issues. ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From brian.curtin at gmail.com Mon May 19 15:36:41 2008 From: brian.curtin at gmail.com (curtin@acm.org) Date: Mon, 19 May 2008 08:36:41 -0500 Subject: [IronPython] precision problem with Int64 In-Reply-To: <2fd6b9d0805190147n28f7ade3pa5d2bf76819981ca@mail.gmail.com> References: <2fd6b9d0805190147n28f7ade3pa5d2bf76819981ca@mail.gmail.com> Message-ID: FWIW, using System.Convert.ToInt64(...) instead of System.Int64(...) works. IronPython 1.1.1 (1.1.1) on .NET 2.0.50727.1433 Copyright (c) Microsoft Corporation. All rights reserved. >>> import System >>> n = 8591464408876390743 >>> x = System.Convert.ToInt64(n) >>> x 8591464408876390743L >>> y = System.Convert.ToInt64(str(n)) >>> y 8591464408876390743L >>> x == y True On Mon, May 19, 2008 at 3:47 AM, Ronnie Maor wrote: > Hi all, > > Is the following a known bug? (IPy 1.1.1) > > >>> import System > >>> n = 8591464408876390743 > >>> x = System.Int64(n) > >>> x > 8591464408876390400L > >>> y = System.Int64(str(n)) > >>> y > 8591464408876390743L > >>> x == y > False > > n is positive and contained in 63 bits, so there shouldn't even be > signed/unsigned issues. > > ? > > > > _______________________________________________ > 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 May 19 15:48:58 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 19 May 2008 14:48:58 +0100 Subject: [IronPython] [Fwd: Ironclad v0.3] Message-ID: <4831854A.3030608@voidspace.org.uk> I've also written a high level of overview of the new "object lifecycle management" in Ironclad at: http://www.voidspace.org.uk/python/weblog/arch_d7_2008_05_17.shtml#e977 -------- Original Message -------- Subject: Ironclad v0.3 Date: Mon, 19 May 2008 03:54:06 -0700 (PDT) From: william at resolversystems.com Reply-To: c-extensions-for-ironpython at googlegroups.com To: C Extensions for IronPython Hi all I'm delighted to announce the release of Ironclad v0.3. There have been no additions to the CPython API, so you can't do anything more with it than you could with v0.2, but we have solved the thorny problem of object lifetimes and consider this to be a significant enough improvement to warrant a point release. For the next release, we hope to implement properties and members on CPython types, and we also hope to fill in a few of the obvious (and easy-to-fix) gaps in the API. Best Regards William --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "C Extensions for IronPython" group. To post to this group, send email to c-extensions-for-ironpython at googlegroups.com To unsubscribe from this group, send email to c-extensions-for-ironpython-unsubscribe at googlegroups.com For more options, visit this group at http://groups.google.com/group/c-extensions-for-ironpython?hl=en -~----------~----~----~----~------~----~------~--~--- From dinov at exchange.microsoft.com Mon May 19 17:18:13 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 19 May 2008 08:18:13 -0700 Subject: [IronPython] Regular expression option using (?...) syntax is not applied In-Reply-To: <5b0248170805182116s5a0f54fcne4db4a7e0327645e@mail.gmail.com> References: <5b0248170805182116s5a0f54fcne4db4a7e0327645e@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF03F3C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Thanks for the bug report Seo! I've opened issue 16657 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16657) to track the bug. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Sunday, May 18, 2008 9:17 PM To: Discussion of IronPython Subject: [IronPython] Regular expression option using (?...) syntax is not applied IronPython 2.0 Beta 2. >>> import re >>> re.compile(r'^bar', re.M).search('foo\nbar') is not None True >>> re.compile(r'^bar(?m)').search('foo\nbar') is not None False Two expressions should produce the same result. This blocks Jinja, a Python template engine. -- Seo Sanghyeon _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Mon May 19 17:23:33 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Mon, 19 May 2008 08:23:33 -0700 Subject: [IronPython] precision problem with Int64 In-Reply-To: <2fd6b9d0805190147n28f7ade3pa5d2bf76819981ca@mail.gmail.com> References: <2fd6b9d0805190147n28f7ade3pa5d2bf76819981ca@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF03F3D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I don't think I've seen this reported anywhere. The good news is it does do the right thing in 2.0 but I've opened a 1.1.2 bug for the issue (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16658). That means we'll consider fixing it for 1.1.2 but I have no clue how simple the fix will be - mainly because I have no clue how it got fixed in 2.0 :). Thanks for the report. From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ronnie Maor Sent: Monday, May 19, 2008 1:47 AM To: Discussion of IronPython Subject: [IronPython] precision problem with Int64 Hi all, Is the following a known bug? (IPy 1.1.1) >>> import System >>> n = 8591464408876390743 >>> x = System.Int64(n) >>> x 8591464408876390400L >>> y = System.Int64(str(n)) >>> y 8591464408876390743L >>> x == y False n is positive and contained in 63 bits, so there shouldn't even be signed/unsigned issues. ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From cjac at colliertech.org Mon May 19 18:12:01 2008 From: cjac at colliertech.org (C.J. Adams-Collier) Date: Mon, 19 May 2008 09:12:01 -0700 Subject: [IronPython] [Ironruby-core] Code Review: RubyLibsAndYaml In-Reply-To: <1211134437.4502.34.camel@norseth> References: <1211134437.4502.34.camel@norseth> Message-ID: <1211213521.23961.136.camel@cjac.intra.cardomain.com> I couldn't find the source for Rietveld before sending the first mail. Guido was kind enough to point me to it, though: http://code.google.com/p/rietveld/source Cheers, C.J. On Sun, 2008-05-18 at 18:13 +0000, C.J. Adams-Collier wrote: > Hey folks, > > Does there exist a formal code review process for the Iron* languages > and/or the DLR? Have you considered using a tool to ease gathering of > review feedback? > > http://www.review-board.org/ - VMWare, Christian Hammond > http://reviews.review-board.org/dashboard/ > > svn checkout http://reviewboard.googlecode.com/svn/trunk/reviewboard > > http://codereview.appspot.com/ - Google, Guido van Rossum > > Cheers, > > C.J. > > > > On Sat, 2008-05-17 at 21:47 -0700, Tomas Matousek wrote: > > tfpt review /shelveset:RubyLibsAndYaml;REDMOND\tomat > > > > Adjusts class-initializer generator to enable generating initializers for multiple libraries within a single assembly. > > Also enables extending existing Ruby modules and classes that are defined in C# libraries (previously only CLR classes could have been extended). For example, the following class adds additional methods on Kernel module: > > > > [RubyModule(Extends = typeof(Kernel))] > > public static class MyKernelOps { > > [RubyMethod("foo")] > > public static void Foo() { ... } > > } > > > > The type specified in Extends parameter is the C# class defining the module/class. > > > > Enables to group C# classes and modules into Ruby libraries (e.g. thread, socket, openssl, yaml, etc.). Each library is identified by a root namespace. All Ruby classes and modules of the assembly defined within the namespace are considered parts of the library. The shelveset updates namespaces in IronRuby.Libraries.dll to group classes by library: > > > > Ruby.Builtins > > Ruby.StandardLibrary.Threading > > Ruby.StandardLibrary.Sockets > > Ruby.StandardLibrary.OpenSsl > > Ruby.StandardLibrary.Digest > > Ruby.StandardLibrary.Zlib > > > > The list of namespaces that define libraries within an assembly is passed to the generator: > > > > ClassInitGenerator IronRuby.Libraries.dll /libraries:Ruby.Builtins;Ruby.StandardLibrary.Threading;Ruby.StandardLibrary.Sockets;Ruby.StandardLibrary.OpenSsl;Ruby.StandardLibrary.Digest;Ruby.StandardLibrary.Zlib /out:Initializers.Generated.cs > > > > The mapping from Ruby library name to the assembly and namespace is established via .rb files: > > > > thread.rb: > > load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.Threading' > > > > openssl.rb: > > load_assembly 'IronRuby.Libraries', 'Ruby.StandardLibrary.OpenSsl' > > > > etc. > > > > (Kernel#load_assembly now takes an optional second argument identifying the library to load by its root namespace). > > > > The files are included in the solution and their build action is set to "copy if new", which means they are copied to the output directory during the build. ir.exe includes the directory it is located in into the load paths list ($:), so the .rb files copied there are found by the standard Ruby require/load mechanism. > > > > Tomas > > _______________________________________________ > > Ironruby-core mailing list > > Ironruby-core at rubyforge.org > > http://rubyforge.org/mailman/listinfo/ironruby-core > _______________________________________________ > 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: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From dblank at brynmawr.edu Mon May 19 20:52:35 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Mon, 19 May 2008 14:52:35 -0400 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> Message-ID: <4831CC73.8060806@brynmawr.edu> I'm attempting to bring the IronPython Community Edition up to date with IP2B2, and having a couple of issues. I've documented everything needed to build it here: http://wiki.roboteducation.org/IronPython2B2 The first is a problem with mapSite in Src/IronPython/Runtime/Builtin.cs. The Mono csharp compiler is complaining that mapSite is uninitialized. Any ideas? The second is comping up with a valid nant xml with the right pieces defined. I can get it to build, and run, but it crashes with: $ mono Src/ipy.exe IronPython 2.0 Beta (0.0.0.0) on .NET 2.0.50727.42 Copyright (c) Microsoft Corporation. All rights reserved. >>> 1 Unhandled exception: Unhandled Exception: System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Microsoft.Scripting.Core.resources" was correctly embedded or linked into assembly "Microsoft.Scripting.Core" at compile time, or that all the satellite assemblies required are loadable and fully signed. at System.Resources.ResourceManager.AssemblyResourceMissing (System.String fileName) [0x00000] at System.Resources.ResourceManager.InternalGetResourceSet (System.Globalization.CultureInfo culture, Boolean Createifnotexists, Boolean tryParents) [0x00000] ... I suspect that the nant xml is incorrect. The relevant part I have added is: Any ideas on these two points would be very helpful. -Doug Douglas S. Blank wrote: > On Fri, May 9, 2008 11:37 pm, Curt Hagenlocher said: >> We added Microsoft.Scripting.Core.dll in Beta2; you'll probably need to >> add >> a reference to that. > > Curt, thanks for the quick feedback! You are right, and now I need to > figure out how to make that happen. > > Seo, et al: any chance of updating the IPCE build to work with IP2Beta2? > It looks like the Microsoft.Scripting.Core.dll requirement isn't going > away, so it won't be wasted effort. (Or someone point me in the right > direction, and I'll try to do it). > > I did try using the MS .dll's directly from CodePlex in Mono, and it > almost works. It builds fine, but *looks* like there is a bug that > prevents Mono from evaluating some statements (like "import sys"). The > stack trace from inside my c# code is below. If you think it is something > else, please let me know. > > I'd also be interested in other options to using IP2B2 (other than > retreating to an earlier IP). I fairly new to all of this, so maybe I am > missing something obvious. > > -Doug > > System.Reflection.TargetInvocationException: Exception has been thrown by > the target of an invocation. ---> System.ArgumentException: The method > should be static. > Parameter name: method > at System.Delegate.CreateDelegate (System.Type type, > System.Reflection.MethodInfo method, Boolean throwOnBindFailure) > [0x00000] > at System.Delegate.CreateDelegate (System.Type type, > System.Reflection.MethodInfo method) [0x00000] > at > Microsoft.Scripting.Utils.InvokeHelper`3[Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]],Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object],Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]]]..ctor > (System.Reflection.MethodInfo ) [0x00000] > at <0x00000> > at (wrapper managed-to-native) > System.Reflection.MonoCMethod:InternalInvoke (object,object[]) > at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags > invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, > System.Globalization.CultureInfo culture) [0x00000] --- End of inner > exception stack trace --- > > at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags > invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, > System.Globalization.CultureInfo culture) [0x00000] > at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, > System.Reflection.Binder binder, System.Object[] parameters, > System.Globalization.CultureInfo culture) [0x00000] > at System.Activator.CreateInstance (System.Type type, BindingFlags > bindingAttr, System.Reflection.Binder binder, System.Object[] args, > System.Globalization.CultureInfo culture, System.Object[] > activationAttributes) [0x00000] > at System.Activator.CreateInstance (System.Type type, System.Object[] > args, System.Object[] activationAttributes) [0x00000] > at System.Activator.CreateInstance (System.Type type, System.Object[] > args) [0x00000] > at Microsoft.Scripting.Utils.ReflectedCaller.SlowCreate > (System.Reflection.MethodInfo info, System.Reflection.ParameterInfo[] > pis) [0x00000] > at Microsoft.Scripting.Utils.ReflectedCaller.FastCreate > (System.Reflection.MethodInfo target, System.Reflection.ParameterInfo[] > pi) [0x00000] > at Microsoft.Scripting.Utils.ReflectedCaller.Create > (System.Reflection.MethodInfo info) [0x00000] >> On Fri, May 9, 2008 at 8:25 PM, Douglas S. Blank >> wrote: >> >>> Does anyone have an example of IronPython2 Beta2 Hosting in C# working >>> with Mono 1.9? I think I have all of the pieces in place, but get an >>> error >>> that ScriptRuntime can not be found on build. >>> >>> Any pointers appreciated! >>> >>> -Doug >>> From vargaz at gmail.com Mon May 19 22:12:29 2008 From: vargaz at gmail.com (Zoltan Varga) Date: Mon, 19 May 2008 22:12:29 +0200 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <4831CC73.8060806@brynmawr.edu> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> Message-ID: <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> Hi, The relevant code is the following: DynamicSite mapSite; if (func != null) mapSite = CallSiteFactory.CreateSimpleCallSite(DefaultContext.DefaultPythonBinder); IEnumerator i = PythonOps.GetEnumerator(param[1]); while (i.MoveNext()) { if (func == null) ret.AddNoLock(i.Current); else ret.AddNoLock(mapSite.Invoke(DefaultContext.Default, func, i.Current)); Here, mapSite is not initialized. I'm not sure why the MS.NET C# compiler allows this. There is another similar case in the same method: DynamicSite mapSite; while (true) { bool done = true; for (int i = 0; i < enums.Length; i++) { if (enums[i].MoveNext()) { args[i] = enums[i].Current; done = false; } else { args[i] = null; } } if (done) { return ret; } if (func != null) { // splat call w/ args, can't use site here yet... if (!mapSite.IsInitialized) { As for the resource problem, try this in the nant build file: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Zoltan On Mon, May 19, 2008 at 8:52 PM, Douglas S. Blank wrote: > I'm attempting to bring the IronPython Community Edition up to date with > IP2B2, and having a couple of issues. I've documented everything needed to > build it here: > > http://wiki.roboteducation.org/IronPython2B2 > > The first is a problem with mapSite in Src/IronPython/Runtime/Builtin.cs. > The Mono csharp compiler is complaining that mapSite is uninitialized. Any > ideas? > > The second is comping up with a valid nant xml with the right pieces > defined. I can get it to build, and run, but it crashes with: > > $ mono Src/ipy.exe > IronPython 2.0 Beta (0.0.0.0) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. >>>> 1 > Unhandled exception: > > Unhandled Exception: System.Resources.MissingManifestResourceException: > Could not find any resources appropriate for the specified culture or the > neutral culture. Make sure "Microsoft.Scripting.Core.resources" was > correctly embedded or linked into assembly "Microsoft.Scripting.Core" at > compile time, or that all the satellite assemblies required are loadable and > fully signed. > at System.Resources.ResourceManager.AssemblyResourceMissing (System.String > fileName) [0x00000] > at System.Resources.ResourceManager.InternalGetResourceSet > (System.Globalization.CultureInfo culture, Boolean Createifnotexists, > Boolean tryParents) [0x00000] > ... > > I suspect that the nant xml is incorrect. The relevant part I have added is: > > warninglevel="${warn}"> > > > > > > > > > Any ideas on these two points would be very helpful. > > -Doug > > Douglas S. Blank wrote: >> >> On Fri, May 9, 2008 11:37 pm, Curt Hagenlocher said: >>> >>> We added Microsoft.Scripting.Core.dll in Beta2; you'll probably need to >>> add >>> a reference to that. >> >> Curt, thanks for the quick feedback! You are right, and now I need to >> figure out how to make that happen. >> >> Seo, et al: any chance of updating the IPCE build to work with IP2Beta2? >> It looks like the Microsoft.Scripting.Core.dll requirement isn't going >> away, so it won't be wasted effort. (Or someone point me in the right >> direction, and I'll try to do it). >> >> I did try using the MS .dll's directly from CodePlex in Mono, and it >> almost works. It builds fine, but *looks* like there is a bug that >> prevents Mono from evaluating some statements (like "import sys"). The >> stack trace from inside my c# code is below. If you think it is something >> else, please let me know. >> >> I'd also be interested in other options to using IP2B2 (other than >> retreating to an earlier IP). I fairly new to all of this, so maybe I am >> missing something obvious. >> >> -Doug >> >> System.Reflection.TargetInvocationException: Exception has been thrown by >> the target of an invocation. ---> System.ArgumentException: The method >> should be static. >> Parameter name: method >> at System.Delegate.CreateDelegate (System.Type type, >> System.Reflection.MethodInfo method, Boolean throwOnBindFailure) >> [0x00000] >> at System.Delegate.CreateDelegate (System.Type type, >> System.Reflection.MethodInfo method) [0x00000] >> at >> >> Microsoft.Scripting.Utils.InvokeHelper`3[Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]],Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object],Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]]]..ctor >> (System.Reflection.MethodInfo ) [0x00000] >> at <0x00000> >> at (wrapper managed-to-native) >> System.Reflection.MonoCMethod:InternalInvoke (object,object[]) >> at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags >> invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, >> System.Globalization.CultureInfo culture) [0x00000] --- End of inner >> exception stack trace --- >> >> at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags >> invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, >> System.Globalization.CultureInfo culture) [0x00000] >> at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, >> System.Reflection.Binder binder, System.Object[] parameters, >> System.Globalization.CultureInfo culture) [0x00000] >> at System.Activator.CreateInstance (System.Type type, BindingFlags >> bindingAttr, System.Reflection.Binder binder, System.Object[] args, >> System.Globalization.CultureInfo culture, System.Object[] >> activationAttributes) [0x00000] >> at System.Activator.CreateInstance (System.Type type, System.Object[] >> args, System.Object[] activationAttributes) [0x00000] >> at System.Activator.CreateInstance (System.Type type, System.Object[] >> args) [0x00000] >> at Microsoft.Scripting.Utils.ReflectedCaller.SlowCreate >> (System.Reflection.MethodInfo info, System.Reflection.ParameterInfo[] >> pis) [0x00000] >> at Microsoft.Scripting.Utils.ReflectedCaller.FastCreate >> (System.Reflection.MethodInfo target, System.Reflection.ParameterInfo[] >> pi) [0x00000] >> at Microsoft.Scripting.Utils.ReflectedCaller.Create >> (System.Reflection.MethodInfo info) [0x00000] >>> >>> On Fri, May 9, 2008 at 8:25 PM, Douglas S. Blank >>> wrote: >>> >>>> Does anyone have an example of IronPython2 Beta2 Hosting in C# working >>>> with Mono 1.9? I think I have all of the pieces in place, but get an >>>> error >>>> that ScriptRuntime can not be found on build. >>>> >>>> Any pointers appreciated! >>>> >>>> -Doug >>>> > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dblank at brynmawr.edu Mon May 19 23:49:35 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Mon, 19 May 2008 17:49:35 -0400 (EDT) Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> Message-ID: <49318.71.59.123.159.1211233775.squirrel@webmail.brynmawr.edu> On Mon, May 19, 2008 4:12 pm, Zoltan Varga said: > Hi, > > The relevant code is the following: [snip] I had already identified the code, and have workarounds (see URL). But I suspect that they are not correct. > As for the resource problem, try this in the nant build file: Excellent! That fixed the issue, and IP2B2 runs fine on Mono (so far). I'll update: http://wiki.roboteducation.org/IronPython2B2 Thanks! -Doug > <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > output="Microsoft.Scripting.Core/Microsoft.Scripting.Core.resources"/> > output="Microsoft.Scripting.Core.dll"> > > > > > > > > > > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > > Zoltan > > On Mon, May 19, 2008 at 8:52 PM, Douglas S. Blank > wrote: >> I'm attempting to bring the IronPython Community Edition up to date with >> IP2B2, and having a couple of issues. I've documented everything needed >> to >> build it here: >> >> http://wiki.roboteducation.org/IronPython2B2 >> >> The first is a problem with mapSite in >> Src/IronPython/Runtime/Builtin.cs. >> The Mono csharp compiler is complaining that mapSite is uninitialized. >> Any >> ideas? >> >> The second is comping up with a valid nant xml with the right pieces >> defined. I can get it to build, and run, but it crashes with: >> >> $ mono Src/ipy.exe >> IronPython 2.0 Beta (0.0.0.0) on .NET 2.0.50727.42 >> Copyright (c) Microsoft Corporation. All rights reserved. >>>>> 1 >> Unhandled exception: >> >> Unhandled Exception: System.Resources.MissingManifestResourceException: >> Could not find any resources appropriate for the specified culture or >> the >> neutral culture. Make sure "Microsoft.Scripting.Core.resources" was >> correctly embedded or linked into assembly "Microsoft.Scripting.Core" at >> compile time, or that all the satellite assemblies required are loadable >> and >> fully signed. >> at System.Resources.ResourceManager.AssemblyResourceMissing >> (System.String >> fileName) [0x00000] >> at System.Resources.ResourceManager.InternalGetResourceSet >> (System.Globalization.CultureInfo culture, Boolean Createifnotexists, >> Boolean tryParents) [0x00000] >> ... >> >> I suspect that the nant xml is incorrect. The relevant part I have added >> is: >> >> > warninglevel="${warn}"> >> >> >> >> >> >> >> >> >> Any ideas on these two points would be very helpful. >> >> -Doug >> >> Douglas S. Blank wrote: >>> >>> On Fri, May 9, 2008 11:37 pm, Curt Hagenlocher said: >>>> >>>> We added Microsoft.Scripting.Core.dll in Beta2; you'll probably need >>>> to >>>> add >>>> a reference to that. >>> >>> Curt, thanks for the quick feedback! You are right, and now I need to >>> figure out how to make that happen. >>> >>> Seo, et al: any chance of updating the IPCE build to work with >>> IP2Beta2? >>> It looks like the Microsoft.Scripting.Core.dll requirement isn't going >>> away, so it won't be wasted effort. (Or someone point me in the right >>> direction, and I'll try to do it). >>> >>> I did try using the MS .dll's directly from CodePlex in Mono, and it >>> almost works. It builds fine, but *looks* like there is a bug that >>> prevents Mono from evaluating some statements (like "import sys"). The >>> stack trace from inside my c# code is below. If you think it is >>> something >>> else, please let me know. >>> >>> I'd also be interested in other options to using IP2B2 (other than >>> retreating to an earlier IP). I fairly new to all of this, so maybe I >>> am >>> missing something obvious. >>> >>> -Doug >>> >>> System.Reflection.TargetInvocationException: Exception has been thrown >>> by >>> the target of an invocation. ---> System.ArgumentException: The method >>> should be static. >>> Parameter name: method >>> at System.Delegate.CreateDelegate (System.Type type, >>> System.Reflection.MethodInfo method, Boolean throwOnBindFailure) >>> [0x00000] >>> at System.Delegate.CreateDelegate (System.Type type, >>> System.Reflection.MethodInfo method) [0x00000] >>> at >>> >>> Microsoft.Scripting.Utils.InvokeHelper`3[Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]],Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object],Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]]]..ctor >>> (System.Reflection.MethodInfo ) [0x00000] >>> at <0x00000> >>> at (wrapper managed-to-native) >>> System.Reflection.MonoCMethod:InternalInvoke (object,object[]) >>> at System.Reflection.MonoCMethod.Invoke (System.Object obj, >>> BindingFlags >>> invokeAttr, System.Reflection.Binder binder, System.Object[] >>> parameters, >>> System.Globalization.CultureInfo culture) [0x00000] --- End of inner >>> exception stack trace --- >>> >>> at System.Reflection.MonoCMethod.Invoke (System.Object obj, >>> BindingFlags >>> invokeAttr, System.Reflection.Binder binder, System.Object[] >>> parameters, >>> System.Globalization.CultureInfo culture) [0x00000] >>> at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, >>> System.Reflection.Binder binder, System.Object[] parameters, >>> System.Globalization.CultureInfo culture) [0x00000] >>> at System.Activator.CreateInstance (System.Type type, BindingFlags >>> bindingAttr, System.Reflection.Binder binder, System.Object[] args, >>> System.Globalization.CultureInfo culture, System.Object[] >>> activationAttributes) [0x00000] >>> at System.Activator.CreateInstance (System.Type type, System.Object[] >>> args, System.Object[] activationAttributes) [0x00000] >>> at System.Activator.CreateInstance (System.Type type, System.Object[] >>> args) [0x00000] >>> at Microsoft.Scripting.Utils.ReflectedCaller.SlowCreate >>> (System.Reflection.MethodInfo info, System.Reflection.ParameterInfo[] >>> pis) [0x00000] >>> at Microsoft.Scripting.Utils.ReflectedCaller.FastCreate >>> (System.Reflection.MethodInfo target, System.Reflection.ParameterInfo[] >>> pi) [0x00000] >>> at Microsoft.Scripting.Utils.ReflectedCaller.Create >>> (System.Reflection.MethodInfo info) [0x00000] >>>> >>>> On Fri, May 9, 2008 at 8:25 PM, Douglas S. Blank >>>> wrote: >>>> >>>>> Does anyone have an example of IronPython2 Beta2 Hosting in C# >>>>> working >>>>> with Mono 1.9? I think I have all of the pieces in place, but get an >>>>> error >>>>> that ScriptRuntime can not be found on build. >>>>> >>>>> Any pointers appreciated! >>>>> >>>>> -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 > -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From dreamer_of_dreamers2000 at yahoo.com Tue May 20 01:39:08 2008 From: dreamer_of_dreamers2000 at yahoo.com (Dan) Date: Mon, 19 May 2008 16:39:08 -0700 (PDT) Subject: [IronPython] Hosting Script Debugging Message-ID: <254698.93758.qm@web65702.mail.ac4.yahoo.com> I am looking at using IronPython 1.1 as a script hosting for an application written in C#. I would like to provide the users of the scripting language full featured functionality for debug of user created python scripts, much like excel does with VB Script. Features I am look at are: 1 - Line Number for code executed. I would like to know and report from my C# code what line number of the python script called my C# function. 2 - Breakpoints 3 - Step through, jump to code within the user supplied python script. Any suggestions on where to start? Thank you, Dan From dblank at brynmawr.edu Tue May 20 02:20:03 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Mon, 19 May 2008 20:20:03 -0400 (EDT) Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <49318.71.59.123.159.1211233775.squirrel@webmail.brynmawr.edu> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> <49318.71.59.123.159.1211233775.squirrel@webmail.brynmawr.edu> Message-ID: <49538.71.59.123.159.1211242803.squirrel@webmail.brynmawr.edu> Seo at al., If you want to grab the patches for an IPCEr8 which will build and run IP2B2: svn export http://svn.cs.brynmawr.edu/Myro/trunk/fepy/IPCE/fepy/patches/2.0b2/ will give you: 2.0b2/patch-builtin-mapsite 2.0b2/patch-nant-build 2.0b2/patch-console 2.0b2/patch-dictproxy 2.0b2/patch-option-v Largely untested. For others, you can adapt IPCEr7 build.sh to get these files. First, change download.sh and build.sh to use IronPython2B2, and change build.sh to something like: ... echo 'Unpacking IronPython 2' unzip -q files/IronPython-$IRON2_VERSION-Src.zip # Add this: echo 'Getting IP2 Patches' rm -rf fepy/patches/2.0b2 (cd fepy/patches; svn export http://svn.cs.brynmawr.edu/Myro/trunk/fepy/IPCE/fepy/patches/2.0b2/) ... -Doug From dan.eloff at gmail.com Tue May 20 06:36:13 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Mon, 19 May 2008 23:36:13 -0500 Subject: [IronPython] Should DBNull treat as false ? In-Reply-To: <20253b0c0805151141i5c3283bbm8696f5a32b06008f@mail.gmail.com> References: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> <20253b0c0805151141i5c3283bbm8696f5a32b06008f@mail.gmail.com> Message-ID: <4817b6fc0805192136l6ed9dbd0l5c7916b4fc06cf55@mail.gmail.com> I don't think DBNull.Value should be True, it's purpose is very similar to None, and it should have the same truth value. Doing otherwise complicates conditional expressions and leads to conversations like this on the mailing list... Usually it's best to choose the path of least surprise. -Dan On Thu, May 15, 2008 at 1:41 PM, Davy Mitchell wrote: > Hi there, > > I *think* this may be related to the Closed issue > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=14605 > > Dino stated at the time (with the last point being relevant here): > "....NET conventions say that enum's should generally have a zero value > (FxCop CA1008 :)). Because of that we can safely define __nonzero__ on > enums and have that return true/false based upon if the value is > zero/non-zero. Otherwise Python says all expressions otherwise defined > return true," > > So I think the behaviour is correct though slightly counter intuitive in the > case of Null. > > Cheers, > Davy > > On Thu, May 15, 2008 at 11:51 AM, Sakesun Roykiattisak > wrote: >> >> Some disambitguity is needed here. >> >> when eval("a == True") is False does not implied "a" is False. >> "a" is just not equal to True. >> >> All .NET types actually consider "nonzero" which in turn will be treat as >> True in conditional expression. >> >> >>>>> if System.DBNull: print 'I am something' >> >> ... >> I am something >>>>> >> >> >>>>> if None: print "This won't show anything" >> >> ... >>>>> >> >> What I'm asking here is whether should DBNull.Value be considered as False >> in conditional expression. >> >> >> >> On Thu, 15 May 2008 15:48:37 +0700, Davy Mitchell >> wrote: >> >>> DBNull is a type. Appears all .Net types evaluate to False. >>> e.g. >>> from System import DBNull, Char >>> print Char==True >>> print DBNull==True >>> >>> both will print False. >>> >>> On Thu, May 15, 2008 at 9:09 AM, Sakesun Roykiattisak < >>> sakesun at boonthavorn.com> wrote: >>> >>>> >>>> Should DBNull treat as False ? >>>> >>>> Just a thought. >>>> _______________________________________________ >>>> 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 > > > > -- > Davy Mitchell > Blog - http://www.latedecember.co.uk/sites/personal/davy/ > Twitter - http://twitter.com/daftspaniel > Skype - daftspaniel http://needgod.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From ronnie.maor at gmail.com Tue May 20 08:41:48 2008 From: ronnie.maor at gmail.com (Ronnie Maor) Date: Tue, 20 May 2008 09:41:48 +0300 Subject: [IronPython] precision problem with Int64 In-Reply-To: <7AD436E4270DD54A94238001769C2227012BBFF03F3D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <2fd6b9d0805190147n28f7ade3pa5d2bf76819981ca@mail.gmail.com> <7AD436E4270DD54A94238001769C2227012BBFF03F3D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <2fd6b9d0805192341g572a4acbl3b851a22a0a73cd7@mail.gmail.com> seems the conversion goes through floating point (was the simplest thing I could think of that would produce that behavior): >>> n = 8591464408876390743 >>> x = long(float(n)) >>> x 8591464408876390400L >>> System.Int64(n) == x True HTH Ronnie On Mon, May 19, 2008 at 6:23 PM, Dino Viehland wrote: > I don't think I've seen this reported anywhere. The good news is it does > do the right thing in 2.0 but I've opened a 1.1.2 bug for the issue ( > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16658). > That means we'll consider fixing it for 1.1.2 but I have no clue how simple > the fix will be ? mainly because I have no clue how it got fixed in 2.0 J. > Thanks for the report. > > > > *From:* users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] *On Behalf Of *Ronnie Maor > *Sent:* Monday, May 19, 2008 1:47 AM > *To:* Discussion of IronPython > *Subject:* [IronPython] precision problem with Int64 > > > > Hi all, > > Is the following a known bug? (IPy 1.1.1) > > >>> import System > >>> n = 8591464408876390743 > >>> x = System.Int64(n) > >>> x > 8591464408876390400L > >>> y = System.Int64(str(n)) > >>> y > 8591464408876390743L > >>> x == y > False > > n is positive and contained in 63 bits, so there shouldn't even be > signed/unsigned issues. > > ? > > > _______________________________________________ > 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 exchange.microsoft.com Tue May 20 18:27:34 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 20 May 2008 09:27:34 -0700 Subject: [IronPython] Should DBNull treat as false ? In-Reply-To: <4817b6fc0805192136l6ed9dbd0l5c7916b4fc06cf55@mail.gmail.com> References: <20253b0c0805150148m7c3d7ccdmfb8ef44de46954cf@mail.gmail.com> <20253b0c0805151141i5c3283bbm8696f5a32b06008f@mail.gmail.com> <4817b6fc0805192136l6ed9dbd0l5c7916b4fc06cf55@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF042A5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I generally agree that DBNull should be false - it is logically the same as None. We can define __nonzero__ on DBNull.Value to make this work. I've opened bug #16695 to track the issue (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16695) and it should be an easy fix. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff Sent: Monday, May 19, 2008 9:36 PM To: Discussion of IronPython Subject: Re: [IronPython] Should DBNull treat as false ? I don't think DBNull.Value should be True, it's purpose is very similar to None, and it should have the same truth value. Doing otherwise complicates conditional expressions and leads to conversations like this on the mailing list... Usually it's best to choose the path of least surprise. -Dan On Thu, May 15, 2008 at 1:41 PM, Davy Mitchell wrote: > Hi there, > > I *think* this may be related to the Closed issue > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=14605 > > Dino stated at the time (with the last point being relevant here): > "....NET conventions say that enum's should generally have a zero value > (FxCop CA1008 :)). Because of that we can safely define __nonzero__ on > enums and have that return true/false based upon if the value is > zero/non-zero. Otherwise Python says all expressions otherwise defined > return true," > > So I think the behaviour is correct though slightly counter intuitive in the > case of Null. > > Cheers, > Davy > > On Thu, May 15, 2008 at 11:51 AM, Sakesun Roykiattisak > wrote: >> >> Some disambitguity is needed here. >> >> when eval("a == True") is False does not implied "a" is False. >> "a" is just not equal to True. >> >> All .NET types actually consider "nonzero" which in turn will be treat as >> True in conditional expression. >> >> >>>>> if System.DBNull: print 'I am something' >> >> ... >> I am something >>>>> >> >> >>>>> if None: print "This won't show anything" >> >> ... >>>>> >> >> What I'm asking here is whether should DBNull.Value be considered as False >> in conditional expression. >> >> >> >> On Thu, 15 May 2008 15:48:37 +0700, Davy Mitchell >> wrote: >> >>> DBNull is a type. Appears all .Net types evaluate to False. >>> e.g. >>> from System import DBNull, Char >>> print Char==True >>> print DBNull==True >>> >>> both will print False. >>> >>> On Thu, May 15, 2008 at 9:09 AM, Sakesun Roykiattisak < >>> sakesun at boonthavorn.com> wrote: >>> >>>> >>>> Should DBNull treat as False ? >>>> >>>> Just a thought. >>>> _______________________________________________ >>>> 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 > > > > -- > Davy Mitchell > Blog - http://www.latedecember.co.uk/sites/personal/davy/ > Twitter - http://twitter.com/daftspaniel > Skype - daftspaniel http://needgod.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 Tim.McClure at ge.com Tue May 20 18:43:59 2008 From: Tim.McClure at ge.com (McClure, Timothy J (GE EntSol, Security)) Date: Tue, 20 May 2008 12:43:59 -0400 Subject: [IronPython] Pylons Message-ID: > _____________________________________________ > From: McClure, Timothy J (GE EntSol, Security) > Sent: Tuesday, May 20, 2008 10:16 AM > To: 'users at lists.ironpython.com' > Subject: Pylons > > Has anyone be able to get Pylons running under IronPython? If so how did you do it? > > Tim McClure > Software Architect > GE Enterprise Solutions > GE Security > Grey Pipe Integration Project > > T + 1 561 912 5939 > M+ 1 561 945 7595 > F + 1 561 994 6572 > E tim.mcclure at ge.com > > 791 Park of Commerce Blvd. > Boca Raton, Fl., 33487 > > GE imagination at work > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From Tim.McClure at ge.com Tue May 20 22:14:55 2008 From: Tim.McClure at ge.com (McClure, Timothy J (GE EntSol, Security)) Date: Tue, 20 May 2008 16:14:55 -0400 Subject: [IronPython] ZipImport Message-ID: Does anyone know how to get around the zipimport module not found issue? Tim McClure Software Architect GE Enterprise Solutions GE Security Grey Pipe Integration Project T + 1 561 912 5939 M+ 1 561 945 7595 F + 1 561 994 6572 E tim.mcclure at ge.com 791 Park of Commerce Blvd. Boca Raton, Fl., 33487 GE imagination at work -------------- next part -------------- An HTML attachment was scrubbed... URL: From sanxiyn at gmail.com Tue May 20 22:18:21 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Wed, 21 May 2008 05:18:21 +0900 Subject: [IronPython] ZipImport In-Reply-To: References: Message-ID: <5b0248170805201318y12e775d4p3dd00acc0b8cb79a@mail.gmail.com> 2008/5/21 McClure, Timothy J (GE EntSol, Security) : > Does anyone know how to get around the zipimport module not found issue? None I know of. This is on my TODO list. If you want to solve this yourself, you may want to look at this pure Python implementation of zipimport and whether it can be used on IronPython: http://svn.python.org/projects/sandbox/trunk/import_in_py/ -- Seo Sanghyeon From slide.o.mix at gmail.com Wed May 21 01:19:34 2008 From: slide.o.mix at gmail.com (Slide) Date: Tue, 20 May 2008 16:19:34 -0700 Subject: [IronPython] determine if running under IP Message-ID: Is there a way in Python code to determine if you are running under IronPython or C Python? Thanks -- slide-o-blog http://slide-o-blog.blogspot.com/ From dfugate at microsoft.com Wed May 21 01:21:44 2008 From: dfugate at microsoft.com (Dave Fugate) Date: Tue, 20 May 2008 16:21:44 -0700 Subject: [IronPython] determine if running under IP In-Reply-To: References: Message-ID: Easy=) Check the value of sys.platform which will be "cli" under IronPython. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Tuesday, May 20, 2008 4:20 PM To: Discussion of IronPython Subject: [IronPython] determine if running under IP Is there a way in Python code to determine if you are running under IronPython or C Python? Thanks -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From jdhardy at gmail.com Wed May 21 02:06:19 2008 From: jdhardy at gmail.com (Jeff Hardy) Date: Tue, 20 May 2008 18:06:19 -0600 Subject: [IronPython] Pylons In-Reply-To: References: Message-ID: Hi Tim, I haven't tried in a while (since about 2.0a7 or so), but I recall there being a number of issues getting it to run. The most important one is a lack of a templating system that works in IronPython - most depend on a C core, and the ones that don't (Mako and Genshi) rely on the CPython "parser" module, which is not yet implemented. You'd also need compatible wrappers for whatever database you need; the CPython database modules usually use C libraries, so they need to be written to call the equivalent .NET library. Seo has done some of the work with his FePy project (fepy.sourceforge.net), but I know that at least the compiler module hasn't been updated to newer versions of IPy. I'd like to get Pylons running as well, but it'll be a couple of weeks before I have time to spend on it. -Jeff On Tue, May 20, 2008 at 10:43 AM, McClure, Timothy J (GE EntSol, Security) wrote: > > > _____________________________________________ > From: McClure, Timothy J (GE EntSol, Security) > Sent: Tuesday, May 20, 2008 10:16 AM > To: 'users at lists.ironpython.com' > Subject: Pylons > > Has anyone be able to get Pylons running under IronPython? If so how did > you do it? > > Tim McClure > Software Architect > GE Enterprise Solutions > GE Security > Grey Pipe Integration Project > > T + 1 561 912 5939 > M+ 1 561 945 7595 > F + 1 561 994 6572 > E tim.mcclure at ge.com > > 791 Park of Commerce Blvd. > Boca Raton, Fl., 33487 > > GE imagination at work > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > From dan.eloff at gmail.com Wed May 21 21:26:51 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 21 May 2008 14:26:51 -0500 Subject: [IronPython] determine if running under IP In-Reply-To: References: Message-ID: <4817b6fc0805211226w25468c52i21118ff92aa8898d@mail.gmail.com> > Easy=) Check the value of sys.platform which will be "cli" under IronPython. Except if you're running IronPython under silverlight, in which case it will be 'silverlight' You could do: try: import clr IronPython = True except ImportError: IronPython = False Except if you're running CPython with Python .NET, in which case it will falsely identify as IronPython (is that wrong? Python .NET aims to be as compatible as possible with IronPython) There's really a million ways to discover this, some of them outlandishly hackish, e.g. IronPython = 'Microsoft' in sys.copyright It depends I guess on what you're particular needs are, and and how elegant you want your solution to be. I hope this gives you some ideas, be creative. -Dan From dinov at exchange.microsoft.com Thu May 22 05:16:09 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 21 May 2008 20:16:09 -0700 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF04821@DF-GRTDANE-MSG.exchange.corp.microsoft.com> BTW I think the lack of requiring assignment is the same issue as http://lists.ironpython.com/pipermail/users-ironpython.com/2007-October/005842.html. I'll fix the code. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Zoltan Varga Sent: Monday, May 19, 2008 1:12 PM To: Discussion of IronPython Subject: Re: [IronPython] Hosting IP2 Beta2 in Mono? Hi, The relevant code is the following: DynamicSite mapSite; if (func != null) mapSite = CallSiteFactory.CreateSimpleCallSite(DefaultContext.DefaultPythonBinder); IEnumerator i = PythonOps.GetEnumerator(param[1]); while (i.MoveNext()) { if (func == null) ret.AddNoLock(i.Current); else ret.AddNoLock(mapSite.Invoke(DefaultContext.Default, func, i.Current)); Here, mapSite is not initialized. I'm not sure why the MS.NET C# compiler allows this. There is another similar case in the same method: DynamicSite mapSite; while (true) { bool done = true; for (int i = 0; i < enums.Length; i++) { if (enums[i].MoveNext()) { args[i] = enums[i].Current; done = false; } else { args[i] = null; } } if (done) { return ret; } if (func != null) { // splat call w/ args, can't use site here yet... if (!mapSite.IsInitialized) { As for the resource problem, try this in the nant build file: <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Zoltan On Mon, May 19, 2008 at 8:52 PM, Douglas S. Blank wrote: > I'm attempting to bring the IronPython Community Edition up to date with > IP2B2, and having a couple of issues. I've documented everything needed to > build it here: > > http://wiki.roboteducation.org/IronPython2B2 > > The first is a problem with mapSite in Src/IronPython/Runtime/Builtin.cs. > The Mono csharp compiler is complaining that mapSite is uninitialized. Any > ideas? > > The second is comping up with a valid nant xml with the right pieces > defined. I can get it to build, and run, but it crashes with: > > $ mono Src/ipy.exe > IronPython 2.0 Beta (0.0.0.0) on .NET 2.0.50727.42 > Copyright (c) Microsoft Corporation. All rights reserved. >>>> 1 > Unhandled exception: > > Unhandled Exception: System.Resources.MissingManifestResourceException: > Could not find any resources appropriate for the specified culture or the > neutral culture. Make sure "Microsoft.Scripting.Core.resources" was > correctly embedded or linked into assembly "Microsoft.Scripting.Core" at > compile time, or that all the satellite assemblies required are loadable and > fully signed. > at System.Resources.ResourceManager.AssemblyResourceMissing (System.String > fileName) [0x00000] > at System.Resources.ResourceManager.InternalGetResourceSet > (System.Globalization.CultureInfo culture, Boolean Createifnotexists, > Boolean tryParents) [0x00000] > ... > > I suspect that the nant xml is incorrect. The relevant part I have added is: > > warninglevel="${warn}"> > > > > > > > > > Any ideas on these two points would be very helpful. > > -Doug > > Douglas S. Blank wrote: >> >> On Fri, May 9, 2008 11:37 pm, Curt Hagenlocher said: >>> >>> We added Microsoft.Scripting.Core.dll in Beta2; you'll probably need to >>> add >>> a reference to that. >> >> Curt, thanks for the quick feedback! You are right, and now I need to >> figure out how to make that happen. >> >> Seo, et al: any chance of updating the IPCE build to work with IP2Beta2? >> It looks like the Microsoft.Scripting.Core.dll requirement isn't going >> away, so it won't be wasted effort. (Or someone point me in the right >> direction, and I'll try to do it). >> >> I did try using the MS .dll's directly from CodePlex in Mono, and it >> almost works. It builds fine, but *looks* like there is a bug that >> prevents Mono from evaluating some statements (like "import sys"). The >> stack trace from inside my c# code is below. If you think it is something >> else, please let me know. >> >> I'd also be interested in other options to using IP2B2 (other than >> retreating to an earlier IP). I fairly new to all of this, so maybe I am >> missing something obvious. >> >> -Doug >> >> System.Reflection.TargetInvocationException: Exception has been thrown by >> the target of an invocation. ---> System.ArgumentException: The method >> should be static. >> Parameter name: method >> at System.Delegate.CreateDelegate (System.Type type, >> System.Reflection.MethodInfo method, Boolean throwOnBindFailure) >> [0x00000] >> at System.Delegate.CreateDelegate (System.Type type, >> System.Reflection.MethodInfo method) [0x00000] >> at >> >> Microsoft.Scripting.Utils.InvokeHelper`3[Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]],Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object],Microsoft.Scripting.Actions.CallSite`1[Microsoft.Scripting.Actions.DynamicSiteTarget`6[System.Object,System.String,Microsoft.Scripting.IAttributesCollection,Microsoft.Scripting.IAttributesCollection,IronPython.Runtime.PythonTuple,System.Object]]]..ctor >> (System.Reflection.MethodInfo ) [0x00000] >> at <0x00000> >> at (wrapper managed-to-native) >> System.Reflection.MonoCMethod:InternalInvoke (object,object[]) >> at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags >> invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, >> System.Globalization.CultureInfo culture) [0x00000] --- End of inner >> exception stack trace --- >> >> at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags >> invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, >> System.Globalization.CultureInfo culture) [0x00000] >> at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, >> System.Reflection.Binder binder, System.Object[] parameters, >> System.Globalization.CultureInfo culture) [0x00000] >> at System.Activator.CreateInstance (System.Type type, BindingFlags >> bindingAttr, System.Reflection.Binder binder, System.Object[] args, >> System.Globalization.CultureInfo culture, System.Object[] >> activationAttributes) [0x00000] >> at System.Activator.CreateInstance (System.Type type, System.Object[] >> args, System.Object[] activationAttributes) [0x00000] >> at System.Activator.CreateInstance (System.Type type, System.Object[] >> args) [0x00000] >> at Microsoft.Scripting.Utils.ReflectedCaller.SlowCreate >> (System.Reflection.MethodInfo info, System.Reflection.ParameterInfo[] >> pis) [0x00000] >> at Microsoft.Scripting.Utils.ReflectedCaller.FastCreate >> (System.Reflection.MethodInfo target, System.Reflection.ParameterInfo[] >> pi) [0x00000] >> at Microsoft.Scripting.Utils.ReflectedCaller.Create >> (System.Reflection.MethodInfo info) [0x00000] >>> >>> On Fri, May 9, 2008 at 8:25 PM, Douglas S. Blank >>> wrote: >>> >>>> Does anyone have an example of IronPython2 Beta2 Hosting in C# working >>>> with Mono 1.9? I think I have all of the pieces in place, but get an >>>> error >>>> that ScriptRuntime can not be found on build. >>>> >>>> Any pointers appreciated! >>>> >>>> -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 dinov at exchange.microsoft.com Thu May 22 05:39:32 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 21 May 2008 20:39:32 -0700 Subject: [IronPython] New hosting API spec available... Message-ID: <7AD436E4270DD54A94238001769C2227012BBFF0482D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Bill has just updated the DLR hosting API spec over at http://compilerlab.members.winisp.net/ It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). There's probably still a few small mismatches from 2.0B2 but it should be pretty accurate to the state of world. Where there are differences the spec should be correct going forward we just need to fix the code :). -------------- next part -------------- An HTML attachment was scrubbed... URL: From ronnie.maor at gmail.com Thu May 22 08:42:47 2008 From: ronnie.maor at gmail.com (Ronnie Maor) Date: Thu, 22 May 2008 09:42:47 +0300 Subject: [IronPython] RPyC and IronPython Message-ID: <2fd6b9d0805212342x21c422dbv1ea572daf178eaa3@mail.gmail.com> I'm trying to use RPyC (http://rpyc.wikispaces.com), which is a great package for "generic remote control" of remote processes. it basically works, except for small changes I needed to make due to outstanding IPy incompatiblities. wanted to let people know in case you also want to use it (it's really great). Also wanted to validate that I'm not missing something in my patches: 1) it uses sys.excepthook. I understand this isn't supported. commented it out (it's not that critical) 2) id(obj) in IPy returns System.Int64, which unfortunately doesn't pickle out of the box, since it's not a python native type. even if you get it to work (using IPCE pickle fix), it won't be compatible with CPython, and running rpyc between IPy and CPython is really cool, and it works :-). The patch I used is to change the affected place to long(id(obj)). Is there a reason not to have IPy return long from id(obj)? I think having pure python code return non python types is a problem. 3) some protocols don't work on proxies to CLR objects. The most serious is that you can't iterate over IEnumerable objects. After initial investigation it seems to boil down to the fact that in IPy an IEnumerable x does the right thing when you call iter(x), but there is no x.__iter__. Is this allowed by the python standard, or IPy bug? In any case I'm going to try and patch the server code to use iter(x) instead of x.__iter__, and same for other protocols which are broken (__len__, others?) If it doesn't work there's a trivial workaround, which is to have the following code on the server side (in advance, or write it from the client): def itr(x): return (i for i in x) then you just wrap the problematic objects with itr (from the client calls) before iterating over them. since generators do have __iter__ this works. I'm also talking to the maintainer of the package, so hopefully rpyc will work with ipy out of the box soon. btw, forgot to mention this is all IPy 1.1.1 Ronnie -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Thu May 22 10:16:19 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Thu, 22 May 2008 09:16:19 +0100 Subject: [IronPython] New hosting API spec available... In-Reply-To: <7AD436E4270DD54A94238001769C2227012BBFF0482D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BBFF0482D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <48352BD3.70500@voidspace.org.uk> Dino Viehland wrote: > > Bill has just updated the DLR hosting API spec over at > http://compilerlab.members.winisp.net/ > > It?s available as both doc > (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF > (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). There?s > probably still a few small mismatches from 2.0B2 but it should be > pretty accurate to the state of world. Where there are differences the > spec should be correct going forward we just need to fix the code J. > Cool - very useful, thanks. Michael Foord http://www.ironpythoninaction.com/ > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From ben2004uk at googlemail.com Thu May 22 11:13:45 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Thu, 22 May 2008 10:13:45 +0100 Subject: [IronPython] New hosting API spec available... In-Reply-To: <48352BD3.70500@voidspace.org.uk> References: <7AD436E4270DD54A94238001769C2227012BBFF0482D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <48352BD3.70500@voidspace.org.uk> Message-ID: Excellent!! Thank you Dino. If we have questions - direct them to the list? Is this Spec going to be updated again for Final - or is this it now for v1? Is this what you meant by this comment - "Where there are differences the spec should be correct going forward we just need to fix the code " Thanks Ben On Thu, May 22, 2008 at 9:16 AM, Michael Foord wrote: > Dino Viehland wrote: >> >> Bill has just updated the DLR hosting API spec over at >> http://compilerlab.members.winisp.net/ >> >> It's available as both doc >> (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF >> (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). There's >> probably still a few small mismatches from 2.0B2 but it should be pretty >> accurate to the state of world. Where there are differences the spec should >> be correct going forward we just need to fix the code J. >> > Cool - very useful, thanks. > > Michael Foord > http://www.ironpythoninaction.com/ > > >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From sanxiyn at gmail.com Thu May 22 11:55:52 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Thu, 22 May 2008 18:55:52 +0900 Subject: [IronPython] RPyC and IronPython In-Reply-To: <2fd6b9d0805212342x21c422dbv1ea572daf178eaa3@mail.gmail.com> References: <2fd6b9d0805212342x21c422dbv1ea572daf178eaa3@mail.gmail.com> Message-ID: <5b0248170805220255m6e4432c4q77274314e6fc19c7@mail.gmail.com> 2008/5/22 Ronnie Maor : > 2) id(obj) in IPy returns System.Int64, which unfortunately doesn't pickle > out of the box, since it's not a python native type. This is clearly a bug. Actually, there already is a CodePlex issue, but it is mistitled. http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16000 1. Can people on the list please vote for this? 2. Can IronPython people please retitle this to something like "id shoud not return Int64"? -- Seo Sanghyeon From dinov at exchange.microsoft.com Thu May 22 16:43:25 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 22 May 2008 07:43:25 -0700 Subject: [IronPython] New hosting API spec available... In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BBFF0482D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <48352BD3.70500@voidspace.org.uk> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9851E9E@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Yep, any questions can go here. The spec is really close to being 100% final but there should be at least one more update at some point. That's because there's some remaining work around configuration. That shouldn't have much impact on people hosting for just IronPython or IronRuby - because they're already configured. For other languages and multi-language hosts that final update will be useful though. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall Sent: Thursday, May 22, 2008 2:14 AM To: Discussion of IronPython Subject: Re: [IronPython] New hosting API spec available... Excellent!! Thank you Dino. If we have questions - direct them to the list? Is this Spec going to be updated again for Final - or is this it now for v1? Is this what you meant by this comment - "Where there are differences the spec should be correct going forward we just need to fix the code " Thanks Ben On Thu, May 22, 2008 at 9:16 AM, Michael Foord wrote: > Dino Viehland wrote: >> >> Bill has just updated the DLR hosting API spec over at >> http://compilerlab.members.winisp.net/ >> >> It's available as both doc >> (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF >> (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). There's >> probably still a few small mismatches from 2.0B2 but it should be pretty >> accurate to the state of world. Where there are differences the spec should >> be correct going forward we just need to fix the code J. >> > Cool - very useful, thanks. > > Michael Foord > http://www.ironpythoninaction.com/ > > >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Thu May 22 16:55:53 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 22 May 2008 07:55:53 -0700 Subject: [IronPython] RPyC and IronPython In-Reply-To: <5b0248170805220255m6e4432c4q77274314e6fc19c7@mail.gmail.com> References: <2fd6b9d0805212342x21c422dbv1ea572daf178eaa3@mail.gmail.com> <5b0248170805220255m6e4432c4q77274314e6fc19c7@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9851EA6@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I've fixed the 2.0 bug and I've also created a bug for 1.1.2: http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16735 There's no reason why we should be doing that. At one point long ago I believe IronPython internally flowed from int32->int64->BigInt but that's long gone so id should be a native data type. The protocol methods is something we've gotten a whole lot better about in 2.0 and is probably a sufficiently large change that wouldn't make it back to 1.x. We used to have fast-paths for everything which were based upon .NET types and interfaces. We now do most (there's still some lingering "fast paths") of our dispatch through the Python protocol methods and as of beta 2 we have a much cleaner solution for projecting them onto .NET types. And currently in 2.0 anything which implements IEnumerable will get an __iter__ method. Thanks for the reports! -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo Sent: Thursday, May 22, 2008 2:56 AM To: Discussion of IronPython Subject: Re: [IronPython] RPyC and IronPython 2008/5/22 Ronnie Maor : > 2) id(obj) in IPy returns System.Int64, which unfortunately doesn't pickle > out of the box, since it's not a python native type. This is clearly a bug. Actually, there already is a CodePlex issue, but it is mistitled. http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16000 1. Can people on the list please vote for this? 2. Can IronPython people please retitle this to something like "id shoud not return Int64"? -- Seo Sanghyeon _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From ronnie.maor at gmail.com Thu May 22 21:44:53 2008 From: ronnie.maor at gmail.com (Ronnie Maor) Date: Thu, 22 May 2008 22:44:53 +0300 Subject: [IronPython] RPyC and IronPython In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC9851EA6@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <2fd6b9d0805212342x21c422dbv1ea572daf178eaa3@mail.gmail.com> <5b0248170805220255m6e4432c4q77274314e6fc19c7@mail.gmail.com> <7AD436E4270DD54A94238001769C2227012BC9851EA6@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <2fd6b9d0805221244n15da7e5bh8acdea7eab9475a0@mail.gmail.com> if you want to use RPyC, the fix for iter and len is to change the method handle_getattr in Connection.py to the following: def handle_getattr(self, oid, name): obj = self.box[oid] if name in ['__iter__','__len__']: def f(): return getattr(__builtins__,name[2:-2])(obj) # call iter(obj), len(obj), etc. return f return getattr(obj, name) I haven't received a response from tomer filiba yet (RPyC's author), but seems to work. I'm now happily iterating over remote lists :-) On Thu, May 22, 2008 at 5:55 PM, Dino Viehland wrote: > I've fixed the 2.0 bug and I've also created a bug for 1.1.2: > > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16735 > > There's no reason why we should be doing that. At one point long ago I > believe IronPython internally flowed from int32->int64->BigInt but that's > long gone so id should be a native data type. > > The protocol methods is something we've gotten a whole lot better about in > 2.0 and is probably a sufficiently large change that wouldn't make it back > to 1.x. We used to have fast-paths for everything which were based upon > .NET types and interfaces. We now do most (there's still some lingering > "fast paths") of our dispatch through the Python protocol methods and as of > beta 2 we have a much cleaner solution for projecting them onto .NET types. > And currently in 2.0 anything which implements IEnumerable will get an > __iter__ method. > > Thanks for the reports! > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto: > users-bounces at lists.ironpython.com] On Behalf Of Sanghyeon Seo > Sent: Thursday, May 22, 2008 2:56 AM > To: Discussion of IronPython > Subject: Re: [IronPython] RPyC and IronPython > > 2008/5/22 Ronnie Maor : > > 2) id(obj) in IPy returns System.Int64, which unfortunately doesn't > pickle > > out of the box, since it's not a python native type. > > This is clearly a bug. Actually, there already is a CodePlex issue, > but it is mistitled. > http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16000 > > 1. Can people on the list please vote for this? > 2. Can IronPython people please retitle this to something like "id > shoud not return Int64"? > > -- > Seo Sanghyeon > _______________________________________________ > 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 r.worbis at cubido.at Fri May 23 09:55:50 2008 From: r.worbis at cubido.at (Rainer Worbis) Date: Fri, 23 May 2008 09:55:50 +0200 Subject: [IronPython] Hierarchical ScriptScope In-Reply-To: <4817b6fc0805211226w25468c52i21118ff92aa8898d@mail.gmail.com> References: <4817b6fc0805211226w25468c52i21118ff92aa8898d@mail.gmail.com> Message-ID: <676F9CCC1D1D3242BE4B133746E3807E4409C4@XARA.cubido.linz> Hallo, after reading the current specs I found out that I can set a ScriptScope in a ScriptScope and can access the values via a.b notation. Is there a possibility (without creating a own IAttributeCollection) to do the reverse - define some ScriptScope hierarchy and get a search logic that searches first in the current scope, if it finds nothing in the parent scope etc.? Rainer From dblank at brynmawr.edu Fri May 23 20:27:40 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Fri, 23 May 2008 14:27:40 -0400 (EDT) Subject: [IronPython] What C# methods do __repr__ and __str__ use? Message-ID: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> I have some C# code that I'm loading in IronPython2B2. What method name and signature do I need to add to a class so that the Python repr(obj) will use it? Likewise, what C# method is used in Python's str(obj)? -Doug -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From antont at kyperjokki.fi Fri May 23 21:37:18 2008 From: antont at kyperjokki.fi (Toni Alatalo) Date: Fri, 23 May 2008 22:37:18 +0300 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> Message-ID: <48371CEE.7080305@kyperjokki.fi> Douglas S. Blank kirjoitti: > will use it? Likewise, what C# method is used in Python's str(obj)? > i don't know, but would guess ToString() .. and wonder about it if it wasn't that but something else :o repr() can't guess, i don't think there's an equivalent in .net, but can very well be mistaken there. > -Doug > ~Toni From jtgalyon at gmail.com Sat May 24 01:59:46 2008 From: jtgalyon at gmail.com (Jason Galyon) Date: Fri, 23 May 2008 18:59:46 -0500 Subject: [IronPython] Using IronPython to introspect and test Assemblies without having the source Message-ID: <48375A72.1070302@gmail.com> I have googled around and there is either no information available or I am using the wrong search terms. I work at a place that has a .NET application and I would like to start whitebox testing of it. However, I currently have no access to the source. Even if I did we have no good changeset system so I would not like to view all changes first and then test. Part of the test would be in fact to detect fatal call chain changes for example. Where can I obtain information about using IronPython to test the assemblies? Thanks, Jason -------------- next part -------------- A non-text attachment was scrubbed... Name: jtgalyon.vcf Type: text/x-vcard Size: 258 bytes Desc: not available URL: From dblank at brynmawr.edu Sat May 24 18:10:43 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Sat, 24 May 2008 12:10:43 -0400 (EDT) Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <48371CEE.7080305@kyperjokki.fi> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> Message-ID: <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: > Douglas S. Blank kirjoitti: >> will use it? Likewise, what C# method is used in Python's str(obj)? >> > > i don't know, but would guess ToString() .. and wonder about it if it > wasn't that but something else :o > repr() can't guess, i don't think there's an equivalent in .net, but can > very well be mistaken there. It looks like the C# method __str__ is used for the Python method, but in IP2B2 the C# method __repr__ is getting overwritten by an auto generated method. Is that a bug, or is there something I'm missing? $ ipy2 -i python/graphics.py >>> pm = Pixmap() >>> pm.getPixel(0,0) # What is this calling? >>> pm.getPixel(0,0).__repr__() # This is repr() too '' >>> pm.getPixel(0,0).__Repr__() # This is mine '' >>> pm.getPixel(0,0).__str__() # That is mine, and str() '' >>> pm.getPixel(0,0).ToString() # Used by __repr__ 'GraphicsCore+Pixel' -Doug >> -Doug >> > > ~Toni > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From fuzzyman at voidspace.org.uk Sat May 24 23:11:11 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 24 May 2008 22:11:11 +0100 Subject: [IronPython] VideoBrush with IronPython and Silverlight Message-ID: <4838846F.8090809@voidspace.org.uk> Hello all, I've been experimenting with using the VideoBrush from IronPython and Silverlight. It works fine from XAML, but the following code shows nothing: from System.Windows import Application from System.Windows.Controls import Canvas #canv = Canvas() #Application.Current.LoadRootVisual(canv, "app.xaml") from System.Windows.Controls import TextBlock, MediaElement from System import Uri, UriKind from System.Windows.Media import VideoBrush, Stretch root = Canvas() video = MediaElement() source = Uri('../SomeVideo.wmv', UriKind.Relative) video.Source = source video.Opacity = 0.0 brush = VideoBrush() brush.Stretch = Stretch.UniformToFill brush.SetSource(video) t = TextBlock() t.Text = 'Video' t.FontSize = 120 t.Foreground = brush root.Children.Add(t) Application.Current.RootVisual = root The XAML that works is: Can anyone see what I'm doing wrong? (Or is this another beta bug.) Thanks Michael Foord http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Sat May 24 23:14:26 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sat, 24 May 2008 22:14:26 +0100 Subject: [IronPython] VideoBrush with IronPython and Silverlight In-Reply-To: <4838846F.8090809@voidspace.org.uk> References: <4838846F.8090809@voidspace.org.uk> Message-ID: <48388532.1050501@voidspace.org.uk> Ha! Worked it out myself. Adding the MediaElement to the Canvas makes it visible... :-) Sorry for the noise... Michael Foord http://www.ironpythoninaction.com/ Michael Foord wrote: > Hello all, > > I've been experimenting with using the VideoBrush from IronPython and > Silverlight. It works fine from XAML, but the following code shows > nothing: > > > from System.Windows import Application > from System.Windows.Controls import Canvas > > #canv = Canvas() > #Application.Current.LoadRootVisual(canv, "app.xaml") > > from System.Windows.Controls import TextBlock, MediaElement > from System import Uri, UriKind > from System.Windows.Media import VideoBrush, Stretch > > root = Canvas() > video = MediaElement() source = Uri('../SomeVideo.wmv', UriKind.Relative) > video.Source = source > video.Opacity = 0.0 > > brush = VideoBrush() > brush.Stretch = Stretch.UniformToFill > brush.SetSource(video) > > t = TextBlock() > t.Text = 'Video' > t.FontSize = 120 > t.Foreground = brush > > root.Children.Add(t) > > Application.Current.RootVisual = root > > > The XAML that works is: > > xmlns="http://schemas.microsoft.com/client/2007" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> > > x:Name="videoMediaElement" > Source="../SomeVideo.wmv" IsMuted="True" > Opacity="0.0" IsHitTestVisible="False" /> > FontFamily="Verdana" FontSize="120" > FontWeight="Bold" TextWrapping="Wrap" > Text="Video"> > > > Stretch="UniformToFill" /> > > > > > > Can anyone see what I'm doing wrong? (Or is this another beta bug.) > > Thanks > > Michael Foord > http://www.ironpythoninaction.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Sun May 25 14:34:28 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 25 May 2008 13:34:28 +0100 Subject: [IronPython] Ironclad Progress Message-ID: <48395CD4.7040709@voidspace.org.uk> William has continued to make good progress on Ironclad. He's just written an import hook (not sure if it is checked in yet, probably not) - this really does allow you to just import C extensions from IronPython: C:\dev\ironclad>ipy IronPython 2.0 Beta (2.0.0.2000) on .NET 2.0.50727.312 Copyright (c) Microsoft Corporation. All rights reserved. >>> import importhook >>> import bz2 >>> bz2.BZ2File.__doc__ "BZ2File(name [, mode='r', buffering=0, compresslevel=9]) -> file object\n\nOpen a bz2 file. The mode can be 'r' or 'w', for reading (default) or\nwriting. When opened for writing, the file will be created if it doesn't\nexist, and truncate d otherwise. If the buffering argument is given, 0 means\nunbuffered, and larger numbers specify the buffer size. If compresslevel\nis given, must be a number b etween 1 and 9.\n\nAdd a 'U' to mode to open the file for input with universal n ewline\nsupport. Any line ending in the input file will be seen as a '\\n' in\nP ython. Also, a file so opened gains the attribute 'newlines'; the value\nfor thi s attribute is one of None (no newline read yet), '\\r', '\\n',\n'\\r\\n' or a t uple containing all the newline types seen. Universal\nnewlines are available on ly when reading.\n" >>> It only works for C extensions that don't use parts of the C Python API that aren't supported by Ironclad yet... But still. :-) Michael Foord http://www.ironpythoninaction.com/ From fuzzyman at voidspace.org.uk Sun May 25 21:16:38 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 25 May 2008 20:16:38 +0100 Subject: [IronPython] Tracing JIT for the DLR Message-ID: <4839BB16.1010603@voidspace.org.uk> Hello guys, Just throwing a wild idea out. :-) PyPy (an interpreter compiler toolchain written in Python) has a tracing JIT that is gradually gaining in capabilities. Similar to the tracing JIT in Tamarin (I believe) it traces types through common code paths and generates specialised code for the common paths and types. This is a great technique for optimising dynamic languages, as although code paths can be taken with different types this is fairly rare. If it does happen, dynamic dispatch can still happen. One interesting consequence of this is that the .NET backend for PyPy (interpreters compiled to run on the .NET framework) can still use the tracing JIT. Although a PyPy compiled interpreter retains the full semantics of the language it implements, it can generate specialised .NET bytecode - using the native .NET types, where it provides a faster path. (A very hazy explanation based on my hazy understanding I'm afraid.) Effectively PyPy compiled interpreters on .NET are double JITTed :-) I wonder if at some point in the future a similar technique could be used to optimise DLR languages. Michael Foord -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ From ben2004uk at googlemail.com Sun May 25 23:55:08 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Sun, 25 May 2008 22:55:08 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build Message-ID: Hello, Posted similar message onto IronRuby but I thought I would also ask you guys. My scenario is that I need to host IronRuby and IronPython within the same application. I thought this would be easy as they both are based on the DLR. However, you both appear to be at different stages of the DLR life and building against different sources. Is this the same internally? At the moment I can't see a way I can build both IronPython and IronRuby from the same DLR assemblies? At some point, I take it the DLR will merge into a single release and known assembly for other language providers and hosts to use instead of multiple different versions? In the mean time - what can I do? Is anyone doing this? Thanks Ben Blog.BenHall.me.uk From fuzzyman at voidspace.org.uk Sun May 25 23:58:22 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Sun, 25 May 2008 22:58:22 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: References: Message-ID: <4839E0FE.6000407@voidspace.org.uk> Hello Ben, I don't have an answer, just to say that I have the same problem. For our 'Dynamic Script Control' project we would like to develop (and test with) for both IronPython and IronRuby. This makes project structure "problematic". I realise that at some point this will be a non-problem, but in the meantime if anyone has any good ideas I'd like to hear them... Michael Foord Ben Hall wrote: > Hello, > > Posted similar message onto IronRuby but I thought I would also ask > you guys. My scenario is that I need to host IronRuby and IronPython > within the same application. I thought this would be easy as they both > are based on the DLR. > > However, you both appear to be at different stages of the DLR life and > building against different sources. Is this the same internally? At > the moment I can't see a way I can build both IronPython and IronRuby > from the same DLR assemblies? > > At some point, I take it the DLR will merge into a single release and > known assembly for other language providers and hosts to use instead > of multiple different versions? > > In the mean time - what can I do? Is anyone doing this? > > Thanks > > Ben > Blog.BenHall.me.uk > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ From ivan at flanders.co.nz Mon May 26 00:56:22 2008 From: ivan at flanders.co.nz (Ivan Porto Carrero) Date: Mon, 26 May 2008 10:56:22 +1200 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: <4839E0FE.6000407@voidspace.org.uk> References: <4839E0FE.6000407@voidspace.org.uk> Message-ID: <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> You could treat it like plugins. that is have a rubybin folder and a pythonbin folder Load the correct assemblies in a different appdomain execute your code there and get the result back. For Michael this idea isn't new :) I'll that later this week in our dynamic script control to see how that works out. Any other more simple and elegant solutions are welcome of course Cheers Ivan On 26/05/2008, at 9:58 AM, Michael Foord wrote: > Hello Ben, > > I don't have an answer, just to say that I have the same problem. > > For our 'Dynamic Script Control' project we would like to develop > (and test with) for both IronPython and IronRuby. > > This makes project structure "problematic". > > I realise that at some point this will be a non-problem, but in the > meantime if anyone has any good ideas I'd like to hear them... > > Michael Foord > > > > Ben Hall wrote: >> Hello, >> >> Posted similar message onto IronRuby but I thought I would also ask >> you guys. My scenario is that I need to host IronRuby and IronPython >> within the same application. I thought this would be easy as they >> both >> are based on the DLR. >> >> However, you both appear to be at different stages of the DLR life >> and >> building against different sources. Is this the same internally? At >> the moment I can't see a way I can build both IronPython and IronRuby >> from the same DLR assemblies? >> >> At some point, I take it the DLR will merge into a single release and >> known assembly for other language providers and hosts to use instead >> of multiple different versions? >> >> In the mean time - what can I do? Is anyone doing this? >> >> Thanks >> >> Ben >> Blog.BenHall.me.uk >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > -- > http://www.ironpythoninaction.com/ > http://www.theotherdelia.co.uk/ > http://www.voidspace.org.uk/ > http://www.ironpython.info/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Mon May 26 01:00:40 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Mon, 26 May 2008 00:00:40 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> References: <4839E0FE.6000407@voidspace.org.uk> <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> Message-ID: <4839EF98.1040805@voidspace.org.uk> Ivan Porto Carrero wrote: > You could treat it like plugins. > > that is have a rubybin folder and a pythonbin folder > > Load the correct assemblies in a different appdomain execute your code > there and get the result back. > > For Michael this idea isn't new :) I'll that later this week in our > dynamic script control to see how that works out. > Any other more simple and elegant solutions are welcome of course > That sounds like it might work - but it sounds like a complex solution to a problem that will eventually go away (at least in our case). What we need effectively are two projects linked to different binaries, but sharing a single set of core code. Visual Studio probably doesn't support this as a project structure - but creating a build script that invokes the compiler to generate two binary sets from a single source set should be easy enough. Michael Foord > Cheers > Ivan > > On 26/05/2008, at 9:58 AM, Michael Foord wrote: > >> Hello Ben, >> >> I don't have an answer, just to say that I have the same problem. >> >> For our 'Dynamic Script Control' project we would like to develop >> (and test with) for both IronPython and IronRuby. >> >> This makes project structure "problematic". >> >> I realise that at some point this will be a non-problem, but in the >> meantime if anyone has any good ideas I'd like to hear them... >> >> Michael Foord >> >> >> >> Ben Hall wrote: >>> Hello, >>> >>> Posted similar message onto IronRuby but I thought I would also ask >>> you guys. My scenario is that I need to host IronRuby and IronPython >>> within the same application. I thought this would be easy as they both >>> are based on the DLR. >>> >>> However, you both appear to be at different stages of the DLR life and >>> building against different sources. Is this the same internally? At >>> the moment I can't see a way I can build both IronPython and IronRuby >>> from the same DLR assemblies? >>> >>> At some point, I take it the DLR will merge into a single release and >>> known assembly for other language providers and hosts to use instead >>> of multiple different versions? >>> >>> In the mean time - what can I do? Is anyone doing this? >>> >>> Thanks >>> >>> Ben >>> Blog.BenHall.me.uk >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> -- >> http://www.ironpythoninaction.com/ >> http://www.theotherdelia.co.uk/ >> http://www.voidspace.org.uk/ >> http://www.ironpython.info/ >> >> _______________________________________________ >> 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.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ From ben2004uk at googlemail.com Mon May 26 01:26:11 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Mon, 26 May 2008 00:26:11 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> References: <4839E0FE.6000407@voidspace.org.uk> <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> Message-ID: Hi Ivan, I think this would only work if you completely abstract away from the DLR. My initial problem with that is this: Main AppDomain references 1.0.0.2000 to use ScriptRuntime etc IPAppDom refereences 1.0.0.2000. Crossing AppDomain boundaries isn't a problem because they are the same version. RubyAppDoman references 1.0.0.0. When you have to pass your ScriptRuntime (Engine, Scope whatever) back to the main appdomain I think it will throw an exception. Not having used AppDomains in a long time I might be wrong :) Ben On Sun, May 25, 2008 at 11:56 PM, Ivan Porto Carrero wrote: > You could treat it like plugins. > > that is have a rubybin folder and a pythonbin folder > > Load the correct assemblies in a different appdomain execute your code there > and get the result back. > > For Michael this idea isn't new :) I'll that later this week in our dynamic > script control to see how that works out. > Any other more simple and elegant solutions are welcome of course > > Cheers > Ivan > > On 26/05/2008, at 9:58 AM, Michael Foord wrote: > >> Hello Ben, >> >> I don't have an answer, just to say that I have the same problem. >> >> For our 'Dynamic Script Control' project we would like to develop (and >> test with) for both IronPython and IronRuby. >> >> This makes project structure "problematic". >> >> I realise that at some point this will be a non-problem, but in the >> meantime if anyone has any good ideas I'd like to hear them... >> >> Michael Foord >> >> >> >> Ben Hall wrote: >>> >>> Hello, >>> >>> Posted similar message onto IronRuby but I thought I would also ask >>> you guys. My scenario is that I need to host IronRuby and IronPython >>> within the same application. I thought this would be easy as they both >>> are based on the DLR. >>> >>> However, you both appear to be at different stages of the DLR life and >>> building against different sources. Is this the same internally? At >>> the moment I can't see a way I can build both IronPython and IronRuby >>> from the same DLR assemblies? >>> >>> At some point, I take it the DLR will merge into a single release and >>> known assembly for other language providers and hosts to use instead >>> of multiple different versions? >>> >>> In the mean time - what can I do? Is anyone doing this? >>> >>> Thanks >>> >>> Ben >>> Blog.BenHall.me.uk >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> -- >> http://www.ironpythoninaction.com/ >> http://www.theotherdelia.co.uk/ >> http://www.voidspace.org.uk/ >> http://www.ironpython.info/ >> >> _______________________________________________ >> 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 ivan at flanders.co.nz Mon May 26 02:24:07 2008 From: ivan at flanders.co.nz (Ivan Porto Carrero) Date: Mon, 26 May 2008 12:24:07 +1200 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: <4839EF98.1040805@voidspace.org.uk> References: <4839E0FE.6000407@voidspace.org.uk> <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> <4839EF98.1040805@voidspace.org.uk> Message-ID: In our case we can just create 2 project files and link the code files in there.. so we edit 1 file but depending on which project you choose to build it will build with different references. After all a vs project file is just an msbuild script :) On 26/05/2008, at 11:00 AM, Michael Foord wrote: > Ivan Porto Carrero wrote: >> You could treat it like plugins. >> >> that is have a rubybin folder and a pythonbin folder >> >> Load the correct assemblies in a different appdomain execute your >> code there and get the result back. >> >> For Michael this idea isn't new :) I'll that later this week in our >> dynamic script control to see how that works out. >> Any other more simple and elegant solutions are welcome of course >> > > That sounds like it might work - but it sounds like a complex > solution to a problem that will eventually go away (at least in our > case). > > What we need effectively are two projects linked to different > binaries, but sharing a single set of core code. > > Visual Studio probably doesn't support this as a project structure - > but creating a build script that invokes the compiler to generate > two binary sets from a single source set should be easy enough. > > Michael Foord > > >> Cheers >> Ivan >> >> On 26/05/2008, at 9:58 AM, Michael Foord wrote: >> >>> Hello Ben, >>> >>> I don't have an answer, just to say that I have the same problem. >>> >>> For our 'Dynamic Script Control' project we would like to develop >>> (and test with) for both IronPython and IronRuby. >>> >>> This makes project structure "problematic". >>> >>> I realise that at some point this will be a non-problem, but in >>> the meantime if anyone has any good ideas I'd like to hear them... >>> >>> Michael Foord >>> >>> >>> >>> Ben Hall wrote: >>>> Hello, >>>> >>>> Posted similar message onto IronRuby but I thought I would also ask >>>> you guys. My scenario is that I need to host IronRuby and >>>> IronPython >>>> within the same application. I thought this would be easy as they >>>> both >>>> are based on the DLR. >>>> >>>> However, you both appear to be at different stages of the DLR >>>> life and >>>> building against different sources. Is this the same internally? >>>> At >>>> the moment I can't see a way I can build both IronPython and >>>> IronRuby >>>> from the same DLR assemblies? >>>> >>>> At some point, I take it the DLR will merge into a single release >>>> and >>>> known assembly for other language providers and hosts to use >>>> instead >>>> of multiple different versions? >>>> >>>> In the mean time - what can I do? Is anyone doing this? >>>> >>>> Thanks >>>> >>>> Ben >>>> Blog.BenHall.me.uk >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> -- >>> http://www.ironpythoninaction.com/ >>> http://www.theotherdelia.co.uk/ >>> http://www.voidspace.org.uk/ >>> http://www.ironpython.info/ >>> >>> _______________________________________________ >>> 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.theotherdelia.co.uk/ > http://www.voidspace.org.uk/ > http://www.ironpython.info/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From ben2004uk at googlemail.com Mon May 26 02:36:08 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Mon, 26 May 2008 01:36:08 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: References: <4839E0FE.6000407@voidspace.org.uk> <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> <4839EF98.1040805@voidspace.org.uk> Message-ID: Ahh! I'm too dependent on the DLR in my UI for that I think. Maybe I could re-work certain parts.... Ben On Mon, May 26, 2008 at 1:24 AM, Ivan Porto Carrero wrote: > In our case we can just create 2 project files and link the code files in > there.. so we edit 1 file but depending on which project you choose to build > it will build with different references. After all a vs project file is just > an msbuild script :) > > > On 26/05/2008, at 11:00 AM, Michael Foord wrote: > >> Ivan Porto Carrero wrote: >>> >>> You could treat it like plugins. >>> >>> that is have a rubybin folder and a pythonbin folder >>> >>> Load the correct assemblies in a different appdomain execute your code >>> there and get the result back. >>> >>> For Michael this idea isn't new :) I'll that later this week in our >>> dynamic script control to see how that works out. >>> Any other more simple and elegant solutions are welcome of course >>> >> >> That sounds like it might work - but it sounds like a complex solution to >> a problem that will eventually go away (at least in our case). >> >> What we need effectively are two projects linked to different binaries, >> but sharing a single set of core code. >> >> Visual Studio probably doesn't support this as a project structure - but >> creating a build script that invokes the compiler to generate two binary >> sets from a single source set should be easy enough. >> >> Michael Foord >> >> >>> Cheers >>> Ivan >>> >>> On 26/05/2008, at 9:58 AM, Michael Foord wrote: >>> >>>> Hello Ben, >>>> >>>> I don't have an answer, just to say that I have the same problem. >>>> >>>> For our 'Dynamic Script Control' project we would like to develop (and >>>> test with) for both IronPython and IronRuby. >>>> >>>> This makes project structure "problematic". >>>> >>>> I realise that at some point this will be a non-problem, but in the >>>> meantime if anyone has any good ideas I'd like to hear them... >>>> >>>> Michael Foord >>>> >>>> >>>> >>>> Ben Hall wrote: >>>>> >>>>> Hello, >>>>> >>>>> Posted similar message onto IronRuby but I thought I would also ask >>>>> you guys. My scenario is that I need to host IronRuby and IronPython >>>>> within the same application. I thought this would be easy as they both >>>>> are based on the DLR. >>>>> >>>>> However, you both appear to be at different stages of the DLR life and >>>>> building against different sources. Is this the same internally? At >>>>> the moment I can't see a way I can build both IronPython and IronRuby >>>>> from the same DLR assemblies? >>>>> >>>>> At some point, I take it the DLR will merge into a single release and >>>>> known assembly for other language providers and hosts to use instead >>>>> of multiple different versions? >>>>> >>>>> In the mean time - what can I do? Is anyone doing this? >>>>> >>>>> Thanks >>>>> >>>>> Ben >>>>> Blog.BenHall.me.uk >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>> >>>> >>>> -- >>>> http://www.ironpythoninaction.com/ >>>> http://www.theotherdelia.co.uk/ >>>> http://www.voidspace.org.uk/ >>>> http://www.ironpython.info/ >>>> >>>> _______________________________________________ >>>> 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.theotherdelia.co.uk/ >> http://www.voidspace.org.uk/ >> http://www.ironpython.info/ >> >> _______________________________________________ >> 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 ivan at flanders.co.nz Mon May 26 02:37:40 2008 From: ivan at flanders.co.nz (Ivan Porto Carrero) Date: Mon, 26 May 2008 12:37:40 +1200 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: References: <4839E0FE.6000407@voidspace.org.uk> <45065C4D-81F8-44A8-B90F-163EFCAC6790@flanders.co.nz> Message-ID: <916982CD-B10B-44F7-A3EA-4DCF4860790A@flanders.co.nz> You can load different versions of assemblies in a different appdomain. The question is what do you pass the main appdomain back. Are you going to pass it back a DLR component or are you just going to pass back the clr object that is the result of your script.. because my guess would be that a CLR object would be just fine but a DLR object might pose some problems. Mind you I'm just guessing here I haven't tested any of this, except for loading different version of assemblies in appdomains. I would think you could pass it the script string or path and then get the clr type back from the execution in the main app domain. And I also haven't tested yet wheter you can actually call properties and methods on a DLR object if it isn't known before in the CLR. And as Michael said before it smells :) It feels very wrong to me to have to do this and I've been known to say things like _ why? because I can._ I just think this isn't one of those cases. Cheers Ivan On 26/05/2008, at 11:26 AM, Ben Hall wrote: > Hi Ivan, > > I think this would only work if you completely abstract away from > the DLR. > > My initial problem with that is this: > > Main AppDomain references 1.0.0.2000 to use ScriptRuntime etc > > IPAppDom refereences 1.0.0.2000. Crossing AppDomain boundaries isn't > a problem because they are the same version. > > RubyAppDoman references 1.0.0.0. When you have to pass your > ScriptRuntime (Engine, Scope whatever) back to the main appdomain I > think it will throw an exception. > > Not having used AppDomains in a long time I might be wrong :) > > Ben > On Sun, May 25, 2008 at 11:56 PM, Ivan Porto Carrero > wrote: >> You could treat it like plugins. >> >> that is have a rubybin folder and a pythonbin folder >> >> Load the correct assemblies in a different appdomain execute your >> code there >> and get the result back. >> >> For Michael this idea isn't new :) I'll that later this week in our >> dynamic >> script control to see how that works out. >> Any other more simple and elegant solutions are welcome of course >> >> Cheers >> Ivan >> >> On 26/05/2008, at 9:58 AM, Michael Foord wrote: >> >>> Hello Ben, >>> >>> I don't have an answer, just to say that I have the same problem. >>> >>> For our 'Dynamic Script Control' project we would like to develop >>> (and >>> test with) for both IronPython and IronRuby. >>> >>> This makes project structure "problematic". >>> >>> I realise that at some point this will be a non-problem, but in the >>> meantime if anyone has any good ideas I'd like to hear them... >>> >>> Michael Foord >>> >>> >>> >>> Ben Hall wrote: >>>> >>>> Hello, >>>> >>>> Posted similar message onto IronRuby but I thought I would also ask >>>> you guys. My scenario is that I need to host IronRuby and >>>> IronPython >>>> within the same application. I thought this would be easy as they >>>> both >>>> are based on the DLR. >>>> >>>> However, you both appear to be at different stages of the DLR >>>> life and >>>> building against different sources. Is this the same internally? >>>> At >>>> the moment I can't see a way I can build both IronPython and >>>> IronRuby >>>> from the same DLR assemblies? >>>> >>>> At some point, I take it the DLR will merge into a single release >>>> and >>>> known assembly for other language providers and hosts to use >>>> instead >>>> of multiple different versions? >>>> >>>> In the mean time - what can I do? Is anyone doing this? >>>> >>>> Thanks >>>> >>>> Ben >>>> Blog.BenHall.me.uk >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> -- >>> http://www.ironpythoninaction.com/ >>> http://www.theotherdelia.co.uk/ >>> http://www.voidspace.org.uk/ >>> http://www.ironpython.info/ >>> >>> _______________________________________________ >>> 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 greg.parker at brovada.com Mon May 26 17:54:04 2008 From: greg.parker at brovada.com (Greg Parker) Date: Mon, 26 May 2008 12:54:04 -0300 Subject: [IronPython] Statefulness of CompiledCode Message-ID: <483ADD1C.1020409@brovada.com> I am currently involved in a project that is using IronPython. I am surprised by an issue that has popped up recently during testing. To efficiently process data as it arrives we have compiled the python script into a CompiledCode object once at startup. Every time we need to process incoming data we simply call execute on the CompiledCode instance after setting up some global attributes. The problem is that the CompiledCode instance seems to be stateful. Certain class variables, et cetera, are retaining their values from one call to execute to the next. Is this desired behavior? If so, how should I be handling this? I did attempt to create a brand new PythonEngine instance to service each transaction, but this seemed to leak memory very badly, and eventually crashed the entire application. Here is a condensed version of the python script to illustrate the problem. I run this from a C# application which executes the CompiledCode ten times. When the length of "fooListClassVariable" is printed, it increases to ten. I would have expected to see one for every iteration. ----SomeInclude.py------------------------ class SomeClass: fooListClassVariable = []; def AddFoo(self): self.fooListClassVariable.append("foo") print str(len(self.fooListClassVariable)) ----Program.py-------------------------- from SomeInclude import SomeClass SomeClass().AddFoo() ---- C# Application--------------------- pyEngine = new PythonEngine(); String py = LoadMyScript("Program.py")); compiledScript = pyEngine.Compile(py); for (int i = 0; i < 10; i++) { compiledScript.Execute(); } From sanxiyn at gmail.com Mon May 26 18:39:14 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Tue, 27 May 2008 01:39:14 +0900 Subject: [IronPython] Statefulness of CompiledCode In-Reply-To: <483ADD1C.1020409@brovada.com> References: <483ADD1C.1020409@brovada.com> Message-ID: <5b0248170805260939q2a7085eaoeea791889747392b@mail.gmail.com> 2008/5/27 Greg Parker : > Here is a condensed version of the python script to illustrate the problem. > I run this from a C# application which executes the CompiledCode ten times. > When the length of "fooListClassVariable" is printed, it increases to ten. > I would have expected to see one for every iteration. > > ----SomeInclude.py------------------------ > class SomeClass: > fooListClassVariable = []; > def AddFoo(self): > self.fooListClassVariable.append("foo") > print str(len(self.fooListClassVariable)) If you want to see 1 printed for every iteration, do: class SomeClass: def __init__(self): self.fooListClassVariable = [] etc. You want it to be an instance variable (which is initialized every time new instance is created), not a class variable (which is shared by all instances of the class). -- Seo Sanghyeon From greg.parker at brovada.com Mon May 26 18:56:32 2008 From: greg.parker at brovada.com (Greg Parker) Date: Mon, 26 May 2008 13:56:32 -0300 Subject: [IronPython] Statefulness of CompiledCode In-Reply-To: <5b0248170805260939q2a7085eaoeea791889747392b@mail.gmail.com> References: <483ADD1C.1020409@brovada.com> <5b0248170805260939q2a7085eaoeea791889747392b@mail.gmail.com> Message-ID: <483AEBC0.4070901@brovada.com> Actually I do want a class variable as I described. By design "fooListClassVariable" should be shared for all instances of "SomeClass" during one execution. However, I don't want it to remember the value on subsequent calls to "compiledScript.Execute()", which is what is happening. I would expect that every time I execute the CompiledCode it would not retain any state information about the last time it was executed. This would be sort of like executing a c# application twice, and seeing class variables initialized to the values from the first execution. Maybe I am misusing the CompiledCode class. > If you want to see 1 printed for every iteration, do: > > class SomeClass: > def __init__(self): > self.fooListClassVariable = [] > > etc. You want it to be an instance variable (which is initialized > every time new instance is created), not a class variable (which is > shared by all instances of the class). > > From lists.ironpython.com at ka.weltenschmiede.com Mon May 26 19:43:58 2008 From: lists.ironpython.com at ka.weltenschmiede.com (Korbinian Abenthum) Date: Mon, 26 May 2008 19:43:58 +0200 Subject: [IronPython] Statefulness of CompiledCode References: <483ADD1C.1020409@brovada.com> Message-ID: <004101c8bf58_135ae390_14b2a8c0@lannisport> Greg Parker wrote: > for (int i = 0; i < 10; i++) { > compiledScript.Execute(); > } AFAIK the import statement creates a new Scope for the imported module that lives in parallel to the ScriptScope passed to Execute (in IP2, I don't know about 1.1). Since import will check if the module was imported before, it is only imported during the first iteration and the class variable of SomeClass will persist during all you calls to Execute. It should work to "import SomeInclude; reload(SomeInclude)" at the beginning or end of each execution. On the C# side, if I add python.Runtime.Globals.ClearVariables(); before or after each call to execute, it removes the (references to the) imported scopes and will load them anew during the next execution, but I do not know if this is the cleanest way to do so. | ScriptEngine python = IronPython.Hosting.PythonEngine.CurrentEngine; | CompiledCode compiledCode = python.CreateScriptSourceFromFile("Program.py").Compile(); | ScriptScope scope = python.CreateScope(); | | for (int i = 0; i < 10; i++) | { | compiledCode.Execute(scope); | python.Runtime.Globals.ClearVariables(); | } From greg.parker at brovada.com Mon May 26 20:12:09 2008 From: greg.parker at brovada.com (Greg Parker) Date: Mon, 26 May 2008 15:12:09 -0300 Subject: [IronPython] Statefulness of CompiledCode In-Reply-To: <004101c8bf58_135ae390_14b2a8c0@lannisport> References: <483ADD1C.1020409@brovada.com> <004101c8bf58_135ae390_14b2a8c0@lannisport> Message-ID: <483AFD79.5030702@brovada.com> Thanks for the suggestions. I tried the reload statement in the python script itself. I executed the same application in a tight loop about 1000 times. The VM Size skyrocketed to ~500M (without the reload it stays at ~16M). So this doesn't look like an option for me, especially since the actual script we are trying to run is much larger and more complicated. As for changes to the C# code, in 1.1 if I try to clear the globals I just get an exception ('module' object has no attribute '__builtins__'). So am I better off just using the latest 2.0 build? Which frameworks does it run on? Thanks again Korbinian Abenthum wrote: > AFAIK the import statement creates a new Scope for the imported module > that lives in parallel to the ScriptScope passed to Execute (in IP2, I > don't know about 1.1). Since import will check if the module was > imported before, it is only imported during the first iteration and > the class variable of SomeClass will persist during all you calls to > Execute. > > It should work to "import SomeInclude; reload(SomeInclude)" at the > beginning or end of each execution. On the C# side, if I add > python.Runtime.Globals.ClearVariables(); > before or after each call to execute, it removes the (references to > the) imported scopes and will load them anew during the next execution, > but I do not know if this is the cleanest way to do so. > > | ScriptEngine python = IronPython.Hosting.PythonEngine.CurrentEngine; > | CompiledCode compiledCode = > python.CreateScriptSourceFromFile("Program.py").Compile(); > | ScriptScope scope = python.CreateScope(); > | | for (int i = 0; i < 10; i++) > | { > | compiledCode.Execute(scope); > | python.Runtime.Globals.ClearVariables(); > | } > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From lists.ironpython.com at ka.weltenschmiede.com Mon May 26 20:46:26 2008 From: lists.ironpython.com at ka.weltenschmiede.com (Korbinian Abenthum) Date: Mon, 26 May 2008 20:46:26 +0200 Subject: [IronPython] Statefulness of CompiledCode References: <483ADD1C.1020409@brovada.com><004101c8bf58_135ae390_14b2a8c0@lannisport> <483AFD79.5030702@brovada.com> Message-ID: <00d401c8bf60_cdf61000_14b2a8c0@lannisport> Greg Parker wrote: > I executed the same application in > a tight loop about 1000 times. The VM Size skyrocketed to > ~500M (without the reload it stays at ~16M). So this doesn't > look like an option for me, especially since the actual script > we are trying to run is much larger and more complicated. As > for changes to the C# code, in 1.1 if I try to clear the > globals I just get an exception ('module' object has no > attribute '__builtins__'). So am I better off just using the > latest 2.0 build? That has the same problem I'm afraid. Apparently the memory is lost during the repeated compilation of SomeScript.py. If I compile it only once and do the import manually, | ScriptEngine python = IronPython.Hosting.PythonEngine.CurrentEngine; | CompiledCode compiledCode = python.CreateScriptSourceFromFile("Program.py").Compile(); | CompiledCode compiledCodeSomeInclude = python.CreateScriptSourceFromFile("SomeInclude.py").Compile(); | | ScriptScope scope = python.CreateScope(); | for (int i = 0; i < 5000; i++) | { | ScriptScope scopeSomeInclude = python.CreateScope(); | compiledCodeSomeInclude.Execute(scopeSomeInclude); | python.Runtime.Globals.SetVariable("SomeInclude", scopeSomeInclude); | | compiledCode.Execute(scope); | } the memory usage remains constant (and it's a whole lot faster). I have no idea how that can be done in 1.1, or if it has side effects I'm not aware of. And if you have complex import chains then this solution might not translate very well to your problem in the first place. HTH anyway. From joesox at gmail.com Tue May 27 00:45:00 2008 From: joesox at gmail.com (JoeSox) Date: Mon, 26 May 2008 15:45:00 -0700 Subject: [IronPython] Redirecting input/output in IronPython 2.x In-Reply-To: <7AD436E4270DD54A94238001769C22270124ED7FF83F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <320411.79349.qm@web30808.mail.mud.yahoo.com> <7AD436E4270DD54A94238001769C22270124ED7FF83F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <785694cd0805261545o6be3b8b4k612968014a3fd395@mail.gmail.com> Dino, This way is not playing well with an overriding System.IO.Stream class I have written. I set SetOutput with this class which has a delegate listening for the output. I do 'source.Execute(scope);' but it doesn't seem to be doing the same thing as ExecuteToConsole (flushing). Any ideas on what the difference is? In IP1.1 I used to use ExecuteToConsole and the output stream was updated. Here is some of the basic code I am using to give some better idea on what I am talking about: ------------------------------------- public ScriptEngine engine = ScriptRuntime.Create().GetEngine("py"); public ScriptScope scope; scope = engine.CreateScope(); //IPEStreamWrapper:Stream, and take delegate IPEngineResponse engine.Runtime.IO.SetOutput(new ITB2.IPEWrapper.IPEStreamWrapper(IPEWrapper.IPEStreamWrapper.IPEngineResponse), engine.Runtime.IO.InputEncoding); ScriptSource source = engine.CreateScriptSourceFromString(command, SourceCodeKind.Expression); object o = source.Execute(scope); IPEStreamWrapper.sbOutput.ToString(); //nothing, I don't see any MemoryStream Flushing in IPEStreamWrapper Stream class ------------------------------------- Thanks, Joe On 4/17/08, Dino Viehland wrote: > > > > You want > ScriptRuntime.IO.SetOutput/ScriptRuntime.IO.SetError which > will let you set the I/O used for all the ScriptEngine's running in the > given ScriptRuntime. You also now need to provide either a Stream and an > Encoding or a Stream and a TextWriter. The reason for that is to support > both text and binary output for scenarios such as PHP wanting to print a > JPG. > > > > > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of > David Seruyange > Sent: Thursday, April 17, 2008 10:59 AM > To: IronPython IronPython > Subject: [IronPython] Redirecting input/output in IronPython 2.x > > > > > > Hey everyone, > > looking at a lot of the samples online I see the following: > > pythonEngine.SetStandardError(s); > pythonEngine.SetStandardOutput(s); > > > where s is some stream. The Python Engine doesn't seem to support that > method when I make a reference to IronPython 2.0. Am I missing something or > are the online resources now obsolete? > > Thanks much - > > David > > > ________________________________ > > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > -- Later, JoeSox "To perceive is to suffer." - Aristotle From sls at iinet.net.au Tue May 27 01:48:03 2008 From: sls at iinet.net.au (Paul Turbett) Date: Tue, 27 May 2008 07:48:03 +0800 Subject: [IronPython] Redirecting input/output in IronPython 2.x In-Reply-To: <785694cd0805261545o6be3b8b4k612968014a3fd395@mail.gmail.com> References: <320411.79349.qm@web30808.mail.mud.yahoo.com> <7AD436E4270DD54A94238001769C22270124ED7FF83F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <785694cd0805261545o6be3b8b4k612968014a3fd395@mail.gmail.com> Message-ID: <483B4C33.5090905@iinet.net.au> Try SourceCodeKind.SingleStatement in the call to CreateScriptScopeFromString. L8r, Paul JoeSox wrote: > Dino, > > This way is not playing well with an overriding System.IO.Stream class > I have written. I set SetOutput with this class which has a delegate > listening for the output. I do 'source.Execute(scope);' but it doesn't > seem to be doing the same thing as ExecuteToConsole (flushing). Any > ideas on what the difference is? > In IP1.1 I used to use ExecuteToConsole and the output stream was updated. > > Here is some of the basic code I am using to give some better idea on > what I am talking about: > ------------------------------------- > public ScriptEngine engine = ScriptRuntime.Create().GetEngine("py"); > public ScriptScope scope; > scope = engine.CreateScope(); > > //IPEStreamWrapper:Stream, and take delegate IPEngineResponse > engine.Runtime.IO.SetOutput(new > ITB2.IPEWrapper.IPEStreamWrapper(IPEWrapper.IPEStreamWrapper.IPEngineResponse), > engine.Runtime.IO.InputEncoding); > > ScriptSource source = engine.CreateScriptSourceFromString(command, > SourceCodeKind.Expression); > object o = source.Execute(scope); > > IPEStreamWrapper.sbOutput.ToString(); //nothing, I don't see any > MemoryStream Flushing in IPEStreamWrapper Stream class > ------------------------------------- > > Thanks, Joe > > On 4/17/08, Dino Viehland wrote: > >> >> You want >> ScriptRuntime.IO.SetOutput/ScriptRuntime.IO.SetError which >> will let you set the I/O used for all the ScriptEngine's running in the >> given ScriptRuntime. You also now need to provide either a Stream and an >> Encoding or a Stream and a TextWriter. The reason for that is to support >> both text and binary output for scenarios such as PHP wanting to print a >> JPG. >> >> >> >> >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of >> David Seruyange >> Sent: Thursday, April 17, 2008 10:59 AM >> To: IronPython IronPython >> Subject: [IronPython] Redirecting input/output in IronPython 2.x >> >> >> >> >> >> Hey everyone, >> >> looking at a lot of the samples online I see the following: >> >> pythonEngine.SetStandardError(s); >> >> > pythonEngine.SetStandardOutput(s); > >> where s is some stream. The Python Engine doesn't seem to support that >> method when I make a reference to IronPython 2.0. Am I missing something or >> are the online resources now obsolete? >> >> Thanks much - >> >> David >> >> >> ________________________________ >> >> >> Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it >> now. >> _______________________________________________ >> 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 joesox at gmail.com Tue May 27 01:58:22 2008 From: joesox at gmail.com (JoeSox) Date: Mon, 26 May 2008 16:58:22 -0700 Subject: [IronPython] Redirecting input/output in IronPython 2.x In-Reply-To: <483B4C33.5090905@iinet.net.au> References: <320411.79349.qm@web30808.mail.mud.yahoo.com> <7AD436E4270DD54A94238001769C22270124ED7FF83F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <785694cd0805261545o6be3b8b4k612968014a3fd395@mail.gmail.com> <483B4C33.5090905@iinet.net.au> Message-ID: <785694cd0805261658t44da2723w1f4f8a20dd4a5bd3@mail.gmail.com> Sweet, that appears to have worked. Thanks! -Joe On 5/26/08, Paul Turbett wrote: > Try SourceCodeKind.SingleStatement in the call to > CreateScriptScopeFromString. > > L8r, Paul > > > JoeSox wrote: > Dino, This way is not playing well with an overriding System.IO.Stream > class I have written. I set SetOutput with this class which has a > delegate listening for the output. I do 'source.Execute(scope);' but it > doesn't seem to be doing the same thing as ExecuteToConsole (flushing). > Any ideas on what the difference is? In IP1.1 I used to use ExecuteToConsole > and the output stream was updated. Here is some of the basic code I am > using to give some better idea on what I am talking > about: ------------------------------------- public > ScriptEngine engine = > ScriptRuntime.Create().GetEngine("py"); public ScriptScope > scope; scope = engine.CreateScope(); //IPEStreamWrapper:Stream, and take > delegate > IPEngineResponse engine.Runtime.IO.SetOutput(new ITB2.IPEWrapper.IPEStreamWrapper(IPEWrapper.IPEStreamWrapper.IPEngineResponse), engine.Runtime.IO.InputEncoding); > ScriptSource source = > engine.CreateScriptSourceFromString(command, SourceCodeKind.Expression); object > o = > source.Execute(scope); IPEStreamWrapper.sbOutput.ToString(); > //nothing, I don't see any MemoryStream Flushing in IPEStreamWrapper Stream > class ------------------------------------- Thanks, > Joe On 4/17/08, Dino Viehland wrote: > You > want ScriptRuntime.IO.SetOutput/ScriptRuntime.IO.SetError > which will let you set the I/O used for all the ScriptEngine's running in > the given ScriptRuntime. You also now need to provide either a Stream and > an Encoding or a Stream and a TextWriter. The reason for that is to > support both text and binary output for scenarios such as PHP wanting to > print a JPG. From: > users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] > On Behalf Of David Seruyange Sent: Thursday, April 17, 2008 10:59 AM To: > IronPython IronPython Subject: [IronPython] Redirecting input/output in > IronPython 2.x Hey everyone, looking at a lot of the samples online I > see the following: pythonEngine.SetStandardError(s); > pythonEngine.SetStandardOutput(s); > where s is some stream. The Python Engine doesn't seem to support > that method when I make a reference to IronPython 2.0. Am I missing > something or are the online resources now obsolete? Thanks much > - David ________________________________ Be a better > friend, newshound, and know-it-all with Yahoo! Mobile. Try > it now. _______________________________________________ Users > mailing > list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From kfarmer at thuban.org Tue May 27 05:33:52 2008 From: kfarmer at thuban.org (Keith J. Farmer) Date: Mon, 26 May 2008 20:33:52 -0700 Subject: [IronPython] Statefulness of CompiledCode In-Reply-To: <483AEBC0.4070901@brovada.com> References: <483ADD1C.1020409@brovada.com><5b0248170805260939q2a7085eaoeea791889747392b@mail.gmail.com> <483AEBC0.4070901@brovada.com> Message-ID: So what you want is a script initializer, right? Try clearing SomeClass.fooListClassVariable at the start of your script. I haven't used the CompiledCode feature, but from the looks of it, the script you get is bound to an engine which defines the execution scope. IMHO, what you're seeing is the correct behavior. You're executing some pre-compiled block of code multiple times against the same engine; it follows that execution would be stateful in this case. This isn't like executing the same application multiple times, since *that* involves a different process each time. Instead, you're executing the same delegate method multiple times within a single process. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Greg Parker Sent: Monday, May 26, 2008 9:57 AM To: Discussion of IronPython Subject: Re: [IronPython] Statefulness of CompiledCode Actually I do want a class variable as I described. By design "fooListClassVariable" should be shared for all instances of "SomeClass" during one execution. However, I don't want it to remember the value on subsequent calls to "compiledScript.Execute()", which is what is happening. I would expect that every time I execute the CompiledCode it would not retain any state information about the last time it was executed. This would be sort of like executing a c# application twice, and seeing class variables initialized to the values from the first execution. Maybe I am misusing the CompiledCode class. > If you want to see 1 printed for every iteration, do: > > class SomeClass: > def __init__(self): > self.fooListClassVariable = [] > > etc. You want it to be an instance variable (which is initialized > every time new instance is created), not a class variable (which is > shared by all instances of the class). > > _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From joesox at gmail.com Tue May 27 08:36:45 2008 From: joesox at gmail.com (JoeSox) Date: Mon, 26 May 2008 23:36:45 -0700 Subject: [IronPython] Hosting IronPython 2.X in .NET app In-Reply-To: <4699E7B3.8060508@voidspace.org.uk> References: <5f040ba90707061243h5f68955fn37facf86b0355bdb@mail.gmail.com> <785694cd0707061929k69cb9a77nb1fbf02f7b400424@mail.gmail.com> <4699E7B3.8060508@voidspace.org.uk> Message-ID: <785694cd0805262336g1d28db46le7bb7d4becd6d6bb@mail.gmail.com> On 7/15/07, Michael Foord wrote: > JoeSox wrote: > > On 7/6/07, Chris Parnin wrote: > > > >> I've seen several examples of how to embed IronPython 1.X in .NET. > >> (e.g. IronTextBox) However, the architecture has changed greatly with > >> 2.X. Does anyone have a good example or pointers on hosting an > >> interactive IronPython session in a .NET app? > >> > > > > One of the reasons why I haven't updated IronTextBox is that > > IronPython 2 is in Alpha. I decided to wait until it was Beta. > > I am eagerly awaiting both the next release of IronPython 2 and a > version of IronTextBox that supports it. :-) Michael, I have completed a version of IronTextBox that works with IP2. Here is the code and article http://www.codeproject.com/KB/miscctrl/irontextbox2.aspx It is sort of late for me here so please let me know if I forgot something in the article or if the project doesn't compile. -- Later, Joe From fuzzyman at voidspace.org.uk Tue May 27 11:31:19 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 27 May 2008 10:31:19 +0100 Subject: [IronPython] Hosting IronPython 2.X in .NET app In-Reply-To: <785694cd0805262336g1d28db46le7bb7d4becd6d6bb@mail.gmail.com> References: <5f040ba90707061243h5f68955fn37facf86b0355bdb@mail.gmail.com> <785694cd0707061929k69cb9a77nb1fbf02f7b400424@mail.gmail.com> <4699E7B3.8060508@voidspace.org.uk> <785694cd0805262336g1d28db46le7bb7d4becd6d6bb@mail.gmail.com> Message-ID: <483BD4E7.8040607@voidspace.org.uk> JoeSox wrote: > On 7/15/07, Michael Foord wrote: > >> JoeSox wrote: >> >>> On 7/6/07, Chris Parnin wrote: >>> >>> >>>> I've seen several examples of how to embed IronPython 1.X in .NET. >>>> (e.g. IronTextBox) However, the architecture has changed greatly with >>>> 2.X. Does anyone have a good example or pointers on hosting an >>>> interactive IronPython session in a .NET app? >>>> >>>> >>> One of the reasons why I haven't updated IronTextBox is that >>> IronPython 2 is in Alpha. I decided to wait until it was Beta. >>> >> I am eagerly awaiting both the next release of IronPython 2 and a >> version of IronTextBox that supports it. :-) >> > > Michael, > > I have completed a version of IronTextBox that works with IP2. > Here is the code and article > http://www.codeproject.com/KB/miscctrl/irontextbox2.aspx > > It is sort of late for me here so please let me know if I forgot > something in the article or if the project doesn't compile. > Cool! I'll give it a try tonight. Michael http://www.ironpythoninaction.com/ From curt at hagenlocher.org Tue May 27 17:27:38 2008 From: curt at hagenlocher.org (Curt Hagenlocher) Date: Tue, 27 May 2008 08:27:38 -0700 Subject: [IronPython] Using IronPython to introspect and test Assemblies without having the source In-Reply-To: <48375A72.1070302@gmail.com> References: <48375A72.1070302@gmail.com> Message-ID: I don't think I understand exactly how you'd like to use IronPython to accomplish this, but if you want to learn more about a .NET application for which you don't have source code, there's no better place to start than Reflector: http://www.aisto.com/roeder/dotnet/ On Fri, May 23, 2008 at 4:59 PM, Jason Galyon wrote: > I have googled around and there is either no information available or I am > using the wrong search terms. I work at a place that has a .NET application > and I would like to start whitebox testing of it. However, I currently have > no access to the source. Even if I did we have no good changeset system so > I would not like to view all changes first and then test. > > Part of the test would be in fact to detect fatal call chain changes for > example. > > Where can I obtain information about using IronPython to test the > assemblies? > > Thanks, > Jason > > _______________________________________________ > 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 Tue May 27 17:55:40 2008 From: dfugate at microsoft.com (Dave Fugate) Date: Tue, 27 May 2008 08:55:40 -0700 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: References: Message-ID: Internally, IronPython and IronRuby are always built against the latest version of the DLR. The reason it looks like they're built on different versions is simply due to different release intervals for the two languages. You're correct that the DLR will eventually stabilize and both IronPython/IronRuby will be buildable against a set version of the DLR (e.g., DLR 1.0). In the short term, I'll talk to the IronRuby guys and see if we can synchronize weekly uploads to IronPython's TFS server and IronRuby's Subversion repository. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall Sent: Sunday, May 25, 2008 2:55 PM To: Discussion of IronPython Subject: [IronPython] IronPython + IronRuby + Known DLR Build Hello, Posted similar message onto IronRuby but I thought I would also ask you guys. My scenario is that I need to host IronRuby and IronPython within the same application. I thought this would be easy as they both are based on the DLR. However, you both appear to be at different stages of the DLR life and building against different sources. Is this the same internally? At the moment I can't see a way I can build both IronPython and IronRuby from the same DLR assemblies? At some point, I take it the DLR will merge into a single release and known assembly for other language providers and hosts to use instead of multiple different versions? In the mean time - what can I do? Is anyone doing this? Thanks Ben Blog.BenHall.me.uk _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Tue May 27 18:06:04 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 27 May 2008 09:06:04 -0700 Subject: [IronPython] Statefulness of CompiledCode In-Reply-To: <00d401c8bf60_cdf61000_14b2a8c0@lannisport> References: <483ADD1C.1020409@brovada.com><004101c8bf58_135ae390_14b2a8c0@lannisport> <483AFD79.5030702@brovada.com> <00d401c8bf60_cdf61000_14b2a8c0@lannisport> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852302@DF-GRTDANE-MSG.exchange.corp.microsoft.com> To avoid leaking memory in 1.x when repeatedly compiling modules you can enable the GenerateModulesAsSnippets option. To do that programmatically you can just do IronPython.Compiler.Options.GenerateModulesAsSnippets = true; It will then cause all modules to get compiled as dynamic methods but it will come with a (significant in v1.x, much less significant in 2.0) throughput cost. You might also find that the compilation is still too expensive but at least memory won't be leaked anymore. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Korbinian Abenthum Sent: Monday, May 26, 2008 11:46 AM To: Discussion of IronPython Subject: Re: [IronPython] Statefulness of CompiledCode Greg Parker wrote: > I executed the same application in > a tight loop about 1000 times. The VM Size skyrocketed to > ~500M (without the reload it stays at ~16M). So this doesn't > look like an option for me, especially since the actual script > we are trying to run is much larger and more complicated. As > for changes to the C# code, in 1.1 if I try to clear the > globals I just get an exception ('module' object has no > attribute '__builtins__'). So am I better off just using the > latest 2.0 build? That has the same problem I'm afraid. Apparently the memory is lost during the repeated compilation of SomeScript.py. If I compile it only once and do the import manually, | ScriptEngine python = IronPython.Hosting.PythonEngine.CurrentEngine; | CompiledCode compiledCode = python.CreateScriptSourceFromFile("Program.py").Compile(); | CompiledCode compiledCodeSomeInclude = python.CreateScriptSourceFromFile("SomeInclude.py").Compile(); | | ScriptScope scope = python.CreateScope(); | for (int i = 0; i < 5000; i++) | { | ScriptScope scopeSomeInclude = python.CreateScope(); | compiledCodeSomeInclude.Execute(scopeSomeInclude); | python.Runtime.Globals.SetVariable("SomeInclude", scopeSomeInclude); | | compiledCode.Execute(scope); | } the memory usage remains constant (and it's a whole lot faster). I have no idea how that can be done in 1.1, or if it has side effects I'm not aware of. And if you have complex import chains then this solution might not translate very well to your problem in the first place. HTH anyway. _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From ben2004uk at googlemail.com Tue May 27 18:10:46 2008 From: ben2004uk at googlemail.com (Ben Hall) Date: Tue, 27 May 2008 17:10:46 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: References: Message-ID: Hi Dave, That would be great!! It could be just an initial sync so I have something to build\work against - even if they are old. At the moment, I just need a nice set of the assemblies working :) Long term, weekly sync's would be useful... Thanks Ben Blog.BenHall.me.uk On Tue, May 27, 2008 at 4:55 PM, Dave Fugate wrote: > Internally, IronPython and IronRuby are always built against the latest version of the DLR. The reason it looks like they're built on different versions is simply due to different release intervals for the two languages. > > You're correct that the DLR will eventually stabilize and both IronPython/IronRuby will be buildable against a set version of the DLR (e.g., DLR 1.0). > > In the short term, I'll talk to the IronRuby guys and see if we can synchronize weekly uploads to IronPython's TFS server and IronRuby's Subversion repository. > > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall > Sent: Sunday, May 25, 2008 2:55 PM > To: Discussion of IronPython > Subject: [IronPython] IronPython + IronRuby + Known DLR Build > > Hello, > > Posted similar message onto IronRuby but I thought I would also ask > you guys. My scenario is that I need to host IronRuby and IronPython > within the same application. I thought this would be easy as they both > are based on the DLR. > > However, you both appear to be at different stages of the DLR life and > building against different sources. Is this the same internally? At > the moment I can't see a way I can build both IronPython and IronRuby > from the same DLR assemblies? > > At some point, I take it the DLR will merge into a single release and > known assembly for other language providers and hosts to use instead > of multiple different versions? > > In the mean time - what can I do? Is anyone doing this? > > Thanks > > Ben > Blog.BenHall.me.uk > _______________________________________________ > 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 exchange.microsoft.com Tue May 27 18:20:18 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 27 May 2008 09:20:18 -0700 Subject: [IronPython] Tracing JIT for the DLR In-Reply-To: <4839BB16.1010603@voidspace.org.uk> References: <4839BB16.1010603@voidspace.org.uk> Message-ID: <7AD436E4270DD54A94238001769C2227012BC985230C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I think we get similar gains from our DynamicSite objects that we store at each call site. These remember the types which were used (where type can be a .NET type or a Python type or a Ruby type or a ...) and then perform the same action if the "test" (we have the same type) passes. We combine that w/ .NET generics so that if we have a statically known type at a call site (e.g. "a + 1") we can do things like flow the int through in it's unboxed form and not have to provide any tests for the int. Finally the call sites are all computed at runtime so they're Just In Time as well :). Now that's certainly not as sophisticated as a tracing JIT but it's a start. We also have other optimizations which we layer on top of these and there's probably some small improvements to come here before 2.x is done. The results of these call site optimizations can easily be seen when you run Pystone. If you run it w/ the default number of iterations we're around the same as we were w/ 1.x. But if you keep cranking up the number of iterations we keep getting faster and faster. In 1.x we just stayed the same speed. Finally we're looking at doing some more advanced optimizations - for example we might start inlining Python functions into the call sites as well as combining what are logically multiple call sites into a single call site with the combined operations. But I wouldn't necessarily expect much more advancement here until 3.x. I would assume the tracing here is some sort of "global", or above the call site, view of the program and we should definitely consider that when we get back to these sophisticated optimizations. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Sunday, May 25, 2008 12:17 PM To: Discussion of IronPython Subject: [IronPython] Tracing JIT for the DLR Hello guys, Just throwing a wild idea out. :-) PyPy (an interpreter compiler toolchain written in Python) has a tracing JIT that is gradually gaining in capabilities. Similar to the tracing JIT in Tamarin (I believe) it traces types through common code paths and generates specialised code for the common paths and types. This is a great technique for optimising dynamic languages, as although code paths can be taken with different types this is fairly rare. If it does happen, dynamic dispatch can still happen. One interesting consequence of this is that the .NET backend for PyPy (interpreters compiled to run on the .NET framework) can still use the tracing JIT. Although a PyPy compiled interpreter retains the full semantics of the language it implements, it can generate specialised .NET bytecode - using the native .NET types, where it provides a faster path. (A very hazy explanation based on my hazy understanding I'm afraid.) Effectively PyPy compiled interpreters on .NET are double JITTed :-) I wonder if at some point in the future a similar technique could be used to optimise DLR languages. Michael Foord -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Tue May 27 19:07:24 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Tue, 27 May 2008 18:07:24 +0100 Subject: [IronPython] IronPython + IronRuby + Known DLR Build In-Reply-To: References: Message-ID: <483C3FCC.5030204@voidspace.org.uk> Dave Fugate wrote: > Internally, IronPython and IronRuby are always built against the latest version of the DLR. The reason it looks like they're built on different versions is simply due to different release intervals for the two languages. > > You're correct that the DLR will eventually stabilize and both IronPython/IronRuby will be buildable against a set version of the DLR (e.g., DLR 1.0). > > In the short term, I'll talk to the IronRuby guys and see if we can synchronize weekly uploads to IronPython's TFS server and IronRuby's Subversion repository. > > > +1 - that would be great. Michael Foord > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Ben Hall > Sent: Sunday, May 25, 2008 2:55 PM > To: Discussion of IronPython > Subject: [IronPython] IronPython + IronRuby + Known DLR Build > > Hello, > > Posted similar message onto IronRuby but I thought I would also ask > you guys. My scenario is that I need to host IronRuby and IronPython > within the same application. I thought this would be easy as they both > are based on the DLR. > > However, you both appear to be at different stages of the DLR life and > building against different sources. Is this the same internally? At > the moment I can't see a way I can build both IronPython and IronRuby > from the same DLR assemblies? > > At some point, I take it the DLR will merge into a single release and > known assembly for other language providers and hosts to use instead > of multiple different versions? > > In the mean time - what can I do? Is anyone doing this? > > Thanks > > Ben > Blog.BenHall.me.uk > _______________________________________________ > 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.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ From sanxiyn at gmail.com Tue May 27 22:46:11 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Wed, 28 May 2008 05:46:11 +0900 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <49538.71.59.123.159.1211242803.squirrel@webmail.brynmawr.edu> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> <49318.71.59.123.159.1211233775.squirrel@webmail.brynmawr.edu> <49538.71.59.123.159.1211242803.squirrel@webmail.brynmawr.edu> Message-ID: <5b0248170805271346y3c6d206aw87ae1d5795b27ab@mail.gmail.com> 2008/5/20 Douglas S. Blank : > Seo at al., > > If you want to grab the patches for an IPCEr8 which will build and run IP2B2: > > svn export > http://svn.cs.brynmawr.edu/Myro/trunk/fepy/IPCE/fepy/patches/2.0b2/ Sorry for a long delay. This is a great work! Thank you. These changes are now incorporated in FePy SVN: http://fepy.svn.sourceforge.net/viewvc/fepy?view=rev&revision=588 However, your patch-builtin-mapsite is incorrect. A function to map can be null (Python None) in valid Python code. Try "map(None, [])" for an example. My workaround involves moving local DynamicSite varaibles to static and using EnsureInitialized to initialize them. See: http://fepy.svn.sourceforge.net/svnroot/fepy/trunk/patches/latest/patch-builtin-mapsite -- Seo Sanghyeon From dblank at brynmawr.edu Tue May 27 22:51:55 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Tue, 27 May 2008 16:51:55 -0400 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <5b0248170805271346y3c6d206aw87ae1d5795b27ab@mail.gmail.com> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> <49318.71.59.123.159.1211233775.squirrel@webmail.brynmawr.edu> <49538.71.59.123.159.1211242803.squirrel@webmail.brynmawr.edu> <5b0248170805271346y3c6d206aw87ae1d5795b27ab@mail.gmail.com> Message-ID: <483C746B.6090009@brynmawr.edu> Sanghyeon Seo wrote: > 2008/5/20 Douglas S. Blank : >> Seo at al., >> >> If you want to grab the patches for an IPCEr8 which will build and run IP2B2: >> >> svn export >> http://svn.cs.brynmawr.edu/Myro/trunk/fepy/IPCE/fepy/patches/2.0b2/ > > Sorry for a long delay. This is a great work! Thank you. These changes > are now incorporated in FePy SVN: > http://fepy.svn.sourceforge.net/viewvc/fepy?view=rev&revision=588 > > However, your patch-builtin-mapsite is incorrect. A function to map > can be null (Python None) in valid Python code. Try "map(None, [])" > for an example. > > My workaround involves moving local DynamicSite varaibles to static > and using EnsureInitialized to initialize them. See: > http://fepy.svn.sourceforge.net/svnroot/fepy/trunk/patches/latest/patch-builtin-mapsite > Excellent; thanks a bunch! I didn't know that you could map None... interesting. That explains that code. -Doug From dinov at exchange.microsoft.com Tue May 27 23:10:13 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Tue, 27 May 2008 14:10:13 -0700 Subject: [IronPython] Hosting IP2 Beta2 in Mono? In-Reply-To: <483C746B.6090009@brynmawr.edu> References: <55277.71.59.123.159.1210389927.squirrel@webmail.brynmawr.edu> <10140.71.59.123.159.1210428199.squirrel@webmail.brynmawr.edu> <4831CC73.8060806@brynmawr.edu> <295e750a0805191312k2893db33p3a0d0b044bf9c80b@mail.gmail.com> <49318.71.59.123.159.1211233775.squirrel@webmail.brynmawr.edu> <49538.71.59.123.159.1211242803.squirrel@webmail.brynmawr.edu> <5b0248170805271346y3c6d206aw87ae1d5795b27ab@mail.gmail.com> <483C746B.6090009@brynmawr.edu> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852447@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Just FYI - I added a way to access sites which are local to the functions caller this morning. There's a new type SiteLocalStorage which you can declare as a parameter on any built-in function. Then when calling it you get an instance of this class which is allocated from the calling dynamic site. Therefore if you have different callers passing different types you'll get different instances of the storage. That will enable functions like map to be implemented as: public static List map(CodeContext/*!*/ context, SiteLocalStorage>/*!*/ storage, object func, IEnumerable enumerator) { if (enumerator == null) { throw PythonOps.TypeError("NoneType is not iterable"); } if (func != null && !storage.Data.IsInitialized) { storage.Data.EnsureInitialized(...); } List ret = new List(); foreach (object o in enumerator) { if (func == null) { ret.AddNoLock(o); } else { ret.AddNoLock(storage.Data.Invoke(context, func, o)); } } return ret; } And therefore we won't have to create a new dynamic site and figure out what to do each time through map - while at the same time usually having a monomorphic call site. If you need more than one site you can declare SiteLocalStorage or SLS>. That should work w/ any DLR language which uses the default method binder. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank Sent: Tuesday, May 27, 2008 1:52 PM To: Discussion of IronPython Subject: Re: [IronPython] Hosting IP2 Beta2 in Mono? Sanghyeon Seo wrote: > 2008/5/20 Douglas S. Blank : >> Seo at al., >> >> If you want to grab the patches for an IPCEr8 which will build and run IP2B2: >> >> svn export >> http://svn.cs.brynmawr.edu/Myro/trunk/fepy/IPCE/fepy/patches/2.0b2/ > > Sorry for a long delay. This is a great work! Thank you. These changes > are now incorporated in FePy SVN: > http://fepy.svn.sourceforge.net/viewvc/fepy?view=rev&revision=588 > > However, your patch-builtin-mapsite is incorrect. A function to map > can be null (Python None) in valid Python code. Try "map(None, [])" > for an example. > > My workaround involves moving local DynamicSite varaibles to static > and using EnsureInitialized to initialize them. See: > http://fepy.svn.sourceforge.net/svnroot/fepy/trunk/patches/latest/patch-builtin-mapsite > Excellent; thanks a bunch! I didn't know that you could map None... interesting. That explains that code. -Doug _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From anto.cuni at gmail.com Wed May 28 15:19:33 2008 From: anto.cuni at gmail.com (Antonio Cuni) Date: Wed, 28 May 2008 15:19:33 +0200 Subject: [IronPython] Tracing JIT for the DLR In-Reply-To: <4839BB16.1010603@voidspace.org.uk> References: <4839BB16.1010603@voidspace.org.uk> Message-ID: <483D5BE5.5060908@gmail.com> Hi Michael, hi all Michael Foord wrote: > One interesting consequence of this is that the .NET backend for PyPy > (interpreters compiled to run on the .NET framework) can still use the > tracing JIT. Although a PyPy compiled interpreter retains the full > semantics of the language it implements, it can generate specialised > .NET bytecode - using the native .NET types, where it provides a faster > path. > > (A very hazy explanation based on my hazy understanding I'm afraid.) > > Effectively PyPy compiled interpreters on .NET are double JITTed :-) Actually, the CLI JIT backend of PyPy is work in progress and it's not able to handle the full Python interpreter. But indeed, the basic idea is that, and once the CLI JIT backend will be completed, we will have a double jitted interpreter. How fast/slow can it be, we don't know yet; very fast, we hope :-). Btw, the CLI JIT backend has just reached its first milestone, i.e. to be able to compile a minimal virtual machine for a simple toy language: http://morepypy.blogspot.com/2008/05/progresses-on-cli-jit-backend-front.html ciao, Anto From Jimmy.Schementi at microsoft.com Wed May 28 20:32:10 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 28 May 2008 11:32:10 -0700 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: <4830108C.6010807@voidspace.org.uk> Message-ID: That's definitely a bug, but I've only seen it on a Mac ... granted it really pissed me off =P I'll be fixing this in a day or so, so I can give you a patched version of Chiron then ... Unless you've fixed it already =P ~js On 5/18/08 4:18 AM, "Michael Foord" wrote: Hello guys, I've been following the instructions on Jimmy's blog entry about packaging Silverlight applications: http://blog.jimmy.schementi.com/2008/05/story-of-ruby-and-python-in-silverlight.html I'm trying to get the application assemblies stored outside the 'xap' file, by using the urlprefix configuration in 'Chiron.exe.config'. As described in Jimmy's blog, I add the following line to the 'appSettings' element of the config file: This actually causes Chiron to generate the following in the manifest file: Which seems wrong. :-) I guess it is just a bug in Chiron... (or I am doing something wrong.) Michael Foord http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed May 28 20:40:29 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 28 May 2008 19:40:29 +0100 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: References: Message-ID: <483DA71D.8050808@voidspace.org.uk> Jimmy Schementi wrote: > That?s definitely a bug, but I?ve only seen it on a Mac ... granted it > really pissed me off =P I?ll be fixing this in a day or so, so I can > give you a patched version of Chiron then ... Unless you?ve fixed it > already =P > Not really a problem for me. Have you got a patched Chiron that allows me to use Firefox on the Mac - now that I would want... Michael Foord > ~js > > > On 5/18/08 4:18 AM, "Michael Foord" wrote: > > Hello guys, > > I've been following the instructions on Jimmy's blog entry about > packaging Silverlight applications: > > http://blog.jimmy.schementi.com/2008/05/story-of-ruby-and-python-in-silverlight.html > > I'm trying to get the application assemblies stored outside the 'xap' > file, by using the urlprefix configuration in 'Chiron.exe.config'. > > As described in Jimmy's blog, I add the following line to the > 'appSettings' element of the config file: > > > > This actually causes Chiron to generate the following in the > manifest file: > > Source="file:///lib/Microsoft.Scripting.Silverlight.dll" /> > > > > > Which seems wrong. :-) > > I guess it is just a bug in Chiron... (or I am doing something wrong.) > > Michael Foord > http://www.ironpythoninaction.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ From Jimmy.Schementi at microsoft.com Wed May 28 20:43:44 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 28 May 2008 11:43:44 -0700 Subject: [IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' In-Reply-To: <482F2809.5040600@voidspace.org.uk> Message-ID: Yay for finding a IronPython bug =) Does it work if you do IsChecked = None as well? Dino, do you know about this? ~js On 5/17/08 11:46 AM, "Michael Foord" wrote: This is cool. I have a checkbox in my silverlight UI. I have a code path that does: if self.remember_me.IsChecked: PutStored(username, password) The *second* time through this code path it blows up with the exception below. I can fix it by changing the test to: if self.remember_me.IsChecked == True: PutStored(username, password) Which works fine, but I thought you might be interested. :-) Full traceback below... ArgumentException: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' ArgumentException at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg, Label ifFalse) at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext context) at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext context) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext callerContext, Object site, T& target, RuleSet`1& rules, StandardRule`1 rule) at Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext callerContext, Object[] args, Boolean execute, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext context, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules) at Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext context, T0 arg0) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2 site, CodeContext context, T0 arg0) at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, T0 arg0) at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object ) at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, T0 arg0) at S$3.onLogin$18(Closure , Object self, Object sender, Object event) at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object arg1, Object arg2, Object arg3) at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object instance, Object[] args) at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method, Object instance, Object[] parameters) at Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context, Expression expression) at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object site, CodeContext context, Object[] args) at Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext callerContext, Object[] args, Boolean execute, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext context, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules) at Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5 site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , Object , Object ) at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2) at System.Void(Object, RoutedEventArgs), using PythonBinder##183(Closure , Object , RoutedEventArgs ) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object sender, MouseButtonEventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) ? Hide Debugging Output Michael Foord http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuzzyman at voidspace.org.uk Wed May 28 20:46:37 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 28 May 2008 19:46:37 +0100 Subject: [IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' In-Reply-To: References: Message-ID: <483DA88D.6080807@voidspace.org.uk> Jimmy Schementi wrote: > Yay for finding a IronPython bug =) Does it work if you do IsChecked = > None as well? Dino, do you know about this? > I'll try setting IsChecked to None. Did you see that on the Mac (Safari) I'm not getting the MediaEnded event on a MediaElement when a video stops playing? Probably not an IronPython bug, more likely a Silverlight one. It used to work for 1.1 Alpha though (I get a CurrentStateChanged event where the state changes to Buffering instead!). Michael > ~js > > On 5/17/08 11:46 AM, "Michael Foord" wrote: > > This is cool. I have a checkbox in my silverlight UI. > > I have a code path that does: > > if self.remember_me.IsChecked: > PutStored(username, password) > > The *second* time through this code path it blows up with the > exception > below. I can fix it by changing the test to: > > if self.remember_me.IsChecked == True: > PutStored(username, password) > > Which works fine, but I thought you might be interested. :-) > > Full traceback below... > > ArgumentException: Cannot cast from > 'System.Nullable`1[System.Boolean]' > to 'System.Boolean' > ArgumentException > at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to) > at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node) > at > Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) > at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node) > at > Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) > at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr) > at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node) > at > Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) > at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg, > Label ifFalse) > at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext > context) > at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext > context) > at > Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext > callerContext, Object site, T& target, RuleSet`1& rules, > StandardRule`1 > rule) > at > Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext > callerContext, Object[] args, Boolean execute, Object site, T& target, > RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext > callerContext, Object[] args, Object site, T& target, RuleSet`1& > rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > context, Object[] args, Object site, T& target, RuleSet`1& rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules) > at > Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext > context, T0 arg0) > at > Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2 > site, CodeContext context, T0 arg0) > at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext > context, > T0 arg0) > at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object ) > at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext > context, > T0 arg0) > at S$3.onLogin$18(Closure , Object self, Object sender, Object event) > at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object > arg1, Object arg2, Object arg3) > at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object > instance, Object[] args) > at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method, > Object instance, Object[] parameters) > at > Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext > context, Expression expr) > at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, > Expression expr) > at > Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext > context, Expression expr) > at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, > Expression expr) > at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context, > Expression expression) > at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object > site, > CodeContext context, Object[] args) > at > Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext > callerContext, Object[] args, Boolean execute, Object site, T& target, > RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext > callerContext, Object[] args, Object site, T& target, RuleSet`1& > rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > context, Object[] args, Object site, T& target, RuleSet`1& rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules) > at > Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext > context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at > Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5 > site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext > context, > T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , > Object , > Object ) > at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext > context, > T0 arg0, T1 arg1, T2 arg2) > at System.Void(Object, RoutedEventArgs), using > PythonBinder##183(Closure > , Object , RoutedEventArgs ) > at System.Windows.Controls.Primitives.ButtonBase.OnClick() > at > System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs > e) > at > System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object > sender, MouseButtonEventArgs e) > at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 > typeIndex, > Delegate handlerDelegate, Object sender, Object args) > at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr > unmanagedObjArgs, Int32 argsTypeIndex, String eventName) > ? Hide > Debugging Output > > > Michael Foord > http://www.ironpythoninaction.com/ > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ From dan.eloff at gmail.com Wed May 28 20:49:04 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Wed, 28 May 2008 13:49:04 -0500 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: <483DA71D.8050808@voidspace.org.uk> References: <483DA71D.8050808@voidspace.org.uk> Message-ID: <4817b6fc0805281149i3801e714x29eed78bf9b5522f@mail.gmail.com> > Not really a problem for me. Have you got a patched Chiron that allows me to > use Firefox on the Mac - now that I would want... Can you use firefox at all with Chiron? I never got firefox to work with Chiron on Vista. -Dan From Jimmy.Schementi at microsoft.com Wed May 28 20:51:01 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 28 May 2008 11:51:01 -0700 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: <483DA71D.8050808@voidspace.org.uk> Message-ID: If you want a work-around for now (forgot if I told you or not) ... just run Chiron twice; the second one should respond to requests. Also, fiddle with your network.dns.disableIPv6 flag in FF (type "about:config" in the address bar). Though, I'll get an binary for ya that fixes these two problems on the Mac ... probably later tonight when I'm in Portland. ~js On 5/28/08 11:40 AM, "Michael Foord" wrote: Jimmy Schementi wrote: > That's definitely a bug, but I've only seen it on a Mac ... granted it > really pissed me off =P I'll be fixing this in a day or so, so I can > give you a patched version of Chiron then ... Unless you've fixed it > already =P > Not really a problem for me. Have you got a patched Chiron that allows me to use Firefox on the Mac - now that I would want... Michael Foord > ~js > > > On 5/18/08 4:18 AM, "Michael Foord" wrote: > > Hello guys, > > I've been following the instructions on Jimmy's blog entry about > packaging Silverlight applications: > > http://blog.jimmy.schementi.com/2008/05/story-of-ruby-and-python-in-silverlight.html > > I'm trying to get the application assemblies stored outside the 'xap' > file, by using the urlprefix configuration in 'Chiron.exe.config'. > > As described in Jimmy's blog, I add the following line to the > 'appSettings' element of the config file: > > > > This actually causes Chiron to generate the following in the > manifest file: > > Source="file:///lib/Microsoft.Scripting.Silverlight.dll" /> > > > > > Which seems wrong. :-) > > I guess it is just a bug in Chiron... (or I am doing something wrong.) > > Michael Foord > http://www.ironpythoninaction.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Wed May 28 20:52:39 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 28 May 2008 11:52:39 -0700 Subject: [IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' In-Reply-To: <483DA88D.6080807@voidspace.org.uk> Message-ID: Oh, from your VideoBrush thread? Didn't try it ... I'll look now On 5/28/08 11:46 AM, "Michael Foord" wrote: Jimmy Schementi wrote: > Yay for finding a IronPython bug =) Does it work if you do IsChecked = > None as well? Dino, do you know about this? > I'll try setting IsChecked to None. Did you see that on the Mac (Safari) I'm not getting the MediaEnded event on a MediaElement when a video stops playing? Probably not an IronPython bug, more likely a Silverlight one. It used to work for 1.1 Alpha though (I get a CurrentStateChanged event where the state changes to Buffering instead!). Michael > ~js > > On 5/17/08 11:46 AM, "Michael Foord" wrote: > > This is cool. I have a checkbox in my silverlight UI. > > I have a code path that does: > > if self.remember_me.IsChecked: > PutStored(username, password) > > The *second* time through this code path it blows up with the > exception > below. I can fix it by changing the test to: > > if self.remember_me.IsChecked == True: > PutStored(username, password) > > Which works fine, but I thought you might be interested. :-) > > Full traceback below... > > ArgumentException: Cannot cast from > 'System.Nullable`1[System.Boolean]' > to 'System.Boolean' > ArgumentException > at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to) > at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node) > at > Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) > at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node) > at > Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) > at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr) > at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node) > at > Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) > at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg, > Label ifFalse) > at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext > context) > at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext > context) > at > Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext > callerContext, Object site, T& target, RuleSet`1& rules, > StandardRule`1 > rule) > at > Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext > callerContext, Object[] args, Boolean execute, Object site, T& target, > RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext > callerContext, Object[] args, Object site, T& target, RuleSet`1& > rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > context, Object[] args, Object site, T& target, RuleSet`1& rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules) > at > Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext > context, T0 arg0) > at > Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2 > site, CodeContext context, T0 arg0) > at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext > context, > T0 arg0) > at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object ) > at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext > context, > T0 arg0) > at S$3.onLogin$18(Closure , Object self, Object sender, Object event) > at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object > arg1, Object arg2, Object arg3) > at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object > instance, Object[] args) > at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method, > Object instance, Object[] parameters) > at > Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext > context, Expression expr) > at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, > Expression expr) > at > Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext > context, Expression expr) > at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, > Expression expr) > at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context, > Expression expression) > at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object > site, > CodeContext context, Object[] args) > at > Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext > callerContext, Object[] args, Boolean execute, Object site, T& target, > RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext > callerContext, Object[] args, Object site, T& target, RuleSet`1& > rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > context, Object[] args, Object site, T& target, RuleSet`1& rules, > Object& result) > at > Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules, Object& result) > at > Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext > callerContext, DynamicAction action, Object[] args, Object site, T& > target, RuleSet`1& rules) > at > Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext > context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at > Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5 > site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext > context, > T0 arg0, T1 arg1, T2 arg2, T3 arg3) > at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , > Object , > Object ) > at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext > context, > T0 arg0, T1 arg1, T2 arg2) > at System.Void(Object, RoutedEventArgs), using > PythonBinder##183(Closure > , Object , RoutedEventArgs ) > at System.Windows.Controls.Primitives.ButtonBase.OnClick() > at > System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs > e) > at > System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object > sender, MouseButtonEventArgs e) > at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 > typeIndex, > Delegate handlerDelegate, Object sender, Object args) > at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr > unmanagedObjArgs, Int32 argsTypeIndex, String eventName) > ? Hide > Debugging Output > > > Michael Foord > http://www.ironpythoninaction.com/ > > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > > ------------------------------------------------------------------------ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From Jimmy.Schementi at microsoft.com Wed May 28 21:16:55 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Wed, 28 May 2008 12:16:55 -0700 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: <4817b6fc0805281149i3801e714x29eed78bf9b5522f@mail.gmail.com> Message-ID: http://flickr.com/photos/jschementi/2531937722/ That's Firefox and Chiron working on Vista, straight from the bits on http://codeplex.com/sdlsdk. Firefox on Windows ships with network.dns.disableIPv6 set to "false". Make sure that's the setting you have (type about:config in the address bar). If it's set to "true", Chiron won't get the request. (Actually, if you start ANOTHER Chiron, that one will get the request =P). This bug will be fixed sometime today/tomorrow in sdlsdk; I'll let you guys know when that happens. To understand the bug a little more, Chiron currently tries to listen on IPv6 first, and if that fails it then tries to listen on IPv4. While that's a fine solution for Vista/XP/Mac, as well as browsers that are tied to their operating system's network settings (IE, Safari), it's a problem for browsers that support both in some configurable manner (Firefox). The new behavior is to listen on both IPv6 and IPv4 when it can, but not fail if IPv6 fails. This will work on both IPv6/v4 operating systems (so Vista/XP/Mac will both work), as well as v4/v6 configurable browsers (Firefox), no matter what their settings. Along other Chiron news, I'm also planning on removing the "only works on localhost" constraint. I don't think it'll be difficult, but I just need to find hacking time. =) I find it useful because I'd like to do development on one machine and browser to it with another machine, especially if I'm testing different browsers. Would others find it useful as well? ~Jimmy On 5/28/08 11:49 AM, "Dan Eloff" wrote: > Not really a problem for me. Have you got a patched Chiron that allows me to > use Firefox on the Mac - now that I would want... Can you use firefox at all with Chiron? I never got firefox to work with Chiron on Vista. -Dan _______________________________________________ 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 Wed May 28 21:22:12 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Wed, 28 May 2008 15:22:12 -0400 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> Message-ID: <483DB0E4.9050400@brynmawr.edu> Anyone have an answer for this: I can't write C# code that has its own method for use in repr(). Am I missing something? -Doug Douglas S. Blank wrote: > On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >> Douglas S. Blank kirjoitti: >>> will use it? Likewise, what C# method is used in Python's str(obj)? >>> >> i don't know, but would guess ToString() .. and wonder about it if it >> wasn't that but something else :o >> repr() can't guess, i don't think there's an equivalent in .net, but can >> very well be mistaken there. > > It looks like the C# method __str__ is used for the Python method, but in > IP2B2 the C# method __repr__ is getting overwritten by an auto generated > method. Is that a bug, or is there something I'm missing? > > $ ipy2 -i python/graphics.py >>>> pm = Pixmap() >>>> pm.getPixel(0,0) # What is this calling? > >>>> pm.getPixel(0,0).__repr__() # This is repr() too > '' >>>> pm.getPixel(0,0).__Repr__() # This is mine > '' >>>> pm.getPixel(0,0).__str__() # That is mine, and str() > '' >>>> pm.getPixel(0,0).ToString() # Used by __repr__ > 'GraphicsCore+Pixel' > > -Doug > >>> -Doug >>> >> ~Toni >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > From dinov at exchange.microsoft.com Wed May 28 21:55:59 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 28 May 2008 12:55:59 -0700 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <483DB0E4.9050400@brynmawr.edu> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> Message-ID: <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> You'll want to implement the ICodeFormattable interface. It looks like we don't pick up a method that's just named __repr__ right now. I could see us fixing that but I wouldn't think it's a high priority unless someone finds implementing ICodeFormattable burdensome. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of IronPython Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? Anyone have an answer for this: I can't write C# code that has its own method for use in repr(). Am I missing something? -Doug Douglas S. Blank wrote: > On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >> Douglas S. Blank kirjoitti: >>> will use it? Likewise, what C# method is used in Python's str(obj)? >>> >> i don't know, but would guess ToString() .. and wonder about it if it >> wasn't that but something else :o >> repr() can't guess, i don't think there's an equivalent in .net, but can >> very well be mistaken there. > > It looks like the C# method __str__ is used for the Python method, but in > IP2B2 the C# method __repr__ is getting overwritten by an auto generated > method. Is that a bug, or is there something I'm missing? > > $ ipy2 -i python/graphics.py >>>> pm = Pixmap() >>>> pm.getPixel(0,0) # What is this calling? > >>>> pm.getPixel(0,0).__repr__() # This is repr() too > '' >>>> pm.getPixel(0,0).__Repr__() # This is mine > '' >>>> pm.getPixel(0,0).__str__() # That is mine, and str() > '' >>>> pm.getPixel(0,0).ToString() # Used by __repr__ > 'GraphicsCore+Pixel' > > -Doug > >>> -Doug >>> >> ~Toni >> >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Wed May 28 21:58:01 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 28 May 2008 12:58:01 -0700 Subject: [IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' In-Reply-To: References: <482F2809.5040600@voidspace.org.uk> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852733@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Looks like I missed it somehow - I've filed as bug #16831 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16831). We definitely should fix it, generally the code should work the same the 1st time through and the 2nd time through :). From: Jimmy Schementi Sent: Wednesday, May 28, 2008 11:44 AM To: Discussion of IronPython; Dino Viehland Subject: Re: [IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' Yay for finding a IronPython bug =) Does it work if you do IsChecked = None as well? Dino, do you know about this? ~js On 5/17/08 11:46 AM, "Michael Foord" wrote: This is cool. I have a checkbox in my silverlight UI. I have a code path that does: if self.remember_me.IsChecked: PutStored(username, password) The *second* time through this code path it blows up with the exception below. I can fix it by changing the test to: if self.remember_me.IsChecked == True: PutStored(username, password) Which works fine, but I thought you might be interested. :-) Full traceback below... ArgumentException: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean' ArgumentException at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr) at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node) at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node) at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg, Label ifFalse) at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext context) at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext context) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext callerContext, Object site, T& target, RuleSet`1& rules, StandardRule`1 rule) at Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext callerContext, Object[] args, Boolean execute, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext context, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules) at Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext context, T0 arg0) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2 site, CodeContext context, T0 arg0) at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, T0 arg0) at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object ) at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, T0 arg0) at S$3.onLogin$18(Closure , Object self, Object sender, Object event) at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object arg1, Object arg2, Object arg3) at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object instance, Object[] args) at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method, Object instance, Object[] parameters) at Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, Expression expr) at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context, Expression expression) at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object site, CodeContext context, Object[] args) at Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext callerContext, Object[] args, Boolean execute, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext context, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules, Object& result) at Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext callerContext, DynamicAction action, Object[] args, Object site, T& target, RuleSet`1& rules) at Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5 site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3) at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , Object , Object ) at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext context, T0 arg0, T1 arg1, T2 arg2) at System.Void(Object, RoutedEventArgs), using PythonBinder##183(Closure , Object , RoutedEventArgs ) at System.Windows.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e) at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object sender, MouseButtonEventArgs e) at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName) ? Hide Debugging Output Michael Foord http://www.ironpythoninaction.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From dblank at brynmawr.edu Wed May 28 22:47:21 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Wed, 28 May 2008 16:47:21 -0400 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <483DC4D9.2000601@brynmawr.edu> Dino Viehland wrote: > You'll want to implement the ICodeFormattable interface. It looks > like we don't pick up a method that's just named __repr__ right now. > I could see us fixing that but I wouldn't think it's a high priority > unless someone finds implementing ICodeFormattable burdensome. Thanks, that did the trick (sample attached below)! It isn't burdensome, but I wonder about what will happen when we use IronRuby, too? We'll we need repr methods for each language? I also wonder if things like a generic list couldn't pick up a reasonable default __repr__ for use in all DLR languages. We're using the .NET languages in an educational environment for new students. Currently, we're going to have to add the __repr__ to all classes, and add subclasses to all types for which there isn't a reasonable repr default. For example, there is a pretty big difference between: "[255, 255, 128]" and " object at 0x000002C [List]>" or whatever it might be. In any event, we have a work around now; thanks again! -Doug using System; using IronPython.Runtime; // for ICodeFormattable using Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : ICodeFormattable { public virtual string __repr__(CodeContext context) { return String.Format(""); } } > -----Original Message----- From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. > Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of > IronPython Subject: Re: [IronPython] What C# methods do __repr__ and > __str__ use? > > Anyone have an answer for this: I can't write C# code that has its > own method for use in repr(). Am I missing something? > > -Doug > > Douglas S. Blank wrote: >> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>> Douglas S. Blank kirjoitti: >>>> will use it? Likewise, what C# method is used in Python's >>>> str(obj)? >>>> >>> i don't know, but would guess ToString() .. and wonder about it >>> if it wasn't that but something else :o repr() can't guess, i >>> don't think there's an equivalent in .net, but can very well be >>> mistaken there. >> It looks like the C# method __str__ is used for the Python method, >> but in IP2B2 the C# method __repr__ is getting overwritten by an >> auto generated method. Is that a bug, or is there something I'm >> missing? >> >> $ ipy2 -i python/graphics.py >>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>> this calling? >> >>>>> pm.getPixel(0,0).__repr__() # This is repr() too >> '' >>>>> pm.getPixel(0,0).__Repr__() # This is mine >> '' >>>>> pm.getPixel(0,0).__str__() # That is mine, and str() >>>>> >> '' >>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >> 'GraphicsCore+Pixel' >> >> -Doug >> >>>> -Doug >>>> >>> ~Toni >>> >>> _______________________________________________ Users mailing >>> list Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> > > _______________________________________________ Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > From dinov at exchange.microsoft.com Wed May 28 22:57:24 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 28 May 2008 13:57:24 -0700 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <483DC4D9.2000601@brynmawr.edu> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> The problem w/ a common __repr__ is that each language will presumably have different syntax for creating the object. For example a better repr in Python might be: Pixel(255,255,128) Where Ruby should probably display something like: Pixel.new(255,255,128) Having a repr of [255,255,128] isn't that meaningful because if I copy and paste that into my code I get a list instead of a Pixel back. We could revisit what our default repr does for .NET objects that override ToString. We discussed it once on the list long ago but that was mainly focused on dealing w/ multi-line ToStrings if I recall correctly - the thought of playing better with multiple languages wasn't much of an issue back then for us. So basically I am open to suggestions :) -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of IronPython Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? Dino Viehland wrote: > You'll want to implement the ICodeFormattable interface. It looks > like we don't pick up a method that's just named __repr__ right now. > I could see us fixing that but I wouldn't think it's a high priority > unless someone finds implementing ICodeFormattable burdensome. Thanks, that did the trick (sample attached below)! It isn't burdensome, but I wonder about what will happen when we use IronRuby, too? We'll we need repr methods for each language? I also wonder if things like a generic list couldn't pick up a reasonable default __repr__ for use in all DLR languages. We're using the .NET languages in an educational environment for new students. Currently, we're going to have to add the __repr__ to all classes, and add subclasses to all types for which there isn't a reasonable repr default. For example, there is a pretty big difference between: "[255, 255, 128]" and " object at 0x000002C [List]>" or whatever it might be. In any event, we have a work around now; thanks again! -Doug using System; using IronPython.Runtime; // for ICodeFormattable using Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : ICodeFormattable { public virtual string __repr__(CodeContext context) { return String.Format(""); } } > -----Original Message----- From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. > Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of > IronPython Subject: Re: [IronPython] What C# methods do __repr__ and > __str__ use? > > Anyone have an answer for this: I can't write C# code that has its > own method for use in repr(). Am I missing something? > > -Doug > > Douglas S. Blank wrote: >> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>> Douglas S. Blank kirjoitti: >>>> will use it? Likewise, what C# method is used in Python's >>>> str(obj)? >>>> >>> i don't know, but would guess ToString() .. and wonder about it >>> if it wasn't that but something else :o repr() can't guess, i >>> don't think there's an equivalent in .net, but can very well be >>> mistaken there. >> It looks like the C# method __str__ is used for the Python method, >> but in IP2B2 the C# method __repr__ is getting overwritten by an >> auto generated method. Is that a bug, or is there something I'm >> missing? >> >> $ ipy2 -i python/graphics.py >>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>> this calling? >> >>>>> pm.getPixel(0,0).__repr__() # This is repr() too >> '' >>>>> pm.getPixel(0,0).__Repr__() # This is mine >> '' >>>>> pm.getPixel(0,0).__str__() # That is mine, and str() >>>>> >> '' >>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >> 'GraphicsCore+Pixel' >> >> -Doug >> >>>> -Doug >>>> >>> ~Toni >>> >>> _______________________________________________ Users mailing >>> list Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> > > _______________________________________________ Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ 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 dblank at brynmawr.edu Wed May 28 23:08:20 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Wed, 28 May 2008 17:08:20 -0400 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <483DC9C4.8010802@brynmawr.edu> Dino Viehland wrote: > The problem w/ a common __repr__ is that each language will > presumably have different syntax for creating the object. For > example a better repr in Python might be: > > Pixel(255,255,128) > > Where Ruby should probably display something like: > > Pixel.new(255,255,128) Agreed. But maybe there can be some name *patterns* that if implemented once would suffice for most languages. I'm not too worried about this though. > Having a repr of [255,255,128] isn't that meaningful because if I > copy and paste that into my code I get a list instead of a Pixel > back. Sorry, I switched issues on you :) That was the point of that example... generic lists don't look like lists at all. I'm actually more concerned with this example than the previous. A generic list of ints, strings, etc. ought to be able to have a better representation in IP. > We could revisit what our default repr does for .NET objects > that override ToString. We discussed it once on the list long ago > but that was mainly focused on dealing w/ multi-line ToStrings if I > recall correctly - the thought of playing better with multiple > languages wasn't much of an issue back then for us. > > So basically I am open to suggestions :) Perhaps generic lists could inherit a version of Python List's __repr__? (But of course, not just for Python, but for Ruby, etc.) Thanks! -Doug > -----Original Message----- From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. > Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of > IronPython Subject: Re: [IronPython] What C# methods do __repr__ and > __str__ use? > > Dino Viehland wrote: >> You'll want to implement the ICodeFormattable interface. It looks >> like we don't pick up a method that's just named __repr__ right >> now. I could see us fixing that but I wouldn't think it's a high >> priority unless someone finds implementing ICodeFormattable >> burdensome. > > Thanks, that did the trick (sample attached below)! It isn't > burdensome, but I wonder about what will happen when we use IronRuby, > too? We'll we need repr methods for each language? > > I also wonder if things like a generic list couldn't pick up a > reasonable default __repr__ for use in all DLR languages. > > We're using the .NET languages in an educational environment for new > students. Currently, we're going to have to add the __repr__ to all > classes, and add subclasses to all types for which there isn't a > reasonable repr default. For example, there is a pretty big > difference between: "[255, 255, 128]" and " > object at 0x000002C [List]>" or whatever it might > be. > > In any event, we have a work around now; thanks again! > > -Doug > > using System; using IronPython.Runtime; // for ICodeFormattable using > Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : > ICodeFormattable { public virtual string __repr__(CodeContext > context) { return String.Format(""); } } > > >> -----Original Message----- From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >> and __str__ use? >> >> Anyone have an answer for this: I can't write C# code that has its >> own method for use in repr(). Am I missing something? >> >> -Doug >> >> Douglas S. Blank wrote: >>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>> Douglas S. Blank kirjoitti: >>>>> will use it? Likewise, what C# method is used in Python's >>>>> str(obj)? >>>>> >>>> i don't know, but would guess ToString() .. and wonder about it >>>> if it wasn't that but something else :o repr() can't guess, i >>>> don't think there's an equivalent in .net, but can very well be >>>> mistaken there. >>> It looks like the C# method __str__ is used for the Python >>> method, but in IP2B2 the C# method __repr__ is getting >>> overwritten by an auto generated method. Is that a bug, or is >>> there something I'm missing? >>> >>> $ ipy2 -i python/graphics.py >>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>> this calling? >>> >>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>> '' >>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>> '' >>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>> str() >>>>>> >>> '' >>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>> 'GraphicsCore+Pixel' >>> >>> -Doug >>> >>>>> -Doug >>>>> >>>> ~Toni >>>> >>>> _______________________________________________ Users mailing >>>> list Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >> _______________________________________________ Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ 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 exchange.microsoft.com Wed May 28 23:19:06 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 28 May 2008 14:19:06 -0700 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <483DC9C4.8010802@brynmawr.edu> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC9C4.8010802@brynmawr.edu> Message-ID: <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> We could definitely add a __repr__ for the normal .NET lists (and even other standard types like Dictionary). Maybe something like Python's set's repr so it'd look like: List[object]([2, 3, 4]) Does that look good? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank Sent: Wednesday, May 28, 2008 2:08 PM To: Discussion of IronPython Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? Dino Viehland wrote: > The problem w/ a common __repr__ is that each language will > presumably have different syntax for creating the object. For > example a better repr in Python might be: > > Pixel(255,255,128) > > Where Ruby should probably display something like: > > Pixel.new(255,255,128) Agreed. But maybe there can be some name *patterns* that if implemented once would suffice for most languages. I'm not too worried about this though. > Having a repr of [255,255,128] isn't that meaningful because if I > copy and paste that into my code I get a list instead of a Pixel > back. Sorry, I switched issues on you :) That was the point of that example... generic lists don't look like lists at all. I'm actually more concerned with this example than the previous. A generic list of ints, strings, etc. ought to be able to have a better representation in IP. > We could revisit what our default repr does for .NET objects > that override ToString. We discussed it once on the list long ago > but that was mainly focused on dealing w/ multi-line ToStrings if I > recall correctly - the thought of playing better with multiple > languages wasn't much of an issue back then for us. > > So basically I am open to suggestions :) Perhaps generic lists could inherit a version of Python List's __repr__? (But of course, not just for Python, but for Ruby, etc.) Thanks! -Doug > -----Original Message----- From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. > Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of > IronPython Subject: Re: [IronPython] What C# methods do __repr__ and > __str__ use? > > Dino Viehland wrote: >> You'll want to implement the ICodeFormattable interface. It looks >> like we don't pick up a method that's just named __repr__ right >> now. I could see us fixing that but I wouldn't think it's a high >> priority unless someone finds implementing ICodeFormattable >> burdensome. > > Thanks, that did the trick (sample attached below)! It isn't > burdensome, but I wonder about what will happen when we use IronRuby, > too? We'll we need repr methods for each language? > > I also wonder if things like a generic list couldn't pick up a > reasonable default __repr__ for use in all DLR languages. > > We're using the .NET languages in an educational environment for new > students. Currently, we're going to have to add the __repr__ to all > classes, and add subclasses to all types for which there isn't a > reasonable repr default. For example, there is a pretty big > difference between: "[255, 255, 128]" and " > object at 0x000002C [List]>" or whatever it might > be. > > In any event, we have a work around now; thanks again! > > -Doug > > using System; using IronPython.Runtime; // for ICodeFormattable using > Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : > ICodeFormattable { public virtual string __repr__(CodeContext > context) { return String.Format(""); } } > > >> -----Original Message----- From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >> and __str__ use? >> >> Anyone have an answer for this: I can't write C# code that has its >> own method for use in repr(). Am I missing something? >> >> -Doug >> >> Douglas S. Blank wrote: >>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>> Douglas S. Blank kirjoitti: >>>>> will use it? Likewise, what C# method is used in Python's >>>>> str(obj)? >>>>> >>>> i don't know, but would guess ToString() .. and wonder about it >>>> if it wasn't that but something else :o repr() can't guess, i >>>> don't think there's an equivalent in .net, but can very well be >>>> mistaken there. >>> It looks like the C# method __str__ is used for the Python >>> method, but in IP2B2 the C# method __repr__ is getting >>> overwritten by an auto generated method. Is that a bug, or is >>> there something I'm missing? >>> >>> $ ipy2 -i python/graphics.py >>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>> this calling? >>> >>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>> '' >>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>> '' >>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>> str() >>>>>> >>> '' >>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>> 'GraphicsCore+Pixel' >>> >>> -Doug >>> >>>>> -Doug >>>>> >>>> ~Toni >>>> >>>> _______________________________________________ Users mailing >>>> list Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >> _______________________________________________ Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ 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 Wed May 28 23:39:55 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 28 May 2008 22:39:55 +0100 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC9C4.8010802@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <483DD12B.907@voidspace.org.uk> Dino Viehland wrote: > We could definitely add a __repr__ for the normal .NET lists (and even other standard types like Dictionary). Maybe something like Python's set's repr so it'd look like: > > List[object]([2, 3, 4]) > > Does that look good? > Spot on. Array could use the same love. Michael Foord > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank > Sent: Wednesday, May 28, 2008 2:08 PM > To: Discussion of IronPython > Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? > > Dino Viehland wrote: > >> The problem w/ a common __repr__ is that each language will >> presumably have different syntax for creating the object. For >> example a better repr in Python might be: >> >> Pixel(255,255,128) >> >> Where Ruby should probably display something like: >> >> Pixel.new(255,255,128) >> > > Agreed. But maybe there can be some name *patterns* that if implemented > once would suffice for most languages. I'm not too worried about this > though. > > >> Having a repr of [255,255,128] isn't that meaningful because if I >> copy and paste that into my code I get a list instead of a Pixel >> back. >> > > Sorry, I switched issues on you :) That was the point of that example... > generic lists don't look like lists at all. I'm actually more concerned > with this example than the previous. A generic list of ints, strings, > etc. ought to be able to have a better representation in IP. > > >> We could revisit what our default repr does for .NET objects >> that override ToString. We discussed it once on the list long ago >> but that was mainly focused on dealing w/ multi-line ToStrings if I >> recall correctly - the thought of playing better with multiple >> languages wasn't much of an issue back then for us. >> >> So basically I am open to suggestions :) >> > > Perhaps generic lists could inherit a version of Python List's __repr__? > (But of course, not just for Python, but for Ruby, etc.) > > Thanks! > > -Doug > > >> -----Original Message----- From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. >> Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of >> IronPython Subject: Re: [IronPython] What C# methods do __repr__ and >> __str__ use? >> >> Dino Viehland wrote: >> >>> You'll want to implement the ICodeFormattable interface. It looks >>> like we don't pick up a method that's just named __repr__ right >>> now. I could see us fixing that but I wouldn't think it's a high >>> priority unless someone finds implementing ICodeFormattable >>> burdensome. >>> >> Thanks, that did the trick (sample attached below)! It isn't >> burdensome, but I wonder about what will happen when we use IronRuby, >> too? We'll we need repr methods for each language? >> >> I also wonder if things like a generic list couldn't pick up a >> reasonable default __repr__ for use in all DLR languages. >> >> We're using the .NET languages in an educational environment for new >> students. Currently, we're going to have to add the __repr__ to all >> classes, and add subclasses to all types for which there isn't a >> reasonable repr default. For example, there is a pretty big >> difference between: "[255, 255, 128]" and " >> object at 0x000002C [List]>" or whatever it might >> be. >> >> In any event, we have a work around now; thanks again! >> >> -Doug >> >> using System; using IronPython.Runtime; // for ICodeFormattable using >> Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : >> ICodeFormattable { public virtual string __repr__(CodeContext >> context) { return String.Format(""); } } >> >> >> >>> -----Original Message----- From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >>> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >>> and __str__ use? >>> >>> Anyone have an answer for this: I can't write C# code that has its >>> own method for use in repr(). Am I missing something? >>> >>> -Doug >>> >>> Douglas S. Blank wrote: >>> >>>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>> >>>>> Douglas S. Blank kirjoitti: >>>>> >>>>>> will use it? Likewise, what C# method is used in Python's >>>>>> str(obj)? >>>>>> >>>>>> >>>>> i don't know, but would guess ToString() .. and wonder about it >>>>> if it wasn't that but something else :o repr() can't guess, i >>>>> don't think there's an equivalent in .net, but can very well be >>>>> mistaken there. >>>>> >>>> It looks like the C# method __str__ is used for the Python >>>> method, but in IP2B2 the C# method __repr__ is getting >>>> overwritten by an auto generated method. Is that a bug, or is >>>> there something I'm missing? >>>> >>>> $ ipy2 -i python/graphics.py >>>> >>>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>>> this calling? >>>>>>> >>>> >>>> >>>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>>>>>> >>>> '' >>>> >>>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>>>>>> >>>> '' >>>> >>>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>>> str() >>>>>>> >>>>>>> >>>> '' >>>> >>>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>>>>>> >>>> 'GraphicsCore+Pixel' >>>> >>>> -Doug >>>> >>>> >>>>>> -Doug >>>>>> >>>>>> >>>>> ~Toni >>>>> >>>>> _______________________________________________ Users mailing >>>>> list Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>>> >>> _______________________________________________ Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ 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 > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ From dinov at exchange.microsoft.com Wed May 28 23:52:31 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Wed, 28 May 2008 14:52:31 -0700 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <483DD12B.907@voidspace.org.uk> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC9C4.8010802@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DD12B.907@voidspace.org.uk> Message-ID: <7AD436E4270DD54A94238001769C2227012BC98527BF@DF-GRTDANE-MSG.exchange.corp.microsoft.com> It's funny that we added __new__ but no __repr__ for array. Anyway, I've opened bug #16833 (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16833) to fix all of them so feel free to vote for it. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord Sent: Wednesday, May 28, 2008 2:40 PM To: Discussion of IronPython Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? Dino Viehland wrote: > We could definitely add a __repr__ for the normal .NET lists (and even other standard types like Dictionary). Maybe something like Python's set's repr so it'd look like: > > List[object]([2, 3, 4]) > > Does that look good? > Spot on. Array could use the same love. Michael Foord > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank > Sent: Wednesday, May 28, 2008 2:08 PM > To: Discussion of IronPython > Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? > > Dino Viehland wrote: > >> The problem w/ a common __repr__ is that each language will >> presumably have different syntax for creating the object. For >> example a better repr in Python might be: >> >> Pixel(255,255,128) >> >> Where Ruby should probably display something like: >> >> Pixel.new(255,255,128) >> > > Agreed. But maybe there can be some name *patterns* that if implemented > once would suffice for most languages. I'm not too worried about this > though. > > >> Having a repr of [255,255,128] isn't that meaningful because if I >> copy and paste that into my code I get a list instead of a Pixel >> back. >> > > Sorry, I switched issues on you :) That was the point of that example... > generic lists don't look like lists at all. I'm actually more concerned > with this example than the previous. A generic list of ints, strings, > etc. ought to be able to have a better representation in IP. > > >> We could revisit what our default repr does for .NET objects >> that override ToString. We discussed it once on the list long ago >> but that was mainly focused on dealing w/ multi-line ToStrings if I >> recall correctly - the thought of playing better with multiple >> languages wasn't much of an issue back then for us. >> >> So basically I am open to suggestions :) >> > > Perhaps generic lists could inherit a version of Python List's __repr__? > (But of course, not just for Python, but for Ruby, etc.) > > Thanks! > > -Doug > > >> -----Original Message----- From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. >> Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of >> IronPython Subject: Re: [IronPython] What C# methods do __repr__ and >> __str__ use? >> >> Dino Viehland wrote: >> >>> You'll want to implement the ICodeFormattable interface. It looks >>> like we don't pick up a method that's just named __repr__ right >>> now. I could see us fixing that but I wouldn't think it's a high >>> priority unless someone finds implementing ICodeFormattable >>> burdensome. >>> >> Thanks, that did the trick (sample attached below)! It isn't >> burdensome, but I wonder about what will happen when we use IronRuby, >> too? We'll we need repr methods for each language? >> >> I also wonder if things like a generic list couldn't pick up a >> reasonable default __repr__ for use in all DLR languages. >> >> We're using the .NET languages in an educational environment for new >> students. Currently, we're going to have to add the __repr__ to all >> classes, and add subclasses to all types for which there isn't a >> reasonable repr default. For example, there is a pretty big >> difference between: "[255, 255, 128]" and " >> object at 0x000002C [List]>" or whatever it might >> be. >> >> In any event, we have a work around now; thanks again! >> >> -Doug >> >> using System; using IronPython.Runtime; // for ICodeFormattable using >> Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : >> ICodeFormattable { public virtual string __repr__(CodeContext >> context) { return String.Format(""); } } >> >> >> >>> -----Original Message----- From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >>> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >>> and __str__ use? >>> >>> Anyone have an answer for this: I can't write C# code that has its >>> own method for use in repr(). Am I missing something? >>> >>> -Doug >>> >>> Douglas S. Blank wrote: >>> >>>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>> >>>>> Douglas S. Blank kirjoitti: >>>>> >>>>>> will use it? Likewise, what C# method is used in Python's >>>>>> str(obj)? >>>>>> >>>>>> >>>>> i don't know, but would guess ToString() .. and wonder about it >>>>> if it wasn't that but something else :o repr() can't guess, i >>>>> don't think there's an equivalent in .net, but can very well be >>>>> mistaken there. >>>>> >>>> It looks like the C# method __str__ is used for the Python >>>> method, but in IP2B2 the C# method __repr__ is getting >>>> overwritten by an auto generated method. Is that a bug, or is >>>> there something I'm missing? >>>> >>>> $ ipy2 -i python/graphics.py >>>> >>>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>>> this calling? >>>>>>> >>>> >>>> >>>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>>>>>> >>>> '' >>>> >>>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>>>>>> >>>> '' >>>> >>>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>>> str() >>>>>>> >>>>>>> >>>> '' >>>> >>>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>>>>>> >>>> 'GraphicsCore+Pixel' >>>> >>>> -Doug >>>> >>>> >>>>>> -Doug >>>>>> >>>>>> >>>>> ~Toni >>>>> >>>>> _______________________________________________ Users mailing >>>>> list Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>>> >>> _______________________________________________ Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ 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 > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dblank at brynmawr.edu Thu May 29 00:05:14 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Wed, 28 May 2008 18:05:14 -0400 (EDT) Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange. corp.microsoft.com> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC9C4.8010802@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <43432.71.59.123.159.1212012314.squirrel@webmail.brynmawr.edu> On Wed, May 28, 2008 5:19 pm, Dino Viehland said: > We could definitely add a __repr__ for the normal .NET lists (and even > other standard types like Dictionary). Maybe something like Python's > set's repr so it'd look like: > > List[object]([2, 3, 4]) > > Does that look good? For our particular usage (new students using IronPython as their first language) this doesn't look so good. But if there will be a way that we can write C# code which can be loaded by Ruby, Python, etc and we can override the repr, then we can adapt. Currently, we're just using Python's list rather than the normal .NET generic list type. That works great (for Python). Will there be a list that will look native across dynamic languages? -Doug > -----Original Message----- > From: users-bounces at lists.ironpython.com > [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank > Sent: Wednesday, May 28, 2008 2:08 PM > To: Discussion of IronPython > Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? > > Dino Viehland wrote: >> The problem w/ a common __repr__ is that each language will >> presumably have different syntax for creating the object. For >> example a better repr in Python might be: >> >> Pixel(255,255,128) >> >> Where Ruby should probably display something like: >> >> Pixel.new(255,255,128) > > Agreed. But maybe there can be some name *patterns* that if implemented > once would suffice for most languages. I'm not too worried about this > though. > >> Having a repr of [255,255,128] isn't that meaningful because if I >> copy and paste that into my code I get a list instead of a Pixel >> back. > > Sorry, I switched issues on you :) That was the point of that example... > generic lists don't look like lists at all. I'm actually more concerned > with this example than the previous. A generic list of ints, strings, > etc. ought to be able to have a better representation in IP. > >> We could revisit what our default repr does for .NET objects >> that override ToString. We discussed it once on the list long ago >> but that was mainly focused on dealing w/ multi-line ToStrings if I >> recall correctly - the thought of playing better with multiple >> languages wasn't much of an issue back then for us. >> >> So basically I am open to suggestions :) > > Perhaps generic lists could inherit a version of Python List's __repr__? > (But of course, not just for Python, but for Ruby, etc.) > > Thanks! > > -Doug > >> -----Original Message----- From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. >> Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of >> IronPython Subject: Re: [IronPython] What C# methods do __repr__ and >> __str__ use? >> >> Dino Viehland wrote: >>> You'll want to implement the ICodeFormattable interface. It looks >>> like we don't pick up a method that's just named __repr__ right >>> now. I could see us fixing that but I wouldn't think it's a high >>> priority unless someone finds implementing ICodeFormattable >>> burdensome. >> >> Thanks, that did the trick (sample attached below)! It isn't >> burdensome, but I wonder about what will happen when we use IronRuby, >> too? We'll we need repr methods for each language? >> >> I also wonder if things like a generic list couldn't pick up a >> reasonable default __repr__ for use in all DLR languages. >> >> We're using the .NET languages in an educational environment for new >> students. Currently, we're going to have to add the __repr__ to all >> classes, and add subclasses to all types for which there isn't a >> reasonable repr default. For example, there is a pretty big >> difference between: "[255, 255, 128]" and " >> object at 0x000002C [List]>" or whatever it might >> be. >> >> In any event, we have a work around now; thanks again! >> >> -Doug >> >> using System; using IronPython.Runtime; // for ICodeFormattable using >> Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : >> ICodeFormattable { public virtual string __repr__(CodeContext >> context) { return String.Format(""); } } >> >> >>> -----Original Message----- From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >>> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >>> and __str__ use? >>> >>> Anyone have an answer for this: I can't write C# code that has its >>> own method for use in repr(). Am I missing something? >>> >>> -Doug >>> >>> Douglas S. Blank wrote: >>>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>>> Douglas S. Blank kirjoitti: >>>>>> will use it? Likewise, what C# method is used in Python's >>>>>> str(obj)? >>>>>> >>>>> i don't know, but would guess ToString() .. and wonder about it >>>>> if it wasn't that but something else :o repr() can't guess, i >>>>> don't think there's an equivalent in .net, but can very well be >>>>> mistaken there. >>>> It looks like the C# method __str__ is used for the Python >>>> method, but in IP2B2 the C# method __repr__ is getting >>>> overwritten by an auto generated method. Is that a bug, or is >>>> there something I'm missing? >>>> >>>> $ ipy2 -i python/graphics.py >>>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>>> this calling? >>>> >>>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>>> '' >>>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>>> '' >>>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>>> str() >>>>>>> >>>> '' >>>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>>> 'GraphicsCore+Pixel' >>>> >>>> -Doug >>>> >>>>>> -Doug >>>>>> >>>>> ~Toni >>>>> >>>>> _______________________________________________ Users mailing >>>>> list Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>> _______________________________________________ Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ 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 > -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From fuzzyman at voidspace.org.uk Thu May 29 00:07:14 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Wed, 28 May 2008 23:07:14 +0100 Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <43432.71.59.123.159.1212012314.squirrel@webmail.brynmawr.edu> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC9C4.8010802@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <43432.71.59.123.159.1212012314.squirrel@webmail.brynmawr.edu> Message-ID: <483DD792.9040201@voidspace.org.uk> Douglas S. Blank wrote: > On Wed, May 28, 2008 5:19 pm, Dino Viehland said: > >> We could definitely add a __repr__ for the normal .NET lists (and even >> other standard types like Dictionary). Maybe something like Python's >> set's repr so it'd look like: >> >> List[object]([2, 3, 4]) >> >> Does that look good? >> > > For our particular usage (new students using IronPython as their first > language) this doesn't look so good. But if there will be a way that we > can write C# code which can be loaded by Ruby, Python, etc and we can > override the repr, then we can adapt. > > The advantage of this representation is that it is exactly the same syntax you use to create it - which I would have thought ideal for a learning situation. Michael Foord > Currently, we're just using Python's list rather than the normal .NET > generic list type. That works great (for Python). Will there be a list > that will look native across dynamic languages? > > -Doug > > >> -----Original Message----- >> From: users-bounces at lists.ironpython.com >> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. Blank >> Sent: Wednesday, May 28, 2008 2:08 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? >> >> Dino Viehland wrote: >> >>> The problem w/ a common __repr__ is that each language will >>> presumably have different syntax for creating the object. For >>> example a better repr in Python might be: >>> >>> Pixel(255,255,128) >>> >>> Where Ruby should probably display something like: >>> >>> Pixel.new(255,255,128) >>> >> Agreed. But maybe there can be some name *patterns* that if implemented >> once would suffice for most languages. I'm not too worried about this >> though. >> >> >>> Having a repr of [255,255,128] isn't that meaningful because if I >>> copy and paste that into my code I get a list instead of a Pixel >>> back. >>> >> Sorry, I switched issues on you :) That was the point of that example... >> generic lists don't look like lists at all. I'm actually more concerned >> with this example than the previous. A generic list of ints, strings, >> etc. ought to be able to have a better representation in IP. >> >> >>> We could revisit what our default repr does for .NET objects >>> that override ToString. We discussed it once on the list long ago >>> but that was mainly focused on dealing w/ multi-line ToStrings if I >>> recall correctly - the thought of playing better with multiple >>> languages wasn't much of an issue back then for us. >>> >>> So basically I am open to suggestions :) >>> >> Perhaps generic lists could inherit a version of Python List's __repr__? >> (But of course, not just for Python, but for Ruby, etc.) >> >> Thanks! >> >> -Doug >> >> >>> -----Original Message----- From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. >>> Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of >>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ and >>> __str__ use? >>> >>> Dino Viehland wrote: >>> >>>> You'll want to implement the ICodeFormattable interface. It looks >>>> like we don't pick up a method that's just named __repr__ right >>>> now. I could see us fixing that but I wouldn't think it's a high >>>> priority unless someone finds implementing ICodeFormattable >>>> burdensome. >>>> >>> Thanks, that did the trick (sample attached below)! It isn't >>> burdensome, but I wonder about what will happen when we use IronRuby, >>> too? We'll we need repr methods for each language? >>> >>> I also wonder if things like a generic list couldn't pick up a >>> reasonable default __repr__ for use in all DLR languages. >>> >>> We're using the .NET languages in an educational environment for new >>> students. Currently, we're going to have to add the __repr__ to all >>> classes, and add subclasses to all types for which there isn't a >>> reasonable repr default. For example, there is a pretty big >>> difference between: "[255, 255, 128]" and " >>> object at 0x000002C [List]>" or whatever it might >>> be. >>> >>> In any event, we have a work around now; thanks again! >>> >>> -Doug >>> >>> using System; using IronPython.Runtime; // for ICodeFormattable using >>> Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : >>> ICodeFormattable { public virtual string __repr__(CodeContext >>> context) { return String.Format(""); } } >>> >>> >>> >>>> -----Original Message----- From: users-bounces at lists.ironpython.com >>>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >>>> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >>>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >>>> and __str__ use? >>>> >>>> Anyone have an answer for this: I can't write C# code that has its >>>> own method for use in repr(). Am I missing something? >>>> >>>> -Doug >>>> >>>> Douglas S. Blank wrote: >>>> >>>>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>>> >>>>>> Douglas S. Blank kirjoitti: >>>>>> >>>>>>> will use it? Likewise, what C# method is used in Python's >>>>>>> str(obj)? >>>>>>> >>>>>>> >>>>>> i don't know, but would guess ToString() .. and wonder about it >>>>>> if it wasn't that but something else :o repr() can't guess, i >>>>>> don't think there's an equivalent in .net, but can very well be >>>>>> mistaken there. >>>>>> >>>>> It looks like the C# method __str__ is used for the Python >>>>> method, but in IP2B2 the C# method __repr__ is getting >>>>> overwritten by an auto generated method. Is that a bug, or is >>>>> there something I'm missing? >>>>> >>>>> $ ipy2 -i python/graphics.py >>>>> >>>>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>>>> this calling? >>>>>>>> >>>>> >>>>> >>>>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>>>>>>> >>>>> '' >>>>> >>>>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>>>>>>> >>>>> '' >>>>> >>>>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>>>> str() >>>>>>>> >>>>>>>> >>>>> '' >>>>> >>>>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>>>>>>> >>>>> 'GraphicsCore+Pixel' >>>>> >>>>> -Doug >>>>> >>>>> >>>>>>> -Doug >>>>>>> >>>>>>> >>>>>> ~Toni >>>>>> >>>>>> _______________________________________________ Users mailing >>>>>> list Users at lists.ironpython.com >>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>> >>>>>> >>>> _______________________________________________ Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> _______________________________________________ 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 >> >> > > > -- http://www.ironpythoninaction.com/ http://www.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/ From dblank at brynmawr.edu Thu May 29 00:21:38 2008 From: dblank at brynmawr.edu (Douglas S. Blank) Date: Wed, 28 May 2008 18:21:38 -0400 (EDT) Subject: [IronPython] What C# methods do __repr__ and __str__ use? In-Reply-To: <483DD792.9040201@voidspace.org.uk> References: <17823.71.59.123.159.1211567260.squirrel@webmail.brynmawr.edu> <48371CEE.7080305@kyperjokki.fi> <34598.71.59.123.159.1211645443.squirrel@webmail.brynmawr.edu> <483DB0E4.9050400@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985272F@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC4D9.2000601@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC9852773@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <483DC9C4.8010802@brynmawr.edu> <7AD436E4270DD54A94238001769C2227012BC985278C@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <43432.71.59.123.159.1212012314.squirrel@webmail.brynmawr.edu> <483DD792.9040201@voidspace.org.uk> Message-ID: <33096.71.59.123.159.1212013298.squirrel@webmail.brynmawr.edu> On Wed, May 28, 2008 6:07 pm, Michael Foord said: > Douglas S. Blank wrote: >> On Wed, May 28, 2008 5:19 pm, Dino Viehland said: >> >>> We could definitely add a __repr__ for the normal .NET lists (and even >>> other standard types like Dictionary). Maybe something like Python's >>> set's repr so it'd look like: >>> >>> List[object]([2, 3, 4]) >>> >>> Does that look good? >>> >> >> For our particular usage (new students using IronPython as their first >> language) this doesn't look so good. But if there will be a way that we >> can write C# code which can be loaded by Ruby, Python, etc and we can >> override the repr, then we can adapt. > > The advantage of this representation is that it is exactly the same > syntax you use to create it - which I would have thought ideal for a > learning situation. Yes, indeed. However, on the first day of class when students do: >>> getRGB(pixel) List[object]([2, 3, 4]) we've just lost the battle :( I completely appreciate the repr for generic list, as it is symmetric---it allows you to cut and paste to go back and forth. I think the answer for us is to make sure that we have getRGB() return a native Python/Ruby list. Thanks all, for helping us come up with the right answer! -Doug > Michael Foord > >> Currently, we're just using Python's list rather than the normal .NET >> generic list type. That works great (for Python). Will there be a list >> that will look native across dynamic languages? >> >> -Doug >> >> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com >>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. >>> Blank >>> Sent: Wednesday, May 28, 2008 2:08 PM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] What C# methods do __repr__ and __str__ use? >>> >>> Dino Viehland wrote: >>> >>>> The problem w/ a common __repr__ is that each language will >>>> presumably have different syntax for creating the object. For >>>> example a better repr in Python might be: >>>> >>>> Pixel(255,255,128) >>>> >>>> Where Ruby should probably display something like: >>>> >>>> Pixel.new(255,255,128) >>>> >>> Agreed. But maybe there can be some name *patterns* that if implemented >>> once would suffice for most languages. I'm not too worried about this >>> though. >>> >>> >>>> Having a repr of [255,255,128] isn't that meaningful because if I >>>> copy and paste that into my code I get a list instead of a Pixel >>>> back. >>>> >>> Sorry, I switched issues on you :) That was the point of that >>> example... >>> generic lists don't look like lists at all. I'm actually more concerned >>> with this example than the previous. A generic list of ints, strings, >>> etc. ought to be able to have a better representation in IP. >>> >>> >>>> We could revisit what our default repr does for .NET objects >>>> that override ToString. We discussed it once on the list long ago >>>> but that was mainly focused on dealing w/ multi-line ToStrings if I >>>> recall correctly - the thought of playing better with multiple >>>> languages wasn't much of an issue back then for us. >>>> >>>> So basically I am open to suggestions :) >>>> >>> Perhaps generic lists could inherit a version of Python List's >>> __repr__? >>> (But of course, not just for Python, but for Ruby, etc.) >>> >>> Thanks! >>> >>> -Doug >>> >>> >>>> -----Original Message----- From: users-bounces at lists.ironpython.com >>>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas S. >>>> Blank Sent: Wednesday, May 28, 2008 1:47 PM To: Discussion of >>>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ and >>>> __str__ use? >>>> >>>> Dino Viehland wrote: >>>> >>>>> You'll want to implement the ICodeFormattable interface. It looks >>>>> like we don't pick up a method that's just named __repr__ right >>>>> now. I could see us fixing that but I wouldn't think it's a high >>>>> priority unless someone finds implementing ICodeFormattable >>>>> burdensome. >>>>> >>>> Thanks, that did the trick (sample attached below)! It isn't >>>> burdensome, but I wonder about what will happen when we use IronRuby, >>>> too? We'll we need repr methods for each language? >>>> >>>> I also wonder if things like a generic list couldn't pick up a >>>> reasonable default __repr__ for use in all DLR languages. >>>> >>>> We're using the .NET languages in an educational environment for new >>>> students. Currently, we're going to have to add the __repr__ to all >>>> classes, and add subclasses to all types for which there isn't a >>>> reasonable repr default. For example, there is a pretty big >>>> difference between: "[255, 255, 128]" and " >>>> object at 0x000002C [List]>" or whatever it might >>>> be. >>>> >>>> In any event, we have a work around now; thanks again! >>>> >>>> -Doug >>>> >>>> using System; using IronPython.Runtime; // for ICodeFormattable using >>>> Microsoft.Scripting.Runtime; // for CodeContext public class TestMe : >>>> ICodeFormattable { public virtual string __repr__(CodeContext >>>> context) { return String.Format(""); } } >>>> >>>> >>>> >>>>> -----Original Message----- From: users-bounces at lists.ironpython.com >>>>> [mailto:users-bounces at lists.ironpython.com] On Behalf Of Douglas >>>>> S. Blank Sent: Wednesday, May 28, 2008 12:22 PM To: Discussion of >>>>> IronPython Subject: Re: [IronPython] What C# methods do __repr__ >>>>> and __str__ use? >>>>> >>>>> Anyone have an answer for this: I can't write C# code that has its >>>>> own method for use in repr(). Am I missing something? >>>>> >>>>> -Doug >>>>> >>>>> Douglas S. Blank wrote: >>>>> >>>>>> On Fri, May 23, 2008 3:37 pm, Toni Alatalo said: >>>>>> >>>>>>> Douglas S. Blank kirjoitti: >>>>>>> >>>>>>>> will use it? Likewise, what C# method is used in Python's >>>>>>>> str(obj)? >>>>>>>> >>>>>>>> >>>>>>> i don't know, but would guess ToString() .. and wonder about it >>>>>>> if it wasn't that but something else :o repr() can't guess, i >>>>>>> don't think there's an equivalent in .net, but can very well be >>>>>>> mistaken there. >>>>>>> >>>>>> It looks like the C# method __str__ is used for the Python >>>>>> method, but in IP2B2 the C# method __repr__ is getting >>>>>> overwritten by an auto generated method. Is that a bug, or is >>>>>> there something I'm missing? >>>>>> >>>>>> $ ipy2 -i python/graphics.py >>>>>> >>>>>>>>> pm = Pixmap() pm.getPixel(0,0) # What is >>>>>>>>> this calling? >>>>>>>>> >>>>>> >>>>>> >>>>>>>>> pm.getPixel(0,0).__repr__() # This is repr() too >>>>>>>>> >>>>>> '' >>>>>> >>>>>>>>> pm.getPixel(0,0).__Repr__() # This is mine >>>>>>>>> >>>>>> '' >>>>>> >>>>>>>>> pm.getPixel(0,0).__str__() # That is mine, and >>>>>>>>> str() >>>>>>>>> >>>>>>>>> >>>>>> '' >>>>>> >>>>>>>>> pm.getPixel(0,0).ToString() # Used by __repr__ >>>>>>>>> >>>>>> 'GraphicsCore+Pixel' >>>>>> >>>>>> -Doug >>>>>> >>>>>> >>>>>>>> -Doug >>>>>>>> >>>>>>>> >>>>>>> ~Toni >>>>>>> >>>>>>> _______________________________________________ Users mailing >>>>>>> list Users at lists.ironpython.com >>>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>>> >>>>>>> >>>>> _______________________________________________ Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> _______________________________________________ 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 >>> >>> >> >> >> > > > -- > http://www.ironpythoninaction.com/ > http://www.theotherdelia.co.uk/ > http://www.voidspace.org.uk/ > http://www.ironpython.info/ > http://www.resolverhacks.net/ > > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Douglas S. Blank Associate Professor, Bryn Mawr College http://cs.brynmawr.edu/~dblank/ Office: 610 526 6501 From dan.eloff at gmail.com Thu May 29 16:07:22 2008 From: dan.eloff at gmail.com (Dan Eloff) Date: Thu, 29 May 2008 09:07:22 -0500 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: References: <4817b6fc0805281149i3801e714x29eed78bf9b5522f@mail.gmail.com> Message-ID: <4817b6fc0805290707w61d43365gde3ab7d654887259@mail.gmail.com> > Firefox on Windows ships with network.dns.disableIPv6 set to "false". Make > sure that's the setting you have (type about:config in the address bar). If > it's set to "true", Chiron won't get the request. (Actually, if you start > ANOTHER Chiron, that one will get the request =P). > > This bug will be fixed sometime today/tomorrow in sdlsdk; I'll let you guys > know when that happens. I'm glad that will be fixed, I seem to recall that the reason I changed that setting from the default was because it introduced unacceptable latency into the loading of pages in firefox. -Dan From slide.o.mix at gmail.com Thu May 29 17:13:33 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 08:13:33 -0700 Subject: [IronPython] hosting and SetVariable Message-ID: Perhaps this is just missing knowledge on my part, but here goes. I am using IP2.0 with the hosting API to add scripting support to my application. I use the following code to create my main module from the script file the user selects: ICompiledCode code = IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, path), _error_sink); __main__ = code.MakeModule("__main__") as ScriptScope; // create our module. ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); // add all the references the "Host" wanted. foreach (string assembly in _assemblies) Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); // set all the variables that the "Host" wanted set. foreach (KeyValuePair obj in _objects) __main__.SetVariable(obj.Key, obj.Value); The last foreach is setting up my object model which is available to my scripts. My problem arises when I want to use one of these variables from a script that is imported from the user selected script file. For instance, if I add an object _objects.Add("MyObj", someObj), I can reference that object in the user script as MyObj with no problem. What I would like to do is have these variables global to all scripts that are imported, etc. I tried import __main__ in my other scripts, but __main__ doesn't show up in sys.modules (which is what I thought PublishModule would do, but thats a different story). Am I going about this the wrong way? Thanks slide -- slide-o-blog http://slide-o-blog.blogspot.com/ From dinov at exchange.microsoft.com Thu May 29 17:37:21 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 08:37:21 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: Message-ID: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); Then you can do: import hello_world and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 8:14 AM To: Discussion of IronPython Subject: [IronPython] hosting and SetVariable Perhaps this is just missing knowledge on my part, but here goes. I am using IP2.0 with the hosting API to add scripting support to my application. I use the following code to create my main module from the script file the user selects: ICompiledCode code = IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, path), _error_sink); __main__ = code.MakeModule("__main__") as ScriptScope; // create our module. ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); // add all the references the "Host" wanted. foreach (string assembly in _assemblies) Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); // set all the variables that the "Host" wanted set. foreach (KeyValuePair obj in _objects) __main__.SetVariable(obj.Key, obj.Value); The last foreach is setting up my object model which is available to my scripts. My problem arises when I want to use one of these variables from a script that is imported from the user selected script file. For instance, if I add an object _objects.Add("MyObj", someObj), I can reference that object in the user script as MyObj with no problem. What I would like to do is have these variables global to all scripts that are imported, etc. I tried import __main__ in my other scripts, but __main__ doesn't show up in sys.modules (which is what I thought PublishModule would do, but thats a different story). Am I going about this the wrong way? Thanks 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 From slide.o.mix at gmail.com Thu May 29 17:42:20 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 08:42:20 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Apparently I need to update to the latest IP2.0 beta. I don't even see CurrentManager.Globals, thanks for the info. On Thu, May 29, 2008 at 8:37 AM, Dino Viehland wrote: > What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: > > ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); > > Then you can do: > > import hello_world > > and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 8:14 AM > To: Discussion of IronPython > Subject: [IronPython] hosting and SetVariable > > Perhaps this is just missing knowledge on my part, but here goes. > > I am using IP2.0 with the hosting API to add scripting support to my > application. I use the following code to create my main module from > the script file the user selects: > > ICompiledCode code = > IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, > path), _error_sink); > __main__ = code.MakeModule("__main__") as ScriptScope; > > // create our module. > ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); > > // add all the references the "Host" wanted. > foreach (string assembly in _assemblies) > Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); > > // set all the variables that the "Host" wanted set. > foreach (KeyValuePair obj in _objects) > __main__.SetVariable(obj.Key, obj.Value); > > The last foreach is setting up my object model which is available to > my scripts. My problem arises when I want to use one of these > variables from a script that is imported from the user selected script > file. > > For instance, if I add an object _objects.Add("MyObj", someObj), I can > reference that object in the user script as MyObj with no problem. > What I would like to do is have these variables global to all scripts > that are imported, etc. I tried import __main__ in my other scripts, > but __main__ doesn't show up in sys.modules (which is what I thought > PublishModule would do, but thats a different story). > > Am I going about this the wrong way? > > Thanks > > 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 > _______________________________________________ > 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 slide.o.mix at gmail.com Thu May 29 18:32:23 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 09:32:23 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Ok, one more question and I should be good to go. I used to call Microsoft.Scripting.ClrModule.GetInstance().AddReference to add references from my hosting code. With the latest beta, I don't see that anywhere and was wondering how to do this. thanks On Thu, May 29, 2008 at 8:42 AM, Slide wrote: > Apparently I need to update to the latest IP2.0 beta. I don't even see > CurrentManager.Globals, thanks for the info. > > On Thu, May 29, 2008 at 8:37 AM, Dino Viehland > wrote: >> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >> >> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >> >> Then you can do: >> >> import hello_world >> >> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:14 AM >> To: Discussion of IronPython >> Subject: [IronPython] hosting and SetVariable >> >> Perhaps this is just missing knowledge on my part, but here goes. >> >> I am using IP2.0 with the hosting API to add scripting support to my >> application. I use the following code to create my main module from >> the script file the user selects: >> >> ICompiledCode code = >> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >> path), _error_sink); >> __main__ = code.MakeModule("__main__") as ScriptScope; >> >> // create our module. >> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >> >> // add all the references the "Host" wanted. >> foreach (string assembly in _assemblies) >> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >> >> // set all the variables that the "Host" wanted set. >> foreach (KeyValuePair obj in _objects) >> __main__.SetVariable(obj.Key, obj.Value); >> >> The last foreach is setting up my object model which is available to >> my scripts. My problem arises when I want to use one of these >> variables from a script that is imported from the user selected script >> file. >> >> For instance, if I add an object _objects.Add("MyObj", someObj), I can >> reference that object in the user script as MyObj with no problem. >> What I would like to do is have these variables global to all scripts >> that are imported, etc. I tried import __main__ in my other scripts, >> but __main__ doesn't show up in sys.modules (which is what I thought >> PublishModule would do, but thats a different story). >> >> Am I going about this the wrong way? >> >> Thanks >> >> 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 >> _______________________________________________ >> 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/ > -- slide-o-blog http://slide-o-blog.blogspot.com/ From dinov at exchange.microsoft.com Thu May 29 19:03:18 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 10:03:18 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852961@DF-GRTDANE-MSG.exchange.corp.microsoft.com> ScriptRuntime.LoadAssembly is the equivalent. The only difference is there's no string overload so you need to pass it the actual Assembly object yourself which gives you control over how it gets loaded. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 9:32 AM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable Ok, one more question and I should be good to go. I used to call Microsoft.Scripting.ClrModule.GetInstance().AddReference to add references from my hosting code. With the latest beta, I don't see that anywhere and was wondering how to do this. thanks On Thu, May 29, 2008 at 8:42 AM, Slide wrote: > Apparently I need to update to the latest IP2.0 beta. I don't even see > CurrentManager.Globals, thanks for the info. > > On Thu, May 29, 2008 at 8:37 AM, Dino Viehland > wrote: >> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >> >> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >> >> Then you can do: >> >> import hello_world >> >> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:14 AM >> To: Discussion of IronPython >> Subject: [IronPython] hosting and SetVariable >> >> Perhaps this is just missing knowledge on my part, but here goes. >> >> I am using IP2.0 with the hosting API to add scripting support to my >> application. I use the following code to create my main module from >> the script file the user selects: >> >> ICompiledCode code = >> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >> path), _error_sink); >> __main__ = code.MakeModule("__main__") as ScriptScope; >> >> // create our module. >> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >> >> // add all the references the "Host" wanted. >> foreach (string assembly in _assemblies) >> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >> >> // set all the variables that the "Host" wanted set. >> foreach (KeyValuePair obj in _objects) >> __main__.SetVariable(obj.Key, obj.Value); >> >> The last foreach is setting up my object model which is available to >> my scripts. My problem arises when I want to use one of these >> variables from a script that is imported from the user selected script >> file. >> >> For instance, if I add an object _objects.Add("MyObj", someObj), I can >> reference that object in the user script as MyObj with no problem. >> What I would like to do is have these variables global to all scripts >> that are imported, etc. I tried import __main__ in my other scripts, >> but __main__ doesn't show up in sys.modules (which is what I thought >> PublishModule would do, but thats a different story). >> >> Am I going about this the wrong way? >> >> Thanks >> >> 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 >> _______________________________________________ >> 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/ > -- 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 From seshapv at microsoft.com Thu May 29 19:11:04 2008 From: seshapv at microsoft.com (Seshadri Pillailokam Vijayaraghavan) Date: Thu, 29 May 2008 10:11:04 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). Thanks Sesh -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 8:42 AM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable Apparently I need to update to the latest IP2.0 beta. I don't even see CurrentManager.Globals, thanks for the info. On Thu, May 29, 2008 at 8:37 AM, Dino Viehland wrote: > What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: > > ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); > > Then you can do: > > import hello_world > > and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 8:14 AM > To: Discussion of IronPython > Subject: [IronPython] hosting and SetVariable > > Perhaps this is just missing knowledge on my part, but here goes. > > I am using IP2.0 with the hosting API to add scripting support to my > application. I use the following code to create my main module from > the script file the user selects: > > ICompiledCode code = > IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, > path), _error_sink); > __main__ = code.MakeModule("__main__") as ScriptScope; > > // create our module. > ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); > > // add all the references the "Host" wanted. > foreach (string assembly in _assemblies) > Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); > > // set all the variables that the "Host" wanted set. > foreach (KeyValuePair obj in _objects) > __main__.SetVariable(obj.Key, obj.Value); > > The last foreach is setting up my object model which is available to > my scripts. My problem arises when I want to use one of these > variables from a script that is imported from the user selected script > file. > > For instance, if I add an object _objects.Add("MyObj", someObj), I can > reference that object in the user script as MyObj with no problem. > What I would like to do is have these variables global to all scripts > that are imported, etc. I tried import __main__ in my other scripts, > but __main__ doesn't show up in sys.modules (which is what I thought > PublishModule would do, but thats a different story). > > Am I going about this the wrong way? > > Thanks > > 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 > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Thu May 29 20:33:35 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 11:33:35 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> Message-ID: Thanks that will be helpful. Is there any documentation specific to IronPython? I would like to do some introspection on modules and such (to retrieve types defined in the module and so forth) and I used to do that with some PythonType magic which doesn't seem to work anymore (ScriptScope is not convertable to Scope when calling Get__dict__). Thanks again! On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan wrote: > The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. > It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). > > Thanks > Sesh > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 8:42 AM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > Apparently I need to update to the latest IP2.0 beta. I don't even see > CurrentManager.Globals, thanks for the info. > > On Thu, May 29, 2008 at 8:37 AM, Dino Viehland > wrote: >> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >> >> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >> >> Then you can do: >> >> import hello_world >> >> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:14 AM >> To: Discussion of IronPython >> Subject: [IronPython] hosting and SetVariable >> >> Perhaps this is just missing knowledge on my part, but here goes. >> >> I am using IP2.0 with the hosting API to add scripting support to my >> application. I use the following code to create my main module from >> the script file the user selects: >> >> ICompiledCode code = >> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >> path), _error_sink); >> __main__ = code.MakeModule("__main__") as ScriptScope; >> >> // create our module. >> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >> >> // add all the references the "Host" wanted. >> foreach (string assembly in _assemblies) >> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >> >> // set all the variables that the "Host" wanted set. >> foreach (KeyValuePair obj in _objects) >> __main__.SetVariable(obj.Key, obj.Value); >> >> The last foreach is setting up my object model which is available to >> my scripts. My problem arises when I want to use one of these >> variables from a script that is imported from the user selected script >> file. >> >> For instance, if I add an object _objects.Add("MyObj", someObj), I can >> reference that object in the user script as MyObj with no problem. >> What I would like to do is have these variables global to all scripts >> that are imported, etc. I tried import __main__ in my other scripts, >> but __main__ doesn't show up in sys.modules (which is what I thought >> PublishModule would do, but thats a different story). >> >> Am I going about this the wrong way? >> >> Thanks >> >> 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 >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > 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 dinov at exchange.microsoft.com Thu May 29 20:56:04 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 11:56:04 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 11:34 AM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable Thanks that will be helpful. Is there any documentation specific to IronPython? I would like to do some introspection on modules and such (to retrieve types defined in the module and so forth) and I used to do that with some PythonType magic which doesn't seem to work anymore (ScriptScope is not convertable to Scope when calling Get__dict__). Thanks again! On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan wrote: > The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. > It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). > > Thanks > Sesh > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 8:42 AM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > Apparently I need to update to the latest IP2.0 beta. I don't even see > CurrentManager.Globals, thanks for the info. > > On Thu, May 29, 2008 at 8:37 AM, Dino Viehland > wrote: >> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >> >> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >> >> Then you can do: >> >> import hello_world >> >> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:14 AM >> To: Discussion of IronPython >> Subject: [IronPython] hosting and SetVariable >> >> Perhaps this is just missing knowledge on my part, but here goes. >> >> I am using IP2.0 with the hosting API to add scripting support to my >> application. I use the following code to create my main module from >> the script file the user selects: >> >> ICompiledCode code = >> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >> path), _error_sink); >> __main__ = code.MakeModule("__main__") as ScriptScope; >> >> // create our module. >> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >> >> // add all the references the "Host" wanted. >> foreach (string assembly in _assemblies) >> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >> >> // set all the variables that the "Host" wanted set. >> foreach (KeyValuePair obj in _objects) >> __main__.SetVariable(obj.Key, obj.Value); >> >> The last foreach is setting up my object model which is available to >> my scripts. My problem arises when I want to use one of these >> variables from a script that is imported from the user selected script >> file. >> >> For instance, if I add an object _objects.Add("MyObj", someObj), I can >> reference that object in the user script as MyObj with no problem. >> What I would like to do is have these variables global to all scripts >> that are imported, etc. I tried import __main__ in my other scripts, >> but __main__ doesn't show up in sys.modules (which is what I thought >> PublishModule would do, but thats a different story). >> >> Am I going about this the wrong way? >> >> Thanks >> >> 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 >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Thu May 29 21:12:54 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 12:12:54 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: It may be able to be accomplished with ObjectOperations. What I am trying to do is find all the types defined in my ScriptScope and determine if they are subclasses (or implementers) of another type. I used to do this using the PythonType class with UnderlyingSystemType and so forth, but all that stuff is gone in the beta 2 I downloaded. Also, I didn't see HostingHelpers.GetScope anywhere, is this from an external library (I checked Microsoft.Scripting, Microsoft.Scripting.Core and the IronPython assemblies) On Thu, May 29, 2008 at 11:56 AM, Dino Viehland wrote: > Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? > > Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 11:34 AM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > Thanks that will be helpful. Is there any documentation specific to > IronPython? I would like to do some introspection on modules and such > (to retrieve types defined in the module and so forth) and I used to > do that with some PythonType magic which doesn't seem to work anymore > (ScriptScope is not convertable to Scope when calling Get__dict__). > > Thanks again! > > On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan > wrote: >> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >> >> Thanks >> Sesh >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:42 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> Apparently I need to update to the latest IP2.0 beta. I don't even see >> CurrentManager.Globals, thanks for the info. >> >> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >> wrote: >>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>> >>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>> >>> Then you can do: >>> >>> import hello_world >>> >>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 8:14 AM >>> To: Discussion of IronPython >>> Subject: [IronPython] hosting and SetVariable >>> >>> Perhaps this is just missing knowledge on my part, but here goes. >>> >>> I am using IP2.0 with the hosting API to add scripting support to my >>> application. I use the following code to create my main module from >>> the script file the user selects: >>> >>> ICompiledCode code = >>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>> path), _error_sink); >>> __main__ = code.MakeModule("__main__") as ScriptScope; >>> >>> // create our module. >>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>> >>> // add all the references the "Host" wanted. >>> foreach (string assembly in _assemblies) >>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>> >>> // set all the variables that the "Host" wanted set. >>> foreach (KeyValuePair obj in _objects) >>> __main__.SetVariable(obj.Key, obj.Value); >>> >>> The last foreach is setting up my object model which is available to >>> my scripts. My problem arises when I want to use one of these >>> variables from a script that is imported from the user selected script >>> file. >>> >>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>> reference that object in the user script as MyObj with no problem. >>> What I would like to do is have these variables global to all scripts >>> that are imported, etc. I tried import __main__ in my other scripts, >>> but __main__ doesn't show up in sys.modules (which is what I thought >>> PublishModule would do, but thats a different story). >>> >>> Am I going about this the wrong way? >>> >>> Thanks >>> >>> 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 >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > 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 seshapv at microsoft.com Thu May 29 21:17:21 2008 From: seshapv at microsoft.com (Seshadri Pillailokam Vijayaraghavan) Date: Thu, 29 May 2008 12:17:21 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 12:13 PM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable It may be able to be accomplished with ObjectOperations. What I am trying to do is find all the types defined in my ScriptScope and determine if they are subclasses (or implementers) of another type. I used to do this using the PythonType class with UnderlyingSystemType and so forth, but all that stuff is gone in the beta 2 I downloaded. Also, I didn't see HostingHelpers.GetScope anywhere, is this from an external library (I checked Microsoft.Scripting, Microsoft.Scripting.Core and the IronPython assemblies) On Thu, May 29, 2008 at 11:56 AM, Dino Viehland wrote: > Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? > > Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 11:34 AM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > Thanks that will be helpful. Is there any documentation specific to > IronPython? I would like to do some introspection on modules and such > (to retrieve types defined in the module and so forth) and I used to > do that with some PythonType magic which doesn't seem to work anymore > (ScriptScope is not convertable to Scope when calling Get__dict__). > > Thanks again! > > On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan > wrote: >> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >> >> Thanks >> Sesh >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:42 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> Apparently I need to update to the latest IP2.0 beta. I don't even see >> CurrentManager.Globals, thanks for the info. >> >> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >> wrote: >>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>> >>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>> >>> Then you can do: >>> >>> import hello_world >>> >>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 8:14 AM >>> To: Discussion of IronPython >>> Subject: [IronPython] hosting and SetVariable >>> >>> Perhaps this is just missing knowledge on my part, but here goes. >>> >>> I am using IP2.0 with the hosting API to add scripting support to my >>> application. I use the following code to create my main module from >>> the script file the user selects: >>> >>> ICompiledCode code = >>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>> path), _error_sink); >>> __main__ = code.MakeModule("__main__") as ScriptScope; >>> >>> // create our module. >>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>> >>> // add all the references the "Host" wanted. >>> foreach (string assembly in _assemblies) >>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>> >>> // set all the variables that the "Host" wanted set. >>> foreach (KeyValuePair obj in _objects) >>> __main__.SetVariable(obj.Key, obj.Value); >>> >>> The last foreach is setting up my object model which is available to >>> my scripts. My problem arises when I want to use one of these >>> variables from a script that is imported from the user selected script >>> file. >>> >>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>> reference that object in the user script as MyObj with no problem. >>> What I would like to do is have these variables global to all scripts >>> that are imported, etc. I tried import __main__ in my other scripts, >>> but __main__ doesn't show up in sys.modules (which is what I thought >>> PublishModule would do, but thats a different story). >>> >>> Am I going about this the wrong way? >>> >>> Thanks >>> >>> 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 >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From dinov at exchange.microsoft.com Thu May 29 21:30:55 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 12:30:55 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852A04@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I'd suggest PythonOps.IsSubClass(typeFromScope, DynamicHelpers.GetPythonTypeFromType(yourType)). Or better yet would be using Builtin.issubclass(...). One warning is that the members of DynamicHelpers will likely move to PythonOps at some point before V2 RTM. We could make issubclass accept .NET type objects as well which would make that even simpler. Just some rational on why we moved everything off of PythonType. We had been moving towards a world where all of our implementations of Python objects public API surface consists only of the API surface you expect to see exposed in Python. Additionally we've been renaming anything that is public to match the Python name - instead of having an attribute which is the Python name. That reduces the amount of reflection we need to do to bring in types. PythonType was the last type to get that cleanup so you won't see any more of that going forward. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 12:13 PM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable It may be able to be accomplished with ObjectOperations. What I am trying to do is find all the types defined in my ScriptScope and determine if they are subclasses (or implementers) of another type. I used to do this using the PythonType class with UnderlyingSystemType and so forth, but all that stuff is gone in the beta 2 I downloaded. Also, I didn't see HostingHelpers.GetScope anywhere, is this from an external library (I checked Microsoft.Scripting, Microsoft.Scripting.Core and the IronPython assemblies) On Thu, May 29, 2008 at 11:56 AM, Dino Viehland wrote: > Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? > > Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 11:34 AM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > Thanks that will be helpful. Is there any documentation specific to > IronPython? I would like to do some introspection on modules and such > (to retrieve types defined in the module and so forth) and I used to > do that with some PythonType magic which doesn't seem to work anymore > (ScriptScope is not convertable to Scope when calling Get__dict__). > > Thanks again! > > On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan > wrote: >> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >> >> Thanks >> Sesh >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 8:42 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> Apparently I need to update to the latest IP2.0 beta. I don't even see >> CurrentManager.Globals, thanks for the info. >> >> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >> wrote: >>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>> >>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>> >>> Then you can do: >>> >>> import hello_world >>> >>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 8:14 AM >>> To: Discussion of IronPython >>> Subject: [IronPython] hosting and SetVariable >>> >>> Perhaps this is just missing knowledge on my part, but here goes. >>> >>> I am using IP2.0 with the hosting API to add scripting support to my >>> application. I use the following code to create my main module from >>> the script file the user selects: >>> >>> ICompiledCode code = >>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>> path), _error_sink); >>> __main__ = code.MakeModule("__main__") as ScriptScope; >>> >>> // create our module. >>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>> >>> // add all the references the "Host" wanted. >>> foreach (string assembly in _assemblies) >>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>> >>> // set all the variables that the "Host" wanted set. >>> foreach (KeyValuePair obj in _objects) >>> __main__.SetVariable(obj.Key, obj.Value); >>> >>> The last foreach is setting up my object model which is available to >>> my scripts. My problem arises when I want to use one of these >>> variables from a script that is imported from the user selected script >>> file. >>> >>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>> reference that object in the user script as MyObj with no problem. >>> What I would like to do is have these variables global to all scripts >>> that are imported, etc. I tried import __main__ in my other scripts, >>> but __main__ doesn't show up in sys.modules (which is what I thought >>> PublishModule would do, but thats a different story). >>> >>> Am I going about this the wrong way? >>> >>> Thanks >>> >>> 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 >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Thu May 29 21:38:31 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 12:38:31 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> Message-ID: That class is not available in Beta2. I also downloaded the latest source and checked the implementation of GetScope, it calls ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with all this stuff coming out soon? thanks On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan wrote: > It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 12:13 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > It may be able to be accomplished with ObjectOperations. What I am > trying to do is find all the types defined in my ScriptScope and > determine if they are subclasses (or implementers) of another type. I > used to do this using the PythonType class with UnderlyingSystemType > and so forth, but all that stuff is gone in the beta 2 I downloaded. > Also, I didn't see HostingHelpers.GetScope anywhere, is this from an > external library (I checked Microsoft.Scripting, > Microsoft.Scripting.Core and the IronPython assemblies) > > On Thu, May 29, 2008 at 11:56 AM, Dino Viehland > wrote: >> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >> >> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 11:34 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> Thanks that will be helpful. Is there any documentation specific to >> IronPython? I would like to do some introspection on modules and such >> (to retrieve types defined in the module and so forth) and I used to >> do that with some PythonType magic which doesn't seem to work anymore >> (ScriptScope is not convertable to Scope when calling Get__dict__). >> >> Thanks again! >> >> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >> wrote: >>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>> >>> Thanks >>> Sesh >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 8:42 AM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>> CurrentManager.Globals, thanks for the info. >>> >>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>> wrote: >>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>> >>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>> >>>> Then you can do: >>>> >>>> import hello_world >>>> >>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 8:14 AM >>>> To: Discussion of IronPython >>>> Subject: [IronPython] hosting and SetVariable >>>> >>>> Perhaps this is just missing knowledge on my part, but here goes. >>>> >>>> I am using IP2.0 with the hosting API to add scripting support to my >>>> application. I use the following code to create my main module from >>>> the script file the user selects: >>>> >>>> ICompiledCode code = >>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>> path), _error_sink); >>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>> >>>> // create our module. >>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>> >>>> // add all the references the "Host" wanted. >>>> foreach (string assembly in _assemblies) >>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>> >>>> // set all the variables that the "Host" wanted set. >>>> foreach (KeyValuePair obj in _objects) >>>> __main__.SetVariable(obj.Key, obj.Value); >>>> >>>> The last foreach is setting up my object model which is available to >>>> my scripts. My problem arises when I want to use one of these >>>> variables from a script that is imported from the user selected script >>>> file. >>>> >>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>> reference that object in the user script as MyObj with no problem. >>>> What I would like to do is have these variables global to all scripts >>>> that are imported, etc. I tried import __main__ in my other scripts, >>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>> PublishModule would do, but thats a different story). >>>> >>>> Am I going about this the wrong way? >>>> >>>> Thanks >>>> >>>> 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 >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > 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 dinov at exchange.microsoft.com Thu May 29 21:46:52 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 12:46:52 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Sorry, I didn't realize that was a recent addition. Can you just iterate over ScriptScope.Items - I checked and it's there in B2 :). As for beta 3 the plan is sometime in June. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 12:39 PM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable That class is not available in Beta2. I also downloaded the latest source and checked the implementation of GetScope, it calls ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with all this stuff coming out soon? thanks On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan wrote: > It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 12:13 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > It may be able to be accomplished with ObjectOperations. What I am > trying to do is find all the types defined in my ScriptScope and > determine if they are subclasses (or implementers) of another type. I > used to do this using the PythonType class with UnderlyingSystemType > and so forth, but all that stuff is gone in the beta 2 I downloaded. > Also, I didn't see HostingHelpers.GetScope anywhere, is this from an > external library (I checked Microsoft.Scripting, > Microsoft.Scripting.Core and the IronPython assemblies) > > On Thu, May 29, 2008 at 11:56 AM, Dino Viehland > wrote: >> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >> >> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 11:34 AM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> Thanks that will be helpful. Is there any documentation specific to >> IronPython? I would like to do some introspection on modules and such >> (to retrieve types defined in the module and so forth) and I used to >> do that with some PythonType magic which doesn't seem to work anymore >> (ScriptScope is not convertable to Scope when calling Get__dict__). >> >> Thanks again! >> >> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >> wrote: >>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>> >>> Thanks >>> Sesh >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 8:42 AM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>> CurrentManager.Globals, thanks for the info. >>> >>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>> wrote: >>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>> >>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>> >>>> Then you can do: >>>> >>>> import hello_world >>>> >>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 8:14 AM >>>> To: Discussion of IronPython >>>> Subject: [IronPython] hosting and SetVariable >>>> >>>> Perhaps this is just missing knowledge on my part, but here goes. >>>> >>>> I am using IP2.0 with the hosting API to add scripting support to my >>>> application. I use the following code to create my main module from >>>> the script file the user selects: >>>> >>>> ICompiledCode code = >>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>> path), _error_sink); >>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>> >>>> // create our module. >>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>> >>>> // add all the references the "Host" wanted. >>>> foreach (string assembly in _assemblies) >>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>> >>>> // set all the variables that the "Host" wanted set. >>>> foreach (KeyValuePair obj in _objects) >>>> __main__.SetVariable(obj.Key, obj.Value); >>>> >>>> The last foreach is setting up my object model which is available to >>>> my scripts. My problem arises when I want to use one of these >>>> variables from a script that is imported from the user selected script >>>> file. >>>> >>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>> reference that object in the user script as MyObj with no problem. >>>> What I would like to do is have these variables global to all scripts >>>> that are imported, etc. I tried import __main__ in my other scripts, >>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>> PublishModule would do, but thats a different story). >>>> >>>> Am I going about this the wrong way? >>>> >>>> Thanks >>>> >>>> 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 >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Thu May 29 21:52:21 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 12:52:21 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: ScriptScope.Item doesn't have my class definition in there. Perhaps I am not doing the initial setup correctly. _runtime.Globals.ClearVariables(); _engine = _runtime.GetEngine("py"); foreach (KeyValuePair obj in _objects) _runtime.Globals.SetVariable(obj.Key, obj.Value); _error_listener = new ScriptErrorListener(); // setup the paths to search for modules List paths = new List(); paths.Add(Environment.CurrentDirectory); paths.Add(Path.Combine(Environment.CurrentDirectory, "Lib")); paths.Add(Path.GetDirectoryName(path)); string[] probe_paths = Directory.GetDirectories(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); paths.AddRange(probe_paths); _engine.SetScriptSourceSearchPaths(paths.ToArray()); CompiledCode code = _engine.CreateScriptSourceFromFile(path).Compile(_error_listener); _scope = code.MakeOptimizedScope(); code.Execute(_scope); _engine.PublishModule("__main__", _scope); // add all the references the "Host" wanted. foreach (string assembly in _assemblies) _runtime.LoadAssembly(Assembly.LoadFrom(assembly)); The code I am passing in contains the following: import ScriptTester class MyClass(ScriptTester.ITest): def DoIt(self, msg): print msg When I iterate over _scope.Items, I don't see "MyClass" in the list of items. Thanks On Thu, May 29, 2008 at 12:46 PM, Dino Viehland wrote: > Sorry, I didn't realize that was a recent addition. Can you just iterate over ScriptScope.Items - I checked and it's there in B2 :). > > As for beta 3 the plan is sometime in June. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 12:39 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > That class is not available in Beta2. I also downloaded the latest > source and checked the implementation of GetScope, it calls > ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with > all this stuff coming out soon? > > thanks > > On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan > wrote: >> It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' >> >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 12:13 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> It may be able to be accomplished with ObjectOperations. What I am >> trying to do is find all the types defined in my ScriptScope and >> determine if they are subclasses (or implementers) of another type. I >> used to do this using the PythonType class with UnderlyingSystemType >> and so forth, but all that stuff is gone in the beta 2 I downloaded. >> Also, I didn't see HostingHelpers.GetScope anywhere, is this from an >> external library (I checked Microsoft.Scripting, >> Microsoft.Scripting.Core and the IronPython assemblies) >> >> On Thu, May 29, 2008 at 11:56 AM, Dino Viehland >> wrote: >>> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >>> >>> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 11:34 AM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> Thanks that will be helpful. Is there any documentation specific to >>> IronPython? I would like to do some introspection on modules and such >>> (to retrieve types defined in the module and so forth) and I used to >>> do that with some PythonType magic which doesn't seem to work anymore >>> (ScriptScope is not convertable to Scope when calling Get__dict__). >>> >>> Thanks again! >>> >>> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >>> wrote: >>>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>>> >>>> Thanks >>>> Sesh >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 8:42 AM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] hosting and SetVariable >>>> >>>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>>> CurrentManager.Globals, thanks for the info. >>>> >>>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>>> wrote: >>>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>>> >>>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>>> >>>>> Then you can do: >>>>> >>>>> import hello_world >>>>> >>>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>>> >>>>> -----Original Message----- >>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>> Sent: Thursday, May 29, 2008 8:14 AM >>>>> To: Discussion of IronPython >>>>> Subject: [IronPython] hosting and SetVariable >>>>> >>>>> Perhaps this is just missing knowledge on my part, but here goes. >>>>> >>>>> I am using IP2.0 with the hosting API to add scripting support to my >>>>> application. I use the following code to create my main module from >>>>> the script file the user selects: >>>>> >>>>> ICompiledCode code = >>>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>>> path), _error_sink); >>>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>>> >>>>> // create our module. >>>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>>> >>>>> // add all the references the "Host" wanted. >>>>> foreach (string assembly in _assemblies) >>>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>>> >>>>> // set all the variables that the "Host" wanted set. >>>>> foreach (KeyValuePair obj in _objects) >>>>> __main__.SetVariable(obj.Key, obj.Value); >>>>> >>>>> The last foreach is setting up my object model which is available to >>>>> my scripts. My problem arises when I want to use one of these >>>>> variables from a script that is imported from the user selected script >>>>> file. >>>>> >>>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>>> reference that object in the user script as MyObj with no problem. >>>>> What I would like to do is have these variables global to all scripts >>>>> that are imported, etc. I tried import __main__ in my other scripts, >>>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>>> PublishModule would do, but thats a different story). >>>>> >>>>> Am I going about this the wrong way? >>>>> >>>>> Thanks >>>>> >>>>> 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 >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>> >>>> >>>> >>>> -- >>>> slide-o-blog >>>> http://slide-o-blog.blogspot.com/ >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > 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 dinov at exchange.microsoft.com Thu May 29 22:22:17 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 13:22:17 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <7AD436E4270DD54A94238001769C2227012BC985291D@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852A26@DF-GRTDANE-MSG.exchange.corp.microsoft.com> There's something strange going on. This small program on 2.0B2: using System; using System.Collections.Generic; using System.Reflection; using Microsoft.Scripting; using Microsoft.Scripting.Hosting; class Test { public static void Main(string[]args) { ScriptRuntime runtime = ScriptRuntime.Create(); runtime.Globals.ClearVariables(); ScriptEngine engine = runtime.GetEngine("py"); CompiledCode code = engine.CreateScriptSourceFromFile("test.py").Compile(); ScriptScope scope = code.MakeOptimizedScope(); code.Execute(scope); foreach(KeyValuePair kvp in scope.Items) { Console.WriteLine("{0} {1}", kvp.Key, kvp.Value); } } } With test.py containing: class x(object): pass prints: __builtins__ IronPython.Runtime.PythonDictionary x IronPython.Runtime.Types.PythonType I'm not sure what the difference would be off the top of my head as that's basically what you're doing minus the additional setup. Can you try reducing some of the additional steps and seeing if you can get a basic type to show up? -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 12:52 PM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable ScriptScope.Item doesn't have my class definition in there. Perhaps I am not doing the initial setup correctly. _runtime.Globals.ClearVariables(); _engine = _runtime.GetEngine("py"); foreach (KeyValuePair obj in _objects) _runtime.Globals.SetVariable(obj.Key, obj.Value); _error_listener = new ScriptErrorListener(); // setup the paths to search for modules List paths = new List(); paths.Add(Environment.CurrentDirectory); paths.Add(Path.Combine(Environment.CurrentDirectory, "Lib")); paths.Add(Path.GetDirectoryName(path)); string[] probe_paths = Directory.GetDirectories(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); paths.AddRange(probe_paths); _engine.SetScriptSourceSearchPaths(paths.ToArray()); CompiledCode code = _engine.CreateScriptSourceFromFile(path).Compile(_error_listener); _scope = code.MakeOptimizedScope(); code.Execute(_scope); _engine.PublishModule("__main__", _scope); // add all the references the "Host" wanted. foreach (string assembly in _assemblies) _runtime.LoadAssembly(Assembly.LoadFrom(assembly)); The code I am passing in contains the following: import ScriptTester class MyClass(ScriptTester.ITest): def DoIt(self, msg): print msg When I iterate over _scope.Items, I don't see "MyClass" in the list of items. Thanks On Thu, May 29, 2008 at 12:46 PM, Dino Viehland wrote: > Sorry, I didn't realize that was a recent addition. Can you just iterate over ScriptScope.Items - I checked and it's there in B2 :). > > As for beta 3 the plan is sometime in June. > > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 12:39 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > That class is not available in Beta2. I also downloaded the latest > source and checked the implementation of GetScope, it calls > ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with > all this stuff coming out soon? > > thanks > > On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan > wrote: >> It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' >> >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 12:13 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> It may be able to be accomplished with ObjectOperations. What I am >> trying to do is find all the types defined in my ScriptScope and >> determine if they are subclasses (or implementers) of another type. I >> used to do this using the PythonType class with UnderlyingSystemType >> and so forth, but all that stuff is gone in the beta 2 I downloaded. >> Also, I didn't see HostingHelpers.GetScope anywhere, is this from an >> external library (I checked Microsoft.Scripting, >> Microsoft.Scripting.Core and the IronPython assemblies) >> >> On Thu, May 29, 2008 at 11:56 AM, Dino Viehland >> wrote: >>> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >>> >>> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 11:34 AM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> Thanks that will be helpful. Is there any documentation specific to >>> IronPython? I would like to do some introspection on modules and such >>> (to retrieve types defined in the module and so forth) and I used to >>> do that with some PythonType magic which doesn't seem to work anymore >>> (ScriptScope is not convertable to Scope when calling Get__dict__). >>> >>> Thanks again! >>> >>> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >>> wrote: >>>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>>> >>>> Thanks >>>> Sesh >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 8:42 AM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] hosting and SetVariable >>>> >>>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>>> CurrentManager.Globals, thanks for the info. >>>> >>>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>>> wrote: >>>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>>> >>>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>>> >>>>> Then you can do: >>>>> >>>>> import hello_world >>>>> >>>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>>> >>>>> -----Original Message----- >>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>> Sent: Thursday, May 29, 2008 8:14 AM >>>>> To: Discussion of IronPython >>>>> Subject: [IronPython] hosting and SetVariable >>>>> >>>>> Perhaps this is just missing knowledge on my part, but here goes. >>>>> >>>>> I am using IP2.0 with the hosting API to add scripting support to my >>>>> application. I use the following code to create my main module from >>>>> the script file the user selects: >>>>> >>>>> ICompiledCode code = >>>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>>> path), _error_sink); >>>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>>> >>>>> // create our module. >>>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>>> >>>>> // add all the references the "Host" wanted. >>>>> foreach (string assembly in _assemblies) >>>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>>> >>>>> // set all the variables that the "Host" wanted set. >>>>> foreach (KeyValuePair obj in _objects) >>>>> __main__.SetVariable(obj.Key, obj.Value); >>>>> >>>>> The last foreach is setting up my object model which is available to >>>>> my scripts. My problem arises when I want to use one of these >>>>> variables from a script that is imported from the user selected script >>>>> file. >>>>> >>>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>>> reference that object in the user script as MyObj with no problem. >>>>> What I would like to do is have these variables global to all scripts >>>>> that are imported, etc. I tried import __main__ in my other scripts, >>>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>>> PublishModule would do, but thats a different story). >>>>> >>>>> Am I going about this the wrong way? >>>>> >>>>> Thanks >>>>> >>>>> 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 >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>> >>>> >>>> >>>> -- >>>> slide-o-blog >>>> http://slide-o-blog.blogspot.com/ >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Thu May 29 23:41:43 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 14:41:43 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC9852A26@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A26@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Dino, Thanks for all the help, it has helped me move forward quite a bit! It turns out I had an error in the python that was being covered up by the way I was doing some things. I fixed that and am left with one last question. Given a PythonType, it looks like there are a bunch of different ways to create an instance through __new__ calls. My question is, where do I get the CodeContext from? I know I can create a new one using "new," but it requires a Scope object, which I don't have HostingHelpers to get from a ScriptScope. So, can you give me a quick example of creating an instance if I have a PythonType? Something that will hopefully be useful going forward as well :-) Thanks! slide On Thu, May 29, 2008 at 1:22 PM, Dino Viehland wrote: > There's something strange going on. This small program on 2.0B2: > > using System; > using System.Collections.Generic; > using System.Reflection; > > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > class Test { > public static void Main(string[]args) { > ScriptRuntime runtime = ScriptRuntime.Create(); > runtime.Globals.ClearVariables(); > ScriptEngine engine = runtime.GetEngine("py"); > CompiledCode code = engine.CreateScriptSourceFromFile("test.py").Compile(); > ScriptScope scope = code.MakeOptimizedScope(); > code.Execute(scope); > foreach(KeyValuePair kvp in scope.Items) { > Console.WriteLine("{0} {1}", kvp.Key, kvp.Value); > } > } > } > > With test.py containing: > > class x(object): pass > > prints: > > __builtins__ IronPython.Runtime.PythonDictionary > x IronPython.Runtime.Types.PythonType > > I'm not sure what the difference would be off the top of my head as that's basically what you're doing minus the additional setup. Can you try reducing some of the additional steps and seeing if you can get a basic type to show up? > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 12:52 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > ScriptScope.Item doesn't have my class definition in there. Perhaps I > am not doing the initial setup correctly. > > > _runtime.Globals.ClearVariables(); > > _engine = _runtime.GetEngine("py"); > > foreach (KeyValuePair obj in _objects) > _runtime.Globals.SetVariable(obj.Key, obj.Value); > > _error_listener = new ScriptErrorListener(); > > // setup the paths to search for modules > List paths = new List(); > paths.Add(Environment.CurrentDirectory); > > paths.Add(Path.Combine(Environment.CurrentDirectory, "Lib")); > paths.Add(Path.GetDirectoryName(path)); > > string[] probe_paths = > Directory.GetDirectories(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); > paths.AddRange(probe_paths); > > _engine.SetScriptSourceSearchPaths(paths.ToArray()); > > CompiledCode code = > _engine.CreateScriptSourceFromFile(path).Compile(_error_listener); > _scope = code.MakeOptimizedScope(); > code.Execute(_scope); > _engine.PublishModule("__main__", _scope); > > // add all the references the "Host" wanted. > foreach (string assembly in _assemblies) > _runtime.LoadAssembly(Assembly.LoadFrom(assembly)); > > > The code I am passing in contains the following: > > import ScriptTester > > class MyClass(ScriptTester.ITest): > def DoIt(self, msg): > print msg > > When I iterate over _scope.Items, I don't see "MyClass" in the list of items. > > Thanks > > On Thu, May 29, 2008 at 12:46 PM, Dino Viehland > wrote: >> Sorry, I didn't realize that was a recent addition. Can you just iterate over ScriptScope.Items - I checked and it's there in B2 :). >> >> As for beta 3 the plan is sometime in June. >> >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 12:39 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> That class is not available in Beta2. I also downloaded the latest >> source and checked the implementation of GetScope, it calls >> ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with >> all this stuff coming out soon? >> >> thanks >> >> On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan >> wrote: >>> It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' >>> >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 12:13 PM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> It may be able to be accomplished with ObjectOperations. What I am >>> trying to do is find all the types defined in my ScriptScope and >>> determine if they are subclasses (or implementers) of another type. I >>> used to do this using the PythonType class with UnderlyingSystemType >>> and so forth, but all that stuff is gone in the beta 2 I downloaded. >>> Also, I didn't see HostingHelpers.GetScope anywhere, is this from an >>> external library (I checked Microsoft.Scripting, >>> Microsoft.Scripting.Core and the IronPython assemblies) >>> >>> On Thu, May 29, 2008 at 11:56 AM, Dino Viehland >>> wrote: >>>> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >>>> >>>> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >>>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 11:34 AM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] hosting and SetVariable >>>> >>>> Thanks that will be helpful. Is there any documentation specific to >>>> IronPython? I would like to do some introspection on modules and such >>>> (to retrieve types defined in the module and so forth) and I used to >>>> do that with some PythonType magic which doesn't seem to work anymore >>>> (ScriptScope is not convertable to Scope when calling Get__dict__). >>>> >>>> Thanks again! >>>> >>>> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >>>> wrote: >>>>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>>>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>>>> >>>>> Thanks >>>>> Sesh >>>>> -----Original Message----- >>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>> Sent: Thursday, May 29, 2008 8:42 AM >>>>> To: Discussion of IronPython >>>>> Subject: Re: [IronPython] hosting and SetVariable >>>>> >>>>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>>>> CurrentManager.Globals, thanks for the info. >>>>> >>>>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>>>> wrote: >>>>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>>>> >>>>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>>>> >>>>>> Then you can do: >>>>>> >>>>>> import hello_world >>>>>> >>>>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>>>> >>>>>> -----Original Message----- >>>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>>> Sent: Thursday, May 29, 2008 8:14 AM >>>>>> To: Discussion of IronPython >>>>>> Subject: [IronPython] hosting and SetVariable >>>>>> >>>>>> Perhaps this is just missing knowledge on my part, but here goes. >>>>>> >>>>>> I am using IP2.0 with the hosting API to add scripting support to my >>>>>> application. I use the following code to create my main module from >>>>>> the script file the user selects: >>>>>> >>>>>> ICompiledCode code = >>>>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>>>> path), _error_sink); >>>>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>>>> >>>>>> // create our module. >>>>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>>>> >>>>>> // add all the references the "Host" wanted. >>>>>> foreach (string assembly in _assemblies) >>>>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>>>> >>>>>> // set all the variables that the "Host" wanted set. >>>>>> foreach (KeyValuePair obj in _objects) >>>>>> __main__.SetVariable(obj.Key, obj.Value); >>>>>> >>>>>> The last foreach is setting up my object model which is available to >>>>>> my scripts. My problem arises when I want to use one of these >>>>>> variables from a script that is imported from the user selected script >>>>>> file. >>>>>> >>>>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>>>> reference that object in the user script as MyObj with no problem. >>>>>> What I would like to do is have these variables global to all scripts >>>>>> that are imported, etc. I tried import __main__ in my other scripts, >>>>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>>>> PublishModule would do, but thats a different story). >>>>>> >>>>>> Am I going about this the wrong way? >>>>>> >>>>>> Thanks >>>>>> >>>>>> 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 >>>>>> _______________________________________________ >>>>>> Users mailing list >>>>>> Users at lists.ironpython.com >>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> slide-o-blog >>>>> http://slide-o-blog.blogspot.com/ >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>> >>>> >>>> >>>> -- >>>> slide-o-blog >>>> http://slide-o-blog.blogspot.com/ >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > 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 dinov at exchange.microsoft.com Thu May 29 23:50:29 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Thu, 29 May 2008 14:50:29 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: References: <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE513@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A26@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852AA2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> I'd just use ObjectOperations for this one - that should be as simple as: engine.Operations.Call(type); and pass any arguments you want. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide Sent: Thursday, May 29, 2008 2:42 PM To: Discussion of IronPython Subject: Re: [IronPython] hosting and SetVariable Dino, Thanks for all the help, it has helped me move forward quite a bit! It turns out I had an error in the python that was being covered up by the way I was doing some things. I fixed that and am left with one last question. Given a PythonType, it looks like there are a bunch of different ways to create an instance through __new__ calls. My question is, where do I get the CodeContext from? I know I can create a new one using "new," but it requires a Scope object, which I don't have HostingHelpers to get from a ScriptScope. So, can you give me a quick example of creating an instance if I have a PythonType? Something that will hopefully be useful going forward as well :-) Thanks! slide On Thu, May 29, 2008 at 1:22 PM, Dino Viehland wrote: > There's something strange going on. This small program on 2.0B2: > > using System; > using System.Collections.Generic; > using System.Reflection; > > using Microsoft.Scripting; > using Microsoft.Scripting.Hosting; > > class Test { > public static void Main(string[]args) { > ScriptRuntime runtime = ScriptRuntime.Create(); > runtime.Globals.ClearVariables(); > ScriptEngine engine = runtime.GetEngine("py"); > CompiledCode code = engine.CreateScriptSourceFromFile("test.py").Compile(); > ScriptScope scope = code.MakeOptimizedScope(); > code.Execute(scope); > foreach(KeyValuePair kvp in scope.Items) { > Console.WriteLine("{0} {1}", kvp.Key, kvp.Value); > } > } > } > > With test.py containing: > > class x(object): pass > > prints: > > __builtins__ IronPython.Runtime.PythonDictionary > x IronPython.Runtime.Types.PythonType > > I'm not sure what the difference would be off the top of my head as that's basically what you're doing minus the additional setup. Can you try reducing some of the additional steps and seeing if you can get a basic type to show up? > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 12:52 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > ScriptScope.Item doesn't have my class definition in there. Perhaps I > am not doing the initial setup correctly. > > > _runtime.Globals.ClearVariables(); > > _engine = _runtime.GetEngine("py"); > > foreach (KeyValuePair obj in _objects) > _runtime.Globals.SetVariable(obj.Key, obj.Value); > > _error_listener = new ScriptErrorListener(); > > // setup the paths to search for modules > List paths = new List(); > paths.Add(Environment.CurrentDirectory); > > paths.Add(Path.Combine(Environment.CurrentDirectory, "Lib")); > paths.Add(Path.GetDirectoryName(path)); > > string[] probe_paths = > Directory.GetDirectories(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); > paths.AddRange(probe_paths); > > _engine.SetScriptSourceSearchPaths(paths.ToArray()); > > CompiledCode code = > _engine.CreateScriptSourceFromFile(path).Compile(_error_listener); > _scope = code.MakeOptimizedScope(); > code.Execute(_scope); > _engine.PublishModule("__main__", _scope); > > // add all the references the "Host" wanted. > foreach (string assembly in _assemblies) > _runtime.LoadAssembly(Assembly.LoadFrom(assembly)); > > > The code I am passing in contains the following: > > import ScriptTester > > class MyClass(ScriptTester.ITest): > def DoIt(self, msg): > print msg > > When I iterate over _scope.Items, I don't see "MyClass" in the list of items. > > Thanks > > On Thu, May 29, 2008 at 12:46 PM, Dino Viehland > wrote: >> Sorry, I didn't realize that was a recent addition. Can you just iterate over ScriptScope.Items - I checked and it's there in B2 :). >> >> As for beta 3 the plan is sometime in June. >> >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 12:39 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> That class is not available in Beta2. I also downloaded the latest >> source and checked the implementation of GetScope, it calls >> ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with >> all this stuff coming out soon? >> >> thanks >> >> On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan >> wrote: >>> It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' >>> >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 12:13 PM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> It may be able to be accomplished with ObjectOperations. What I am >>> trying to do is find all the types defined in my ScriptScope and >>> determine if they are subclasses (or implementers) of another type. I >>> used to do this using the PythonType class with UnderlyingSystemType >>> and so forth, but all that stuff is gone in the beta 2 I downloaded. >>> Also, I didn't see HostingHelpers.GetScope anywhere, is this from an >>> external library (I checked Microsoft.Scripting, >>> Microsoft.Scripting.Core and the IronPython assemblies) >>> >>> On Thu, May 29, 2008 at 11:56 AM, Dino Viehland >>> wrote: >>>> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >>>> >>>> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >>>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 11:34 AM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] hosting and SetVariable >>>> >>>> Thanks that will be helpful. Is there any documentation specific to >>>> IronPython? I would like to do some introspection on modules and such >>>> (to retrieve types defined in the module and so forth) and I used to >>>> do that with some PythonType magic which doesn't seem to work anymore >>>> (ScriptScope is not convertable to Scope when calling Get__dict__). >>>> >>>> Thanks again! >>>> >>>> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >>>> wrote: >>>>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>>>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>>>> >>>>> Thanks >>>>> Sesh >>>>> -----Original Message----- >>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>> Sent: Thursday, May 29, 2008 8:42 AM >>>>> To: Discussion of IronPython >>>>> Subject: Re: [IronPython] hosting and SetVariable >>>>> >>>>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>>>> CurrentManager.Globals, thanks for the info. >>>>> >>>>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>>>> wrote: >>>>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>>>> >>>>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>>>> >>>>>> Then you can do: >>>>>> >>>>>> import hello_world >>>>>> >>>>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>>>> >>>>>> -----Original Message----- >>>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>>> Sent: Thursday, May 29, 2008 8:14 AM >>>>>> To: Discussion of IronPython >>>>>> Subject: [IronPython] hosting and SetVariable >>>>>> >>>>>> Perhaps this is just missing knowledge on my part, but here goes. >>>>>> >>>>>> I am using IP2.0 with the hosting API to add scripting support to my >>>>>> application. I use the following code to create my main module from >>>>>> the script file the user selects: >>>>>> >>>>>> ICompiledCode code = >>>>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>>>> path), _error_sink); >>>>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>>>> >>>>>> // create our module. >>>>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>>>> >>>>>> // add all the references the "Host" wanted. >>>>>> foreach (string assembly in _assemblies) >>>>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>>>> >>>>>> // set all the variables that the "Host" wanted set. >>>>>> foreach (KeyValuePair obj in _objects) >>>>>> __main__.SetVariable(obj.Key, obj.Value); >>>>>> >>>>>> The last foreach is setting up my object model which is available to >>>>>> my scripts. My problem arises when I want to use one of these >>>>>> variables from a script that is imported from the user selected script >>>>>> file. >>>>>> >>>>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>>>> reference that object in the user script as MyObj with no problem. >>>>>> What I would like to do is have these variables global to all scripts >>>>>> that are imported, etc. I tried import __main__ in my other scripts, >>>>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>>>> PublishModule would do, but thats a different story). >>>>>> >>>>>> Am I going about this the wrong way? >>>>>> >>>>>> Thanks >>>>>> >>>>>> 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 >>>>>> _______________________________________________ >>>>>> Users mailing list >>>>>> Users at lists.ironpython.com >>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> slide-o-blog >>>>> http://slide-o-blog.blogspot.com/ >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>> >>>> >>>> >>>> -- >>>> slide-o-blog >>>> http://slide-o-blog.blogspot.com/ >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- slide-o-blog http://slide-o-blog.blogspot.com/ _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From slide.o.mix at gmail.com Fri May 30 00:50:41 2008 From: slide.o.mix at gmail.com (Slide) Date: Thu, 29 May 2008 15:50:41 -0700 Subject: [IronPython] hosting and SetVariable In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC9852AA2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <7AD436E4270DD54A94238001769C2227012BC98529E5@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <4F06AAB8EC03C349A5D6D0A797C4881C40B00DE5EA@NA-EXMSG-C112.redmond.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A10@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852A26@DF-GRTDANE-MSG.exchange.corp.microsoft.com> <7AD436E4270DD54A94238001769C2227012BC9852AA2@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: Works like a charm, thanks! On Thu, May 29, 2008 at 2:50 PM, Dino Viehland wrote: > I'd just use ObjectOperations for this one - that should be as simple as: > > engine.Operations.Call(type); > > and pass any arguments you want. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide > Sent: Thursday, May 29, 2008 2:42 PM > To: Discussion of IronPython > Subject: Re: [IronPython] hosting and SetVariable > > Dino, > > Thanks for all the help, it has helped me move forward quite a bit! It > turns out I had an error in the python that was being covered up by > the way I was doing some things. I fixed that and am left with one > last question. Given a PythonType, it looks like there are a bunch of > different ways to create an instance through __new__ calls. My > question is, where do I get the CodeContext from? I know I can create > a new one using "new," but it requires a Scope object, which I don't > have HostingHelpers to get from a ScriptScope. So, can you give me a > quick example of creating an instance if I have a PythonType? > Something that will hopefully be useful going forward as well :-) > > Thanks! > > slide > > On Thu, May 29, 2008 at 1:22 PM, Dino Viehland > wrote: >> There's something strange going on. This small program on 2.0B2: >> >> using System; >> using System.Collections.Generic; >> using System.Reflection; >> >> using Microsoft.Scripting; >> using Microsoft.Scripting.Hosting; >> >> class Test { >> public static void Main(string[]args) { >> ScriptRuntime runtime = ScriptRuntime.Create(); >> runtime.Globals.ClearVariables(); >> ScriptEngine engine = runtime.GetEngine("py"); >> CompiledCode code = engine.CreateScriptSourceFromFile("test.py").Compile(); >> ScriptScope scope = code.MakeOptimizedScope(); >> code.Execute(scope); >> foreach(KeyValuePair kvp in scope.Items) { >> Console.WriteLine("{0} {1}", kvp.Key, kvp.Value); >> } >> } >> } >> >> With test.py containing: >> >> class x(object): pass >> >> prints: >> >> __builtins__ IronPython.Runtime.PythonDictionary >> x IronPython.Runtime.Types.PythonType >> >> I'm not sure what the difference would be off the top of my head as that's basically what you're doing minus the additional setup. Can you try reducing some of the additional steps and seeing if you can get a basic type to show up? >> >> -----Original Message----- >> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >> Sent: Thursday, May 29, 2008 12:52 PM >> To: Discussion of IronPython >> Subject: Re: [IronPython] hosting and SetVariable >> >> ScriptScope.Item doesn't have my class definition in there. Perhaps I >> am not doing the initial setup correctly. >> >> >> _runtime.Globals.ClearVariables(); >> >> _engine = _runtime.GetEngine("py"); >> >> foreach (KeyValuePair obj in _objects) >> _runtime.Globals.SetVariable(obj.Key, obj.Value); >> >> _error_listener = new ScriptErrorListener(); >> >> // setup the paths to search for modules >> List paths = new List(); >> paths.Add(Environment.CurrentDirectory); >> >> paths.Add(Path.Combine(Environment.CurrentDirectory, "Lib")); >> paths.Add(Path.GetDirectoryName(path)); >> >> string[] probe_paths = >> Directory.GetDirectories(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)); >> paths.AddRange(probe_paths); >> >> _engine.SetScriptSourceSearchPaths(paths.ToArray()); >> >> CompiledCode code = >> _engine.CreateScriptSourceFromFile(path).Compile(_error_listener); >> _scope = code.MakeOptimizedScope(); >> code.Execute(_scope); >> _engine.PublishModule("__main__", _scope); >> >> // add all the references the "Host" wanted. >> foreach (string assembly in _assemblies) >> _runtime.LoadAssembly(Assembly.LoadFrom(assembly)); >> >> >> The code I am passing in contains the following: >> >> import ScriptTester >> >> class MyClass(ScriptTester.ITest): >> def DoIt(self, msg): >> print msg >> >> When I iterate over _scope.Items, I don't see "MyClass" in the list of items. >> >> Thanks >> >> On Thu, May 29, 2008 at 12:46 PM, Dino Viehland >> wrote: >>> Sorry, I didn't realize that was a recent addition. Can you just iterate over ScriptScope.Items - I checked and it's there in B2 :). >>> >>> As for beta 3 the plan is sometime in June. >>> >>> >>> -----Original Message----- >>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>> Sent: Thursday, May 29, 2008 12:39 PM >>> To: Discussion of IronPython >>> Subject: Re: [IronPython] hosting and SetVariable >>> >>> That class is not available in Beta2. I also downloaded the latest >>> source and checked the implementation of GetScope, it calls >>> ScriptScope.Scope, which also doesn't exist in Beta2. Is Beta3 with >>> all this stuff coming out soon? >>> >>> thanks >>> >>> On Thu, May 29, 2008 at 12:17 PM, Seshadri Pillailokam Vijayaraghavan >>> wrote: >>>> It's fully qualified path is (Runtime\)'Microsoft.Scripting.Hosting.HostingHelpers' >>>> >>>> >>>> -----Original Message----- >>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>> Sent: Thursday, May 29, 2008 12:13 PM >>>> To: Discussion of IronPython >>>> Subject: Re: [IronPython] hosting and SetVariable >>>> >>>> It may be able to be accomplished with ObjectOperations. What I am >>>> trying to do is find all the types defined in my ScriptScope and >>>> determine if they are subclasses (or implementers) of another type. I >>>> used to do this using the PythonType class with UnderlyingSystemType >>>> and so forth, but all that stuff is gone in the beta 2 I downloaded. >>>> Also, I didn't see HostingHelpers.GetScope anywhere, is this from an >>>> external library (I checked Microsoft.Scripting, >>>> Microsoft.Scripting.Core and the IronPython assemblies) >>>> >>>> On Thu, May 29, 2008 at 11:56 AM, Dino Viehland >>>> wrote: >>>>> Unfortunately there isn't any specific documentation. Can what you used to do be accomplished with the ObjectOperations class? >>>>> >>>>> Otherwise there's a HostingHelpers.GetScope which you could use to get a Scope from a ScriptScope and you can probably re-use your old magic. >>>>> >>>>> -----Original Message----- >>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>> Sent: Thursday, May 29, 2008 11:34 AM >>>>> To: Discussion of IronPython >>>>> Subject: Re: [IronPython] hosting and SetVariable >>>>> >>>>> Thanks that will be helpful. Is there any documentation specific to >>>>> IronPython? I would like to do some introspection on modules and such >>>>> (to retrieve types defined in the module and so forth) and I used to >>>>> do that with some PythonType magic which doesn't seem to work anymore >>>>> (ScriptScope is not convertable to Scope when calling Get__dict__). >>>>> >>>>> Thanks again! >>>>> >>>>> On Thu, May 29, 2008 at 10:11 AM, Seshadri Pillailokam Vijayaraghavan >>>>> wrote: >>>>>> The latest Hosting API Spec is available at http://compilerlab.members.winisp.net/. >>>>>> It's available as both doc (http://compilerlab.members.winisp.net/dlr-spec-hosting.doc) or PDF (http://compilerlab.members.winisp.net/dlr-spec-hosting.pdf). >>>>>> >>>>>> Thanks >>>>>> Sesh >>>>>> -----Original Message----- >>>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>>> Sent: Thursday, May 29, 2008 8:42 AM >>>>>> To: Discussion of IronPython >>>>>> Subject: Re: [IronPython] hosting and SetVariable >>>>>> >>>>>> Apparently I need to update to the latest IP2.0 beta. I don't even see >>>>>> CurrentManager.Globals, thanks for the info. >>>>>> >>>>>> On Thu, May 29, 2008 at 8:37 AM, Dino Viehland >>>>>> wrote: >>>>>>> What you want to do is put the variables in ScriptDomainManager.Globals/ScriptRuntime.Globals and then you can import them. For example: >>>>>>> >>>>>>> ScriptDomainManager.CurrentManager.Globals.SetVariable("hello_world", "hi!"); >>>>>>> >>>>>>> Then you can do: >>>>>>> >>>>>>> import hello_world >>>>>>> >>>>>>> and we'll pick it up from globals. Just FYI IronPython.Hosting.PythonEngine is going away (along w/ CurrentEngine) so you're better off creating a ScriptRuntime and getting a ScriptEngine from it by name. >>>>>>> >>>>>>> -----Original Message----- >>>>>>> From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Slide >>>>>>> Sent: Thursday, May 29, 2008 8:14 AM >>>>>>> To: Discussion of IronPython >>>>>>> Subject: [IronPython] hosting and SetVariable >>>>>>> >>>>>>> Perhaps this is just missing knowledge on my part, but here goes. >>>>>>> >>>>>>> I am using IP2.0 with the hosting API to add scripting support to my >>>>>>> application. I use the following code to create my main module from >>>>>>> the script file the user selects: >>>>>>> >>>>>>> ICompiledCode code = >>>>>>> IronPython.Hosting.PythonEngine.CurrentEngine.Compile(SourceUnit.CreateFileUnit(_context, >>>>>>> path), _error_sink); >>>>>>> __main__ = code.MakeModule("__main__") as ScriptScope; >>>>>>> >>>>>>> // create our module. >>>>>>> ScriptDomainManager.CurrentManager.PublishModule(__main__, "__main__"); >>>>>>> >>>>>>> // add all the references the "Host" wanted. >>>>>>> foreach (string assembly in _assemblies) >>>>>>> Microsoft.Scripting.ClrModule.GetInstance().AddReference(Path.GetFileNameWithoutExtension(assembly)); >>>>>>> >>>>>>> // set all the variables that the "Host" wanted set. >>>>>>> foreach (KeyValuePair obj in _objects) >>>>>>> __main__.SetVariable(obj.Key, obj.Value); >>>>>>> >>>>>>> The last foreach is setting up my object model which is available to >>>>>>> my scripts. My problem arises when I want to use one of these >>>>>>> variables from a script that is imported from the user selected script >>>>>>> file. >>>>>>> >>>>>>> For instance, if I add an object _objects.Add("MyObj", someObj), I can >>>>>>> reference that object in the user script as MyObj with no problem. >>>>>>> What I would like to do is have these variables global to all scripts >>>>>>> that are imported, etc. I tried import __main__ in my other scripts, >>>>>>> but __main__ doesn't show up in sys.modules (which is what I thought >>>>>>> PublishModule would do, but thats a different story). >>>>>>> >>>>>>> Am I going about this the wrong way? >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> 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 >>>>>>> _______________________________________________ >>>>>>> Users mailing list >>>>>>> Users at lists.ironpython.com >>>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> slide-o-blog >>>>>> http://slide-o-blog.blogspot.com/ >>>>>> _______________________________________________ >>>>>> Users mailing list >>>>>> Users at lists.ironpython.com >>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>> _______________________________________________ >>>>>> Users mailing list >>>>>> Users at lists.ironpython.com >>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> slide-o-blog >>>>> http://slide-o-blog.blogspot.com/ >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> _______________________________________________ >>>>> Users mailing list >>>>> Users at lists.ironpython.com >>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>>> >>>> >>>> >>>> >>>> -- >>>> slide-o-blog >>>> http://slide-o-blog.blogspot.com/ >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> _______________________________________________ >>>> Users mailing list >>>> Users at lists.ironpython.com >>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>>> >>> >>> >>> >>> -- >>> slide-o-blog >>> http://slide-o-blog.blogspot.com/ >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> _______________________________________________ >>> Users mailing list >>> Users at lists.ironpython.com >>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >>> >> >> >> >> -- >> slide-o-blog >> http://slide-o-blog.blogspot.com/ >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> > > > > -- > slide-o-blog > http://slide-o-blog.blogspot.com/ > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > 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 Jimmy.Schementi at microsoft.com Fri May 30 01:22:51 2008 From: Jimmy.Schementi at microsoft.com (Jimmy Schementi) Date: Thu, 29 May 2008 16:22:51 -0700 Subject: [IronPython] urlprefix in Chiron and Silverlight Manifest Files In-Reply-To: <4817b6fc0805290707w61d43365gde3ab7d654887259@mail.gmail.com> References: <4817b6fc0805281149i3801e714x29eed78bf9b5522f@mail.gmail.com> <4817b6fc0805290707w61d43365gde3ab7d654887259@mail.gmail.com> Message-ID: <5283CA0A4168DF4FBBD71AE9ECA5A32845CBECFBB4@NA-EXMSG-C116.redmond.corp.microsoft.com> http://jimmy.schementi.com/silverlight/Chiron.zip This contains Chiron.exe, with a fix for the IPv4/6 issues. Let me know if anyone has issues on Firefox on either Windows or Mac. This fix will appear on Codeplex in a week. I haven't fixed the "file:///" bug on the Mac yet since it doesn't repro on Windows ... so it probably (?) is a Mono bug. I'll see if I can work around it, but in the meantime you can just do "Chiron /m /d:app" to generate the AppManifest.xaml to disk ... then you can edit it and remove the "file://"s (leave one "/" in the front though!). ~Jimmy > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users- > bounces at lists.ironpython.com] On Behalf Of Dan Eloff > Sent: Thursday, May 29, 2008 7:07 AM > To: Discussion of IronPython > Subject: Re: [IronPython] urlprefix in Chiron and Silverlight Manifest > Files > > > Firefox on Windows ships with network.dns.disableIPv6 set to "false". > Make > > sure that's the setting you have (type about:config in the address > bar). If > > it's set to "true", Chiron won't get the request. (Actually, if you > start > > ANOTHER Chiron, that one will get the request =P). > > > > This bug will be fixed sometime today/tomorrow in sdlsdk; I'll let > you guys > > know when that happens. > > I'm glad that will be fixed, I seem to recall that the reason I > changed that setting from the default was because it introduced > unacceptable latency into the loading of pages in firefox. > > -Dan > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From ben.aurel at gmail.com Fri May 30 09:39:14 2008 From: ben.aurel at gmail.com (Ben Aurel) Date: Fri, 30 May 2008 09:39:14 +0200 Subject: [IronPython] static compilation of Python scripts Message-ID: <899c88330805300039q245951dk128324709264d3a6@mail.gmail.com> hi I try to figure out if IP supports static compilation (Python->MSIL). Is it possible to build an assembly that exposes the contents (types,...) when imported into a C# class the same way if it would have be written in plain C#? thanks Ben From sanxiyn at gmail.com Fri May 30 12:33:05 2008 From: sanxiyn at gmail.com (Sanghyeon Seo) Date: Fri, 30 May 2008 19:33:05 +0900 Subject: [IronPython] static compilation of Python scripts In-Reply-To: <899c88330805300039q245951dk128324709264d3a6@mail.gmail.com> References: <899c88330805300039q245951dk128324709264d3a6@mail.gmail.com> Message-ID: <5b0248170805300333r3162193eg8c4d1c180141cf3e@mail.gmail.com> 2008/5/30 Ben Aurel : > Is it possible to build an assembly that exposes the contents > (types,...) when imported into a C# class the same way if it would > have be written in plain C#? No. Not currently. -- Seo Sanghyeon From kevin at kubasik.net Fri May 30 20:51:40 2008 From: kevin at kubasik.net (Kevin Kubasik) Date: Fri, 30 May 2008 12:51:40 -0600 Subject: [IronPython] static compilation of Python scripts In-Reply-To: <5b0248170805300333r3162193eg8c4d1c180141cf3e@mail.gmail.com> References: <899c88330805300039q245951dk128324709264d3a6@mail.gmail.com> <5b0248170805300333r3162193eg8c4d1c180141cf3e@mail.gmail.com> Message-ID: <78b1a24a0805301151m50f9f2d7w6b7745c72d7ff99b@mail.gmail.com> Is this something that might happen in the future? I see some translation problems, but hypothetically there could be some cool potential, especially in the enterprise field. -Kevin Kubasik On Fri, May 30, 2008 at 4:33 AM, Sanghyeon Seo wrote: > 2008/5/30 Ben Aurel : >> Is it possible to build an assembly that exposes the contents >> (types,...) when imported into a C# class the same way if it would >> have be written in plain C#? > > No. Not currently. > > -- > Seo Sanghyeon > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Kevin Kubasik http://kubasik.net/blog From dinov at exchange.microsoft.com Fri May 30 22:58:44 2008 From: dinov at exchange.microsoft.com (Dino Viehland) Date: Fri, 30 May 2008 13:58:44 -0700 Subject: [IronPython] static compilation of Python scripts In-Reply-To: <78b1a24a0805301151m50f9f2d7w6b7745c72d7ff99b@mail.gmail.com> References: <899c88330805300039q245951dk128324709264d3a6@mail.gmail.com> <5b0248170805300333r3162193eg8c4d1c180141cf3e@mail.gmail.com> <78b1a24a0805301151m50f9f2d7w6b7745c72d7ff99b@mail.gmail.com> Message-ID: <7AD436E4270DD54A94238001769C2227012BC9852D82@DF-GRTDANE-MSG.exchange.corp.microsoft.com> It's something we've actually tried once - in v1.x we have a static compiler which produces real .NET types. But it's incredibly hacky so I wouldn't suggest anyone to try using it. The big problem with doing this is we basically create P# instead of Python. For example what does: from foo import * class x(object): pass produce? Is this really a subtype of object? Another big problem is the API that is exposed to C# isn't very friendly to the C# programmer - everything needs to be typed to take and return object. The only exceptions to this today are when we detect you're overriding a virtual method. Instead we're much more excited about the whole DLR thing and the possibility of broadly supporting dynamic dispatch from within static languages - something along the lines of http://blogs.msdn.com/charlie/archive/2008/01/25/future-focus.aspx. If/when that happens it will solve a large class of the problems of consuming IronPython objects from static languages. -----Original Message----- From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kevin Kubasik Sent: Friday, May 30, 2008 11:52 AM To: Discussion of IronPython Subject: Re: [IronPython] static compilation of Python scripts Is this something that might happen in the future? I see some translation problems, but hypothetically there could be some cool potential, especially in the enterprise field. -Kevin Kubasik On Fri, May 30, 2008 at 4:33 AM, Sanghyeon Seo wrote: > 2008/5/30 Ben Aurel : >> Is it possible to build an assembly that exposes the contents >> (types,...) when imported into a C# class the same way if it would >> have be written in plain C#? > > No. Not currently. > > -- > Seo Sanghyeon > _______________________________________________ > Users mailing list > Users at lists.ironpython.com > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > -- Kevin Kubasik http://kubasik.net/blog _______________________________________________ Users mailing list Users at lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com From fuzzyman at voidspace.org.uk Fri May 30 23:12:07 2008 From: fuzzyman at voidspace.org.uk (Michael Foord) Date: Fri, 30 May 2008 22:12:07 +0100 Subject: [IronPython] static compilation of Python scripts In-Reply-To: <7AD436E4270DD54A94238001769C2227012BC9852D82@DF-GRTDANE-MSG.exchange.corp.microsoft.com> References: <899c88330805300039q245951dk128324709264d3a6@mail.gmail.com> <5b0248170805300333r3162193eg8c4d1c180141cf3e@mail.gmail.com> <78b1a24a0805301151m50f9f2d7w6b7745c72d7ff99b@mail.gmail.com> <7AD436E4270DD54A94238001769C2227012BC9852D82@DF-GRTDANE-MSG.exchange.corp.microsoft.com> Message-ID: <48406DA7.6070805@voidspace.org.uk> Part of the problem is that Python has a very different view of classes to C#. In Python, classes are created at runtime (and can be modified at runtime of course) - whereas C# needs a static target at compile time to compile against. One possibility is a project started by Curt called 'coils', which will take a Python class and generate a static type from it that actually proxies the Python type. http://www.codeplex.com/coils This is in an early stage, but can undoubtedly be made to work. Once my book is finished I would like to contribute to it... Michael Foord Dino Viehland wrote: > It's something we've actually tried once - in v1.x we have a static compiler which produces real .NET types. But it's incredibly hacky so I wouldn't suggest anyone to try using it. The big problem with doing this is we basically create P# instead of Python. For example what does: > > from foo import * > class x(object): > pass > > produce? Is this really a subtype of object? > > Another big problem is the API that is exposed to C# isn't very friendly to the C# programmer - everything needs to be typed to take and return object. The only exceptions to this today are when we detect you're overriding a virtual method. > > Instead we're much more excited about the whole DLR thing and the possibility of broadly supporting dynamic dispatch from within static languages - something along the lines of http://blogs.msdn.com/charlie/archive/2008/01/25/future-focus.aspx. If/when that happens it will solve a large class of the problems of consuming IronPython objects from static languages. > > -----Original Message----- > From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Kevin Kubasik > Sent: Friday, May 30, 2008 11:52 AM > To: Discussion of IronPython > Subject: Re: [IronPython] static compilation of Python scripts > > Is this something that might happen in the future? I see some > translation problems, but hypothetically there could be some cool > potential, especially in the enterprise field. > > -Kevin Kubasik > > On Fri, May 30, 2008 at 4:33 AM, Sanghyeon Seo wrote: > >> 2008/5/30 Ben Aurel : >> >>> Is it possible to build an assembly that exposes the contents >>> (types,...) when imported into a C# class the same way if it would >>> have be written in plain C#? >>> >> No. Not currently. >> >> -- >> Seo Sanghyeon >> _______________________________________________ >> Users mailing list >> Users at lists.ironpython.com >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com >> >> > > > > -- > Kevin Kubasik > http://kubasik.net/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.theotherdelia.co.uk/ http://www.voidspace.org.uk/ http://www.ironpython.info/ http://www.resolverhacks.net/