Re: [IronPython] How do I test if a variable is defined?

2008-11-05 Thread Michael Foord
Tony Meyer wrote: On Wed, Nov 5, 2008 at 8:06 AM, Michael Foord [EMAIL PROTECTED] wrote: Marty Nelson wrote: How do I test in Iron Python (in python) if a variable is defined? [...] try: name except NameError: # variable 'name' is not defined If you're running

[IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread William Reade
Hi all While running the numpy tests, I've come across a situation which, to the best of my knowledge, is simply impossible. I'm hoping that one of the local .NET gurus will be able to tell me what I'm missing, or point me somewhere I can get more insight. The 4 methods involved are as

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread William Reade
Incidentally, logging a Stopwatch timestamp in WriteFlush reveals that, yes, the calls really are happening in the order they appear to be. So, option (3) appears to be a red herring, and options (1) and (2) remain unchanged. William Reade wrote: Hi all While running the numpy tests, I've

Re: [IronPython] How do I test if a variable is defined?

2008-11-05 Thread Kenneth Miller
Can't you just do.. 'variable_name' in locals() or 'variable_name' in dir() Regards, Ken On Nov 5, 2008, at 4:07 AM, Michael Foord wrote: Tony Meyer wrote: On Wed, Nov 5, 2008 at 8:06 AM, Michael Foord [EMAIL PROTECTED] wrote: Marty Nelson wrote: How do I test in Iron Python (in

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread Curt Hagenlocher
So, the obvious question for me is whether or not you're using any finalizers. On Wed, Nov 5, 2008 at 5:57 AM, William Reade [EMAIL PROTECTED]wrote: Hi all While running the numpy tests, I've come across a situation which, to the best of my knowledge, is simply impossible. I'm hoping that

[IronPython] IronPython 2: Bug in Indexing (Blocker)

2008-11-05 Thread Michael Foord
Hello Guys, Discovered a bug in indexing Python objects in IronPython 2. The following code: class X(object): def __setitem__(self, key, value): print repr(key) def f(a, b): X()[a, b] = object() f(1, 2) f('one', 'two') Produces the following exception: Traceback (most

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread Curt Hagenlocher
...or, for that matter, any __del__ methods from within Python -- which ultimately are handled by finalization. On Wed, Nov 5, 2008 at 9:37 AM, Curt Hagenlocher [EMAIL PROTECTED]wrote: So, the obvious question for me is whether or not you're using any finalizers. On Wed, Nov 5, 2008 at 5:57

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread William Reade
Hi Curt I am indeed; that's how I know thread 2 is the GC thread. Is locking during GC forbidden? William Curt Hagenlocher wrote: ...or, for that matter, any __del__ methods from within Python -- which ultimately are handled by finalization. On Wed, Nov 5, 2008 at 9:37 AM, Curt

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread Curt Hagenlocher
Locking during finalization is often considered to be a bad idea. In particular, locking without a timeout introduces the possibility that you will hang the finalization thread, preventing further objects from being finalized. But clearly, that's not what's happening here. Other questions that

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread William Reade
The log starts in the middle (after many lock/unlocks, some from each thread); I'm running on x86; and I have no additional AppDomains. I don't think it would be safe for me to entirely avoid locking during finalization, but I could probably cut it down to a quick lock, on a separate object,

Re: [IronPython] IronPython 2: Bug in Indexing (Blocker)

2008-11-05 Thread Dino Viehland
Thanks for the report. I've opened CodePlex bug #19350 to track this (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=19350). I believe the fix is actually pretty simple and we'll discuss whether we'll take it for 2.0 final at our Friday team meeting. If you want to try out

Re: [IronPython] How do I test if a variable is defined?

2008-11-05 Thread Marty Nelson
That worked great, thanks. From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kenneth Miller Sent: Wednesday, November 05, 2008 7:46 AM To: Discussion of IronPython Subject: Re: [IronPython] How do I test if a variable is defined? Can't you

[IronPython] Extension methods in python

2008-11-05 Thread Marty Nelson
Is there the equivalent of extension method in python? I want to put a variable into the script scope and create extension methods for it. Does this make sense and is it possible? === Notice: This e-mail message, together with any attachments, contains information of Symyx Technologies,

Re: [IronPython] Extension methods in python

2008-11-05 Thread Dino Viehland
If it's an object defined in Python you can usually attach methods directly to the object or it's Python type. But otherwise we have no support for automatically adding .NET extension methods to existing types currently. It is a frequent request and we will probably get to it at some point.

Re: [IronPython] Extension methods in python

2008-11-05 Thread Marty Nelson
If it's an object defined in Python you can usually attach methods directly to the object or it's Python type. So how would this work? Let's say I had injested a variable into the scope from c#: scope.SetVarialble(widget, hello world) Can I do something in python so that I can then

Re: [IronPython] Extension methods in python

2008-11-05 Thread Dino Viehland
In this case widget is the string hello world so it won't work. If it was instead something like: class x(object): pass a = x() ... Then in C# you could do: widget = scope.GetVariable(a) then you could do engine.Operations.SetMember(widget, foo, () = hello world); and then back in Python:

[IronPython] _WindowsError and errno

2008-11-05 Thread Jeff Hardy
Hi IronPython team, Is there any reason why _WindowsError sets errno to 22 in all cases? There's some code in Django that checks if e.errno = errno.EEXIST. The exception that gets thrown by IronPython has winerror = 17 (and the message string says [Errno 17]...!), but e.errno is 22 (EINVAL).

Re: [IronPython] _WindowsError and errno

2008-11-05 Thread Dino Viehland
It's because when I initially looked at WindowsError it sure seemed like 22 was the error code that was always used :). If you do: for i in xrange(100): print WindowsError(i, i).errno on CPython You'll see a large amount of the errno's are set to 22 (including 0 and 1) - apparently I

Re: [IronPython] Ironclad problem, with which someone here may be able to help

2008-11-05 Thread Dino Viehland
I would suggest getting a snap shot of the call stacks when this is happening if that's possible. I can't pin anything down but I wonder if you could have an STA object or something that otherwise requires message pumping. That message pumping could happen while you're doing a Monitor.Enter