[IronPython] CPickle problem

2010-02-15 Thread Don Sawatzky
This assert works in CPython 2.6 and not in IronPython 2.6.1 RC 1 with a failure in dumps(): from collections import namedtuple # verify that instances can be pickled from cPickle import loads, dumps Point = namedtuple('Point', 'x, y', False) p = Point(x=10, y=20) assert p == loads(dumps(p))

Re: [IronPython] CPickle problem

2010-02-15 Thread Dino Viehland
This works if you run with the -X:Frames option. This is because namedtuple is using sys._getframe to find the calling module name and setting it on the created class. Alternately you could do this yourself: Point.__module__ = __name__ You could file a bug on this on CodePlex but to fix it

Re: [IronPython] CPickle problem

2010-02-15 Thread Michael Foord
On 15/02/2010 16:04, Dino Viehland wrote: This works if you run with the --X:Frames option. This is because namedtuple is using sys._getframe to find the calling module name and setting it on the created class. Alternately you could do this yourself: Point.__module__ = __name__ You could

Re: [IronPython] CPickle problem

2010-02-15 Thread Dino Viehland
Michael wrote: Could the namedtuple API be changed to better support IronPython - perhaps an optional __module__ argument? That'd be one way to do it - but I'm not sure it helps much compared to just setting __module__ when you get it back. It would certainly be more discoverable though.

Re: [IronPython] CPickle problem

2010-02-15 Thread Michael Foord
On 15/02/2010 16:22, Dino Viehland wrote: Michael wrote: Could the namedtuple API be changed to better support IronPython - perhaps an optional __module__ argument? That'd be one way to do it - but I'm not sure it helps much compared to just setting __module__ when you get it back.

[IronPython] IronPython 2.6 CodePlex Source Update

2010-02-15 Thread merllab
This is an automated email letting you know that sources have recently been pushed out. You can download these newer sources directly from http://ironpython.codeplex.com/SourceControl/changeset/view/63991. MODIFIED SOURCES

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Dino Viehland
This is now checked into the Main branch if anyone wants to download, compile, and give it a shot. I'll push it to the 2.6 branch post-PyCon. -Original Message- From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Michael Foord Sent:

[IronPython] Adding new infix operators to IronPython

2010-02-15 Thread Tristan Zajonc
Hi, I'm interested in experimenting with adding new infix operators to IronPython to support objectwise and elementwise operators. PEP 225 (http://www.python.org/dev/peps/pep-0225/) describes the potential use cases for such operators. Matlab style matrix operations are the chief example.

Re: [IronPython] Adding new infix operators to IronPython

2010-02-15 Thread Dino Viehland
Hopefully updating the tokenizer and parser should be fairly obvious. Once you've done that you'll need to actually implement the operators themselves. If the implementation of these operators is effectively exactly the same as the normal binary operators it should be pretty easy - you just

[IronPython] How can I exit from Python Script File?

2010-02-15 Thread Mark Grice
I am using IronPython within a C# .NET application. I have a class that the Python code uses, so I create a scope and set the variable, then execute the engine like this: private ScriptEngine scptEngine = null; private ScriptRuntime scptRuntime = null; private ScriptScope

Re: [IronPython] How can I exit from Python Script File?

2010-02-15 Thread Michael Foord
On 15/02/2010 21:54, Mark Grice wrote: I am using IronPython within a C# .NET application. I have a class that the Python code uses, so I create a scope and set the variable, then execute the engine like this: private ScriptEngine scptEngine = null; private ScriptRuntime

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Jeff Hardy
Works for me - lots more Django tests passing, now. Awesome work, Dino! (PS: do you even sleep?) - Jeff On Mon, Feb 15, 2010 at 10:49 AM, Dino Viehland di...@microsoft.com wrote: This is now checked into the Main branch if anyone wants to download, compile, and give it a shot. I'll push it

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Jeff Hardy
On Mon, Feb 15, 2010 at 3:57 PM, Dino Viehland di...@microsoft.com wrote: This was relatively easy, it was just work once Michael came up with the great idea.  But I do manage to get plenty of sleep - I just put off other mundane but important things on my TODO list like updating our perf

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Dino Viehland
It's not the tests, it's the infrastructure. Years ago when we were on the CLR team we wired up everything to run on their perf testing infrastructure. They've since moved on and we've been running on the old stuff that's been bit-rotting away. But the Developer Division has some division-wide

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Jeff Hardy
I found one more issue: class Foo(object): def __unicode__(self): return 'uFoo' print 'Foo: %s' % Foo() print u'Foo: %s' % Foo() python test_u.py Foo: __main__.Foo object at 0x003E8370 Foo: uFoo ipy.exe test_u.py Foo: Foo object at 0x002B Foo: Foo object at

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Dino Viehland
Is the template string really a constant in the case that you care about? -Original Message- From: users-boun...@lists.ironpython.com [mailto:users-boun...@lists.ironpython.com] On Behalf Of Jeff Hardy Sent: Monday, February 15, 2010 3:12 PM To: Discussion of IronPython Subject: Re:

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Jeff Hardy
On Mon, Feb 15, 2010 at 4:13 PM, Dino Viehland di...@microsoft.com wrote: Is the template string really a constant in the case that you care about? Yeah, it is, thankfully. I doubt there's a ton of cases where it occurs, and I really hope there aren't any where the format string is in a variable

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Dave Fugate
shameless plug For anyone attending PyCon, I'll be presenting a poster session entitled Behind the Iron Curtain: How Python is Tested at Microsoft. Any ways, one of the focuses of this session is our old performance lab infrastructure. Not only will you hear some details about how performance

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Dino Viehland
We could make % on a Unicode literal do something special much like we're doing for calls to unicode(...). Alternately we could make % try to invoke __unicode__ before __str__ - but that would sometimes be wrong. Probably not very often, it's hard to imagine someone defining __unicode__ and

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Jeff Hardy
On Mon, Feb 15, 2010 at 4:41 PM, Dino Viehland di...@microsoft.com wrote: We could make % on a Unicode literal do something special much like we're doing for calls to unicode(...).  Alternately we could make % try to invoke __unicode__ before __str__ - but that would sometimes be wrong.  

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Michael Foord
On 15/02/2010 23:51, Jeff Hardy wrote: On Mon, Feb 15, 2010 at 4:41 PM, Dino Viehlanddi...@microsoft.com wrote: We could make % on a Unicode literal do something special much like we're doing for calls to unicode(...). Alternately we could make % try to invoke __unicode__ before __str__ -

Re: [IronPython] Django, __unicode__, and #20366

2010-02-15 Thread Michael Foord
On 15/02/2010 23:53, Michael Foord wrote: On 15/02/2010 23:51, Jeff Hardy wrote: On Mon, Feb 15, 2010 at 4:41 PM, Dino Viehlanddi...@microsoft.com wrote: We could make % on a Unicode literal do something special much like we're doing for calls to unicode(...). Alternately we could make % try

Re: [IronPython] Monkey-patching CLR types

2010-02-15 Thread Jimmy Schementi
Thanks Dino! I've got something to at least compile, but I'm getting the error ArgumentTypeException: unsupported operand type(s) for +=: 'PythonBrowserEvent' and 'function'. OK, makes sense, it's not finding InPlaceAdd(Python.Runtime.Method), right? Since I can't link against IronPython,

Re: [IronPython] Monkey-patching CLR types

2010-02-15 Thread Dino Viehland
If you strongly type handler to a delegate type IronPython should convert the function to the delegate type on the call. I had meant to write EventHandlerHtmlEventArgs in my original sample code but somehow I ended up using the Python syntax EventHandler[HtmlEventArgs] :) Yeah, the comment's