8000 Fix in dotnet code path: find mmap in libc rather than __Internal · pythonnet/pythonnet@4096a95 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4096a95

Browse files
author
Benoit Hudson
committed
Fix in dotnet code path: find mmap in libc rather than __Internal
When run with mono or in visual studio, DllImport("__Internal", ...) works; but when run via dotnet, it fails to load the library somehow. mmap is in libc, so get it that way now. Exceptions thrown in NUnit setup/teardown get silently swallowed, so I also added try/catch to dynamic.cs to help debug future initialization exceptions.
1 parent c0b52fa commit 4096a95

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/embed_tests/dynamic.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,23 @@ public class DynamicTest
1212
[SetUp]
1313
public void SetUp()
1414
{
15-
_gs = Py.GIL();
15+
try {
16+
_gs = Py.GIL();
17+
} catch (Exception e) {
18+
Console.WriteLine($"exception in SetUp: {e}");
19+
throw;
20+
}
1621
}
1722

1823
[TearDown]
1924
public void Dispose()
2025
{
21-
_gs.Dispose();
26+
try {
27+
_gs.Dispose();
28+
} catch(Exception e) {
29+
Console.WriteLine($"exception in TearDown: {e}");
30+
throw;
31+
}
2232
}
2333

2434
/// <summary>

src/runtime/typemanager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ int MAP_ANONYMOUS
609609
}
610610
}
611611

612-
[DllImport("__Internal")]
612+
[DllImport("libc")]
613613
static extern IntPtr mmap(IntPtr addr, IntPtr len, int prot, int flags, int fd, IntPtr offset);
614614

615-
[DllImport("__Internal")]
615+
[DllImport("libc")]
616616
static extern int mprotect(IntPtr addr, IntPtr len, int prot);
617617

618618
public IntPtr MapWriteable(int numBytes)

0 commit comments

Comments
 (0)
0