[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-10 Thread Facundo Batista

Facundo Batista added the comment:

I have another way:

* Check if the destination is a directory, and in such case make an
os.path.join(destination, originfile), and then use os.rename() with
this new destination.

What do you think? Do you think this way suffers from any multiplatform
issue?

More important: how can this be tested?

--
nosy: +facundobatista

__
Tracker <[EMAIL PROTECTED]>

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



[issue1202] zlib.crc32() and adler32() return value

2007-12-10 Thread Armin Rigo

Armin Rigo added the comment:

The C reference code in rfc1950 for Adler-32 and in rfc1952 for CRC-32
compute with and return "unsigned long" values.  From this point of
view, returning negative values on 32-bit machines from CPython's zlib
module can be considered a bug.  That only leaves open the question of
backward compatibility.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1313119] urlparse "caches" parses regardless of encoding

2007-12-10 Thread Tom Parker

Tom Parker added the comment:

Also effects Python 2.5.1 (tested on Debian python2.5 package version
2.5.1-5)

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



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I had looked at the version 2 instead of version 3.

Version 3 is much closer.  A couple of comments.  Don't change the 
brace opening/closing convention in the file -- stick with the K&R 
style -- mixing two different styles makes the file harder to read and 
maintain.

Also, do not introduce string optimization in new places.  If it wasn't 
there before, it was likely left out for a reason (lines 1231 and 1352 
for example).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1579] logging documentation is unclear

2007-12-10 Thread Kylotan

New submission from Kylotan:

The documentation for the logging module is quite confusing, and (I am
told) seems to assume prior experience with the log4j utility or similar.

In particular:
 - the front page has a rather confusing example of the named hierarchy
system, which might mislead the reader by making them think it's about
file types (perhaps for log output) rather than just arbitrary naming
conventions.
 - section 14.5.3 attempts to explain this hierarchy, but does so via an
example for something else (ie. showing logging to multiple
destinations), and is just a large code-dump, mixing several concepts in
one example.

All in all, it could just do with being a lot more explicit about how
the naming convention and the hierarchy works, how each logger relates
to children/parents, and having a more transparent example on the first
page.

--
components: Documentation
messages: 58347
nosy: Kylotan
severity: normal
status: open
title: logging documentation is unclear
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



[issue1579] logging documentation is unclear

2007-12-10 Thread Facundo Batista

Facundo Batista added the comment:

Do you think that can came up with a patch for this?

Just the paragraphs better written, or a better example, that would be
great!

Thanks!

--
nosy: +facundobatista

__
Tracker <[EMAIL PROTECTED]>

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



[issue1578] Problems in win_getpass

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

I've added wide char API variants of the get and put commands to msvcrt
in the trunk. I'm going to fix the problem with the new functions.

--
assignee:  -> tiran
keywords: +py3k
nosy: +tiran
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1322] platform.dist() has unpredictable result under Linux

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

I'm mentoring a task for GHOP which is going to fix the problem.

--
assignee:  -> tiran
priority:  -> normal
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



[issue1564] The set implementation should special-case PyUnicode instead of PyString

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

I've done as you said and committed the changes in r59449.

Next time I won't try to add optimizations without consulting you in the
first place. :] Thanks for your advice.

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



[issue1530] doctest should return error if not all tests passed

2007-12-10 Thread Miki Tebeka

Miki Tebeka added the comment:

Thank you for accepting it :)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1578] Problems in win_getpass

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

Fixed in r59451

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



[issue1560] PATCH: Attribute lookup caching

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Are you withdrawing this in favor of #1568?

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

We should first decide what should happen.  While for command line tools
"mv FILE DIR" is established syntax for "mv FILE DIR/`basename FILE`",
I'm not at all sure that shutil.move(src, dst) should do the same.  I
think it should be closer to the UNIX os.rename() semantics which
promises that src *replaces* dst.  If dst is an empty dir, it is removed
using rmdir(); if it is a non-empty dir, the removal fails and hence the
move fails.  I think this is what shutil.move() should do too.  (Even if
it can't make the atomicity promises that UNIX makes.)

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1576] First draft of a post import hook

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

The new patch fixes some ref leaks, corner cases and adds some new unit
tests. All unit tests are passing but I'm leaking lots of references in
the register function.

Added file: http://bugs.python.org/file8909/py3k_post_import_hook3.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Python/import.c
===
--- Python/import.c	(Revision 59449)
+++ Python/import.c	(Arbeitskopie)
@@ -161,7 +161,7 @@
 void
 _PyImportHooks_Init(void)
 {
-	PyObject *v, *path_hooks = NULL, *zimpimport;
+	PyObject *v, *path_hooks = NULL, *zimpimport, *pihr;
 	int err = 0;
 
 	/* adding sys.path_hooks and sys.path_importer_cache, setting up
@@ -198,6 +198,14 @@
 			  );
 	}
 
+	pihr = PyDict_New();
+	if (pihr == NULL ||
+PySys_SetObject("post_import_hooks", pihr) != 0) {
+		PyErr_Print();
+		Py_FatalError("initialization of post import hook registry "
+			  "failed");
+	}
+
 	zimpimport = PyImport_ImportModule("zipimport");
 	if (zimpimport == NULL) {
 		PyErr_Clear(); /* No zip import module -- okay */
@@ -623,6 +631,239 @@
 			  "sys.modules failed");
 }
 
+/* post import hook API */
+PyObject *
+PyImport_GetPostImportHooks(void)
+{
+	PyObject *pihr;
+
+	pihr = PySys_GetObject("post_import_hooks");
+	/* This should only happen during initialization */
+	if (pihr == NULL)
+		return NULL;
+
+	if (!PyDict_Check(pihr)) {
+		PyErr_SetString(PyExc_TypeError,
+"post import registry is not a dict");
+	}
+
+	Py_INCREF(pihr);
+	return pihr;
+}
+
+PyObject *
+PyImport_NotifyPostImport(PyObject *module)
+{
+	static PyObject *name = NULL;
+	PyObject *mod_name = NULL, *registry = NULL, *o;
+	PyObject *hooks = NULL, *hook, *it = NULL;
+	int status = -1;
+
+	if (module == NULL) {
+		return NULL;
+	}
+	if (!PyModule_Check(module)) {
+		PyErr_Format(PyExc_TypeError,
+			 "A module object was expected, got '%.200s'",
+			 Py_Type(module)->tp_name);
+		Py_DECREF(module);
+		return NULL;
+	}
+
+	if (!PyModule_IsLoaded(module)) {
+		/* nothing to do here */
+		return module;
+	}
+	/* XXX check if module is in sys.modules ? */
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL) {
+		/* This should only happen during initialization */
+		return module;
+	}
+
+	if (name == NULL) {
+		name = PyUnicode_InternFromString("__name__");
+		if (name == NULL) {
+			return NULL;
+		}
+	}
+
+	mod_name = PyObject_GetAttr(module, name);
+	if (mod_name == NULL) {
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyObject *repr;
+		char *name;
+
+		repr = PyObject_Repr(module);
+		name = repr ? PyUnicode_AsString(repr) : "";
+		PyErr_Format(PyExc_TypeError,
+			 "Module __name__ attribute of '%.200s' is not "
+			 "string", name);
+		Py_XDECREF(repr);
+		goto error;
+	}
+
+	hooks = PyDict_GetItem(registry, mod_name);
+	if (hooks == NULL || hooks == Py_None) {
+		/* Either no hooks are defined or they are already fired */
+		if (hooks == NULL) {
+			PyErr_Clear();
+		}
+		Py_DECREF(mod_name);
+		Py_DECREF(registry);
+		return module;
+	}
+	if (!PyList_Check(hooks)) {
+		PyErr_Format(PyExc_TypeError,
+			 "expected None or list of hooks, got '%.200s'",
+			 Py_Type(hooks)->tp_name);
+		goto error;
+	}
+
+	/* fire hooks */
+	it = PyObject_GetIter(hooks);
+	if (it == NULL) {
+		goto error;
+	}
+	while ((hook = PyIter_Next(it)) != NULL) {
+		o = PyObject_CallFunction(hook, "O", module);
+		if (o == NULL) {
+			goto error;
+		}
+		Py_DECREF(o);
+	}
+
+	/* Mark hooks as fired */
+	if (PyDict_SetItem(registry, mod_name, Py_None) < 0) {
+		goto error;
+	}
+
+/* end: */
+	status = 0;
+error:
+	Py_XDECREF(mod_name);
+	Py_XDECREF(hooks);
+	Py_XDECREF(it);
+	Py_XDECREF(registry);
+	if (status < 0) {
+		return NULL;
+	}
+	else {
+		return module;
+	}
+}
+
+PyObject *
+PyImport_RegisterPostImportHook(PyObject *callable, PyObject *mod_name)
+{
+	PyObject *registry = NULL, *hooks = NULL;
+	int status = -1;
+
+	if (!PyCallable_Check(callable)) {
+		PyErr_SetString(PyExc_TypeError, "expected callable");
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyErr_SetString(PyExc_TypeError, "expected string");
+		goto error;
+	}
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL) {
+		goto error;
+	}
+
+	lock_import();
+
+	hooks = PyDict_GetItem(registry, mod_name);
+	/* module may be already loaded, get the module object from sys */
+	if (hooks == NULL || hooks == Py_None) {
+		PyObject *o, *modules;
+		PyObject *module = NULL;
+
+		modules = PySys_GetObject("modules");
+		if (modules == NULL) {
+			goto error;
+		}
+		module = PyObject_GetItem(modules, mod_name);
+		if (module == NULL) {
+			PyErr_Clear();
+			/* somebody messed up sys.modules */
+			if (hooks == Py_None) {
+; /* XXX error */
+			}
+		}
+		/* mark hooks as fired */
+		if (hooks == NULL) {
+			if (PyDict_SetItem(registry

[issue1576] First draft of a post import hook

2007-12-10 Thread Christian Heimes

Changes by Christian Heimes:


Removed file: http://bugs.python.org/file8906/py3k_post_import_hook2.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1722225] Build on QNX

2007-12-10 Thread Matt Kraai

Matt Kraai added the comment:

I'm willing to maintain the QNX 6 port, but I can't promise that I'll be
able to do so for 5 years.  I don't know if that's sufficient or not.

_
Tracker <[EMAIL PROTECTED]>

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



[issue1560] PATCH: Attribute lookup caching

2007-12-10 Thread Neil Toronto

Neil Toronto added the comment:

Yes, as well #1700288 (Armin's attribute lookup caching patch ported to
2.6) or #1685986 (Armin's original for 2.4), or whatever Raymond finds
most convenient.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1677872] Efficient reverse line iterator

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

I'd like to see the doc patches separated out and applied to 2.6 --
they'll automatically merge into 3.0 then. Make that a separate bug please.

I like the idea, haven't had time to carefully review the code, but
noticed one oddity:

>>> for line in reversed(open("/etc/passwd")): print(line, end="")

immediately raises

ValueError: I/O operation on closed file

--
nosy: +gvanrossum

_
Tracker <[EMAIL PROTECTED]>

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



[issue1202] zlib.crc32() and adler32() return value

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

How about, in Python 2.6 we make the 64-bit version return a signed
value for better compatibility with the 32-bit version, and in Python
3.0 we make both versions return the signed value for better compliance
with the standard?

__
Tracker <[EMAIL PROTECTED]>

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



[issue1581] xmlrpclib.ServerProxy() doesn't use x509 data

2007-12-10 Thread Andreas Hasenack

New submission from Andreas Hasenack:

I was trying to use xmlrpclib.ServerProxy() with https and client
certificate validation (I know httplib doesn't do server certificate
validation yet). I found no way to pass on host/uri as a
(host,x509_dict) tuple as the connection methods support, so I came up
with this patch.

--
components: Library (Lib)
files: xmlrpclib-x509.patch
messages: 58363
nosy: ahasenack
severity: minor
status: open
title: xmlrpclib.ServerProxy() doesn't use x509 data
type: behavior
versions: Python 2.5
Added file: http://bugs.python.org/file8911/xmlrpclib-x509.patch

__
Tracker <[EMAIL PROTECTED]>

__--- xmlrpclib.py.orig	2007-12-10 17:00:49.0 -0200
+++ xmlrpclib.py	2007-12-10 17:37:55.0 -0200
@@ -1185,6 +1185,7 @@
 errcode, errmsg, headers = h.getreply()
 
 if errcode != 200:
+host, extra, x509 = self.get_host_info(host)
 raise ProtocolError(
 host + handler,
 errcode, errmsg,
@@ -1382,7 +1383,8 @@
 """uri [,options] -> a logical connection to an XML-RPC server
 
 uri is the connection point on the server, given as
-scheme://host/target.
+scheme://host/target. It can also be a tuple of the form (uri,x509_dict)
+where x509_dict is a dictionary specifying files for SSL key and certificate.
 
 The standard implementation always supports the "http" scheme.  If
 SSL socket support is available (Python 2.0), it also supports
@@ -1404,12 +1406,17 @@
  allow_none=0, use_datetime=0):
 # establish a "logical" server connection
 
+x509 = {}
 # get the url
 import urllib
+if isinstance(uri, TupleType):
+uri, x509 = uri
 type, uri = urllib.splittype(uri)
 if type not in ("http", "https"):
 raise IOError, "unsupported XML-RPC protocol"
 self.__host, self.__handler = urllib.splithost(uri)
+if x509:
+self.__host = (self.__host, x509)
 if not self.__handler:
 self.__handler = "/RPC2"
 
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

I like this; but I don't have time for a complete thourough review. 
Maybe Tim can lend a hand?

If Tim has no time, I propose that if it works correctly without leaks
on at least Windows, OSX and Linux, we check it in, and worry about more
review later.

Crys, can you test this on Windows and see if it needs any project file
updates?  I'll check OSX.  Linux works and I see no leaks.

--
assignee:  -> tiran
keywords: +patch
nosy: +gvanrossum, tim_one, tiran

__
Tracker <[EMAIL PROTECTED]>

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



[issue1560] PATCH: Attribute lookup caching

2007-12-10 Thread Guido van Rossum

Changes by Guido van Rossum:


--
resolution:  -> out of date
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



[issue1560] PATCH: Attribute lookup caching

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

That's still ambiguous -- do you want any of those to be closed too? 
Clearly we're not going to patch 2.4.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1581] xmlrpclib.ServerProxy() doesn't use x509 data

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

This should be considered for 2.6, not 2.5 (which is in feature freeze).

I'm hoping Bill Janssen can review this.

--
assignee:  -> janssen
nosy: +gvanrossum, janssen

__
Tracker <[EMAIL PROTECTED]>

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



[issue1114345] Add SSL certificate validation

2007-12-10 Thread Andreas Hasenack

Changes by Andreas Hasenack:


--
nosy: +ahasenack

_
Tracker <[EMAIL PROTECTED]>

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



[issue1560] PATCH: Attribute lookup caching

2007-12-10 Thread Neil Toronto

Neil Toronto added the comment:

Sorry - I'll be more clear. I'd love to see 2.6 get attribute lookup
caching, and Kevin's port (#1700288) of Armin's original 2.4 patch
(#1685986) does that for 2.6. #1685986 (2.4) should be closed and
#1700288 (2.6) should remain open. But Raymond has indicated that he's
currently working on #1685986 - I think for 2.6, but it's not clear.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1577] shutil.move() does not use os.rename() if dst is a directory

2007-12-10 Thread Ingemar Nilsson

Ingemar Nilsson added the comment:

Well, if that's what you want, I suggest documenting it in the manual.
>From reading the manual, I thought that shutil.move() would behave like
mv, and I was surprised that it doesn't.

To me the big issue isn't how it is solved, it's rather that its
behavior is clearly documented in the manual.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1582] Documentation patch for reversed() and __reversed__()

2007-12-10 Thread Mark Russell

New submission from Mark Russell:

This patch adds documentation for the reversed() builtin and 
__reversed__() special method.

--
components: Documentation
files: reverse-2.6-docs.diff
messages: 58369
nosy: mark_t_russell
severity: normal
status: open
title: Documentation patch for reversed() and __reversed__()
versions: Python 2.6
Added file: http://bugs.python.org/file8912/reverse-2.6-docs.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Doc/reference/datamodel.rst
===
--- Doc/reference/datamodel.rst (revision 59453)
+++ Doc/reference/datamodel.rst (working copy)
@@ -1819,12 +1819,27 @@
Iterator objects also need to implement this method; they are required to 
return
themselves.  For more information on iterator objects, see :ref:`typeiter`.
 
+.. method:: object.__reversed__(self)
+
+   Called (if present) by the :func:`reversed()` builtin to implement
+   reverse iteration.  It should return a new iterator object that iterates
+   over all the objects in the container in reverse order.
+
+   If the :meth:`__reversed__()` method is not provided, the
+   :func:`reversed()` builtin will fall back to using the sequence protocol
+   (:meth:`__len__()` and :meth:`__getitem__()`). Objects should normally
+   only provide :meth:`__reversed__()` if they do not support the sequence
+   protocol and an efficient implementation of reverse iteration is possible.
+   
 The membership test operators (:keyword:`in` and :keyword:`not in`) are 
normally
 implemented as an iteration through a sequence.  However, container objects can
 supply the following special method with a more efficient implementation, which
 also does not require the object be a sequence.
 
 
+
+
+
 .. method:: object.__contains__(self, item)
 
Called to implement membership test operators.  Should return true if 
*item* is
Index: Doc/library/functions.rst
===
--- Doc/library/functions.rst   (revision 59453)
+++ Doc/library/functions.rst   (working copy)
@@ -974,8 +974,9 @@
 
 .. function:: reversed(seq)
 
-   Return a reverse :term:`iterator`.  *seq* must be an object which supports
-   the sequence protocol (the :meth:`__len__` method and the 
:meth:`__getitem__`
+   Return a reverse :term:`iterator`.  *seq* must be an object which has
+   a :meth:`__reversed__` method [#]_ or supports the sequence protocol
+   (the :meth:`__len__` method and the :meth:`__getitem__`
method with integer arguments starting at ``0``).
 
.. versionadded:: 2.4
@@ -1342,6 +1343,8 @@
any I/O has been performed, and there's no reliable way to determine whether
this is the case.
 
+.. [#] See :ref:`sequence-types`
+
 .. [#] In the current implementation, local variable bindings cannot normally 
be
affected this way, but variables retrieved from other scopes (such as 
modules)
can be.  This may change.
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1677872] Efficient reverse line iterator

2007-12-10 Thread Mark Russell

Mark Russell added the comment:

As Guido requested I've split off the generic reversed() and __reversed__()
doc additions to this patch against 2.6: http://bugs.python.org/issue1582

The I/O error from reversed(open("/etc/passwd")) was caused by the inner
TextIOWrapper calling close() (via the inherited IOBase.__del__() method).
I've fixed it by having TextIOReverseIterator keep a reference to the file
object, and added a test case for the bug.

I think it's at least questionable that TextIOWrapper.close() is calling 
buffer.close() on a buffer that it did not create.  I assumed that keeping
a reference to the buffer object would be enough to keep the buffer open,
and I suspect this is likely to trip up others in future.  I think
TextIOWrapper.close() should probably just set a flag (for the use of its 
own closed() method) and rely on reference counting to call close() 
on the buffer object.  If that sounds on the right lines I'm happy to think
about it a bit more and submit a patch.

Added file: http://bugs.python.org/file8913/reverse-file-iterator-20071210.diff

_
Tracker <[EMAIL PROTECTED]>
<http://bugs.python.org/issue1677872>
_Index: Doc/library/stdtypes.rst
===
--- Doc/library/stdtypes.rst(revision 59453)
+++ Doc/library/stdtypes.rst(working copy)
@@ -1937,7 +1937,16 @@
right.  However, using :meth:`seek` to reposition the file to an absolute
position will flush the read-ahead buffer.
 
+.. method:: file.__reversed__()
 
+   Return a new iterator that returns lines in reverse order (but without
+   reading the entire file into memory first).  Normally called via the
+   :func:`reversed()` builtin, as in ``for line in reversed(f): print(line)``.
+   Useful for scanning backwards through large files without reading the
+   entire file first.  Note that this changes the current position of the
+   underlying file object, so you should not interleave use of reverse and
+   forward iteration over the same file object.
+
 .. method:: file.read([size])
 
Read at most *size* bytes from the file (less if the read hits EOF before
Index: Lib/io.py
===
--- Lib/io.py   (revision 59453)
+++ Lib/io.py   (working copy)
@@ -1136,6 +1136,126 @@
)[self.seennl]
 
 
+class TextIOReverseIterator:
+"""Line-based reverse iterator wrapper for IOBase objects.
+
+This class is used to implement TextIOWrapper.__reversed__().
+It searches backwards for encoded line terminator, which
+works for UTF-8 but not for encodings where one character encoding
+can be a substring of another longer one.
+"""
+
+# XXX Should we check for encodings that are known to work?  Currently
+# we would return incorrect results for a codec where, say, the encoding
+# of newline could appear as a substring of the encoding for some other
+# character or where the codec can have a non-default state at the start
+# of a line (do such encodings exist?).
+
+def __init__(self, buffer, encoding, newline=None,
+ buffer_size=DEFAULT_BUFFER_SIZE, wrapped_file=None):
+if not isinstance(encoding, str):
+raise ValueError("invalid encoding: %r" % encoding)
+buffer.seek(0, 2)
+self.buffer = buffer
+self._wrapped_file = wrapped_file # Keep ref to avoid premature close
+self._bufsize = buffer_size
+self._encoding = encoding
+self._translate_newlines = newline is None
+if newline:
+self._enc_cr = self._enc_lf = None
+else:
+self._enc_cr = '\r'.encode(encoding)
+self._enc_lf = '\n'.encode(encoding)
+if self._enc_cr + self._enc_lf != '\r\n'.encode(encoding):
+raise ValueError('unsupported encoding: %r' % encoding)
+self._newline = newline.encode(encoding) if newline else None
+self._limpos = buffer.tell()
+self._bufpos = self._limpos
+self._pending = b''
+
+def _extend_buffer_backwards(self):
+(bufpos, limpos, bufsize) = (self._bufpos, self._limpos, self._bufsize)
+
+newpos = (bufpos // bufsize) * bufsize
+if newpos == bufpos:
+newpos -= bufsize
+assert newpos >= 0
+nbytes = bufpos - newpos
+assert nbytes != 0
+
+self.buffer.seek(newpos, 0)
+assert self.buffer.tell() == newpos, \
+   'seek() arrived at %r (expected %r)' % (seekpos, newpos)
+newbuf = self.buffer.read(nbytes)
+assert len(newbuf) == nbytes, 'Unexpected EOF'
+
+if limpos > bufpos:
+newbuf += self._pending[:limpos - bufpos]
+ 

[issue1560] PATCH: Attribute lookup caching

2007-12-10 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I'm trying to look at all of them. Having it split into several patches
and getting frequent updates and posts is making it difficult.

Please communicate with me directly (python at rcn dot com) so I can
find out which versions are the latest and the reason behind each variation.

--
nosy: +rhettinger

__
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-10 Thread Bill Janssen

Bill Janssen added the comment:

I think I've figured it out.  My initial patch to socket.py and ssl.py
had an extra method defined on socket.socket, _real_close(), which did'
the cleanup work of deallocating the underlying socket, and in the SSL
subclass, of releasing the SSL context.  Guido must have removed that
method, and folded what it does into the socket.close() call.  But that
means that subclasses can't hook onto that code, to get cleaned up
when the socket is truly closed.  So the SSL context gets leaked.

Adding _real_close() back to the socket module fixes most of the leak,
but not all of it.  I'm looking for the other problem...

__
Tracker <[EMAIL PROTECTED]>

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



[issue1581] xmlrpclib.ServerProxy() doesn't use x509 data

2007-12-10 Thread Martin v. Löwis

Martin v. Löwis added the comment:

I would like to ask the submitter to review the code himself for
suitability in 2.6. The underlying API has been extended a lot, so it's
unlikely that this patch is still the best choice.

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

Applied in r59457

I had to add checks for _M_X64 and _M_IA64 to doubledigits.c. The rest
was fine on Windows.

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



[issue1202] zlib.crc32() and adler32() return value

2007-12-10 Thread Armin Rigo

Armin Rigo added the comment:

Obscure but reasonable.  (I suspect you meant to say that py3k should
return the *unsigned* value for better compliance with the standard.)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1202] zlib.crc32() and adler32() return value

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

> Obscure but reasonable.  (I suspect you meant to say that py3k should
> return the *unsigned* value for better compliance with the standard.)

Yes. :)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1643738] Problem with signals in a single-threaded application

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Discussing this with Rhamporyncus (Adam Olson) on #python-dev now.

--
assignee:  -> gvanrossum
nosy: +gvanrossum

_
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-10 Thread Bill Janssen

Bill Janssen added the comment:

So, what's the final status of __del__ in py3K?  The other bit of leak
is due to _real_close() not being called when a socket is dropped on the
floor (say, you try to connect, fail, and raise the exception back to
the caller, without ever explicitly calling close() on the opened
socket).  It looks like the __del__ method in SSLSocket isn't being called.

__
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-10 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Is it possible that you have the same problem as in
http://bugs.python.org/issue1540 ?

To be sure, check the gc.garbage variable at the end of the test. It may
contain the references you are looking for...

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



[issue1643738] Problem with signals in a single-threaded application

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Committed revision 59460 to 2.6.

Will backport to 2.5 as well.

--
resolution:  -> accepted

_
Tracker <[EMAIL PROTECTED]>

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



[issue1643738] Problem with signals in a single-threaded application

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Committed revision 59461 to 2.5.

Thanks, Ulisses!!

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



[issue1754489] Non-portable address length calculation for AF_UNIX sockets

2007-12-10 Thread Christian Heimes

Changes by Christian Heimes:


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



[issue1469] SSL tests leak memory

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

> So, what's the final status of __del__ in py3K?  The other bit of leak
> is due to _real_close() not being called when a socket is dropped on the
> floor (say, you try to connect, fail, and raise the exception back to
> the caller, without ever explicitly calling close() on the opened
> socket).  It looks like the __del__ method in SSLSocket isn't being called.

There are no current plans to change __del__ in Py3k.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1576] First draft of a post import hook

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

UPDATES:

* no ref leaks
* PyModule_IsLazy(mod) checks mod.__lazy_import__ attribute (we can
argue about a nice name later)
* Added imp.is_lazy(mod_or_name)

Added file: http://bugs.python.org/file8914/py3k_post_import_hook4.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Python/import.c
===
--- Python/import.c	(Revision 59449)
+++ Python/import.c	(Arbeitskopie)
@@ -161,7 +161,7 @@
 void
 _PyImportHooks_Init(void)
 {
-	PyObject *v, *path_hooks = NULL, *zimpimport;
+	PyObject *v, *path_hooks = NULL, *zimpimport, *pihr;
 	int err = 0;
 
 	/* adding sys.path_hooks and sys.path_importer_cache, setting up
@@ -198,6 +198,14 @@
 			  );
 	}
 
+	pihr = PyDict_New();
+	if (pihr == NULL ||
+PySys_SetObject("post_import_hooks", pihr) != 0) {
+		PyErr_Print();
+		Py_FatalError("initialization of post import hook registry "
+			  "failed");
+	}
+
 	zimpimport = PyImport_ImportModule("zipimport");
 	if (zimpimport == NULL) {
 		PyErr_Clear(); /* No zip import module -- okay */
@@ -369,6 +377,7 @@
 	"path", "argv", "ps1", "ps2",
 	"last_type", "last_value", "last_traceback",
 	"path_hooks", "path_importer_cache", "meta_path",
+	"post_import_hooks",
 	NULL
 };
 
@@ -623,6 +632,228 @@
 			  "sys.modules failed");
 }
 
+/* post import hook API */
+PyObject *
+PyImport_GetPostImportHooks(void)
+{
+	PyObject *pihr;
+
+	pihr = PySys_GetObject("post_import_hooks");
+	/* This should only happen during initialization */
+	if (pihr == NULL)
+		return NULL;
+
+	if (!PyDict_Check(pihr)) {
+		PyErr_SetString(PyExc_TypeError,
+"post import registry is not a dict");
+	}
+	return pihr;
+}
+
+PyObject *
+PyImport_NotifyPostImport(PyObject *module)
+{
+	static PyObject *name = NULL;
+	PyObject *mod_name = NULL, *registry = NULL, *o;
+	PyObject *hooks = NULL, *hook, *it = NULL;
+	int status = -1;
+
+	if (name == NULL) {
+		name = PyUnicode_InternFromString("__name__");
+		if (name == NULL) {
+			return NULL;
+		}
+	}
+
+	if (module == NULL) {
+		return NULL;
+	}
+
+	if (!PyModule_Check(module)) {
+		PyErr_Format(PyExc_TypeError,
+			 "A module object was expected, got '%.200s'",
+			 Py_Type(module)->tp_name);
+		Py_DECREF(module);
+		return NULL;
+	}
+
+	if (PyModule_IsLazy(module)) {
+		/* nothing to do here */
+		return module;
+	}
+	/* XXX check if module is in sys.modules ? */
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL) {
+		/* This should only happen during initialization */
+		return module;
+	}
+
+	mod_name = PyObject_GetAttr(module, name);
+	if (mod_name == NULL) {
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyObject *repr;
+		char *name;
+
+		repr = PyObject_Repr(module);
+		name = repr ? PyUnicode_AsString(repr) : "";
+		PyErr_Format(PyExc_TypeError,
+			 "Module __name__ attribute of '%.200s' is not "
+			 "string", name);
+		Py_XDECREF(repr);
+		goto error;
+	}
+
+	hooks = PyDict_GetItem(registry, mod_name);
+	if (hooks == NULL || hooks == Py_None) {
+		/* Either no hooks are defined or they are already fired */
+		if (hooks == NULL) {
+			PyErr_Clear();
+		}
+		goto end;
+	}
+	if (!PyList_Check(hooks)) {
+		PyErr_Format(PyExc_TypeError,
+			 "expected None or list of hooks, got '%.200s'",
+			 Py_Type(hooks)->tp_name);
+		goto error;
+	}
+
+	/* fire hooks */
+	it = PyObject_GetIter(hooks);
+	if (it == NULL) {
+		goto error;
+	}
+	while ((hook = PyIter_Next(it)) != NULL) {
+		o = PyObject_CallFunctionObjArgs(hook, module, NULL);
+		Py_DECREF(hook);
+		if (o == NULL) {
+			goto error;
+		}
+		Py_DECREF(o);
+	}
+
+	/* Mark hooks as fired */
+	if (PyDict_SetItem(registry, mod_name, Py_None) < 0) {
+		goto error;
+	}
+
+end:
+	status = 0;
+error:
+	Py_XDECREF(mod_name);
+	Py_XDECREF(it);
+	if (status < 0) {
+		return NULL;
+	}
+	else {
+		return module;
+	}
+}
+
+PyObject *
+PyImport_RegisterPostImportHook(PyObject *callable, PyObject *mod_name)
+{
+	PyObject *registry = NULL, *hooks = NULL;
+	int status = -1;
+
+	if (!PyCallable_Check(callable)) {
+		PyErr_SetString(PyExc_TypeError, "expected callable");
+		goto error;
+	}
+	if (!PyUnicode_Check(mod_name)) {
+		PyErr_SetString(PyExc_TypeError, "expected string");
+		goto error;
+	}
+
+	registry = PyImport_GetPostImportHooks();
+	if (registry == NULL) {
+		goto error;
+	}
+
+	lock_import();
+
+	hooks = PyDict_GetItem(registry, mod_name);
+	/* module may be already loaded, get the module object from sys */
+	if (hooks == NULL || hooks == Py_None) {
+		PyObject *o, *modules;
+		PyObject *module = NULL;
+
+		modules = PySys_GetObject("modules");
+		if (modules == NULL) {
+			goto error;
+		}
+		module = PyObject_GetItem(modules, mod_name);
+		if (module == NULL) {
+			PyErr_Clear();
+			/* somebody messed up sys.modules */
+			if (hooks == Py_None) {
+; /* XXX error */
+			}
+		}
+		/*

[issue1582] Documentation patch for reversed() and __reversed__()

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Georg, can you handle this?

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

__
Tracker <[EMAIL PROTECTED]>

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



[issue1583] Patch for signal.set_wakeup_fd

2007-12-10 Thread Adam Olsen

New submission from Adam Olsen:

This adds signal.set_wakeup_fd(fd), which allows a single library to be
woken when a signal comes in.

--
files: python2.6-set_wakeup_fd1.diff
messages: 58385
nosy: rhamphoryncus
severity: normal
status: open
title: Patch for signal.set_wakeup_fd
Added file: http://bugs.python.org/file8915/python2.6-set_wakeup_fd1.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/test/test_signal.py
===
--- Lib/test/test_signal.py	(revision 59455)
+++ Lib/test/test_signal.py	(working copy)
@@ -165,12 +165,59 @@
 self.assertRaises(TypeError, signal.signal,
   signal.SIGUSR1, None)
 
+class WakeupSignalTests(unittest.TestCase):
+TIMEOUT_FULL = 10
+TIMEOUT_HALF = 5
+
+def test_wakeup_fd_early(self):
+import select
+
+signal.alarm(1)
+before_time = time.time()
+# We attempt to get a signal during the sleep,
+# before select is called
+time.sleep(self.TIMEOUT_FULL)
+mid_time = time.time()
+self.assert_(mid_time - before_time < self.TIMEOUT_HALF)
+select.select([self.read], [], [], self.TIMEOUT_FULL)
+after_time = time.time()
+self.assert_(after_time - mid_time < self.TIMEOUT_HALF)
+
+def test_wakeup_fd_during(self):
+import select
+
+signal.alarm(1)
+before_time = time.time()
+# We attempt to get a signal during the select call
+self.assertRaises(select.error, select.select,
+[self.read], [], [], self.TIMEOUT_FULL)
+after_time = time.time()
+self.assert_(after_time - before_time < self.TIMEOUT_HALF)
+
+def setUp(self):
+import fcntl
+
+self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None)
+self.read, self.write = os.pipe()
+flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0)
+flags = flags | os.O_NONBLOCK
+fcntl.fcntl(self.write, fcntl.F_SETFL, flags)
+self.old_wakeup = signal.set_wakeup_fd(self.write)
+
+def tearDown(self):
+signal.set_wakeup_fd(self.old_wakeup)
+os.close(self.read)
+os.close(self.write)
+signal.signal(signal.SIGALRM, self.alrm)
+
+
 def test_main():
 if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos':
 raise test_support.TestSkipped("Can't test signal on %s" % \
sys.platform)
 
-test_support.run_unittest(BasicSignalTests, InterProcessSignalTests)
+test_support.run_unittest(BasicSignalTests, InterProcessSignalTests,
+WakeupSignalTests)
 
 
 if __name__ == "__main__":
Index: Modules/signalmodule.c
===
--- Modules/signalmodule.c	(revision 59455)
+++ Modules/signalmodule.c	(working copy)
@@ -12,6 +12,8 @@
 
 #include 
 
+#include 
+
 #ifndef SIG_ERR
 #define SIG_ERR ((PyOS_sighandler_t)(-1))
 #endif
@@ -75,6 +77,8 @@
 PyObject *func;
 } Handlers[NSIG];
 
+static sig_atomic_t wakeup_fd = -1;
+
 static int is_tripped = 0; /* Speed up sigcheck() when none tripped */
 
 static PyObject *DefaultHandler;
@@ -112,6 +116,7 @@
 static void
 signal_handler(int sig_num)
 {
+	const char dummy_byte = '\0';
 #ifdef WITH_THREAD
 #ifdef WITH_PTH
 	if (PyThread_get_thread_ident() != main_thread) {
@@ -125,6 +130,8 @@
 		is_tripped++;
 		Handlers[sig_num].tripped = 1;
 		Py_AddPendingCall(checksignals_witharg, NULL);
+		if (wakeup_fd != -1)
+			write(wakeup_fd, &dummy_byte, 1);
 #ifdef WITH_THREAD
 	}
 #endif
@@ -264,6 +271,38 @@
 anything else -- the callable Python object used as a handler");
 
 
+static PyObject *
+signal_set_wakeup_fd(PyObject *self, PyObject *args)
+{
+	struct stat buf;
+	int fd, old_fd;
+	if (!PyArg_ParseTuple(args, "i:set_wakeup_fd", &fd))
+		return NULL;
+#ifdef WITH_THREAD
+	if (PyThread_get_thread_ident() != main_thread) {
+		PyErr_SetString(PyExc_ValueError,
+"set_wakeup_fd only works in main thread");
+		return NULL;
+	}
+#endif
+	if (fd != -1 && fstat(fd, &buf) != 0) {
+		PyErr_SetString(PyExc_ValueError, "invalid fd");
+		return NULL;
+	}
+	old_fd = wakeup_fd;
+	wakeup_fd = fd;
+	return PyLong_FromLong(old_fd);
+}
+
+PyDoc_STRVAR(set_wakeup_fd_doc,
+"set_wakeup_fd(fd)\n\
+\n\
+Sets the fd to be written to (with '\\0') when a signal\n\
+comes in.  A library can use this to wakeup select or poll.\n\
+\n\
+The fd must be non-blocking.");
+
+
 /* List of functions defined in the module */
 static PyMethodDef signal_methods[] = {
 #ifdef HAVE_ALARM
@@ -271,6 +310,7 @@
 #endif
 	{"signal",	signal_signal, METH_VARARGS, signal_doc},
 	{"getsignal",	signal_getsignal, METH_VARARGS, getsignal_doc},
+	{"set_wakeup_fd",	signal_set_wakeup_fd, METH_VARARGS, set_wakeup_fd_doc},
 #ifdef HAVE_PAUSE
 	{"pause",	(PyCFunction)signal_pause,
 	 

[issue1583] Patch for signal.set_wakeup_fd

2007-12-10 Thread Adam Olsen

Adam Olsen added the comment:

Guido, it looks like I can't alter the Assigned To field.  You get the
Nosy List instead. ;)

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1583] Patch for signal.set_wakeup_fd

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Thanks!

Can you add a doc patch too?  Doc/library/signal.rst

--
assignee:  -> gvanrossum
keywords: +py3k
versions: +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



[issue1469] SSL tests leak memory

2007-12-10 Thread Bill Janssen

Bill Janssen added the comment:

The other leak comes from this code:

   s = ssl.wrap_socket(socket.socket(), ...)
   s.connect((SOME BOGUS ADDRESS OR SERVER))

The connect() fails, and the SSLSocket "s"gets dropped on the floor,
but never seems to be GC'd, (or the GC never seems to call the __del__
method).  Any idea why?

Could this be because the base class is a C class?

__
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-10 Thread Bill Janssen

Bill Janssen added the comment:

gc.garbage is always empty.

__
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-10 Thread Guido van Rossum

Guido van Rossum added the comment:

I wonder if Christian Heimes was correct that the ssl object needs GC
support? This was part of his patch (which I checked in and then
reverted because the other part of it didn't work as advertised).

Alternatively, if 's' is involved in a cycle *and* any of the objects
in the cycle has a __del__ method, the GC won't call __del__. This
seems counter-intuitive but is actually correct since __del__ can only
be called when there are no references to an object left.

--Guido

On Dec 10, 2007 3:30 PM, Bill Janssen <[EMAIL PROTECTED]> wrote:
>
> Bill Janssen added the comment:
>
> The other leak comes from this code:
>
>s = ssl.wrap_socket(socket.socket(), ...)
>s.connect((SOME BOGUS ADDRESS OR SERVER))
>
> The connect() fails, and the SSLSocket "s"gets dropped on the floor,
> but never seems to be GC'd, (or the GC never seems to call the __del__
> method).  Any idea why?
>
> Could this be because the base class is a C class?
>
>
> __
> Tracker <[EMAIL PROTECTED]>
> 
> __
>

__
Tracker <[EMAIL PROTECTED]>

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



[issue1583] Patch for signal.set_wakeup_fd

2007-12-10 Thread Guido van Rossum

Changes by Guido van Rossum:


--
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1583] Patch for signal.set_wakeup_fd

2007-12-10 Thread Guido van Rossum

Changes by Guido van Rossum:


--
keywords: +patch -py3k

__
Tracker <[EMAIL PROTECTED]>

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



[issue1564547] Py_signal_pipe

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Rejected, in favor of #1583 which lets the app choose whether to use a
fd or not.  We had an extensive #python-dev discussion on this and this
time the rejection is irrevocable.

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



[issue1564547] Py_signal_pipe

2007-12-10 Thread Guido van Rossum

Changes by Guido van Rossum:


--
resolution: accepted -> rejected
superseder:  -> Patch for signal.set_wakeup_fd

_
Tracker <[EMAIL PROTECTED]>

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



[issue1583] Patch for signal.set_wakeup_fd

2007-12-10 Thread Adam Olsen

Adam Olsen added the comment:

version 2, adds to Doc/library/signal.rst.  It also tweaks the
set_wakeup_fd's docstring.

I haven't verified that my formatting in signal.rst is correct. 
Specifically, the '\0' should be checked.

Added file: http://bugs.python.org/file8916/python2.6-set_wakeup_fd2.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Doc/library/signal.rst
===
--- Doc/library/signal.rst	(revision 59455)
+++ Doc/library/signal.rst	(working copy)
@@ -110,6 +110,20 @@
:manpage:`signal(2)`.)
 
 
+.. function:: set_wakeup_fd(fd)
+
+   Set the wakeup fd to *fd*.  When a signal is received, a `'\0'` byte is written
+   to the fd.  This can be used by a library to wakeup a poll or select call,
+   allowing the signal to be fully processed.
+
+   The old wakeup fd is returned.  *fd* must be non-blocking.  It is up to the
+   library to remove any bytes before calling poll or select again.
+
+   When threads are enabled, this function can only be called from the main thread;
+   attempting to call it from other threads will cause a :exc:`ValueError`
+   exception to be raised.
+
+
 .. function:: signal(signalnum, handler)
 
Set the handler for signal *signalnum* to the function *handler*.  *handler* can
Index: Lib/test/test_signal.py
===
--- Lib/test/test_signal.py	(revision 59455)
+++ Lib/test/test_signal.py	(working copy)
@@ -165,12 +165,59 @@
 self.assertRaises(TypeError, signal.signal,
   signal.SIGUSR1, None)
 
+class WakeupSignalTests(unittest.TestCase):
+TIMEOUT_FULL = 10
+TIMEOUT_HALF = 5
+
+def test_wakeup_fd_early(self):
+import select
+
+signal.alarm(1)
+before_time = time.time()
+# We attempt to get a signal during the sleep,
+# before select is called
+time.sleep(self.TIMEOUT_FULL)
+mid_time = time.time()
+self.assert_(mid_time - before_time < self.TIMEOUT_HALF)
+select.select([self.read], [], [], self.TIMEOUT_FULL)
+after_time = time.time()
+self.assert_(after_time - mid_time < self.TIMEOUT_HALF)
+
+def test_wakeup_fd_during(self):
+import select
+
+signal.alarm(1)
+before_time = time.time()
+# We attempt to get a signal during the select call
+self.assertRaises(select.error, select.select,
+[self.read], [], [], self.TIMEOUT_FULL)
+after_time = time.time()
+self.assert_(after_time - before_time < self.TIMEOUT_HALF)
+
+def setUp(self):
+import fcntl
+
+self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None)
+self.read, self.write = os.pipe()
+flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0)
+flags = flags | os.O_NONBLOCK
+fcntl.fcntl(self.write, fcntl.F_SETFL, flags)
+self.old_wakeup = signal.set_wakeup_fd(self.write)
+
+def tearDown(self):
+signal.set_wakeup_fd(self.old_wakeup)
+os.close(self.read)
+os.close(self.write)
+signal.signal(signal.SIGALRM, self.alrm)
+
+
 def test_main():
 if sys.platform[:3] in ('win', 'os2') or sys.platform == 'riscos':
 raise test_support.TestSkipped("Can't test signal on %s" % \
sys.platform)
 
-test_support.run_unittest(BasicSignalTests, InterProcessSignalTests)
+test_support.run_unittest(BasicSignalTests, InterProcessSignalTests,
+WakeupSignalTests)
 
 
 if __name__ == "__main__":
Index: Modules/signalmodule.c
===
--- Modules/signalmodule.c	(revision 59455)
+++ Modules/signalmodule.c	(working copy)
@@ -12,6 +12,8 @@
 
 #include 
 
+#include 
+
 #ifndef SIG_ERR
 #define SIG_ERR ((PyOS_sighandler_t)(-1))
 #endif
@@ -75,6 +77,8 @@
 PyObject *func;
 } Handlers[NSIG];
 
+static sig_atomic_t wakeup_fd = -1;
+
 static int is_tripped = 0; /* Speed up sigcheck() when none tripped */
 
 static PyObject *DefaultHandler;
@@ -112,6 +116,7 @@
 static void
 signal_handler(int sig_num)
 {
+	const char dummy_byte = '\0';
 #ifdef WITH_THREAD
 #ifdef WITH_PTH
 	if (PyThread_get_thread_ident() != main_thread) {
@@ -125,6 +130,8 @@
 		is_tripped++;
 		Handlers[sig_num].tripped = 1;
 		Py_AddPendingCall(checksignals_witharg, NULL);
+		if (wakeup_fd != -1)
+			write(wakeup_fd, &dummy_byte, 1);
 #ifdef WITH_THREAD
 	}
 #endif
@@ -264,6 +271,39 @@
 anything else -- the callable Python object used as a handler");
 
 
+static PyObject *
+signal_set_wakeup_fd(PyObject *self, PyObject *args)
+{
+	struct stat buf;
+	int fd, old_fd;
+	if (!PyArg_ParseTuple(args, "i:set_wakeup_fd", &fd))
+		return NULL;
+#ifdef WITH_THREAD
+	if (PyThread_get_thread_ident() != main_thread) {
+		PyErr_SetString(PyExc_ValueError,
+"set_wake

[issue1374] IDLE - minor FormatParagraph bug fix

2007-12-10 Thread Kurt B. Kaiser

Kurt B. Kaiser added the comment:

r59463
Thanks for the patch!

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

Noam, perhaps you can help with this?  We checked this in but found a
problem: repr(1e5) suddenly returns '1.0'.  Can you think of a cause for
this?

--
status: closed -> open

__
Tracker <[EMAIL PROTECTED]>

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



[issue1252] IDLE - patch Delegator to support callables

2007-12-10 Thread Kurt B. Kaiser

Kurt B. Kaiser added the comment:

Do you have any further comments on this issue?

__
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-10 Thread Bill Janssen

Bill Janssen added the comment:

Ah, I see what's going on.  The revision of the socket code (nice job,
by the way) removed the distinction between the C socket object and the
Python socket object.  The C SSLContext keeps a pointer to the C socket
object, which is now the Python socket object, or in the SSL case, the
SSLSocket object.  So there's a circular reference.

The right fix is to make the ref in the SSL C code a weakref.

__
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-10 Thread Christian Heimes

Christian Heimes added the comment:

Guido van Rossum wrote:
> Guido van Rossum added the comment:
> 
> I wonder if Christian Heimes was correct that the ssl object needs GC
> support? This was part of his patch (which I checked in and then
> reverted because the other part of it didn't work as advertised).
> 
> Alternatively, if 's' is involved in a cycle *and* any of the objects
> in the cycle has a __del__ method, the GC won't call __del__. This
> seems counter-intuitive but is actually correct since __del__ can only
> be called when there are no references to an object left.

A combination of GC support and the removal of __del__ from SSLSocket
has fixed the reference leak problem for me. I tried to move the
_real_clean() call to PySSL_dealloc but it wasn't as easy as I thought.

The code contains a reference cycle. ssl.SSLSocket() contains a
reference to PySSLObject and PySSLObject->Socket is a reference to the
same ssl.SSLSocket instance.

Christian

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Noam Raphael

Noam Raphael added the comment:

I don't know, for me it works fine, even after downloading a fresh SVN
copy. On what platform does it happen?

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

I've disabled the new repr() in trunk and py3k until somebody has sorted
out the build problems. I've removed doubledigits.c from Makefile.in and
disabled the code with #ifdef Py_BROKEN_REPR in floatobject.c.

--
assignee: tiran -> 
keywords: +py3k
priority:  -> high
resolution: fixed -> 
versions: +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



[issue1736190] asyncore/asynchat patches

2007-12-10 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

In attachment I provide a patch for fixing this last mentioned issue.
It's a rewriting of initiate_send method which now looks at what is
specified by ac_out_buffer_size attribute.

Added file: http://bugs.python.org/file8917/initiate_send.py

_
Tracker <[EMAIL PROTECTED]>

_def initiate_send (self):
while self.producer_fifo and self.connected:
first = self.producer_fifo[0]
# handle empty string/buffer or None entry
if not first:
del self.producer_fifo[0]
if first is None:
self.handle_close()
return

# handle classic producer behavior
obs = self.ac_out_buffer_size
try:
data = buffer(first, 0, obs)
except TypeError:
self.producer_fifo.appendleft(first.more())
continue

# send the data
try:
   num_sent = self.send(data)
except socket.error, why:
   self.handle_error()
   return

if num_sent:
if num_sent < len(data) or obs < len(first):
self.producer_fifo[0] = first[num_sent:]
else:
del self.producer_fifo[0]
# we tried to send some actual data
return___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1736190] asyncore/asynchat patches

2007-12-10 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola':


Added file: http://bugs.python.org/file8918/differences.diff

_
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Guido van Rossum

Guido van Rossum added the comment:

> On what platform does it happen?

Linux on x86.

It seems find on PPC OSX.

This suggests it could be a byte order bug.

__
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-10 Thread Bill Janssen

Bill Janssen added the comment:

I think Christian analysis is right, in that it takes a bit of GC
support, but not perhaps in the specifics of his approach.  I've done
two things to fix this:

1)  Put _real_close() back in socket.py, and then override it in
ssl.SSLSocket to release the SSLContext, and

2)  Change the pointer to the SSLSocket in _ssl.c to a weakref.

Now SSLSockets get cleaned up properly by the GC system.

One question: _real_close() is what Java calls a "protected" method.  Do
we have any way to mark this with annotations or metaclass stuff?

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Noam Raphael

Noam Raphael added the comment:

I also use linux on x86. I think that byte order would cause different
results (the repr of a random float shouldn't be "1.0".)
Does the test case run ok? Because if it does, it's really strange.

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Christian Heimes

Changes by Christian Heimes:


--
versions: +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



[issue1469] SSL tests leak memory

2007-12-10 Thread Bill Janssen

Bill Janssen added the comment:

Here's a patch -- take a look and let me know.

I also added a real asyncore server test.

Added file: http://bugs.python.org/file8919/a

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Tim Peters

Tim Peters added the comment:

There is nothing you can do to repr() that's sufficient by itself to
ensure eval(repr(x)) == x.

The other necessary part is correctly rounded float /input/ routines.

The 754 standard does not require correctly rounding input or output
routines.  It does require that eval(repr(x)) == x provided that repr(x)
produce at least 17 significant digits (not necessarily correctly
rounded, but "good enough" so that eval(repr(x)) == x).  That's why
Python produces 17 significant digits.  While there's no guarantee that
all platform I/O routines are good enough to meet the 754 requirement,
most do, and what Python's repr() actually does is the strongest that
/can/ be done assuming no more than full 754 conformance.

Again, this cannot be improved cross-platform without Python supplying
both output and input routines.  Burger's output routines supply only
half of what's needed.  An efficient way to do the other half (correctly
rounding input) was first written up by Clinger.  Note that neither the
Burger/Dybvig output code nor the Clinger input code are used much in
practice anymore; David Gay's code is usually used instead for "go fast"
reasons:

http://mail.python.org/pipermail/python-list/2004-July/272167.html

Clinger also endorses Gay's code:

ftp://ftp.ccs.neu.edu/pub/people/will/retrospective.pdf

However, as the Python list link says, Gay's code is "mind-numbingly
complicated".

There is no easy cross-platform solution, where "cross-platform" means
just "limited to 754 platforms".

__
Tracker <[EMAIL PROTECTED]>

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



[issue1563] asyncore and asynchat incompatible with Py3k str and bytes

2007-12-10 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

There's a patch pending which should be included in the 2.6 trunk before
solving issues related to py3k and/or applying other changes, imho: 
http://bugs.python.org/issue1736190

--
nosy: +giampaolo.rodola

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Christian Heimes

Christian Heimes added the comment:

I've written a small C program for auto config that checks the
endianness of IEEE doubles. Neil has promised to add something to
configure.in when I come up with a small C program. It *should* do the
right thing on a BE platform but I can't test it.

Tim, does Python run on a non IEEE 754 platform? Should the new repr()
be ripped out? I hate to break Python for scientists just to silence
some ignorants and unexperienced newbies.

--
nosy: +nascheme
Added file: http://bugs.python.org/file8920/ieee_dbl.c

__
Tracker <[EMAIL PROTECTED]>

__#define BIAS 1023
typedef struct {
	unsigned int  sign :  1;
	unsigned int   exp : 11;
	unsigned intm1 :  4;
	unsigned intm2 : 16;
	unsigned intm3 : 16;
	unsigned intm4 : 16;
} be_ieee_dbl;

typedef struct {
	unsigned intm4 : 16;
	unsigned intm3 : 16;
	unsigned intm2 : 16;
	unsigned intm1 :  4;
	unsigned int   exp : 11;
	unsigned int  sign :  1;
} le_ieee_dbl;

/* 1 = little endian IEEE double
 * 2 = big endian IEEE double
 * 0 = error
 */
int main(void)
{
	double dbl = -9.;
	le_ieee_dbl *le = (le_ieee_dbl*)&dbl;
	be_ieee_dbl *be = (be_ieee_dbl*)&dbl;
	if (le->sign == 1 && le->exp-BIAS == 3 && le->m1 == 2 &&
	le->m2 == 0 && le->m3 == 0 && le->m4 == 0) {
		return 1;
	}
if (be->sign == 1 && be->exp-BIAS == 3 && be->m1 == 2 &&
	be->m2 == 0 && be->m3 == 0 && be->m4 == 0) {
		return 2;
	}
	return 0;
}

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



[issue1482] IMAP4 SSL isn't working

2007-12-10 Thread Bill Janssen

Bill Janssen added the comment:

I'm still getting this with the latest SSL module fixes.  I'm guessing
this is a problem with the implementation of imaplib, but I haven't
looked into it yet.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1482] IMAP4 SSL isn't working

2007-12-10 Thread Bill Janssen

Bill Janssen added the comment:

Here's a fix for the 3K branch.

Added file: http://bugs.python.org/file8921/b

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1482] IMAP4 SSL isn't working

2007-12-10 Thread Bill Janssen

Changes by Bill Janssen:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1223] httplib does not handle ssl end of file properly

2007-12-10 Thread Bill Janssen

Bill Janssen added the comment:

I'll close this when the fix gets into all the branches (right now it's
in the pre-2.6 code, and in the 3K code, but not yet in the 2.6 branch).

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Tim Peters

Tim Peters added the comment:

Again, without replacing float input routines too, this is /not/ good
enough to ensure eval(repr(x)) == x even across just 100%-conforming 754
platforms.

It is good enough to ensure (well, assuming the code is 100% correct)
eval(repr(x)) == x across conforming 754 platforms that go /beyond/ the
standard by also supplying correctly rounding input routines.  Some
platform C libraries do, some don't.  For example, I believe glibc does
(and builds its I/O code on David Gay's, mentioned before), but that
Microsoft's does not (but that Microsoft's do meet the 754 standard,
which-- again --isn't strong enough for "shortest output" to round-trip
correctly in all cases).

__
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-10 Thread Bill Janssen

Bill Janssen added the comment:

Now, about the "confused signature" of SSLSocket.read().

I'm not sure how confused it is.  It's sui generis; SSLSocket doesn't
inherit from some other class with a different read() method with a
different signature.  But we could change the name, perhaps to
"readbytes", or something similar?  I wrote it the way I did to keep
some kind of compatibility with pre-3.0 uses of the SSL module.

Anyway, the error is coming from a bug in the implementation of
'suppress_ragged_eofs'.  The code in SSLSocket.read() that handles the
EOF error needs to return the right kind of value.  I've added it to the
patch.

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

__
Tracker <[EMAIL PROTECTED]>

__

patch-2
Description: Binary data
___
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-10 Thread Bill Janssen

Changes by Bill Janssen:


Removed file: http://bugs.python.org/file8919/a

__
Tracker <[EMAIL PROTECTED]>

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



[issue1584] Mac OS X: building with X11 Tkinter

2007-12-10 Thread C. E. Ball

New submission from C. E. Ball:

On OS X, I wanted to build my own copy of Python that used my own copy
of Tkinter (built for X11). 

To do this, I passed "LDFLAGS=-rpath,/path/to/lib" to configure so that
Python could find my specific lib files, but I also had to edit Python's
setup.py so that detect_tkinter() would not do anything special for Darwin:

$ diff setup.py original_setup.py 
1199c1199
< if 0 and (platform == 'darwin' and
---
> if (platform == 'darwin' and


I did this based on a post by Ronald Oussoren to the Python-SIG Mac
mailing list [http://article.gmane.org/gmane.comp.python.apple/14008].
He also suggested that I file a bug report, asking for an argument to be
added to python's configure script to avoid having to edit setup.py.

Thanks

--
components: Build, Macintosh, Tkinter
messages: 58413
nosy: ceball
severity: minor
status: open
title: Mac OS X: building with X11 Tkinter
type: behavior
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



[issue1597850] Cross compiling patches for MINGW

2007-12-10 Thread John Stowers

John Stowers added the comment:

I created config.cache and populated it with 
ac_cv_printf_zd_format=yes

before executing the following

./configure --prefix /home/john/jhbuild/win32/build/  
--build=i686-pc-linux-gnuaout --host=i586-pc-mingw32msvc
--target=i586-pc-mingw32msvc --disable-docs --enable-all-warnings 
AR="/usr/bin/i586-mingw32msvc-ar" 
RANLIB="/usr/bin/i586-mingw32msvc-ranlib" 
STRIP="/usr/bin/i586-mingw32msvc-strip" 
AS="/usr/bin/i586-mingw32msvc-as" 
DLLTOOL="/usr/bin/i586-mingw32msvc-dlltool" 
OBJDUMP="/usr/bin/i586-mingw32msvc-objdump" 
NM="/usr/bin/i586-mingw32msvc-nm" 
WINDRES="/usr/bin/i586-mingw32msvc-windres" --config-cache

ac_cv_printf_zd_format=yes ./configure . doesn't work either

Is it necessary to rm configure && autoconf ? Im afraid I cant get this
to work...

_
Tracker <[EMAIL PROTECTED]>

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



[issue1582] Documentation patch for reversed() and __reversed__()

2007-12-10 Thread Georg Brandl

Georg Brandl added the comment:

Certainly!

__
Tracker <[EMAIL PROTECTED]>

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



[issue1580] Use shorter float repr when possible

2007-12-10 Thread Noam Raphael

Noam Raphael added the comment:

Oh, this is sad. Now I know why Tcl have implemented also a decimal to
binary routine.

Perhaps we can simply use both their routines? If I am not mistaken,
their only real dependency is on a library which allows arbitrary long
integers, called tommath, from which they use a few basic functions.
We can use instead the functions from longobject.c. It will probably
be somewhat slower, since longobject.c wasn't created to allow
in-place operations, but I don't think it should be that bad -- we are
mostly talking about compile time.

__
Tracker <[EMAIL PROTECTED]>

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