Skip to content

Commit 2540de6

Browse files
committed
Use TryToInt for integer conversion
1 parent b4227ff commit 2540de6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/core/IronPython.Modules/termios.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ static byte GetControlChar(object? o) {
494494
}
495495

496496
static ulong ToUInt64(object? o)
497-
=> PythonOps.TryToIndex(o, out BigInteger index)
497+
=> PythonOps.TryToInt(o, out BigInteger index)
498498
? (ulong)index
499499
: throw PythonOps.TypeErrorForBadInstance("tcsetattr: an integer is required (got type {0})", o);
500500
}
@@ -581,7 +581,7 @@ public static object tcgetwinsize(CodeContext context, int fd) {
581581

582582
object result = PythonFcntl.ioctl(fd, TIOCGWINSZ, buf, mutate_flag: true);
583583

584-
if (ToTermiosError(context, result) is object ex) {
584+
if (ToTermiosError(context, result) is not null and var ex) {
585585
return ex;
586586
}
587587
return PythonTuple.MakeTuple((int)ws[0], (int)ws[1]);
@@ -607,7 +607,7 @@ public static object tcgetwinsize(CodeContext context, int fd) {
607607
var buf = new MemoryBufferProtocolWrapper<ushort>(ws.AsMemory());
608608

609609
object result = PythonFcntl.ioctl(fd, TIOCGWINSZ, buf, mutate_flag: true);
610-
if (ToTermiosError(context, result) is object ex) {
610+
if (ToTermiosError(context, result) is not null and var ex) {
611611
return ex;
612612
}
613613

@@ -618,7 +618,7 @@ public static object tcgetwinsize(CodeContext context, int fd) {
618618
}
619619

620620
result = PythonFcntl.ioctl(fd, TIOCSWINSZ, buf);
621-
if (ToTermiosError(context, result) is object ex2) {
621+
if (ToTermiosError(context, result) is not null and var ex2) {
622622
return ex2;
623623
}
624624

0 commit comments

Comments
 (0)