[issue8847] crash appending list and namedtuple

2010-05-28 Thread benrg
New submission from benrg benrud...@gmail.com: c:\python Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. from collections import namedtuple foo = namedtuple('foo', '') [1] + foo

[issue5391] mmap: read_byte/write_byte and object type

2010-10-16 Thread benrg
benrg benrud...@gmail.com added the comment: With this patch, read_byte returns an integer in the range -128 to 127 instead of 0 to 255 if char is signed. Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 is affected by this. I think it is a bug. The test

[issue11427] ctypes from_buffer no longer accepts bytes

2011-03-06 Thread benrg
New submission from benrg benrud...@gmail.com: In Python 3.1.3, (c_char*5).from_buffer(b'abcde') worked. In 3.2 it fails with TypeError: expected an object with a writable buffer interface. This seems to represent a significant decrease in the functionality of ctypes, since, if I understand

[issue11428] with statement looks up __exit__ incorrectly

2011-03-06 Thread benrg
New submission from benrg benrud...@gmail.com: class MakeContextHandler: def __init__(self, enter, exit): self.__enter__ = enter self.__exit__ = exit with MakeContextHandler(lambda: None, lambda *e: None): pass In 3.1.3 this worked; in 3.2 it raises AttributeError('__exit__'), which

[issue8847] crash appending list and namedtuple

2011-03-06 Thread benrg
benrg benrud...@gmail.com added the comment: The bug is still present in 3.2. -- versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8847

[issue11429] ctypes is highly eclectic in its raw-memory support

2011-03-06 Thread benrg
New submission from benrg benrud...@gmail.com: ctypes accepts bytes objects as arguments to C functions, but not bytearray objects. It has its own array types but seems to be unaware of array.array. It doesn't even understand memoryview objects. I think that all of these types should

[issue11430] can't change the sizeof a Structure that doesn't own its buffer

2011-03-07 Thread benrg
New submission from benrg benrud...@gmail.com: A struct that is resized knows its new size; among other things, the new size is returned by sizeof. But it seems to be impossible to increase the size of a struct that doesn't own its buffer. resize fails in this case. This would not be too bad

[issue11428] with statement looks up __exit__ incorrectly

2011-03-07 Thread benrg
benrg benrud...@gmail.com added the comment: But when I translate my example according to PEP 343, it works (i.e., doesn't raise an exception) in 3.2, and PEP 343 says [t]he details of the above translation are intended to prescribe the exact semantics. So I think that at least one of PEP 343

[issue2405] Drop w9xpopen and all dependencies

2011-03-07 Thread benrg
benrg benrud...@gmail.com added the comment: w9xpopen is currently used on NT. The patch to use it on NT was checked in by bquinlan in August of 2001 (http://mail.python.org/pipermail/patches/2001-August/005719.html). He claims that it is necessary in NT, even though (a) the cited knowledge

[issue2405] Drop w9xpopen and all dependencies

2011-03-07 Thread benrg
benrg benrud...@gmail.com added the comment: It turns out that, on Windows 7 32-bit with COMSPEC pointing to command.com, platform.popen('dir').read() works with w9xpopen and fails (no output) without it. But the reason has nothing to do with the old Win9x problem. It's because subprocess

[issue11427] ctypes from_buffer no longer accepts bytes

2011-11-29 Thread benrg
benrg benrud...@gmail.com added the comment: I am still interested in this for the same reason I was interested in this in the first place; nothing has changed. I guess I will reiterate, and try to expand. The problem is that ctypes tries to enforce const correctness (inconsistently

[issue16701] Docs missing the behavior of += (in-place add) for lists.

2013-01-23 Thread benrg
benrg added the comment: This is bizarre: Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. x = y = [1, 2] x += [3] y [1, 2, 3] x = y = {1, 2} x -= {2} y {1} Since when has

[issue16701] Docs missing the behavior of += (in-place add) for lists.

2013-01-23 Thread benrg
benrg added the comment: As far as I know Ezio is correct, when possible means when the target is mutable. The documentation should probably be clarified on that point. Yes, it needs to be made very, very clear in the documentation. As I said, I'm not aware of any other language in which

[issue16701] Docs missing the behavior of += (in-place add) for lists.

2013-01-24 Thread benrg
benrg added the comment: AFAIK in C x += 1 is equivalent to x++, and both are semantically more about incrementing (mutating) the value of x than about creating a new value that gets assigned to x. Likewise it seems to me more natural to interpret x += y as add the value of y to the object x

[issue32525] Empty tuples are not optimized as constant expressions

2018-01-09 Thread benrg
New submission from benrg <benrud...@gmail.com>: >From 3.3 on, the expression () is compiled to BUILD_TUPLE 0 instead of >LOAD_CONST. That's probably fine and I suppose it's slightly more efficient to >avoid adding an entry to the constant table. The problem is tha

[issue32612] pathlib.(Pure)WindowsPaths can compare equal but refer to different files

2018-01-21 Thread benrg
New submission from benrg <benrud...@gmail.com>: (Pure)WindowsPath uses str.lower to fold paths for comparison and hashing. This doesn't match the case folding of actual Windows file systems. There exist WindowsPath objects that compare and hash equal, but refer to different

[issue32612] pathlib.(Pure)WindowsPaths can compare equal but refer to different files

2018-01-22 Thread benrg
benrg <benrud...@gmail.com> added the comment: This bug is about paths that compare *equal*, but refer to *different* files. I agree that the opposite is not much of a problem (and I said so in the original comment). The reason I classified this as a security bug is that Python scripts

[issue32612] pathlib.(Pure)WindowsPaths can compare equal but refer to different files

2018-01-23 Thread benrg
benrg <benrud...@gmail.com> added the comment: I don't know whether this clarifies it at all, but if x and y are Path objects, and x == y, I would expect also x.exists() == y.exists(), and x.read_bytes() == y.read_bytes(), and so on, unless there is a race condition. I think all progr

[issue42627] urllib.request.getproxies() misparses Windows registry proxy settings

2020-12-12 Thread benrg
New submission from benrg : If `HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer` contains the string `http=host:123;https=host:456;ftp=host:789`, then getproxies_registry() should return {'http': 'http://host:123', 'https': 'http://host:456', 'ftp': 'http

[issue46842] py to pyc location mapping with sys.pycache_prefix isn't 1-to-1 on Windows

2022-02-23 Thread benrg
New submission from benrg : `importlib._bootstrap_external` contains this comment: # We need an absolute path to the py file to avoid the possibility of # collisions within sys.pycache_prefix [...] # [...] the idea here is that if we get `Foo\Bar`, we first # make it absolute

[issue46848] Use optimized string search function in mmap.find()

2022-02-24 Thread benrg
benrg added the comment: memmem isn't a standard C function, and some libraries don't have it, notably Microsoft's. newlib's memmem seems to be the same as glibc's, but is under a BSD 3-clause license instead of LGPL. An older version of newlib's memmem (prior to 2019-01-01) has

[issue46858] mmap constructor resets the file pointer on Windows

2022-02-25 Thread benrg
New submission from benrg : On Windows, `mmap.mmap(f.fileno(), ...)` has the undocumented side effect of setting f's file pointer to 0. The responsible code in mmapmodule is this: /* Win9x appears to need us seeked to zero */ lseek(fileno, 0, SEEK_SET); Win9x is no longer supported

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

2022-02-25 Thread benrg
New submission from benrg : On Windows, if one writes env = os.environ.copy() env['http_proxy'] = 'whatever' or either of the documented equivalents ({**os.environ, ...} or (os.environ | {...})), and passes the resulting environment to subprocess.run or subprocess.Popen, the spawned

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

2022-02-25 Thread benrg
New submission from benrg : The Windows functions that deal with environment variables are case-insensitive and case-preserving, like most Windows file systems. Many environment variables are conventionally written in all caps, but others aren't, such as `ProgramData`, `PSModulePath

[issue46791] Allow os.remove to defer to rmdir

2022-02-28 Thread benrg
benrg added the comment: The REMOVE_DIR case reduces to return RemoveDirectoryW(path->wide) ? 0 : -1; so I think there's no reason to combine it with the other two. The REMOVE_BOTH case is attrs = GetFileAttributesW(path->wide); if (attrs != INVALID_FILE_ATTRIBUTES &am

[issue46868] Improve performance of math.prod with bignums (and functools.reduce?)

2022-02-28 Thread benrg
benrg added the comment: Anything that produces output of O(m+n) size in O(m+n) time. Ordered merging operations. Mergesort is a binary ordered merge with log-depth tree reduction, and insertion sort is the same binary operation with linear-depth tree reduction. Say you're merging sorted

[issue46868] Improve performance of math.prod with bignums (and functools.reduce?)

2022-02-28 Thread benrg
benrg added the comment: >That memory frugality adds a log2 factor to the runtime. Your iterative algorithm is exactly the one I had in mind, but it doesn't have the run time that you seem to think. Is that the whole reason for our disagreement? It does only O(1) extra work (not e

[issue46868] Improve performance of math.prod with bignums (and functools.reduce?)

2022-02-26 Thread benrg
New submission from benrg : math.prod is slow at multiplying arbitrary-precision numbers. E.g., compare the run time of factorial(5) to prod(range(2, 50001)). factorial has some special-case optimizations, but the bulk of the difference is due to prod evaluating an expression tree

[issue46868] Improve performance of math.prod with bignums (and functools.reduce?)

2022-02-27 Thread benrg
benrg added the comment: My example used ints, but I was being deliberately vague when I said "bignums". Balanced-tree reduction certainly isn't optimal for ints, and may not be optimal for anything, but it's pretty good for a lot of things. It's the comparison-based sorting of

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

2022-02-26 Thread benrg
benrg added the comment: This issue should be marked dependent on issue 43702 or issue 46862, since fixing it could break third-party code unless they're fixed first. > Given 'nt.environ' is available without case remapping, I think that's the > best workaround. Right now, it's not