Skip to content

CI validation only (do not merge): win32 COM0 device path - #1

Open
JPHutchins wants to merge 1 commit into
masterfrom
fix-win32-com0-device-path
Open

CI validation only (do not merge): win32 COM0 device path#1
JPHutchins wants to merge 1 commit into
masterfrom
fix-win32-com0-device-path

Conversation

@JPHutchins

Copy link
Copy Markdown
Collaborator

Temporary PR opened only to run the test workflow on the windows-2025 runner, since CI on the upstream PR (pyserial#871) is gated behind maintainer approval. Not for merge.

@JPHutchins JPHutchins closed this Jul 29, 2026
@JPHutchins JPHutchins reopened this Jul 29, 2026
Windows resolves only the bare names COM1 through COM9 as MS-DOS device
aliases. `serial.tools.list_ports` reports a device whose `PortName` is
COM0, but `Serial("COM0")` could not open it: the "\\.\" prefix was
applied only when the port number was greater than 8, so the bare name
was resolved as an ordinary relative file system path instead.

Prefix every COM port that Windows has no alias for, which also covers
the zero padded COM00 and COM01 spellings. COM1 through COM9 keep using
the MS-DOS device name, so no assumption is made about how well older
Windows versions accept a prefixed legacy name. Requiring COM followed
by decimal digits preserves the pass through for names such as
COMnotanumber without an `int()` call and its ValueError guard.

Extracting the rule as `device_path()` makes it testable without a
serial port.

Fixes pyserial#870

Co-Authored-By: claude-opus-5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant