This repository was archived by the owner on Oct 19, 2026. It is now read-only.
Repository navigation
Fix Windows Unicode file paths in native I/O - #333
Merged
Merged
Conversation
heitzmann
approved these changes
Oct 15, 2026
Owner
|
Thanks @CAOShurong |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #292.
On Windows, Python's filesystem converter passes UTF-8 filenames to the native
code, but narrow
fopeninterprets them using the ANSI codepage. This can writeto a different filename, fail for an existing Unicode parent directory, or
overwrite an unrelated ANSI-decoded filename.
Route the native file-open calls through one helper that converts valid UTF-8
paths to UTF-16 and uses
_wfopenon Windows. Other platforms still callfopenunchanged. Stream modes, serialization and Python converters areunchanged; invalid UTF-8 is rejected rather than replaced.
The regression tests cover GDS/OAS/SVG output, streaming and raw-cell reads,
metadata, existing files moved independently with Python,
str/Path/bytesarguments, supplementary/decomposed characters and failure paths.
Validation on Windows 11, CPython 3.13.1, ANSI codepage 936, MSVC:
the existing Windows CI configuration. The new tests fail 149 cases on main
(52 pass); the patch passes all 201 cases repeatedly. All 91 original test
outcomes are unchanged; the full suite passes 292 tests.
python -m pytest <checkout>/tests/file_io_test.py -qandpython -m pytest <checkout>/tests -qfrom outside the source package,with
--basetemp=<fresh-directory>after the default local temporary directoryproduced fixture permission errors.
C++ plus installed Python GDS/OAS/SVG success and error workflows.
still reports the same five pre-existing diagnostics on unmodified main.
Linux/macOS and other Python versions have not been run locally. An existing
Windows
gds_timestamp(path, new_timestamp)failure also reproduces onunmodified main and is unchanged; this patch covers timestamp reads and file
opening, not that separate timestamp-update issue.