[issue1531] tarfile.open(fileobj=f) and bad metadata of the first file within the archive

2007-12-01 Thread Lars Gustäbel

Changes by Lars Gustäbel:


--
assignee:  -> lars.gustaebel
nosy: +lars.gustaebel

__
Tracker <[EMAIL PROTECTED]>

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



[issue1534] sys.maxfloat patch

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

Applied in r59254.

I've moved the code to floatobject.c/h and added PyFloat_GetMax() and
PyFloat_GetMin(), too. The intobject.c file has a similar function.

--
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



[issue1205] urllib fail to read URL contents, urllib2 crash Python

2007-12-01 Thread jos

jos added the comment:

included torriem's fix.

IMHO, there is no clear solution for this
because this is due to HTTP server's "bug"
and a bug is the one that you can't predict accurately...

Added file: http://bugs.python.org/file8841/httplib.py.diff

__
Tracker <[EMAIL PROTECTED]>

__

httplib.py.diff
Description: Binary data
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1706039] Added clearerr() to clear EOF state

2007-12-01 Thread jos

jos added the comment:

Any chance to get this fix commmited in?

--
type:  -> behavior

_
Tracker <[EMAIL PROTECTED]>

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



[issue1533] Bug in range() function for large values

2007-12-01 Thread Raymond Hettinger

Changes by Raymond Hettinger:


--
assignee:  -> rhettinger
nosy: +rhettinger

__
Tracker <[EMAIL PROTECTED]>

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



[issue1438] Calling base class methods is slow due to __instancecheck__ override in abc.py

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

Unbound methods are gone and so is the isinstance check in method_call().

--
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



[issue1535] Rename __builtin__ to builtins

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

Here is a fixer for the new name.

Added file: http://bugs.python.org/file8843/2to3_builtins.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: tests/test_fixers.py
===
--- tests/test_fixers.py	(Revision 59235)
+++ tests/test_fixers.py	(Arbeitskopie)
@@ -1270,7 +1270,10 @@
 fixer = "imports"
 
 modules = {"StringIO":  ("io", ["StringIO"]),
-   "cStringIO": ("io", ["StringIO"])}
+   "cStringIO": ("io", ["StringIO"]),
+   "__builtin__" : ("builtins", ["open", "Exception",
+   "__debug__", "str"]),
+  }
 
 def test_import_module(self):
 for old, (new, members) in self.modules.items():
@@ -1285,11 +1288,11 @@
 def test_import_from(self):
 for old, (new, members) in self.modules.items():
 for member in members:
-b = "from %s import %s" % (old, ", ".join(members))
-a = "from %s import %s" % (new, ", ".join(members))
+b = "from %s import %s" % (old, member)
+a = "from %s import %s" % (new, member)
 self.check(b, a)
 
-s = "from foo import %s" % ", ".join(members)
+s = "from foo import %s" % member
 self.unchanged(s)
 
 def test_import_module_as(self):
@@ -1305,8 +1308,8 @@
 def test_import_from_as(self):
 for old, (new, members) in self.modules.items():
 for member in members:
-b = "from %s import %s as foo_bar" % (old, ", ".join(members))
-a = "from %s import %s as foo_bar" % (new, ", ".join(members))
+b = "from %s import %s as foo_bar" % (old, member)
+a = "from %s import %s as foo_bar" % (new, member)
 self.check(b, a)
 
 def test_star(self):
Index: fixes/fix_imports.py
===
--- fixes/fix_imports.py	(Revision 59168)
+++ fixes/fix_imports.py	(Arbeitskopie)
@@ -10,9 +10,14 @@
 # Local imports
 from fixes import basefix
 from fixes.util import Name, attr_chain, any, set
+import __builtin__
+builtin_names = [name for name in dir(__builtin__)
+ if name not in ("__name__", "__doc__")]
 
 MAPPING = {"StringIO":  ("io", ["StringIO"]),
-   "cStringIO": ("io", ["StringIO"])}
+   "cStringIO": ("io", ["StringIO"]),
+   "__builtin__" : ("builtins", builtin_names), 
+  }
 
 
 def alternates(members):
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1535] Rename __builtin__ to builtins

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

I had to copy the __builtin__.rst prior to patch.

svn cp Doc/library/__builtin__.rst Doc/library/builtins.rst
svn patch -p0 < builtins.diff
svn del --force Doc/library/__builtin__.rst

--
keywords: +patch, py3k
nosy: +tiran
priority:  -> high

__
Tracker <[EMAIL PROTECTED]>

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



[issue1498] Rename __builtins__ to __root_namespace__?

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

See http://bugs.python.org/issue1535 for future discussion.

--
resolution:  -> duplicate
status: open -> closed
superseder:  -> Rename __builtin__ to builtins

__
Tracker <[EMAIL PROTECTED]>

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



[issue1535] Rename __builtin__ to builtins

2007-12-01 Thread Georg Brandl

Changes by Georg Brandl:


Removed file: http://bugs.python.org/file8842/builtins.diff

__
Tracker <[EMAIL PROTECTED]>

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



[issue1358] Compile error on OS X 10.5

2007-12-01 Thread Ronald Oussoren

Ronald Oussoren added the comment:

This issue is fixed in the trunk and python2.5 branch.

To work around this issue with the 2.5.1 source tree you have to set 
MACOSX_DEPLOYMENT_TARGET when configuring python:

  ../configure  MACOSX_DEPLOYMENT_TARGET=10.3

(the value 10.3 is what configure picks by default, building with 10.5 
as the target works as well). The problem is that configure picked a 
deployment target for use during compilation of python itself, but 
didn't use that during the configure phase. That causes configure to 
pick up the wrong set of feature macros.

--
nosy: +ronaldoussoren
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



[issue1534] sys.maxfloat patch

2007-12-01 Thread Mark Dickinson

Mark Dickinson added the comment:

A (probably stupid) question:  what's supposed to happen on platforms that 
don't define things like DBL_MAX_10_EXP, which isn't part of ANSI C89?  Or 
are there no such platforms?

--
nosy: +marketdickinson

__
Tracker <[EMAIL PROTECTED]>

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



[issue1284316] Win32: Security problem with default installation directory

2007-12-01 Thread Carl Karsten

Carl Karsten added the comment:

Another reason to fix: perception.  installing to the root looks like a
hack.  Installing to the proper place* looks professional.  

As for it being hard to type, either add it to PATH or put a .bat file
in the path.  I think vista even supports some sort of symlink, so that
might be best.

As for easy_install.exe and others breaking when they hit a space, They
should be fixed too.  avoiding fixing them means people who try to force
the installer to do the right thing end up with a headache, which is evil.

* proper place isn't always "C:\Program Files" - the installer builder
should have an option to determine what it should be.  The environment
var %ProgramFiles% holds the correct path.  There is an API call too.

--
nosy: +carlfk

_
Tracker <[EMAIL PROTECTED]>

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



[issue1534] sys.maxfloat patch

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

I've checked all major platforms before committing the patch. They all
have a float.h with the information available. Do you know of a platform
where this information isn't available? I could add a lot of #ifdef but
I don't feel like bloating the code unless it is necessary.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1534] sys.maxfloat patch

2007-12-01 Thread Mark Dickinson

Mark Dickinson added the comment:

And it looks as though DBL_MAX_10_EXP *is* part of ANSI C anyway...  I 
shouldn't have assumed that just because it's not in Kernighan and Ritchie 
(2nd edition) it doesn't exist...  Apologies.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1534] sys.maxfloat patch

2007-12-01 Thread Mark Dickinson

Mark Dickinson added the comment:

No, I don't know of any platforms that don't define these constants.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1338] pickling bytes?

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Please assign this to me.

I am planning to fix this, along a few other bugs, with my new revision
of the pickle protocol.

--
nosy: +alexandre.vassalotti

__
Tracker <[EMAIL PROTECTED]>

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



[issue892902] problem with pickling newstyle class instances

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Please assign this bug to me.

Note that neither cPickle or pickle is able to load the stream generated
by cPickle correctly:

   >>> g = group(None)
   >>> subitem(g)
   >>> g[0].parent is g
   True
   >>> gp = cPickle.loads(cPickle.dumps(g))
   >>> gp[0].parent is gp
   False

I don't think that will be easy to fix, but I will try to see what I can do.

--
components: +Library (Lib) -Interpreter Core
nosy: +alexandre.vassalotti
type:  -> behavior


Tracker <[EMAIL PROTECTED]>


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



[issue939395] cPickle.Pickler: in list mode, no way to set protocol

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Please mark this bug as Won't Fix.

As Tim said, the list-based interface of cPickle is unsupported and
pending removal. Please use the pickle.dumps and pickle.loads functions
if you want string interface to pickle.

--
nosy: +alexandre.vassalotti


Tracker <[EMAIL PROTECTED]>


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



[issue1338] pickling bytes?

2007-12-01 Thread Georg Brandl

Georg Brandl added the comment:

I added the Developer role to your roundup account, so you can now
assign bugs to yourself. :)

--
assignee:  -> alexandre.vassalotti

__
Tracker <[EMAIL PROTECTED]>

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



[issue1761028] pickle - cannot unpickle circular deps with custom __hash__

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Please assign this bug to me.

This certainly doesn't look easy to fix. I will look into it, but I can
promise that I can fix it.

--
nosy: +alexandre.vassalotti
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



[issue1338] pickling bytes?

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Thank you, Georg!

__
Tracker <[EMAIL PROTECTED]>

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



[issue892902] problem with pickling newstyle class instances

2007-12-01 Thread Alexandre Vassalotti

Changes by Alexandre Vassalotti:


--
assignee:  -> alexandre.vassalotti


Tracker <[EMAIL PROTECTED]>


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



[issue1761028] pickle - cannot unpickle circular deps with custom __hash__

2007-12-01 Thread Alexandre Vassalotti

Changes by Alexandre Vassalotti:


--
assignee:  -> alexandre.vassalotti

_
Tracker <[EMAIL PROTECTED]>

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



[issue1534] sys.maxfloat patch

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

Thanks for checking it out for me! Do you have a reliable online source
for the ANSI C89 standard? I'm usually using the GNU C Library docs but
the site doesn't list what's available in C89.

__
Tracker <[EMAIL PROTECTED]>

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



[issue939395] cPickle.Pickler: in list mode, no way to set protocol

2007-12-01 Thread Georg Brandl

Changes by Georg Brandl:


--
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



[issue1536] pickle's documentation is severely outdated

2007-12-01 Thread Alexandre Vassalotti

New submission from Alexandre Vassalotti:

The current documentation for the pickle module (and related modules) is
outdated and should be updated. For example, the section "Pickling and
unpickling extension types" [1] is not only confusing, but outright
wrong. For Python 2.6, the documentation of cPickle should be updated to
reflect the differences between the cPickle and pickle.py modules. It
would be also be appropriate to note that cPickle is pending removal and
should not be used anymore.

[1]:
http://docs.python.org/dev/library/pickle.html#pickling-and-unpickling-extension-types

--
assignee: alexandre.vassalotti
components: Documentation
messages: 58063
nosy: alexandre.vassalotti
priority: normal
severity: normal
status: open
title: pickle's documentation is severely outdated
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



[issue956303] Update pickle docs to describe format of persistent IDs

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

This should be fixed along issue1536.

--
assignee:  -> alexandre.vassalotti
dependencies: +pickle's documentation is severely outdated
nosy: +alexandre.vassalotti


Tracker <[EMAIL PROTECTED]>


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



[issue1469] SSL tests leak memory

2007-12-01 Thread Christian Heimes

Christian Heimes added the comment:

Are you sure that the SSL tests are still leaking memory? The tests
aren't leaking references on Windows nor on Linux.

__
Tracker <[EMAIL PROTECTED]>

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



[issue655802] cPickle not always same as pickle

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

This should be fixed along with issue1536.

I am assigning this to me, instead of Fred Drake. (Is that okay with
you, Fred?)

--
assignee: fdrake -> alexandre.vassalotti
dependencies: +pickle's documentation is severely outdated
nosy: +alexandre.vassalotti
versions: +Python 2.5, Python 2.6


Tracker <[EMAIL PROTECTED]>


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



[issue1536] pickle's documentation is severely outdated

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

[I just realized that dependencies in the tracker should go the other
way around.]

--
dependencies: +Update pickle docs to describe format of persistent IDs, cPickle 
not always same as pickle

__
Tracker <[EMAIL PROTECTED]>

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



[issue655802] cPickle not always same as pickle

2007-12-01 Thread Alexandre Vassalotti

Changes by Alexandre Vassalotti:


--
dependencies:  -pickle's documentation is severely outdated


Tracker <[EMAIL PROTECTED]>


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



[issue956303] Update pickle docs to describe format of persistent IDs

2007-12-01 Thread Alexandre Vassalotti

Changes by Alexandre Vassalotti:


--
dependencies:  -pickle's documentation is severely outdated


Tracker <[EMAIL PROTECTED]>


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



[issue1673409] datetime module missing some important methods

2007-12-01 Thread Chris AtLee

Chris AtLee added the comment:

timedelta.todays() could be useful in general I suppose.  I think
timedelta.toweeks() could be omitted since it's simple division by an
easy to recognize constant...also the timedelta docs say that it stores
data in terms of microseconds, seconds, and days.

OTOH tohours(), tominutes(), etc. (all the units that the constructor
uses) could be useful in some cases.

My feeling is that adding a method for each time unit bloats the API too
much.  Personally I've only ever wanted to know the number of seconds a
timedelta represents. It seems like seconds are a good base unit to
support since it allows easier interoperability with other python types
and external data.

_
Tracker <[EMAIL PROTECTED]>

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



[issue1531] tarfile.open(fileobj=f) and bad metadata of the first file within the archive

2007-12-01 Thread Lars Gustäbel

Lars Gustäbel added the comment:

I fixed this in the trunk (r59260) and release25-maint branch (r59261).
Thanks for the report. If you cannot wait for the next release, I
recommend you use mode "r|" as a workaround.

BTW, 756 is absolutely no realistic example value for the position of
the second member. A header block must start on a 512-byte boundary.

--
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



[issue1469] SSL tests leak memory

2007-12-01 Thread Bill Janssen

Bill Janssen added the comment:

I'm seeing the leaks on my Leopard machine.  I haven't had a chance to look
into it yet.

On Dec 1, 2007 11:20 AM, Christian Heimes <[EMAIL PROTECTED]> wrote:

>
> Christian Heimes added the comment:
>
> Are you sure that the SSL tests are still leaking memory? The tests
> aren't leaking references on Windows nor on Linux.
>
> __
> Tracker <[EMAIL PROTECTED]>
> 
> __
>

Added file: http://bugs.python.org/file8845/unnamed

__
Tracker <[EMAIL PROTECTED]>

__I'm seeing the leaks on my Leopard machine.  I haven't had a 
chance to look into it yet.On Dec 1, 
2007 11:20 AM, Christian Heimes 
[EMAIL PROTECTED]> wrote:Christian Heimes added the comment:Are you sure 
that the SSL tests are still leaking memory? The tests
aren't leaking references on Windows nor on 
Linux.__Tracker [EMAIL PROTECTED]>
http://bugs.python.org/issue1469>__

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



[issue1283] PyBytes (buffer) .extend method needs to accept any iterable of ints

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Here a patch that adds support for any iterable (or sequence) of
integers to bytearray.extend().

--
assignee:  -> alexandre.vassalotti
keywords: +patch
nosy: +alexandre.vassalotti
resolution: accepted -> 
Added file: http://bugs.python.org/file8847/byte_extend.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/bytesobject.c
===
--- Objects/bytesobject.c	(revision 59259)
+++ Objects/bytesobject.c	(working copy)
@@ -2487,24 +2487,6 @@
 return NULL;
 }
 
-PyDoc_STRVAR(extend__doc__,
-"B.extend(iterable int) -> None\n\
-\n\
-Append all the elements from the iterator or sequence to the\n\
-end of B.");
-static PyObject *
-bytes_extend(PyBytesObject *self, PyObject *arg)
-{
-/* XXX(gps): The docstring says any iterable int will do but the
- * bytes_setslice code only accepts something supporting PEP 3118.
- * A list or tuple of 0 <= int <= 255 is supposed to work.  */
-/* bug being tracked on:  http://bugs.python.org/issue1283  */
-if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
-return NULL;
-Py_RETURN_NONE;
-}
-
-
 PyDoc_STRVAR(reverse__doc__,
 "B.reverse() -> None\n\
 \n\
@@ -2591,6 +2573,66 @@
 Py_RETURN_NONE;
 }
 
+PyDoc_STRVAR(extend__doc__,
+"B.extend(iterable int) -> None\n\
+\n\
+Append all the elements from the iterator or sequence to the\n\
+end of B.");
+static PyObject *
+bytes_extend(PyBytesObject *self, PyObject *arg)
+{
+PyObject *it, *item, *tmp, *res;
+Py_ssize_t len_hint, buf_size = 0, len = 0;
+int value;
+char *buf;
+
+/* bytes_setslice code only accepts something supporting PEP 3118. */
+if (PyObject_CheckBuffer(arg)) {
+if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
+return NULL;
+
+Py_RETURN_NONE;
+}
+
+it = PyObject_GetIter(arg);
+if (it == NULL)
+return NULL;
+
+len_hint = _PyObject_LengthHint(arg);
+if (len_hint != -1) {
+buf_size = len_hint;
+}
+else {
+PyErr_Clear();
+buf_size = 32;
+}
+
+buf = (char *)PyMem_Malloc(buf_size * sizeof(char));
+if (buf == NULL)
+return PyErr_NoMemory();
+
+while ((item = PyIter_Next(it)) != NULL) {
+if (! _getbytevalue(item, &value))
+return NULL;
+buf[len++] = value;
+Py_DECREF(item);
+if (len >= buf_size) {
+buf_size = len + (len >> 1);
+buf = PyMem_Realloc(buf, buf_size * sizeof(char));
+if (buf == NULL)
+return PyErr_NoMemory();
+}
+}
+Py_DECREF(it);
+
+tmp = PyBytes_FromStringAndSize(buf, len);
+res = bytes_extend(self, tmp);
+Py_DECREF(tmp);
+PyMem_Free(buf);
+
+return res;
+}
+
 PyDoc_STRVAR(pop__doc__,
 "B.pop([index]) -> int\n\
 \n\
Index: Lib/test/test_bytes.py
===
--- Lib/test/test_bytes.py	(revision 59259)
+++ Lib/test/test_bytes.py	(working copy)
@@ -529,6 +529,21 @@
 a.extend(a)
 self.assertEqual(a, orig + orig)
 self.assertEqual(a[5:], orig)
+a = bytearray(b'')
+a.extend(map(int, orig * 50))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+a.extend(iter(map(int, orig * 50)))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+a.extend(list(map(int, orig * 50)))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+self.assertRaises(ValueError, a.extend, [0, 1, 2, 3, 256])
+self.assertEqual(len(a), 0)
 
 def test_remove(self):
 b = bytearray(b'hello')
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1283] PyBytes (buffer) .extend method needs to accept any iterable of ints

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

Made 2 minor enhancements to the patch:
   + Added the proper type-cast to PyMem_Realloc call.
   + Changed (len >> 1) to (len >> 1) + 1, just to be sure that the
buffer  doesn't overflow if __length_hint__ return 0 or 1 erroneously.

Added file: http://bugs.python.org/file8848/byte_extend-2.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/bytesobject.c
===
--- Objects/bytesobject.c	(revision 59259)
+++ Objects/bytesobject.c	(working copy)
@@ -2487,24 +2487,6 @@
 return NULL;
 }
 
-PyDoc_STRVAR(extend__doc__,
-"B.extend(iterable int) -> None\n\
-\n\
-Append all the elements from the iterator or sequence to the\n\
-end of B.");
-static PyObject *
-bytes_extend(PyBytesObject *self, PyObject *arg)
-{
-/* XXX(gps): The docstring says any iterable int will do but the
- * bytes_setslice code only accepts something supporting PEP 3118.
- * A list or tuple of 0 <= int <= 255 is supposed to work.  */
-/* bug being tracked on:  http://bugs.python.org/issue1283  */
-if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
-return NULL;
-Py_RETURN_NONE;
-}
-
-
 PyDoc_STRVAR(reverse__doc__,
 "B.reverse() -> None\n\
 \n\
@@ -2591,6 +2573,66 @@
 Py_RETURN_NONE;
 }
 
+PyDoc_STRVAR(extend__doc__,
+"B.extend(iterable int) -> None\n\
+\n\
+Append all the elements from the iterator or sequence to the\n\
+end of B.");
+static PyObject *
+bytes_extend(PyBytesObject *self, PyObject *arg)
+{
+PyObject *it, *item, *tmp, *res;
+Py_ssize_t len_hint, buf_size = 0, len = 0;
+int value;
+char *buf;
+
+/* bytes_setslice code only accepts something supporting PEP 3118. */
+if (PyObject_CheckBuffer(arg)) {
+if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
+return NULL;
+
+Py_RETURN_NONE;
+}
+
+it = PyObject_GetIter(arg);
+if (it == NULL)
+return NULL;
+
+len_hint = _PyObject_LengthHint(arg);
+if (len_hint != -1) {
+buf_size = len_hint;
+}
+else {
+PyErr_Clear();
+buf_size = 32;
+}
+
+buf = (char *)PyMem_Malloc(buf_size * sizeof(char));
+if (buf == NULL)
+return PyErr_NoMemory();
+
+while ((item = PyIter_Next(it)) != NULL) {
+if (! _getbytevalue(item, &value))
+return NULL;
+buf[len++] = value;
+Py_DECREF(item);
+if (len >= buf_size) {
+buf_size = len + (len >> 1) + 1;
+buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
+if (buf == NULL)
+return PyErr_NoMemory();
+}
+}
+Py_DECREF(it);
+
+tmp = PyBytes_FromStringAndSize(buf, len);
+res = bytes_extend(self, tmp);
+Py_DECREF(tmp);
+PyMem_Free(buf);
+
+return res;
+}
+
 PyDoc_STRVAR(pop__doc__,
 "B.pop([index]) -> int\n\
 \n\
Index: Lib/test/test_bytes.py
===
--- Lib/test/test_bytes.py	(revision 59259)
+++ Lib/test/test_bytes.py	(working copy)
@@ -529,6 +529,21 @@
 a.extend(a)
 self.assertEqual(a, orig + orig)
 self.assertEqual(a[5:], orig)
+a = bytearray(b'')
+a.extend(map(int, orig * 50))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+a.extend(iter(map(int, orig * 50)))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+a.extend(list(map(int, orig * 50)))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+self.assertRaises(ValueError, a.extend, [0, 1, 2, 3, 256])
+self.assertEqual(len(a), 0)
 
 def test_remove(self):
 b = bytearray(b'hello')
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1283] PyBytes (buffer) .extend method needs to accept any iterable of ints

2007-12-01 Thread Alexandre Vassalotti

Alexandre Vassalotti added the comment:

There is a reference leak in my previous patches. So, I updated (again)
the patch. There is still another possible leak if the PyMem_Realloc
return NULL (i.e., the system is out of memory), but I don't think it
worth fixing.

Added file: http://bugs.python.org/file8849/byte_extend-3.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Objects/bytesobject.c
===
--- Objects/bytesobject.c	(revision 59259)
+++ Objects/bytesobject.c	(working copy)
@@ -2487,24 +2487,6 @@
 return NULL;
 }
 
-PyDoc_STRVAR(extend__doc__,
-"B.extend(iterable int) -> None\n\
-\n\
-Append all the elements from the iterator or sequence to the\n\
-end of B.");
-static PyObject *
-bytes_extend(PyBytesObject *self, PyObject *arg)
-{
-/* XXX(gps): The docstring says any iterable int will do but the
- * bytes_setslice code only accepts something supporting PEP 3118.
- * A list or tuple of 0 <= int <= 255 is supposed to work.  */
-/* bug being tracked on:  http://bugs.python.org/issue1283  */
-if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
-return NULL;
-Py_RETURN_NONE;
-}
-
-
 PyDoc_STRVAR(reverse__doc__,
 "B.reverse() -> None\n\
 \n\
@@ -2591,6 +2573,69 @@
 Py_RETURN_NONE;
 }
 
+PyDoc_STRVAR(extend__doc__,
+"B.extend(iterable int) -> None\n\
+\n\
+Append all the elements from the iterator or sequence to the\n\
+end of B.");
+static PyObject *
+bytes_extend(PyBytesObject *self, PyObject *arg)
+{
+PyObject *it, *item, *tmp, *res;
+Py_ssize_t len_hint, buf_size = 0, len = 0;
+int value;
+char *buf;
+
+/* bytes_setslice code only accepts something supporting PEP 3118. */
+if (PyObject_CheckBuffer(arg)) {
+if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1)
+return NULL;
+
+Py_RETURN_NONE;
+}
+
+it = PyObject_GetIter(arg);
+if (it == NULL)
+return NULL;
+
+len_hint = _PyObject_LengthHint(arg);
+if (len_hint != -1) {
+buf_size = len_hint;
+}
+else {
+PyErr_Clear();
+buf_size = 32;
+}
+
+buf = (char *)PyMem_Malloc(buf_size * sizeof(char));
+if (buf == NULL)
+return PyErr_NoMemory();
+
+while ((item = PyIter_Next(it)) != NULL) {
+if (! _getbytevalue(item, &value)) {
+Py_DECREF(item);
+Py_DECREF(it);
+return NULL;
+}
+buf[len++] = value;
+Py_DECREF(item);
+if (len >= buf_size) {
+buf_size = len + (len >> 1) + 1;
+buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char));
+if (buf == NULL)
+return PyErr_NoMemory();
+}
+}
+Py_DECREF(it);
+
+tmp = PyBytes_FromStringAndSize(buf, len);
+res = bytes_extend(self, tmp);
+Py_DECREF(tmp);
+PyMem_Free(buf);
+
+return res;
+}
+
 PyDoc_STRVAR(pop__doc__,
 "B.pop([index]) -> int\n\
 \n\
Index: Lib/test/test_bytes.py
===
--- Lib/test/test_bytes.py	(revision 59259)
+++ Lib/test/test_bytes.py	(working copy)
@@ -529,6 +529,21 @@
 a.extend(a)
 self.assertEqual(a, orig + orig)
 self.assertEqual(a[5:], orig)
+a = bytearray(b'')
+a.extend(map(int, orig * 50))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+a.extend(iter(map(int, orig * 50)))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+a.extend(list(map(int, orig * 50)))
+self.assertEqual(a, orig * 50)
+self.assertEqual(a[-5:], orig)
+a = bytearray(b'')
+self.assertRaises(ValueError, a.extend, [0, 1, 2, 3, 256])
+self.assertEqual(len(a), 0)
 
 def test_remove(self):
 b = bytearray(b'hello')
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1534] sys.maxfloat patch

2007-12-01 Thread Mark Dickinson

Mark Dickinson added the comment:

The site that persuaded me about DBL_MAX_10_EXP was 

http://www.schweikhardt.net/identifiers.html

Googling 'C89 draft' also turns up some potentially useful stuff.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1531] tarfile.open(fileobj=f) and bad metadata of the first file within the archive

2007-12-01 Thread George Notaras

George Notaras added the comment:

Thanks for the quick fix and the workaround.

You are right about position 756. I hadn't spent enough time studying
the ''ustar'' format.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1535] Rename __builtin__ to builtins

2007-12-01 Thread Guido van Rossum

Guido van Rossum added the comment:

OK Georg, take 'er away!

--
assignee: gvanrossum -> georg.brandl
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1535] Rename __builtin__ to builtins

2007-12-01 Thread Guido van Rossum

Guido van Rossum added the comment:

PS. A note on backporting this to 2.6: I think it's sufficient if
"builtins" exists in sys.modules as an alias of "__builtin__" in 2.6.

Crys: go ahead and check in the fixer as well.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1537] Change GeneratorExit's base class from Exception to BaseException

2007-12-01 Thread Chad Austin

New submission from Chad Austin:

Per discussion at http://mail.python.org/pipermail/python-dev/2007-
December/075498.html, this patch changes GeneratorExit's base class 
from Exception to BaseException.

I updated the tests and documentation, but I may have missed any other 
discussion of GeneratorExit in the documentation.  Happy to update the 
patch if there is any feedback.

--
components: Interpreter Core
files: GeneratorExit-BaseException.patch
messages: 58079
nosy: aegis
severity: normal
status: open
title: Change GeneratorExit's base class from Exception to BaseException
type: behavior
versions: Python 2.6
Added file: http://bugs.python.org/file8850/GeneratorExit-BaseException.patch

__
Tracker <[EMAIL PROTECTED]>

__

GeneratorExit-BaseException.patch
Description: Binary data
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1487] PEP 366 implementation

2007-12-01 Thread Nick Coghlan

Nick Coghlan added the comment:

I forgot to update the special _run_module_as_main variant when I
modified run_module. I'll modify the patch to fix that and to test '-m'
explicitly in test_cmd_line_script.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1538] Avoid string copy when split char doesn't match

2007-12-01 Thread Skip Montanaro

New submission from Skip Montanaro:

The topic of avoiding string copies in certain string methods came up in 
the
ChiPy list:

  http://mail.python.org/pipermail/chicago/2007-December/002975.html.

The attached patch modifies the split and rsplit implementations to 
avoid
making a copy of self when the split fails to find anything to split on:

>>> s = "abc def"
>>> x = s.split(';')
>>> x[0] is s
True
>>> y = s.rsplit('-')
>>> y[0] is s
True
>>> t = "abcdef"
>>> x = t.split()
>>> x[0] is t
True
>>> y = t.rsplit()
>>> y[0] is t
True

All tests pass.  Given that this is just a small optimization I
don't believe any changes to the docs or the existing tests are
necessary.

--
components: Interpreter Core
files: string-split.patch
keywords: patch
messages: 58081
nosy: skip.montanaro
priority: normal
severity: normal
status: open
title: Avoid string copy when split char doesn't match
type: rfe
versions: Python 2.6
Added file: http://bugs.python.org/file8851/string-split.patch

__
Tracker <[EMAIL PROTECTED]>

__*** /tmp/skip/ediffWFAoxm   Sun Dec  2 01:28:32 2007
--- /Users/skip/src/python/trunk/Objects/stringobject.c Sun Dec  2 01:27:56 2007
***
*** 1403,1410 
  #define RSKIP_NONSPACE(s, i) { while (i>=0  && 
!isspace(Py_CHARMASK(s[i]))) i--; }
  
  Py_LOCAL_INLINE(PyObject *)
! split_whitespace(const char *s, Py_ssize_t len, Py_ssize_t maxsplit)
  {
Py_ssize_t i, j, count=0;
PyObject *str;
PyObject *list = PyList_New(PREALLOC_SIZE(maxsplit));
--- 1403,1411 
  #define RSKIP_NONSPACE(s, i) { while (i>=0  && 
!isspace(Py_CHARMASK(s[i]))) i--; }
  
  Py_LOCAL_INLINE(PyObject *)
! split_whitespace(PyStringObject *self, Py_ssize_t len, Py_ssize_t maxsplit)
  {
+   const char *s = PyString_AS_STRING(self);
Py_ssize_t i, j, count=0;
PyObject *str;
PyObject *list = PyList_New(PREALLOC_SIZE(maxsplit));
***
*** 1419,1424 
--- 1420,1432 
if (i==len) break;
j = i; i++;
SKIP_NONSPACE(s, i, len);
+   if (j == 0 && i == len) {
+   /* No whitespace in self, so just use it as list[0] */
+   Py_INCREF(self);
+   PyList_SET_ITEM(list, 0, (PyObject *)self);
+   count++;
+   break;
+   }
SPLIT_ADD(s, j, i);
}
  
***
*** 1437,1444 
  }
  
  Py_LOCAL_INLINE(PyObject *)
! split_char(const char *s, Py_ssize_t len, char ch, Py_ssize_t maxcount)
  {
register Py_ssize_t i, j, count=0;
PyObject *str;
PyObject *list = PyList_New(PREALLOC_SIZE(maxcount));
--- 1445,1453 
  }
  
  Py_LOCAL_INLINE(PyObject *)
! split_char(PyStringObject *self, Py_ssize_t len, char ch, Py_ssize_t maxcount)
  {
+   const char *s = PyString_AS_STRING(self);
register Py_ssize_t i, j, count=0;
PyObject *str;
PyObject *list = PyList_New(PREALLOC_SIZE(maxcount));
***
*** 1457,1463 
}
}
}
!   if (i <= len) {
SPLIT_ADD(s, i, len);
}
FIX_PREALLOC_SIZE(list);
--- 1466,1478 
}
}
}
!   if (i == 0 && count == 0) {
!   /* ch not in self, so just use self as list[0] */
!   Py_INCREF(self);
!   PyList_SET_ITEM(list, 0, (PyObject *)self);
!   count++;
!   }
!   else if (i <= len) {
SPLIT_ADD(s, i, len);
}
FIX_PREALLOC_SIZE(list);
***
*** 1492,1498 
if (maxsplit < 0)
maxsplit = PY_SSIZE_T_MAX;
if (subobj == Py_None)
!   return split_whitespace(s, len, maxsplit);
if (PyString_Check(subobj)) {
sub = PyString_AS_STRING(subobj);
n = PyString_GET_SIZE(subobj);
--- 1507,1513 
if (maxsplit < 0)
maxsplit = PY_SSIZE_T_MAX;
if (subobj == Py_None)
!   return split_whitespace(self, len, maxsplit);
if (PyString_Check(subobj)) {
sub = PyString_AS_STRING(subobj);
n = PyString_GET_SIZE(subobj);
***
*** 1509,1515 
return NULL;
}
else if (n == 1)
!   return split_char(s, len, sub[0], maxsplit);
  
list = PyList_New(PREALLOC_SIZE(maxsplit));
if (list == NULL)
--- 1524,1530 
return NULL;
}
else if (n == 1)
!   return split_char(self, len, sub[0], maxsplit);
  
list = PyList_New(PREALLOC_SIZE(maxsplit));
if (list == NULL)
***
*** 1609,1616 
  }
  
  Py_LOCAL_INLINE(PyObject *)
! rsplit_whitespace(c