qzyu999 commented on code in PR #3721:
URL: https://github.com/apache/iceberg-python/pull/3721#discussion_r3686460142


##########
pyiceberg/io/__init__.py:
##########
@@ -41,6 +42,17 @@
 
 logger = logging.getLogger(__name__)
 
+
+def _is_windows_drive_letter(scheme: str) -> bool:
+    r"""Check if a parsed URL scheme is actually a Windows drive letter.
+
+    On Windows, Python's urlparse treats paths like 'C:\\Users\\...' as having
+    scheme='c'. This detects that case so callers can route to the local 
filesystem.
+    Only returns True on Windows — no behavior change on other platforms.
+    """
+    return sys.platform == "win32" and len(scheme) == 1 and scheme.isalpha()

Review Comment:
   Good question! My understanding is that `"win32"` is sufficient here, the 
drive letter parsing bug only exists on native Windows where paths look like 
`C:\...`.
   
   The other `sys.platform` values from that SO thread don't need coverage 
because they use POSIX paths, so `urlparse` never produces a single-letter 
scheme on them:
   
   - **Cygwin** (`sys.platform == "cygwin"`) translates `C:\Users\...` to 
`/cygdrive/c/Users/...` at the filesystem layer ([Cygwin 
docs](https://cygwin.com/cygwin-ug-net/using.html#cygdrive))
   - **MSYS2** (`sys.platform == "msys"`) similarly maps `C:\Users` to 
`/c/Users` ([MSYS2 docs](https://www.msys2.org/docs/filesystem-paths/))
   
   `sys.platform == "win32"` is also the standard CPython idiom for this, it's 
how the `stdlib` distinguishes Windows from POSIX behavior (`sys.platform` 
[docs](https://docs.python.org/3/library/sys.html#sys.platform)), and what 
[pytest](https://docs.pytest.org/en/stable/how-to/skipping.html#id1) recommends 
for `skipif` markers.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to