[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Changes by Eugene Kapun abacabadabac...@gmail.com: Added file: http://bugs.python.org/file19617/test-ctypes.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6083

[issue6083] Reference counting bug in PyArg_ParseTuple and PyArg_ParseTupleAndKeywords

2010-11-16 Thread Eugene Kapun
Changes by Eugene Kapun abacabadabac...@gmail.com: Added file: http://bugs.python.org/file19618/test-functools.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6083

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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 the comparison shrinks

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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

[issue8420] Objects/setobject.c contains unsafe code

2010-04-18 Thread Eugene Kapun
Changes by Eugene Kapun abacabadabac...@gmail.com: Added file: http://bugs.python.org/file16981/repr.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8420

[issue8401] Strange behavior of bytearray slice assignment

2010-04-17 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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

[issue8420] Objects/setobject.c contains unsafe code

2010-04-17 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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.clear

[issue8435] It is possible to observe a mutating frozenset

2010-04-17 Thread Eugene Kapun
New submission from Eugene Kapun abacabadabac...@gmail.com: 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

[issue8420] Objects/setobject.c contains unsafe code

2010-04-17 Thread Eugene Kapun
Changes by Eugene Kapun abacabadabac...@gmail.com: -- type: - crash ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8420 ___ ___ Python-bugs-list

[issue8436] set.__init__ accepts keyword args

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

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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 call last): File stdin, line 1, in module

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

2010-04-16 Thread Eugene Kapun
New submission from Eugene Kapun abacabadabac...@gmail.com: bytes(10) b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' bytes(10 ** 100) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'int' object is not iterable -- components: Interpreter Core messages

[issue1766304] improve xrange.__contains__

2010-04-16 Thread Eugene Kapun
Changes by Eugene Kapun abacabadabac...@gmail.com: -- nosy: +abacabadabacaba ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1766304 ___ ___ Python

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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

[issue8401] Strange behavior of bytearray slice assignment

2010-04-16 Thread Eugene Kapun
Eugene Kapun abacabadabac...@gmail.com 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, unless

[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 abacabadabac...@gmail.com: 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 -- components: Interpreter Core messages

[issue8401] Strange behavior of bytearray slice assignment

2010-04-14 Thread Eugene Kapun
New submission from Eugene Kapun abacabadabac...@gmail.com: 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[:] = -1 Traceback (most recent call last): File stdin, line 1