[issue46561] Descriptor resolution should own arguments passed to descriptors
Maxwell Bernstein added the comment: Ah, and another piece of the puzzle: this can happen in runtimes like Cinder that provide their own native code entrypoints to functions like a __get__. -- ___ Python tracker <https://bugs.python.org/issue46561> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46561] Descriptor resolution should own arguments passed to descriptors
Change by Maxwell Bernstein : -- components: +C API ___ Python tracker <https://bugs.python.org/issue46561> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46561] Descriptor resolution should own arguments passed to descriptors
Maxwell Bernstein added the comment: Hi Dennis, Sorry, let me be more clear. CPython in general ensures that objects passed in as arguments to a function will live for the duration of the function call if they are otherwise untouched. As it is now, this invariant is not maintained when calling the __get__ descriptor. Right now, it is not only borrowed by the callee but also not owned by the caller (!). Max -- ___ Python tracker <https://bugs.python.org/issue46561> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46561] Descriptor resolution should own arguments passed to descriptors
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +29158 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30979 ___ Python tracker <https://bugs.python.org/issue46561> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46561] Descriptor resolution should own arguments passed to descriptors
New submission from Maxwell Bernstein : Currently the descriptor (self) argument to __get__ is passed borrowed, since _PyType_LookupId returns a borrowed reference (see _PyObject_LookupSpecial and lookup_maybe_method in Objects/typeobject.c). This should instead own the reference. -- messages: 411978 nosy: tekknolagi priority: normal severity: normal status: open title: Descriptor resolution should own arguments passed to descriptors versions: Python 3.10, Python 3.11, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue46561> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39425] list.count performance regression
Change by Maxwell Bernstein : -- nosy: +tekknolagi nosy_count: 5.0 -> 6.0 pull_requests: +28262 pull_request: https://github.com/python/cpython/pull/30036 ___ Python tracker <https://bugs.python.org/issue39425> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46041] Add reference counting micro-optimizations to listobject.c
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +28261 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30036 ___ Python tracker <https://bugs.python.org/issue46041> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46041] Add reference counting micro-optimizations to listobject.c
New submission from Maxwell Bernstein : Avoid reference counting in the fast path of list.contains and list.index -- messages: 408242 nosy: tekknolagi priority: normal severity: normal status: open title: Add reference counting micro-optimizations to listobject.c ___ Python tracker <https://bugs.python.org/issue46041> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45956] Add scanf regular expressions to re
Change by Maxwell Bernstein : -- resolution: -> rejected stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue45956> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45956] Add scanf regular expressions to re
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +28111 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29885 ___ Python tracker <https://bugs.python.org/issue45956> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45956] Add scanf regular expressions to re
New submission from Maxwell Bernstein : The documentation for the `re` module suggests several regular expressions for use in simulating `scanf()`. Provide these directly in the `re` module. -- components: Library (Lib) messages: 407491 nosy: tekknolagi priority: normal severity: normal status: open title: Add scanf regular expressions to re versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue45956> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36203] PyWeakref_NewRef docs are misleading
Change by Maxwell Bernstein : -- pull_requests: +24879 pull_request: https://github.com/python/cpython/pull/26273 ___ Python tracker <https://bugs.python.org/issue36203> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42199] bytecode_helper assertNotInBytecode fails too eagerly
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +21950 stage: -> patch review pull_request: https://github.com/python/cpython/pull/23031 ___ Python tracker <https://bugs.python.org/issue42199> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42199] bytecode_helper assertNotInBytecode fails too eagerly
New submission from Maxwell Bernstein : assertNotInBytecode should only fail if: * the instr matches and the arg is unspecified, or * the instr matches, the arg is specified, and the arg matches But right now it fails in a third case because of the dangling self.fail() call. The self.fail() call should be moved into the `if`/`elif`. -- components: Tests messages: 379885 nosy: tekknolagi priority: normal severity: normal status: open title: bytecode_helper assertNotInBytecode fails too eagerly versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue42199> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42065] Fix incorrectly formatted _codecs.charmap_decode error message
Change by Maxwell Bernstein : -- keywords: +patch nosy: +tekknolagi nosy_count: 1.0 -> 2.0 pull_requests: +21704 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19940 ___ Python tracker <https://bugs.python.org/issue42065> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40704] PyIter_Check fails when compiling in the Limited API
Maxwell Bernstein added the comment: Oh, it looks like this has been done: https://github.com/python/cpython/commit/ea62ce7f4fefc66bc0adba16bcd7666d5bbd5b44 Although I am not sure what version this made it into. So maybe this does not affect versions 3.9/3.10. I've seen it in 3.6/6, for sure. -- versions: +Python 3.6, Python 3.7 -Python 3.10, Python 3.9 ___ Python tracker <https://bugs.python.org/issue40704> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40704] PyIter_Check fails when compiling in the Limited API
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +20165 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/7477 ___ Python tracker <https://bugs.python.org/issue40704> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40704] PyIter_Check fails when compiling in the Limited API
Maxwell Bernstein added the comment: See for example the following C program: ``` #define Py_LIMITED_API #include "Python.h" int main() { Py_Initialize(); PyObject* foo; PyIter_Check(foo); } ``` when compiled (gcc test.c `pkg-config --cflags python3`) produces: ``` In file included from /usr/include/python3.6m/Python.h:135:0, from test.c:3: test.c: In function ‘main’: /usr/include/python3.6m/abstract.h:712:20: error: dereferencing pointer to incomplete type ‘struct _typeobject’ ((obj)->ob_type->tp_iternext != NULL && \ ^ test.c:8:3: note: in expansion of macro ‘PyIter_Check’ PyIter_Check(foo); ^~~~ /usr/include/python3.6m/abstract.h:713:38: error: ‘_PyObject_NextNotImplemented’ undeclared (first use in this function); did you mean ‘PyObject_HashNotImplemented’? (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) ^ test.c:8:3: note: in expansion of macro ‘PyIter_Check’ PyIter_Check(foo); ^~~~ /usr/include/python3.6m/abstract.h:713:38: note: each undeclared identifier is reported only once for each function it appears in (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) ^ test.c:8:3: note: in expansion of macro ‘PyIter_Check’ PyIter_Check(foo); ^~~~ ``` -- ___ Python tracker <https://bugs.python.org/issue40704> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40704] PyIter_Check fails when compiling in the Limited API
New submission from Maxwell Bernstein : PyIter_Check is itself marked as available in the Limited API but: a) it's a macro, and b) it pokes directly at tp_iternext This means that it's functionally impossible to use PyIter_Check when working with the Limited API. -- components: C API messages: 369479 nosy: tekknolagi priority: normal severity: normal status: open title: PyIter_Check fails when compiling in the Limited API versions: Python 3.6, Python 3.7 ___ Python tracker <https://bugs.python.org/issue40704> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40638] input() with malformed input stream triggers assertion failure
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +19430 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20125 ___ Python tracker <https://bugs.python.org/issue40638> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40638] input() with malformed input stream triggers assertion failure
New submission from Maxwell Bernstein : builtin_input_impl does multiple attribute lookups in a row assuming they will succeed, but part of attribute lookup assumes that there is no pending exception. I propose doing the lookups one by one and checking for an error after each. There is an upcoming patch. -- components: Interpreter Core, Library (Lib) messages: 368982 nosy: tekknolagi priority: normal severity: normal status: open title: input() with malformed input stream triggers assertion failure versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue40638> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27307] string.Formatter does not support key/attribute access on unnumbered fields
Maxwell Bernstein added the comment: Okay, well it doesn't provide the desired behavior of raising the error when switching back and forth between manual and auto numbering, so I am looking into that. -- ___ Python tracker <https://bugs.python.org/issue27307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27307] string.Formatter does not support key/attribute access on unnumbered fields
Maxwell Bernstein added the comment: Looks like the patch solves my problem, so I am going to update my PR sometime today. -- ___ Python tracker <https://bugs.python.org/issue27307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27307] string.Formatter does not support key/attribute access on unnumbered fields
Maxwell Bernstein added the comment: I'll take a look at the patch and see if this solves my problem. If it does, I'll update my PR with tests. -- ___ Python tracker <https://bugs.python.org/issue27307> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39985] str.format and string.Formatter subscript behaviors diverge
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +18418 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19065 ___ Python tracker <https://bugs.python.org/issue39985> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39985] str.format and string.Formatter subscript behaviors diverge
New submission from Maxwell Bernstein : As I understand it, str.format and string.Formatter are supposed to behave the same, with string.Formatter being a pluggable variant. While poking at string.Formatter, I noticed that they do not behave the same when formatting a nameless subscript: ``` import string str.format("{[0]}", "hello") # => "h" string.Formatter().format("{[0]}", "hello") # => KeyError("") ``` They seem to work the same in the case where the arg is either indexed by number or by name: ``` import string str.format("{0[0]}", "hello") # => "h" string.Formatter().format("{0[0]}", "hello") # => "h" str.format("{a[0]}", a="hello") # => "h" string.Formatter().format("{a[0]}", a="hello") # => "h" ``` After some digging, I have come up with a couple ideas: * Change _string.formatter_field_name_split to treat an empty string field name as 0, so that string.Formatter.get_value looks up the arg in args, instead of kwargs * Change string.Formatter.get_value to treat empty string key as 0, and look up the arg in args, instead of kwargs I'm happy to submit a PR if people find one of these two solutions palatable or have some solutions of their own. (Note: this may appear in other versions, but I don't have them on my machine to test.) -- components: Library (Lib) messages: 364382 nosy: tekknolagi priority: normal severity: normal status: open title: str.format and string.Formatter subscript behaviors diverge type: behavior versions: Python 2.7, Python 3.6, Python 3.7 ___ Python tracker <https://bugs.python.org/issue39985> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38648] Py_tp_free is specified twice in Python-ast.c
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +16529 stage: -> patch review pull_request: https://github.com/python/cpython/pull/17002 ___ Python tracker <https://bugs.python.org/issue38648> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38648] Py_tp_free is specified twice in Python-ast.c
New submission from Maxwell Bernstein : This looks like a typo due to copy-paste. -- messages: 355726 nosy: tekknolagi priority: normal severity: normal status: open title: Py_tp_free is specified twice in Python-ast.c versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue38648> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38031] FileIO.__init__ aborts when opener returns bad fd
New submission from Maxwell Bernstein : On a debug build, the following causes an abort: import _io _io.FileIO("foobar", opener=lambda name, flags: 100) 100 is not a valid fd. FileIO attempts to raise an IOError from errno, but there is already an exception set when PyErr_SetFromErrno uses PyObject_Call to create the exception. -- components: IO messages: 351150 nosy: tekknolagi priority: normal severity: normal status: open title: FileIO.__init__ aborts when opener returns bad fd type: crash versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue38031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36929] Other Python _io implementations may not expose _io in their type names
Change by Maxwell Bernstein : -- pull_requests: +13302 ___ Python tracker <https://bugs.python.org/issue36929> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36929] Other Python _io implementations may not expose _io in their type names
Change by Maxwell Bernstein : -- nosy: +vstinner ___ Python tracker <https://bugs.python.org/issue36929> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36929] Other Python _io implementations may not expose _io in their type names
Change by Maxwell Bernstein : -- keywords: +patch pull_requests: +13258 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue36929> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36929] Other Python _io implementations may not expose _io in their type names
Maxwell Bernstein added the comment: I have the beginnings of a PR to patch the test suite to make the prefix optional, if anybody is interested. -- ___ Python tracker <https://bugs.python.org/issue36929> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36929] Other Python _io implementations may not expose _io in their type names
New submission from Maxwell Bernstein : For a vanishingly small number of internal types, CPython sets the tp_name slot to mod_name.type_name, either in the PyTypeObject or the PyType_Spec. There are a few minor places where this surfaces: * Custom repr functions for those types (some of which ignore the tp_name in favor of using a string literal, such as _io.TextIOWrapper) * Pickling error messages The existing test suite only tests the former. This makes it tricky for other Python implementations to pass the test suite if they do not expose the module name (_io, _ssl, _tkinter, etc) in their type names. -- assignee: christian.heimes components: IO, SSL, Tests, Tkinter messages: 342593 nosy: christian.heimes, tekknolagi priority: normal severity: normal status: open title: Other Python _io implementations may not expose _io in their type names type: behavior versions: Python 3.6, Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue36929> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36203] PyWeakref_NewRef docs are misleading
Maxwell Bernstein added the comment: I can likely do it tomorrow. If not I'll update this. On Thu, Mar 7, 2019, 00:20 Windson Yang wrote: > > Windson Yang added the comment: > > It looks to me the fix is easy, we just will return NULL and raise > TypeError when the callback is not callable, None, or NULL. I'm not an > expert in C, but I would love to create a PR for it if you don't have time. > > -- > > ___ > Python tracker > <https://bugs.python.org/issue36203> > ___ > -- ___ Python tracker <https://bugs.python.org/issue36203> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36203] PyWeakref_NewRef docs are misleading
Maxwell Bernstein added the comment: NewProxy checks if it's callable, so I suppose the code should be fixed. On Wed, Mar 6, 2019, 03:32 Windson Yang wrote: > > Windson Yang added the comment: > > Yes, Maxwell. I guess the docs are misleading, the code locate in > https://github.com/python/cpython/blob/master/Objects/weakrefobject.c#L748 > > if (callback == Py_None) > callback = NULL; > if (callback == NULL) > /* return existing weak reference if it exists */ > result = ref; > if (result != NULL) > Py_INCREF(result); > else { > ... > } > > However, I'm not sure we should fix the docs or the code here. > > -- > nosy: +Windson Yang > > ___ > Python tracker > <https://bugs.python.org/issue36203> > ___ > -- ___ Python tracker <https://bugs.python.org/issue36203> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36203] PyWeakref_NewRef docs are misleading
New submission from Maxwell Bernstein : The docs for `PyWeakref_NewRef` state "if callback is not callable, None, or NULL, this will return NULL and raise TypeError". It does not appear as though there is a callable check for the callback. -- messages: 337255 nosy: Maxwell Bernstein priority: normal severity: normal status: open title: PyWeakref_NewRef docs are misleading versions: Python 3.6, Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue36203> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com