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
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 be
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 expand
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
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
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
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
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 beli
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
Change by Dan Snider :
--
nosy: bup
priority: normal
severity: normal
status: open
title: add "
___
Python tracker
<https://bugs.python.org/issue39528>
___
___
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
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
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__,
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 is that
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 not
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
Change by Dan Snider :
--
nosy: -bup
___
Python tracker
<https://bugs.python.org/issue35331>
___
___
Python-bugs-list mailing list
Unsubscribe:
Change by Dan Snider :
--
nosy: +bup
___
Python tracker
<https://bugs.python.org/issue35331>
___
___
Python-bugs-list mailing list
Unsubscribe:
https://mail.pyth
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
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
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/is
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" operator
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
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
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, "
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
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
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
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` slot:
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}
T
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 do
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 "", lin
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
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
>>&g
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
ac
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
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):
F
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 la
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 lo
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
Change by Dan Snider :
--
keywords: +patch
pull_requests: +8394
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue34497>
___
___
Python-
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
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&
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 im
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 *)
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.
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
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 las
Change by Dan Snider :
--
keywords: +patch
pull_requests: +7616
stage: -> patch review
___
Python tracker
<https://bugs.python.org/issue33998>
___
___
Python-
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
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. Sp
New submission from Dan Snider :
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
components: IDLE
messages: 3
Change by Dan Snider :
--
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" format charact
New submission from Dan Snider :
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 *module) {
digit w = 9;
New submission from Dan Snider :
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 instance of class `cls`. There
New submission from Dan Snider :
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 implicit parenthesis are
ad
Dan Snider 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 implies that
the __class__ cell is the wrong type
Dan Snider 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_FastToLocalsWithError.
Also creating
New submission from Dan Snider :
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__
def new_code(c_or_f):
New submission from Dan Snider :
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, bases, namespace)
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
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 of a
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
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):
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
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
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
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
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
69 matches
Mail list logo