| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. | |||
| 14 | 14 | ### Fixed | |
| 15 | 15 | ||
| 16 | 16 | - Fixed objects leaking when Python attached event handlers to them even if they were later removed | |
| 17 | + - Fixed `PyInt` conversion to `BigInteger` and `System.String` produced incorrect result for values between 128 and 255. | ||
| 17 | 18 | ||
| 18 | 19 | ||
| 19 | 20 | ## [3.0.0](https://github.com/pythonnet/pythonnet/releases/tag/v3.0.0) - 2022-09-29 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -191,16 +191,23 @@ public void ToBigInteger() | |||
| 191 | 191 | { | |
| 192 | 192 | 0, 1, 2, | |
| 193 | 193 | 0x10, | |
| 194 | + 0x79, | ||
| 195 | + 0x80, | ||
| 196 | + 0x81, | ||
| 197 | + 0xFF, | ||
| 194 | 198 | 0x123, | |
| 199 | + 0x8000, | ||
| 195 | 200 | 0x1234, | |
| 201 | + 0x8001, | ||
| 202 | + 0x4000, | ||
| 203 | + 0xFF, | ||
| 196 | 204 | }; | |
| 197 | 205 | simpleValues = simpleValues.Concat(simpleValues.Select(v => -v)).ToArray(); | |
| 198 | 206 | ||
| 199 | - foreach (var val in simpleValues) | ||
| 200 | - { | ||
| 201 | - var pyInt = new PyInt(val); | ||
| 202 | - Assert.AreEqual((BigInteger)val, pyInt.ToBigInteger()); | ||
| 203 | - } | ||
| 207 | + var expected = simpleValues.Select(v => new BigInteger(v)).ToArray(); | ||
| 208 | + var actual = simpleValues.Select(v => new PyInt(v).ToBigInteger()).ToArray(); | ||
| 209 | + | ||
| 210 | + CollectionAssert.AreEqual(expected, actual); | ||
| 204 | 211 | } | |
| 205 | 212 | ||
| 206 | 213 | [Test] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,7 +212,7 @@ public BigInteger ToBigInteger() | |||
| 212 | 212 | offset++; | |
| 213 | 213 | neg = true; | |
| 214 | 214 | } | |
| 215 | - byte[] littleEndianBytes = new byte[(hex.Length - offset + 1) / 2]; | ||
| 215 | + byte[] littleEndianBytes = new byte[(hex.Length - offset + 1) / 2 + 1]; | ||
| 216 | 216 | for (; offset < hex.Length; offset++) | |
| 217 | 217 | { | |
| 218 | 218 | int littleEndianHexIndex = hex.Length - 1 - offset; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments