[issue19431] Document PyFrame_FastToLocals() and PyFrame_FastToLocalsWithError()

2018-01-12 Thread João Sebastião de Oliveira Bueno

João Sebastião de Oliveira Bueno <gwid...@gmail.com> added the comment:

This discussion is fresh, so maybe it is worth asking here prior to 
python-ideas:

In Python we can change any global variable, object attribute or mapping-value 
with function calls. Locals and nonlocals are the only exceptions and from time 
to time that gets in the way of clever oneliners, and it is just plain 
asymmetric. 

What do you say of adding a wrapper to this as an oficial Python function in 
the stdlib? Maybe inspect.setlocal() that could set f_locals and call this?? 
That would  provide a workaround to the asymmetry that locals currently 
experiment. 

It would not impose any extra security risks, since this can be called via 
ctypes already, and also it is not any more subject to abuse than setattr or 
globals()[...] =  can already be abused.

--
nosy: +João.Sebastião.de.Oliveira.Bueno

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue19431>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28672] Explain in the "Data Model" document why arguments to __init__ are ok when __new__ is not defined

2016-11-11 Thread João Sebastião de Oliveira Bueno

New submission from João Sebastião de Oliveira Bueno:

There is an specific Python behavior on object instantiation that is "expected" 
but not explicit, even for avanced users:

When a custom class defines `__init__` with extra parameters, but do not 
overrides `__new__`, it simply works. But if `__new__`is defined it has to 
match `__init__`s signature.

This behavior is not documented anywhere.

I could found this issue was discussed in this thread earlier this year, 
starting with this e-mail:
https://mail.python.org/pipermail/python-list/2016-March/704013.html

I propose the following paragraph from a follow up e-mail by "eryksun at 
gmail.com" to be added to the description of "__new__" in the Data Model 
documentation page:

"""

[The implementation] knows whether a type overrides the __new__ or
__init__ methods. You're expected to consume additional arguments in
this case. However, excess arguments are ignored in object.__new__ if
a type overrides __init__ without overriding __new__ (i.e. your second
example). Excess arguments are also ignored in object.__init__ if a
type overrides __new__ without overriding __init__.
"""
(Source: https://mail.python.org/pipermail/python-list/2016-March/704024.html)

--
assignee: docs@python
components: Documentation
messages: 280633
nosy: João.Sebastião.de.Oliveira.Bueno, docs@python
priority: normal
severity: normal
status: open
title: Explain in the "Data Model" document why arguments to __init__ are ok 
when __new__ is not defined
type: enhancement
versions: Python 3.6

___
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28672>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11842] slice.indices with negative step and default stop

2011-04-13 Thread João Sebastião de Oliveira Bueno

João Sebastião de Oliveira Bueno gwid...@gmail.com added the comment:

I don't see this as a bug. The indices returned in both cases are exactly what 
you need to feed to range, in order to get the correct indices for the provided 
slice parameters.

Perceive that if for 
s = slice(None, None, -2)

It would return anything different from
(9, -1, -2)
It would be impossible to properly generate the desired indices. (With a 0 
instead of -1, we would be missing the last index).

When you pass these numbers with the [ ] notation for being used as 
indices, the negative index is interpreted as len(sequence) - index. In the 
case of -1 in your example it is the same as 9 not the same as one before 
zero.

I recommend closing this as not a bug.

--
nosy: +João.Sebastião.de.Oliveira.Bueno

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11842
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com