Skip to content

Commit 382c4d6

Browse files
authored
Merge branch 'master' into string-marshaling-cache
2 parents 0df879e + e0f47ba commit 382c4d6

19 files changed

+138
-64
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
2727

2828
### Changed
2929

30+
- Reattach python exception traceback information (#545)
31+
- PythonEngine.Intialize will now call `Py_InitializeEx` with a default value of 0, so signals will not be configured by default on embedding. This is different from the previous behaviour, where `Py_Initialize` was called instead, which sets initSigs to 1. ([#449][i449])
32+
3033
### Fixed
3134

3235
- Fixed secondary PythonEngine.Initialize call, all sensitive static variables now reseted.
@@ -46,6 +49,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
4649
- Fixed errors breaking .NET Remoting on method invoke ([#276][i276])
4750
- Fixed PyObject.GetHashCode ([#676][i676])
4851
- Fix memory leaks due to spurious handle incrementation ([#691][i691])
52+
- Fix spurious assembly loading exceptions from private types ([#703][i703])
4953
- Fix inheritance of non-abstract base methods ([#755][i755])
5054

5155

@@ -699,4 +703,5 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
699703
[i131]: https://github.com/pythonnet/pythonnet/issues/131
700704
[p531]: https://github.com/pythonnet/pythonnet/pull/531
701705
[i755]: https://github.com/pythonnet/pythonnet/pull/755
702-
[p534]: https://github.com/pythonnet/pythonnet/pull/534
706+
[p534]: https://github.com/pythonnet/pythonnet/pull/534
707+
[i449]: https://github.com/pythonnet/pythonnet/issues/449

NuGet.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
33
<packageSources>
44
<add key="dot-net MyGet Feed" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" protocolVersion="3"/>

pythonnet.sln

+37-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Microsoft Visual Studio Solution File, Format Version 12.00
2-
# Visual Studio 14
3-
VisualStudioVersion = 14.0.25420.1
2+
# Visual Studio 15
3+
VisualStudioVersion = 15.0.28010.2046
44
MinimumVisualStudioVersion = 10.0.40219.1
55
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Python.Runtime", "src\runtime\Python.Runtime.csproj", "{097B4AC0-74E9-4C58-BCF8-C69746EC8271}"
66
EndProject
@@ -32,38 +32,38 @@ Global
3232
ReleaseWinPY3|x86 = ReleaseWinPY3|x86
3333
EndGlobalSection
3434
GlobalSection(ProjectConfigurationPlatforms) = postSolution
35-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.ActiveCfg = DebugMono|x64
36-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.Build.0 = DebugMono|x64
37-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.ActiveCfg = DebugMono|x86
38-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.Build.0 = DebugMono|x86
39-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|x64
40-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|x64
41-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|x86
42-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|x86
43-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.ActiveCfg = DebugWin|x64
44-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.Build.0 = DebugWin|x64
45-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.ActiveCfg = DebugWin|x86
46-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.Build.0 = DebugWin|x86
47-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|x64
48-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.Build.0 = DebugWinPY3|x64
49-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|x86
50-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.Build.0 = DebugWinPY3|x86
51-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.ActiveCfg = ReleaseMono|x64
52-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.Build.0 = ReleaseMono|x64
53-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.ActiveCfg = ReleaseMono|x86
54-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.Build.0 = ReleaseMono|x86
55-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|x64
56-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|x64
57-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|x86
58-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|x86
59-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.ActiveCfg = ReleaseWin|x64
60-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.Build.0 = ReleaseWin|x64
61-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.ActiveCfg = ReleaseWin|x86
62-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.Build.0 = ReleaseWin|x86
63-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|x64
64-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|x64
65-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|x86
66-
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|x86
35+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.ActiveCfg = DebugMono|Any CPU
36+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x64.Build.0 = DebugMono|Any CPU
37+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.ActiveCfg = DebugMono|Any CPU
38+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMono|x86.Build.0 = DebugMono|Any CPU
39+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.ActiveCfg = DebugMonoPY3|Any CPU
40+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x64.Build.0 = DebugMonoPY3|Any CPU
41+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.ActiveCfg = DebugMonoPY3|Any CPU
42+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugMonoPY3|x86.Build.0 = DebugMonoPY3|Any CPU
43+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.ActiveCfg = DebugWin|Any CPU
44+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x64.Build.0 = DebugWin|Any CPU
45+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.ActiveCfg = DebugWin|Any CPU
46+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWin|x86.Build.0 = DebugWin|Any CPU
47+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.ActiveCfg = DebugWinPY3|Any CPU
48+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x64.Build.0 = DebugWinPY3|Any CPU
49+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.ActiveCfg = DebugWinPY3|Any CPU
50+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.DebugWinPY3|x86.Build.0 = DebugWinPY3|Any CPU
51+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.ActiveCfg = ReleaseMono|Any CPU
52+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x64.Build.0 = ReleaseMono|Any CPU
53+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.ActiveCfg = ReleaseMono|Any CPU
54+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMono|x86.Build.0 = ReleaseMono|Any CPU
55+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.ActiveCfg = ReleaseMonoPY3|Any CPU
56+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x64.Build.0 = ReleaseMonoPY3|Any CPU
57+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.ActiveCfg = ReleaseMonoPY3|Any CPU
58+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseMonoPY3|x86.Build.0 = ReleaseMonoPY3|Any CPU
59+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.ActiveCfg = ReleaseWin|Any CPU
60+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x64.Build.0 = ReleaseWin|Any CPU
61+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.ActiveCfg = ReleaseWin|Any CPU
62+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWin|x86.Build.0 = ReleaseWin|Any CPU
63+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.ActiveCfg = ReleaseWinPY3|Any CPU
64+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x64.Build.0 = ReleaseWinPY3|Any CPU
65+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.ActiveCfg = ReleaseWinPY3|Any CPU
66+
{097B4AC0-74E9-4C58-BCF8-C69746EC8271}.ReleaseWinPY3|x86.Build.0 = ReleaseWinPY3|Any CPU
6767
{6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.ActiveCfg = DebugMono|x64
6868
{6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x64.Build.0 = DebugMono|x64
6969
{6F401A34-273B-450F-9A4C-13550BE0767B}.DebugMono|x86.ActiveCfg = DebugMono|x86
@@ -188,6 +188,9 @@ Global
188188
GlobalSection(SolutionProperties) = preSolution
189189
HideSolutionNode = FALSE
190190
EndGlobalSection
191+
GlobalSection(ExtensibilityGlobals) = postSolution
192+
SolutionGuid = {10AE1870-1175-445A-B23A-C83497EAAE4B}
193+
EndGlobalSection
191194
GlobalSection(MonoDevelopProperties) = preSolution
192195
StartupItem = src\console\Console.csproj
193196
Policies = $0

src/embed_tests/Python.EmbeddingTest.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

src/embed_tests/TestConverter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using NUnit.Framework;
1+
using NUnit.Framework;
22
using Python.Runtime;
33

44
namespace Python.EmbeddingTest

src/embed_tests/TestNamedArguments.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using NUnit.Framework;
33
using Python.Runtime;
44

src/embed_tests/TestPyObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using NUnit.Framework;

src/embed_tests/TestPyWith.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using NUnit.Framework;
33
using Python.Runtime;
44

src/embed_tests/dynamic.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ public void PassPyObjectInNet()
128128
sys.testattr2 = sys.testattr1;
129129

130130
// Compare in Python
131-
PyObject res = PythonEngine.RunString(
131+
PythonEngine.RunSimpleString(
132132
"import sys\n" +
133133
"sys.testattr3 = sys.testattr1 is sys.testattr2\n"
134134
);
135+
135136
Assert.AreEqual(sys.testattr3.ToString(), "True");
136137

137138
// Compare in .NET

src/runtime/Python.Runtime.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

src/runtime/Util.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33

44
namespace Python.Runtime

src/runtime/assemblymanager.cs

+32-7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Diagnostics;
66
using System.IO;
7+
using System.Linq;
78
using System.Reflection;
89
using System.Threading;
910

@@ -349,9 +350,7 @@ internal static void ScanAssembly(Assembly assembly)
349350
// A couple of things we want to do here: first, we want to
350351
// gather a list of all of the namespaces contributed to by
351352
// the assembly.
352-
353-
Type[] types = assembly.GetTypes();
354-
foreach (Type t in types)
353+
foreach (Type t in GetTypes(assembly))
355354
{
356355
string ns = t.Namespace ?? "";
357356
if (!namespaces.ContainsKey(ns))
@@ -425,10 +424,9 @@ public static List<string> GetNames(string nsname)
425424
{
426425
foreach (Assembly a in namespaces[nsname].Keys)
427426
{
428-
Type[] types = a.GetTypes();
429-
foreach (Type t in types)
427+
foreach (Type t in GetTypes(a))
430428
{
431-
if ((t.Namespace ?? "") == nsname)
429+
if ((t.Namespace ?? "") == nsname && !t.IsNested)
432430
{
433431
names.Add(t.Name);
434432
}
@@ -467,5 +465,32 @@ public static Type LookupType(string qname)
467465
}
468466
return null;
469467
}
468+
469+
internal static Type[] GetTypes(Assembly a)
470+
{
471+
if (a.IsDynamic)
472+
{
473+
try
474+
{
475+
return a.GetTypes();
476+
}
477+
catch (ReflectionTypeLoadException exc)
478+
{
479+
// Return all types that were successfully loaded
480+
return exc.Types.Where(x => x != null).ToArray();
481+
}
482+
}
483+
else
484+
{
485+
try
486+
{
487+
return a.GetExportedTypes();
488+
}
489+
catch (FileNotFoundException)
490+
{
491+
return new Type[0];
492+
}
493+
}
494+
}
470495
}
471-
}
496+
}

src/runtime/clrobject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Runtime.InteropServices;
33

44
namespace Python.Runtime

src/runtime/debughelper.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ internal static void debug(string msg)
116116
Console.WriteLine(" {0}", msg);
117117
}
118118

119-
/// <summary>
119+
/// <summary>
120120
/// Helper function to inspect/compare managed to native conversions.
121-
/// Especially useful when debugging CustomMarshaler.
122-
/// </summary>
121+
/// Especially useful when debugging CustomMarshaler.
122+
/// </summary>
123123
/// <param name="bytes"></param>
124124
[Conditional("DEBUG")]
125125
public static void PrintHexBytes(byte[] bytes)

src/runtime/exceptions.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ public static void SetError(Exception e)
256256
var pe = e as PythonException;
257257
if (pe != null)
258258
{
259-
Runtime.PyErr_SetObject(pe.PyType, pe.PyValue);
259+
Runtime.XIncref(pe.PyType);
260+
Runtime.XIncref(pe.PyValue);
261+
Runtime.XIncref(pe.PyTB);
262+
Runtime.PyErr_Restore(pe.PyType, pe.PyValue, pe.PyTB);
260263
return;
261264
}
262265

src/runtime/pythonengine.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -140,9 +140,9 @@ public static void Initialize()
140140
Initialize(setSysArgv: true);
141141
}
142142

143-
public static void Initialize(bool setSysArgv = true)
143+
public static void Initialize(bool setSysArgv = true, bool initSigs = false)
144144
{
145-
Initialize(Enumerable.Empty<string>(), setSysArgv: setSysArgv);
145+
Initialize(Enumerable.Empty<string>(), setSysArgv: setSysArgv, initSigs: initSigs);
146146
}
147147

148148
/// <summary>
@@ -153,8 +153,9 @@ public static void Initialize(bool setSysArgv = true)
153153
/// more than once, though initialization will only happen on the
154154
/// first call. It is *not* necessary to hold the Python global
155155
/// interpreter lock (GIL) to call this method.
156+
/// initSigs can be set to 1 to do default python signal configuration. This will override the way signals are handled by the application.
156157
/// </remarks>
157-
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
158+
public static void Initialize(IEnumerable<string> args, bool setSysArgv = true, bool initSigs = false)
158159
{
159160
if (!initialized)
160161
{
@@ -164,7 +165,7 @@ public static void Initialize(IEnumerable<string> args, bool setSysArgv = true)
164165
// during an initial "import clr", and the world ends shortly thereafter.
165166
// This is probably masking some bad mojo happening somewhere in Runtime.Initialize().
166167
delegateManager = new DelegateManager();
167-
Runtime.Initialize();
168+
Runtime.Initialize(initSigs);
168169
initialized = true;
169170
Exceptions.Clear();
170171

src/runtime/runtime.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,11 @@ public enum MachineType
275275
/// <summary>
276276
/// Initialize the runtime...
277277
/// </summary>
278-
internal static void Initialize()
278+
internal static void Initialize(bool initSigs = false)
279279
{
280280
if (Py_IsInitialized() == 0)
281281
{
282-
Py_Initialize();
282+
Py_InitializeEx(initSigs ? 1 : 0);
283283
}
284284

285285
if (PyEval_ThreadsInitialized() == 0)
@@ -733,6 +733,9 @@ internal static unsafe long Refcount(IntPtr op)
733733
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
734734
internal static extern void Py_Initialize();
735735

736+
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
737+
internal static extern void Py_InitializeEx(int initsigs);
738+
736739
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
737740
internal static extern int Py_IsInitialized();
738741

src/testing/Python.Test.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?xml version="1.0" encoding="utf-8"?>
1+
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

src/tests/test_subclass.py

+33
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,39 @@ def test_derived_class():
128128
assert id(x) == id(ob)
129129

130130

131+
def test_derived_traceback():
132+
"""Test python exception traceback in class derived from managed base"""
133+
class DerivedClass(SubClassTest):
134+
__namespace__ = "Python.Test.traceback"
135+
136+
def foo(self):
137+
print (xyzname)
138+
return None
139+
140+
import sys,traceback
141+
ob = DerivedClass()
142+
143+
# direct call
144+
try:
145+
ob.foo()
146+
assert False
147+
except:
148+
e = sys.exc_info()
149+
assert "xyzname" in str(e[1])
150+
location = traceback.extract_tb(e[2])[-1]
151+
assert location[2] == "foo"
152+
153+
# call through managed code
154+
try:
155+
FunctionsTest.test_foo(ob)
156+
assert False
157+
except:
158+
e = sys.exc_info()
159+
assert "xyzname" in str(e[1])
160+
location = traceback.extract_tb(e[2])[-1]
161+
assert location[2] == "foo"
162+
163+
131164
def test_create_instance():
132165
"""Test derived instances can be created from managed code"""
133166
DerivedClass = derived_class_fixture(test_create_instance.__name__)

0 commit comments

Comments
 (0)