[issue43749] venv module does not copy the correct python exe

2021-12-10 Thread Eryk Sun
Eryk Sun added the comment: The Windows implementation of symlink_or_copy() actually copies "python.exe" and "pythonw.exe" launchers from "Lib/venv/scripts/nt". One cannot simply copy the "python3.exe" executable because the required DLLs aren't

[issue43749] venv module does not copy the correct python exe

2021-12-10 Thread Eryk Sun
Change by Eryk Sun : -- components: +Windows nosy: +paul.moore, steve.dower, tim.golden, zach.ware versions: +Python 3.11 -Python 3.8 ___ Python tracker <https://bugs.python.org/issue43

[issue43749] venv module does not copy the correct python exe

2021-12-10 Thread Eryk Sun
Eryk Sun added the comment: The code to copy a file could be rewritten to use a regex match. For example: # Copy src to dst. If src is a base executable, copy a launcher. dirname, filename = os.path.split(src) m = re.match(r'(pythonw?)[0-9._]*(

[issue23948] Deprecate os.kill() on Windows

2021-12-11 Thread Eryk Sun
Change by Eryk Sun : -- resolution: -> rejected stage: needs patch -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue42962] Windows: SystemError during os.kill(..., signal.CTRL_C_EVENT)

2021-12-11 Thread Eryk Sun
Change by Eryk Sun : -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> missing return in win32_kill? ___ Python tracker <https://bugs.python

[issue14484] missing return in win32_kill?

2021-12-11 Thread Eryk Sun
Eryk Sun added the comment: The details of os.kill() on Windows have been discussed extensively for years in various issues such as bpo-26350, bp-23948, and bp42962. But the problem of the missing return statement is always overwhelmed by discussion of the egregiously bad design of this

[issue14484] missing return in win32_kill?

2021-12-11 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg408336 ___ Python tracker <https://bugs.python.org/issue14484> ___ ___ Python-bugs-list mailin

[issue14484] missing return in win32_kill?

2021-12-11 Thread Eryk Sun
Eryk Sun added the comment: The details of os.kill() on Windows have been discussed extensively for years in various issues such as bpo-26350, bpo-23948, and bpo-42962. But the problem of the missing return statement is always overwhelmed by discussion of the egregiously bad design of this

[issue37701] shutil.copyfile raises SpecialFileError for symlink to fifo

2021-12-11 Thread Eryk Sun
Eryk Sun added the comment: > Raising a SpecialFileError would be OK if `follow_symlinks` was False. I expect it to fail if follow_symlinks is True, which is the default value. I expect it to succeed with follow_symlinks=False, which should create a shallow copy of just the syml

[issue46052] IDLE: make Ctrl, Alt + IME non-ascii letter work on Windows

2021-12-12 Thread Eryk Sun
Eryk Sun added the comment: The alternate keyboard shortcuts for the clipboard work fine with a Russian keyboard layout: copy: Ctrl+Insert cut: Shift+Delete paste: Shift+Insert Some programs also support Alt+Backspace for undo (Ctrl+Z). Watch out with Shift+Delete in GUI shells

[issue46052] IDLE: make Ctrl, Alt + IME non-ascii letter work on Windows

2021-12-12 Thread Eryk Sun
Eryk Sun added the comment: I think the following wiki article still applies even though it was first discussed in 2003: "KeySyms on platforms other than X11" [1]. In particular, it states the following: On Windows and MacOS X Tk only supports keysyms correctly for a limi

[issue46056] Cannot use virtual environment on Windows 10 in corporate security settings

2021-12-12 Thread Eryk Sun
Eryk Sun added the comment: Try using symlinks if you're allowed, e.g. `python -m venv --symlinks `. Note that a virtual environment created with symlinks is unreliable in some cases because ShellExecute[Ex]W() eagerly resolves a symlink before calling CreateProcessW(). Also, you won

[issue46056] Cannot use virtual environment on Windows 10 in corporate security settings

2021-12-13 Thread Eryk Sun
Eryk Sun added the comment: > symlinks do not work for me Sorry, I forgot that you're using the store app. The store app has to use the copied venv launchers. When a store app is run from the command line, the system executes an appexec link from "%LocalAppData%\Microsof

[issue45915] Use fcntl(fd, F_GETFD) to check whether an fd is valid

2021-12-13 Thread Eryk Sun
Eryk Sun added the comment: PR 29821 adds __APPLE__ to the platforms that use fcntl(fd, F_GETFD). Is this okay on macOS, given bpo-30225? Apparently fstat() fails if the other end of a pipe is closed. -- ___ Python tracker <ht

[issue46084] Python 3.9.6 scan_dir returns filenotfound on long paths, but os_walk does not

2021-12-15 Thread Eryk Sun
Eryk Sun added the comment: > Python 3.9.6 scan_dir returns filenotfound on long paths, > but os_walk does not. This would be surprising. os.walk() has been implemented via os.scandir() since Python 3.5. Do you have a concrete example of the directory structure to test? > I see

[issue46084] Python 3.9.6 scan_dir returns filenotfound on long paths, but os_walk does not

2021-12-15 Thread Eryk Sun
Eryk Sun added the comment: It works as expected for me: >>> len(p) 261 >>> print(p) C:\Temp\Jim\Documents\jschw_uiowtv3_old\AppData\Local\Google\Chrome\User Data\Default\Extensions\nenlahapcbofgnanklpelkaejcehkggg\0.1.823.675_0\notifications\pages\C

[issue46084] Python 3.9.6 scan_dir returns filenotfound on long paths, but os_walk does not

2021-12-15 Thread Eryk Sun
Eryk Sun added the comment: If I had long paths enabled, then next(os.walk(p, onerror=print)) would not have printed the error that I showed in the example and would not have immediately raised StopIteration. Instead it would have returned a (dirpath, dirnames, filenames) result for

[issue46084] Python 3.9.6 scan_dir returns filenotfound on long paths, but os_walk does not

2021-12-15 Thread Eryk Sun
Eryk Sun added the comment: > but errors in DirEntry.is_dir() and DirEntry.is_symlink() > are always ignored In Windows, is_symlink() won't fail due to a long path, since that information comes from the directory listing, but is_dir() might fail for a long path if it'

[issue46143] [docs] IO > Text Encoding info outdated

2021-12-21 Thread Eryk Sun
Eryk Sun added the comment: The rare circumstance in which UTF-8 mode gets enabled automatically is described in the following paragraph [1]: If the PYTHONUTF8 environment variable is not set at all, then the interpreter defaults to using the current locale settings, unless the

[issue41222] POpen bufsize=0 ignored with universal_newlines=True

2021-12-22 Thread Eryk Sun
Eryk Sun added the comment: > Buffering is necessary for implementing the universal_newlines Why is that? I can see that it requires newline state tracking, and the allowance to make two read(fd, &c, 1) system calls for a single read(1) method call, in case a "\n"

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Eryk Sun
Eryk Sun added the comment: > If exec gets two separate objects as globals and locals, > the code will be executed as if it were embedded in a > class definition. That's a misleading comparison because a class definition intentionally supports nonlocal closures, which

[issue46153] function fails in exec when locals is given

2021-12-22 Thread Eryk Sun
Eryk Sun added the comment: > That's taken straight out of the documentation. Yes, but it's still a misleading comparison. > Until I understood that exec with two different mapping objects as > globals and locals behaves as if the code where embedded inside a > class

[issue46153] function fails in exec when locals is given

2021-12-23 Thread Eryk Sun
Eryk Sun added the comment: > You seem to be arguing that a description in the docs is "misleading", > not because it misleads, but because it don't describe a situation > which has nothing to do with the situation that the docs are describing. To me it's mislea

[issue46171] venv module produces spurious warning that location has moved

2021-12-24 Thread Eryk Sun
Eryk Sun added the comment: There's no point to making the user worry about short names, symlinks, or non-canonical mount points in the filesystem path of a virtual environment. It's still accessible where the user expects to find it. The problem for bpo-45337 is filesystem redi

[issue46171] venv module produces spurious warning that location has moved

2021-12-24 Thread Eryk Sun
Eryk Sun added the comment: There's still the problem of the system using short names in %TEMP%, since by default that's under "%USERPROFILE%\AppData". Either an exception could be made for the temp directory, since it's never redirected (AFAIK), or su

[issue46171] venv module produces spurious warning that location has moved

2021-12-28 Thread Eryk Sun
Eryk Sun added the comment: > There are plenty of other ways to get a venv through a potentially > unexpected path (turns out I've been doing one for years) Examples would be appreciated because I'm drawing a blank here. A junction or directory symlink in the parent pat

[issue46193] Using a dictionary for open files.

2021-12-29 Thread Eryk Sun
Eryk Sun added the comment: Every time open(r"test.txt", "w") is called, the existing "test.txt" file gets overwritten in the filesystem as an empty file. For each iteration, setdefault() returns a reference to the first file object, which advances its f

[issue46171] venv module produces spurious warning that location has moved

2021-12-31 Thread Eryk Sun
Eryk Sun added the comment: > My VHDX mounted in a directory is affected by this I created a VHDX and mounted it in a directory. It's just a regular volume mount point with a junction (IO_REPARSE_TAG_MOUNT_POINT). That won't cause any problems, so I guess your setup must be

[issue34931] os.path.splitext with more dots

2022-01-03 Thread Eryk Sun
Eryk Sun added the comment: > On Windows the extension of "python.exe" is "exe", not ".exe". FWIW, a file extension in Windows includes the dot. Trailing dots are stripped from filenames, so a file can't be named "python." because it's

[issue46217] 3.11 build failure on Win10: new _freeze_module changes?

2022-01-03 Thread Eryk Sun
Eryk Sun added the comment: With just PATHCCH_ALLOW_LONG_PATHS, PathCchCombineEx() returns a long path as a normal path (i.e. not a \\?\ extended path) if long-path support is enabled for the current process. Otherwise, if long-path support isn't enabled or available, as is always the

[issue46276] ImportError: DLL load failed while importing

2022-01-06 Thread Eryk Sun
Eryk Sun added the comment: "_frida.cp310-win_amd64.pyd" is a bad build or corrupted file. It imports a procedure with no name from a DLL with no name, which causes the loader to search for a file named ".DLL". Even if that were found, it imports another procedure wit

[issue46276] ImportError: DLL load failed while importing

2022-01-06 Thread Eryk Sun
Eryk Sun added the comment: > ImportError: DLL load failed while importing _socket: El parámetro no es > correcto. I'm not familiar with the implementation of PyInstaller, which is a third-party tool. The above invalid-parameter error may be indirectly related to the problem wit

[issue9937] _winreg.EnumValue causes MemoryError

2022-01-07 Thread Eryk Sun
Eryk Sun added the comment: > Did anyone reproduce on python3.X? In principle, winreg should not have a problem in 3.x because it only uses the UTF-16 wide-character API. -- nosy: +eryksun stage: -> resolved status: pending -> closed _

[issue46217] 3.11 build failure on Win10: new _freeze_module changes?

2022-01-07 Thread Eryk Sun
Eryk Sun added the comment: Terry, it's just a simple bug that slipped by. The PATHCCH_OPTIONS enum in the SDK header "PathCch.h" unconditionally defines all of the options. So there's no compiler error when building with a newer version of the SDK, even though we de

[issue46297] Python interpreter crashes on bootup with multiple PythonPaths set in registry

2022-01-07 Thread Eryk Sun
Change by Eryk Sun : -- components: +Windows nosy: +paul.moore, tim.golden, zach.ware type: crash -> behavior ___ Python tracker <https://bugs.python.org/issu

[issue46297] Python interpreter crashes on bootup with multiple PythonPaths set in registry

2022-01-07 Thread Eryk Sun
Change by Eryk Sun : -- type: behavior -> crash ___ Python tracker <https://bugs.python.org/issue46297> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue46287] UNC path normalisation issues on Windows

2022-01-07 Thread Eryk Sun
Eryk Sun added the comment: > _Py_abspath/_getfullpathname does not always call GetFullPathNameW on 3.11. Also, PathCchSkipRoot() doesn't recognize forward slash as a path separator, so _Py_isabs() is wrong in many cases compared to the same path that uses backslash as the path s

[issue46226] User specific paths added to System PATH environment variable

2022-01-07 Thread Eryk Sun
Eryk Sun added the comment: Were you upgrading an existing installation of Python 3.10? Did it actually install in "C:\Program Files\Python310"? Is Python currently installed in per-user "%LocalAppData%\Programs\Python\Python310"? Was it ever installed there? -

[issue46142] python --help output is too long

2022-01-10 Thread Eryk Sun
Eryk Sun added the comment: > Do you know other projects which dump the full help into stdout > when asking for the "full help"? `ps --help` lists sections "". The "--help all" output is all sections, but truly all help is only available via `man ps`.

[issue46326] 'virtualenv --clear' should prompt user before nuking entire directory

2022-01-10 Thread Eryk Sun
Eryk Sun added the comment: Ned, the CLI of venv has a `--clear` option, which invokes EnvBuilder [1] with clear=True. It's implemented by EnvBuilder.clear_directory(). Ali wants this method to prompt for confirmation before deleting the directory contents and also proposes the additi

[issue46326] 'virtualenv --clear' should prompt user before nuking entire directory

2022-01-10 Thread Eryk Sun
Eryk Sun added the comment: The implementation of `--clear` in virtualenv apparently was changed to align with venv. On the linked virtualenv issue, Bernát Gábor suggested creating a bpo issue for venv to determine how the issue should be resolved for virtualenv. -- nosy

[issue46287] UNC path normalisation issues on Windows

2022-01-14 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg410068 ___ Python tracker <https://bugs.python.org/issue46287> ___ ___ Python-bugs-list mailin

[issue45554] multiprocessing exitcode is insufficiently documented

2022-01-18 Thread Eryk Sun
Eryk Sun added the comment: PR 30142 is sufficient for Unix, but it's missing a bit for Windows. In Windows, the C runtime library maps the console event for Ctrl+Break to SIGBREAK. The default handler for SIGBREAK exits with 0xC13A (i.e. STATUS_CONTROL_C_EXIT). This value is unre

[issue45554] multiprocessing exitcode is insufficiently documented

2022-01-18 Thread Eryk Sun
Change by Eryk Sun : -- stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue45554> ___ ___ Python-bugs-

[issue46454] '0 -> /dev/null' is lost

2022-01-22 Thread Eryk Sun
Eryk Sun added the comment: > If some one closes fd 0, then he reopens it. it will not be inherited. In Windows, when a console process spawns a child console process without enabling handle inheritance -- e.g. subprocess.Popen(['python.exe']) -- the OS will manually duplicate

[issue46490] Add "follow_symlinks=False" support for "os.utime()" on Windows

2022-01-23 Thread Eryk Sun
Eryk Sun added the comment: The Windows API doesn't directly support opening a 'symlink' as Python defines it for the follow_symlinks parameter. That problem should be resolved in a separate issue. Then updating os.utime() would be relatively trivial. -- components

[issue45382] platform() is not able to detect windows 11

2022-01-24 Thread Eryk Sun
Eryk Sun added the comment: > It's *very* unlikely you'll ever get output that doesn't fit into MBCS, When writing to a pipe, wmic.exe hard codes using the process OEM code page (i.e. CP_OEMCP). If it matters, running wmic.exe with subprocess should use encoding='oe

[issue46506] [Windows] wrap CreateFile to support follow_symlinks

2022-01-24 Thread Eryk Sun
New submission from Eryk Sun : Issue 46490 proposes to support follow_symlinks in os.utime() on Windows. Instead of duplicating the os.stat() implementation of follow_symlinks, I suggest factoring out a common _Py_CreateFile() function with two additional parameters: traverse (input) and

[issue46490] Add "follow_symlinks=False" support for "os.utime()" on Windows

2022-01-24 Thread Eryk Sun
Change by Eryk Sun : -- dependencies: +[Windows] wrap CreateFile to support follow_symlinks ___ Python tracker <https://bugs.python.org/issue46490> ___ ___ Pytho

[issue45382] platform() is not able to detect windows 11

2022-01-25 Thread Eryk Sun
Eryk Sun added the comment: > Bit wmic seems nice solution. > Is still working for windows lower than 11? wmic.exe is still included in Windows 10 and 11, but it's officially deprecated [1], which means it's no longer being actively developed, and it might be removed in

[issue45382] platform() is not able to detect windows 11

2022-01-25 Thread Eryk Sun
Eryk Sun added the comment: > sys.getwindowsversion() which exposes GetVersionEx() looks fine to me. In Windows 8+, sys.getwindowsversion() returns a version that can vary from 6.2.9200 (Windows 8) up to the actual OS version. It depends on the OS versions supported by the applicat

[issue45382] platform() is not able to detect windows 11

2022-01-26 Thread Eryk Sun
Eryk Sun added the comment: > AFAIK, the Win32_OperatingSystem caption is always ASCII. I think I was wrong here. The "Caption" field is localized, so the wmic.exe OEM encoded output to a pipe isn't reliable. The system OEM code page doesn't necessarily match the dis

[issue46454] '0 -> /dev/null' is lost

2022-01-26 Thread Eryk Sun
Eryk Sun added the comment: > stdin is closed > os.open() is called and creates a new fd=0 > a call to os.dup2(fd, 0) is made but is a noop The dup2() silent noop case is a problem, but not the problem that's reported in msg43. The two examples for this issue are fd.py

[issue46506] [Windows] wrap CreateFile to support follow_symlinks

2022-01-26 Thread Eryk Sun
Eryk Sun added the comment: > switch to the newer CreateFile2() function Apparently we need to allow FILE_SHARE_READ if CreateFile2() is used to implement os.stat(). It's not a big deal, but this is a design flaw. CreateFile2() always uses the kernel I/O flag FILE_DISALLOW_EXCL

[issue46506] [Windows] wrap CreateFile to support follow_symlinks

2022-01-26 Thread Eryk Sun
Eryk Sun added the comment: Here's an implementation of _Py_CreateFile2() and win32_xstat_impl(): typedef struct { DWORD type; DWORD attributes; DWORD reparseTag; } _PY_CREATE_FILE_INFO; static HANDLE _Py_CreateFile2(LPCWSTR lpFileName, DWORD dwDesiredA

[issue46550] __slots__ updates despite being read-only

2022-01-27 Thread Eryk Sun
Eryk Sun added the comment: Please read about augmented assignment [1]. In the REPL, use help("+="). An augmented assignment evaluates the target (which, unlike normal assignment statements, cannot be an unpacking) and the expression list, performs the binary operation s

[issue46454] '0 -> /dev/null' is lost

2022-01-27 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg411776 ___ Python tracker <https://bugs.python.org/issue46454> ___ ___ Python-bugs-list mailin

[issue46454] '0 -> /dev/null' is lost

2022-01-27 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg411287 ___ Python tracker <https://bugs.python.org/issue46454> ___ ___ Python-bugs-list mailin

[issue46550] __slots__ updates despite being read-only

2022-01-28 Thread Eryk Sun
Eryk Sun added the comment: If the target object of an augmented assignment doesn't support the in-place binary operation, the normal binary operation is used instead. Thus an augmented assignment is implemented to always assign the result back to the target. For an attribute, t

[issue46572] Unicode identifiers not necessarily unique

2022-01-29 Thread Eryk Sun
Eryk Sun added the comment: Please read "Identifiers and keywords" [1] in the documentation. For example: >>> import unicodedata as ud >>> ud.normalize('NFKC', '𝖇𝖆𝖗') == 'bar' True >>> c = '\N{CYRILLIC

[issue29688] Add support for Path.absolute()

2022-01-29 Thread Eryk Sun
Eryk Sun added the comment: In Windows, paths that are relative to the current directory on a drive aren't resolved. The following should be resolved by the current code: >>> os.chdir('C:/Temp') >>> pathlib.Path('C:').absolute() Windows

[issue44264] Add descriptive error message when environment variable not detected

2022-01-29 Thread Eryk Sun
Eryk Sun added the comment: This is just a point of clarification. > my del did not change the environment variable os.environ defines the __delitem__ method to call C unsetenv(). Thus `del os.environ[varname]` does unset the environment variable, at least at the level of the C runt

[issue46582] Windows builds fail: fatal error RC1116: RC terminating after preprocessor errors

2022-01-30 Thread Eryk Sun
Eryk Sun added the comment: PR 29396 and PR 29501 didn't get backported to 3.8 in November. Probably that was intentional since 3.8 only gets security fixes since 3.8.10, which was released in May. Supporting a newer build environment isn't a security issue. A core developer cou

[issue46585] Should we re-export `PyObj_FromPtr` in `ctypes`?

2022-01-30 Thread Eryk Sun
Eryk Sun added the comment: Alternatively, one can cast the address to py_object and dereference its `value`. For example: >>> obj = bytearray(b'spam') >>> sys.getrefcount(obj) 2 >>> obj2 = ctypes.cast(id(obj), ctypes.py_objec

[issue46578] cant DEBUG os.spawnv()

2022-01-30 Thread Eryk Sun
Eryk Sun added the comment: > cmd310 = ["/LIBPATH:D:\\python310\\lib\\site-packages\\torch\\lib", The `argv` parameter of os.spawnv() should begin with a command name to ensure that the application parses its command-line correctly. This doesn't necessarily have to be a f

[issue46555] Unicode-mangled names refer inconsistently to constants

2022-01-30 Thread Eryk Sun
Eryk Sun added the comment: Why was it decided to not raise a syntax error when the NFKC normalization of a non-ASCII token matches a keyword? I don't see a use for cases such as `𝕚𝕗 = 1` and `𝕚𝕗 + 1`. It seems the cost in terms of confusion far outweighs any potential be

[issue29688] Add support for Path.absolute()

2022-01-31 Thread Eryk Sun
Eryk Sun added the comment: > I'm not seeing what's wrong with your example. "C:" or "C:spam\\eggs" are not absolute paths. They depend on the effective working directory on the drive. An absolute path should never depend on a working directory, wh

[issue29688] Add support for Path.absolute()

2022-01-31 Thread Eryk Sun
Change by Eryk Sun : -- Removed message: https://bugs.python.org/msg412220 ___ Python tracker <https://bugs.python.org/issue29688> ___ ___ Python-bugs-list mailin

[issue29688] Add support for Path.absolute()

2022-01-31 Thread Eryk Sun
Eryk Sun added the comment: > I'm not seeing what's wrong with your example. "C:" or "C:spam\\eggs" are not absolute paths. They depend on the effective working directory on the drive. An absolute path should never depend on a working directory, wh

[issue29688] Add support for Path.absolute()

2022-01-31 Thread Eryk Sun
Eryk Sun added the comment: > I'd imagine that bug is reproducible with `Path('C:\\Temp', 'C:')` > already, right? If that's the case, should it logged as a > separate issue? Yes, it's a separate issue that affects the _from_parts() call in ab

[issue46594] Windows "Edit with IDLE >" only has one selection

2022-01-31 Thread Eryk Sun
Eryk Sun added the comment: Check your settings in the registry. In "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts" there should be a ".py" key, but not necessarily. It should have an "OpenWithList" subkey that contains an "MRUList&qu

[issue46594] Windows "Edit with IDLE >" only has one selection

2022-02-01 Thread Eryk Sun
Eryk Sun added the comment: > the Open With entries may not be being merged. That would probably be a bug in the Windows shell API. The HKCU and HKLM subkeys of "Software\Classes\Python.File\Shell\editwithidle\shell" are merged in the HKCR view. The same key path can exist

[issue46490] Add "follow_symlinks=False" support for "os.utime()" on Windows

2022-02-02 Thread Eryk Sun
Eryk Sun added the comment: In case you missed it, I implemented _Py_CreateFile2() in bpo-46506 and rewrote os.stat() based on it. Check it out in case you're interested in moving forward with a PR in bpo-46506. For this issue, follow_symlinks is fairly simple to support

[issue46631] Implement a "strict" mode for getpass.getuser()

2022-02-03 Thread Eryk Sun
New submission from Eryk Sun : getpass.getuser() checks the environment variables LOGNAME (login name), USER, LNAME, and USERNAME, in that order. In Windows, LOGNAME, USER, and LNAME have no conventional usage. I think there should be a strict mode that restricts getuser() to check only

[issue46631] Implement a "strict" mode for getpass.getuser()

2022-02-04 Thread Eryk Sun
Eryk Sun added the comment: Here's an example for the suggested changes to _winapi. Include these headers: #include // LsaGetLogonSessionData #include // STATUS_SUCCESS Add these argument-clinic macros to _winapi_functions: _WINAPI_GETCURRENTPROCESSTOKEN_METH

[issue46654] file_open doesn't handle UNC paths produced by pathlib's resolve() (but can handle UNC paths with additional slashes)

2022-02-05 Thread Eryk Sun
Eryk Sun added the comment: Builtin open() calls C open(). This C function supports whatever path types are supported natively. In Windows, C open() calls WinAPI CreateFileW(), which does not support "file://" URIs. The Windows API handles it as a relative path, which gets resolv

[issue46654] file_open doesn't handle UNC paths produced by pathlib's resolve() (but can handle UNC paths with additional slashes)

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

[issue46654] urllib.request.urlopen doesn't handle UNC paths produced by pathlib's resolve() (but can handle UNC paths with additional slashes)

2022-02-05 Thread Eryk Sun
Eryk Sun added the comment: In FileHandler.file_open(), req.host is the host name, which is either None or an empty string for a local drive path such as, respectively, "file:/Z:/test.py" or "file:///Z:/test.py". The value of req.selector never starts with "//"

[issue46654] urllib.request.urlopen doesn't handle UNC paths produced by pathlib's resolve() (but can handle UNC paths with additional slashes)

2022-02-05 Thread Eryk Sun
Eryk Sun added the comment: > file://server/host/file.ext on windows, even though > file:server/host/file.ext open just fine. For r"\\host\share\test.py", the two slash conversion "file://host/share/test.py" is correct according to RFC80889 "E.3.1. UR

[issue46654] urllib.request.urlopen doesn't handle UNC paths produced by pathlib's as_uri() (but can handle UNC paths with additional slashes)

2022-02-06 Thread Eryk Sun
Eryk Sun added the comment: > The value of req.selector never starts with "//", for which file_open() > checks, but rather a single slash, such as "/Z:/test.py" or > "/share/test.py". To correct myself, actually req.selector will start with &qu

[issue46654] urllib.request.urlopen doesn't handle UNC paths produced by pathlib's as_uri() (but can handle UNC paths with additional slashes)

2022-02-06 Thread Eryk Sun
Change by Eryk Sun : -- assignee: docs@python -> components: -2to3 (2.x to 3.x conversion tool), Argument Clinic, Build, C API, Cross-Build, Demos and Tools, Distutils, Documentation, Extension Modules, FreeBSD, IDLE, IO, Installation, Interpreter Core, Parser, Regular Expressi

[issue46668] encodings: the "mbcs" alias doesn't work

2022-02-06 Thread Eryk Sun
Eryk Sun added the comment: > The Python 3.6 and 3.7 "codecs.register(_alias_mbcs)" doesn't work > because "search_function()" is tested before and it works for "cpXXX" > encodings. Isn't the 3.6-3.10 ordering of search_function() and _

[issue46668] encodings: the "mbcs" alias doesn't work

2022-02-07 Thread Eryk Sun
Eryk Sun added the comment: > I don't think that this fallback is needed anymore. Which Windows > code page can be used as ANSI code page which is not already > implemented as a Python codec? Python has full coverage of the ANSI and OEM code pages in the standard Windows

[issue46659] Deprecate locale.getdefaultlocale() function

2022-02-08 Thread Eryk Sun
Eryk Sun added the comment: > getdefaultlocale() falls back to LANG and LANGUAGE. _Py_SetLocaleFromEnv(LC_CTYPE) (e.g. setlocale(LC_CTYPE, "")) gets called at startup, except for the isolated configuration [1]. I think calendar.Locale*Calendar should try the LC_CTYPE locale if L

[issue46659] Deprecate locale.getdefaultlocale() function

2022-02-08 Thread Eryk Sun
Eryk Sun added the comment: > Oh. Serhiy asked me to use LC_TIME rather than LC_CTYPE. Since Locale*Calendar is documented as not being thread safe, __init__() could get the real default via setlocale(LC_TIME, "") when locale=None and the current LC_TIME is "C". Resto

[issue46686] [venv / PC/launcher] issue with a space in the installed python path

2022-02-08 Thread Eryk Sun
Eryk Sun added the comment: run_child() expects `cmdline` to be correctly quoted, and normally it is. I can't reproduce this problem with Python 3.10.2. I created a user account with a space in the account name, logged on, and installed 3.10.2 for the current user, with the option en

[issue46686] [venv / PC/launcher] issue with a space in the installed python path

2022-02-08 Thread Eryk Sun
Eryk Sun added the comment: I checked the source code in PC/launcher.c process(). It turns out that `executable` is not getting quoted in the venv launcher case. CreateProcessW() tries to get around this. If the command isn't quoted, it has a loop that consumes up to a space (or tab

[issue46686] [venv / PC/launcher] issue with a space in the installed python path

2022-02-08 Thread Eryk Sun
Eryk Sun added the comment: The venv launcher can quote the executable path either always or only when it contains spaces. The following is a suggestion for implementing the latter. Before allocating `executable`, use memchr() (include ) to search the UTF-8 source for a space. If found

[issue46697] _ctypes_simple_instance returns inverted logic

2022-02-09 Thread Eryk Sun
Change by Eryk Sun : -- stage: -> patch review versions: -Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue46697> ___ ___ Python-

[issue46703] boolean operation issue (True == False == False)

2022-02-09 Thread Eryk Sun
Eryk Sun added the comment: > True == False == False is really True == False and False == False > wich is False and True which is False Moreover, since the left-hand comparison is `True == False`, which evaluates to False, the right-hand comparison doesn't even get evaluate

[issue46716] regrtest didn't respect the timeout when running test_subprocess on AMD64 Windows11 3.x

2022-02-11 Thread Eryk Sun
Eryk Sun added the comment: > test_call_timeout() or test_timeout() in test_subprocess.py. These tests don't override the standard files, and they only spawn a single child with no descendants. I don't see why this would hang. It shouldn't be a problem with leaked pip

[issue46726] Thread spuriously marked dead after interrupting a join call

2022-02-12 Thread Eryk Sun
Eryk Sun added the comment: > The race on := is much smaller than the original race > and I suspect in practice will be very hard to hit. In Windows, the acquire() method of a lock can't be interrupted. Thus, in the main thread, an exception from Ctrl+C gets raised as soon

[issue46726] Thread spuriously marked dead after interrupting a join call

2022-02-12 Thread Eryk Sun
Eryk Sun added the comment: > If the acquire() in fact times out, but the store to the `acquired` > variable is interrupted, `if _WINDOWS and acquired is None` will > succeed, despite that the lock is still locked Yeah, my proposed workaround is no good, so we can't resolve

[issue46726] Thread spuriously marked dead after interrupting a join call

2022-02-12 Thread Eryk Sun
Eryk Sun added the comment: > Wrap everything needed in a custom C function. Maybe add an `acquire_and_release()` method: static PyObject * lock_PyThread_acquire_and_release_lock( lockobject *self, PyObject *args, PyObject *kwds) { _PyTime_t time

[issue46716] regrtest didn't respect the timeout when running test_subprocess on AMD64 Windows11 3.x

2022-02-13 Thread Eryk Sun
Eryk Sun added the comment: > the fix should be as simple as coercing the timeout values to >= 0. Popen._remaining_time() should return max(endtime - _time(), 0). Popen._wait() should raise OverflowError if the timeout is too large for the implementation. In Windows, the upper li

[issue46726] Thread spuriously marked dead after interrupting a join call

2022-02-13 Thread Eryk Sun
Eryk Sun added the comment: > is there a bulletproof way to guarantee that `self._stop()` gets > called if the acquire_and_release() succeeds? I don't think it's critical. But we still should deal with the common case in Windows in which a KeyboardInterrupt is raised immed

[issue46726] Thread spuriously marked dead after interrupting a join call

2022-02-13 Thread Eryk Sun
Eryk Sun added the comment: > Anything at the Python level that cares whether the thread is > still alive will call _wait_for_tstate_lock() again It's nice that _maintain_shutdown_locks() gets called in _stop(), but the more important call site is in _set_tstate_lock(). I t

[issue46726] Thread spuriously marked dead after interrupting a join call

2022-02-13 Thread Eryk Sun
Eryk Sun added the comment: > I didn't have that in mind at all. I understood what you had in mind, and I don't disagree. I was just highlighting that the only somewhat important work done in _stop() is to clean up the _shutdown_locks set, to keep it from growing too large. But

[issue46716] regrtest didn't respect the timeout when running test_subprocess on AMD64 Windows11 3.x

2022-02-14 Thread Eryk Sun
Eryk Sun added the comment: > I fear the potential 3rd-party breakage alone should bump > this to its own issue. The change to the DWORD converter in _winapi should only be in 3.11+. If this causes problems for other projects, they're probably depending on undefined behavior in t

[issue46716] regrtest didn't respect the timeout when running test_subprocess on AMD64 Windows11 3.x

2022-02-14 Thread Eryk Sun
Eryk Sun added the comment: > 4) use Job objects to group Windows processes for termination I think a separate issue should be created for this enhancement. _winapi wrappers would be needed for CreateJobObjectW(), SetInformationJobObject(), AssignProcessToJobObject(), TerminatejobObj

  1   2   3   4   5   6   7   8   9   10   >