Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 44bfec2

Browse files
authored
Merge branch 'master' into PR/Codecs
2 parents 2e19f2c + a424998 commit 44bfec2

File tree

6 files changed

+35
-6
lines changed

6 files changed

+35
-6
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Alex Earl ([@slide](https://github.com/slide))
1616
- Alex Helms ([@alexhelms](https://github.com/alexhelms))
1717
- Alexandre Catarino([@AlexCatarino](https://github.com/AlexCatarino))
18+
- Andrey Sant'Anna ([@andreydani](https://github.com/andreydani))
1819
- Arvid JB ([@ArvidJB](https://github.com/ArvidJB))
1920
- Benoît Hudson ([@benoithudson](https://github.com/benoithudson))
2021
- Bradley Friedman ([@leith-bartrich](https://github.com/leith-bartrich))

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][].
2929
together with Nuitka
3030
- Fixes bug where delegates get casts (dotnetcore)
3131
- Determine size of interpreter longs at runtime
32+
- Handling exceptions ocurred in ModuleObject's getattribute
3233

3334
## [2.4.0][]
3435

src/perf_tests/BaselineComparisonConfig.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
using BenchmarkDotNet.Configs;
77
using BenchmarkDotNet.Jobs;
8+
using BenchmarkDotNet.Horology;
89

910
namespace Python.PerformanceTests
1011
{
@@ -18,7 +19,11 @@ public BaselineComparisonConfig()
1819

1920
string deploymentRoot = BenchmarkTests.DeploymentRoot;
2021

21-
var baseJob = Job.Default;
22+
var baseJob = Job.Default
23+
.WithLaunchCount(1)
24+
.WithWarmupCount(3)
25+
.WithMaxIterationCount(100)
26+
.WithIterationTime(TimeInterval.FromMilliseconds(100));
2227
this.Add(baseJob
2328
.WithId("baseline")
2429
.WithEnvironmentVariable(EnvironmentVariableName,

src/runtime/moduleobject.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,18 @@ public static IntPtr tp_getattro(IntPtr ob, IntPtr key)
273273
return self.dict;
274274
}
275275

276-
ManagedType attr = self.GetAttribute(name, true);
276+
ManagedType attr = null;
277+
278+
try
279+
{
280+
attr = self.GetAttribute(name, true);
281+
}
282+
catch (Exception e)
283+
{
284+
Exceptions.SetError(e);
285+
return IntPtr.Zero;
286+
}
287+
277288

278289
if (attr == null)
279290
{

src/runtime/pythonexception.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class PythonException : System.Exception, IPyDisposable
2121
public PythonException()
2222
{
2323
IntPtr gs = PythonEngine.AcquireLock();
24-
Runtime.PyErr_Fetch(ref _pyType, ref _pyValue, ref _pyTB);
24+
Runtime.PyErr_Fetch(out _pyType, out _pyValue, out _pyTB);
2525
if (_pyType != IntPtr.Zero && _pyValue != IntPtr.Zero)
2626
{
2727
string type;
@@ -161,12 +161,23 @@ public void Dispose()
161161
if (Runtime.Py_IsInitialized() > 0 && !Runtime.IsFinalizing)
162162
{
163163
IntPtr gs = PythonEngine.AcquireLock();
164-
Runtime.XDecref(_pyType);
165-
Runtime.XDecref(_pyValue);
164+
if (_pyType != IntPtr.Zero)
165+
{
166+
Runtime.XDecref(_pyType);
167+
_pyType= IntPtr.Zero;
168+
}
169+
170+
if (_pyValue != IntPtr.Zero)
171+
{
172+
Runtime.XDecref(_pyValue);
173+
_pyValue = IntPtr.Zero;
174+
}
175+
166176
// XXX Do we ever get TraceBack? //
167177
if (_pyTB != IntPtr.Zero)
168178
{
169179
Runtime.XDecref(_pyTB);
180+
_pyTB = IntPtr.Zero;
170181
}
171182
PythonEngine.ReleaseLock(gs);
172183
}

src/runtime/runtime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1942,7 +1942,7 @@ internal static IntPtr PyMem_Realloc(IntPtr ptr, long size)
19421942
internal static extern IntPtr PyErr_Occurred();
19431943

19441944
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
1945-
internal static extern void PyErr_Fetch(ref IntPtr ob, ref IntPtr val, ref IntPtr tb);
1945+
internal static extern void PyErr_Fetch(out IntPtr ob, out IntPtr val, out IntPtr tb);
19461946

19471947
[DllImport(_PythonDll, CallingConvention = CallingConvention.Cdecl)]
19481948
internal static extern void PyErr_Restore(IntPtr ob, IntPtr val, IntPtr tb);

0 commit comments

Comments
 (0)