Skip to content

Commit 070a7fc

Browse files
authored
Merge branch 'master' into master
2 parents c2cd097 + fb84cd2 commit 070a7fc

20 files changed

+491
-252
lines changed

.travis.yml

-7
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ matrix:
2222
- dotnet-hostfxr-2.0.0
2323
- dotnet-runtime-2.0.0
2424
- dotnet-sdk-2.0.0
25-
- python: 3.3
26-
env: *xplat-env
27-
addons: *xplat-addons
28-
2925
- python: 3.4
3026
env: *xplat-env
3127
addons: *xplat-addons
@@ -47,9 +43,6 @@ matrix:
4743
- BUILD_OPTS=
4844
- NUNIT_PATH=./packages/NUnit.*/tools/nunit3-console.exe
4945

50-
- python: 3.3
51-
env: *classic-env
52-
5346
- python: 3.4
5447
env: *classic-env
5548

AUTHORS.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
## Contributors
1414

15+
- Alexandre Catarino([@AlexCatarino](https://github.com/AlexCatarino))
1516
- Arvid JB ([@ArvidJB](https://github.com/ArvidJB))
1617
- Bradley Friedman ([@leith-bartrich](https://github.com/leith-bartrich))
1718
- Callum Noble ([@callumnoble](https://github.com/callumnoble))
@@ -28,6 +29,7 @@
2829
-   Jeff Reback ([@jreback](https://github.com/jreback))
2930
- Joe Frayne ([@jfrayne](https://github.com/jfrayne))
3031
- John Burnett ([@johnburnett](https://github.com/johnburnett))
32+
- John Wilkes ([@jbw3](https://github.com/jbw3))
3133
- Luke Stratman ([@lstratman](https://github.com/lstratman))
3234
- Konstantin Posudevskiy ([@konstantin-posudevskiy](https://github.com/konstantin-posudevskiy))
3335
- Matthias Dittrich ([@matthid](https://github.com/matthid))
@@ -40,13 +42,15 @@
4042
- Ville M. Vainio ([@vivainio](https://github.com/vivainio))
4143
- Virgil Dupras ([@hsoft](https://github.com/hsoft))
4244
- Wenguang Yang ([@yagweb](https://github.com/yagweb))
45+
- William Sardar ([@williamsardar])(https://github.com/williamsardar)
4346
- Xavier Dupré ([@sdpython](https://github.com/sdpython))
4447
- Zane Purvis ([@zanedp](https://github.com/zanedp))
4548
- ([@bltribble](https://github.com/bltribble))
49+
- ([@civilx64](https://github.com/civilx64))
50+
- ([@GSPP](https://github.com/GSPP))
4651
- ([@omnicognate](https://github.com/omnicognate))
4752
- ([@rico-chet](https://github.com/rico-chet))
4853
- ([@rmadsen-ks](https://github.com/rmadsen-ks))
4954
- ([@stonebig](https://github.com/stonebig))
5055
- ([@testrunner123](https://github.com/testrunner123))
51-
- ([@GSPP](https://github.com/GSPP))
5256

CHANGELOG.md

+181-84
Large diffs are not rendered by default.

appveyor.yml

-3
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,13 @@ environment:
1717
matrix:
1818
- PYTHON_VERSION: 2.7
1919
BUILD_OPTS: --xplat
20-
- PYTHON_VERSION: 3.3
21-
BUILD_OPTS: --xplat
2220
- PYTHON_VERSION: 3.4
2321
BUILD_OPTS: --xplat
2422
- PYTHON_VERSION: 3.5
2523
BUILD_OPTS: --xplat
2624
- PYTHON_VERSION: 3.6
2725
BUILD_OPTS: --xplat
2826
- PYTHON_VERSION: 2.7
29-
- PYTHON_VERSION: 3.3
3027
- PYTHON_VERSION: 3.4
3128
- PYTHON_VERSION: 3.5
3229
- PYTHON_VERSION: 3.6

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Requirements for both Travis and AppVeyor
22
pytest==3.2.5
33
coverage
4+
psutil
45

56
# Coverage upload
67
codecov

src/embed_tests/Python.EmbeddingTest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
<Compile Include="TestPyList.cs" />
9494
<Compile Include="TestPyLong.cs" />
9595
<Compile Include="TestPyNumber.cs" />
96+
<Compile Include="TestPyObject.cs" />
9697
<Compile Include="TestPySequence.cs" />
9798
<Compile Include="TestPyString.cs" />
9899
<Compile Include="TestPythonException.cs" />

src/embed_tests/TestPyObject.cs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using NUnit.Framework;
5+
using Python.Runtime;
6+
7+
namespace Python.EmbeddingTest
8+
{
9+
public class TestPyObject
10+
{
11+
[OneTimeSetUp]
12+
public void SetUp()
13+
{
14+
PythonEngine.Initialize();
15+
}
16+
17+
[OneTimeTearDown]
18+
public void Dispose()
19+
{
20+
PythonEngine.Shutdown();
21+
}
22+
23+
[Test]
24+
public void TestGetDynamicMemberNames()
25+
{
26+
List<string> expectedMemberNames = new List<string>
27+
{
28+
"add",
29+
"getNumber",
30+
"member1",
31+
"member2"
32+
};
33+
34+
PyDict locals = new PyDict();
35+
36+
PythonEngine.Exec(@"
37+
class MemberNamesTest(object):
38+
def __init__(self):
39+
self.member1 = 123
40+
self.member2 = 'Test string'
41+
42+
def getNumber(self):
43+
return 123
44+
45+
def add(self, x, y):
46+
return x + y
47+
48+
a = MemberNamesTest()
49+
", null, locals.Handle);
50+
51+
PyObject a = locals.GetItem("a");
52+
53+
IEnumerable<string> memberNames = a.GetDynamicMemberNames();
54+
55+
foreach (string expectedName in expectedMemberNames)
56+
{
57+
Assert.IsTrue(memberNames.Contains(expectedName), "Could not find member '{0}'.", expectedName);
58+
}
59+
}
60+
}
61+
}

src/runtime/Python.Runtime.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@
145145
</ItemGroup>
146146
<ItemGroup Condition=" '$(PythonInteropFile)' == '' ">
147147
<Compile Include="interop27.cs" />
148-
<Compile Include="interop33.cs" />
149148
<Compile Include="interop34.cs" />
150149
<Compile Include="interop35.cs" />
151150
<Compile Include="interop36.cs" />

src/runtime/constructorbinding.cs

+1-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static IntPtr tp_descr_get(IntPtr op, IntPtr instance, IntPtr owner)
7575
return Exceptions.RaiseTypeError("How in the world could that happen!");
7676
}
7777
}*/
78-
Runtime.XIncref(self.pyHandle); // Decref'd by the interpreter.
78+
Runtime.XIncref(self.pyHandle);
7979
return self.pyHandle;
8080
}
8181

@@ -105,8 +105,6 @@ public static IntPtr mp_subscript(IntPtr op, IntPtr key)
105105
}
106106
var boundCtor = new BoundContructor(self.type, self.pyTypeHndl, self.ctorBinder, ci);
107107

108-
/* Since nothing is cached, do we need the increment???
109-
Runtime.XIncref(boundCtor.pyHandle); // Decref'd by the interpreter??? */
110108
return boundCtor.pyHandle;
111109
}
112110

src/runtime/interop33.cs

-143
This file was deleted.

src/runtime/iterator.cs

+14-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@ public Iterator(IEnumerator e)
2323
public static IntPtr tp_iternext(IntPtr ob)
2424
{
2525
var self = GetManagedObject(ob) as Iterator;
26-
if (!self.iter.MoveNext())
26+
try
2727
{
28-
Exceptions.SetError(Exceptions.StopIteration, Runtime.PyNone);
28+
if (!self.iter.MoveNext())
29+
{
30+
Exceptions.SetError(Exceptions.StopIteration, Runtime.PyNone);
31+
return IntPtr.Zero;
32+
}
33+
}
34+
catch (Exception e)
35+
{
36+
if (e.InnerException != null)
37+
{
38+
e = e.InnerException;
39+
}
40+
Exceptions.SetError(e);
2941
return IntPtr.Zero;
3042
}
3143
object item = self.iter.Current;

src/runtime/methodbinder.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,12 @@ internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase i
507507

508508
if (binding == null)
509509
{
510-
Exceptions.SetError(Exceptions.TypeError, "No method matches given arguments");
510+
var value = "No method matches given arguments";
511+
if (methodinfo != null && methodinfo.Length > 0)
512+
{
513+
value += $" for {methodinfo[0].Name}";
514+
}
515+
Exceptions.SetError(Exceptions.TypeError, value);
511516
return IntPtr.Zero;
512517
}
513518

src/runtime/methodbinding.cs

-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public static IntPtr mp_subscript(IntPtr tp, IntPtr idx)
5656
}
5757

5858
var mb = new MethodBinding(self.m, self.target) { info = mi };
59-
Runtime.XIncref(mb.pyHandle);
6059
return mb.pyHandle;
6160
}
6261

@@ -85,7 +84,6 @@ public static IntPtr tp_getattro(IntPtr ob, IntPtr key)
8584
case "__overloads__":
8685
case "Overloads":
8786
var om = new OverloadMapper(self.m, self.target);
88-
Runtime.XIncref(om.pyHandle);
8987
return om.pyHandle;
9088
default:
9189
return Runtime.PyObject_GenericGetAttr(ob, key);

src/runtime/overload.cs

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public static IntPtr mp_subscript(IntPtr tp, IntPtr idx)
4444
}
4545

4646
var mb = new MethodBinding(self.m, self.target) { info = mi };
47-
Runtime.XIncref(mb.pyHandle);
4847
return mb.pyHandle;
4948
}
5049

0 commit comments

Comments
 (0)