8000 PyObject.Length no longer returns 0 when it is impossible to determin… · losttech/pythonnet@ad7f83b · GitHub
[go: up one dir, main page]

Skip to content

Commit ad7f83b

Browse files
committed
PyObject.Length no longer returns 0 when it is impossible to determine length
1 parent ef72455 commit ad7f83b

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/runtime/pyobject.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -657,19 +657,14 @@ public virtual void DelItem(int index)
657657
/// <summary>
658658
/// Length Method
659659
/// </summary>
660-
/// <remarks>
661-
/// Returns the length for objects that support the Python sequence
662-
/// protocol, or 0 if the object does not support the protocol.
663-
/// </remarks>
664660
public virtual long Length()
665661
{
666662
DebugUtil.EnsureGIL();
667663

668664
var s = Runtime.PyObject_Size(obj);
669665
if (s < 0)
670666
{
671-
Runtime.PyErr_Clear();
672-
return 0;
667+
throw PythonException.ThrowLastAsClrException();
673668
}
674669
return s;
675670
}

0 commit comments

Comments
 (0)
0