-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate usage of the Windows ANSI API in the nt module #57583
Comments
Attached patch deprecates the Windows ANSI API (bytes API) in the nt module. Use Unicode filenames instead of bytes filenames to not depend on the ANSI code page anymore and to support any Unicode filename. The patch changes also os.link(), os.rename() and os.symlink() to not accept two filenames of different types: require two Unicode filenames or two bytes filenames. It is an expected change, it did it to simplify the source code. I change it if necessary. |
New changeset 6bf07db23445 by Victor Stinner in branch 'default': |
The patch deprecates bytes filenames for the following functions: nt._getfullpathname Oh, I forgot a test for os.open(bytes). |
Functions like os.execv() or os.readlink() are not deprecated because the underlying C function really uses a bytes API (execv and readlink). |
Probably os.execv() should be implemented on Windows with _wexecv() instead of _execv(). Likewise for other functions which have "wide" versions. Or maybe it wouldn't be worth the effort, since it would mean writing separate Windows implementations. I don't know what you mean about os.readlink() though: the Windows implementation uses CreateFileW() and DeviceIoControl(). |
That's a different story. Would you like to implement it? If yes, please open a
Oops, you are right. The Windows implement only accepts Unicode, so no |
Updated patch:
|
Writing separate Windows versions has a long tradition in posixmodule.c, |
deprecate_win_bytes_api-2.patch:
|
I notice that the patch changes rename() and link() to use Is this approach of coercing to unicode and only using the wide api And are we able to assume that on Windows we have access to wide libc |
It's not. If people use byte strings, they specifically ask for what
How so? This entire handling of file names is windows specific;
Yes, but Python should avoid using them.
No: |
Well, I did that to simplify the source code.
I can change my patch to mimick the previous behaviour: try Unicode-Unicode,
It was already discussed before to drop the bytes API to decode Unicode |
New changeset d42811b93357 by Victor Stinner in branch 'default': |
IIUC, it means that the library/application should not use the bytes API if it intends to be supported on major platforms. |
I think you misunderstand; it does not literally mean that. Instead, it |
New changeset afc716e463a1 by Victor Stinner in branch 'default': |
New changeset 5f239b0ba819 by Victor Stinner in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: