Repository navigation
test_ioctl fails on macOS #119770
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or errortestsTests in the Lib/test dirTests in the Lib/test dir
on May 30, 2024 Yes, the same happens for me on m2
Unfortunately, this commit breaks backward compatibility. Previously, it was allowed to pass negative values for the
requestparameter and then they were converted to positive values. However, now, due to a change in the type from unsigned int to unsigned long, this is not working.This test is strange. Why passing negative request if its type is unsigned long? The value should be positive.
test_ioctl was always skipped until recently. I fixed regrtest to test it: #119275
This test is strange. Why passing negative request if its type is unsigned long? The value should be positive.
test_ioctl was always skipped until recently. I fixed regrtest to test it: #119275
Yes, I agree with you that this is strange. Our documentation does not mention that the
ioctlrequest parameter can be negative. I think this test was broken by design.This line from the
test_ioctl_signed_unsigned_code_paramis confused me:if termios.TIOCSWINSZ < 0:Is there any chance that
TIOCSWINSZcan be negative?Is there any chance that TIOCSWINSZ can be negative?
darwin-xnu uses uint32_t with the MSB bit set:
#define IOC_IN (__uint32_t)0x80000000 #define _IOC(inout, group, num, len) \ (inout | ((len & IOCPARM_MASK) << 16) | ((group) << 8) | (num)) #define _IOW(g, n, t) _IOC(IOC_IN, (g), (n), sizeof(t)) #define TIOCSWINSZ _IOW('t', 103, struct winsize) /* set window size */
Source:
- https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ioccom.h#L85-L95
- https://github.com/apple/darwin-xnu/blob/2ff845c2e033bd0ff64b5b6aa6063a1f8f65aa32/bsd/sys/ttycom.h#L154
Python termios module stores the constant as
longintermios_constantsarray, and then create an object using PyLong_FromLong()`.The value may be negative or not depending on how C treats the integers. I would prefer to have a more reliable value.
- added 5 commits that reference this issue
on May 31, 2024 I wrote PR gh-119840 to make termios ioctl() constants positive and to update test_ioctl.
Fixed by 64ff1e2
Bug report
Bug description:
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs