8000 Fixed comment and removed \r from added source · pythonnet/pythonnet@335cd37 · GitHub
[go: up one dir, main page]

Skip to content

Commit 335cd37

Browse files
committed
Fixed comment and removed \r from added source
1 parent d5951f6 commit 335cd37

File tree

3 files changed

+38
-28
lines changed

3 files changed

+38
-28
lines changed

src/runtime/converter.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,11 @@ internal static IntPtr ToPython<T>(T value)
126126

127127
internal static IntPtr ToPython(Object value, Type type)
128128
{
129-
if(value is PyObject)
130-
{
131-
IntPtr handle = ((PyObject)value).Handle;
132-
Runtime.XIncref(handle);
133-
return handle;
129+
if(value is PyObject)
130+
{
131+
IntPtr handle = ((PyObject)value).Handle;
132+
Runtime.XIncref(handle);
133+
return handle;
134134
}
135135
IntPtr result = IntPtr.Zero;
136136

@@ -271,15 +271,15 @@ internal static bool ToManaged(IntPtr value, Type type,
271271
internal static bool ToManagedValue(IntPtr value, Type obType,
272272
out Object result, bool setError)
273273
{
274-
if (obType == typeof(PyObject))
275-
{
276-
Runtime.XIncref(value); // PyObject() assumes ownership
277-
result = new PyObject(value);
278-
return true;
279-
}
280-
281-
// Common case: if the Python value is a wrapped managed object
282-
// instance, just return the wrapped object.
274+
if (obType == typeof(PyObject))
275+
{
276+
Runtime.XIncref(value); // PyObject() assumes ownership
277+
result = new PyObject(value);
278+
return true;
279+
}
280+
281+
// Common case: if the Python value is a wrapped managed object
282+
// instance, just return the wrapped object.
283283
ManagedType mt = ManagedType.GetManagedObject(value);
284284
result = null;
285285

src/runtime/pyobject.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ protected virtual void Dispose(bool disposing)
127127
}
128128
}
129129

130+
public long RefCount
131+
{
132+
get
133+
{
134+
if(!disposed)
135+
return Runtime.Refcount(obj);
136+
return -1;
137+
}
138+
}
139+
130140
public void Dispose()
131141
{
132142
Dispose(true);

src/testing/callbacktest.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public string Call_simpleDefaultArg_WithEmptyArgs(string moduleName)
2727
return module.simpleDefaultArg();
2828
}
2929
}
30-
}
31-
32-
//==========================================================================
33-
// Tests calling from Python into C# and back into Python using a PyObject.
34-
// SelfCallbackTest should be inherited from a Python class.
35-
// Used in test_class.py / testCallback
36-
//==========================================================================
37-
public class SelfCallbackTest
38-
{
39-
public void Callback(Runtime.PyObject self)
40-
{
41-
using (Runtime.Py.GIL())
42-
((dynamic)self).PyCallback(self);
43-
}
30+
}
31+
32+
//==========================================================================
33+
// Tests calling from Python into C# and back into Python using a PyObject.
34+
// SelfCallbackTest should be inherited by a Python class.
35+
// Used in test_class.py / testCallback
36+
//==========================================================================
37+
public class SelfCallbackTest
38+
{
39+
public void Callback(Runtime.PyObject self)
40+
{
41+
using (Runtime.Py.GIL())
42+
((dynamic)self).PyCallback(self);
43+
}
4444
}
4545
}

0 commit comments

Comments
 (0)
0