Commit 00cb1ed
committed
Fix: Make fcntl usage conditional in mcpm share for Windows compatibility
The `fcntl` module is not available on Windows, and its direct import
was causing `ImportError` when `mcpm share` was invoked or its module
(src/mcpm/commands/share.py) was loaded on Windows systems.
This commit makes the import and usage of `fcntl` within the
`make_non_blocking` function conditional on `os.name == 'posix'`.
On non-POSIX systems (like Windows), the function will now do nothing.
The existing code for reading from subprocess pipes in `mcpm share`
utilizes `select.select()` with timeouts and handles `IOError`/`OSError`
exceptions. This setup is expected to provide sufficient non-blocking
behavior for reading subprocess output on Windows, even without an
explicit `fcntl` call to set `O_NONBLOCK`.
Note: Full dynamic testing of `mcpm share` on a Windows-like environment
was not possible due to a Python version mismatch (environment: 3.10.17,
project requires: >=3.11) in the available testing sandbox. This change
addresses the direct `ImportError`.1 parent 30ebdb0 commit 00cb1ed
File tree
1 file changed
+9
-5
lines changed- src/mcpm/commands
1 file changed
+9
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| |||
0 commit comments