[issue46872] Odd handling of signal raised if an illegal syscall is attempted on Android

2022-02-27 Thread Dan Snider
New submission from Dan Snider : On Android, the following calls generate a SIGSYS signal that is neither blocked by pthread_sigmask(SIG_BLOCK, {SIGSYS}) nor ignored after its handler is set to SIG_IGN: (os.chroot(path)) os.setgid(rgid) os.setuid(ruid) (os.setegid(gid

[issue46791] Allow os.remove to defer to rmdir

2022-02-18 Thread Dan Snider
New submission from Dan Snider : It appears sometime recently-ish that POSIX updated remove to the following: #include int remove(const char *path); If path does not name a directory, remove(path) shall be equivalent to  unlink(path). If path names a directory, remove(path) shall

[issue46350] re.sub, re.Match.expand, etc doesn't allow x, u, U, or N escapes in the template

2022-01-11 Thread Dan Snider
New submission from Dan Snider : The docs use the phrase "unknown escapes of ASCII letters are reserved for future use and treated as errors". That seems ambiguous enough to question why "\x", "\u", "\U", and "\N{}" escapes aren't expanded in

[issue21627] Concurrently closing files and iterating over the open files directory is not well specified

2021-09-17 Thread Dan Snider
Dan Snider added the comment: On Android, if os.close_range closes the file descriptor of the scandir iterator, the interpreter immediately crashes eg: >>> import os >>> os.scandir() >>> os.closerange(3,) fdsan: attempted to close file descriptor 3, expec

[issue44664] builtins.chr and the 'c' format flag raise different errors

2021-07-17 Thread Dan Snider
New submission from Dan Snider : chr (or anything else which calls `PyUnicode_FromOrdinal`) raises ValueError if its argument falls outside the range of valid Unicode code points, while `PyUnicode_FromFormat` raises OverflowError. Shouldn't the latter raise ValueError as well

[issue43947] lambdas stored with assignment expressions are unoptimized

2021-04-26 Thread Dan Snider
New submission from Dan Snider : >>> import dis >>> @dis.dis ... def funcdef(k): return k in {None} ... 2 0 LOAD_FAST 0 (k) 2 LOAD_CONST

[issue43545] Use LOAD_GLOBAL to set __module__ in class def

2021-03-18 Thread Dan Snider
New submission from Dan Snider : Other than obvious performance implications this has, usage of LOAD_NAME makes defining cls.__name__ from within metaclass.__prepare__ difficult. -- messages: 389026 nosy: bup priority: normal severity: normal status: open title: Use LOAD_GLOBAL to set

[issue43436] bounded _lru_cache_wrapprer behaves as if typed=True when it wasn't

2021-03-08 Thread Dan Snider
New submission from Dan Snider : Isn't the point of setting typed=True to make it so that e.g. True doesn't register as a hit when there is already a cache entry for 1.0? Assuming that is the case, although this report specifically targets 3.8 I found no indication that what I believe

[issue43341] functools.partial missing __weakref__ descriptor?

2021-02-27 Thread Dan Snider
New submission from Dan Snider : The only way to lookup weak references to functools.partial objects is with weakref.getweakrefs. I don't know if it's normal for extension types that define tp_weaklistoffset to not add a __weakref__ descriptor, but I figured at the very least a subtype

[issue39528] add "

2020-02-01 Thread Dan Snider
Change by Dan Snider : -- nosy: bup priority: normal severity: normal status: open title: add " ___ Python tracker <https://bugs.python.org/issue39528> ___ ___

[issue39281] The CO_NESTED flag is associated with a significant performance cost

2020-01-09 Thread Dan Snider
New submission from Dan Snider : The title was carefully worded as I have no idea how or why what is happening is happening, only that it has been like this since a least 3.6.0. That version in particular, by the way, is able to execute a call to a python function with 1 argument 25% faster

[issue38689] IDLE crashes when KeyError is raised during calltip generation

2019-11-04 Thread Dan Snider
New submission from Dan Snider : When the following program has been input (into 32 bit 3.8.0 Python running on windows 10), all IDLE processes and windows will immediately and irrevocably hang the instant the open parentheses at the end of the statement "Object(" is rendered

[issue38579] 'u' formatted arrays mostly prevent appends of 4 byte characters

2019-10-24 Thread Dan Snider
New submission from Dan Snider : Unicode characters with code points above u+ can only be added to the end of an array, and only from a call to the "fromunicode" method. This is because "fromunicode" uses a different procedure to modify the array compared to __new__,

[issue38446] Ambiguous signature for builtins.__build_class__

2019-10-11 Thread Dan Snider
New submission from Dan Snider : The function has the following signature documented: __build_class__(func, name, *bases, metaclass=None, **kwds) This implies that `func` and `name` are not positional only parameters when in fact, they are. Another problem with that signature

[issue37367] octal escapes applied inconsistently throughout the interpreter and lib

2019-06-21 Thread Dan Snider
New submission from Dan Snider : At present, the bytecode compiler can generate 512 different unicode characters, one for each integral from the range [0-511), 512 being the total number of syntactically valid permutations of 3 octal digits preceded by a backslash. However, this does

[issue37063] Incorrect application of func.__defaults__ by inspect's signature APIs

2019-05-27 Thread Dan Snider
New submission from Dan Snider : The interpreter matches the values in func.__defaults__ with the calculated positional argument names "right-to-left", while inspect does does so "left-to-right". In every day usage, for "normal" functions, generated by the comp

[issue35331] Incorrect __module__ attribute for _struct.Struct and perhaps a few others

2019-05-23 Thread Dan Snider
Change by Dan Snider : -- nosy: -bup ___ Python tracker <https://bugs.python.org/issue35331> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue35331] Incorrect __module__ attribute for _struct.Struct and perhaps a few others

2019-05-23 Thread Dan Snider
Change by Dan Snider : -- nosy: +bup ___ Python tracker <https://bugs.python.org/issue35331> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue36956] Calling "functions" used to implement generators/comps easily cause crash

2019-05-18 Thread Dan Snider
New submission from Dan Snider : As far as I know, generators, set comprehensions, list comprehensions, and dict comprehensions, (along with their asynchronous variants) are implemented by first calling the GET_(A)ITER opcode and then building and calling a function that acepts the resulting

[issue36846] range_iterator does not use __index__

2019-05-07 Thread Dan Snider
New submission from Dan Snider : I wouldn't even know where to begin to try and find a palatable solution for this that wouldn't be summarily dismissed. Perhaps it isn't unreasonable to suggest PyNumber_Index shouldn't use the less stringent PyLong_Check as the entry to the fast path

[issue36669] weakref proxy doesn't support the matrix multiplication operator

2019-04-19 Thread Dan Snider
Change by Dan Snider : -- nosy: bup priority: normal severity: normal status: open title: weakref proxy doesn't support the matrix multiplication operator ___ Python tracker <https://bugs.python.org/issue36

[issue36617] The rich comparison operators are second class citizens

2019-04-12 Thread Dan Snider
New submission from Dan Snider : The rich comparison operators have an (far as I can tell, unnecessary) limitation compared to the other binary operators, being that the result of an unparenthesized comparison expression cannot be unpacked using the *iterable "unpack" oper

[issue36283] eval is needlessly limited

2019-03-13 Thread Dan Snider
New submission from Dan Snider : The footnote about why eval/exec cannot be used for arbitrary code has been (for the most part) incorrect for quite some time as the signature for PyEval_EvalCodeEx demonstrates: PyObject* PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals

[issue36000] __debug__ is a keyword but not a keyword

2019-02-15 Thread Dan Snider
New submission from Dan Snider : keyword.py is used by stuff like the idle colorizer to help determine if an identifier is considered a keyword but it doesn't identify __debug__ despite the fact that the parser treats it exactly the same as None, True, and False. I could not find a more

[issue35979] Incorrect __text_signature__ for the __get__ slot wrapper

2019-02-12 Thread Dan Snider
New submission from Dan Snider : The current signature: "__get__($self, instance, owner, /)\n--\n\nReturn an attribute of instance, which is of type owner." doens't match how wrap_descr_get actually parses the arguments to __get__ with: PyArg_UnpackTuple(args

[issue35937] Add instancemethod to types.py

2019-02-07 Thread Dan Snider
New submission from Dan Snider : Having the ability to add binding behavior to any callable is an incredibly useful feature if one knows how to take advantage of it, but unfortunately, nothing that currently (publicly) exists comes close to filling the gap `instancemethod`s secrecy leaves

[issue35714] Document that the null character '\0' terminates a struct format spec

2019-01-10 Thread Dan Snider
New submission from Dan Snider : ie.: >>> from struct import calcsize >>> calcsize('\144\u0064\000xf\U0031000\60d\121\U0051') 16 I'm sure some people think it's obvious or even expect the null character to signal EOF but it probably isn't obvious at al

[issue35196] IDLE text squeezer is too aggressive and is slow

2019-01-02 Thread Dan Snider
Dan Snider added the comment: Not 100% sure if it's appropriate to post this here... so sorry if not. So anyway, the _MAX_COLS and _MAX_LINE constants used for `get_argspec` seem like they were intended to limit the generated text tips to at most 5 rows, 85 characters wide, which makes

[issue35331] Incorrect __module__ attribute for _struct.Struct and perhaps a few others

2018-11-27 Thread Dan Snider
New submission from Dan Snider : _struct.Struct not defining a valid __module__ by prefixing its tp_name slot with "_struct" is inconsistent with every other extension type which is available in the corresponding module globals. >From the documentation of the `tp_name` s

[issue35166] BUILD_MAP_UNPACK doesn't function as expected for dict subclasses

2018-11-04 Thread Dan Snider
New submission from Dan Snider : >>> class Dict(dict): def keys(self): assert 0 def update(*args, **kwds): assert 0 def __getitem__(self, key): assert 0 def __iter__(self): assert 0 >>> {**Dict(a=1)} {'a': 1} The opcode

[issue25410] Clean up and fix OrderedDict

2018-11-04 Thread Dan Snider
Dan Snider added the comment: It might be more appropriate to start a new issue for this, but I'll leave that decision to somehow who would know for sure. Anyway, basically the entire dict/PyDictObject api functions do not appear work at all with OrderedDict. Or rather, OrderedDict doesn't

[issue35048] Can't reassign __class__ despite the assigned class having identical slots

2018-10-23 Thread Dan Snider
New submission from Dan Snider : >>> class a(dict): __slots__ = '__dict__', 'x' >>> class b(dict): __slots__ = '__dict__', 'x' >>> self = a(); self.__class__ = b Traceback (most recent call last): File "", line 1, in self=a(); self.__class__ =

[issue34396] Certain methods that heap allocated subtypes inherit suffer a 50-80% performance penalty

2018-10-20 Thread Dan Snider
Dan Snider added the comment: Well, I found another mystery. Calling tuple.__getitem__ directly, on an actual tuple instance, is 50-80% slower than calling list.__getitem__ even though in theory, they should be virtually identical with maybe tuple access being infinitesimally be faster

[issue34924] inspect.signature isn't aware that types.MethodType can wrap any callable

2018-10-07 Thread Dan Snider
New submission from Dan Snider : I actually noticed this due to it confusingly breaking IDLE call tips and code completion. >>> import inspect >>> from types import MethodType >>> bound_len = MethodType(len, 'abc') >>> bound_len() 3 >>> inspect

[issue34887] bytes subclass __repr__ raise SystemError when set to bytes.decode

2018-10-03 Thread Dan Snider
New submission from Dan Snider : I've tested it on at least one of each minor version since 3.4 but it looks like it may be specific to 3.6.0. The developer's guide isn't clear enough for me to understand what's eligible for bug fixes but since I'm not sure if it actually is 3.6.0 exclusive

[issue34848] range.index only takes one argument when it's documented as taking the usual 3

2018-09-30 Thread Dan Snider
Dan Snider added the comment: So I also just happened to notice that the "documentation is wrong" for list, tuple, and collections.deque. They use use _PyEval_SliceIndexNotNone whch causes this: >>> s = 'abcde' >>> s.index('d', 0, None) 3 >>> [*s].in

[issue34848] range.index only takes one argument when it's documented as taking the usual 3

2018-09-29 Thread Dan Snider
New submission from Dan Snider : Unfortunately, it looks like there's no requirement for an abc.Sequence to implement the 3 argument form of seq.index, so I suppose this is technically just a documentation bug... >>> range(5).index(2, 1) Traceback (most recent call last): File &

[issue34842] Incorrect error messages in bisect

2018-09-29 Thread Dan Snider
New submission from Dan Snider : internal_bisect_left and internal_bisect_right use PySequence_Size when a "hi" argument wasn't provided, which causes this silly error message: >>> bisect.bisect_right(dict.fromkeys(range(10)), 5) Traceback (most recent call last):

[issue34750] locals().update doesn't work in Enum body, even though direct assignment to locals() does

2018-09-21 Thread Dan Snider
Dan Snider added the comment: It's working as intended. locals() and vars() simply returns the current frame's f_locals. In functions, modifying this usually accomplishes nothing useful because the code object has OPTIMIZED and NEWLOCALS flags set, meaning local variables are looked up

[issue34620] Octal byte literals with a decimal value > 255 are silently truncated

2018-09-10 Thread Dan Snider
New submission from Dan Snider : >>> b'\542\571\564\545\563', b'\142\171\164\145\163' (b'bytes', b'bytes') All the C compilers I know of at the very least generate a warning when one tries to assign an oct literal >= '\400' to a byte. And that's because it's nonsense when bytes

[issue34497] Remove needless set operator restriction

2018-08-25 Thread Dan Snider
Change by Dan Snider : -- keywords: +patch pull_requests: +8394 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue34497> ___ ___ Python-

[issue34497] Remove needless set operator restriction

2018-08-25 Thread Dan Snider
New submission from Dan Snider : I only just now realized that `dict.fromkeys('abc').keys() - 'bc'` returns {'a'} instead of raising an error like {*'abc'} - 'bc' would, which is really quite handy. The __xor__, __and__, and __sub__ methods of dict_keys (and items, assuming

[issue34396] Certain methods that heap allocated subtypes inherit suffer a 50-80% performance penalty

2018-08-13 Thread Dan Snider
New submission from Dan Snider : The ones I know of are list.__getitem__, dict __contains__ & __getitem__, and (frozen)set.__contains__ but from what I can tell so far it seems like dict.__getitem__ takes the worst hit. For dicts, I've spent a few hours trying to figure out what's get

[issue34314] Like __hash__, allow setting MyClass.__init__ to None to prevent it being called by type.__call__

2018-08-01 Thread Dan Snider
New submission from Dan Snider : Right now, you really gotta jump through hoops in some cases if you only want to use __new__ and don't care about __init__ (is there ever a time where you'd use both?). The problem originates in type.__call__. I'm attaching a full Python implementation

[issue34290] _ctypes PyCField_new doesn't do anything

2018-07-31 Thread Dan Snider
New submission from Dan Snider : The function is essentially nothing more than a prototype at the moment: static PyObject * PyCField_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { CFieldObject *obj; obj = (CFieldObject *)type->tp_alloc(type, 0); return (PyObject *)

[issue34192] FunctionType.__new__ can generate functions that immediately crash

2018-07-22 Thread Dan Snider
New submission from Dan Snider : The following program crashes on 3.3.1, 3.4.2, 3.5.2, and 3.6.1 because despite having a non-empty co_cellvars slot due to the generator object, the NOFREE flag was set. 3.7 isn't immune to some bad behavior here, either. While I only have access to 3.7.03b

[issue34146] PyCData_Type.tp_hash doesn't use PyObject_HashNotImplemented

2018-07-18 Thread Dan Snider
New submission from Dan Snider : So not only does the function it does use (`PyCData_nohash`) prevent PyType_Ready from setting _ctypes._SimpleCData.__dict__["__hash__"] to `None`, (contrary to to every other unhashable type in the standard library) but the error message it retur

[issue34123] ambiguous documentation for dict.popitem

2018-07-16 Thread Dan Snider
New submission from Dan Snider : https://docs.python.org/3/library/stdtypes.html#dict.popitem `dict.popitem` no longer returns an "arbitrary" (key, value) pair as the documentation suggests. Rather, it always returns the pair whose key was most recently *inserted* (ie., the

[issue33998] random.randrange completely ignores the step argument when stop is None

2018-06-29 Thread Dan Snider
Change by Dan Snider : -- keywords: +patch pull_requests: +7616 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue33998> ___ ___ Python-

[issue33998] random.randrange completely ignores the step argument when stop is None

2018-06-29 Thread Dan Snider
New submission from Dan Snider : This "bug" is present even in 2.7. I have a really hard time believing that, even if it would be incredibly rare for someone to stumble upon this, may others haven't noticed this rather glaring flaw in the code. I couldn't find any similar issues th

[issue33814] exec() maybe has a memory leak

2018-06-09 Thread Dan Snider
New submission from Dan Snider : Sort of because I'm really not sure if it's working as intended or not. When I found this out today, I noticed that the documentation of `exec` has been updated since the last time I saw it, which is good, but it still leaves much to be desired. Specifically

[issue33386] Double clicking to select an identifier in IDLE does not work with some unicode characters

2018-04-29 Thread Dan Snider
New submission from Dan Snider <mr.assume.a...@gmail.com>: https://i.imgur.com/61sHBRR.png At least with "μ", it behaves as if it's one of the ascii characters for which id.isidentifier() returns False, as in https://i.imgur.com/XbEW0ZC.png. -- assignee: terry.reedy

[issue33279] Py_BuildValue is causing crashes with the "L" and "K" format characters when upcasting sub 64-bit integer types

2018-04-14 Thread Dan Snider
Change by Dan Snider <mr.assume.a...@gmail.com>: -- title: Py_Build value is causing crashes with the "L" and "K" format characters when upcasting sub 64-bit integer types -> Py_BuildValue is causing crashes with the "L" and "K" fo

[issue33279] Py_Build value is causing crashes with the "L" and "K" format characters when upcasting sub 64-bit integer types

2018-04-14 Thread Dan Snider
New submission from Dan Snider <mr.assume.a...@gmail.com>: New to both C and the CPython api so I'm not sure what compiler details matter but this is with VS14 and default compile parameters on windows 10 with 32bit Python. The following function: static PyObject *spam(PyObject *

[issue32683] isinstance is calling ob.__getattribute__ as a fallback instead of object.__class__.__get__

2018-01-26 Thread Dan Snider
New submission from Dan Snider <mr.assume.a...@gmail.com>: It doesn't even care if the result it gets from ob.__getattribute__("__class__") isn't a type. Surely `isinstance` is intended to do what it is named and be guaranteed to return True if an object `ob` is an instan

[issue32575] IDLE cannot locate certain SyntaxErrors raised by f-string expressions

2018-01-16 Thread Dan Snider
New submission from Dan Snider <mr.assume.a...@gmail.com>: For example the following f-string f'{1):.1%}' IDLE will scroll to the top of the file and highlight a random and irrelevant line (not sure what it's doing tbh). running the expression with `exec` makes it look like im

[issue32176] Zero argument super is broken in 3.6 for methods with a hacked __class__ cell

2017-12-01 Thread Dan Snider
Dan Snider <mr.assume.a...@gmail.com> added the comment: So while CO_NOFREE is set in all versions with the example code, it appears only python 3.6 recognizes that flag and disallows the accessing of the __class__ cell. In this case the error message is bad because it i

[issue32176] Zero argument super is broken in 3.6 for methods with a hacked __class__ cell

2017-11-30 Thread Dan Snider
Dan Snider <mr.assume.a...@gmail.com> added the comment: The hacked cell object using this method appears to be changed to NULL when accessed by frame.f_localsplus. I don't know C well enough to find out what's happening because nothing looks different to me in PyFrame_FastToLocalsWit

[issue32176] Zero argument super is broken in 3.6 for methods with a hacked __class__ cell

2017-11-29 Thread Dan Snider
New submission from Dan Snider <mr.assume.a...@gmail.com>: The following code works in 3.3, 3.4, and 3.5, but in 3.6 it throws RuntimeError: super(): bad __class__ cell. from types import FunctionType, CodeType def create_closure(__class__): return (lambda: __class__).__closure_

[issue31789] Better error message when failing to overload metaclass.mro

2017-10-14 Thread Dan Snider
New submission from Dan Snider <mr.assume.a...@gmail.com>: class meta(type): mros = (object,) def __new__(metacls, name, bases, namespace, fake_bases=()): print('entering __new__') metacls.fake_bases = fake_bases cls = type.__new__(metacls, name,

[issue31563] Change repr of dict_keys, dict_values, and dict_items to use curly braces

2017-09-23 Thread Dan Snider
New submission from Dan Snider: They behave like sets yet their repr looks like a list: dict_keys([0, 1, 3, 4]). It should be dict_keys({0, 1, 2, 3, 4}). Ditto for odict_keys/odict_values. Maybe this is a holdover from when the repr of sets was Set([0, 1, 2, ...])? The reason I bring this up

[issue31477] IDLE 'strip trailing whitespace' changes the value of multiline strings

2017-09-14 Thread Dan Snider
New submission from Dan Snider: This function is supposed to be purely cosmetic. It just cleans up the junk whitespace commonly left behind when coding. But it could cause a problem when someone expects some string they defined to stay the same value, and then use that function and all

[issue31248] method wrapper type has invalid __name__/__qualname__ 'method-wrapper'

2017-08-21 Thread Dan Snider
New submission from Dan Snider: Out of the 202 builtin/extension types easily accessible in sys.modules, that is the only one with a dash in its name. -- components: Library (Lib) messages: 300632 nosy: bup priority: normal severity: normal status: open title: method wrapper type has

[issue31194] Inconsistent __repr__s for _collections objects

2017-08-13 Thread Dan Snider
New submission from Dan Snider: With the new C implementation of collections.OrderedDict, its repr correctly uses the subclass's name, unlike deque and defaultdict. class Thing(_collections.OrderedDict): pass >>> Thing() Thing([]) class Thing(_collections.deque): pass

[issue31168] IDLE hangs with absurdly long __repr__s

2017-08-09 Thread Dan Snider
New submission from Dan Snider: Objects with a 500,000+ character __repr__ will cause the IDLE shell to hang and thus lose any progress on open windows. 200,000 (on a decent system) seems to be the tipping point where it can never recover. -- assignee: terry.reedy components: IDLE

[issue30702] pickle uses getattr(obj, '__reduce__') instead of getattr(type(obj), '__reduce__')

2017-06-19 Thread Dan Snider
New submission from Dan Snider: That is inconsistent with every other object.__dunder_method__ which still work even if the instance gets an attribute with the same name. -- components: Library (Lib) messages: 296337 nosy: assume_away priority: normal severity: normal status: open

[issue30402] Unexpected and/or inconsistent del behavior

2017-05-18 Thread Dan Snider
New submission from Dan Snider: k = 'k' del [k] That deletes the variable k from the local scope (even though it *looks* like it's trying to delete a list containing 1 element which is equivalent to the variable k). But if using list literals to delete groups of objects is valid, then why

[issue29944] Argumentless super() fails in classes constructed with type()

2017-04-08 Thread Dan Snider
Dan Snider added the comment: Just wanted to add that I found this when I was trying to find a way to decorate all methods in a class without using a metaclass or modifying __getattr__. Using Josh's workaround, here's a simple demonstration that (at least at first glance) prints a message

[issue29008] Can't do dict comp from previously defined dict in the outermost scope of class defintion

2016-12-18 Thread Dan Snider
New submission from Dan Snider: class MyClass: a_dict = {'key':'value'} r_dict = {a_dict[k]:k for k in a_dict} throws the error: Traceback (most recent call last): File "C:/Users/D/AppData/Local/Programs/Python/Python35-32/deleteme.py", line 1, in class MyClass: