[issue2909] struct.Struct.unpack to return a namedtuple for easier attribute access
New submission from Aaron Gallagher <[EMAIL PROTECTED]>: With the advent of collections.namedtuple, I thought that having a counterpart in the struct module would make having to deal with unpacked data much easier. Per suggestion, this extends the behavior of _struct.Struct rather than a separate NamedStruct class. The regexp might not be immediately obvious as to what the format required is. The format string is represented like this: "attribute_name1(attribute_format) attribute_name2(attribute_format2)" and so on. Formats given in parentheses without an attribute name are allowed, so that byte order and pad bytes can be specified. For example: "(!) x1(h) x2(h) (2x) y1(h) y2(h)" Suggestions and criticism are welcome. I think it would simplify using the struct module a lot to be able to have named attributes like this. -- components: Library (Lib) files: named-struct.patch keywords: patch messages: 67038 nosy: habnabit severity: normal status: open title: struct.Struct.unpack to return a namedtuple for easier attribute access versions: Python 3.0 Added file: http://bugs.python.org/file10368/named-struct.patch __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2909> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2909] struct.Struct.unpack to return a namedtuple for easier attribute access
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: Okay, here's a new version of my patch. Instead of replacing the default functionality of struct.Struct, this patch now adds the functionality to a separate class called NamedStruct, so as to not break backwards compatibility. The coding style has been revised, and it now also raises a more descriptive error if the regex fails to parse. Also included: a unit test. -- versions: +Python 2.6 Added file: http://bugs.python.org/file10374/named-struct2.patch __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2909> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
New submission from Aaron Gallagher <[EMAIL PROTECTED]>: Currently, pickle.py in the stdlib is limited by the python call stack. For deeply recursive data structures, the default recursion limit of 1000 is not enough. The patch attached modifies pickle.py to instead use a deque object as a call stack. Pickler.save and other methods that increase the recursion depth are now generators which may yield either another generator or None, where yielding a generator adds it to the call stack. -- components: Library (Lib) files: pickle.patch keywords: patch messages: 68262 nosy: habnabit severity: normal status: open title: pickle.py is limited by python's call stack type: behavior versions: Python 2.6, Python 3.0 Added file: http://bugs.python.org/file10638/pickle.patch ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2480] eliminate recursion in pickling
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: I've provided an alternate implementation of this that works with very minimal modification to pickle.py. See issue 3119 for the patch. -- nosy: +habnabit ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2480> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: Ah, I didn't know that a list would be as fast for appending and popping. I knew that lists were optimized for .append() and .pop(), but I didn't know that a list would be just as fast as a deque if it was just used as a stack. And I'll be happy to write unit tests if it can be pointed out to me how exactly they can be written. Should it just test to make sure pickling a deeply nested object hierarchy can be pickled without raising a RuntimeError? I tried to make this as transparent as possible of a change. ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: Alright, sorry this took so long. Hopefully this can still be included in 3.0. Included is a patch that no longer uses collections.deque and also adds a test case to test/test_pickle.py. The test catches RuntimeError and fails the unittest. I didn't see anything that would behave like the opposite of assertRaises except letting the exception propagate. Added file: http://bugs.python.org/file11168/pickle2.patch ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2573] Can't change the framework name on OS X builds
New submission from Aaron Gallagher <[EMAIL PROTECTED]>: There is currently no way in the configure script to specify an alternate name for Python.framework. If I want to completely separate versions of Python (e.g. for 3.0 alphas and/or Stackless), I have to manually edit configure.in and configure to change the framework name. It would be much more convenient if --with-framework could take an optional parameter of the framework name to use. -- components: Build, Macintosh messages: 65105 nosy: habnabit severity: normal status: open title: Can't change the framework name on OS X builds type: feature request versions: Python 2.6, Python 3.0 __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2573> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2573] Can't change the framework name on OS X builds
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: Here's a framework that implements the necessary change. I'm not very good at autoconf, so it might need to be touched up. -- keywords: +patch Added file: http://bugs.python.org/file9977/framework.patch __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2573> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2573] Can't change the framework name on OS X builds
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: Okay, here's the same patch but now with Mac/Makefile.in patched. I changed all references to Python to the framework name, because I believe it won't work properly otherwise. Added file: http://bugs.python.org/file9979/framework2.patch __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2573> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4579] .read() and .readline() differ in failing
Aaron Gallagher <[EMAIL PROTECTED]> added the comment: I can't reproduce this on python 2.5.1, 2.5.2, or 2.6.0 on Mac OS 10.5.4. Both .read() and .readline() raise an EBADF IOError. 3.0.0 fails in the same way. -- nosy: +habnabit ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4579> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44493] Missing terminated NUL in the length of sockaddr_un
Aaron Gallagher <_...@habnab.it> added the comment: sigh.. adding myself to nosy here too in the hope that this gets any traction -- nosy: +habnabit ___ Python tracker <https://bugs.python.org/issue44493> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14965] super() and property inheritance behavior
Change by Aaron Gallagher : -- nosy: +Aaron Gallagher nosy_count: 20.0 -> 21.0 pull_requests: +24811 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/26194 ___ Python tracker <https://bugs.python.org/issue14965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14965] super() and property inheritance behavior
Aaron Gallagher <_...@habnab.it> added the comment: @daniel.urban I'm attempting to move this patch along, but since the contributing process has changed in the years since your patch, you'll need to sign the CLA. Are you interested in picking this back up at all? I haven't been given any indication of how to proceed if I'm doing this on your behalf, but hopefully the core team will enlighten us. -- nosy: +habnabit ___ Python tracker <https://bugs.python.org/issue14965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14965] super() and property inheritance behavior
Aaron Gallagher <_...@habnab.it> added the comment: @daniel.urban would you kindly resubmit your patch as a PR to the cpython repo? I've learned out-of-band from someone else that putting patches on bpo is considered obsolete. you can use the PR I've submitted (https://github.com/python/cpython/pull/26194) and reset the author. I'd be happy to do it myself (giving you a branch that's all set up, so all you need to do is click the 'new PR' button) if you tell me what to set the author to. -- ___ Python tracker <https://bugs.python.org/issue14965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40199] Invalid escape sequence DeprecationWarnings don't trigger by default
Aaron Gallagher <_...@habnab.it> added the comment: This is definitely not windows-specific. On macos: $ python3.9 Python 3.9.4 (default, Apr 5 2021, 01:47:16) [Clang 11.0.0 (clang-1100.0.33.17)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> '\s' '\\s' -- nosy: +habnabit ___ Python tracker <https://bugs.python.org/issue40199> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14965] super() and property inheritance behavior
Aaron Gallagher <_...@habnab.it> added the comment: I will note, Raymond, that I’ve wanted this for years before discovering this bpo issue, and I found it because you linked it on Twitter. ;) On Wed, Dec 8, 2021 at 19:08 Raymond Hettinger wrote: > > Raymond Hettinger added the comment: > > Another thought: Given that this tracker issue has been open for a decade > without resolution, we have evidence that this isn't an important problem > in practice. > > Arguably, people have been better off being nudged in another direction > toward better design or having been forced to be explicit about what method > is called and when. > > -- > > ___ > Python tracker > <https://bugs.python.org/issue14965> > ___ > -- ___ Python tracker <https://bugs.python.org/issue14965> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31742] Default to emitting FutureWarning for provisional APIs
Aaron Gallagher <_...@habnab.it> added the comment: >Storing the marker attribute in __main__ [...] Can I request please not using __main__ for this? setuptools console_scripts are very common, which is a case where __main__ will be a generated (i.e. not user-controllable) file. Making application code import __main__ to set the flag would be brittle. -- nosy: +habnabit ___ Python tracker <https://bugs.python.org/issue31742> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16113] Add SHA-3 (Keccak) support
Aaron Gallagher added the comment: As long as the reference Keccak code is going to live in the python stdlib anyway, I would /greatly/ appreciate it if the Keccak sponge function was directly exposed instead of just the fixed parameters used for SHA-3. A Keccak sponge can have a much wider range of rates/capacities, and after absorption can have any number of bytes squeezed out. The ability to get an unbounded number of bytes out is very useful and I've written some code that uses that behavior. I ended up having to write my own Keccak python library since none of the other SHA-3 libraries exposed this either. -- nosy: +habnabit ___ Python tracker <http://bugs.python.org/issue16113> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16113] Add SHA-3 (Keccak) support
Aaron Gallagher added the comment: https://pypi.python.org/pypi/cykeccak/ is what I've written to do this, for reference. Honestly I hope that the Keccak sponge is directly exposed in openssl (or any other SHA-3 implementation) because of its utility beyond SHA-3. If the source of some other implementation is going to be bundled with python anyway, it shouldn't be difficult to expose the sponge bits. -- ___ Python tracker <http://bugs.python.org/issue16113> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
Aaron Gallagher added the comment: Okay, here's a new version for the py3k trunk. I'm assuming that this is not going to make it into 2.x at all, because of the API changes. This patch only touches the python version of the code and adds a unit test for testing whether pickle works with arbitrary nesting depth in test.pickletest. The test is disabled for the C pickle tests currently, since it causes python to run out of stack space and crash. So, does _pickle.Pickler's API need to be changed as well? Right now, pickle._Pickler.dump expects save (and save expects the other save_* methods) to either return None or an iterable, where the iterable yields either None or further iterables. I'm sure it wouldn't be hard to make _pickle.Pickler.dump work the same way, but since C doesn't have generators, I don't know how exactly the API would translate. -- versions: +Python 3.1 -Python 2.6, Python 3.0 Added file: http://bugs.python.org/file13654/pickle3.patch ___ Python tracker <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
Aaron Gallagher added the comment: Here's a patch that fixes the unit tests. A new test was added that tried to test the C implementation of this though none exists. -- keywords: +patch Added file: http://bugs.python.org/file18073/pickle4.patch ___ Python tracker <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29403] mock's autospec's behavior on method-bound builtin functions is broken
New submission from Aaron Gallagher: Cython will, in the right circumstances, offer a MethodType instance where im_func is a builtin function. Any instance of MethodType is automatically assumed to be a python-defined function (more specifically, a function that has an inspectable signature), but _set_signature was still conservative in its assumptions. As a result _set_signature would return early with None instead of a mock since the im_func had no inspectable signature. This causes problems deeper inside mock, as _set_signature is assumed to always return a mock, and nothing checked its return value. In similar corner cases, autospec will simply not check the spec of the function, so _set_signature is amended to now return early with the original, not-wrapped mock object. There is another None early return in _set_signature, but it seems.. harder to trigger? It seems more appropriate to raise an exception there if this is being fixed. -- components: Library (Lib) messages: 286565 nosy: Aaron Gallagher priority: normal severity: normal status: open title: mock's autospec's behavior on method-bound builtin functions is broken type: behavior versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7 ___ Python tracker <http://bugs.python.org/issue29403> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29403] mock's autospec's behavior on method-bound builtin functions is broken
Aaron Gallagher added the comment: Patch adapted from https://github.com/testing-cabal/mock/pull/389 -- keywords: +patch Added file: http://bugs.python.org/file46468/mock.patch ___ Python tracker <http://bugs.python.org/issue29403> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29403] mock's autospec's behavior on method-bound builtin functions is broken
Changes by Aaron Gallagher : -- pull_requests: +193 ___ Python tracker <http://bugs.python.org/issue29403> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16113] Add SHA-3 and SHAKE (Keccak) support
Aaron Gallagher added the comment: I'm not sure why one would pick and choose here—SHAKE is part of the NIST SHA-3 standard. -- ___ Python tracker <http://bugs.python.org/issue16113> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
Changes by Aaron Gallagher <_...@habnab.it>: -- nosy: -habnabit ___ Python tracker <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3119] pickle.py is limited by python's call stack
Aaron Gallagher added the comment: Definitely not interested in pickle at all anymore. -- ___ Python tracker <http://bugs.python.org/issue3119> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com