[issue2292] Missing *-unpacking generalizations

2008-04-07 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I missed the first line copying the class definition into my previous post. Class 'X' was defined as follows: class X(int): def __hash__(self): print('hash', self)

[issue2568] Seconds range in time unit

2008-04-07 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On the other hand, the time module allows full [00,61] range: >>> [time.strftime('%S',time.strptime(x, '%S')) for x in ('00', '61')] ['00',

[issue2568] Seconds range in time unit

2008-04-07 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Mon, Apr 7, 2008 at 3:42 PM, Anton Fedorov <[EMAIL PROTECTED]> wrote: > There no leap second in 2000th. I was just too lazy too look up the leap second year, but datetime module knows nothing about leap second

[issue2292] Missing *-unpacking generalizations

2008-04-07 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Mon, Apr 7, 2008 at 4:02 PM, Thomas Wouters <[EMAIL PROTECTED]> wrote: > .. The order of evaluation is the same, the > BUILD_SET implementation just hashes the evaluated items in a different > order. You can&

[issue2197] Further simplify dict literal bytecode

2008-04-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Python-3000 discussion <http://mail.python.org/pipermail/python- 3000/2008-March/012753.html> did not reveal any opposition to the idea of batch processing of dict displays. However, a compromise suggestion was made to l

[issue2587] PyString_FromStringAndSize() to be considered unsafe

2008-04-08 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- title: PyString_FromStringAndSize() to be considered unsane -> PyString_FromStringAndSize() to be considered unsafe __ Tracker <[EMAIL PROTECTED]> <http://bugs.py

[issue2588] PyOS_vsnprintf() underflow leads to memory corruption

2008-04-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: As long as snprintf is used with a fixed size buffer using an idiom snprintf(buffer, sizeof(buffer), ..) there is no issue because sizeof(buffer) cannot be zero. AFAICT, this is how python uses PyOS_vsnprintf wrapper. On the

[issue2588] PyOS_vsnprintf() underflow leads to memory corruption

2008-04-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Tue, Apr 8, 2008 at 9:21 PM, Justin Ferguson <[EMAIL PROTECTED]> wrote: > .. > While no one seems to ever use it this way, don't forget that a good > alternative to asprintf() is calling sprintf() with

[issue2586] Integer signedness bugs in zlib modules

2008-04-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: This has just been fixed in the trunk: r62235. -- nosy: +belopolsky __ Tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue2587] PyString_FromStringAndSize() to be considered unsafe

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I agree that PySSL_SSLread should check that its argument is >= 0. I don't think this check belongs to PyString_FromStringAndSize. It should be the responsibility of the caller to verify that the preconditio

[issue2588] PyOS_vsnprintf() underflow leads to memory corruption

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 9, 2008 at 1:16 PM, Justin Ferguson <[EMAIL PROTECTED]> wrote: .. > That said, theres plenty of other implementations that manage this > without the potential of underflowing a buffer > Do you have i

[issue2587] PyString_FromStringAndSize() to be considered unsafe

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 9, 2008 at 1:20 PM, Justin Ferguson <[EMAIL PROTECTED]> wrote: .. > Do I need to create proof of concepts for each of these bugs, or can I > reference this ticket? > It would be best if you could pro

[issue2587] PyString_FromStringAndSize() to be considered unsafe

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 9, 2008 at 3:08 PM, Justin Ferguson <[EMAIL PROTECTED]> wrote: > Okay, so I'm not sure whose point of view takes precedence here? I don't have a strong view on this, but just a few points to co

[issue2568] Seconds range in time unit

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 9, 2008 at 2:49 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: > Isn't the bug here rather that strptime doesn't allow leap seconds? This is not specific to strptime. The datetime module do

[issue2599] allow field_name in format strings to default to next positional argument (e.g., "{}")

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Omitting the ordinals from {} format units will present a problem with internationalization because the arguments may need to be rendered in different order in different languages. This is a frequent problem with the % formats

[issue2598] "{ +(}".format(**{' +(': 44}) should produce ValueError: invalid identifier, ' +(' in format

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: This is a feature explained in PEP 3101: """ Implementation note: The implementation of this proposal is not required to enforce the rule about a simple or dotted name being a valid Python identifier.

[issue2603] Make range __eq__ work

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Your patch does not check the return values of PyObject_RichCompare calls for NULL. This is probably ok given the current restrictions on the type of start/step/stop, but adding the null checks will make the code more

[issue2603] Make range __eq__ work

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Actually, the patch contains an exploitable bug: $ cat x.py class X(int): def __eq__(self, other): raise ValueError x = range(X(1),X(10),X(1)) x == x $ ./python x.py Segmentation fault (core

[issue2603] Make range __eq__ work

2008-04-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 9, 2008 at 6:08 PM, Georg Brandl <[EMAIL PROTECTED]> wrote: > Ah yes, and variable declarations must be at the start of a block You can avoid the need for extra local variables by declaring range_richcompa

[issue2603] Make range __eq__ work

2008-04-10 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Thu, Apr 10, 2008 at 3:16 AM, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote: > > And, a __hash__ method should be added. > See issue2268 for a slice.__hash__ implementation which sho

[issue2607] why is (default)dict so slow on tuples???

2008-04-10 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: My guess is that this is due to the fact that strings cache their hash values while tuples don't. IIRC, caching tuple's hash values has been proposed and rejected some time ago. Furthermore, dict lookups are heavily o

[issue2609] Tests fail if ./@test is not writeable

2008-04-10 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: If @test file is not writable in the current directory, test_support.TESTFN is changed to '/tmp/@test', but several tests fail if TESTFN is an absolute path: $ mkdir @test $ make test .. 4 tests failed: test_

[issue2586] Integer signedness bugs in zlib modules

2008-04-10 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Thu, Apr 10, 2008 at 1:17 PM, David Remahl <[EMAIL PROTECTED]> wrote: > I submit that a check for negative values (non-assert-based) should be > added to PyString_FromStringAndSize(). See is

[issue2587] PyString_FromStringAndSize() to be considered unsafe

2008-04-10 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 9, 2008 at 8:18 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > [*sigh* i wish we didn't use a signed size type all over the place] > > What would you use for error returns then? >

[issue2587] PyString_FromStringAndSize() to be considered unsafe

2008-04-10 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Thu, Apr 10, 2008 at 3:48 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: Maybe as the first step we could get rid of the size sign abuse in long integer objects. I would suggest reserving a bit in the first (or la

[issue1738] filecmp.dircmp does exact match only

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: +1 on adding the match argument. Can you comment on how one would implement the old behavior? I would guess match=lambda x,y: x in y, which is not that bad, but maybe that should be the default and those who need pattern ma

[issue2610] string representation of range

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: -1 I don't think <0, 1, ..., 9> is much clearer than range(0, 10). The only problem students may have is that 10 not in range(0, 10), but this can be learned very quickly. The <..> repr breaks x == eval(repr(

[issue2610] string representation of range

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I did not realize that the proposed patch only affects str and not repr. Some of may previous arguments against it do not hold in this case, but I am still -1. If you introduce range before list, it will be hard to explain why

[issue2610] string representation of range

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: It looks like our messages have crossed in flight. > this little patch allows them to print(range(100,0,-1)) > and get a much better intuition about what is happening. This is a really bad example. Why would you want to i

[issue1738] filecmp.dircmp does exact match only

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 11, 2008 at 12:10 PM, Michael Amrhein <[EMAIL PROTECTED]> wrote: > .. > a) A string given in ignore contains wildcard character(s): > In this case this parameter would have no effect in the previ

[issue2610] string representation of range

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 11, 2008 at 12:06 PM, Brad Miller <[EMAIL PROTECTED]> wrote: > Our use of range in the first few classes is exactly for iteration > purposes, but I do not like students to have to have too many mysteri

[issue1738] filecmp.dircmp does exact match only

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: As you are working on this, please consider changing self.hide+self.ignore in phase0 to chain(self.hide, self.ignore) where chain should be imported from itertools. There is no need to create the combined list (twice!) and not acc

[issue2610] string representation of range

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 11, 2008 at 2:45 PM, Brad Miller <[EMAIL PROTECTED]> wrote: .. > My question is how does this get resolved. When I posted this idea to > python-dev Guido suggested an approach. Nobody else expressed an o

[issue2620] Multiple buffer overflows in unicode processing

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Note that in r61458 Neal replaced PyMem_RESIZE with a direct call to PyMem_REALLOC thus eliminating integer overflow check even from the debug builds. -- nosy: +belopolsky, nnorwitz __ T

[issue2620] Multiple buffer overflows in unicode processing

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Justin, Where did you find the definition that you cited: 95 #define PyMem_RESIZE(p, type, n) \ 96 ( assert((n) <= PY_SIZE_MAX / sizeof(type)) , \ 97 ( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) ) ?

[issue2620] Multiple buffer overflows in unicode processing

2008-04-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: The following simple change should be enough for this issue, but I would consider implementing the overflow check in the PyMem_RESIZE and PyMem_NEW macros and de-deprecate the

[issue2620] Multiple buffer overflows in unicode processing

2008-04-13 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Sun, Apr 13, 2008 at 11:12 PM, Gregory P. Smith <[EMAIL PROTECTED]> wrote: .. > Here's a patch that fixes this by making both Python's malloc and > realloc return NULL if (0 <= size <= PY_SSIZE

[issue2603] Make range __eq__ work

2008-04-15 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: The patch does not add unit tests for hash(range(..)). I would actually test that hash(range(a,b,c)) == hash((a,b,c)) for various values of a, b, and c. A nit-pick: while I personally like the coding style with line breaks

[issue2603] Make range __eq__ work

2008-04-15 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Tue, Apr 15, 2008 at 10:21 PM, Benjamin Peterson <[EMAIL PROTECTED]> wrote: > I'm not really sure what to do about the hash. I > just removed the Py_SIZE parts. I hope that's OK. If you want to maintai

[issue2603] Make range __eq__ work

2008-04-16 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: With range_eq5.patch applied on an x86-64 Linux box: $ ./python Python 3.0a4+ (py3k:62359M, Apr 16 2008, 13:36:31) [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2 Type "help", "copyright", "credits&quo

[issue2603] Make range __eq__ work

2008-04-16 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: range_eq5.patch fails to reproduce tuple hash because in the tuple hash implementation the len variable varies between iterations over items. I would just use literals for the three different values of mult rather than copyin

[issue2603] Make range __eq__ work

2008-04-16 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 16, 2008 at 3:40 PM, Antoine Pitrou <[EMAIL PROTECTED]> wrote: .. > Why would you want to have hash(range(a,b,c)) == hash((a,b,c)) ? No particular reason other than that this is easy to test and gives some

[issue2603] Make range __eq__ work

2008-04-16 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 16, 2008 at 9:24 PM, Benjamin Peterson wrote: .. > Why not just hash a tuple? There are a few reasons, but neither is good enough to have another round of code review :-) 1. It is strange to have the hash function

[issue2646] Python does not accept unicode keywords

2008-04-16 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I would say this is a good idea for 2.6. Note that C functions are more forgiving: >>> from datetime import * >>> date(1,2,**{u'day':10}) datetime.date(1, 2, 10) >>> dict(**{u'x':1

[issue2646] Python does not accept unicode keywords

2008-04-16 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: Added file: http://bugs.python.org/file10045/issue2646.diff __ Tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue2663] shutil.copytree glob-style filtering [patch]

2008-04-21 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On the interface, I would suggest renaming 'exclude' to 'ignore' for consistency with filecmp.dircmp. Also consider detecting file separator in the patterns and interpreting them as an absolute (if patte

[issue2668] apply() documentation is slightly incorrect

2008-04-22 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: Current Doc/library/functions.rst says "The use of apply() is exactly equivalent to function(*args, **keywords)." which is no longer correct because f(*args, **keywords) notation allows use of an arbitrary mapping as

[issue2672] speed of set.update([])

2008-04-23 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: This has nothing to do with set.update, the difference is due to the time to setup the generator: $ python -m timeit -s 'x = set(range(1)); y = []' 'x.update(y)' 100 loops, best of 3: 0.38 usec per loo

[issue2672] speed of set.update(

2008-04-24 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Thu, Apr 24, 2008 at 2:23 PM, John Arbash Meinel <[EMAIL PROTECTED]> wrote: .. > So if you compare consuming a generator multiple times to creating it > each time, it is 0.662 usec - 0.173 usec = 0.489 usec to

[issue2689] Fix indentation in range_item

2008-04-25 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- components: Interpreter Core files: range.diff keywords: patch nosy: belopolsky severity: normal status: open title: Fix indentation in range_item versions: Python 3.0 Added file: http://bugs.python.org/file10104/rang

[issue2690] Precompute range length

2008-04-25 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: Attached patch makes range objects precompute their length on creation. This speeds up indexing and len at the expense of a small increase in range object size. The main benefit, however is that unsupported length > sy

[issue2691] Document size_t related long object APIs

2008-04-25 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: Attached patch adds documentation for the new in 2.5 APIs: PyObject* PyLong_FromSsize_t(Py_ssize_t v) PyObject* PyLong_FromSize_t(size_t v) and Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) -- assignee: georg.

[issue2691] Document size_t related long object APIs

2008-04-25 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2691> __ ___ Python-bugs-list mailing list

[issue2691] Document size_t related long object APIs

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: - __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2691> __ ___ Python-bugs-list mailing list

[issue2691] Document size_t related long object APIs

2008-04-25 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2691> __ ___ Python-bugs-list mailing list

[issue2691] Document size_t related long object APIs

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Web submission did not work. Trying sending the patch as an e-mail attachment. -- keywords: +patch Added file: http://bugs.python.org/file10108/doc-long.diff __ Tracker <[EMAIL

[issue2691] Document size_t related long object APIs

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: For some reason the tracker web interface fails to upload the patch. Trying again with this message, if it fails again, will resubmit by e- mail. __ Tracker <[EMAIL PROTECTED]> <http://

[issue2690] Precompute range length

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 25, 2008 at 12:55 PM, Mark Dickinson <[EMAIL PROTECTED]> wrote: .. > I don't much like this aspect of the change: there are uses for > > for i in range(ridiculously_large_number): For this app

[issue2690] Precompute range length

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Option (3) would require changing both sq_item and sq_length signatures, which is likely to have a large negative impact on performance. Option (2) would either require a change for the sq_length signature, or leave the prob

[issue2690] Precompute range length

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 25, 2008 at 4:37 PM, Mark Dickinson <[EMAIL PROTECTED]> wrote: .. > for i in range(1, p): > if (i_is_a_nonresidue_modulo_p): > break > > Here p might be a 200-digit prime number, and

[issue2689] Fix indentation in range_item

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 25, 2008 at 4:37 PM, Benjamin Peterson <[EMAIL PROTECTED]> wrote: > > I don't really see what's wrong with the indentation. Sorry, I thought it would be obvious from the patch. As of revision

[issue2603] Make range __eq__ work

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 25, 2008 at 5:31 PM, Benjamin Peterson <[EMAIL PROTECTED]> wrote: > Comments? In the range_hash function, len, start, step locals should be declared Py_ssize_t, not long. Also, you can use range_leng

[issue2603] Make range __eq__ work

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: It looks like e-mail processor eats '>>>' examples. My examples were >>> range(2**100) == range(2**100+1) Traceback (most recent call last): File "", line 1, in OverflowError: Pytho

[issue2603] Make range __eq__ work

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 25, 2008 at 5:57 PM, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote: .. > - Did you change your mind about range equality? > range(0,10,2) == range(0,9,2) > seems True now; it was not with ran

[issue2603] Make range __eq__ work

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, Apr 25, 2008 at 7:10 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: .. > I think I'd be okay with normalization on creation, so that range(0, > 5, 2) returns range(0, 6, 2). Hm, but isn't that o

[issue2603] Make range __eq__ work

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: With respect to range_eq8_normalize2.patch, it is unusual to have a function that consumes a reference to its argument. I would combine normalize_stop with PyNumber_Index and make it similar to validate_step with resp

[issue2603] Make range __eq__ work

2008-04-25 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: ... and your patch produces wrong results: >>> list(range(5,0,-2)) # expected [5, 3, 1] [5, 3] See my patch in issue2690 for a way to compute length correctly in range_new. __

[issue1950] Potential overflows due to incorrect usage of PyUnicode_AsString.

2008-04-26 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: The patch looks good. Just a question: I thought the strings returned by PyUnicode_AsStringAndSize are 0-terminated, while your patch at several places attempts to explicitly 0-terminate a copy of such string. Are you sure t

[issue2690] Precompute range length

2008-04-28 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I've implemented range slicing and x in range(..) in range-sequence.diff and registered range with the Sequence ABC. Added file: http://bugs.python.org/file10131/range-sequence.diff __ Trac

[issue2690] Precompute range length

2008-04-28 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Reviewing my own patch (range-sequence.diff), I've realized that it is being a bit too clever in handling x in range(..) where x is not an integer. It seems that upon a failed PyLong_Check, range_contains should just

[issue2690] Precompute range length

2008-04-28 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: > For me, range() should mimic a number generator: no limit, no length. That's itertools.count() __ Tracker <[EMAIL PROTECTED]> <http://bu

[issue2723] Truncate __len__() at sys.maxsize

2008-04-29 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: On Tue, Apr 29, 2008 at 10:36 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: .. > Let's also fix __len__() so that it returns sys.{maxint,maxsize} when > the result doesn't fit in a Py_ssize_t. http

[issue2723] Truncate __len__() at sys.maxsize

2008-04-29 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- type: -> feature request __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2723> __ ___

[issue2723] Truncate __len__() at sys.maxsize

2008-04-30 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 30, 2008 at 2:32 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > Wouldn't it be better to raise OverflowError or somesuch? Thats what the current code does. I don't know what Guido's full

[issue2719] Backport next()

2008-04-30 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I thought new code is supposed to use Py_TYPE macro instead of ->ob_type: + "%.200s object is not an iterator", it->ob_type- >tp_name); .. + res = (*it->ob_type->tp_iternext)

[issue2719] Backport next()

2008-04-30 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: One more question: What is the rationale for + res = (*it->ob_type->tp_iternext)(it); + if (res == NULL) { .. + PyErr_SetNone(PyExc_StopIteration); + return NULL;

[issue2719] Backport next()

2008-04-30 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 30, 2008 at 12:41 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > > Guido van Rossum <[EMAIL PROTECTED]> added the comment: > > > .. builtin_next() should return > > NULL with

[issue2719] Backport next()

2008-04-30 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Wed, Apr 30, 2008 at 12:41 PM, Guido van Rossum <[EMAIL PROTECTED]> wrote: > the iternext slot is designed to return NULL without setting an > exception. This is not what the documentation says:

[issue2727] clarify tp_nextiter behavior in the C API documentation

2008-04-30 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: See discussion in issue2719 for details. -- assignee: georg.brandl components: Documentation files: doc-typeobj.diff keywords: patch messages: 66016 nosy: belopolsky, georg.brandl severity: normal status: open title: c

[issue2735] range: lean and mean

2008-05-01 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: The start/step/stop getter functions should INCREF return values. Is there a reason not to adapt slice implementation: static PyMemberDef slice_members[] = { {"start", T_OBJECT, offsetof(PySliceObject,

[issue2735] range: lean and mean

2008-05-01 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: - With length precomputed in range_new, we can probably get rid of get_len_of_range. - There is no need to recompute length in range_iter. A nit: iterator object's size member is called "len", but the same

[issue2735] range: lean and mean

2008-05-02 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: One more nit: you don't need to zero out trailing range_as_sequence members explicitly. static PySequenceMethods range_as_sequence = { (lenfunc)range_length, /* sq_length */ }; shoul

[issue2650] re.escape should not escape underscore

2008-05-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Lorenz's patch uses a set, not a list for special characters. Set lookup is as fast as dict lookup, but a set takes less memory because it does not have to store dummy values. More importantly, use of frozenset inst

[issue2650] re.escape should not escape underscore

2008-05-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Thu, May 8, 2008 at 10:36 AM, Russ Cox <[EMAIL PROTECTED]> wrote: .. > The title of this issue (#2650) is "re.escape should not escape underscore", > not "re.escape is too slow and too easy to rea

[issue2650] re.escape should not escape underscore

2008-05-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Thu, May 8, 2008 at 11:45 AM, Russ Cox <[EMAIL PROTECTED]> wrote: .. > My argument is only that Python should behave the same in > this respect as other systems that use substantially the same > regular expres

[issue2786] Names in traceback should have class names, if they're methods

2008-05-08 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: This is similar to issue2516. -- nosy: +belopolsky __ Tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue2804] Integer right shift raises OverflowError when second operand is large

2008-05-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Attached patch makes a >> b return 0 for b > maxsize. -- keywords: +patch nosy: +belopolsky Added file: http://bugs.python.org/file10234/issue2804.diff __ Tracker <[EMAIL

[issue2804] Integer right shift raises OverflowError when second operand is large

2008-05-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On the second thought, it is theoretically possible to have a long int a for which a >> maxsize is not zero because that would require only maxsize/15 digits. I am not sure it is worth the trouble to acco

[issue2804] Integer right shift raises OverflowError when second operand is large

2008-05-09 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Fri, May 9, 2008 at 7:08 PM, Martin v. Löwis <[EMAIL PROTECTED]> wrote: .. > I'm -1 on this patch (or any other fixing the perceived problem). > Special cases aren't special enough to break the rules. &g

[issue2723] Truncate __len__() at sys.maxsize

2008-05-11 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: On Sun, May 11, 2008 at 6:38 PM, Gregory P. Smith <[EMAIL PROTECTED]> wrote: .. > But I must've missed something, why can't __len__ return the correct > value? The problem is the C signature of the sq_leng

[issue4197] Doctest module does not work with zipped packages

2008-10-24 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: With attached teestmodule.zip and svn revision 67006, $ ./python.exe testmodule.zip Traceback (most recent call last): File "/Users/sasha/Work/python-svn/trunk/Lib/runpy.py", line 121, in _run_module_as_main &

[issue4197] Doctest module does not work with zipped packages

2008-10-24 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: Attached patch addresses the crash, but two issues remain: $ ./python.exe testmodule.zip ** File "__main__", line ?, in __main__.c Failed exam

[issue4197] Doctest module does not work with zipped packages

2008-10-24 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- keywords: +patch Added file: http://bugs.python.org/file11878/doctest.patch ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue4197] Doctest module does not work with zipped packages

2008-10-24 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: The next patch, doctest-1.patch addresses the line number issue, but the file name is still wrong. $ ./python.exe testmodule.zip ** File "__main__&q

[issue4197] Doctest module does not work with zipped packages

2008-10-24 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: I don't think there is an easy way to fix source file name reporting without injecting __file__ = '/' into the module namespace is zipimporter, but I don't know if any code relies on __file__ set to None. S

[issue4201] Pdb cannot access source code in zipped packages.

2008-10-24 Thread Alexander Belopolsky
New submission from Alexander Belopolsky <[EMAIL PROTECTED]>: With attached test.zip and svn revision 67006, $ ./python.exe test.zip > /Users/sasha/Work/python-svn/trunk/test.zip/__main__.py(2)f() (Pdb) l [EOF] With pdb.patch: $ ./python.exe test.zip > /Users/sasha/Work/pyth

[issue4201] Pdb cannot access source code in zipped packages.

2008-10-24 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- keywords: +patch Added file: http://bugs.python.org/file11883/pdb.patch ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue4201] Pdb cannot access source code in zipped packages.

2008-10-24 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- components: +Library (Lib) type: -> behavior versions: +Python 2.5.3 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.py

[issue4197] Doctest module does not work with zipped packages

2008-10-24 Thread Alexander Belopolsky
Changes by Alexander Belopolsky <[EMAIL PROTECTED]>: -- versions: +Python 2.5.3, Python 2.6 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.pytho

[issue4223] inspect.getsource doesn't work on functions imported from a zipfile

2008-10-28 Thread Alexander Belopolsky
Alexander Belopolsky <[EMAIL PROTECTED]> added the comment: This must be very similar to #4197 and #4201 that I reported a few days ago. I'll see if a similar patch would work in this case. -- nosy: +belopolsky ___ Python tracker <[E

<    10   11   12   13   14   15   16   17   18   19   >