[issue2730] file readline w+ memory dumps

2008-05-01 Thread tempname

New submission from tempname <[EMAIL PROTECTED]>:

the following code actually dumps the heap into the temp file... very
strange. Make sure the file doesn't exist before running the script.
Only the list of numbers should be written to the file, but alot of junk
is added.

x = str(range(10))
f = open('c:\\temp.txt', 'w+')
f.write(x)
for i in range(10):
y = f.readline()
print repr(y)

f.close()

--
components: None
messages: 66032
nosy: tempname1234
severity: normal
status: open
title: file readline w+ memory dumps
type: security
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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



[issue2636] Regexp 2.6 (modifications to current re 2.2.2)

2008-05-01 Thread Jeffrey C. Jacobs

Jeffrey C. Jacobs <[EMAIL PROTECTED]> added the comment:

I am making my changes in a Bazaar branch hosted on Launchpad.  It took
me quite a while to get things set up more-or-less logically but there
they are and I'm currently trying to re-apply my local changes up to
today into the various branches I have.  Each of the 11 issues I
outlined originally has its own branch, with a root branch from which
all these branches are derived to serve as a place for a) merging in
python 2.6 alpha concurrent development (merges) and to apply any
additional re changes that don't fall into any of the other categories,
of which I have so far found only 2 small ones.

Anyway, if anyone is interested in monitoring my progress, it is
available at:

https://code.launchpad.net/~timehorse/

I will still post major milestones here, but one can monitory day-to-day 
progress on Launchpad.  Also on launchpad you will find more detail on
the plans for each of the 11 modifications, for the curious.

Thanks again for all the advice!

__
Tracker <[EMAIL PROTECTED]>

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



[issue2731] Documentation error on prime example in tutorial

2008-05-01 Thread Gerald Schlüter

New submission from Gerald Schlüter <[EMAIL PROTECTED]>:

Hi there,

on the page "controlflow.html" in chapter "break and continue 
Statements..." the line:

print(n, 'equals', x, '*', n/x)
should be changed to:
print(n, 'equals', x, '*', n//x)
or else the shown output should be modified.

Thank you,
Gerry

--
assignee: georg.brandl
components: Documentation
messages: 66034
nosy: georg.brandl, gls
severity: normal
status: open
title: Documentation error on prime example in tutorial
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue2732] curses.textpad loses characters at the end of lines

2008-05-01 Thread Shish

New submission from Shish <[EMAIL PROTECTED]>:

Even in the self-test suite, the bug appears, run:

python /usr/lib/python2.4/curses/textpad.py

then type so that the line wraps, eg 123456789123456789 to fill two 
lines, and then ctrl-g to return -- the result has had the end 
characters of each line removed, so the return value is 
12345678\n12345678\n

As a quick hack on my local install I changed line 56 from:

last = min(self.maxx, last+1)

to

last = min(self.maxx, last)+1

and it seems to work, but I have no idea if this is the right way to 
fix it (ie, this might have side effects, or this off-by-one might 
happen in several places and need a global fix, not just one local one)

--
components: Extension Modules
messages: 66035
nosy: shish
severity: normal
status: open
title: curses.textpad loses characters at the end of lines
versions: Python 2.4

__
Tracker <[EMAIL PROTECTED]>

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



[issue2733] mmap resize fails on anonymous memory (Windows)

2008-05-01 Thread Kathryn M Kowalski

New submission from Kathryn M Kowalski <[EMAIL PROTECTED]>:

We have a shared memory module that has been running fine on Windows 
with Active State Python 2.4.3 Build 12.  On machines with 2.5.1.1 
mmap.resize fails on an existing anonymous shared memory.  The attached 
file is a stripped down version of the code to illustrate the problem.  
Start it running in one window to create the shared memory, then in 
another window run it again to hook into existing shared memory. Result:
Testing SharedMemory
open -self.memory_size 336
Traceback (most recent call last):
  File "C:/home/weather/TESTOF~1.PY", line 164, in 
example()
  File "C:/home/weather/TESTOF~1.PY", line 147, in example
sm = SharedMemory( 'my_shared_memory')
  File "C:/home/weather/TESTOF~1.PY", line 31, in __init__
self.__open()
  File "C:/home/weather/TESTOF~1.PY", line 94, in __open
self.memory.resize(self.memory_size)
WindowsError: [Error 8] Not enough storage is available to process this 
command

--
components: Library (Lib)
files: testofResizeB.txt
messages: 66036
nosy: kmk
severity: normal
status: open
title: mmap resize fails on anonymous memory (Windows)
type: crash
versions: Python 2.5
Added file: http://bugs.python.org/file10151/testofResizeB.txt

__
Tracker <[EMAIL PROTECTED]>

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



[issue2732] curses.textpad loses characters at the end of lines

2008-05-01 Thread Shish

Changes by Shish <[EMAIL PROTECTED]>:


--
type:  -> behavior

__
Tracker <[EMAIL PROTECTED]>

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



[issue2731] Documentation error on prime example in tutorial

2008-05-01 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Thanks, fixed in r62615.

--
resolution:  -> fixed
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue2734] 2to3 converts long(itude) argument to int

2008-05-01 Thread Charles McCreary

New submission from Charles McCreary <[EMAIL PROTECTED]>:

The 2to3 converter converts variables named "long" to "int".
Original:
long is an argument (longitude)
def add_test_qtrmin(tdb, lat, long, area_id, call_center=""):

Converted:

def add_test_qtrmin(tdb, lat, int, area_id, call_center=""):

I can see what it is trying to do, but I definitely don't want this
behavior!

--
assignee: collinwinter
components: 2to3 (2.x to 3.0 conversion tool)
messages: 66038
nosy: collinwinter, crmccreary
severity: normal
status: open
title: 2to3 converts long(itude) argument to int
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue2512] decide what to do with gettext API

2008-05-01 Thread Guido van Rossum

Guido van Rossum <[EMAIL PROTECTED]> added the comment:

This patch doesn't apply cleanly. :-(

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue2730] file readline w+ memory dumps

2008-05-01 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment:

This is a duplicate of issue1394612, which was closed as "invalid". See
the discussion there:

- "in standard C mixing reads with writes yields undefined behavior [...]
If you want defined behavior, then, for example, add
>>> f.seek(0)
between your write() and read() calls."""

BTW, python 3.0 has a new implementation of the I/O stack, which does
not use fopen, and does not have this problem.

--
nosy: +amaury.forgeotdarc
resolution:  -> wont fix
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue2734] 2to3 converts long(itude) argument to int

2008-05-01 Thread Collin Winter

Collin Winter <[EMAIL PROTECTED]> added the comment:

Agreed. There's code in fix_next to detect this kind of case. I'll see
what I can do about generalizing it to support fix_long.

__
Tracker <[EMAIL PROTECTED]>

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



[issue2512] decide what to do with gettext API

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

I've pushed a fresh branch and am attaching a new patch.

Added file: http://bugs.python.org/file10153/gettext_api2.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue2735] range: lean and mean

2008-05-01 Thread Benjamin Peterson

New submission from Benjamin Peterson <[EMAIL PROTECTED]>:

Per discussions on Python-3000, I've stipped range down to a bare
minimum. Here's an overview of the patch:

1. No slicing.
2. Length is computed in constructor and is a PyLong in the object's
struct. __len__ simply tries to convert it to a Py_ssize_t.
3. start, stop, and, step are exposed as attributes

--
assignee: gvanrossum
components: Interpreter Core
files: range_lean_and_mean.patch
keywords: patch
messages: 66042
nosy: benjamin.peterson, gvanrossum
severity: normal
status: open
title: range: lean and mean
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file10152/range_lean_and_mean.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue2733] mmap resize fails on anonymous memory (Windows)

2008-05-01 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc <[EMAIL PROTECTED]> added the comment:

It seems that you attached the output file instead of a python script...

--
nosy: +amaury.forgeotdarc

__
Tracker <[EMAIL PROTECTED]>

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



[issue2736] datetime needs and "epoch" method

2008-05-01 Thread Miki Tebeka

New submission from Miki Tebeka <[EMAIL PROTECTED]>:

If you try to convert datetime objects to seconds since epoch and back
it will not work since the microseconds get lost:

>>> dt = datetime(2008, 5, 1, 13, 35, 41, 56)
>>> seconds = mktime(dt.timetuple())
>>> datetime.fromtimestamp(seconds) == dt
False

Current fix is to do
>>> seconds += (dt.microsecond / 100.0)
>>> datetime.fromtimestamp(seconds) == dt
True

--
components: Library (Lib)
messages: 66045
nosy: tebeka
severity: normal
status: open
title: datetime needs and "epoch" method
type: behavior
versions: Python 2.6, Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue2723] Truncate __len__() at sys.maxsize

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

If you're interested I asked a Java news group:
http://groups.google.com/group/comp.lang.java.programmer/browse_thread/thread/fddbc3b1f9fec125#

--
nosy: +benjamin.peterson

__
Tracker <[EMAIL PROTECTED]>

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



[issue1640] Enhancements for mathmodule

2008-05-01 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

The patch was part of the merge of Mark's and my trunk-math branch. It
was merged into the trunk and 3.0 a while ago.

--
resolution:  -> accepted
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue2734] 2to3 converts long(itude) argument to int

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

This seems to happen whenever argument are types that need to be renamed
(eg. unicode -> str) Can this be fixed globally?

--
nosy: +benjamin.peterson

__
Tracker <[EMAIL PROTECTED]>

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



[issue2735] range: lean and mean

2008-05-01 Thread Facundo Batista

Facundo Batista <[EMAIL PROTECTED]> added the comment:

Just for the record: Why __len__ tries to convert it to Py_size_t
(possibly generating an Overflow), and not just returns the PyLong object?

--
nosy: +facundobatista

__
Tracker <[EMAIL PROTECTED]>

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



[issue2735] range: lean and mean

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

__len__ always has to return a Py_ssize_t because that's the data type
that represents lengths in C. It's just the way it is.

__
Tracker <[EMAIL PROTECTED]>

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



[issue2734] 2to3 converts long(itude) argument to int

2008-05-01 Thread Collin Winter

Collin Winter <[EMAIL PROTECTED]> added the comment:

It *could* be implemented for all fixers, but since it's fairly
expensive, I'd rather limit it to cases where the problem is more likely
to occur (for example, unicode -> str doesn't meet this threshold IMHO).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1569] Add VS CRT redist to the MSI installer

2008-05-01 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

As far as I understood recent commits Martin has figured out how to
integrate the VS CRT redist merge modules into the MSI installer. Am I
correct?

--
status: open -> pending

__
Tracker <[EMAIL PROTECTED]>

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



[issue1569] Add VS CRT redist to the MSI installer

2008-05-01 Thread Martin v. Löwis

Martin v. Löwis <[EMAIL PROTECTED]> added the comment:

Correct. This is now fixed.

--
resolution:  -> fixed
status: pending -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue1722344] Thread shutdown exception in Thread.notify()

2008-05-01 Thread Adam Olsen

Adam Olsen <[EMAIL PROTECTED]> added the comment:

This bug was introduced by r53249, which was fixing bug #1566280.

Fixed by moving the WaitForThreadShutdown call into Py_Finalize, so all
shutdown paths use it.  I also tweaked the name to follow local helper
function conventions.

Martin, since you did the previous fix, can you review this one?

--
keywords: +patch
nosy: +loewis
Added file: http://bugs.python.org/file10154/nondaemon_thread_shutdown.diff

_
Tracker <[EMAIL PROTECTED]>

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



[issue1722344] Thread shutdown exception in Thread.notify()

2008-05-01 Thread Adam Olsen

Adam Olsen <[EMAIL PROTECTED]> added the comment:

Oh, and the patch includes a testcase.  The current test_threading.py
doesn't work with older versions, but a freestanding version of this
testcase passes in 2.1 to 2.4, fails in 2.5 and trunk, and passes with
the patch.

_
Tracker <[EMAIL PROTECTED]>

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



[issue2224] branches/trunk-math patch

2008-05-01 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

Closing:  Christian merged the trunk-math branch into the trunk in
r62380.

--
resolution:  -> accepted
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue2705] incompatible change to warnings.showwarning

2008-05-01 Thread Brett Cannon

Brett Cannon <[EMAIL PROTECTED]> added the comment:

Fixed in r62626. I left in the optional arguments but they are just not 
called anymore by the 'warnings' machinery. I might add a 
PendingDeprecationWarning so that people start to add the argument, 
though, for future use.

--
resolution:  -> fixed
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue2705] incompatible change to warnings.showwarning

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

Why don't you add a Py3k warning and keep it in Py3k?

__
Tracker <[EMAIL PROTECTED]>

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



[issue2705] incompatible change to warnings.showwarning

2008-05-01 Thread Brett Cannon

Brett Cannon <[EMAIL PROTECTED]> added the comment:

On Thu, May 1, 2008 at 7:29 PM, Benjamin Peterson
<[EMAIL PROTECTED]> wrote:
>
>  Benjamin Peterson <[EMAIL PROTECTED]> added the comment:
>
>  Why don't you add a Py3k warning and keep it in Py3k?

Just asked python-dev if they are okay with that. 2.6 could get a
PendingDeprecationWarning and 3.0 could get a DeprecationWarning. But
I don't want to do an API change between the two that breaks code like
that.

__
Tracker <[EMAIL PROTECTED]>

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



[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, start), READONLY}, 
{"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY}, 
{"step", T_OBJECT, offsetof(PySliceObject, step), READONLY}, 
{0} 
};

--
nosy: +belopolsky

__
Tracker <[EMAIL PROTECTED]>

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



[issue2735] range: lean and mean

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

On Thu, May 1, 2008 at 9:38 PM, Alexander Belopolsky
<[EMAIL PROTECTED]> wrote:
>
>  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:

No, its much simpler.

Added file: http://bugs.python.org/file10155/range_lean_and_mean2.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/rangeobject.c
===
--- Objects/rangeobject.c   (revision 62626)
+++ Objects/rangeobject.c   (working copy)
@@ -1,6 +1,7 @@
 /* Range object implementation */
 
 #include "Python.h"
+#include "structmember.h"
 
 /* Support objects whose length is > PY_SSIZE_T_MAX.
 
@@ -14,6 +15,7 @@
 PyObject *start;
 PyObject *stop;
 PyObject *step;
+PyObject *length;
 } rangeobject;
 
 /* Helper function for validating step.  Always returns a new reference or
@@ -43,6 +45,9 @@
 return step;
 }
 
+static PyObject* range_compute_length(PyObject *start,
+  PyObject *stop, PyObject *step);
+
 /* XXX(nnorwitz): should we error check if the user passes any empty ranges?
range(-10)
range(0, -5)
@@ -52,7 +57,7 @@
 range_new(PyTypeObject *type, PyObject *args, PyObject *kw)
 {
 rangeobject *obj = NULL;
-PyObject *start = NULL, *stop = NULL, *step = NULL;
+PyObject *start = NULL, *stop = NULL, *step = NULL, *length = NULL;
 
 if (!_PyArg_NoKeywords("range()", kw))
 return NULL;
@@ -81,25 +86,30 @@
 goto Fail;
 }
 
+length = range_compute_length(start, stop, step);
+if (length == NULL)
+   goto Fail;
 obj = PyObject_New(rangeobject, &PyRange_Type);
 if (obj == NULL)
 goto Fail;
 obj->start = start;
 obj->stop = stop;
 obj->step = step;
+obj->length = length;
 return (PyObject *) obj;
 
 Fail:
 Py_XDECREF(start);
 Py_XDECREF(stop);
 Py_XDECREF(step);
+Py_XDECREF(length);
 return NULL;
 }
 
 PyDoc_STRVAR(range_doc,
 "range([start,] stop[, step]) -> range object\n\
 \n\
-Returns an iterator that generates the numbers in the range on demand.");
+Returns a virtual sequence of numbers from start to stop by step.");
 
 static void
 range_dealloc(rangeobject *r)
@@ -107,6 +117,7 @@
 Py_DECREF(r->start);
 Py_DECREF(r->stop);
 Py_DECREF(r->step);
+Py_DECREF(r->length);
 PyObject_Del(r);
 }
 
@@ -116,8 +127,8 @@
  * Arguments MUST return 1 with either PyLong_Check() or
  * PyLong_Check().  Return -1 when there is an error.
  */
-static PyObject*
-range_length_obj(rangeobject *r)
+static PyObject *
+range_compute_length(PyObject *start, PyObject *stop, PyObject *step)
 {
 /* -
 Algorithm is equal to that of get_len_of_range(), but it operates
@@ -125,7 +136,6 @@
 ---*/
 int cmp_result, cmp_call;
 PyObject *lo, *hi;
-PyObject *step = NULL;
 PyObject *diff = NULL;
 PyObject *one = NULL;
 PyObject *tmp1 = NULL, *tmp2 = NULL, *result;
@@ -134,23 +144,22 @@
 PyObject *zero = PyLong_FromLong(0);
 if (zero == NULL)
 return NULL;
-cmp_call = PyObject_Cmp(r->step, zero, &cmp_result);
+cmp_call = PyObject_Cmp(step, zero, &cmp_result);
 Py_DECREF(zero);
 if (cmp_call == -1)
 return NULL;
 
 assert(cmp_result != 0);
 if (cmp_result > 0) {
-lo = r->start;
-hi = r->stop;
-step = r->step;
+lo = start;
+hi = stop;
 Py_INCREF(step);
 } else {
-lo = r->stop;
-hi = r->start;
-step = PyNumber_Negative(r->step);
+lo = stop;
+hi = start;
+step = PyNumber_Negative(step);
 if (!step)
-return NULL;
+goto Fail;
 }
 
 /* if (lo >= hi), return length of 0. */
@@ -193,46 +202,11 @@
 static Py_ssize_t
 range_length(rangeobject *r)
 {
-PyObject *len = range_length_obj(r);
-Py_ssize_t result = -1;
-if (len) {
-result = PyLong_AsSsize_t(len);
-Py_DECREF(len);
-}
-return result;
+return PyLong_AsSsize_t(r->length);
 }
 
-/* range(...)[x] is necessary for:  seq[:] = range(...) */
 
 static PyObject *
-range_item(rangeobject *r, Py_ssize_t i)
-{
-Py_ssize_t len = range_length(r);
-PyObject *rem, *incr, *result;
-
-/* XXX(nnorwitz): should negative indices be supported? */
-/* XXX(nnorwitz): should support range[x] where x > PY_SSIZE_T_MAX? */
-if (i < 0 || i >= len) {
-if (!PyErr_Occurred())
-PyErr_SetString(PyExc_IndexError,
-"range object index out of range");
-return NULL;
-}
-
-/* XXX(nnorwitz

[issue2720] make compiling struct be passed around to all ast helpers

2008-05-01 Thread Benjamin Peterson

Benjamin Peterson <[EMAIL PROTECTED]> added the comment:

Georg, is it all right if I apply this?

--
assignee:  -> georg.brandl
nosy: +georg.brandl

__
Tracker <[EMAIL PROTECTED]>

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



[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 
member of the range object is called "length."  I have no preference 
between the two names, but I think they should be the same.

Off-topic: why optimized iterator uses long rather than ssize_t 
arithmetics?  On x86-64, ssize_t is 64 and long is 32 bit.

__
Tracker <[EMAIL PROTECTED]>

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