From 804cd5160a43e5b80702ca85b2ffb06bab9f8140 Mon Sep 17 00:00:00 2001 From: Brian Lloyd Date: Thu, 6 Apr 2006 17:01:15 +0000 Subject: [PATCH 1/6] land import syntax refactoring on 1.x branch --- pythonnet/demo/helloform.py | 10 +- pythonnet/demo/splitter.py | 12 +- pythonnet/demo/wordpad.py | 16 +- pythonnet/src/console/assemblyinfo.cs | 6 +- pythonnet/src/console/pythonconsole.cs | 6 +- pythonnet/src/runtime/arrayobject.cs | 6 +- pythonnet/src/runtime/assemblyinfo.cs | 6 +- pythonnet/src/runtime/assemblymanager.cs | 68 ++++++--- pythonnet/src/runtime/classbase.cs | 6 +- pythonnet/src/runtime/classmanager.cs | 6 +- pythonnet/src/runtime/classobject.cs | 6 +- pythonnet/src/runtime/clrobject.cs | 6 +- pythonnet/src/runtime/codegenerator.cs | 6 +- pythonnet/src/runtime/constructorbinder.cs | 6 +- pythonnet/src/runtime/converter.cs | 6 +- pythonnet/src/runtime/debughelper.cs | 6 +- pythonnet/src/runtime/delegatemanager.cs | 6 +- pythonnet/src/runtime/delegateobject.cs | 6 +- pythonnet/src/runtime/eventbinding.cs | 6 +- pythonnet/src/runtime/eventobject.cs | 6 +- pythonnet/src/runtime/exceptions.cs | 8 +- pythonnet/src/runtime/extensiontype.cs | 6 +- pythonnet/src/runtime/fieldobject.cs | 6 +- pythonnet/src/runtime/importhook.cs | 155 +++++++++++--------- pythonnet/src/runtime/indexer.cs | 6 +- pythonnet/src/runtime/interfaceobject.cs | 6 +- pythonnet/src/runtime/interop.cs | 6 +- pythonnet/src/runtime/ipythonconvertable.cs | 12 +- pythonnet/src/runtime/iterator.cs | 6 +- pythonnet/src/runtime/managedtype.cs | 6 +- pythonnet/src/runtime/metatype.cs | 6 +- pythonnet/src/runtime/methodbinder.cs | 6 +- pythonnet/src/runtime/methodbinding.cs | 6 +- pythonnet/src/runtime/methodobject.cs | 6 +- pythonnet/src/runtime/methodwrapper.cs | 6 +- pythonnet/src/runtime/moduleobject.cs | 48 +++--- pythonnet/src/runtime/nativecall.cs | 6 +- pythonnet/src/runtime/propertyobject.cs | 6 +- pythonnet/src/runtime/pydict.cs | 6 +- pythonnet/src/runtime/pyfloat.cs | 6 +- pythonnet/src/runtime/pyint.cs | 6 +- pythonnet/src/runtime/pylist.cs | 6 +- pythonnet/src/runtime/pylong.cs | 6 +- pythonnet/src/runtime/pynumber.cs | 6 +- pythonnet/src/runtime/pyobject.cs | 6 +- pythonnet/src/runtime/pysequence.cs | 6 +- pythonnet/src/runtime/pystring.cs | 6 +- pythonnet/src/runtime/pythonengine.cs | 6 +- pythonnet/src/runtime/pythonexception.cs | 6 +- pythonnet/src/runtime/pytuple.cs | 6 +- pythonnet/src/runtime/runtime.cs | 6 +- pythonnet/src/runtime/typemanager.cs | 8 +- pythonnet/src/runtime/typemethod.cs | 6 +- pythonnet/src/testing/arraytest.cs | 6 +- pythonnet/src/testing/classtest.cs | 6 +- pythonnet/src/testing/constructortests.cs | 6 +- pythonnet/src/testing/conversiontest.cs | 6 +- pythonnet/src/testing/delegatetest.cs | 6 +- pythonnet/src/testing/enumtest.cs | 6 +- pythonnet/src/testing/eventtest.cs | 6 +- pythonnet/src/testing/exceptiontest.cs | 6 +- pythonnet/src/testing/fieldtest.cs | 6 +- pythonnet/src/testing/globaltest.cs | 6 +- pythonnet/src/testing/indexertest.cs | 6 +- pythonnet/src/testing/interfacetest.cs | 6 +- pythonnet/src/testing/methodtest.cs | 6 +- pythonnet/src/testing/propertytest.cs | 6 +- pythonnet/src/testing/threadtest.cs | 6 +- pythonnet/src/tests/leaktest.py | 32 ++-- pythonnet/src/tests/profile.py | 9 ++ pythonnet/src/tests/runtests.py | 12 +- pythonnet/src/tests/stress.py | 6 +- pythonnet/src/tests/stresstest.py | 9 ++ pythonnet/src/tests/test_array.py | 64 ++++---- pythonnet/src/tests/test_class.py | 28 ++-- pythonnet/src/tests/test_constructors.py | 10 +- pythonnet/src/tests/test_conversion.py | 18 +-- pythonnet/src/tests/test_delegate.py | 20 ++- pythonnet/src/tests/test_engine.py | 12 +- pythonnet/src/tests/test_enum.py | 14 +- pythonnet/src/tests/test_event.py | 12 +- pythonnet/src/tests/test_exceptions.py | 66 ++++----- pythonnet/src/tests/test_field.py | 14 +- pythonnet/src/tests/test_indexer.py | 16 +- pythonnet/src/tests/test_interface.py | 21 ++- pythonnet/src/tests/test_method.py | 44 +++--- pythonnet/src/tests/test_module.py | 148 ++++++++++--------- pythonnet/src/tests/test_property.py | 10 +- pythonnet/src/tests/test_thread.py | 10 +- 89 files changed, 586 insertions(+), 680 deletions(-) diff --git a/pythonnet/demo/helloform.py b/pythonnet/demo/helloform.py index 568b52922..e4a7eee8f 100755 --- a/pythonnet/demo/helloform.py +++ b/pythonnet/demo/helloform.py @@ -1,16 +1,14 @@ -# Copyright (c) 2001, 2002 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== -import CLR.System.Windows.Forms as WinForms -from CLR.System.Drawing import Size, Point +import System.Windows.Forms as WinForms +from System.Drawing import Size, Point class HelloApp(WinForms.Form): diff --git a/pythonnet/demo/splitter.py b/pythonnet/demo/splitter.py index 46adc9bec..f40b67137 100755 --- a/pythonnet/demo/splitter.py +++ b/pythonnet/demo/splitter.py @@ -1,17 +1,15 @@ -# Copyright (c) 2003 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== -import CLR.System.Windows.Forms as WinForms -from CLR.System.Drawing import Color, Size, Point -from CLR import System +import System.Windows.Forms as WinForms +from System.Drawing import Color, Size, Point +import System class Splitter(WinForms.Form): diff --git a/pythonnet/demo/wordpad.py b/pythonnet/demo/wordpad.py index c2f1eb616..36286b811 100755 --- a/pythonnet/demo/wordpad.py +++ b/pythonnet/demo/wordpad.py @@ -1,19 +1,17 @@ -# Copyright (c) 2003 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== -import CLR.System.Windows.Forms as WinForms -from CLR.System.Drawing import Color, Size, Point -from CLR.System.Text import Encoding -from CLR.System.IO import File -from CLR import System +import System.Windows.Forms as WinForms +from System.Drawing import Color, Size, Point +from System.Text import Encoding +from System.IO import File +import System class Wordpad(WinForms.Form): diff --git a/pythonnet/src/console/assemblyinfo.cs b/pythonnet/src/console/assemblyinfo.cs index 781c0ec36..fa7f2b59f 100755 --- a/pythonnet/src/console/assemblyinfo.cs +++ b/pythonnet/src/console/assemblyinfo.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2004 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/console/pythonconsole.cs b/pythonnet/src/console/pythonconsole.cs index 672d0f3cd..231520c04 100755 --- a/pythonnet/src/console/pythonconsole.cs +++ b/pythonnet/src/console/pythonconsole.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using Python.Runtime; diff --git a/pythonnet/src/runtime/arrayobject.cs b/pythonnet/src/runtime/arrayobject.cs index e1668e1d2..af8504520 100755 --- a/pythonnet/src/runtime/arrayobject.cs +++ b/pythonnet/src/runtime/arrayobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/assemblyinfo.cs b/pythonnet/src/runtime/assemblyinfo.cs index eaa619665..b9043cf27 100755 --- a/pythonnet/src/runtime/assemblyinfo.cs +++ b/pythonnet/src/runtime/assemblyinfo.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/runtime/assemblymanager.cs b/pythonnet/src/runtime/assemblymanager.cs index d7375c406..c182a6faa 100755 --- a/pythonnet/src/runtime/assemblymanager.cs +++ b/pythonnet/src/runtime/assemblymanager.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.IO; @@ -32,7 +30,6 @@ internal class AssemblyManager { static Hashtable namespaces; static ArrayList assemblies; static Hashtable probed; - static int last; private AssemblyManager() {} @@ -241,28 +238,33 @@ public static bool LoadImplicit(string name) { static void ScanAssembly(Assembly assembly) { - // TODO: this is a workaround for a current Mono bug: calling - // GetTypes on a generated assembly will cause it to fall over. - // For now we'll skip generated assemblies, which usually are - // uninteresting support code anyway. - - if (assembly is AssemblyBuilder) { - return; - } + // A couple of things we want to do here: first, we want to + // gather a list of all of the namespaces contributed to by + // the assembly. Since we have to rifle through all of the + // types in the assembly anyway, we also build up a running + // list of 'odd names' like generic names so that we can map + // them appropriately later while still being lazy about + // type lookup and instantiation. Type[] types = assembly.GetTypes(); for (int i = 0; i < types.Length; i++) { - string type_ns = types[i].Namespace; - if ((type_ns != null) && (!namespaces.ContainsKey(type_ns))) { - string[] names = type_ns.Split('.'); + Type t = types[i]; + string ns = t.Namespace != null ? t.Namespace : ""; + if ((ns != null) && (!namespaces.ContainsKey(ns))) { + string[] names = ns.Split('.'); string s = ""; for (int n = 0; n < names.Length; n++) { s = (n == 0) ? names[0] : s + "." + names[n]; if (!namespaces.ContainsKey(s)) { - namespaces.Add(s, String.Empty); + namespaces.Add(s, new Hashtable()); } } } + + Hashtable asm = namespaces[ns] as Hashtable; + if (ns != null && !asm.ContainsKey(assembly)) { + asm.Add(assembly, String.Empty); + } } } @@ -277,6 +279,38 @@ public static bool IsValidNamespace(string name) { } + //=================================================================== + // Returns the current list of valid names for the input namespace. + //=================================================================== + + public static StringCollection GetNames(string nsname) { + StringCollection names = new StringCollection(); + if (namespaces.ContainsKey(nsname)) { + Hashtable asm = namespaces[nsname] as Hashtable; + foreach (Object o in asm.Keys) { + Assembly a = o as Assembly; + Type[] types = a.GetTypes(); + for (int i = 0; i < types.Length; i++) { + Type t = types[i]; + if (t.Namespace == nsname) { + names.Add(t.Name); + } + } + } + int nslen = nsname.Length; + foreach (object n in namespaces.Keys) { + string key = n as string; + if (key.Length > nslen && key.StartsWith(nsname)) { + string tail = key.Substring(nslen); + if (key.IndexOf('.') == -1) { + names.Add(key); + } + } + } + } + return names; + } + //=================================================================== // Returns the System.Type object for a given qualified name, // looking in the currently loaded assemblies for the named diff --git a/pythonnet/src/runtime/classbase.cs b/pythonnet/src/runtime/classbase.cs index 001b0084b..1ff3b7ef3 100755 --- a/pythonnet/src/runtime/classbase.cs +++ b/pythonnet/src/runtime/classbase.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/classmanager.cs b/pythonnet/src/runtime/classmanager.cs index d5695c6aa..143c1c1c2 100755 --- a/pythonnet/src/runtime/classmanager.cs +++ b/pythonnet/src/runtime/classmanager.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/classobject.cs b/pythonnet/src/runtime/classobject.cs index 196300dee..bae8c90e7 100755 --- a/pythonnet/src/runtime/classobject.cs +++ b/pythonnet/src/runtime/classobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2003 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/runtime/clrobject.cs b/pythonnet/src/runtime/clrobject.cs index 8ed9a4b8e..ba0a4a73b 100755 --- a/pythonnet/src/runtime/clrobject.cs +++ b/pythonnet/src/runtime/clrobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/codegenerator.cs b/pythonnet/src/runtime/codegenerator.cs index b8458dbe8..a7744f870 100755 --- a/pythonnet/src/runtime/codegenerator.cs +++ b/pythonnet/src/runtime/codegenerator.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Threading; diff --git a/pythonnet/src/runtime/constructorbinder.cs b/pythonnet/src/runtime/constructorbinder.cs index 39f9cb316..0110e5abf 100755 --- a/pythonnet/src/runtime/constructorbinder.cs +++ b/pythonnet/src/runtime/constructorbinder.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2003 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/runtime/converter.cs b/pythonnet/src/runtime/converter.cs index 30cf412c3..45001c118 100755 --- a/pythonnet/src/runtime/converter.cs +++ b/pythonnet/src/runtime/converter.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/runtime/debughelper.cs b/pythonnet/src/runtime/debughelper.cs index 5c016a147..8d94dfd75 100755 --- a/pythonnet/src/runtime/debughelper.cs +++ b/pythonnet/src/runtime/debughelper.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/delegatemanager.cs b/pythonnet/src/runtime/delegatemanager.cs index 870c41bdd..affa7543a 100755 --- a/pythonnet/src/runtime/delegatemanager.cs +++ b/pythonnet/src/runtime/delegatemanager.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Threading; diff --git a/pythonnet/src/runtime/delegateobject.cs b/pythonnet/src/runtime/delegateobject.cs index 50c4620a9..c7d4a325b 100755 --- a/pythonnet/src/runtime/delegateobject.cs +++ b/pythonnet/src/runtime/delegateobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2003 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/runtime/eventbinding.cs b/pythonnet/src/runtime/eventbinding.cs index 98a386470..807a526eb 100755 --- a/pythonnet/src/runtime/eventbinding.cs +++ b/pythonnet/src/runtime/eventbinding.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/eventobject.cs b/pythonnet/src/runtime/eventobject.cs index 44c4a8374..7d77ac786 100755 --- a/pythonnet/src/runtime/eventobject.cs +++ b/pythonnet/src/runtime/eventobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/exceptions.cs b/pythonnet/src/runtime/exceptions.cs index 1bae03228..3f721f33d 100755 --- a/pythonnet/src/runtime/exceptions.cs +++ b/pythonnet/src/runtime/exceptions.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; @@ -114,7 +112,7 @@ internal static void SetupExceptionHack() { IntPtr builtins = Runtime.PyEval_GetBuiltins(); Runtime.PyDict_SetItemString(dict, "__builtins__", builtins); - IntPtr namestr = Runtime.PyString_FromString("CLR.System"); + IntPtr namestr = Runtime.PyString_FromString("System"); Runtime.PyDict_SetItemString(dict, "__name__", namestr); Runtime.Decref(namestr); diff --git a/pythonnet/src/runtime/extensiontype.cs b/pythonnet/src/runtime/extensiontype.cs index 8ece4123a..d9c77f1fd 100755 --- a/pythonnet/src/runtime/extensiontype.cs +++ b/pythonnet/src/runtime/extensiontype.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/fieldobject.cs b/pythonnet/src/runtime/fieldobject.cs index 39589717a..d324d267b 100755 --- a/pythonnet/src/runtime/fieldobject.cs +++ b/pythonnet/src/runtime/fieldobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/importhook.cs b/pythonnet/src/runtime/importhook.cs index b01a381f5..92b6a49f8 100755 --- a/pythonnet/src/runtime/importhook.cs +++ b/pythonnet/src/runtime/importhook.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; @@ -23,6 +21,7 @@ internal class ImportHook { static IntPtr py_import; static ModuleObject root; static MethodWrapper hook; + static int preload; //=================================================================== // Initialization performed on startup of the Python runtime. @@ -49,6 +48,7 @@ internal static void Initialize() { root = new ModuleObject(""); Runtime.PyDict_SetItemString(dict, "CLR", root.pyHandle); + preload = -1; } @@ -70,116 +70,133 @@ internal static void Shutdown() { public static IntPtr __import__(IntPtr self, IntPtr args, IntPtr kw) { // Replacement for the builtin __import__. The original import - // hook is saved as this.importFunc. This version handles CLR + // hook is saved as this.py_import. This version handles CLR // import and defers to the normal builtin for everything else. int num_args = Runtime.PyTuple_Size(args); - if (num_args < 1) { - Exceptions.SetError( - Exceptions.TypeError, - "__import__() takes at least 1 argument (0 given)" - ); - return IntPtr.Zero; + return Exceptions.RaiseTypeError( + "__import__() takes at least 1 argument (0 given)" + ); } // borrowed reference IntPtr py_mod_name = Runtime.PyTuple_GetItem(args, 0); - if ((py_mod_name == IntPtr.Zero) || (!Runtime.IsStringType(py_mod_name))) { - Exceptions.SetError(Exceptions.TypeError, "string expected"); - return IntPtr.Zero; - } - - // If not a CLR module, defer to the standard Python import. - // Could use Python here to avoid a string conversion. - - string mod_name = Runtime.GetManagedString(py_mod_name); - - if (!(mod_name.StartsWith("CLR.") || mod_name == "CLR")) { - return Runtime.PyObject_Call(py_import, args, kw); + return Exceptions.RaiseTypeError("string expected"); } // Check whether the import is of the form 'from x import y'. // This determines whether we return the head or tail module. - bool from_list = false; + IntPtr fromList = IntPtr.Zero; + bool fromlist = false; if (num_args >= 4) { - IntPtr fromList = Runtime.PyTuple_GetItem(args, 3); + fromList = Runtime.PyTuple_GetItem(args, 3); if ((fromList != IntPtr.Zero) && (Runtime.PyObject_IsTrue(fromList) == 1)) { - from_list = true; + fromlist = true; } } - // See if sys.modules for this interpreter already has the - // requested module. If so, just return the exising module. - - IntPtr sys_modules = Runtime.PyImport_GetModuleDict(); - IntPtr module = Runtime.PyDict_GetItem(sys_modules, py_mod_name); + string mod_name = Runtime.GetManagedString(py_mod_name); - if (module != IntPtr.Zero) { - if (from_list) { - Runtime.Incref(module); - return module; - } + if (mod_name == "CLR" || mod_name == "clr") { Runtime.Incref(root.pyHandle); return root.pyHandle; } - // Now we know we are looking for a CLR module and are likely - // going to have to ask the AssemblyManager. The assembly mgr - // tries really hard not to use Python objects or APIs, because - // parts of it can run recursively and on strange threads, etc. + string realname = mod_name; + if (mod_name.StartsWith("CLR.")) { + realname = mod_name.Substring(4); + } + + string[] names = realname.Split('.'); + + // Now we need to decide if the name refers to a CLR module, + // and may have to do an implicit load (for b/w compatibility) + // using the AssemblyManager. The assembly manager tries + // really hard not to use Python objects or APIs, because + // parts of it can run recursively and on strange threads. // // It does need an opportunity from time to time to check to // see if sys.path has changed, in a context that is safe. Here // we know we have the GIL, so we'll let it update if needed. AssemblyManager.UpdatePath(); + AssemblyManager.LoadImplicit(realname); + if (!AssemblyManager.IsValidNamespace(realname)) { + return Runtime.PyObject_Call(py_import, args, kw); + } - // Special case handling: if the qualified module name would - // cause an implicit assembly load, we need to do that first - // to make sure that each of the steps in the qualified name - // is recognized as a valid namespace. Otherwise the import - // process can encounter unknown namespaces before it gets to - // load the assembly that would make them valid. + // See if sys.modules for this interpreter already has the + // requested module. If so, just return the exising module. - if (mod_name.StartsWith("CLR.")) { - string real_name = mod_name.Substring(4); - AssemblyManager.LoadImplicit(real_name); - } + IntPtr modules = Runtime.PyImport_GetModuleDict(); + IntPtr module = Runtime.PyDict_GetItem(modules, py_mod_name); - // Traverse the qualified module name to get the requested - // module and place references in sys.modules as we go. + if (module != IntPtr.Zero) { + if (fromlist) { + Runtime.Incref(module); + return module; + } + module = Runtime.PyDict_GetItemString(modules, names[0]); + Runtime.Incref(module); + return module; + } + Exceptions.Clear(); + + // Traverse the qualified module name to get the named module + // and place references in sys.modules as we go. Note that if + // we are running in interactive mode we pre-load the names in + // each module, which is often useful for introspection. If we + // are not interactive, we stick to just-in-time creation of + // objects at lookup time, which is much more efficient. + + if (preload < 0) { + if (Runtime.PySys_GetObject("ps1") != IntPtr.Zero) { + preload = 1; + } + else { + Exceptions.Clear(); + preload = 0; + } + } - string[] names = mod_name.Split('.'); + ModuleObject head = (mod_name == realname) ? null : root; ModuleObject tail = root; for (int i = 0; i < names.Length; i++) { string name = names[i]; - if (name == "CLR") { - tail = root; + ManagedType mt = tail.GetAttribute(name); + if (!(mt is ModuleObject)) { + string error = String.Format("No module named {0}", name); + Exceptions.SetError(Exceptions.ImportError, error); + return IntPtr.Zero; } - else { - ManagedType mt = tail.GetAttribute(name); - if (!(mt is ModuleObject)) { - string error = String.Format("No module named {0}", - name - ); - Exceptions.SetError(Exceptions.ImportError, error); - return IntPtr.Zero; - } - tail = (ModuleObject) mt; + if (head == null) { + head = (ModuleObject)mt; + } + tail = (ModuleObject) mt; + if (preload == 1) { + tail.LoadNames(); } + Runtime.PyDict_SetItemString(modules, tail.moduleName, + tail.pyHandle + ); + } - Runtime.PyDict_SetItemString( - sys_modules, tail.ModuleName, tail.pyHandle - ); + ModuleObject mod = fromlist ? tail : head; + + if (fromlist && Runtime.PySequence_Size(fromList) == 1) { + IntPtr fp = Runtime.PySequence_GetItem(fromList, 0); + if ((preload < 1) && Runtime.GetManagedString(fp) == "*") { + mod.LoadNames(); + } + Runtime.Decref(fp); } - ModuleObject mod = from_list ? tail : root; Runtime.Incref(mod.pyHandle); return mod.pyHandle; } diff --git a/pythonnet/src/runtime/indexer.cs b/pythonnet/src/runtime/indexer.cs index 938949ce9..e7d7d01ec 100755 --- a/pythonnet/src/runtime/indexer.cs +++ b/pythonnet/src/runtime/indexer.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/interfaceobject.cs b/pythonnet/src/runtime/interfaceobject.cs index 9b6b18595..2fc3d8414 100755 --- a/pythonnet/src/runtime/interfaceobject.cs +++ b/pythonnet/src/runtime/interfaceobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2003 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Reflection; diff --git a/pythonnet/src/runtime/interop.cs b/pythonnet/src/runtime/interop.cs index f20e9bbc0..372bf6909 100755 --- a/pythonnet/src/runtime/interop.cs +++ b/pythonnet/src/runtime/interop.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/ipythonconvertable.cs b/pythonnet/src/runtime/ipythonconvertable.cs index 746744b4f..958eb6ec3 100755 --- a/pythonnet/src/runtime/ipythonconvertable.cs +++ b/pythonnet/src/runtime/ipythonconvertable.cs @@ -1,17 +1,11 @@ -// =========================================================================== -// -// Copyright (c) 2005 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, -// Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +// Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. -// -// =========================================================================== +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/iterator.cs b/pythonnet/src/runtime/iterator.cs index 8fdfa5805..1e4f00faf 100755 --- a/pythonnet/src/runtime/iterator.cs +++ b/pythonnet/src/runtime/iterator.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/managedtype.cs b/pythonnet/src/runtime/managedtype.cs index 8724b0f37..0513f65c0 100755 --- a/pythonnet/src/runtime/managedtype.cs +++ b/pythonnet/src/runtime/managedtype.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/metatype.cs b/pythonnet/src/runtime/metatype.cs index b7d6ca971..3b869f2b1 100755 --- a/pythonnet/src/runtime/metatype.cs +++ b/pythonnet/src/runtime/metatype.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/methodbinder.cs b/pythonnet/src/runtime/methodbinder.cs index 0711298f6..ff1f1b1e6 100755 --- a/pythonnet/src/runtime/methodbinder.cs +++ b/pythonnet/src/runtime/methodbinder.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2003 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/methodbinding.cs b/pythonnet/src/runtime/methodbinding.cs index c32785199..038ce9013 100755 --- a/pythonnet/src/runtime/methodbinding.cs +++ b/pythonnet/src/runtime/methodbinding.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/methodobject.cs b/pythonnet/src/runtime/methodobject.cs index 9d0972d04..f413e1b60 100755 --- a/pythonnet/src/runtime/methodobject.cs +++ b/pythonnet/src/runtime/methodobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/methodwrapper.cs b/pythonnet/src/runtime/methodwrapper.cs index 0d866aab9..8b895b29d 100755 --- a/pythonnet/src/runtime/methodwrapper.cs +++ b/pythonnet/src/runtime/methodwrapper.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/moduleobject.cs b/pythonnet/src/runtime/moduleobject.cs index f9741ff62..05ff7cbaa 100755 --- a/pythonnet/src/runtime/moduleobject.cs +++ b/pythonnet/src/runtime/moduleobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; @@ -27,14 +25,14 @@ namespace Python.Runtime { internal class ModuleObject : ExtensionType { - string moduleName; + internal string moduleName; string _namespace; Hashtable cache; static bool hacked; IntPtr dict; public ModuleObject(string name) : base() { - moduleName = (name == String.Empty) ? "CLR" : "CLR." + name; + moduleName = (name == String.Empty) ? "CLR" : name; cache = new Hashtable(); _namespace = name; @@ -150,30 +148,30 @@ private void StoreAttribute(string name, ManagedType ob) { } - [PythonMethod] - public static IntPtr _preload(IntPtr ob, IntPtr args, IntPtr kw) { - ModuleObject self = (ModuleObject)GetManagedObject(ob); + //=================================================================== + // Preloads all currently-known names for the module namespace. This + // can be called multiple times, to add names from assemblies that + // may have been loaded since the last call to the method. + //=================================================================== - string module_ns = self._namespace; - AppDomain domain = AppDomain.CurrentDomain; - Assembly[] assemblies = domain.GetAssemblies(); - for (int i = 0; i < assemblies.Length; i++) { - Assembly assembly = assemblies[i]; - Type[] types = assembly.GetTypes(); - for (int n = 0; n < types.Length; n++) { - Type type = types[n]; - - string ns = type.Namespace; - if ((ns != null) && (ns == module_ns)) { - if (type.IsPublic) { - ClassBase c = ClassManager.GetClass(type); - self.StoreAttribute(type.Name, c); + public void LoadNames() { + foreach (string name in AssemblyManager.GetNames(_namespace)) { + if (!this.cache.ContainsKey(name)) { + ManagedType attr = this.GetAttribute(name); + if (Runtime.wrap_exceptions) { + if (attr is ClassBase) { + ClassBase c = attr as ClassBase; + if (c.is_exception) { + IntPtr p = attr.pyHandle; + IntPtr r = Exceptions.GetExceptionClassWrapper(p); + Runtime.PyDict_SetItemString(dict, name, r); + Runtime.Incref(r); + + } } } } } - Runtime.Incref(Runtime.PyNone); - return Runtime.PyNone; } diff --git a/pythonnet/src/runtime/nativecall.cs b/pythonnet/src/runtime/nativecall.cs index 2d120b0ec..e55d9db32 100755 --- a/pythonnet/src/runtime/nativecall.cs +++ b/pythonnet/src/runtime/nativecall.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Threading; diff --git a/pythonnet/src/runtime/propertyobject.cs b/pythonnet/src/runtime/propertyobject.cs index 496ae14ad..c02056472 100755 --- a/pythonnet/src/runtime/propertyobject.cs +++ b/pythonnet/src/runtime/propertyobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/runtime/pydict.cs b/pythonnet/src/runtime/pydict.cs index 8556313b9..8414efd51 100755 --- a/pythonnet/src/runtime/pydict.cs +++ b/pythonnet/src/runtime/pydict.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/pyfloat.cs b/pythonnet/src/runtime/pyfloat.cs index 317fda4f9..16acf0935 100755 --- a/pythonnet/src/runtime/pyfloat.cs +++ b/pythonnet/src/runtime/pyfloat.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/pyint.cs b/pythonnet/src/runtime/pyint.cs index c07d63fd5..5b68c00d8 100755 --- a/pythonnet/src/runtime/pyint.cs +++ b/pythonnet/src/runtime/pyint.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/pylist.cs b/pythonnet/src/runtime/pylist.cs index d7ac1e1ca..b414424d2 100755 --- a/pythonnet/src/runtime/pylist.cs +++ b/pythonnet/src/runtime/pylist.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pylong.cs b/pythonnet/src/runtime/pylong.cs index 681134c3d..ad9f16ba7 100755 --- a/pythonnet/src/runtime/pylong.cs +++ b/pythonnet/src/runtime/pylong.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pynumber.cs b/pythonnet/src/runtime/pynumber.cs index 43bdd204e..4732cab84 100755 --- a/pythonnet/src/runtime/pynumber.cs +++ b/pythonnet/src/runtime/pynumber.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pyobject.cs b/pythonnet/src/runtime/pyobject.cs index a18790cb8..58515d14b 100755 --- a/pythonnet/src/runtime/pyobject.cs +++ b/pythonnet/src/runtime/pyobject.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pysequence.cs b/pythonnet/src/runtime/pysequence.cs index 6382b7ead..30e046905 100755 --- a/pythonnet/src/runtime/pysequence.cs +++ b/pythonnet/src/runtime/pysequence.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pystring.cs b/pythonnet/src/runtime/pystring.cs index f15a2aa36..a4286d655 100755 --- a/pythonnet/src/runtime/pystring.cs +++ b/pythonnet/src/runtime/pystring.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pythonengine.cs b/pythonnet/src/runtime/pythonengine.cs index 128406f1d..76e0c3dac 100755 --- a/pythonnet/src/runtime/pythonengine.cs +++ b/pythonnet/src/runtime/pythonengine.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Threading; diff --git a/pythonnet/src/runtime/pythonexception.cs b/pythonnet/src/runtime/pythonexception.cs index 788a7346d..6935a631c 100755 --- a/pythonnet/src/runtime/pythonexception.cs +++ b/pythonnet/src/runtime/pythonexception.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/pytuple.cs b/pythonnet/src/runtime/pytuple.cs index 2aa702443..a85714b35 100755 --- a/pythonnet/src/runtime/pytuple.cs +++ b/pythonnet/src/runtime/pytuple.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/runtime/runtime.cs b/pythonnet/src/runtime/runtime.cs index 29b085d21..adf230995 100755 --- a/pythonnet/src/runtime/runtime.cs +++ b/pythonnet/src/runtime/runtime.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; diff --git a/pythonnet/src/runtime/typemanager.cs b/pythonnet/src/runtime/typemanager.cs index 87ca5658a..c1c43427d 100755 --- a/pythonnet/src/runtime/typemanager.cs +++ b/pythonnet/src/runtime/typemanager.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Runtime.InteropServices; @@ -162,7 +160,7 @@ internal static IntPtr CreateType(ManagedType impl, Type clrType) { Runtime.PyType_Ready(type); IntPtr dict = Marshal.ReadIntPtr(type, TypeOffset.tp_dict); - string mn = "CLR." + clrType.Namespace; + string mn = clrType.Namespace != null ? clrType.Namespace : ""; IntPtr mod = Runtime.PyString_FromString(mn); Runtime.PyDict_SetItemString(dict, "__module__", mod); diff --git a/pythonnet/src/runtime/typemethod.cs b/pythonnet/src/runtime/typemethod.cs index 84c8e9e0d..46169a727 100755 --- a/pythonnet/src/runtime/typemethod.cs +++ b/pythonnet/src/runtime/typemethod.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/testing/arraytest.cs b/pythonnet/src/testing/arraytest.cs index 045701f4d..aca13fb0e 100755 --- a/pythonnet/src/testing/arraytest.cs +++ b/pythonnet/src/testing/arraytest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/testing/classtest.cs b/pythonnet/src/testing/classtest.cs index d053f2d65..d886a2174 100755 --- a/pythonnet/src/testing/classtest.cs +++ b/pythonnet/src/testing/classtest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/testing/constructortests.cs b/pythonnet/src/testing/constructortests.cs index d1fc1bc52..caa77ac13 100755 --- a/pythonnet/src/testing/constructortests.cs +++ b/pythonnet/src/testing/constructortests.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/testing/conversiontest.cs b/pythonnet/src/testing/conversiontest.cs index 4158ebd6c..435853b1d 100755 --- a/pythonnet/src/testing/conversiontest.cs +++ b/pythonnet/src/testing/conversiontest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/delegatetest.cs b/pythonnet/src/testing/delegatetest.cs index 60c85a2fe..8b1d67de6 100755 --- a/pythonnet/src/testing/delegatetest.cs +++ b/pythonnet/src/testing/delegatetest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/enumtest.cs b/pythonnet/src/testing/enumtest.cs index 76b161b88..c10f2062b 100755 --- a/pythonnet/src/testing/enumtest.cs +++ b/pythonnet/src/testing/enumtest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/eventtest.cs b/pythonnet/src/testing/eventtest.cs index 96872d3ab..24531a850 100755 --- a/pythonnet/src/testing/eventtest.cs +++ b/pythonnet/src/testing/eventtest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Windows.Forms; diff --git a/pythonnet/src/testing/exceptiontest.cs b/pythonnet/src/testing/exceptiontest.cs index d2ddd3572..211fefbc0 100755 --- a/pythonnet/src/testing/exceptiontest.cs +++ b/pythonnet/src/testing/exceptiontest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/fieldtest.cs b/pythonnet/src/testing/fieldtest.cs index e41737060..3ff27760f 100755 --- a/pythonnet/src/testing/fieldtest.cs +++ b/pythonnet/src/testing/fieldtest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/globaltest.cs b/pythonnet/src/testing/globaltest.cs index 441747233..70e8ba901 100755 --- a/pythonnet/src/testing/globaltest.cs +++ b/pythonnet/src/testing/globaltest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/indexertest.cs b/pythonnet/src/testing/indexertest.cs index 79a5d1128..04e5d4ccf 100755 --- a/pythonnet/src/testing/indexertest.cs +++ b/pythonnet/src/testing/indexertest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/testing/interfacetest.cs b/pythonnet/src/testing/interfacetest.cs index 93bf1dba2..d32dfba3e 100755 --- a/pythonnet/src/testing/interfacetest.cs +++ b/pythonnet/src/testing/interfacetest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/methodtest.cs b/pythonnet/src/testing/methodtest.cs index 39a442300..70b7fad2b 100755 --- a/pythonnet/src/testing/methodtest.cs +++ b/pythonnet/src/testing/methodtest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.IO; diff --git a/pythonnet/src/testing/propertytest.cs b/pythonnet/src/testing/propertytest.cs index 1e9454482..39c4f1010 100755 --- a/pythonnet/src/testing/propertytest.cs +++ b/pythonnet/src/testing/propertytest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2001, 2002 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; diff --git a/pythonnet/src/testing/threadtest.cs b/pythonnet/src/testing/threadtest.cs index 832b41021..354a7fec7 100755 --- a/pythonnet/src/testing/threadtest.cs +++ b/pythonnet/src/testing/threadtest.cs @@ -1,13 +1,11 @@ -// Copyright (c) 2005 Zope Corporation and Contributors. -// -// All Rights Reserved. -// +// ========================================================================== // This software is subject to the provisions of the Zope Public License, // Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. // THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED // WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED // WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS // FOR A PARTICULAR PURPOSE. +// ========================================================================== using System; using System.Collections; diff --git a/pythonnet/src/tests/leaktest.py b/pythonnet/src/tests/leaktest.py index e41a456be..95f3873a2 100755 --- a/pythonnet/src/tests/leaktest.py +++ b/pythonnet/src/tests/leaktest.py @@ -1,15 +1,13 @@ -# Copyright (c) 2001, 2002 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== -import CLR.System as System +import System import gc class LeakTest: @@ -69,19 +67,19 @@ def testModules(self): if i == 10: self.start_test() - __import__('CLR') - __import__('CLR.System') - __import__('CLR.System.IO') - __import__('CLR.System.Net') - __import__('CLR.System.Xml') + __import__('clr') + __import__('System') + __import__('System.IO') + __import__('System.Net') + __import__('System.Xml') self.end_test() def testClasses(self): - from CLR.System.Collections import Hashtable - from CLR.Python.Test import StringDelegate - from CLR.System import Int32 + from System.Collections import Hashtable + from Python.Test import StringDelegate + from System import Int32 self.notify("Running class leak check...") @@ -105,7 +103,7 @@ def testClasses(self): def testEnumerations(self): - from CLR.Python import Test + from Python import Test self.notify("Running enum leak check...") @@ -141,7 +139,7 @@ def testEnumerations(self): def testEvents(self): - from CLR.Python.Test import EventTest, TestEventArgs + from Python.Test import EventTest, TestEventArgs self.notify("Running event leak check...") @@ -219,8 +217,8 @@ def handler(sender, args, dict=dict): def testDelegates(self): - from CLR.Python.Test import DelegateTest, StringDelegate - from CLR import System + from Python.Test import DelegateTest, StringDelegate + import System self.notify("Running delegate leak check...") diff --git a/pythonnet/src/tests/profile.py b/pythonnet/src/tests/profile.py index b182da21d..cc5e48ac9 100755 --- a/pythonnet/src/tests/profile.py +++ b/pythonnet/src/tests/profile.py @@ -1,3 +1,12 @@ +# =========================================================================== +# This software is subject to the provisions of the Zope Public License, +# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# =========================================================================== + """Run all of the unit tests for this package over and over, in order to provide for better profiling.""" diff --git a/pythonnet/src/tests/runtests.py b/pythonnet/src/tests/runtests.py index df9739527..b5b9b40af 100755 --- a/pythonnet/src/tests/runtests.py +++ b/pythonnet/src/tests/runtests.py @@ -1,3 +1,12 @@ +# =========================================================================== +# This software is subject to the provisions of the Zope Public License, +# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# =========================================================================== + """Run all of the unit tests for this package.""" import time @@ -5,6 +14,7 @@ test_modules = ( 'test_exceptions', 'test_module', + 'test_compat', 'test_conversion', 'test_class', 'test_interface', @@ -16,7 +26,7 @@ 'test_method', 'test_delegate', 'test_array', - 'test_thread', + 'test_thread' ) diff --git a/pythonnet/src/tests/stress.py b/pythonnet/src/tests/stress.py index b0258f775..d0716022a 100755 --- a/pythonnet/src/tests/stress.py +++ b/pythonnet/src/tests/stress.py @@ -1,13 +1,11 @@ -# Copyright (c) 2005 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== """ Run all of the unit tests for this package multiple times in a highly diff --git a/pythonnet/src/tests/stresstest.py b/pythonnet/src/tests/stresstest.py index afb419fbd..58b448c78 100755 --- a/pythonnet/src/tests/stresstest.py +++ b/pythonnet/src/tests/stresstest.py @@ -1,3 +1,12 @@ +# =========================================================================== +# This software is subject to the provisions of the Zope Public License, +# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE. +# =========================================================================== + """Basic stress test.""" def main(): diff --git a/pythonnet/src/tests/test_array.py b/pythonnet/src/tests/test_array.py index 1625ae346..c4f81c3af 100755 --- a/pythonnet/src/tests/test_array.py +++ b/pythonnet/src/tests/test_array.py @@ -1,16 +1,14 @@ -# Copyright (c) 2001, 2002 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== import sys, os, string, unittest, types -import CLR.Python.Test as Test +import Python.Test as Test class ArrayTests(unittest.TestCase): @@ -693,7 +691,7 @@ def testDecimalArray(self): object = Test.DecimalArrayTest() items = object.items - from CLR.System import Decimal + from System import Decimal max_d = Decimal.Parse("79228162514264337593543950335") min_d = Decimal.Parse("-79228162514264337593543950335") @@ -764,7 +762,7 @@ def test(): def testEnumArray(self): """Test enum arrays.""" - from CLR.Python.Test import ShortEnum + from Python.Test import ShortEnum object = Test.EnumArrayTest() items = object.items @@ -806,7 +804,7 @@ def test(): def testObjectArray(self): """Test object arrays.""" - from CLR.Python.Test import Spam + from Python.Test import Spam object = Test.ObjectArrayTest() items = object.items @@ -880,7 +878,7 @@ def test(): def testInterfaceArray(self): """Test interface arrays.""" - from CLR.Python.Test import Spam + from Python.Test import Spam object = Test.InterfaceArrayTest() items = object.items @@ -925,7 +923,7 @@ def test(): def testTypedArray(self): """Test typed arrays.""" - from CLR.Python.Test import Spam + from Python.Test import Spam object = Test.TypedArrayTest() items = object.items @@ -1061,8 +1059,8 @@ def testArrayIteration(self): def testTupleArrayConversion(self): """Test conversion of tuples to array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam items = [] for i in range(10): @@ -1076,8 +1074,8 @@ def testTupleArrayConversion(self): def testTupleNestedArrayConversion(self): """Test conversion of tuples to array-of-array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam items = [] for i in range(10): @@ -1096,8 +1094,8 @@ def testTupleNestedArrayConversion(self): def testListArrayConversion(self): """Test conversion of lists to array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam items = [] for i in range(10): @@ -1110,8 +1108,8 @@ def testListArrayConversion(self): def testListNestedArrayConversion(self): """Test conversion of lists to array-of-array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam items = [] for i in range(10): @@ -1129,8 +1127,8 @@ def testListNestedArrayConversion(self): def testSequenceArrayConversion(self): """Test conversion of sequence-like objects to array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam from UserList import UserList items = UserList() @@ -1144,8 +1142,8 @@ def testSequenceArrayConversion(self): def testSequenceNestedArrayConversion(self): """Test conversion of sequences to array-of-array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam from UserList import UserList items = UserList() @@ -1164,8 +1162,8 @@ def testSequenceNestedArrayConversion(self): def testTupleArrayConversionTypeChecking(self): """Test error handling for tuple conversion to array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam # This should work, because null / None is a valid value in an # array of reference types. @@ -1201,8 +1199,8 @@ def test(items = items): def testListArrayConversionTypeChecking(self): """Test error handling for list conversion to array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam # This should work, because null / None is a valid value in an # array of reference types. @@ -1233,8 +1231,8 @@ def test(items = items): def testSequenceArrayConversionTypeChecking(self): """Test error handling for sequence conversion to array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam + from Python.Test import ArrayConversionTest + from Python.Test import Spam from UserList import UserList # This should work, because null / None is a valid value in an @@ -1266,9 +1264,9 @@ def test(items = items): def testMDArrayConversion(self): """Test passing of multi-dimensional array arguments.""" - from CLR.Python.Test import ArrayConversionTest - from CLR.Python.Test import Spam - from CLR.System import Array + from Python.Test import ArrayConversionTest + from Python.Test import Spam + from System import Array # Currently, the runtime does not support automagic conversion of # Python sequences to true multi-dimensional arrays (though it @@ -1298,8 +1296,8 @@ def testBoxedValueTypeMutationResult(self): # to accidentally write code like the following which is not really # mutating value types in-place but changing boxed copies. - from CLR.System.Drawing import Point - from CLR.System import Array + from System.Drawing import Point + from System import Array items = Array.CreateInstance(Point, 5) diff --git a/pythonnet/src/tests/test_class.py b/pythonnet/src/tests/test_class.py index 38ab0b495..a88e55103 100755 --- a/pythonnet/src/tests/test_class.py +++ b/pythonnet/src/tests/test_class.py @@ -1,19 +1,17 @@ -# Copyright (c) 2001, 2002 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== -from CLR.System.Collections import Hashtable -from CLR.Python.Test import ClassTest +from System.Collections import Hashtable +from Python.Test import ClassTest import sys, os, string, unittest, types -import CLR.Python.Test as Test -import CLR.System as System +import Python.Test as Test +import System class ClassTests(unittest.TestCase): @@ -34,7 +32,7 @@ def testBasicValueType(self): def testClassStandardAttrs(self): """Test standard class attributes.""" self.failUnless(ClassTest.__name__ == 'ClassTest') - self.failUnless(ClassTest.__module__ == 'CLR.Python.Test') + self.failUnless(ClassTest.__module__ == 'Python.Test') self.failUnless(type(ClassTest.__dict__) == types.DictProxyType) self.failUnless(len(ClassTest.__doc__) > 0) @@ -54,15 +52,15 @@ def testClassDefaultStr(self): def testClassDefaultRepr(self): """Test the default __repr__ implementation for managed objects.""" s = System.String("this is a test") - self.failUnless(repr(s).startswith(" count + 1) def testImplicitAssemblyLoad(self): """Test implicit assembly loading via import.""" def test(): - # This should fail until CLR.System.Windows.Forms has been + # This should fail until System.Windows.Forms has been # imported or that assembly has been explicitly loaded. - import CLR.System.Windows + import System.Windows self.failUnlessRaises(ImportError, test) - import CLR.System.Windows.Forms as Forms + import System.Windows.Forms as Forms self.failUnless(self.isCLRModule(Forms)) - self.failUnless(Forms.__name__ == 'CLR.System.Windows.Forms') - - from CLR.System.Drawing import Graphics - self.failUnless(self.isCLRClass(Graphics)) - self.failUnless(Graphics.__name__ == 'Graphics') + self.failUnless(Forms.__name__ == 'System.Windows.Forms') + from System.Windows.Forms import Form + self.failUnless(self.isCLRClass(Form)) + self.failUnless(Form.__name__ == 'Form') def testExplicitAssemblyLoad(self): """Test explicit assembly loading using standard CLR tools.""" - from CLR.System.Reflection import Assembly - import sys + from System.Reflection import Assembly + import System, sys assembly = Assembly.LoadWithPartialName('System.Data') self.failUnless(assembly != None) - import CLR.System.Data - self.failUnless(sys.modules.has_key('CLR.System.Data')) + import System.Data + self.failUnless(sys.modules.has_key('System.Data')) assembly = Assembly.LoadWithPartialName('SpamSpamSpamSpamEggsAndSpam') self.failUnless(assembly == None) @@ -207,43 +211,43 @@ def testImplicitLoadAlreadyValidNamespace(self): # assembly, which is _not_ loaded by default, which also contains # types in the System namespace. The desired behavior is for the # Python runtime to "do the right thing", allowing types from both - # assemblies to be found in the CLR.System module implicitly. - import CLR.System - self.failUnless(self.isCLRClass(CLR.System.UriBuilder)) + # assemblies to be found in the System module implicitly. + import System + self.failUnless(self.isCLRClass(System.UriBuilder)) def testImportNonExistantModule(self): """Test import failure for a non-existant module.""" def test(): - import CLR.System.SpamSpamSpam + import System.SpamSpamSpam self.failUnlessRaises(ImportError, test) def testLookupNoNamespaceType(self): """Test lookup of types without a qualified namespace.""" - import CLR.Python.Test - import CLR - self.failUnless(self.isCLRClass(CLR.NoNamespaceType)) + import Python.Test + import clr + self.failUnless(self.isCLRClass(clr.NoNamespaceType)) def testModuleLookupRecursion(self): """Test for recursive lookup handling.""" def test1(): - from CLR import CLR + from System import System self.failUnlessRaises(ImportError, test1) def test2(): - import CLR - x = CLR.CLR + import System + x = System.System self.failUnlessRaises(AttributeError, test2) def testModuleGetAttr(self): """Test module getattr behavior.""" - import CLR.System as System + import System int_type = System.Int32 self.failUnless(self.isCLRClass(int_type)) @@ -270,8 +274,8 @@ def testModuleAttrAbuse(self): # like dir() will fail if a module dict is not a real dictionary. def test(): - import CLR.System - CLR.System.__dict__['foo'] = 0 + import System + System.__dict__['foo'] = 0 return 1 self.failUnless(test()) @@ -279,7 +283,7 @@ def test(): def testModuleTypeAbuse(self): """Test handling of attempts to break the module type.""" - import CLR.System as System + import System mtype = type(System) def test(): diff --git a/pythonnet/src/tests/test_property.py b/pythonnet/src/tests/test_property.py index 27b5e76ab..6247396d8 100755 --- a/pythonnet/src/tests/test_property.py +++ b/pythonnet/src/tests/test_property.py @@ -1,16 +1,14 @@ -# Copyright (c) 2001, 2002 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== import sys, os, string, unittest, types -from CLR.Python.Test import PropertyTest +from Python.Test import PropertyTest class PropertyTests(unittest.TestCase): @@ -181,7 +179,7 @@ def testInterfaceProperty(self): that an IsAbstract check was inappropriate and prevented use of properties when only the interface is known.""" - from CLR.System.Collections import Hashtable, ICollection + from System.Collections import Hashtable, ICollection mapping = Hashtable() coll = ICollection(mapping) self.failUnless(coll.Count == 0) diff --git a/pythonnet/src/tests/test_thread.py b/pythonnet/src/tests/test_thread.py index 7822cc5a5..c5580d70b 100755 --- a/pythonnet/src/tests/test_thread.py +++ b/pythonnet/src/tests/test_thread.py @@ -1,16 +1,14 @@ -# Copyright (c) 2005 Zope Corporation and Contributors. -# -# All Rights Reserved. -# +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. +# =========================================================================== import sys, os, string, unittest, types, thread -from CLR.Python.Test import ThreadTest +from Python.Test import ThreadTest def dprint(msg): @@ -42,7 +40,7 @@ def testPythonThreadCallsToCLR(self): """Test calls by Python-spawned threads into managed code.""" # This test is very likely to hang if something is wrong ;) import threading, thread, time - from CLR.System import String + from System import String done = [] def run_thread(): From 4e2a3bd454b580f0b11149bed775ac6cd32300c0 Mon Sep 17 00:00:00 2001 From: Brian Lloyd Date: Sat, 8 Apr 2006 14:33:28 +0000 Subject: [PATCH 2/6] merged method selections and fixes from the trunk --- pythonnet/src/runtime/arrayobject.cs | 13 +- pythonnet/src/runtime/classbase.cs | 10 + pythonnet/src/runtime/classobject.cs | 26 ++ pythonnet/src/runtime/constructorbinder.cs | 7 +- pythonnet/src/runtime/converter.cs | 36 ++- pythonnet/src/runtime/exceptions.cs | 17 ++ pythonnet/src/runtime/managedtype.cs | 12 + pythonnet/src/runtime/metatype.cs | 14 ++ pythonnet/src/runtime/methodbinder.cs | 81 +++++- pythonnet/src/runtime/methodbinding.cs | 28 ++- pythonnet/src/runtime/methodobject.cs | 9 +- pythonnet/src/testing/methodtest.cs | 168 +++++++++++++ pythonnet/src/tests/runtests.py | 1 + pythonnet/src/tests/test_array.py | 134 ++++++++++ pythonnet/src/tests/test_method.py | 278 +++++++++++++++++++++ 15 files changed, 823 insertions(+), 11 deletions(-) diff --git a/pythonnet/src/runtime/arrayobject.cs b/pythonnet/src/runtime/arrayobject.cs index af8504520..ef91f0739 100755 --- a/pythonnet/src/runtime/arrayobject.cs +++ b/pythonnet/src/runtime/arrayobject.cs @@ -29,7 +29,18 @@ internal override bool CanSubclass() { } [CallConvCdecl()] - public static IntPtr tp_new(IntPtr ob, IntPtr args, IntPtr kw) { + public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw) { + ArrayObject self = GetManagedObject(tp) as ArrayObject; + if (Runtime.PyTuple_Size(args) != 1) { + return Exceptions.RaiseTypeError("array expects 1 argument"); + } + IntPtr op = Runtime.PyTuple_GetItem(args, 0); + Object result; + + if (!Converter.ToManaged(op, self.type, out result, true)) { + return IntPtr.Zero; + } + return CLRObject.GetInstHandle(result, tp); string message = "cannot instantiate array wrapper"; return Exceptions.RaiseTypeError(message); } diff --git a/pythonnet/src/runtime/classbase.cs b/pythonnet/src/runtime/classbase.cs index 1ff3b7ef3..e4be1b630 100755 --- a/pythonnet/src/runtime/classbase.cs +++ b/pythonnet/src/runtime/classbase.cs @@ -50,6 +50,16 @@ public static int tp_init(IntPtr ob, IntPtr args, IntPtr kw) { return 0; } + + //==================================================================== + // Default implementation of [] semantics for reflected types. + //==================================================================== + + public virtual IntPtr type_subscript(IntPtr ob, IntPtr idx) { + return Exceptions.RaiseTypeError("unsubscriptable object"); + } + + //==================================================================== // Standard comparison implementation for instances of reflected types. //==================================================================== diff --git a/pythonnet/src/runtime/classobject.cs b/pythonnet/src/runtime/classobject.cs index bae8c90e7..91163deb6 100755 --- a/pythonnet/src/runtime/classobject.cs +++ b/pythonnet/src/runtime/classobject.cs @@ -126,6 +126,32 @@ public static IntPtr tp_new(IntPtr tp, IntPtr args, IntPtr kw) { } + //==================================================================== + // Implementation of [] semantics for reflected types. This mainly + // exists to implement the Array[int] syntax for creating arrays. + //==================================================================== + + public override IntPtr type_subscript(IntPtr ob, IntPtr idx) { + if ((this.type) != typeof(Array)) { + return Exceptions.RaiseTypeError("unsubscriptable object"); + } + + if (Runtime.PyTuple_Check(idx)) { + return Exceptions.RaiseTypeError("expected single type"); + } + + ClassBase c = GetManagedObject(idx) as ClassBase; + Type t = (c != null) ? c.type : Converter.GetTypeByAlias(idx); + if (t == null) { + return Exceptions.RaiseTypeError("type expected"); + } + Array a = Array.CreateInstance(t, 0); + c = ClassManager.GetClass(a.GetType()); + Runtime.Incref(c.pyHandle); + return c.pyHandle; + } + + //==================================================================== // Implements __getitem__ for reflected classes and value types. //==================================================================== diff --git a/pythonnet/src/runtime/constructorbinder.cs b/pythonnet/src/runtime/constructorbinder.cs index 0110e5abf..5cafb5826 100755 --- a/pythonnet/src/runtime/constructorbinder.cs +++ b/pythonnet/src/runtime/constructorbinder.cs @@ -33,7 +33,12 @@ internal ConstructorBinder () : base() {} // Python type to use when wrapping the result (may be a subclass). //==================================================================== - internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) { + internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) { + return this.InvokeRaw(inst, args, kw, null); + } + + internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, + MethodBase info) { Binding binding = this.Bind(inst, args, kw); Object result; diff --git a/pythonnet/src/runtime/converter.cs b/pythonnet/src/runtime/converter.cs index 45001c118..3457b0838 100755 --- a/pythonnet/src/runtime/converter.cs +++ b/pythonnet/src/runtime/converter.cs @@ -28,6 +28,7 @@ private Converter() {} static NumberFormatInfo nfi; static Type objectType; static Type stringType; + static Type doubleType; static Type int32Type; static Type int64Type; static Type flagsType; @@ -40,12 +41,38 @@ static Converter () { stringType = typeof(String); int32Type = typeof(Int32); int64Type = typeof(Int64); + doubleType = typeof(Double); flagsType = typeof(FlagsAttribute); boolType = typeof(Boolean); typeType = typeof(Type); } + //==================================================================== + // Given a builtin Python type, return the corresponding CLR type. + //==================================================================== + + internal static Type GetTypeByAlias(IntPtr op) { + if ((op == Runtime.PyStringType) || + (op == Runtime.PyUnicodeType)) { + return stringType; + } + else if (op == Runtime.PyIntType) { + return int32Type; + } + else if (op == Runtime.PyLongType) { + return int64Type; + } + else if (op == Runtime.PyFloatType) { + return doubleType; + } + else if (op == Runtime.PyBoolType) { + return boolType; + } + return null; + } + + //==================================================================== // Return a Python object for the given native object, converting // basic types (string, int, etc.) into equivalent Python objects. @@ -177,7 +204,6 @@ internal static bool ToManaged(IntPtr value, Type type, internal static bool ToManagedValue(IntPtr value, Type obType, out Object result, bool setError) { - // Common case: if the Python value is a wrapped managed object // instance, just return the wrapped object. ManagedType mt = ManagedType.GetManagedObject(value); @@ -199,6 +225,12 @@ internal static bool ToManagedValue(IntPtr value, Type obType, mt = ManagedType.GetManagedObject(value); } } + IntPtr c = Exceptions.UnwrapExceptionClass(value); + if ((c != IntPtr.Zero) && (c != value)) { + value = c; + Runtime.Decref(c); + mt = ManagedType.GetManagedObject(value); + } } } @@ -601,6 +633,8 @@ static bool ToArray(IntPtr value, Type obType, out Object result, Array items = Array.CreateInstance(elementType, size); + // XXX - is there a better way to unwrap this if it is a real + // array? for (int i = 0; i < size; i++) { Object obj = null; IntPtr item = Runtime.PySequence_GetItem(value, i); diff --git a/pythonnet/src/runtime/exceptions.cs b/pythonnet/src/runtime/exceptions.cs index 3f721f33d..ff143615b 100755 --- a/pythonnet/src/runtime/exceptions.cs +++ b/pythonnet/src/runtime/exceptions.cs @@ -192,6 +192,23 @@ internal static IntPtr GetExceptionInstanceWrapper(IntPtr real) { return op; } + internal static IntPtr UnwrapExceptionClass(IntPtr op) { + // In some cases its necessary to recognize an exception *class*, + // and obtain the inner (wrapped) exception class. This method + // returns the inner class if found, or a null pointer. + + IntPtr d = Runtime.PyObject_GetAttrString(op, "__dict__"); + if (d == IntPtr.Zero) { + Exceptions.Clear(); + return IntPtr.Zero; + } + IntPtr c = Runtime.PyDict_GetItemString(d, "_class"); + Runtime.Decref(d); + if (c == IntPtr.Zero) { + Exceptions.Clear(); + } + return c; + } /// diff --git a/pythonnet/src/runtime/managedtype.cs b/pythonnet/src/runtime/managedtype.cs index 0513f65c0..0bf64eef3 100755 --- a/pythonnet/src/runtime/managedtype.cs +++ b/pythonnet/src/runtime/managedtype.cs @@ -46,6 +46,18 @@ internal static ManagedType GetManagedObject(IntPtr ob) { GCHandle gc = (GCHandle)op; return (ManagedType)gc.Target; } + + // In certain situations, we need to recognize a wrapped + // exception class and be willing to unwrap the class :( + + if (Runtime.wrap_exceptions) { + IntPtr e = Exceptions.UnwrapExceptionClass(ob); + if ((e != IntPtr.Zero) && (e != ob)) { + ManagedType m = GetManagedObject(e); + Runtime.Decref(e); + return m; + } + } } return null; } diff --git a/pythonnet/src/runtime/metatype.cs b/pythonnet/src/runtime/metatype.cs index 3b869f2b1..07f0d3540 100755 --- a/pythonnet/src/runtime/metatype.cs +++ b/pythonnet/src/runtime/metatype.cs @@ -220,6 +220,20 @@ public static int tp_setattro(IntPtr tp, IntPtr name, IntPtr value) { return 0; } + //==================================================================== + // The metatype has to implement [] semantics for generic types, so + // here we just delegate to the generic type def implementation. Its + // own mp_subscript + //==================================================================== + + [CallConvCdecl()] + public static IntPtr mp_subscript(IntPtr tp, IntPtr idx) { + ClassBase cb = GetManagedObject(tp) as ClassBase; + if (cb != null) { + return cb.type_subscript(tp, idx); + } + return Exceptions.RaiseTypeError("unsubscriptable object"); + } //==================================================================== // Dealloc implementation. This is called when a Python type generated diff --git a/pythonnet/src/runtime/methodbinder.cs b/pythonnet/src/runtime/methodbinder.cs index ff1f1b1e6..944c7c872 100755 --- a/pythonnet/src/runtime/methodbinder.cs +++ b/pythonnet/src/runtime/methodbinder.cs @@ -114,6 +114,60 @@ internal static int ArgPrecedence(Type t) { } + internal static MethodInfo MatchByTypeSig(MethodInfo[] msig, + IntPtr psig) { + IntPtr args = psig; + bool free = false; + + if (!Runtime.PyTuple_Check(psig)) { + args = Runtime.PyTuple_New(1); + Runtime.Incref(psig); + Runtime.PyTuple_SetItem(args, 0, psig); + free = true; + } + + int plen = Runtime.PyTuple_Size(args); + MethodInfo match = null; + + // XXX: what about out args, etc.? + + for (int i = 0; i < msig.Length; i++) { + ParameterInfo[] pi = msig[i].GetParameters(); + if (pi.Length != plen) { + continue; + } + bool matched = true; + for (int n = 0; n < pi.Length; n++) { + IntPtr p = Runtime.PyTuple_GetItem(args, n); + if (p == IntPtr.Zero) { + Exceptions.Clear(); + break; + } + ClassBase c = ManagedType.GetManagedObject(p) as ClassBase; + Type t = (c != null) ? c.type : + Converter.GetTypeByAlias(p); + + if (t == null) { + break; + } + if (t != pi[n].ParameterType) { + matched = false; + break; + } + } + if (matched) { + match = msig[i]; + break; + } + } + + if (free) { + Runtime.Decref(args); + } + + return match; + } + //==================================================================== // Bind the given Python instance and arguments to a particular method @@ -122,12 +176,26 @@ internal static int ArgPrecedence(Type t) { //==================================================================== internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw) { + return this.Bind(inst, args, kw, null); + } + + internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, + MethodBase info) { // loop to find match, return invoker w/ or /wo error + MethodBase[] _methods = null; int nargs = Runtime.PyTuple_Size(args); object arg; - MethodBase[] _methods = GetMethods(); - + if (info != null) { + _methods = (MethodBase[])Array.CreateInstance( + typeof(MethodBase), 1 + ); + _methods.SetValue(info, 0); + } + else { + _methods = GetMethods(); + } + for (int i = 0; i < _methods.Length; i++) { MethodBase mi = _methods[i]; ParameterInfo[] pi = mi.GetParameters(); @@ -171,9 +239,14 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw) { return null; } - internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw) { - Binding binding = this.Bind(inst, args, kw); + return this.Invoke(inst, args, kw, null); + + } + + internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw, + MethodBase info) { + Binding binding = this.Bind(inst, args, kw, info); Object result; if (binding == null) { diff --git a/pythonnet/src/runtime/methodbinding.cs b/pythonnet/src/runtime/methodbinding.cs index 038ce9013..d80d596c8 100755 --- a/pythonnet/src/runtime/methodbinding.cs +++ b/pythonnet/src/runtime/methodbinding.cs @@ -8,6 +8,7 @@ // ========================================================================== using System; +using System.Reflection; namespace Python.Runtime { @@ -19,16 +20,38 @@ namespace Python.Runtime { internal class MethodBinding : ExtensionType { + MethodInfo info; MethodObject m; IntPtr target; public MethodBinding(MethodObject m, IntPtr target) : base() { Runtime.Incref(target); this.target = target; + this.info = null; this.m = m; } + //==================================================================== + // Implement explicit overload selection using subscript syntax ([]). + //==================================================================== + + [CallConvCdecl()] + public static IntPtr mp_subscript(IntPtr tp, IntPtr idx) { + MethodBinding self = (MethodBinding)GetManagedObject(tp); + MethodInfo sig = MethodBinder.MatchByTypeSig(self.m.info, idx); + if (sig == null) { + return Exceptions.RaiseTypeError( + "No match found for signature" + ); + } + MethodBinding mb = new MethodBinding(self.m, self.target); + mb.info = sig; + Runtime.Incref(mb.pyHandle); + return mb.pyHandle; + } + + //==================================================================== // MethodBinding __getattribute__ implementation. //==================================================================== @@ -77,12 +100,13 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw) { IntPtr uargs = Runtime.PyTuple_GetSlice(args, 1, len); IntPtr inst = Runtime.PyTuple_GetItem(args, 0); Runtime.Incref(inst); - IntPtr r = self.m.Invoke(inst, uargs, kw); + IntPtr r = self.m.Invoke(inst, uargs, kw, self.info); Runtime.Decref(inst); + Runtime.Decref(uargs); return r; } - return self.m.Invoke(self.target, args, kw); + return self.m.Invoke(self.target, args, kw, self.info); } diff --git a/pythonnet/src/runtime/methodobject.cs b/pythonnet/src/runtime/methodobject.cs index f413e1b60..c70560377 100755 --- a/pythonnet/src/runtime/methodobject.cs +++ b/pythonnet/src/runtime/methodobject.cs @@ -35,8 +35,13 @@ public MethodObject(string name, MethodInfo[] info) : base() { } - public virtual IntPtr Invoke(IntPtr target, IntPtr args, IntPtr kw) { - return binder.Invoke(target, args, kw); + public virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw) { + return this.Invoke(inst, args, kw, null); + } + + public virtual IntPtr Invoke(IntPtr target, IntPtr args, IntPtr kw, + MethodBase info) { + return binder.Invoke(target, args, kw, info); } diff --git a/pythonnet/src/testing/methodtest.cs b/pythonnet/src/testing/methodtest.cs index 70b7fad2b..7209adfa0 100755 --- a/pythonnet/src/testing/methodtest.cs +++ b/pythonnet/src/testing/methodtest.cs @@ -127,6 +127,174 @@ public static void TestVoidSingleRefParam (ref int i) { i = 42; } + // overload selection test support + + public static bool TestOverloadSelection(bool v) { + return v; + } + + public static byte TestOverloadSelection(byte v) { + return v; + } + + public static sbyte TestOverloadSelection(sbyte v) { + return v; + } + + public static char TestOverloadSelection(char v) { + return v; + } + + public static short TestOverloadSelection(short v) { + return v; + } + + public static int TestOverloadSelection(int v) { + return v; + } + + public static long TestOverloadSelection(long v) { + return v; + } + + public static ushort TestOverloadSelection(ushort v) { + return v; + } + + public static uint TestOverloadSelection(uint v) { + return v; + } + + public static ulong TestOverloadSelection(ulong v) { + return v; + } + + public static float TestOverloadSelection(float v) { + return v; + } + + public static double TestOverloadSelection(double v) { + return v; + } + + public static decimal TestOverloadSelection(decimal v) { + return v; + } + + public static string TestOverloadSelection(string v) { + return v; + } + + public static ShortEnum TestOverloadSelection(ShortEnum v) { + return v; + } + + public static object TestOverloadSelection(object v) { + return v; + } + + public static InterfaceTest TestOverloadSelection(InterfaceTest v) { + return v; + } + + public static ISayHello1 TestOverloadSelection(ISayHello1 v) { + return v; + } + + public static bool[] TestOverloadSelection(bool[] v) { + return v; + } + + public static byte[] TestOverloadSelection(byte[] v) { + return v; + } + + public static sbyte[] TestOverloadSelection(sbyte[] v) { + return v; + } + + public static char[] TestOverloadSelection(char[] v) { + return v; + } + + public static short[] TestOverloadSelection(short[] v) { + return v; + } + + public static int[] TestOverloadSelection(int[] v) { + return v; + } + + public static long[] TestOverloadSelection(long[] v) { + return v; + } + + public static ushort[] TestOverloadSelection(ushort[] v) { + return v; + } + + public static uint[] TestOverloadSelection(uint[] v) { + return v; + } + + public static ulong[] TestOverloadSelection(ulong[] v) { + return v; + } + + public static float[] TestOverloadSelection(float[] v) { + return v; + } + + public static double[] TestOverloadSelection(double[] v) { + return v; + } + + public static decimal[] TestOverloadSelection(decimal[] v) { + return v; + } + + public static string[] TestOverloadSelection(string[] v) { + return v; + } + + public static ShortEnum[] TestOverloadSelection(ShortEnum[] v) { + return v; + } + + public static object[] TestOverloadSelection(object[] v) { + return v; + } + + public static InterfaceTest[] TestOverloadSelection(InterfaceTest[] v){ + return v; + } + + public static ISayHello1[] TestOverloadSelection(ISayHello1[] v) { + return v; + } + +// public static GenericWrapper TestOverloadSelection( +// GenericWrapper v) { +// return v; +// } + +// public static GenericWrapper[] TestOverloadSelection( +// GenericWrapper[] v) { +// return v; +// } + + public static int TestOverloadSelection(string s, int i, object[] o) { + return o.Length; + } + + public static int TestOverloadSelection(string s, int i) { + return i; + } + + public static int TestOverloadSelection(int i, string s) { + return i; + } + } diff --git a/pythonnet/src/tests/runtests.py b/pythonnet/src/tests/runtests.py index b5b9b40af..ec0df0821 100755 --- a/pythonnet/src/tests/runtests.py +++ b/pythonnet/src/tests/runtests.py @@ -15,6 +15,7 @@ 'test_exceptions', 'test_module', 'test_compat', + #'test_generic', 'test_conversion', 'test_class', 'test_interface', diff --git a/pythonnet/src/tests/test_array.py b/pythonnet/src/tests/test_array.py index c4f81c3af..f865f679f 100755 --- a/pythonnet/src/tests/test_array.py +++ b/pythonnet/src/tests/test_array.py @@ -9,6 +9,7 @@ import sys, os, string, unittest, types import Python.Test as Test +import System class ArrayTests(unittest.TestCase): @@ -1325,6 +1326,139 @@ def testBoxedValueTypeMutationResult(self): self.failUnless(items[i].Y == i + 1) + def testSpecialArrayCreation(self): + """Test using the Array[] syntax for creating arrays.""" + from Python.Test import ISayHello1, InterfaceTest, ShortEnum + from System import Array + inst = InterfaceTest() + + value = Array[System.Boolean]([True, True]) + self.failUnless(value[0] == True) + self.failUnless(value[1] == True) + self.failUnless(value.Length == 2) + + value = Array[bool]([True, True]) + self.failUnless(value[0] == True) + self.failUnless(value[1] == True) + self.failUnless(value.Length == 2) + + value = Array[System.Byte]([0, 255]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 255) + self.failUnless(value.Length == 2) + + value = Array[System.SByte]([0, 127]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 127) + self.failUnless(value.Length == 2) + + value = Array[System.Char]([u'A', u'Z']) + self.failUnless(value[0] == u'A') + self.failUnless(value[1] == u'Z') + self.failUnless(value.Length == 2) + + value = Array[System.Char]([0, 65535]) + self.failUnless(value[0] == unichr(0)) + self.failUnless(value[1] == unichr(65535)) + self.failUnless(value.Length == 2) + + value = Array[System.Int16]([0, 32767]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 32767) + self.failUnless(value.Length == 2) + + value = Array[System.Int32]([0, 2147483647]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 2147483647) + self.failUnless(value.Length == 2) + + value = Array[int]([0, 2147483647]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 2147483647) + self.failUnless(value.Length == 2) + + value = Array[System.Int64]([0, 9223372036854775807L]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 9223372036854775807L) + self.failUnless(value.Length == 2) + + value = Array[long]([0, 9223372036854775807L]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 9223372036854775807L) + self.failUnless(value.Length == 2) + + value = Array[System.UInt16]([0, 65000]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 65000) + self.failUnless(value.Length == 2) + + value = Array[System.UInt32]([0, 4294967295L]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 4294967295L) + self.failUnless(value.Length == 2) + + value = Array[System.UInt64]([0, 18446744073709551615L]) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 18446744073709551615L) + self.failUnless(value.Length == 2) + + value = Array[System.Single]([0.0, 3.402823e38]) + self.failUnless(value[0] == 0.0) + self.failUnless(value[1] == 3.402823e38) + self.failUnless(value.Length == 2) + + value = Array[System.Double]([0.0, 1.7976931348623157e308]) + self.failUnless(value[0] == 0.0) + self.failUnless(value[1] == 1.7976931348623157e308) + self.failUnless(value.Length == 2) + + value = Array[float]([0.0, 1.7976931348623157e308]) + self.failUnless(value[0] == 0.0) + self.failUnless(value[1] == 1.7976931348623157e308) + self.failUnless(value.Length == 2) + + value = Array[System.Decimal]([System.Decimal.Zero,System.Decimal.One]) + self.failUnless(value[0] == System.Decimal.Zero) + self.failUnless(value[1] == System.Decimal.One) + self.failUnless(value.Length == 2) + + value = Array[System.String](["one", "two"]) + self.failUnless(value[0] == "one") + self.failUnless(value[1] == "two") + self.failUnless(value.Length == 2) + + value = Array[str](["one", "two"]) + self.failUnless(value[0] == "one") + self.failUnless(value[1] == "two") + self.failUnless(value.Length == 2) + + value = Array[ShortEnum]([ShortEnum.Zero, ShortEnum.One]) + self.failUnless(value[0] == ShortEnum.Zero) + self.failUnless(value[1] == ShortEnum.One) + self.failUnless(value.Length == 2) + + value = Array[System.Object]([inst, inst]) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + self.failUnless(value.Length == 2) + + value = Array[InterfaceTest]([inst, inst]) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + self.failUnless(value.Length == 2) + + value = Array[ISayHello1]([inst, inst]) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + self.failUnless(value.Length == 2) + + inst = System.Exception("badness") + value = Array[System.Exception]([inst, inst]) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + self.failUnless(value.Length == 2) + + def testArrayAbuse(self): """Test array abuse.""" _class = Test.PublicArrayTest diff --git a/pythonnet/src/tests/test_method.py b/pythonnet/src/tests/test_method.py index 589296e33..912835b3c 100755 --- a/pythonnet/src/tests/test_method.py +++ b/pythonnet/src/tests/test_method.py @@ -388,6 +388,284 @@ def test(): self.failUnlessRaises(TypeError, test) + def testExplicitOverloadSelection(self): + """Check explicit overload selection using [] syntax.""" + from Python.Test import ISayHello1, InterfaceTest, ShortEnum + from System import Array + inst = InterfaceTest() + + value = MethodTest.TestOverloadSelection[System.Boolean](True) + self.failUnless(value == True) + + value = MethodTest.TestOverloadSelection[bool](True) + self.failUnless(value == True) + + value = MethodTest.TestOverloadSelection[System.Byte](255) + self.failUnless(value == 255) + + value = MethodTest.TestOverloadSelection[System.SByte](127) + self.failUnless(value == 127) + + value = MethodTest.TestOverloadSelection[System.Char](u'A') + self.failUnless(value == u'A') + + value = MethodTest.TestOverloadSelection[System.Char](65535) + self.failUnless(value == unichr(65535)) + + value = MethodTest.TestOverloadSelection[System.Int16](32767) + self.failUnless(value == 32767) + + value = MethodTest.TestOverloadSelection[System.Int32](2147483647) + self.failUnless(value == 2147483647) + + value = MethodTest.TestOverloadSelection[int](2147483647) + self.failUnless(value == 2147483647) + + value = MethodTest.TestOverloadSelection[System.Int64]( + 9223372036854775807L + ) + self.failUnless(value == 9223372036854775807L) + + value = MethodTest.TestOverloadSelection[long]( + 9223372036854775807L + ) + self.failUnless(value == 9223372036854775807L) + + value = MethodTest.TestOverloadSelection[System.UInt16](65000) + self.failUnless(value == 65000) + + value = MethodTest.TestOverloadSelection[System.UInt32](4294967295L) + self.failUnless(value == 4294967295L) + + value = MethodTest.TestOverloadSelection[System.UInt64]( + 18446744073709551615L + ) + self.failUnless(value == 18446744073709551615L) + + value = MethodTest.TestOverloadSelection[System.Single](3.402823e38) + self.failUnless(value == 3.402823e38) + + value = MethodTest.TestOverloadSelection[System.Double]( + 1.7976931348623157e308 + ) + self.failUnless(value == 1.7976931348623157e308) + + value = MethodTest.TestOverloadSelection[float]( + 1.7976931348623157e308 + ) + self.failUnless(value == 1.7976931348623157e308) + + value = MethodTest.TestOverloadSelection[System.Decimal]( + System.Decimal.One + ) + self.failUnless(value == System.Decimal.One) + + value = MethodTest.TestOverloadSelection[System.String]("spam") + self.failUnless(value == "spam") + + value = MethodTest.TestOverloadSelection[str]("spam") + self.failUnless(value == "spam") + + value = MethodTest.TestOverloadSelection[ShortEnum](ShortEnum.Zero) + self.failUnless(value == ShortEnum.Zero) + + value = MethodTest.TestOverloadSelection[System.Object](inst) + self.failUnless(value.__class__ == inst.__class__) + + value = MethodTest.TestOverloadSelection[InterfaceTest](inst) + self.failUnless(value.__class__ == inst.__class__) + + value = MethodTest.TestOverloadSelection[ISayHello1](inst) + self.failUnless(value.__class__ == inst.__class__) + + atype = Array[System.Object] + value = MethodTest.TestOverloadSelection[str, int, atype]( + "one", 1, atype([1, 2, 3]) + ) + self.failUnless(value == 3) + + value = MethodTest.TestOverloadSelection[str, int]("one", 1) + self.failUnless(value == 1) + + value = MethodTest.TestOverloadSelection[int, str](1, "one") + self.failUnless(value == 1) + + + def testOverloadSelectionWithArrayTypes(self): + """Check overload selection using array types.""" + from Python.Test import ISayHello1, InterfaceTest, ShortEnum + from System import Array + inst = InterfaceTest() + + vtype = Array[System.Boolean] + input = vtype([True, True]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == True) + self.failUnless(value[1] == True) + + vtype = Array[bool] + input = vtype([True, True]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == True) + self.failUnless(value[1] == True) + + vtype = Array[System.Byte] + input = vtype([0, 255]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 255) + + vtype = Array[System.SByte] + input = vtype([0, 127]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 127) + + vtype = Array[System.Char] + input = vtype([u'A', u'Z']) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == u'A') + self.failUnless(value[1] == u'Z') + + vtype = Array[System.Char] + input = vtype([0, 65535]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == unichr(0)) + self.failUnless(value[1] == unichr(65535)) + + vtype = Array[System.Int16] + input = vtype([0, 32767]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 32767) + + vtype = Array[System.Int32] + input = vtype([0, 2147483647]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 2147483647) + + vtype = Array[int] + input = vtype([0, 2147483647]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 2147483647) + + vtype = Array[System.Int64] + input = vtype([0, 9223372036854775807L]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 9223372036854775807L) + + vtype = Array[long] + input = vtype([0, 9223372036854775807L]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 9223372036854775807L) + + vtype = Array[System.UInt16] + input = vtype([0, 65000]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 65000) + + vtype = Array[System.UInt32] + input = vtype([0, 4294967295L]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 4294967295L) + + vtype = Array[System.UInt64] + input = vtype([0, 18446744073709551615L]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0) + self.failUnless(value[1] == 18446744073709551615L) + + vtype = Array[System.Single] + input = vtype([0.0, 3.402823e38]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0.0) + self.failUnless(value[1] == 3.402823e38) + + vtype = Array[System.Double] + input = vtype([0.0, 1.7976931348623157e308]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0.0) + self.failUnless(value[1] == 1.7976931348623157e308) + + vtype = Array[float] + input = vtype([0.0, 1.7976931348623157e308]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == 0.0) + self.failUnless(value[1] == 1.7976931348623157e308) + + vtype = Array[System.Decimal] + input = vtype([System.Decimal.Zero, System.Decimal.One]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == System.Decimal.Zero) + self.failUnless(value[1] == System.Decimal.One) + + vtype = Array[System.String] + input = vtype(["one", "two"]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == "one") + self.failUnless(value[1] == "two") + + vtype = Array[str] + input = vtype(["one", "two"]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == "one") + self.failUnless(value[1] == "two") + + vtype = Array[ShortEnum] + input = vtype([ShortEnum.Zero, ShortEnum.One]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0] == ShortEnum.Zero) + self.failUnless(value[1] == ShortEnum.One) + + vtype = Array[System.Object] + input = vtype([inst, inst]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + + vtype = Array[InterfaceTest] + input = vtype([inst, inst]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + + vtype = Array[ISayHello1] + input = vtype([inst, inst]) + value = MethodTest.TestOverloadSelection[vtype](input) + self.failUnless(value[0].__class__ == inst.__class__) + self.failUnless(value[1].__class__ == inst.__class__) + + + def testExplicitOverloadSelectionFailure(self): + """Check that overload selection fails correctly.""" + + def test(): + value = MethodTest.TestOverloadSelection[System.Type](True) + + self.failUnlessRaises(TypeError, test) + + def test(): + value = MethodTest.TestOverloadSelection[int, int](1, 1) + + self.failUnlessRaises(TypeError, test) + + def test(): + value = MethodTest.TestOverloadSelection[str, int, int]("", 1, 1) + + self.failUnlessRaises(TypeError, test) + + def test(): + value = MethodTest.TestOverloadSelection[int, long](1) + + self.failUnlessRaises(TypeError, test) + + def test_suite(): From 316182f354dd48cdc4fa31156e8dbe0a0af673f8 Mon Sep 17 00:00:00 2001 From: Tony Roberts Date: Fri, 26 Jun 2015 11:07:43 +0100 Subject: [PATCH 3/6] Update README.md Update CI badges to use the master branch. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b88ac0e9..5ad3a5cde 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,6 @@ pythonnet Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. -[![Build Status](https://travis-ci.org/pythonnet/pythonnet.png?branch=develop)](https://travis-ci.org/pythonnet/pythonnet) +[![Build Status](https://travis-ci.org/pythonnet/pythonnet.png?branch=master)](https://travis-ci.org/pythonnet/pythonnet) -[![Build status](https://ci.appveyor.com/api/projects/status/65riiu1hvgaxsbwb)](https://ci.appveyor.com/project/davidanthoff/pythonnet) +[![Build status](https://ci.appveyor.com/api/projects/status/c8k0miljb3n1c7be/branch/master)](https://ci.appveyor.com/project/TonyRoberts/pythonnet-480xs) From 108d7dd05ba5c43ae050463db3c5838a4b3f0948 Mon Sep 17 00:00:00 2001 From: denfromufa Date: Thu, 16 Jul 2015 14:47:53 -0500 Subject: [PATCH 4/6] exception message passed from Python to .NET correctly https://github.com/pythonnet/pythonnet/issues/82 --- src/runtime/pythonexception.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runtime/pythonexception.cs b/src/runtime/pythonexception.cs index 592e9ea37..f09d9ffe1 100644 --- a/src/runtime/pythonexception.cs +++ b/src/runtime/pythonexception.cs @@ -35,7 +35,9 @@ public PythonException() : base() if ((_pyType != IntPtr.Zero) && (_pyValue != IntPtr.Zero)) { string type = new PyObject(_pyType).GetAttr("__name__").ToString(); - string message = Runtime.GetManagedString(_pyValue); + IntPtr _PyValueStr = Runtime.PyObject_Str(_pyValue); + string message = Runtime.GetManagedString(_PyValueStr); + //string message = Runtime.GetManagedString(_pyValue); _message = type + " : " + message; } if (_pyTB != IntPtr.Zero) From 131104c3bab1345d858d163829aa0302c1983df4 Mon Sep 17 00:00:00 2001 From: denfromufa Date: Mon, 31 Aug 2015 01:04:10 -0500 Subject: [PATCH 5/6] post-build script to copy assemblies to python\lib\site-packages, pyproj for python unit tests --- pythonnet.sln | 126 +++++++++++++++++++++++++++++- src/clrmodule/clrmodule.csproj | 18 +++-- src/runtime/Python.Runtime.csproj | 53 +++++++------ src/testing/Python.Test.csproj | 22 ++++-- src/tests/test_exceptions.py | 21 ++--- src/tests/tests.pyproj | 59 ++++++++++++++ 6 files changed, 252 insertions(+), 47 deletions(-) create mode 100644 src/tests/tests.pyproj diff --git a/pythonnet.sln b/pythonnet.sln index 64bf45fa2..547bf02ee 100644 --- a/pythonnet.sln +++ b/pythonnet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +# Visual Studio 14 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}" EndProject @@ -13,90 +13,212 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "src\console\Cons EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "clrmodule", "src\clrmodule\clrmodule.csproj", "{86E834DE-1139-4511-96CC-69636A56E7AC}" EndProject +Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "tests", "src\tests\tests.pyproj", "{414322E9-AEB7-475E-BBF2-7DF60D982AC6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + DebugMono|Any CPU = DebugMono|Any CPU DebugMono|x64 = DebugMono|x64 DebugMono|x86 = DebugMono|x86 + DebugWin|Any CPU = DebugWin|Any CPU DebugWin|x64 = DebugWin|x64 DebugWin|x86 = DebugWin|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + ReleaseMono|Any CPU = ReleaseMono|Any CPU ReleaseMono|x64 = ReleaseMono|x64 ReleaseMono|x86 = ReleaseMono|x86 + ReleaseWin|Any CPU = ReleaseWin|Any CPU ReleaseWin|x64 = ReleaseWin|x64 ReleaseWin|x86 = ReleaseWin|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.ActiveCfg = ReleaseWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|Any CPU.Build.0 = ReleaseWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.ActiveCfg = DebugWin|x64 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x64.Build.0 = DebugWin|x64 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x86.ActiveCfg = DebugWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Debug|x86.Build.0 = DebugWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.ActiveCfg = DebugMono|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.Build.0 = DebugMono|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.ActiveCfg = DebugMono|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.Build.0 = DebugMono|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.ActiveCfg = DebugWin|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.Build.0 = DebugWin|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.ActiveCfg = DebugWin|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.Build.0 = DebugWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.ActiveCfg = ReleaseWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|Any CPU.Build.0 = ReleaseWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.ActiveCfg = ReleaseWin|x64 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x64.Build.0 = ReleaseWin|x64 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x86.ActiveCfg = ReleaseWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.Release|x86.Build.0 = ReleaseWin|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 {097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.ActiveCfg = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|Any CPU.Build.0 = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.ActiveCfg = DebugWin|x64 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x64.Build.0 = DebugWin|x64 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x86.ActiveCfg = DebugWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Debug|x86.Build.0 = DebugWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.ActiveCfg = DebugMono|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.Build.0 = DebugMono|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x86.ActiveCfg = DebugMono|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x86.Build.0 = DebugMono|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x64.ActiveCfg = DebugWin|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x64.Build.0 = DebugWin|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x86.ActiveCfg = DebugWin|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.DebugWin|x86.Build.0 = DebugWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.ActiveCfg = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|Any CPU.Build.0 = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.ActiveCfg = ReleaseWin|x64 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x64.Build.0 = ReleaseWin|x64 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x86.ActiveCfg = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.Release|x86.Build.0 = ReleaseWin|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 {6F401A34-273B-450F-9A4C-13550BE0767B}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|Any CPU.ActiveCfg = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|Any CPU.Build.0 = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x64.ActiveCfg = DebugWin|x64 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x64.Build.0 = DebugWin|x64 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x86.ActiveCfg = DebugWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Debug|x86.Build.0 = DebugWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x64.ActiveCfg = DebugMono|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x64.Build.0 = DebugMono|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x86.ActiveCfg = DebugMono|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugMono|x86.Build.0 = DebugMono|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x64.ActiveCfg = DebugWin|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x64.Build.0 = DebugWin|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x86.ActiveCfg = DebugWin|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.DebugWin|x86.Build.0 = DebugWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|Any CPU.ActiveCfg = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|Any CPU.Build.0 = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x64.ActiveCfg = ReleaseWin|x64 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x64.Build.0 = ReleaseWin|x64 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x86.ActiveCfg = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.Release|x86.Build.0 = ReleaseWin|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 {4165C59D-2822-499F-A6DB-EACA4C331EB5}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.ActiveCfg = Debug|x64 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x64.Build.0 = Debug|x64 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x86.ActiveCfg = Debug|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Debug|x86.Build.0 = Debug|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|Any CPU.ActiveCfg = DebugMono_x86|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|Any CPU.Build.0 = DebugMono_x86|Any CPU {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x64.ActiveCfg = DebugMono_x86|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x64.Build.0 = DebugMono_x86|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x86.ActiveCfg = DebugMono_x86|x86 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugMono|x86.Build.0 = DebugMono_x86|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|Any CPU.ActiveCfg = DebugMono_x86|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|Any CPU.Build.0 = DebugMono_x86|Any CPU {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x64.ActiveCfg = DebugMono_x86|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x64.Build.0 = DebugMono_x86|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x86.ActiveCfg = DebugMono_x86|x86 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.DebugWin|x86.Build.0 = DebugMono_x86|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|Any CPU.Build.0 = Release|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.ActiveCfg = Release|x64 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x64.Build.0 = Release|x64 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x86.ActiveCfg = Release|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.Release|x86.Build.0 = Release|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|Any CPU.ActiveCfg = Release|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|Any CPU.Build.0 = Release|Any CPU {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x64.ActiveCfg = Release|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x64.Build.0 = Release|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x86.ActiveCfg = Release|x86 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseMono|x86.Build.0 = Release|x86 + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|Any CPU.ActiveCfg = Release|Any CPU + {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|Any CPU.Build.0 = Release|Any CPU {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.ActiveCfg = Release|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x64.Build.0 = Release|x64 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.ActiveCfg = Release|x86 {E29DCF0A-5114-4A98-B1DD-71264B6EA349}.ReleaseWin|x86.Build.0 = Release|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Debug|Any CPU.ActiveCfg = ReleaseWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Debug|Any CPU.Build.0 = ReleaseWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Debug|x64.ActiveCfg = DebugWin|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Debug|x64.Build.0 = DebugWin|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Debug|x86.ActiveCfg = DebugWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Debug|x86.Build.0 = DebugWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|Any CPU.ActiveCfg = DebugMono|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.ActiveCfg = DebugMono|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x64.Build.0 = DebugMono|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.ActiveCfg = DebugMono|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugMono|x86.Build.0 = DebugMono|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|Any CPU.ActiveCfg = DebugWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.ActiveCfg = DebugWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x64.Build.0 = DebugWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.ActiveCfg = DebugWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.DebugWin|x86.Build.0 = DebugWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Release|Any CPU.ActiveCfg = ReleaseWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Release|Any CPU.Build.0 = ReleaseWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Release|x64.ActiveCfg = ReleaseWin|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Release|x64.Build.0 = ReleaseWin|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Release|x86.ActiveCfg = ReleaseWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.Release|x86.Build.0 = ReleaseWin|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|Any CPU.ActiveCfg = ReleaseMono|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x64.Build.0 = ReleaseMono|x64 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseMono|x86.Build.0 = ReleaseMono|x86 + {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|Any CPU.ActiveCfg = ReleaseWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x64.Build.0 = ReleaseWin|x64 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86 {86E834DE-1139-4511-96CC-69636A56E7AC}.ReleaseWin|x86.Build.0 = ReleaseWin|x86 + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.Debug|x64.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.Debug|x86.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.DebugMono|Any CPU.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.DebugMono|x64.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.DebugMono|x86.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.DebugWin|Any CPU.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.DebugWin|x64.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.DebugWin|x86.ActiveCfg = Debug|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.Release|x64.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.Release|x86.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.ReleaseMono|Any CPU.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.ReleaseMono|x64.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.ReleaseMono|x86.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.ReleaseWin|Any CPU.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.ReleaseWin|x64.ActiveCfg = Release|Any CPU + {414322E9-AEB7-475E-BBF2-7DF60D982AC6}.ReleaseWin|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/clrmodule/clrmodule.csproj b/src/clrmodule/clrmodule.csproj index 92dc2a945..420aa9a3d 100644 --- a/src/clrmodule/clrmodule.csproj +++ b/src/clrmodule/clrmodule.csproj @@ -40,7 +40,8 @@ bin\x86\ReleaseMono\ - + + true pdbonly x86 @@ -51,7 +52,8 @@ bin\x64\ReleaseMono\ - + + true pdbonly x64 @@ -84,7 +86,8 @@ bin\x86\ReleaseWin\ - + + true pdbonly x86 @@ -95,7 +98,8 @@ bin\x64\ReleaseWin\ - + + true pdbonly x64 @@ -120,7 +124,11 @@ - + + + for /f "delims=" %25%25i in ('python -c "import site; print(site.getsitepackages()[1])"') do set output=%25%25i +copy /Y "$(SolutionDir)\clr.pyd" %25output%25 + \ No newline at end of file diff --git a/src/runtime/Python.Runtime.csproj b/src/runtime/Python.Runtime.csproj index f5bf3378a..385f2ed8a 100644 --- a/src/runtime/Python.Runtime.csproj +++ b/src/runtime/Python.Runtime.csproj @@ -9,7 +9,7 @@ Python.Runtime Python.Runtime ..\..\ - $(SolutionDir) + $(SolutionDir) bin\x86\ReleaseMono\ @@ -92,28 +92,29 @@ false full x64 + TRACE;DEBUG;PYTHON34,UCS2 - - - - - False - ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll - - - - - - - False - ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll - - - - - - - + + + + + False + ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll + + + + + + + False + ..\..\packages\MonoGAC\Mono.Posix\4.0.0.0__0738eb9f132ed756\Mono.Posix.dll + + + + + + + @@ -185,6 +186,10 @@ - + - + + for /f "delims=" %25%25i in ('python -c "import site; print(site.getsitepackages()[1])"') do set output=%25%25i +copy /Y "$(TargetPath)" %25output%25 + + \ No newline at end of file diff --git a/src/testing/Python.Test.csproj b/src/testing/Python.Test.csproj index b0c41a866..9af04b334 100644 --- a/src/testing/Python.Test.csproj +++ b/src/testing/Python.Test.csproj @@ -38,7 +38,8 @@ bin\x86\ReleaseMono\ - + + true pdbonly x86 @@ -49,7 +50,8 @@ bin\x64\ReleaseMono\ - + + true pdbonly x64 @@ -57,7 +59,7 @@ true true false - + true bin\x86\DebugWin\ @@ -68,7 +70,7 @@ true false false - + true bin\x64\DebugWin\ @@ -82,7 +84,8 @@ bin\x86\ReleaseWin\ - + + true pdbonly x86 @@ -93,7 +96,8 @@ bin\x64\ReleaseWin\ - + + true pdbonly x64 @@ -141,7 +145,11 @@ $(SolutionDir) + + for /f "delims=" %25%25i in ('python -c "import site; print(site.getsitepackages()[1])"') do set output=%25%25i +copy /Y "$(TargetPath)" %25output%25 + - + \ No newline at end of file diff --git a/src/tests/test_exceptions.py b/src/tests/test_exceptions.py index de6dd01e5..9930a22ad 100644 --- a/src/tests/test_exceptions.py +++ b/src/tests/test_exceptions.py @@ -1,4 +1,4 @@ -# =========================================================================== +# =========================================================================== # This software is subject to the provisions of the Zope Public License, # Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED @@ -6,9 +6,12 @@ # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # =========================================================================== - -import sys, os, string, unittest, types +import clr import System +import sys, os, string, unittest, types + +#TODO: Py 2/3 compatibility +#TODO: build to Python directory # Note: all of these tests are known to fail because Python currently # doesn't allow new-style classes to be used as exceptions. I'm leaving @@ -93,7 +96,7 @@ def testRaiseClassExceptionWithValue(self): from System import NullReferenceException def test(): - raise NullReferenceException, 'Aiiieee!' + raise NullReferenceException('Aiiieee!') self.assertRaises(NullReferenceException, test) @@ -185,7 +188,7 @@ def testCatchExceptionFromManagedMethod(self): try: ExceptionTest().ThrowException() - except OverflowException, e: + except OverflowException as e: self.assertTrue(isinstance(e, OverflowException)) return @@ -199,13 +202,13 @@ def testCatchExceptionFromManagedProperty(self): try: v = ExceptionTest().ThrowProperty - except OverflowException, e: + except OverflowException as e: self.assertTrue(isinstance(e, OverflowException)) return try: ExceptionTest().ThrowProperty = 1 - except OverflowException, e: + except OverflowException as e: self.assertTrue(isinstance(e, OverflowException)) return @@ -267,7 +270,7 @@ def testCatchExceptionWithAssignment(self): try: raise OverflowException('overflow') - except OverflowException, e: + except OverflowException as e: self.assertTrue(isinstance(e, OverflowException)) @@ -303,7 +306,7 @@ def testStrOfException(self): try: Convert.ToDateTime('this will fail') - except FormatException, e: + except FormatException as e: msg = unicode(e).encode("utf8") # fix for international installation self.assertTrue(msg.find('System.Convert.ToDateTime') > -1, msg) diff --git a/src/tests/tests.pyproj b/src/tests/tests.pyproj new file mode 100644 index 000000000..da63f0c16 --- /dev/null +++ b/src/tests/tests.pyproj @@ -0,0 +1,59 @@ + + + + Debug + 2.0 + {414322e9-aeb7-475e-bbf2-7df60d982ac6} + + leaktest.py + + . + . + {888888a0-9f3d-457c-b088-3a5042f75d52} + Standard Python launcher + + + + + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 7c281d9ac7429dd74ffb833db8a2a602608fb074 Mon Sep 17 00:00:00 2001 From: denfromufa Date: Thu, 10 Sep 2015 12:50:33 -0500 Subject: [PATCH 6/6] load assembly from full path --- src/runtime/assemblymanager.cs | 30 ++++++++++++++++++++++++++++++ src/runtime/moduleobject.cs | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/runtime/assemblymanager.cs b/src/runtime/assemblymanager.cs index 583b5c945..49009d0a5 100644 --- a/src/runtime/assemblymanager.cs +++ b/src/runtime/assemblymanager.cs @@ -199,6 +199,7 @@ public static Assembly LoadAssembly(string name) { //=================================================================== public static Assembly LoadAssemblyPath(string name) { + string path = FindAssembly(name); Assembly assembly = null; if (path != null) { @@ -208,6 +209,35 @@ public static Assembly LoadAssemblyPath(string name) { return assembly; } + /// + /// Loads an assembly using full path. + /// + /// + /// + public static Assembly LoadAssemblyFullPath(string name) + { + Assembly assembly = null; + if (name.Contains(Convert.ToString(Path.DirectorySeparatorChar))) + { + string temp = ""; + temp = name + ".dll"; + if (!File.Exists(temp)) + { + temp = name + ".exe"; + if (!File.Exists(temp)) + { + temp = ""; + } + } + if (temp != "") + { + try { assembly = Assembly.LoadFrom(temp); } + catch { } + } + } + return assembly; + } + //=================================================================== // Returns an assembly that's already been loaded //=================================================================== diff --git a/src/runtime/moduleobject.cs b/src/runtime/moduleobject.cs index c5735ca4a..ec81f3576 100644 --- a/src/runtime/moduleobject.cs +++ b/src/runtime/moduleobject.cs @@ -385,7 +385,12 @@ public static Assembly AddReference(string name) { AssemblyManager.UpdatePath(); Assembly assembly = null; - assembly = AssemblyManager.FindLoadedAssembly(name); + + assembly = AssemblyManager.LoadAssemblyFullPath(name); + if (assembly == null) + { + assembly = AssemblyManager.FindLoadedAssembly(name); + } if (assembly == null) { assembly = AssemblyManager.LoadAssemblyPath(name);