Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7e7cbca

Browse files
authored
Disable implicit conversion from PyFloat to uint64 (#1362)
1 parent5fd77b1 commit7e7cbca

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

‎src/runtime/converter.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -698,19 +698,10 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
698698

699699
caseTypeCode.UInt64:
700700
{
701-
op=value;
702-
if(Runtime.PyObject_TYPE(value)!=Runtime.PyLongType)
703-
{
704-
op=Runtime.PyNumber_Long(value);
705-
if(op==IntPtr.Zero)
706-
{
707-
gotoconvert_error;
708-
}
709-
}
710-
ulongnum=Runtime.PyLong_AsUnsignedLongLong(op);
701+
ulongnum=Runtime.PyLong_AsUnsignedLongLong(value);
711702
if(num==ulong.MaxValue&&Exceptions.ErrorOccurred())
712703
{
713-
gotooverflow;
704+
gotoconvert_error;
714705
}
715706
result=num;
716707
returntrue;

‎src/tests/test_conversion.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,10 @@ def test_uint64_conversion():
382382
ob.UInt64Field=System.UInt64(0)
383383
assertob.UInt64Field==0
384384

385-
withpytest.raises(ValueError):
385+
withpytest.raises(TypeError):
386+
ConversionTest().UInt64Field=0.5
387+
388+
withpytest.raises(TypeError):
386389
ConversionTest().UInt64Field="spam"
387390

388391
withpytest.raises(TypeError):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp