[issue25631] Segmentation fault with invalid Unicode command-line arguments in embedded Python

2015-11-16 Thread Eryk Sun
Eryk Sun added the comment: The interpreter isn't initialized, so calling PyErr_Format in a release build segfaults when it tries to dereference a NULL PyThreadState. OTOH, a debug build should call PyThreadState_Get, which in this case calls Py_FatalError and aborts the process

[issue25659] ctypes.Array.from_buffer segmentation fault when trying to create from array.array

2015-11-18 Thread Eryk Sun
Eryk Sun added the comment: You have to subclass ctypes.Array with a _type_ and _length_. But ctypes types also implement sequence repetition (*) to facilitate creating array types. For example: import array, ctypes a1 = array.array('l') a1.fromlist(range(10)) c1

[issue25639] open 'PhysicalDriveN' on windows fails (since python 3.5) with OSError: [WinError 1] Incorrect function

2015-11-16 Thread Eryk Sun
Eryk Sun added the comment: As a workaround you can open a file descriptor via os.open: >>> import os >>> fd = os.open(r'\\.\PhysicalDrive0', os.O_RDONLY | os.O_BINARY) >>> os.read(fd, 512)[:8] b'3\xc0\x8e\xd0\xbc\x00|\x8e' > _Py_fstat result not

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-02 Thread Eryk Sun
Eryk Sun added the comment: Based on matplotlib's win32InstalledFonts function [1], I created a small test to check the data strings returned by winreg.EnumValue for the presence of null characters. I tested on Windows 7 and 10 but couldn't reproduce the problem. Please run nullcheck.py

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-02 Thread Eryk Sun
Eryk Sun added the comment: You should be able to run nullcheck.py in the command prompt by changing to the directory where it's saved and entering nullcheck.py. For example, if you saved it in your Downloads folder: >cd /d C:\Users\Anshul\Downloads >nullcheck.py If that

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-02 Thread Eryk Sun
Eryk Sun added the comment: I only wrote it for Python 3, but it would be interesting to see what you get with Python 2. Please try nullcheck2.py. -- Added file: http://bugs.python.org/file41213/nullcheck2.py ___ Python tracker <

[issue25731] Assigning and deleting __new__ attr on the class does not allow to create instances of this class

2015-12-01 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: -- nosy: +benjamin.peterson, twouters ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-03 Thread Eryk Sun
Eryk Sun added the comment: REG_SZ and REG_EXPAND_SZ are documented as null-terminated strings [1], which shouldn't have an embedded null character. As such, the default result in the high-level environment of Python shouldn't have embedded nulls. However, since the buffer is sized, I think

[issue25794] __setattr__ does not always overload operators

2015-12-04 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: Removed file: http://bugs.python.org/file41235/issue25794_1.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25794] __setattr__ does not always overload operators

2015-12-04 Thread Eryk Sun
Eryk Sun added the comment: Normally Python code calls built-in setattr, which calls the C API PyObject_SetAttr. This API interns the attribute name before calling the type's tp_setattro or tp_setattr function. Interning the string is a critical step, since the implementation for updating

[issue25794] __setattr__ does not always overload operators

2015-12-04 Thread Eryk Sun
Eryk Sun added the comment: This updated patch calls PyUnicode_Check to ensure the name is a string before calling PyUnicode_InternInPlace. -- Added file: http://bugs.python.org/file41236/issue25794_2.patch ___ Python tracker <rep...@bugs.python.

[issue25789] py launcher stderr is not piped to subprocess.Popen.stderr

2015-12-04 Thread Eryk Sun
Eryk Sun added the comment: Patch 2 additionally modifies run_child to call exit() instead of ExitProcess. For example: >>> import os, subprocess >>> os.environ['PYLAUNCH_DEBUG'] = '1' >>> p = subprocess.Popen(r'py -3 -c ""', stderr=sub

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-03 Thread Eryk Sun
Eryk Sun added the comment: > add a QueryRawValue[Ex] function Or QueryValueEx and EnumValue could take a boolean argument named "raw" or "binary", which if True forces the data to be returned as REG_BINARY regardles

[issue25803] pathlib.Path('/').mkdir() raises wrong error type

2015-12-05 Thread Eryk Sun
Eryk Sun added the comment: The mkdir method needs a fix similar to what was done for issue 25583. For example, currently on Windows the exist_ok option doesn't handle the PermissionError raised when [accidentally] trying to create the root directory: >>> pathlib.Path('C:

[issue25815] Improper subprocess output of arguments with braces in them on windows

2015-12-06 Thread Eryk Sun
Eryk Sun added the comment: Using the cmd shell's "echo" command requires shell=True. You must have an "echo.exe" somewhere in your PATH. Check "where echo" in cmd. -- nosy: +eryksun ___ Python tracker

[issue25815] Improper subprocess output of arguments with braces in them on windows

2015-12-06 Thread Eryk Sun
Eryk Sun added the comment: AFAICT, there's no place where subprocess.Popen would be responsible for removing braces from the output. I think it's something unusual with the "echo.exe" program. In the cmd.exe shell -- i.e. no msys, bash, etc -- what do you get for the following?

[issue25803] pathlib.Path('/').mkdir() raises wrong error type

2015-12-05 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: -- nosy: +pitrou versions: +Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

2015-12-05 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> subprocess failing in GUI applications on Windows ___ Python tracker <rep...@bugs.python.org>

[issue11361] suggestion for os.kill(pid,CTRL_C_EVENT) in tests

2015-12-05 Thread Eryk Sun
Eryk Sun added the comment: test_CTRL_C_EVENT can be removed from Lib/test/test_os.py. It's of no practical consequence. Ctrl+Break is always enabled in the child process, so test_CTRL_BREAK_EVENT should remain. When using CREATE_NEW_PROCESS_GROUP, the child process is started with Ctrl+C

[issue25492] subprocess with redirection fails after FreeConsole

2015-12-05 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: -- resolution: -> duplicate stage: -> resolved status: open -> closed superseder: -> subprocess failing in GUI applications on Windows ___ Python tracker <rep...@bugs.python.org>

[issue13368] Possible problem in documentation of module subprocess, method send_signal

2015-12-04 Thread Eryk Sun
Eryk Sun added the comment: You can send CTRL_C_EVENT to a process group. But it requires the group leader to manually enable Ctrl+C handling. Initially it's disabled when creating a process with CREATE_NEW_PROCESS_GROUP. The attached script demonstrates sending CTRL_C_EVENT to a process

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-03 Thread Eryk Sun
Eryk Sun added the comment: > I don't like the idea of having a mismatch between what we set and > what we get, even if what we're setting technically shouldn't be > allowed. Currently if you set a string with null, you won't see it using either regedit.exe or reg.exe: >

[issue25772] Misleading descriptions about built-in `super.`

2015-12-01 Thread Eryk Sun
Eryk Sun added the comment: > Just FYI, 'super' is not a type No, super is a type: >>> super It's one of 3 types defined in Objects/typeobject.c: PyBaseObject_Type : "object" PyType_Type : "type" PySuper_Type : "super&qu

[issue25778] winreg.EnumValue does not truncate strings correctly

2015-12-02 Thread Eryk Sun
Eryk Sun added the comment: Here's a patch for Python 3 that modifies the Reg2Py function in PC/winreg.c for the case of REG_SZ/REG_EXPAND_SZ. The existing code took a conservative approach by only removing a null character at the end of a buffer. I modified it to use wcsnlen instead. I

[issue25789] py launcher stderr is not piped to subprocess.Popen.stderr

2015-12-03 Thread Eryk Sun
Eryk Sun added the comment: The error() function in PC/launcher.c should call exit(rc) instead of ExitProcess(rc). This allows the CRT to terminate properly and flush the stderr FILE stream. With this change it works as expected: >>> import subprocess >>> p = subpro

[issue23948] Deprecate os.kill() on Windows

2015-12-09 Thread Eryk Sun
Eryk Sun added the comment: The signal module switched to using an enum for signal values: >>> print(*map(repr, sorted(signal.Signals)), sep='\n') We can use the console API when passed the CTRL_C_EVENT or CTRL_BREAK_EVENT enu

[issue25851] installing 3.5 on windows server 2003 x86 R2 Standard Edition Sp2 ENU,

2015-12-12 Thread Eryk Sun
Eryk Sun added the comment: It's the correct behavior. 3.5 supports all versions of Windows that had mainstream or extended support as of its release on 2015-09-13. Windows Server 2003 R2 extended support ended on 2015-07-14 [1]. [1]: https://support.microsoft.com/en-us/lifecycle/search?sort

[issue26004] pip install lifetimes - throwing error and unable to install packages

2016-01-05 Thread Eryk Sun
Eryk Sun added the comment: You can build NumPy with only a C compiler, but it won't have accelerated BLAS/LAPACK. However, lifetimes requires SciPy, which in turn requires Fortran. This is a common requirement with a lot of the scientific-computing stack, so you may as well choose a complete

[issue21579] Python 3.4: tempfile.close attribute does not work

2015-12-30 Thread Eryk Sun
Eryk Sun added the comment: For anyone interested, this issue is solvable on Windows by working around how O_TEMPORARY is implemented. To do this the _winapi module would need a wrapper for SetFileInformationByHandle (available in Vista+), which would need to support at least

[issue25778] winreg.EnumValue does not truncate strings correctly

2016-01-01 Thread Eryk Sun
Eryk Sun added the comment: The current test works for 3.x because we keep the full string length via PyUnicode_AsWideCharString(value, ) when creating a REG_SZ value. OTOH, 2.x Py2Reg gets the length via strlen. I'd prefer to make this consistent with 3.x by using the full string length from

[issue25778] winreg.EnumValue does not truncate strings correctly

2016-01-01 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: Added file: http://bugs.python.org/file41470/issue25778_py36_2.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25778] winreg.EnumValue does not truncate strings correctly

2016-01-01 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: Added file: http://bugs.python.org/file41469/issue25778_py27_1.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25778] winreg.EnumValue does not truncate strings correctly

2016-01-01 Thread Eryk Sun
Eryk Sun added the comment: I've added a patch for 2.7 that updates Py2Reg to use PyString_GET_SIZE instead of strlen and updates Reg2Py to use strnlen instead of returning strings with embedded NULs. -- ___ Python tracker <rep...@bugs.python.

[issue25999] Add support of native number in bin()

2016-01-03 Thread Eryk Sun
Eryk Sun added the comment: bin() returns a Python literal, which thankfully requires an explicit sign. 2's complement literals would be prone to human error. If you want 2's complement, you can write your own function. For example: def mybin(number, nbits=None, *, signed=True

[issue26024] Non-ascii Windows locale names

2016-01-06 Thread Eryk Sun
Eryk Sun added the comment: PyLocale_setlocale in Modules/_localemodule.c is incorrectly passing the locale as a UTF-8 string ("z") instead of using the codepage of the current locale. As you can see below "å" is passed as the UTF-8 string "\xc3\xa5": >&g

[issue26024] Non-ascii Windows locale names

2016-01-06 Thread Eryk Sun
Eryk Sun added the comment: Yes, it's ANSI. I should have said "system locale" instead of "current locale". To find the requested locale, the CRT function __get_qualified_locale calls EnumSystemLocalesA. The passed callback calls GetLocaleInfoA for each enumerated local

[issue24823] ctypes.create_string_buffer does not add NUL if len(init) == size

2016-01-09 Thread Eryk Sun
Eryk Sun added the comment: I didn't want to change the function in lieu of breaking someone's code. If this change is accepted, then it at least needs a documentation note to indicate the new behavior. -- versions: +Python 3.6 -Python 3.4

[issue24823] ctypes.create_string_buffer does not add NUL if len(init) == size

2016-01-09 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- components: +Documentation, Library (Lib) ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue26065] python embedded 3.5 amd64 crash when using venv

2016-01-09 Thread Eryk Sun
Eryk Sun added the comment: 0xC409 (3221226505) is STATUS_STACK_BUFFER_OVERRUN due to the CRT calling __fastfail(FAST_FAIL_FATAL_APP_EXIT) in abort(). This is expected behavior in Windows 8+ [1]. Initially I couldn't reproduce this error because Python found the standard library from

[issue26071] bdist_wininst created binaries fail to start and find 32bit Pythons

2016-01-09 Thread Eryk Sun
Eryk Sun added the comment: I would call SetDllDirectory instead of changing the current directory. This replaces the current directory in the DLL search. Then call SetDllDirectory(NULL) to restore the default before returning. When you say "the CRT assembly", you're tal

[issue26024] Non-ascii Windows locale names

2016-01-09 Thread Eryk Sun
Eryk Sun added the comment: The issue isn't quite the same for 3.5+. The new CRT uses Windows Vista locale APIs. In this case it uses LOCALE_SENGLISHLANGUAGENAME instead of the old LOCALE_SENGLANGUAGE. This maps "Norwegian" to simply "Norwegian" instead o

[issue21579] Python 3.4: tempfile.close attribute does not work

2015-12-21 Thread Eryk Sun
Eryk Sun added the comment: > To extend support for this to Windows, we can add a > feature to mkstmp to not use O_TEMPORARY O_TEMPORARY is only used for NamedTemporaryFile, not mkstemp. Regarding NamedTemporaryFile, that can be worked around to keep Windows from deleting the file

[issue12797] io.FileIO and io.open should support openat

2015-12-22 Thread Eryk Sun
Eryk Sun added the comment: Марк, os.open added dir_fd support in 3.3, which is implemented on POSIX systems by calling openat. The dir_fd parameter is available for many os functions. This is discussed in section 1.5, Files and Directories [1]. It would be nice if we could support dir_fd

[issue25930] os.unlink != os.remove in python3.5

2015-12-22 Thread Eryk Sun
Eryk Sun added the comment: This is due to using argument clinic in Modules/posixmodule.c: /*[clinic input] os.remove = os.unlink builtin_function_or_method instances are equal if m_self (the module in this case) and m_ml->ml_meth (the C function) are the same. In 3.4, the funct

[issue25931] os.fork() command distributed in windows Python27 (in SocketServer module)

2015-12-22 Thread Eryk Sun
Eryk Sun added the comment: Starting a Windows process is expensive. Who not use threading, e.g. SocketServer.ThreadingTCPServer? It seems to me that it's a bug to even define ForkingMixIn, ForkingTCPServer, and ForkingUDPServer on Windows. Those should be conditionally defined depending

[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2015-12-23 Thread Eryk Sun
Eryk Sun added the comment: Considering there's no plan to implement bytes paths for scandir on Windows, then the following line in the os docs needs to be modified: "All functions accepting path or file names accept both bytes and string objects, and result in an object of the same

[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-24 Thread Eryk Sun
Eryk Sun added the comment: psexec.exe can be run from the the live server. >>> subprocess.call(r'\\live.sysinternals.com\tools\psexec.exe -s whoami') PsExec v2.11 - Execute processes remotely Copyright (C) 2001-2014 Mark Russinovich Sysinternals - www.sysinternals.com

[issue25954] Python 3.5.1 installer fails on Windows 7

2015-12-25 Thread Eryk Sun
Eryk Sun added the comment: The main log file reports that installing the CRT exited with the code ERROR_INSTALL_ALREADY_RUNNING (0x652): Another installation is already in progress. Complete that installation before proceeding with this install. You may need to completely

[issue25954] Python 3.5.1 installer fails on Windows 7

2015-12-26 Thread Eryk Sun
Eryk Sun added the comment: Packages are installed from the ProgramData folder on the system volume. For example, the log shows the CRT update executed as follows: "C:\Windows\system32\wusa.exe" "C:\ProgramData\Package Cache\ D4036846864773E3D647F421DFE7F6CA536E307B\

[issue25939] _ssl.enum_certificates() fails with ERROR_ACCESS_DENIED if python.exe run with low integrity level

2015-12-28 Thread Eryk Sun
Eryk Sun added the comment: Testing based on integrity level doesn't require creating a child process. I'm attaching a ctypes-based example that defines a context manager that temporarily sets the integrity level of the current thread's impersonation token. To get the impersonation token, I

[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2015-12-21 Thread Eryk Sun
Eryk Sun added the comment: The ANSI API is problematic because it returns a best-fit encoding to the system codepage. For example: >>> os.listdir('.') ['ƠƨưƸǀLjǐǘǠǨǰǸ'] >>> os.listdir(b'.') [b'O?u?|?iu?Kj?'] To somewhat work around this problem, listdir

[issue25709] Problem with string concatenation and utf-8 cache.

2015-11-23 Thread Eryk Sun
Eryk Sun added the comment: Serhiy, when does sharing UTF-8 data occur in a compact object? It has to be ASCII since non-ASCII UTF-8 isn't sharable, but PyASCIIObject doesn't have the utf8 field. So it has to be a PyCompactUnicodeObject. But isn't ASCII always allocated as a PyASCIIObject? I

[issue25731] Assigning and deleting __new__ attr on the class does not allow to create instances of this class

2015-11-25 Thread Eryk Sun
Eryk Sun added the comment: For "del X.__new__", type_setattro in Objects/typeobject.c indirectly calls update_one_slot. This finds object.__new__ fom the base object class when it looks up __new__ on the type. Since __new__ for built-in types is special-cased to be a built-in meth

[issue25741] Usual Installation Directory

2015-11-28 Thread Eryk Sun
Eryk Sun added the comment: > LOCALAPPDATA is set by the operating system, typically to > C:\Users\\AppData\Local (at least since Vista I > think? Certainly since Win7 Vista introduced LOCALAPPDATA, so there's no problem referencing it in the docs for 3.5+. On a related note

[issue25758] ensurepip/venv broken on Windows if path includes unicode

2015-11-28 Thread Eryk Sun
Eryk Sun added the comment: The problem is that the compile_source function in Modules/zipimport.c calls PyUnicode_EncodeFSDefault to get an encoded string to pass as the filename argument of Py_CompileString. On Windows this uses the ANSI codepage (i.e. 'mbcs'). Apparently your system's ANSI

[issue25763] I cannot use absolute path in sqlite3 , python 2.7.9, windows

2015-11-29 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: -- resolution: -> not a bug stage: -> resolved ___ Python tracker <rep...@bugs.python.org> <http://bugs.

[issue25765] Installation error

2015-11-30 Thread Eryk Sun
Eryk Sun added the comment: > The error code is from Windows Update (which we sometimes need to > run as part of the install), and there's so much spam out there > these days that it is impossible to find out what it means. The error is WU_E_NOT_INITIALIZED [1], "th

[issue25737] array is not a Sequence

2015-11-26 Thread Eryk Sun
Eryk Sun added the comment: This is a duplicate of issue 23864, i.e. only the "one-trick ponies" work: >>> issubclass(array.array, abc.Sized) True >>> issubclass(array.array, abc.Iterable) True >>> issubclass(array.array, abc.Container

[issue25653] ctypes+callbacks+fork+selinux = crash

2015-11-18 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: -- nosy: +eryksun ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25653> ___ __

[issue25678] int() from a buffer reads past the buffer boundaries

2015-11-20 Thread Eryk Sun
Eryk Sun added the comment: I just made a quick modification to check that it works. I'm sure you could do the same. But here it is anyway. -- keywords: +patch Added file: http://bugs.python.org/file41095/issue25678.patch ___ Python tracker <

[issue25678] int() from a buffer reads past the buffer boundaries

2015-11-20 Thread Eryk Sun
Eryk Sun added the comment: > Now we have an example, and can backport that patch. More seriously it's possible to get a buffer over-read using NumPy: >>> import numpy >>> int(buffer(numpy.array('123', dtype='c'))) Traceback (most recent call last):

[issue25678] int() from a buffer reads past the buffer boundaries

2015-11-20 Thread Eryk Sun
Eryk Sun added the comment: > I think the tests should be using buffer(..., a, b) instead. Thanks, you're right. :) -- Added file: http://bugs.python.org/file41102/issue25678_3.patch ___ Python tracker <rep...@bugs.python.org&

[issue25678] int() from a buffer reads past the buffer boundaries

2015-11-20 Thread Eryk Sun
Changes by Eryk Sun <eryk...@gmail.com>: Added file: http://bugs.python.org/file41101/issue25678_2.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue8304] time.strftime() and Unicode characters on Windows

2015-11-22 Thread Eryk Sun
Eryk Sun added the comment: The problem from issue 10653 is that internally the CRT encodes the time zone name using the ANSI codepage (i.e. the default system codepage). wcsftime decodes this string using mbstowcs (i.e. multibyte string to wide-character string), which uses Latin-1 in the C

[issue25709] Problem with string concatenation and utf-8 cache.

2015-11-23 Thread Eryk Sun
Eryk Sun added the comment: > Why do strings cache their UTF-8 encoding? Strings also cache the wide-string representation. For example: from ctypes import * s = '\241\242\243' pythonapi.PyUnicode_AsUnicodeAndSize(py_object(s), None) pythonapi.PyUnicode_AsUTF8AndSize(py_obj

[issue25709] greek alphabet bug it is very disturbing...

2015-11-23 Thread Eryk Sun
Eryk Sun added the comment: unicode_modifiable in Objects/unicodeobject.c should return 0 if there's cached PyUnicode_UTF8 data. In this case PyUnicode_Append won't operate in place but instead concatenate a new string. -- nosy: +eryksun ___ Python

[issue26086] Bug in standardmodule os

2016-01-11 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- components: +Windows nosy: +paul.moore, steve.dower, tim.golden, zach.ware ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue26086] Bug in standardmodule os

2016-01-11 Thread Eryk Sun
Eryk Sun added the comment: The "yield from" syntax was added in Python 3.3, so somehow you're using the 3.5 standard library with either an old 3.x or 2.x version. The older version shouldn't use 3.5's standard library, unless you have either PYTHONHOME or PYTHONPATH defined.

[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-01-11 Thread Eryk Sun
Eryk Sun added the comment: > I strongly recommend people use https://pypi.python.org/pypi/subprocess32/ I think this warrants a note that draws more attention to itself than the "see also" text. -- nosy: +eryksun ___ Python

[issue16192] ctypes - documentation example

2016-06-02 Thread Eryk Sun
Eryk Sun added the comment: > ``sizeof(long double) == sizeof(double)`` it is an alias to > :class:`c_double`. This should be "``sizeof(long) == sizeof(int)`` ... :class:`c_long`". -- resolution: fixed -> stage: resolved ->

[issue27184] Support path objects in the ntpath module

2016-06-02 Thread Eryk Sun
New submission from Eryk Sun: nt is the module name for posixmodule.c on Windows, so I'm changing the title to reference ntpath instead. Regarding nt, two of its built-in functions are exposed directly in ntpath. _isdir is imported as isdir, so it needs a wrapper to support __fspath__. Only

[issue27179] subprocess uses wrong encoding on Windows

2016-06-05 Thread Eryk Sun
Eryk Sun added the comment: > so if we default to UTF-8 it will be even worse than > defaulting to ANSI because there aren't many programs > on Windows which would use UTF-8 I didn't say subprocess should default to UTF-8. What I wish is for Python to default to using UTF-8 for its

[issue27268] Incorrect error message on float('')

2016-06-08 Thread Eryk Sun
Eryk Sun added the comment: > The message comes from Objects/floatobject.c:183 No, in this case the error is set in PyOS_string_to_double in Python/pystrtod.c, because `fail_pos == s`, and it doesn't get replaced in PyFloat_FromString because `end == last`. The format str

[issue27274] [ctypes] Allow from_pointer creation

2016-06-09 Thread Eryk Sun
Eryk Sun added the comment: Probably adding from_pointer is a good idea. That said, there's a simpler way to go about getting a bytes copy for a pointer. Say that you have a pointer p for the following array: >>> a = (c_float * 3)(1, 2, 3) >>> bytes(a) b'\x00\x0

[issue27264] python 3.4 vs. 3.5 strftime same locale different output on Windows

2016-06-09 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- resolution: -> third party stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bu

[issue27264] python 3.4 vs. 3.5 strftime same locale different output on Windows

2016-06-08 Thread Eryk Sun
Eryk Sun added the comment: The universal CRT that's used by 3.5+ implements locales using Windows locale names [1], which were introduced in Vista. Examples for Spanish include 'es', 'es-ES', and 'es-ES_tradnl' . The latter is the traditional sort for Spain, which has the 3-letter

[issue27263] IDLE sets the HOME environment variable breaking scripts

2016-06-07 Thread Eryk Sun
Eryk Sun added the comment: This affects all Tkinter applications on Windows. For example, in Python 2.7: import Tkinter import ctypes libc = ctypes.CDLL('msvcr90') libc.getenv.restype = ctypes.c_char_p >>> libc.getenv(b"HOME") &g

[issue27284] some new stuff

2016-06-10 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bu

[issue27284] some new stuff

2016-06-10 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- Removed message: http://bugs.python.org/msg268100 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27179] subprocess uses wrong encoding on Windows

2016-06-03 Thread Eryk Sun
Eryk Sun added the comment: > I would say almost all Windows console programs does use > console's encoding for input/output because otherwise > user wouldn't be able to read it. While some programs do use the console codepage, even when writing to a pipe or disk file -- such as

[issue27179] subprocess uses wrong encoding on Windows

2016-06-03 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- Removed message: http://bugs.python.org/msg267090 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27179] subprocess uses wrong encoding on Windows

2016-06-03 Thread Eryk Sun
Eryk Sun added the comment: > I would say almost all Windows console programs does use > console's encoding for input/output because otherwise > user wouldn't be able to read it. While some programs do use the console codepage, even when writing to a pipe or disk file -- such as

[issue27184] Support path objects in the ntpath module

2016-06-02 Thread Eryk Sun
Eryk Sun added the comment: Sorry, I must have missed or misunderstood something. PEP 519 discusses modifying os.path. For the os module it only discusses adding fspath and updating fsencode and fsdecode. It also discusses a new PyOS_FSPath C API, but without any discussion regarding its use

[issue27179] subprocess uses wrong encoding on Windows

2016-06-04 Thread Eryk Sun
Eryk Sun added the comment: >> so ANSI is the natural default for a detached process > > To clarify - ANSI is the natural default *for programs that > don't support Unicode*. By natural, I meant in the context of using GetConsoleOutputCP(), since WideCharToMultiByte(0, ..

[issue27318] Add support for symlinks to zipfile

2016-06-14 Thread Eryk Sun
Eryk Sun added the comment: os.symlink needs the target_is_directory argument on Windows. Maybe extract() can search for the link target in namelist() to determine if it's a directory (i.e. ends in "/"). Note that the flag gets set automatically if the target exists, so this is only

[issue27305] Crash with "pip list --outdated" on Windows 10 with Python 2.7.12rc1

2016-06-13 Thread Eryk Sun
Eryk Sun added the comment: I get an access violation due to calling the ASN1_ITEM pointer as a function: > 810: ASN1_ITEM_ptr(method->it))); _ssl!_get_peer_alt_names+0x12a: 7ffe`17b1225a ffd0call

[issue27179] subprocess uses wrong encoding on Windows

2016-06-04 Thread Eryk Sun
Eryk Sun added the comment: Another set of counterexamples are the utilities in the GnuWin32 collection, which use ANSI in a pipe: >>> call('chcp.com') Active code page: 437 0 >>> '¡'.encode('1252') b'\xa1' >>> '\xa1'.encode('437')

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Eryk Sun
Eryk Sun added the comment: > why write `metatype == _Type` rather than > PyType_CheckExact(metatype)`? If only `type` should implement this special case, then it needs to be `metatype == _Type`. This was actually how it was implemented in 2.2a3: https://hg.python.org/cpython/file/

[issue27179] subprocess uses wrong encoding on Windows

2016-06-01 Thread Eryk Sun
Eryk Sun added the comment: There is no right encoding as far as I can see. If it's attached to a console (i.e. conhost.exe), then cmd.exe uses the console's output codepage when writing to a pipe or file, which is the scenario that your patch attempts to address. But if you pass

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- Removed message: http://bugs.python.org/msg266710 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-30 Thread Eryk Sun
Eryk Sun added the comment: > Please treat this as a new feature (just in case) and only > apply it to 3.6. How about changing PyType_CheckExact to PyType_Check for 2.7 and 3.5? It solves the original problem by expanding the single-argument case to metaclasses that aren't an exact in

[issue27157] Unhelpful error message when one calls a subclass of type with a custom metaclass

2016-05-29 Thread Eryk Sun
Eryk Sun added the comment: All types are instances of `type`, so the single argument case makes sense to me as a 'constructor'. It always returns an instance of `type`, just not a new instance. >>> X = type('X', (type,), {}) >>> type(X) >>&g

[issue27048] distutils._msvccompiler._get_vc_env() fails with UnicodeDecodeError if an env var is not encodable

2016-06-17 Thread Eryk Sun
Eryk Sun added the comment: vcvarsall.bat is mostly `set` and `echo` statements, which print using UTF-16LE with "/u". It also runs reg.exe, but with stdout and stderr redirected to nul, so that's no problem. The final `set` command prints cmd's UTF-16LE environment. Using error

[issue27346] Implement os.readv() / os.writev()

2016-06-18 Thread Eryk Sun
Changes by Eryk Sun <eryksun+pyb...@gmail.com>: -- components: +Library (Lib) -Extension Modules ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue27346] Implement os.readv() / os.writev()

2016-06-18 Thread Eryk Sun
Eryk Sun added the comment: ReadFileScatter and WriteFileGather also require a handle for a file that's opened with FILE_FLAG_OVERLAPPED (asynchronous access; the file pointer is not updated) and FILE_FLAG_NO_BUFFERING (buffers must be a multiple of the physical sector size and aligned

[issue26071] bdist_wininst created binaries fail to start and find 32bit Pythons

2016-01-09 Thread Eryk Sun
Eryk Sun added the comment: > We'd have to statically link python##.dll. I was talking about the partially static build that you used for wininst-14.0-amd64.exe in rc3, in which vcruntime is linked statically but ucrt is linked dynamically (actually to the api-ms-win-crt-* API s

[issue26071] bdist_wininst created binaries fail to start and find 32bit Pythons

2016-01-09 Thread Eryk Sun
Eryk Sun added the comment: Steve, I think I understand the linking problem now -- in terms of the bad assumption I mentioned in the previous message. Mark said the "built binary links against the DLL version of the CRT", but I just checked in 3.5.1 that you actually didn't switc

[issue26071] bdist_wininst created binaries fail to start and find 32bit Pythons

2016-01-10 Thread Eryk Sun
Eryk Sun added the comment: > why isn't the directory containing the loaded DLL searched > for dependencies? That's possible. The loader provides several ways to go about solving this problem. The directory of the DLL can be added to the search path if you use LoadLibraryEx with th

[issue26108] Calling PyInitialize with 2.7.11 on Windows x64 terminates process

2016-01-14 Thread Eryk Sun
Eryk Sun added the comment: Probably this is related to issue 25824. When built as a console application and run from the command prompt, you should see an the error ImportError: No module named site If that's the case, the problem is that even the 64-bit build is incorrectly setting

[issue26132] 2.7.11 Windows Installer issues on Win2008R2

2016-01-16 Thread Eryk Sun
Eryk Sun added the comment: Steve, is this something that can only be reproduced on Windows 7/2008 for some reason? My "just for me" installation on Windows 10 seems to work fine. I installed from "python-2.7.11.amd64.msi" with the MD5 sum 25acca42662d4b02682eee0df3f

  1   2   3   4   5   6   7   8   9   10   >