| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,9 @@ def _find_msbuild_tool(tool="msbuild.exe", use_windows_sdk=False): | |||
| 31 | 31 | value_name = "InstallationFolder" | |
| 32 | 32 | sdk_name = "Windows SDK" | |
| 33 | 33 | keys_to_check = [ | |
| 34 | + r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A\WinSDK-Win32Tools", | ||
| 34 | 35 | r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1\WinSDKWin32Tools", | |
| 36 | + r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-Win32Tools", | ||
| 35 | 37 | r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0\WinSDKWin32Tools", | |
| 36 | 38 | r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A\WinSDKWin32Tools", | |
| 37 | 39 | ] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,7 +26,7 @@ internal class ClassObject : ClassBase { | |||
| 26 | 26 | ||
| 27 | 27 | internal ClassObject(Type tp) : base(tp) { | |
| 28 | 28 | ctors = type.GetConstructors(); | |
| 29 | - binder = new ConstructorBinder(); | ||
| 29 | + binder = new ConstructorBinder(type); | ||
| 30 | 30 | ||
| 31 | 31 | for (int i = 0; i < ctors.Length; i++) { | |
| 32 | 32 | binder.AddMethod(ctors[i]); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,8 +21,11 @@ namespace Python.Runtime { | |||
| 21 | 21 | //======================================================================== | |
| 22 | 22 | ||
| 23 | 23 | internal class ConstructorBinder : MethodBinder { | |
| 24 | + private Type _containingType = null; | ||
| 24 | 25 | ||
| 25 | - internal ConstructorBinder () : base() {} | ||
| 26 | + internal ConstructorBinder(Type containingType) : base() { | ||
| 27 | + _containingType = containingType; | ||
| 28 | + } | ||
| 26 | 29 | ||
| 27 | 30 | //==================================================================== | |
| 28 | 31 | // Constructors get invoked when an instance of a wrapped managed | |
@@ -53,9 +56,31 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw) { | |||
| 53 | 56 | /// </remarks> | |
| 54 | 57 | internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, | |
| 55 | 58 | MethodBase info) { | |
| 56 | - Binding binding = this.Bind(inst, args, kw, info); | ||
| 57 | 59 | Object result; | |
| 58 | 60 | ||
| 61 | + if (_containingType.IsValueType && !_containingType.IsPrimitive && | ||
| 62 | + !_containingType.IsEnum && _containingType != typeof (decimal) && | ||
| 63 | + Runtime.PyTuple_Size(args) == 0) { | ||
| 64 | + // If you are trying to construct an instance of a struct by | ||
| 65 | + // calling its default constructor, that ConstructorInfo | ||
| 66 | + // instance will not appear in reflection and the object must | ||
| 67 | + // instead be constructed via a call to | ||
| 68 | + // Activator.CreateInstance(). | ||
| 69 | + try { | ||
| 70 | + result = Activator.CreateInstance(_containingType); | ||
| 71 | + } | ||
| 72 | + catch (Exception e) { | ||
| 73 | + if (e.InnerException != null) { | ||
| 74 | + e = e.InnerException; | ||
| 75 | + } | ||
| 76 | + Exceptions.SetError(e); | ||
| 77 | + return null; | ||
| 78 | + } | ||
| 79 | + return result; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + Binding binding = this.Bind(inst, args, kw, info); | ||
| 83 | + | ||
| 59 | 84 | if (binding == null) { | |
| 60 | 85 | // It is possible for __new__ to be invoked on construction | |
| 61 | 86 | // of a Python subclass of a managed class, so args may | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -136,10 +136,9 @@ def testStructConstruction(self): | |||
| 136 | 136 | """Test construction of structs.""" | |
| 137 | 137 | from System.Drawing import Point | |
| 138 | 138 | ||
| 139 | - def test(): | ||
| 140 | - p = Point() | ||
| 141 | - | ||
| 142 | - self.assertRaises(TypeError, test) | ||
| 139 | + p = Point() | ||
| 140 | + self.assertTrue(p.X == 0) | ||
| 141 | + self.assertTrue(p.Y == 0) | ||
| 143 | 142 | ||
| 144 | 143 | p = Point(0, 0) | |
| 145 | 144 | self.assertTrue(p.X == 0) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments