[issue17788] Add a with expression, for use in comprehensions

2013-04-18 Thread Eric Wieser
New submission from Eric Wieser: It would be nice if there was a `with` expression. Such that instead of: with open(...) as f: result = foo(f) One could write: result = foo(f) with open(...) as f This would be particularly useful in comprehensions. Instead of: files

[issue17788] Add a with expression, for use in comprehensions

2013-04-18 Thread Eric Wieser
Changes by Eric Wieser wieser.eric+py...@gmail.com: -- components: +Interpreter Core ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17788

[issue18110] Nested set comprehensions in class scope fail

2013-05-31 Thread Eric Wieser
New submission from Eric Wieser: This code: class Sudoku(dict): COLUMNS = [ {(x, y) for y in xrange(9)} for x in xrange(9) ] When run on Python 2.7.5, fails with this traceback: Traceback (most recent call last): File pyshell#3, line 1, in module

[issue18110] Nested set comprehensions in class scope fail

2013-06-01 Thread Eric Wieser
Changes by Eric Wieser wieser.eric+py...@gmail.com: -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18110 ___ ___ Python

[issue18110] Nested set comprehensions in class scope fail

2013-06-01 Thread Eric Wieser
Eric Wieser added the comment: This is not at first glance, a duplicate of 3692 - in that case, the list comprehension is referring to another class variable. Most notably, that describes a behavioural change introduced by python 3 - in this case, python 3 handles it correctly - there's a bug

[issue18110] Nested set comprehensions in class scope fail

2013-06-10 Thread Eric Wieser
Eric Wieser added the comment: Thanks for the clarification - this behavior now makes perfect sense to me. As expected, swapping the list comprehension for a generator comprehension, or vice versa, prevents the error. -- ___ Python tracker rep

[issue27042] Incorrect grammar for function definitions

2016-05-16 Thread Eric Wieser
New submission from Eric Wieser: https://docs.python.org/3.2/reference/compound_stmts.html#function-definitions and onwards say the following decorator ::= "@" dotted_name ["(" [parameter_list [","]] ")"] NEWLINE This is a regression

[issue27042] Incorrect grammar for function definitions

2016-05-16 Thread Eric Wieser
Eric Wieser added the comment: The parent commit is also bad: https://hg.python.org/cpython/rev/b65007ef59c0 -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue27042] Incorrect grammar for function definitions

2016-05-16 Thread Eric Wieser
Eric Wieser added the comment: The offending patch can be found at https://hg.python.org/cpython/rev/71ff2235bb4c -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue30140] Binary arithmetic does not always call subclasses first

2017-04-23 Thread Eric Wieser
Changes by Eric Wieser <wieser.eric+py...@gmail.com>: -- nosy: +Eric.Wieser ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30140> ___

[issue31801] vars() manipulation encounters problems with Enum

2017-11-15 Thread Eric Wieser
Eric Wieser <wieser.eric+py...@gmail.com> added the comment: Not necessarily an argument against this feature, but two workarounds exist for this already: 1. Use `nonlocal` to prevent `value` going into the class namespace: value = None class BaudRate(enu

[issue28716] Fractions instantiation revisited

2017-11-05 Thread Eric Wieser
Eric Wieser <wieser.eric+py...@gmail.com> added the comment: > allows Fraction instantiation from duck-typing classes that provide > as_integer_ratio This would allow the numpy `np.floating` types to take part in `Fraction` conversion as well, which would be great. As far a

[issue33909] PyObject_CallFinalizerFromDealloc is not referenced in any documentation

2018-06-20 Thread Eric Wieser
New submission from Eric Wieser : PEP 442 states that: > Two new C API functions are provided to ease calling of tp_finalize, > especially from custom deallocators. But it does not give the names of these functions, nor do any python docs I can discover. >From grepping for tp

[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-02-05 Thread Eric Wieser
New submission from Eric Wieser <wieser.eric+py...@gmail.com>: Discovered [here](https://github.com/numpy/numpy/issues/10528) Consider the following structure, and a memoryview created from it: class foo(ctypes.Structure): _fields_ = [('one', ctypes.c

[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-02-05 Thread Eric Wieser
Change by Eric Wieser <wieser.eric+py...@gmail.com>: -- keywords: +patch pull_requests: +5383 stage: -> patch review ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-02-05 Thread Eric Wieser
Change by Eric Wieser <wieser.eric+py...@gmail.com>: -- type: -> behavior ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32780> ___ _

[issue32782] ctypes: memoryview gives incorrect PEP3118 itemsize for array of length zero

2018-02-06 Thread Eric Wieser
New submission from Eric Wieser <wieser.eric+py...@gmail.com>: Take the following simple structure: class Foo(ctypes.Structure): _fields_ = [('f', ctypes.uint32_t)] And construct some arrays with it: def get_array_view(N): return memoryview((Foo * N)()) In most

[issue32782] ctypes: memoryview gives incorrect PEP3118 itemsize for array of length zero

2018-02-06 Thread Eric Wieser
Change by Eric Wieser <wieser.eric+py...@gmail.com>: -- keywords: +patch pull_requests: +5394 stage: -> patch review ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue4921] Object lifetime and inner recursive function

2018-02-19 Thread Eric Wieser
Eric Wieser <wieser.eric+py...@gmail.com> added the comment: Would it be possible for function self-reference cell vars to be weak references? This wouldn't solve the issue for co-recursive inner functions, but would at least prevent reference cycles for the more common case of

[issue34305] inspect.getsourcefile and inspect.getcomments do not work with decorated functions

2018-08-01 Thread Eric Wieser
New submission from Eric Wieser : Following on from https://bugs.python.org/issue1764286 - inspect.getsourcefile and inspect.getcomments fall afoul of the same problem. -- components: Library (Lib) messages: 322847 nosy: Eric.Wieser priority: normal severity: normal status: open title

[issue34305] inspect.getsourcefile and inspect.getcomments do not work with decorated functions

2018-08-01 Thread Eric Wieser
Change by Eric Wieser : -- keywords: +patch pull_requests: +8108 stage: -> patch review ___ Python tracker <https://bugs.python.org/issue34305> ___ ___ Py

[issue34305] inspect.getsourcefile and inspect.getcomments do not work with decorated functions

2018-08-01 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +yselivanov ___ Python tracker <https://bugs.python.org/issue34305> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue1764286] inspect.getsource does not work with decorated functions

2018-08-02 Thread Eric Wieser
Eric Wieser added the comment: New issue opened at https://bugs.python.org/issue34305, along with a PR linked there. -- ___ Python tracker <https://bugs.python.org/issue1764

[issue1764286] inspect.getsource does not work with decorated functions

2018-07-31 Thread Eric Wieser
Eric Wieser added the comment: This now leaves `inspect.getsource` inconsistent with `inspect.getsourcefile`: >>> import inspect >>> from contextlib import contextmanager >>> @contextmanager ... def func(): ...yield >>> inspect.getsource(func) '@cont

[issue34494] simple "sequence" class ignoring __len__

2018-08-25 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric.Wieser ___ Python tracker <https://bugs.python.org/issue34494> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue34494] simple "sequence" class ignoring __len__

2018-08-25 Thread Eric Wieser
Eric Wieser added the comment: What I think I find surprising is that I'd expect the sequence protocol to be defined by `__getitem__` and `__len__`, and for `__iter__` to be inferred as: def __iter__(self): for i in range(len(self)): yield self[i] But in reality

[issue8525] Display exceptions' subclasses in help()

2018-07-23 Thread Eric Wieser
Eric Wieser added the comment: > I get the following results for builtin objects that have defined subclasses >From that list, the only unhelpful ones with > 4 items, in my opinion, appear >to be `object`, since that just tells you every type that exists, and `tuple`, >bec

[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-07-23 Thread Eric Wieser
Eric Wieser added the comment: > It should be fairly simple to modify the code to use a format of "B" > for unions, so that it at least matches the itemsize Seems reasonable, although: * I think it should be "B" or "()B" * I'd rather leave that for a la

[issue32782] ctypes: memoryview gives incorrect PEP3118 itemsize for array of length zero

2018-09-06 Thread Eric Wieser
Eric Wieser added the comment: Pinging again, for lack of a clearer path forward -- ___ Python tracker <https://bugs.python.org/issue32782> ___ ___ Python-bug

[issue34305] inspect.getsourcefile and inspect.getcomments do not work with decorated functions

2018-09-06 Thread Eric Wieser
Eric Wieser added the comment: Pinging, as recommended by https://devguide.python.org/pullrequest/#reviewing. -- ___ Python tracker <https://bugs.python.org/issue34

[issue4921] Object lifetime and inner recursive function

2018-09-10 Thread Eric Wieser
Eric Wieser added the comment: For anyone doing archaeology - this came up on python-dev about a year after this issue was filed: https://mail.python.org/pipermail/python-dev/2009-December/094439.html -- ___ Python tracker <ht

[issue32782] ctypes: memoryview gives incorrect PEP3118 itemsize for array of length zero

2018-07-08 Thread Eric Wieser
Eric Wieser added the comment: Pinging, as recommended by https://devguide.python.org/pullrequest/#reviewing. Ideally this and https://bugs.python.org/issue32780 would make the same patch release. -- ___ Python tracker <https://bugs.python.

[issue32780] ctypes: memoryview gives incorrect PEP3118 format strings for both packed and unpacked structs

2018-07-08 Thread Eric Wieser
Eric Wieser added the comment: Pinging, as recommended by https://devguide.python.org/pullrequest/#reviewing. PEP3118 as a protocol is far less useful if the canonical implementation is non-compliant. -- ___ Python tracker <ht

[issue28716] Fractions instantiation revisited

2018-03-13 Thread Eric Wieser
Eric Wieser <wieser.eric+py...@gmail.com> added the comment: > Are you suggesting that _if_ they were to implement `as_integer_ratio` at > some point in the future, then they'd become compatible with `Fraction` Yes, exactly. Conversely, there's little gain in implementing it _until

[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Eric Wieser
Eric Wieser <wieser.eric+py...@gmail.com> added the comment: Apologies, I missed the important part of that snippet: ``` In [3]: gc.collect(); x = make_array_ctype((1,)); del x; gc.collect() Out[3]: 7 ``` -- ___ Python tracker <rep...@bugs.p

[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Eric Wieser
New submission from Eric Wieser <wieser.eric+py...@gmail.com>: Discovered in https://github.com/numpy/numpy/pull/10882/files#r180813166 A reproduction: ``` In [1]: import ctypes In [2]: def make_array_ctype(shape): ...: import ctypes ...: ct = ctypes.c_uint8 ...:

[issue8987] Distutils doesn't quote Windows command lines properly

2018-11-18 Thread Eric Wieser
Eric Wieser added the comment: > then we should perhaps instead consider the rewrite for 3.6: provide a *new* > distutils function that does use Popen and does things "right" (based on > everything we've learned since distutils was written), leaving the old > functio

[issue32782] memoryview & ctypes: incorrect itemsize for empty array

2019-04-14 Thread Eric Wieser
Eric Wieser added the comment: > Revising the code example to use an empty array I think you mean >>> import array >>> memoryview(array.array('H', [])).itemsize 2 Your example is an array containing 0, not an empty array - but the conclusion is the same. > It is

[issue37187] CField.size from the ctypes module does not behave as documented on bitfields

2019-06-06 Thread Eric Wieser
New submission from Eric Wieser : This behavior is pretty surprising: ```python import ctypes class Simple(ctypes.Structure): _fields_ = [ ('a', ctypes.c_uint8), ('b', ctypes.c_uint8), ] class Bitfields(ctypes.Structure): _fields_ = [ ('a', ctypes.c_uint8

[issue37188] Creating a ctypes array of an element with size zero causes "Fatal Python error: Floating point exception"

2019-06-07 Thread Eric Wieser
Change by Eric Wieser : -- keywords: +patch pull_requests: +13759 stage: -> patch review pull_request: https://github.com/python/cpython/pull/13881 ___ Python tracker <https://bugs.python.org/issu

[issue37188] Creating a ctypes array of an element with size zero causes "Fatal Python error: Floating point exception"

2019-06-07 Thread Eric Wieser
New submission from Eric Wieser : Introduced in the fix to bpo-36504, GH-12660. ```python >>> (ctypes.c_uint8 * 0 * 2)() Fatal Python error: Floating point exception >>> struct Empty(ctypes.Structure): _fields_ = [] >>> (Empty * 2)() Fatal Python error: Floating poi

[issue37188] Creating a ctypes array of an element with size zero causes "Fatal Python error: Floating point exception"

2019-06-07 Thread Eric Wieser
Change by Eric Wieser : -- components: +ctypes ___ Python tracker <https://bugs.python.org/issue37188> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37187] CField.size from the ctypes module does not behave as documented on bitfields

2019-06-07 Thread Eric Wieser
Change by Eric Wieser : -- components: +ctypes type: -> behavior ___ Python tracker <https://bugs.python.org/issue37187> ___ ___ Python-bugs-list mai

[issue37188] Creating a ctypes array of an element with size zero causes "Fatal Python error: Floating point exception"

2019-06-07 Thread Eric Wieser
Change by Eric Wieser : -- pull_requests: +13779 stage: backport needed -> patch review pull_request: https://github.com/python/cpython/pull/13906 ___ Python tracker <https://bugs.python.org/issu

[issue29258] __init__.py required for pkgutil.walk_packages in python3

2019-09-18 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue29258> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue32782] memoryview & ctypes: incorrect itemsize for empty array

2019-07-15 Thread Eric Wieser
Eric Wieser added the comment: Pinging again, now that the patch has undergone a revision with some cleanup thanks to @skrah -- ___ Python tracker <https://bugs.python.org/issue32

[issue37604] warnings should use a ContextVar to manage filters/registry

2019-12-04 Thread Eric Wieser
Eric Wieser added the comment: A relevant old issue is https://bugs.python.org/issue6647 -- components: +Library (Lib) nosy: +Eric Wieser type: -> behavior ___ Python tracker <https://bugs.python.org/issu

[issue39610] memoryview.__len__ should raise an exception for 0d buffers

2020-03-02 Thread Eric Wieser
Eric Wieser added the comment: Thanks for pointing out the docs reference, I updated the patch to reword that section. There's a sentence right before the one you draw attention to which to me reads as another argument to change this: > ``len(view)`` is equal to the length of :cl

[issue39471] Meaning and clarification of PyBuffer_Release()

2020-01-27 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue39471> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue39610] memoryview.__len__ should raise an exception for 0d buffers

2020-02-11 Thread Eric Wieser
Change by Eric Wieser : -- keywords: +patch pull_requests: +17836 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18463 ___ Python tracker <https://bugs.python.org/issu

[issue39610] memoryview.__len__ should raise an exception for 0d buffers

2020-02-11 Thread Eric Wieser
New submission from Eric Wieser : Right now, the behavior is: >>> import numpy as np >>> arr_0d = np.array(42) >>> mem_0d = memoryview(arr_0d) >>> len(mem_0d) 1 >>> mem_0d[0] TypeError: invalid indexing of 0-dim memory It seems bizarre to have this

[issue29258] __init__.py required for pkgutil.walk_packages in python3

2020-01-20 Thread Eric Wieser
Eric Wieser added the comment: If the resolution here is that this is behaving as intended (which personally I disagree with), I think this issue should remain open as a documentation task - the docs should clearly state that this does not apply to PEP420 namespace packages

[issue34305] inspect.getsourcefile and inspect.getcomments do not work with decorated functions

2020-03-12 Thread Eric Wieser
Eric Wieser added the comment: Nothing holding it up from my end, just waiting on someone to review it. Perhaps this ping will help with that. -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue34

[issue23967] Make inspect.signature expression evaluation more powerful

2020-03-30 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue23967> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue23967] Make inspect.signature expression evaluation more powerful

2020-03-30 Thread Eric Wieser
Eric Wieser added the comment: > To make this work I had to write an ast printer that produces evaluatable > Python code. Note that it's not complete, I know it's not complete, it's > missing loads of operators. Assume that if this is a good idea I will add > all the missi

[issue37881] __text_signature__ parser doesn't handle globals in extension module

2020-03-30 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue37881> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue40606] Copy property return annotations to __annotations__

2020-05-12 Thread Eric Wieser
New submission from Eric Wieser : Consider a class like class MyClass: x: int y: int Which has >>> MyClass.__annotations__ {'x': int, 'y': int} In future, it might change to class MyClass: @property def x(sel

[issue40606] Copy property return annotations to __annotations__

2020-05-12 Thread Eric Wieser
Change by Eric Wieser : -- keywords: +patch nosy: +Eric.Wieser nosy_count: 1.0 -> 2.0 pull_requests: +19361 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20052 ___ Python tracker <https://bugs.python.org/i

[issue37496] Support annotations in signature strings.

2020-05-16 Thread Eric Wieser
Eric Wieser added the comment: This seems somewhat related to https://bugs.python.org/issue31939 -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue37

[issue41673] Result of multiprocessing.heap.BufferWrapper.create_memoryview can point to freed memory

2020-08-31 Thread Eric Wieser
Eric Wieser added the comment: Whoops, typo. `>>> b[0]` should read `m[0]`. -- ___ Python tracker <https://bugs.python.org/issue41673> ___ ___ Python-bu

[issue41673] Result of multiprocessing.heap.BufferWrapper.create_memoryview can point to freed memory

2020-08-31 Thread Eric Wieser
New submission from Eric Wieser : The full definition of `multiprocessing.heap.BufferWrapper` is: class BufferWrapper(object): _heap = Heap() def __init__(self, size): if size < 0: raise ValueError("Size {0:n} out of range"

[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-08-19 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue41584> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Eric Wieser
New submission from Eric Wieser : Python distinguishes signed zeros by their repr: # floats >>> 0.0 0.0 >>> -0.0 -0.0 # complex >>> complex(0.0, 0.0) # A 0j >>> complex(0.0, -0.0) # B -0j >>> complex(-0.0, 0.0) # C (-0+0j) >>&g

[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Eric Wieser
Eric Wieser added the comment: This was reported and closed in https://bugs.python.org/issue17336, but it seems to me that this is easy to avoid - have `__repr__` return `complex(...)` for values which do not round-trip. -- ___ Python tracker

[issue17336] Complex number representation round-trip doesn't work with signed zero values

2020-08-05 Thread Eric Wieser
Eric Wieser added the comment: > BTW I don't want repr() of a complex number to use the complex(..., ...) A compromise would be to only use this notation if signed zeros are involved. --- Another option would be to use slightly unusual reprs for these complex numbers, which at least ro

[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Eric Wieser
Eric Wieser added the comment: Apologies for not searching the issue tracker effectively until after filing this. -- ___ Python tracker <https://bugs.python.org/issue41

[issue31861] add aiter() and anext() functions to operator module

2020-06-03 Thread Eric Wieser
Change by Eric Wieser : -- nosy: +Eric Wieser ___ Python tracker <https://bugs.python.org/issue31861> ___ ___ Python-bugs-list mailing list Unsubscribe: