[issue1868] threading.local doesn't free attrs when assigning thread exits

2008-11-29 Thread Martin v. Löwis

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

Is any of the patches believed to be ready?

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Akira Kitada

Akira Kitada [EMAIL PROTECTED] added the comment:

The new patch attached renamed Py_GCC_ATTRIBUTE to Py_GCC_FORMAT_ATTRIBUTE.

As Roumen pointed out, the current python code use Py_GCC_ATTRIBUTE
only for 'format(printf(...)) ' attribute.,  so this change should not
be no harm itself.
 
Because a GCC attribute was/will be introduced in different version of
GCC, we cannot have generic Py_GCC_ATTRIBUTE easily.

You can find availability of a attribute at
http://www.ohse.de/uwe/articles/gcc-attributes.html
http://www.ohse.de/uwe/articles/gcc-attributes.html

Added file: http://bugs.python.org/file12159/issue4370.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Akira Kitada

Changes by Akira Kitada [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file12124/pyport.h.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1529142] Allowing multiple instances of IDLE with sub-processes

2008-11-29 Thread Tal Einat

Tal Einat [EMAIL PROTECTED] added the comment:

First of all, the multiprocessing module doesn't work fully in an
interactive shell.

From the Python2.6 docs:
Note Functionality within this package requires that the __main__
method be importable by the children. This is covered in Programming
guidelines however it is worth pointing out here. This means that some
examples, such as the multiprocessing.Pool examples will not work in
the interactive interpreter.

And later on that same page (under Programming Guidelines - Windows):
Make sure that the main module can be safely imported by a new Python
interpreter without causing unintended side effects (such a starting a
new process).

This is probably why IDLE is acting up for you. I would be surprised
if using the multiprocessing module will work well in IDLE either with
or without a sub-process.


As per the patch, someone should just work up an updated one with all
of the insight gained in the last several years (!) regarding this.

It should just do two things:
1) remove the use of the SO_REUSEADDR flag in the sub-process spawning
code -- see http://bugs.python.org/issue1201569
2) pass zero as the argument for the port number, which instructs the
underlying socket library to select an available port, and later
retrieve the selected port from the socket object -- see
http://mail.python.org/pipermail/idle-dev/2008-June/002687.html

The other changes in my original patch, while they do work, are
unnecessarily complex and make it much harder to get the patch
accepted. They should also not be significant if the spawning delays
are fixed.

If you'd like to work up such a patch and get it reviewed and
committed, please be my guest! I will help you in any way I can if you
take this up. Otherwise I guess it will wait until I find the time and
energy...

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1529142
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Akira Kitada

Changes by Akira Kitada [EMAIL PROTECTED]:


Added file: http://bugs.python.org/file12160/issue4370.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Akira Kitada

Akira Kitada [EMAIL PROTECTED] added the comment:

Tested my patch on 
* FreeBSD 4.11 (gcc version 2.95.4, does not support z)
* FreeBSD 6.3 (gcc version 3.4.6, supports z)
and it worked fine on both. (using trunk)

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Martin v. Löwis

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

I'm opposed to applying this patch to a maintenance branch. It removes
the Py_GCC_ATTRIBUTE macro, which some extension modules might rely on.

I also wonder whether it is really necessary to complicate the code just
so that gcc 2.95 stops producing some warnings. So I propose to close
this as won't fix.

--
keywords:  -needs review
nosy: +loewis

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1868] threading.local doesn't free attrs when assigning thread exits

2008-11-29 Thread Martin v. Löwis

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

Reconsidering: I think the needs review keyword should only be applied
if there is a single patch associated with the issue that needs review.
So anybody setting the keyword should remove all patches that don't need
review anymore (as they are superceded). I'm removing the keyword for now.

--
keywords:  -needs review

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1868
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4428] io.BufferedWriter does not observe buffer size limits

2008-11-29 Thread Martin v. Löwis

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

According to msg76581, the patch fails review (lacking test cases), so
I'm removing the needs review keyword.

--
keywords:  -needs review
nosy: +loewis

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4428
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4428] io.BufferedWriter does not observe buffer size limits

2008-11-29 Thread David M. Beazley

David M. Beazley [EMAIL PROTECTED] added the comment:

I agree with previous comments that write() should definitely write all 
data when in blocking mode.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4428
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Martin v. Löwis

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

I don't think this is quite right yet. If I run

import socket
s=socket.socket()
s.connect(('www.python.org',80))
x=s.makefile()
del x
del s

and put a print statement into real_close, I don't see that real_close
is invoked.

--
nosy: +loewis

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Akira Kitada

Akira Kitada [EMAIL PROTECTED] added the comment:

Martin,
Thank you for the feedback.

I think we can avoid the problem that would be introduced by the removal
of Py_GCC_ATTRIBUTE by leaving it as is
(probably adding #warning this macro is deprecated. Please use
Py_GCC_FORMAT_ATTRIBUTE instead).

The patch looks not so complicated to me. It's just a renaming of a
macro. The new name is more explicit.

IMHO, source code should be kept warning-free, as long as the fix is
simple and it does not cost much.

So I think now the question would be whether having explicitly named
macro and warning-free code for old compilers worth the effort of
renaming all Py_GCC_ATTRIBUTE to Py_GCC_FORMAT_ATTRIBUTE.

I would like to leave the decision to the core developers.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Martin v. Löwis

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

Ok. Removing 2.5.3 from the target releases until a decision is made
(and potentially a new patch is available).

--
versions:  -Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Amaury Forgeot d'Arc

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

But real_close() is not called either in the trivial socket use:

import socket
s=socket.socket()
s.connect(('www.python.org',80))
del s

OTOH, I added some printf statements in socketmodule.c, near all usages 
of SOCKETCLOSE(). They show that the raw socket is closed as expected - 
except in the following case:

import socket
s=socket.socket()
s.connect(('www.python.org',80))
x=s.makefile()
x.close()
del s

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4459] bdist_rpm assumes python

2008-11-29 Thread John5342

New submission from John5342 [EMAIL PROTECTED]:

When using bdist_rpm the %build section of the generated spec file
contains the following:

env CFLAGS=$RPM_OPT_FLAGS python setup.py build

This works fine until the python is installed using altinstall. In this
situation the spec file will use the default python rather than the one
currently used.

I am currently using python3.0 with the default python being 2.5. As a
result the spec file is created which then calles python (2.5) and my
setup.py contains 3.0 code so the spec file fails.

When the above line is generated it should use the current interpreters
path and name rather than just python

--
components: Distutils
messages: 76596
nosy: John5342
severity: normal
status: open
title: bdist_rpm assumes python
type: behavior
versions: Python 3.0

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4459
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1683] Thread local storage and PyGILState_* mucked up by os.fork()

2008-11-29 Thread Christian Heimes

Christian Heimes [EMAIL PROTECTED] added the comment:

I was wrong and the patch is right. Something is wrong in
multiprocessings connection_recvbytes_into() function for the old buffer
protocol. Somehow PyArg_ParseTuple(args, w#| ...) fucks up the
process' memory.

Martin, are you fine with the patch? fork-thread-patch-2 still applies
with some fuzzying.

--
assignee: christian.heimes - loewis
nosy: +loewis

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1683
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4456] xmlrpc is broken

2008-11-29 Thread Jeremy Hylton

Jeremy Hylton [EMAIL PROTECTED] added the comment:

I don't think I understand this report.  The TransportSubclassTestCase
class tests the behavior of overridable methods that don't exist in
Python 3.0.  Is this really a Python 3.0 problem?  I'm not sure why we
expect it to work there.

Jeremy

On Fri, Nov 28, 2008 at 5:43 PM, Benjamin Peterson
[EMAIL PROTECTED] wrote:

 New submission from Benjamin Peterson [EMAIL PROTECTED]:

 It looks there are logic problems with regards to encoding in xmlrpc:

if not isinstance(methodname, str):
methodname = methodname.encode(encoding)

 Merging r67370 and running test_xmlrpc gives:

 test_bug_1164912 (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_cmp_datetime_DateTime (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_datetime_before_1900 (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_bad_dict (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_bare_datetime (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_big_int (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_big_long (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_load (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_none (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_recursive_dict (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_dump_recursive_seq (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_newstyle_class (test.test_xmlrpc.XMLRPCTestCase) ... ok
 test_escape (test.test_xmlrpc.HelperTestCase) ... ok
 test_datetime_datetime (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_decode (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_default (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_repr (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_time (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_time_struct (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_time_tuple (test.test_xmlrpc.DateTimeTestCase) ... ok
 test_decode (test.test_xmlrpc.BinaryTestCase) ... ok
 test_default (test.test_xmlrpc.BinaryTestCase) ... ok
 test_string (test.test_xmlrpc.BinaryTestCase) ... ok
 test_dotted_attribute (test.test_xmlrpc.FaultTestCase) ... ok
 test_dump_fault (test.test_xmlrpc.FaultTestCase) ... ok
 test_repr (test.test_xmlrpc.FaultTestCase) ... ok
 test_custom_user_agent (test.test_xmlrpc.TransportSubclassTestCase) ...
 ERROR
 test_send_content (test.test_xmlrpc.TransportSubclassTestCase) ... ERROR
 test_send_host (test.test_xmlrpc.TransportSubclassTestCase) ... ERROR
 test_send_request (test.test_xmlrpc.TransportSubclassTestCase) ... ERROR
 test_dotted_attribute (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_introspection1 (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_introspection2 (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_introspection3 (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_introspection4 (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_multicall (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_non_existing_multicall (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_simple1 (test.test_xmlrpc.SimpleServerTestCase) ... ok
 test_basic (test.test_xmlrpc.FailingServerTestCase) ... ok
 test_fail_no_info (test.test_xmlrpc.FailingServerTestCase) ... ok
 test_fail_with_info (test.test_xmlrpc.FailingServerTestCase) ... ok
 test_cgi_get (test.test_xmlrpc.CGIHandlerTestCase) ... ok
 test_cgi_xmlrpc_response (test.test_xmlrpc.CGIHandlerTestCase) ... ok

 ==
 ERROR: test_custom_user_agent (test.test_xmlrpc.TransportSubclassTestCase)
 --
 Traceback (most recent call last):
  File /temp/python/py3k/Lib/test/test_xmlrpc.py, line 657, in
 test_custom_user_agent
req = self.issue_request(TestTransport)
  File /temp/python/py3k/Lib/test/test_xmlrpc.py, line 645, in
 issue_request
proxy.pow(6, 8)
  File /temp/python/py3k/Lib/xmlrpc/client.py, line 1095, in __call__
return self.__send(self.__name, args)
  File /temp/python/py3k/Lib/xmlrpc/client.py, line 1353, in __request
verbose=self.__verbose
  File /temp/python/py3k/Lib/xmlrpc/client.py, line 1136, in request
return self._parse_response(resp, None)
  File /temp/python/py3k/Lib/xmlrpc/client.py, line 1246, in
 _parse_response
p.feed(response)
  File /temp/python/py3k/Lib/xmlrpc/client.py, line 516, in feed
self._parser.Parse(data, 0)
 xml.parsers.expat.ExpatError: mismatched tag: line 12, column 2

 ==
 ERROR: test_send_content (test.test_xmlrpc.TransportSubclassTestCase)
 --
 Traceback (most recent call last):
  File /temp/python/py3k/Lib/test/test_xmlrpc.py, line 687, in
 test_send_content
req = self.issue_request(TestTransport)
  File /temp/python/py3k/Lib/test/test_xmlrpc.py, line 645, in
 issue_request
proxy.pow(6, 8)
  File /temp/python/py3k/Lib/xmlrpc/client.py, line 1095, in __call__
return 

[issue4456] xmlrpc is broken

2008-11-29 Thread Benjamin Peterson

Benjamin Peterson [EMAIL PROTECTED] added the comment:

On Sat, Nov 29, 2008 at 10:21 AM, Jeremy Hylton [EMAIL PROTECTED] wrote:

 Jeremy Hylton [EMAIL PROTECTED] added the comment:

 I don't think I understand this report.  The TransportSubclassTestCase
 class tests the behavior of overridable methods that don't exist in
 Python 3.0.  Is this really a Python 3.0 problem?  I'm not sure why we
 expect it to work there.

Oh! I had no idea that those methods were not supported in 3.0. I
guess we can close this.


 Jeremy

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4456
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4456] xmlrpc is broken

2008-11-29 Thread Benjamin Peterson

Changes by Benjamin Peterson [EMAIL PROTECTED]:


--
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4456
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4460] The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Modules/_sre.c(match_getindex)
Line 2766

The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL.

--
components: None
messages: 76600
nosy: CWRU_Researcher1
severity: normal
status: open
title: The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL
type: resource usage
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4460
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4370] warning: unknown conversion type character `z' in format

2008-11-29 Thread Roumen Petrov

Roumen Petrov [EMAIL PROTECTED] added the comment:

My idea was not to remove Py_GCC_ATTRIBUTE but the new macro with
specific name that use Py_GCC_ATTRIBUTE.

If macro name is Py_GCC_FORMAT_ATTRIBUTE then something similar to :
#if !defined(PY_FORMAT_SIZE_T)
#define Py_GCC_FORMAT_ATTRIBUTE(type, str_idx, arg_idx)
#else
#define Py_GCC_FORMAT_ATTRIBUTE(type, str_idx, arg_idx)
Py_GCC_ATTRIBUTE((format(type, str_idx, arg_idx))
#endif

and next in the code
s/Py_GCC_ATTRIBUTE(...)/Py_GCC_FORMAT_ATTRIBUTE(...)/g as rest of the
proposed patch.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4370
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4461] parameters of PyLong_FromString() are not checked for NULL

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Python/ast.c(parsenumber)
Line 3061

The parameters of PyLong_FromString() are not checked for NULL before
the method is called.

--
components: None
messages: 76602
nosy: CWRU_Researcher1
severity: normal
status: open
title: parameters of PyLong_FromString() are not checked for NULL
type: resource usage
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4461
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4462] result of PyList_GetItem() not validated

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Python/import.c(find_module)
Lines 1171

PyString_Check() is not called on the result of PyList_GetItem(), nor is
the result checked to see if it is NULL.

--
components: None
messages: 76603
nosy: CWRU_Researcher1
severity: normal
status: open
title: result of PyList_GetItem() not validated
type: resource usage
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4462
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4463] Parameters and result of PyList_GetItem() are not validated

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Python/import.c(get_path_importer)
Lines 1079

PyString_Check() is not called on the result of PyList_GetItem() and the
parameters of PyList_GetItem() are not validated before the method is
called.

--
components: None
messages: 76604
nosy: CWRU_Researcher1
severity: normal
status: open
title: Parameters and result of PyList_GetItem() are not validated
type: performance
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4463
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4464] PyList_GetItem() result and parameters not fully validated

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Python/codecs.c(_PyCodec_Lookup)
Lines 106, 144

PyString_Check() is not called on the result of PyList_GetItem() and the
first parameter of PyList_GetItem() does not have PyList_Check() called
on it.
(See Python-2.5.2/Python/traceback.c(tb_displayline) for a correct
instance of the pattern)

--
components: None
messages: 76605
nosy: CWRU_Researcher1
severity: normal
status: open
title: PyList_GetItem() result and parameters not fully validated
type: performance
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4368] A bug in ncurses.h still exists in FreeBSD 4.9 - 4.11

2008-11-29 Thread Akira Kitada

Changes by Akira Kitada [EMAIL PROTECTED]:


--
versions: +Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4368
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4465] The result of set_copy() is not checked for NULL

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Objects/setobject.c
Line 1204

The result of set_copy() is not checked for NULL.

[See Objects/setobject.c(set_difference) for example of correct usage]

--
components: None
messages: 76606
nosy: CWRU_Researcher1
severity: normal
status: open
title: The result of set_copy() is not checked for NULL
type: performance
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4460] The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

I'm confused.  I'm probably missing something, but why do you think such a 
check is necessary?  The code I'm seeing at around line 2766 is:

static Py_ssize_t
match_getindex(MatchObject* self, PyObject* index)
{
Py_ssize_t i;

if (PyInt_Check(index))
return PyInt_AsSsize_t(index);

...

Is there any reason to expect that the index argument to match_getindex 
might be NULL?  Even if it were, surely it would be the PyInt_Check call 
that would be affected, not PyInt_AsSsize_t?

The usual pattern in Python C code is to check return values, but not 
incoming arguments.

--
nosy: +marketdickinson

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4460
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4465] The result of set_copy() is not checked for NULL

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

I believe the code is correct as it is.  The relevant lines are in
set_intersection:

if ((PyObject *)so == other)
return set_copy(so);

If the result of the set_copy is NULL then the NULL is passed directly 
back to the calling routine;  this is as it should be.  A NULL coming from 
set_copy indicates that an exception occurred; this is then passed on to 
the calling routine so that the calling routine is aware of the exception.

If you haven't already done so, please take a look at

http://docs.python.org/dev/c-api/index.html

especially the section on exception handling.

--
nosy: +marketdickinson
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4460] The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL

2008-11-29 Thread Brian Szuter

Brian Szuter [EMAIL PROTECTED] added the comment:

abstract.c(PyNumber_AsSsize_t) shows this check of PyInt_AsSsize_t()'s
parameter:

980:if (value == NULL)
981:return -1;
982: 
983:/* We're done if PyInt_AsSsize_t() returns without error. */   
984:result = PyInt_AsSsize_t(value);

Similar checks of this parameter occur in the following places:
classobject.c(instance_length) 980
sliceobject.c(PySlice_GetIndices) 1020
sliceobject.c(PySlice_GetIndices) 123
sliceobject.c(PySlice_GetIndices) 115
ceval.c(PyEval_EvalFrameEx) 1179
_sre.c(match_getindex) 2772

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4460
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4465] The result of set_copy() is not checked for NULL

2008-11-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

The code is correct as-is.

--
nosy: +rhettinger

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4465
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4466] The return value of PyFile_FromFile is not checked for NULL

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Modules/posixmodule.c(posix_tmpfile)
Line 6841

The return value of PyFile_FromFile is not checked for NULL

See the following where it is checked:
tokenizer.c(fp_setreadl) 429
fileobject.c(PyFile_FromString) 300
posixmodule.c(posix_popen) 5323

--
messages: 76611
nosy: CWRU_Researcher1
severity: normal
status: open
title: The return value of PyFile_FromFile is not checked for NULL

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4460] The parameter of PyInt_AsSsize_t() is not checked to see if it is NULL

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

 abstract.c(PyNumber_AsSsize_t) shows this check of PyInt_AsSsize_t()'s
 parameter:

Yup.  And that's because 'value' is the return value from 
PyNumber_Index.  PyNumber_Index might return NULL, so the check is 
necessary.

Am closing this as invalid.

I appreciate that you're trying to help here;  may I suggest that you 
take some time to read through the various development docs available?

--
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4460
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4466] The return value of PyFile_FromFile is not checked for NULL

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

See explanation for issue 4465.

--
nosy: +marketdickinson
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4466
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4467] return value of PyUnicode_AsEncodedString() is not checked for NULL

2008-11-29 Thread Brian Szuter

New submission from Brian Szuter [EMAIL PROTECTED]:

Python-2.5.2/Objects/unicodeobject.c(unicode_str)
Line 6816

The return value of PyUnicode_AsEncodedString() is not checked for NULL.

According to
http://www.python.org/doc/2.5.2/api/builtinCodecs.html#l2h-519 this
indicates an exception occurred.

See the following for instances of where this value is checked:
Parser/tokenizer.c(tok_stdin_decode) 726
Parser/tokenizer.c(dec_utf8) 1555
Objects/object.c(PyObject_GenericSetAttr) 1386
Objects/object.c(PyObject_GenericGetAttr) 1260
Objects/object.c(PyObject_SetAttr) 1161
Objects/object.c(PyObject_Str) 434-437
Objects/stringobject.c(PyString_AsEncodedString) 501
Objects/stringobject.c(PyString_AsDecodedString) 421
Objects/unicodeobject.c(_PyUnicodeUCS2_AsDefaultEncodedString) 735

--
components: None
messages: 76614
nosy: CWRU_Researcher1
severity: normal
status: open
title: return value of PyUnicode_AsEncodedString() is not checked for NULL
type: performance
versions: Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4467
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4467] return value of PyUnicode_AsEncodedString() is not checked for NULL

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

See explanation for issue 4466.

It seems to me that you have some misunderstandings about the way that 
Python works.  Please could you refrain from introducing new issues here 
unless you're sure that they really *are* issues.

If you're unsure whether something really is an issue or not, I'd be happy 
to answer queries by email.

--
nosy: +marketdickinson
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4467
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4462] result of PyList_GetItem() not validated

2008-11-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

PyObject *hook = PyList_GetItem(meta_path, i);
loader = PyObject_CallMethod(hook, find_module,
  sO, fullname, path != NULL ? path : Py_None);


The hook pointer is checked for NULL in PyObject_CallMethod() -- see
line 1947 in Objects/abstract.c.  The hook is a general object
(hopefully with a find_module() method), not a string.

--
nosy: +rhettinger
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4462
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4464] PyList_GetItem() result and parameters not fully validated

2008-11-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

Python/codecs.c line 144-147:

func = PyList_GetItem(interp-codec_search_path, i);
if (func == NULL)
goto onError;
result = PyEval_CallObject(func, args);

The func result is expected to be a callable, not a string.

The code for PyList_GetItem does the list check.

--
nosy: +rhettinger
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4463] Parameters and result of PyList_GetItem() are not validated

2008-11-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

Python/import.c lines: 1078-1082:

for (j = 0; j  nhooks; j++) {
PyObject *hook = PyList_GetItem(path_hooks, j);
if (hook == NULL)
return NULL;
importer = PyObject_CallFunctionObjArgs(hook, p, NULL);

The hook object is supposed to be a callable, not a string.  The code
for PyList_GetItem() does its own argument checking.

--
nosy: +rhettinger
resolution:  - invalid
status: open - closed

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4463
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue2053] IDLE - standardize dialogs

2008-11-29 Thread Tal Einat

Tal Einat [EMAIL PROTECTED] added the comment:

Attaching a new patch against a more recent revision (resolved minor
conflict).

Only 3 extremely minor changes from previous patch: fixed two more
places where the parent was being passed explicitly (no longer required)
and changed two tabs - spaces.

I've done some fairly thorough manual testing of this, and have been
using it without any issues for almost six months.

Added file: 
http://bugs.python.org/file12161/IDLE_standardize_dialogs.081129.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue2053
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4461] parameters of PyLong_FromString() are not checked for NULL

2008-11-29 Thread Raymond Hettinger

Raymond Hettinger [EMAIL PROTECTED] added the comment:

This is an internal call, so am not worried about const char *s being
NULL -- that duty belongs to the caller who creates the pointer in the
first place.  That being said, it wouldn't hurt to add an assertion at
the beginning of the function.

--
assignee:  - marketdickinson
components: +Interpreter Core -None
keywords: +patch
nosy: +marketdickinson, rhettinger
priority:  - low
stage:  - patch review
type: resource usage - 
versions: +Python 2.6, Python 2.7, Python 3.0
Added file: http://bugs.python.org/file12162/parsenumber.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4461
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4461] parameters of PyLong_FromString() are not checked for NULL

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

Patch looks fine. (!)
Okay just to apply this to 2.6 and up?  It's not a bugfix.

--
versions:  -Python 2.5.3

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4461
___
___
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

2008-11-29 Thread John Smith

John Smith [EMAIL PROTECTED] added the comment:

Hi, when will this patch be checkedin?

--
versions: +Python 2.5.3, Python 2.6, Python 3.0

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1706039
___
___
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

2008-11-29 Thread Akira Kitada

Akira Kitada [EMAIL PROTECTED] added the comment:

I'm just curious to know which is the right behavior.

# Python 3.0
Traceback (most recent call last):
  File bad_range.py, line 7, in module
print(range(MyInt(2**3), MyInt(2**3+10)))
TypeError: 'MyInt' object cannot be interpreted as an integer

# Python 2.7a0
[8, 9, 10, 11, 12, 13, 14, 15, 16, 17]
here
[18446744073709551616L, 18446744073709551617L, 18446744073709551618L,
18446744073709551619L, 18446744073709551620L, 18446744073709551621L,
18446744073709551622L, 18446744073709551623L, 18446744073709551624L,
18446744073709551625L]
Traceback (most recent call last):
  File bad_range.py, line 11, in module
print(range(MyInt(2**64), MyInt(2**64+10)))
TypeError: range() integer start argument expected, got instance.

--
nosy: +akitada

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1533
___
___
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

2008-11-29 Thread Robert Bradshaw

Robert Bradshaw [EMAIL PROTECTED] added the comment:

I think *both* behaviors are wrong, the 3.0 one is backwards
incompatible, and the 2.7 one is inconsistent (accepting MyInt if it's 
32 bits, rejecting it for  64 bits). 

For our particular use case, it is very annoying to not be able to use
non-ints. It goes against the principle duck typing by simply defining
the __int__ and __index__ methods.

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1533
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Gregory P. Smith

Gregory P. Smith [EMAIL PROTECTED] added the comment:

Martin: socket.socket has no destructor so a call to
socket.socket._real_close() is not guaranteed.  Thats fine as its parent
class from socketmodule.c _socket.socket does the right thing in its
destructor.

Amaury: The case you show doesn't call SOCKETCLOSE() because x still
exists and holds a reference to the socket object.

In order to fix that, SocketIO needs to drop its reference on close. 
Take a look at the attached -gps04 patch.  It fixes that.

Added file: http://bugs.python.org/file12163/issue3826_socket-gps04.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4388] test_cmd_line fails on MacOS X

2008-11-29 Thread Mark Dickinson

Mark Dickinson [EMAIL PROTECTED] added the comment:

So the obvious quick fix is, on OS X only, to set the locale to e.g. 
en_US.UTF-8 instead of  just before the mbstowcs call.

Here's a patch that does this.

I don't like this much, though.  For one thing, I don't have any reason 
to believe that the particular locale en_US.UTF-8 will be supported on 
any given installation of OS X.

Anyone have any better suggestions?

--
keywords: +patch
Added file: http://bugs.python.org/file12164/issue4388.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4388
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4426] UTF7 decoding is far too strict

2008-11-29 Thread Antoine Pitrou

Changes by Antoine Pitrou [EMAIL PROTECTED]:


--
nosy: +pitrou

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4426
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4425] UTF7 encoding of slash (character 47) is incorrect

2008-11-29 Thread Antoine Pitrou

Changes by Antoine Pitrou [EMAIL PROTECTED]:


--
nosy: +pitrou

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4425
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4387] binascii b2a functions accept strings (unicode) as data

2008-11-29 Thread Antoine Pitrou

Antoine Pitrou [EMAIL PROTECTED] added the comment:

It's not /exactly/ nonsense, it seems to assume an utf8 encoding pass is
necessary:

 b'\xe1\x80\x80'.decode('utf8') == '\u1000'
True

IMO, while accepting unicode strings instead of bytes for the a2b_xx
functions is understandable (because in practice only ASCII characters
are allowed), it is not acceptable for b2a_xx functions to accept
unicode strings instead of bytes.

In other words, it might/should be ok for
`binascii.a2b_base64('YWFh\n')` to return the same as
`binascii.a2b_base64('YWFh\n')` (that is, b'aaa'), but
`binascii.b2a_base64('aaa')` should raise a TypeError rather than
applying an utf8 encoding pass before doing the actual b2a encoding.

I think this must be fixed before 3.0 final, and is therefore a release
blocker.

--
nosy: +pitrou
priority:  - release blocker

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4387
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4387] binascii b2a functions accept strings (unicode) as data

2008-11-29 Thread Antoine Pitrou

Antoine Pitrou [EMAIL PROTECTED] added the comment:

Hmm, I obviously meant:

[...] In other words, it might/should be ok for
`binascii.a2b_base64('YWFh\n')` to return the same as
`binascii.a2b_base64(b'YWFh\n')` (that is, b'aaa') [...]

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4387
___
___
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

2008-11-29 Thread Akira Kitada

Akira Kitada [EMAIL PROTECTED] added the comment:

Updating versions.

--
versions: +Python 2.5.3, Python 2.6, Python 2.7, Python 3.0

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue1533
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Gregory P. Smith

Gregory P. Smith [EMAIL PROTECTED] added the comment:

gps05.diff includes the fix and unittests.

Added file: http://bugs.python.org/file12165/issue3826_gps05.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Gregory P. Smith

Changes by Gregory P. Smith [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file12154/issue3826_socket-gps03.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Gregory P. Smith

Changes by Gregory P. Smith [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file12156/test_makefileclose.patch

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Gregory P. Smith

Changes by Gregory P. Smith [EMAIL PROTECTED]:


Removed file: http://bugs.python.org/file12163/issue3826_socket-gps04.diff

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue4388] test_cmd_line fails on MacOS X

2008-11-29 Thread Martin v. Löwis

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

 I don't like this much, though.  For one thing, I don't have any reason 
 to believe that the particular locale en_US.UTF-8 will be supported on 
 any given installation of OS X.

I'm opposed to this patch for the same reason.

 Anyone have any better suggestions?

We should manually decode the command line arguments with UTF-8 on OSX;
this will require yet another UTF-8 implementation (this time to
wchar_t).

Regards,
Martin

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue4388
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3826] BaseHTTPRequestHandler depends on GC to close connections

2008-11-29 Thread Gabriel Genellina

Gabriel Genellina [EMAIL PROTECTED] added the comment:

--- El vie 28-nov-08, Gregory P. Smith [EMAIL PROTECTED] escribió:

 P.S.  Gabriel Genellina (gagenellina)  -  Your comment
 sounded like you
 had a unit test for this but it never got attached.  Still
 have it?

I've found it; it uses BaseHTTPRequestHandler as in the original bug report. 
I'm not sure it is still relevant, but I'm attaching it here anyway.

Added file: http://bugs.python.org/file12166/test_httpclose_py3k.py

___
Python tracker [EMAIL PROTECTED]
http://bugs.python.org/issue3826
___import socket
import http.server
import threading
import unittest
from time import sleep

RESPONSE_TEXT = b'Expected response'
PORT = 8123

class DummyRequestHandler(http.server.BaseHTTPRequestHandler):
def log_message(self, *args):
# no log messages
pass

def do_GET(self):
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.send_header('Content-Length', len(RESPONSE_TEXT))
self.send_header('Connection', 'close')
self.end_headers()
self.wfile.write(RESPONSE_TEXT)

class DummyRequestHandlerWithCycle(DummyRequestHandler):
def do_GET(self):
# this cycle makes the server not to close the connection
self.foo = self
DummyRequestHandler.do_GET(self)

class TestHttpClose(unittest.TestCase):

  def run_server_bg(self, handler_class):
httpd = http.server.HTTPServer(('127.0.0.1', PORT), handler_class)
httpd.handle_request() # only 1 request!

  def _test(self, handler_class):
t = threading.Thread(target=self.run_server_bg, args=(handler_class,))
t.start()
sleep(1)
s = socket.socket()
s.settimeout(5)
s.connect(('127.0.0.1', PORT))
req = b'GET / HTTP/1.0\r\n\r\n'
s.sendall(req)
resp = b''
while True:
  d = s.recv(100)
  if not d: break
  resp += d
self.assert_(RESPONSE_TEXT in resp)
self.assert_(s.recv(1)==b'', Connection should be closed by now)

  def testCloseNoCycle(self):
self._test(handler_class=DummyRequestHandler)

  def testCloseWithCycle(self):
self._test(handler_class=DummyRequestHandlerWithCycle)

if __name__=='__main__':
   unittest.main()

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