| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dd3302a commit ad0d4e7
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,5 @@ | |||
| 1 | 1 | using System; | |
| 2 | + using System.Collections.Generic; | ||
| 2 | 3 | using System.Text; | |
| 3 | 4 | using NUnit.Framework; | |
| 4 | 5 | using Python.Runtime; | |
@@ -126,5 +127,15 @@ public void PassPyObjectInNet() | |||
| 126 | 127 | // Compare in .NET | |
| 127 | 128 | Assert.IsTrue(sys.testattr1.Equals(sys.testattr2)); | |
| 128 | 129 | } | |
| 130 | + | ||
| 131 | + // regression test for https://github.com/pythonnet/pythonnet/issues/1680 | ||
| 132 | + [Test] | ||
| 133 | + public void ForEach() | ||
| 134 | + { | ||
| 135 | + dynamic pyList = PythonEngine.Eval("[1,2,3]"); | ||
| 136 | + var list = new List<int>(); | ||
| 137 | + foreach (int item in pyList) | ||
| 138 | + list.Add(item); | ||
| 139 | + } | ||
| 129 | 140 | } | |
| 130 | 141 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1296,6 +1296,12 @@ public override bool TryConvert(ConvertBinder binder, out object? result) | |||
| 1296 | 1296 | return converted; | |
| 1297 | 1297 | } | |
| 1298 | 1298 | ||
| 1299 | + if (binder.Type == typeof(System.Collections.IEnumerable) && this.IsIterable()) | ||
| 1300 | + { | ||
| 1301 | + result = new PyIterable(this.Reference); | ||
| 1302 | + return true; | ||
| 1303 | + } | ||
| 1304 | + | ||
| 1299 | 1305 | return false; | |
| 1300 | 1306 | } | |
| 1301 | 1307 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments