Commit d39f9f6
Fix conversion of 'float' and 'double' values (pythonnet#487)
* Fix conversion of 'float' and 'double' values
Fix problem of conversion 'float' and 'double' values in converter.cs.
As there was a range check both for 'float' and 'double' values, which
are less or greater than its 'MinValue' and 'MaxValue' accordingly,
several values like 'float.NegativeInfinity', 'float.PositiveInfinity'
and the same 'double' values cannot be converted from Python to .NET
values.
Add error check after 'PyFloat_AsDouble' call.
Due to Python C API documentation, method 'PyFloat_AsDouble' can return
'-1.0' upon failure. So it requires error check. This rule forces to
check for error and throw exception in case of error.
Add tests, which cover problem of conversion 'float' and 'double'
values.
Resolves: pythonnet#486.
* Fix failing 'test_double_conversion' test
Fix incorrect part of 'test_double_conversion' test in test_conversion.py.
An 'OverflowError' was expected for valid values, which represent Python
'inf' and '-inf'.
The problem was identified with support of conversion for Python 'inf'
and '-inf' to .NET System.Double PositiveInfinity and NegativeInfinity.
See also: pythonnet#487.1 parent bfce5e2 commit d39f9f6
File tree
6 files changed
+58
-16
lines changed- src
- embed_tests
- runtime
- tests
6 files changed
+58
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
770 | 770 | | |
771 | 771 | | |
772 | 772 | | |
| 773 | + | |
773 | 774 | | |
774 | 775 | | |
775 | 776 | | |
776 | | - | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
777 | 781 | | |
778 | 782 | | |
779 | 783 | | |
| |||
785 | 789 | | |
786 | 790 | | |
787 | 791 | | |
| 792 | + | |
788 | 793 | | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | 794 | | |
794 | 795 | | |
795 | 796 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | 469 | | |
481 | 470 | | |
482 | 471 | | |
| |||
0 commit comments