[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Changes by Eugene Kapun : Added file: http://bugs.python.org/file19618/test-functools.py ___ Python tracker <http://bugs.python.org/issue6083> ___ ___ Python-bugs-list m

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Changes by Eugene Kapun : Added file: http://bugs.python.org/file19617/test-ctypes.py ___ Python tracker <http://bugs.python.org/issue6083> ___ ___ Python-bugs-list mailin

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Eugene Kapun added the comment: Actually, this can't be fixed without modifying C API methods PyArg_ParseTuple and PyArg_ParseTupleAndKeywords, because it's possible to make an object deallocated before PyArg_ParseTuple returns, so Py_INCREF immediately after parsing would be a

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Changes by Eugene Kapun : Added file: http://bugs.python.org/file16981/repr.diff ___ Python tracker <http://bugs.python.org/issue8420> ___ ___ Python-bugs-list mailin

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun added the comment: This code crashes python by using another bug in set_repr. This only affects py3k. This code relies on out-of-memory condition, so run it like: $ (ulimit -v 65536 && python3 test.py) Otherwise, it will eat all your free memory before crashing. val = &qu

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun added the comment: > > One solution is to check that so->mask didn't > > change as well. > > I saw that and agree it would make a tighter check, but haven't convinced > myself that it is necessary. Without this check, it is possible that th

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun added the comment: This patch still assumes that if so->table didn't change then the table wasn't reallocated (see http://en.wikipedia.org/wiki/ABA_problem). One solution is to check that so->mask didn't change as well. Also, checking that refcnt > 1

[issue8436] set.__init__ accepts keyword args

2010-04-17 Thread Eugene Kapun
New submission from Eugene Kapun : >>> list().__init__(a=0) Traceback (most recent call last): File "", line 1, in TypeError: 'a' is an invalid keyword argument for this function >>> set().__init__(a=0) -- components: Interpreter Core messages:

[issue8420] Objects/setobject.c contains unsafe code

2010-04-17 Thread Eugene Kapun
Changes by Eugene Kapun : -- type: -> crash ___ Python tracker <http://bugs.python.org/issue8420> ___ ___ Python-bugs-list mailing list Unsubscri

[issue8435] It is possible to observe a mutating frozenset

2010-04-17 Thread Eugene Kapun
New submission from Eugene Kapun : This code shows that frozensets aren't really immutable. The same frozenset is printed twice, with different content. Buggy functions are set_contains, set_remove and set_discard, all in Objects/setobject.c class bad: def __eq__(self,

[issue8420] Objects/setobject.c contains unsafe code

2010-04-17 Thread Eugene Kapun
Eugene Kapun added the comment: I've found more unsafe code in Objects/setobject.c. This code makes Python 3.1.2 segfault by using a bug in function set_merge: class bad: def __eq__(self, other): if be_bad: set2.

[issue8401] Strange behavior of bytearray slice assignment

2010-04-17 Thread Eugene Kapun
Eugene Kapun added the comment: -1 on special-casing string without an encoding. Current code does (almost) this: ... if argument_is_a_string: if not encoding_is_given: # Special case raise TypeError("string argument without an encoding") encod

[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun : >>> small_set = set(range(2000)) >>> large_set = set(range(2000)) >>> large_set -= small_set # Fast >>> small_set -= large_set # Slow, should be fast >>> small_set = small_set - large_set # Fast -- compo

[issue8420] set_lookkey is unsafe

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun : I've noticed that set_lookkey (in Objects/setobject.c) does some unsafe things: Objects/setobject.c: > if (entry->hash == hash) { > startkey = entry->key; > Py_INCREF(startkey); > cmp = PyObject_RichCompareBo

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun added the comment: __doc__ of bytearray says: > bytearray(iterable_of_ints) -> bytearray > bytearray(string, encoding[, errors]) -> bytearray > bytearray(bytes_or_bytearray) -> mutable copy of bytes_or_bytearray > bytearray(memory_view) -> bytearray So, unl

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun added the comment: > Not really, chars are not ints Yes, however, empty string contains exactly zero chars. > and anyway the empty string fall in the first case. Strings aren't mentioned in documentation of bytearray slice assignment. However, I think that bytearray

[issue1766304] improve xrange.__contains__

2010-04-16 Thread Eugene Kapun
Changes by Eugene Kapun : -- nosy: +abacabadabacaba ___ Python tracker <http://bugs.python.org/issue1766304> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue8417] bytes and bytearray constructors raise TypeError for very large ints

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun : >>> bytes(10) b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' >>> bytes(10 ** 100) Traceback (most recent call last): File "", line 1, in TypeError: 'int' object is not iterable -- components: Interpr

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun added the comment: Empty string is an iterable of integers in the range 0 <= x < 256, so it should be allowed. >>> all(isinstance(x, int) and 0 <= x < 256 for x in "") True >>> bytearray()[:] = "" Traceback (most recent ca

[issue8401] Strange behavior of bytearray slice assignment

2010-04-14 Thread Eugene Kapun
New submission from Eugene Kapun : >>> a = bytearray() >>> a[:] = 0 # Is it a feature? >>> a bytearray(b'') >>> a[:] = 10 # If so, why not document it? >>> a bytearray(b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00') >>> a[:]