[issue46751] Windows-style path is not recognized under cygwin

2022-02-14 Thread Eryk Sun
Eryk Sun added the comment: MSYS2 has basically the same problem when the script is passed as a Windows path, except it uses "/c" for the "C:" drive instead of "/cygdrive/c". # python3 -VV Python 3.9.9 (main, Dec 28 2021, 11:05:23) [GCC 11.2

[issue46733] pathlib.Path methods can raise NotImplementedError

2022-02-14 Thread Eryk Sun
Eryk Sun added the comment: WindowsPath.is_mount() should call ntpath.ismount(). This function needs a significant redesign, but it's fine to use it as long as it's documented that is_mount() is equivalent to os.path.ismount(). Since the owner() and group() methods return names

[issue46733] pathlib.Path methods can raise NotImplementedError

2022-02-15 Thread Eryk Sun
Eryk Sun added the comment: > I'm planning to learn more heavily on posixpath + ntpath in > pathlib once bpo-44136 is done. I think that would be a good > time to introduce is_mount() support on Windows. In the long run, it would be better to migrate the implementation

[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-16 Thread Eryk Sun
Eryk Sun added the comment: Python uses the volume serial number (VSN) and file ID for st_dev and st_ino. The OS allows the file ID to be 0 if the filesystem doesn't support file IDs. Also, it does not require or force the VSN to be a unique ID in the system, though if it's

[issue46775] [Windows] OSError should unconditionally call winerror_to_errno

2022-02-16 Thread Eryk Sun
New submission from Eryk Sun : bpo-37705 overlooked fixing the OSError constructor. oserror_parse_args() in Objects/exceptions.c should unconditionally call winerror_to_errno(), which is defined in PC/errmap.h. winerror_to_errno() maps the Winsock range 1-11999 directly, except for the

[issue46763] os.path.samefile incorrect results for shadow copies

2022-02-16 Thread Eryk Sun
Eryk Sun added the comment: Sample implementation: import os import msvcrt import win32file def samefile(f1, f2): """Test whether two paths refer to the same file or directory.""" s1 = os.stat(f1) s2 = os.stat(f2)

[issue46785] On Windows, os.stat() can fail if called while another process is creating or deleting the file

2022-02-18 Thread Eryk Sun
Eryk Sun added the comment: Windows filesystems disallow new opens for a file that has its delete disposition set (i.e. the file is marked for deletion). For example, CreateFileW() fails with ERROR_ACCESS_DENIED (5) in this case. A file with its delete disposition set is still visibly

[issue46791] Allow os.remove to defer to rmdir

2022-02-19 Thread Eryk Sun
Eryk Sun added the comment: In Windows, checking for a directory in order to defer to either os_rmdir_impl() or os_unlink_impl() would lead to a redundant directory check. os_unlink_impl() already has to check for a directory in order to delete a directory symlink or mountpoint. I suggest

[issue46733] pathlib.Path methods can raise NotImplementedError

2022-02-21 Thread Eryk Sun
Eryk Sun added the comment: > pathlib does not allow to distinguish "path" from "path/". os.path.normpath() and os.path.abspath() don't retain a trailing slash -- or a leading dot component for that matter. Are you referring to os.path.join()? For example:

[issue46839] Process finished with exit code -1073741819 (0xC0000005)

2022-02-23 Thread Eryk Sun
Eryk Sun added the comment: I tried to get more information for you by installing 2.7.11 (64-bit because of the given fault) and unassembling python27.dll at the fault offset. But it doesn't help. Whatever the bug is, it ended up jumping to an address that's in the middle of an i

[issue12165] [doc] clarify documentation of nonlocal

2022-02-24 Thread Eryk Sun
Eryk Sun added the comment: > Another problem with the current text is that it fails to exclude > enclosing class scopes The nonlocal statement is only disallowed in module code (i.e. "exec" compilation mode) because it can never be nested. It's allowed in a class d

[issue37426] getpass.getpass not working with on windows when ctrl+v is used to enter the string

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: > Clicking `Edit > Paste` from the window menu > Use right-click to paste In particular, if the console has quick-edit mode enabled, then you can paste text by right-clicking. Also, if text is selected in quick-edit mode, right-clicking copies to the

[issue37426] getpass.getpass not working with on windows when ctrl+v is used to enter the string

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: > I have an idea to solve it. But I don't know how to get the > clipboard data. In Windows, using the window manager entails extending the process and the current thread with GUI-related structures in the kernel and then connecting the process

[issue46855] printing a string with strange characters loops forever

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: The ordinal range 0x80-0x9F is the C1 control code set [1]. Ordinal 0x9F is "Application Program Command" (APC). The command must be terminated by ordinal 0x9C, "String Terminator" (ST). For example, "\x9f Some Command \x9c". In G

[issue46858] mmap constructor resets the file pointer on Windows

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: The resize() method also modifies the file pointer. Instead of fixing that oversight, I think it should directly set the file's FileEndOfFileInfo and FileAllocationInfo. For example: // resize the file if (!SetFileInformationByH

[issue46862] subprocess makes environment blocks with duplicate keys on Windows

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: This should be handled in _winapi.CreateProcess(). An environment block is technically required to be sorted. (Ages ago this was a MUST requirement for getting and setting variables to work correctly, since the implementation depended on the sort order, but I

[issue43702] [Windows] correctly sort and remove duplicates in _winapi getenvironment()

2022-02-25 Thread Eryk Sun
Change by Eryk Sun : -- versions: +Python 3.11 -Python 3.8 ___ Python tracker <https://bugs.python.org/issue43702> ___ ___ Python-bugs-list mailing list Unsub

[issue46862] subprocess makes environment blocks with duplicate keys on Windows

2022-02-25 Thread Eryk Sun
Eryk Sun added the comment: I suggest closing this issue as a duplicate of bpo-43702. -- ___ Python tracker <https://bugs.python.org/issue46862> ___ ___ Pytho

[issue28824] os.environ should preserve the case of the OS keys ?

2022-02-25 Thread Eryk Sun
Change by Eryk Sun : -- versions: +Python 3.11 ___ Python tracker <https://bugs.python.org/issue28824> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46861] os.environ forces variable names to upper case on Windows

2022-02-25 Thread Eryk Sun
Change by Eryk Sun : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> os.environ should preserve the case of the OS keys ? ___ Python tracker <https://bugs.python

[issue28824] os.environ should preserve the case of the OS keys ?

2022-02-26 Thread Eryk Sun
Eryk Sun added the comment: > I think there should be a public class like this. I wrote a basic implementation of _CaseInsensitiveString under the assumption that it's hidden behind the __getitem__(), __setitem__(), and __delitem__() methods of the _Environ class. I don't want

[issue46869] platform.release() and sys returns wrong version on Windows 11

2022-02-26 Thread Eryk Sun
Eryk Sun added the comment: platform.release() returns platform.uname().release, which comes from platform.win32_ver() in Windows [1]. The issue with Windows 11 is being discussed in bpo-45382, but no PR has been submitted yet to resolve the issue. > >>> sys.getwi

[issue46791] Allow os.remove to defer to rmdir

2022-02-28 Thread Eryk Sun
Eryk Sun added the comment: > For REMOVE_BOTH, I don't see the need of calling GetFileAttributes I was thinking that the NtQueryAttributesFile() system call is relatively cheap compared to a full open, especially if the attributes of a remote file are cached locally. However, o

[issue46791] Allow os.remove to defer to rmdir

2022-03-01 Thread Eryk Sun
Eryk Sun added the comment: glibc remove() has an optimization to skip calling rmdir() if the macro condition IS_NO_DIRECTORY_ERROR is true for the unlink() error. For Linux, this condition is `errno != EISDIR`. On other platforms (e.g. BSD systems), the condition is `errno != EPERM`. The

[issue46888] SharedMemory.close() destroys memory

2022-03-01 Thread Eryk Sun
Eryk Sun added the comment: > Yes, named memory mappings only exist on Windows until the last > reference is closed, so this is a difference due to the underlying OS. That's true for the Windows API, so it's true for all practical purposes. In the underlying NT API, crea

[issue15373] copy.copy() does not properly copy os.environment

2022-03-01 Thread Eryk Sun
Eryk Sun added the comment: In bpo-28824, I suggested preserving the case of environment variables in Windows by using a case-insensitive subclass of str in the encodekey() function. This is self-contained by the use of the encodekey() and decodekey() functions in the mapping methods such

[issue46888] SharedMemory.close() destroys memory

2022-03-01 Thread Eryk Sun
Eryk Sun added the comment: > The persistent mode sounds just like Python shared memory also works > on Linux (where I can have these /dev/shm/* files even after the > Python process ends) but I think on Windows, Python is not using > the persistent mode and thus the shared memo

[issue28824] os.environ should preserve the case of the OS keys ?

2022-03-02 Thread Eryk Sun
Eryk Sun added the comment: Putting words into action, here's an example of what a privileged process (e.g. running as SYSTEM) can do if a script or application is written to call the undocumented NT API function NtMakePermanentObject(). A use case would be a script running as a s

[issue28824] os.environ should preserve the case of the OS keys ?

2022-03-02 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg414332 ___ Python tracker <https://bugs.python.org/issue28824> ___ ___ Python-bugs-list mailin

[issue46888] SharedMemory.close() destroys memory

2022-03-02 Thread Eryk Sun
Eryk Sun added the comment: Putting words into action, here's an example of what a privileged process (e.g. running as SYSTEM) can do if a script or application is written to call the undocumented NT API function NtMakePermanentObject(). A use case would be a script running as a s

[issue46905] winsound.PlaySound should accept pathlib.Path instances

2022-03-02 Thread Eryk Sun
Eryk Sun added the comment: PlaySound() is implemented by the C function winsound_PlaySound_impl() in "PC/winsound.c". To support pathlike objects, it could use `soundname = PyOS_FSPath(sound)`, and require soundname to be a Unicode string via PyUnicode_Check(soundname). Or it

[issue46905] winsound.PlaySound should accept pathlib.Path instances

2022-03-02 Thread Eryk Sun
Change by Eryk Sun : -- components: +Windows keywords: +easy (C) nosy: +paul.moore, steve.dower, tim.golden, zach.ware ___ Python tracker <https://bugs.python.org/issue46

[issue46916] There is a problem with escape characters in the path passed in by pathlib.Path.mkdir()

2022-03-03 Thread Eryk Sun
Eryk Sun added the comment: > FileNotFoundError: [WinError 3] The system cannot find > the path specified: 'F:\\ceven\\test2' The Windows error code, ERROR_PATH_NOT_FOUND (3), indicates that the parent path, r"F:\ceven", does not exist. Try e.mkdir(par

[issue46916] There is a problem with escape characters in the path passed in by pathlib.Path.mkdir()

2022-03-03 Thread Eryk Sun
Eryk Sun added the comment: > e = Path(r'F:\ceven\test2') Using forward slashes in the string literal is preferred, e.g. Path('F:/ceven/test2'). This avoids the problem of backslash escapes in string literals. The Path constructor parses the path and stores it interna

[issue46916] There is a problem with escape characters in the path passed in by pathlib.Path.mkdir()

2022-03-04 Thread Eryk Sun
Eryk Sun added the comment: > I thought pathlib would solve this problem completely now, > without having to replace the slashes. pathlib has nothing to do with how the Python language compiles string literals. A string *literal* is Python source code that gets compiled and instantia

[issue37609] support "UNC" device paths in ntpath.splitdrive

2022-03-06 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg390391 ___ Python tracker <https://bugs.python.org/issue37609> ___ ___ Python-bugs-list mailin

[issue46966] c_void_p array is a footgun on I32LP64 systems

2022-03-09 Thread Eryk Sun
Eryk Sun added the comment: > I'm not sure what can be done here (maybe a truncation warning?) For a function pointer, the default argument conversion for Python integers is the platform int type. Ideally, Python integer arguments would be converted to a type that matches the platf

[issue46785] On Windows, os.stat() can fail if called while another process is creating or deleting the file

2022-03-11 Thread Eryk Sun
Eryk Sun added the comment: Itai, you can add a test to Win32NtTests in Lib/test/test_os.py. Maybe spawn a child process that creates and unlinks a file in a loop. In the parent process execute a loop that tries to stat the file and ignores errors when the file or path isn't found

[issue46988] if a python program is execute by subprocess, the python program can't output unicode characters and raise UnicodeEncodeError

2022-03-11 Thread Eryk Sun
Change by Eryk Sun : -- superseder: -> Encoding error running in subprocess with captured output ___ Python tracker <https://bugs.python.org/issue46988> ___ _

[issue47001] deadlock in ctypes?

2022-03-13 Thread Eryk Sun
Eryk Sun added the comment: Pointers to resource type/name strings use the lower 16-bit range for integer identifiers such as RT_ICON (3) and RT_GROUP_ICON (14). C code checks for these cases using the IS_INTRESOURCE() macro. It's incorrect to use a simple C string pointer type su

[issue46785] On Windows, os.stat() can fail if called while another process is creating or deleting the file

2022-03-13 Thread Eryk Sun
Eryk Sun added the comment: > Why catch ERROR_NOT_READY and ERROR_BAD_NET_NAME as well? When os.stat() falls back on FindFirstFileW(), an error that means the file doesn't exist should be kept. ERROR_BAD_NET_NAME is an obvious error to keep because it's already mapped to ENOE

[issue46785] On Windows, os.stat() can fail if called while another process is creating or deleting the file

2022-03-14 Thread Eryk Sun
Eryk Sun added the comment: I was following the pattern of StatAttributeTests.test_access_denied(), which uses the current user's temp directory to get a filesystem that supports security. It would probably be better to skip tests if the filesystem of the current working directory do

[issue46950] Windows 11, VENV not working with case sensitive windows paths

2022-03-14 Thread Eryk Sun
Eryk Sun added the comment: In 3.10, you should be able to work around the problem for the venv site-packages directory by setting the environment variable "PYTHONPLATLIBDIR" to "Lib". This sets sys.platlibdir, which the site module uses to create the site-packages di

[issue47025] bytes do not work on sys.path

2022-03-15 Thread Eryk Sun
Eryk Sun added the comment: > this is a regression from 3.2 In Windows, bytes paths in sys.path do not work in 3.2+. I didn't test 3.0 and 3.1, but practically one can say that bytes paths were never supported in Python 3 on Windows. -- nosy:

[issue46890] getpath problems with framework build

2022-03-16 Thread Eryk Sun
Eryk Sun added the comment: > This means that "python -S" doesn't work with a virtual environment. Does that matter? I've only used a virtual environment to override or extend the system site packages. Is there a reason to use one without site packages? --

[issue47037] Build problems on Windows

2022-03-16 Thread Eryk Sun
Eryk Sun added the comment: bpo-46587 added top-level code to "Lib/test/support/__init__.py" to check whether time.strftime("%4Y") works. Since "Lib/test/libregrtest/setup.py" imports the support module, that code executes before suppress_msvcrt_asser

[issue47037] Build problems on Windows

2022-03-16 Thread Eryk Sun
Eryk Sun added the comment: > Ouch, is Python crashes because of an unsupported strftime call? It's not a crash. It's a CRT error report dialog, which is enabled by default for the _CRT_ASSERT and _CRT_ERROR macros in debug builds. This dialog can be helpful when debugging inte

[issue47037] Build problems on Windows

2022-03-17 Thread Eryk Sun
Change by Eryk Sun : -- priority: normal -> critical ___ Python tracker <https://bugs.python.org/issue47037> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue47037] Build problems on Windows

2022-03-18 Thread Eryk Sun
Eryk Sun added the comment: The main entry point for python[_d].exe should support a command-line -X option or environment variable that suppresses Windows error/assert/warn reporting, or redirects it to stderr in verbose mode. This would be useful to simplify everyone's automated te

[issue43702] [Windows] correctly sort and remove duplicates in _winapi getenvironment()

2022-03-19 Thread Eryk Sun
Eryk Sun added the comment: > which name should be stored if they are duplicated with case insensitive? Ideally os.environ would preserve the original case of the process environment, and os.environ.copy() would return a copy that's also case insensitive. That would prevent most

[issue46788] regrtest fails to start on missing performance counter names

2022-03-21 Thread Eryk Sun
Eryk Sun added the comment: I was just wondering whether it's worth implementing it using the API. To be clear, I wasn't implying to hold off on applying Jeremy's PR. The existing code is causing him problems, and he has a working solution. --

[issue46788] regrtest fails to start on missing performance counter names

2022-03-22 Thread Eryk Sun
Eryk Sun added the comment: I implemented a ctypes prototype that replaces the registry-based implementation with the API calls PdhOpenQueryW(), PdhAddEnglishCounterW(), PdhCollectQueryData(), PdhGetRawCounterValue(), and PdhCloseQuery(). I'm attaching the script, but here's

[issue47093] Documentation Fix: Remove .bat when activating venv on windows

2022-03-22 Thread Eryk Sun
Eryk Sun added the comment: Running `tutorial-env\Scripts\activate` should suffice. The .bat script is for CMD, and the .ps1 script is for PowerShell. The shell should run the right script without having to include the extension. In Windows 10+, if you use a case-sensitive directory for

[issue47096] Use the PDH API in WindowsLoadTracker

2022-03-22 Thread Eryk Sun
New submission from Eryk Sun : In bpo-44336, a new version of WindowsLoadTracker was implemented in Lib/test/libregrtest/win_utils.py. This version resolves issues with the previous implementation that spawned typeperf.exe. The new implementation uses the registry API's HKEY_PERFORMANCE

[issue46788] regrtest fails to start on missing performance counter names

2022-03-22 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg415781 ___ Python tracker <https://bugs.python.org/issue46788> ___ ___ Python-bugs-list mailin

[issue46788] regrtest fails to start on missing performance counter names

2022-03-22 Thread Eryk Sun
Change by Eryk Sun : Removed file: https://bugs.python.org/file50695/loadtracker.py ___ Python tracker <https://bugs.python.org/issue46788> ___ ___ Python-bugs-list m

[issue47086] Include HTML docs with Windows installer instead of CHM

2022-03-22 Thread Eryk Sun
Eryk Sun added the comment: Do you have any thoughts about distributing the docs in ePub format? -- nosy: +eryksun ___ Python tracker <https://bugs.python.org/issue47

[issue47086] Include HTML docs with Windows installer instead of CHM

2022-03-22 Thread Eryk Sun
Change by Eryk Sun : -- nosy: -eryksun ___ Python tracker <https://bugs.python.org/issue47086> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue32642] add support for path-like objects in sys.path

2022-03-26 Thread Eryk Sun
Eryk Sun added the comment: > I've got in mind a PyListObject subclass with calls to PyOS_FSPath > before insert, append, extend and __getitem__. The sys module doesn't prevent rebinding sys.path. Most code I think is careful to update sys.path. But surely some code replac

[issue47134] Document the meaning of the number in OverflowError

2022-03-26 Thread Eryk Sun
Eryk Sun added the comment: The error code for `1e+300 ** 2` is ERANGE, from calling libm pow(). Since pow() returns a double, there's no way to indicate an error in the return value. Instead, C errno is set to 0 beforehand and checked for a non-zero error value after the call. If the

[issue39090] Document various options for getting the absolute path from pathlib.Path objects

2022-04-01 Thread Eryk Sun
Eryk Sun added the comment: > Now a file that doesn't exist: > >>> mike = Path("palin.jpg") > >>> mike.resolve() > WindowsPath('palin.jpg') This is a bug in resolve(). It was fixed in 3.10+ by switching to ntpath.realpath(). I don'

[issue47161] pathlib method relative_to doesnt work with // in paths

2022-04-01 Thread Eryk Sun
Eryk Sun added the comment: > Hmm..., I get it, but Im not gonna lie it's pretty confusing given > that in other places `//` works as a substitute for `/`. Maybe it > should be mentioned in the documentation? In Linux, the system resolves "//" as just "/"

[issue47170] py launcher on windows opens new terminal window when parsing python script with shebang

2022-04-01 Thread Eryk Sun
Eryk Sun added the comment: > This is Windows (shell) behaviour. To avoid this, you need to > add the .py extension to the PATHEXT environment variable. PowerShell reuses the current console session only if .PY is set in PATHEXT. Otherwise Python gets executed with a flag that tel

[issue47198] os.stat on windows doesn't take an open file even though os.stat in os.supports_fd

2022-04-01 Thread Eryk Sun
Eryk Sun added the comment: You're mistaken about what `fd` is. It's a TextIOWrapper, which wraps a BufferedWriter, which buffers a FileIO raw file object, which accesses the open file number fd.fileno(). For example: >>> f = open('tmp.tmp','w')

[issue47203] ImportError: DLL load failed while importing binascii: %1 is not a valid Win32 application.

2022-04-03 Thread Eryk Sun
Eryk Sun added the comment: The user site packages directory is architecture specific starting with 3.10, e.g. "%AppData%\Python\Python310-32\site-packages". The PYTHONPATH environment variable is shared by all versions. However, I don't understand how the binascii mo

[issue47203] ImportError: DLL load failed while importing binascii: %1 is not a valid Win32 application.

2022-04-05 Thread Eryk Sun
Eryk Sun added the comment: There is something fundamentally wrong with the way modules built into the interpreter DLL (python3x.dll) are loaded if anything in sys.path or the system PATH can cause an import to fail. -- ___ Python tracker <ht

[issue37834] readlink on Windows cannot read app exec links

2019-08-13 Thread Eryk Sun
Eryk Sun added the comment: > Honestly, the only real problem I've seen is in applications that use > a reimplementation of spawn() rather than the UCRT's version (which > handles the reparse point jsut fine). I looked into this spawn problem. It's due to Cygwi

[issue37834] readlink on Windows cannot read app exec links

2019-08-13 Thread Eryk Sun
Eryk Sun added the comment: > I feel like that's more work than is worth us doing for something that > will be relatively rarely used, will live in the stdlib, and is > obviously something that will become outdated as Microsoft adds new > reparse points. Junctions (NT 5) a

[issue37834] readlink on Windows cannot read app exec links

2019-08-13 Thread Eryk Sun
Eryk Sun added the comment: > Replacing "\??\" with "\\?\" in place is trivial though, as we start > with a mutable buffer. I'm just not clear that it's as simple as that, > though. If the path starts with "\\??\\" we can just change the f

[issue37834] readlink on Windows cannot read app exec links

2019-08-13 Thread Eryk Sun
Eryk Sun added the comment: > Until then, I think it makes sense for os.readlink() to handle the > prefix and _getfinalpathname() call, but leave nt.readlink() as > returning the raw value. os.readlink() shouldn't resolve the final path or realpath(). It should simply r

[issue37850] Console: holding right arrow key reproduces entire previous input

2019-08-14 Thread Eryk Sun
Eryk Sun added the comment: > I did not observe this behaviour on WSL, which is why I think > this is a bug. WSL uses a low-level console interface in virtual-terminal mode. Python's console REPL in Windows is using the standard high-level console editing that's provide

[issue37834] readlink on Windows cannot read app exec links

2019-08-14 Thread Eryk Sun
Eryk Sun added the comment: > I really want a fix for this in 3.8, or else os.stat(sys.executable) > may fail I agree, but Python can support this without handling junctions as symlinks or limiting the reparse points that we can follow. There are reparse points for offline stora

[issue37834] readlink on Windows cannot read app exec links

2019-08-14 Thread Eryk Sun
Eryk Sun added the comment: > but suddenly adding "\\?\" to the paths breaks a lot of assumptions. The unwritten assumption has been that readlink() is reading symlinks that get created by CreateSymbolicLinkW, which sets the print name as the DOS path that's passed to the

[issue37859] time.process_time() constant / erratic on Windows

2019-08-14 Thread Eryk Sun
Eryk Sun added the comment: > I suppose it may benefit from a more precise counter, but since in > Windows it also has a precise counter with time.perf_counter_ns(), > I was expecting to see that value change, but it was mainly a > confusion with the older time.clock(). Don

[issue37834] readlink on Windows cannot read app exec links

2019-08-14 Thread Eryk Sun
Eryk Sun added the comment: > I wish we could remove the MAX_PATH limit in this case. > > The problem is that we have to remove the limit in any case where the > resulting path might be used, which is what we're already trying to > encourage by supporting long paths.

[issue37834] readlink on Windows cannot read app exec links

2019-08-15 Thread Eryk Sun
Eryk Sun added the comment: > Unless your point is that we should _always_ traverse junctions? In > which case we have a traverse 'upgrade' scenario (calls to lstat() > become calls to stat() when we find out it's a junction). If we've opened the reparse point t

[issue37834] readlink on Windows cannot read app exec links

2019-08-15 Thread Eryk Sun
Eryk Sun added the comment: > Okay, I get it now. So we _do_ want to "upgrade" lstat() to stat() > when it's not a symlink. I don't see that as a behavior upgrade. It's just an implementation detail. lstat() is still following its mandate to not follow syml

[issue37834] readlink on Windows cannot read app exec links

2019-08-15 Thread Eryk Sun
Eryk Sun added the comment: > It also has a bug that a drive root is a mount point, even if the > drive doesn't exist. Also, it's wrong in not checking for junctions > in UNC paths. SMB supports opening reparse points over the wire. "It" in the above sen

[issue37834] readlink on Windows cannot read app exec links

2019-08-15 Thread Eryk Sun
Eryk Sun added the comment: > # Always make the OS resolve "unknown" reparse points >ALLOWED_TO_TRAVERSE = {SYMLINK, MOUNT_POINT} >if !traverse and st.reparse_tag not in ALLOWED_TO_TRAVERSE: >return xstat(path, !traverse) To me the nami

[issue37834] readlink on Windows cannot read app exec links

2019-08-15 Thread Eryk Sun
Eryk Sun added the comment: > So for an actual non-root mount point ntpath.ismount() returns True > and with IO_REPARSE_TAG_MOUNT_POINT included ntpath.islink() also > returns True. nt.readlink() returns the "\\?\Volume{GUID}\" path If islink() is true, then st_mode

[issue37871] 40 * 473 grid of "é" has a single wrong character on Windows

2019-08-15 Thread Eryk Sun
Eryk Sun added the comment: To be compatible with Windows 7, _io__WindowsConsoleIO_write_impl in Modules/_io/winconsoleio.c is forced to write to the console in chunks that do not exceed 32 KiB. It does so by repeatedly dividing the length to decode by 2 until the decoded buffer size is

[issue37834] readlink on Windows cannot read app exec links

2019-08-16 Thread Eryk Sun
Eryk Sun added the comment: > Where "links" are the generic term for the set that includes > "reparse point", "symlink", "mount point", "junction", etc.) Why group all reparse points under the banner of 'link'? If we have

[issue37834] readlink on Windows cannot read app exec links

2019-08-16 Thread Eryk Sun
Eryk Sun added the comment: > the '/mnt/c/Document and Settings' junction... though now I try > it that those don't actually work...) The security on compatibility junctions denies everyone read-data (list) access, but in Windows they can still be traversed (e.g. "

[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun
Eryk Sun added the comment: Here's the requested overview for the case where name-surrogate reparse points are handled as winlinks (Windows links), but S_IFLNK is reserved for IO_REPARSE_TAG_SYMLINK. I took the time this afternoon to write it up in C, which hopefully is clearer th

[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun
Eryk Sun added the comment: Here are two additional differences between mount points and symlinks: (1) A mount point in a remote path is always evaluated on the server and restricted to devices that are local to the server. So if we handle a mount point as if it's a POSIX symlink that

[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun
Eryk Sun added the comment: > Any particular reason you did GetFileAttributesW(path) in the > non-FILE_TYPE_DISK case when we have the hFile around? The point of getting the file attributes is to identify the root directory of the namedpipe and mailslot file systems. For example, os.l

[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-20 Thread Eryk Sun
Eryk Sun added the comment: > PS: I personally believe from my experience that shared memory > segments should outlive the process, unless specified otherwise. > Also, a argument persist=True, can be added which can ensure > that the shared_memory segment outlives the process

[issue9949] os.path.realpath on Windows does not follow symbolic links

2019-08-21 Thread Eryk Sun
Eryk Sun added the comment: I'm tentatively reopening this issue for you to consider the following point, Steve. A real path is not always the same as a final path. We can find code that does `relpath(realpath(target), realpath(start))` to compute the relative path to target for a sy

[issue9949] os.path.realpath on Windows does not follow symbolic links

2019-08-21 Thread Eryk Sun
Eryk Sun added the comment: > Aware code can handle it [the exception] by getting a real path and > taking appropriate measures. That should be "by getting a final path". -- ___ Python tracker <https://bugs.p

[issue9949] os.path.realpath on Windows does not follow symbolic links

2019-08-21 Thread Eryk Sun
Eryk Sun added the comment: >> We can find code that does `relpath(realpath(target), >> realpath(start))` to compute the relative path to target >> for a symlink. >> ... > I don't know how common this scenario is, but I can certainly > say that it's

[issue37894] [win] shutil.which can not find the path if 'cmd' include directory path and not include extension name

2019-08-21 Thread Eryk Sun
Eryk Sun added the comment: The code that sets up the PATHEXT `files` could be moved up. It also needs to be fixed in order to implement the correct behavior. For example: use_bytes = isinstance(cmd, bytes) files = [cmd] if _WINDOWS: # Also look for the name plus each

[issue29250] islink and stat follow_symlinks are inconsistent on Windows

2019-08-21 Thread Eryk Sun
Change by Eryk Sun : -- dependencies: -os.walk always follows Windows junctions resolution: -> out of date stage: needs patch -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue37074] os.stat() does not work for NUL and CON

2019-08-21 Thread Eryk Sun
Change by Eryk Sun : -- resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue37074> ___ ___

[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-21 Thread Eryk Sun
Eryk Sun added the comment: > register the shared the shared_memory only when it's created and > not when it's attached. In Windows, the section object is reference counted. I haven't looked into the Unix implementation, but maybe it could use advisory locking. After o

[issue37074] os.stat() does not work for NUL and CON

2019-08-21 Thread Eryk Sun
Eryk Sun added the comment: > Where it was fixed? It was addressed in issue 37834. PR 15231 includes a rewrite of win32_xstat_impl. The file type was needed, so the rewrite could also address the problem of character devices such as CON and

[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-22 Thread Eryk Sun
Eryk Sun added the comment: > It seems like self.stdout.read() hangs even after the child process > has been killed. This is an issue when the standard handles are inherited or duplicated to a grandchild process, and so on. In the case of Popen(sys.executable), the system is dupli

[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-22 Thread Eryk Sun
Eryk Sun added the comment: > Is there a way to workaround that? For Windows, subprocess could have a _read_all(file) method that special cases a pipe. The read loop for a pipe would check whether the child has exited. Then call _winapi.PeekNamedPipe on the handle (from get_osfhandle),

[issue37549] os.dup() fails for standard streams on Windows 7

2019-08-23 Thread Eryk Sun
Eryk Sun added the comment: > Should we add a version check as well [1]? I'm not totally comfortable > with bitmasking a handle here, but if we only do this additional > check on Win7 then I'm okay with it. A version check should not be necessary. For file objects, setti

[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-23 Thread Eryk Sun
Eryk Sun added the comment: Alternatively, instead of special casing the file type and spinning on PeekNamedPipe, the workaround could be based on a multiple-object wait that includes the child process handle. In this case, communicate() would always call _communicate in Windows, regardless

[issue37939] os.path.normpath change some characters of a path into kinda 'hex number'

2019-08-24 Thread Eryk Sun
Eryk Sun added the comment: As Karthikeyan noted, in a regular string literal, backslash is an escape character that's used in the following escape sequences: \N{name} : named character \U : 32-bit hexadecimal ordinal (e.g. \U0010) \u : 16-bit hexade

<    1   2   3   4   5   6   7   8   9   10   >