| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,12 +14,14 @@ public T this[int index] | |||
| 14 | 14 | { | |
| 15 | 15 | get | |
| 16 | 16 | { | |
| 17 | + using var _ = Py.GIL(); | ||
| 17 | 18 | var item = Runtime.PyList_GetItem(pyObject, index); | |
| 18 | 19 | var pyItem = new PyObject(item); | |
| 19 | 20 | return pyItem.As<T>()!; | |
| 20 | 21 | } | |
| 21 | 22 | set | |
| 22 | 23 | { | |
| 24 | + using var _ = Py.GIL(); | ||
| 23 | 25 | var pyItem = value.ToPython(); | |
| 24 | 26 | var result = Runtime.PyList_SetItem(pyObject, index, new NewReference(pyItem).Steal()); | |
| 25 | 27 | if (result == -1) | |
@@ -37,6 +39,7 @@ public void Insert(int index, T item) | |||
| 37 | 39 | if (IsReadOnly) | |
| 38 | 40 | throw new InvalidOperationException("Collection is read-only"); | |
| 39 | 41 | ||
| 42 | + using var _ = Py.GIL(); | ||
| 40 | 43 | var pyItem = item.ToPython(); | |
| 41 | 44 | ||
| 42 | 45 | int result = Runtime.PyList_Insert(pyObject, index, pyItem); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,10 +14,14 @@ public int Count | |||
| 14 | 14 | { | |
| 15 | 15 | get | |
| 16 | 16 | { | |
| 17 | - var size = Runtime.PySequence_Size(pyObject.Reference); | ||
| 18 | - if (size == -1) | ||
| 17 | + nint size = -1; | ||
| 19 | 18 | { | |
| 20 | - Runtime.CheckExceptionOccurred(); | ||
| 19 | + using var _ = Py.GIL(); | ||
| 20 | + size = Runtime.PySequence_Size(pyObject.Reference); | ||
| 21 | + if (size == -1) | ||
| 22 | + { | ||
| 23 | + Runtime.CheckExceptionOccurred(); | ||
| 24 | + } | ||
| 21 | 25 | } | |
| 22 | 26 | ||
| 23 | 27 | return checked((int)size); | |
@@ -38,6 +42,7 @@ public void Clear() | |||
| 38 | 42 | { | |
| 39 | 43 | if (IsReadOnly) | |
| 40 | 44 | throw new NotImplementedException(); | |
| 45 | + using var _ = Py.GIL(); | ||
| 41 | 46 | int result = Runtime.PySequence_DelSlice(pyObject, 0, Count); | |
| 42 | 47 | if (result == -1) | |
| 43 | 48 | { | |
@@ -77,12 +82,16 @@ protected bool removeAt(int index) | |||
| 77 | 82 | if (index >= Count || index < 0) | |
| 78 | 83 | return false; | |
| 79 | 84 | ||
| 80 | - int result = Runtime.PySequence_DelItem(pyObject, index); | ||
| 81 | 85 | ||
| 82 | - if (result == 0) | ||
| 83 | - return true; | ||
| 86 | + { | ||
| 87 | + using var _ = Py.GIL(); | ||
| 88 | + int result = Runtime.PySequence_DelItem(pyObject, index); | ||
| 89 | + | ||
| 90 | + if (result == 0) | ||
| 91 | + return true; | ||
| 84 | 92 | ||
| 85 | - Runtime.CheckExceptionOccurred(); | ||
| 93 | + Runtime.CheckExceptionOccurred(); | ||
| 94 | + } | ||
| 86 | 95 | return false; | |
| 87 | 96 | } | |
| 88 | 97 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,7 +59,6 @@ def test_iterable(): | |||
| 59 | 59 | assert 3 == ob.GetLength2(iterable2) | |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | - @pytest.mark.skip | ||
| 63 | 62 | def test_sequence(): | |
| 64 | 63 | Python.Runtime.Codecs.SequenceDecoder.Register() | |
| 65 | 64 | ob = ListConversionTester() | |
@@ -71,7 +70,6 @@ def test_sequence(): | |||
| 71 | 70 | assert 3 == ob.GetLength(tup2) | |
| 72 | 71 | ||
| 73 | 72 | ||
| 74 | - @pytest.mark.skip | ||
| 75 | 73 | def test_list(): | |
| 76 | 74 | Python.Runtime.Codecs.SequenceDecoder.Register() | |
| 77 | 75 | ob = ListConversionTester() | |
| Back | FazBrowse Home | New Git URL |
0 commit comments