[issue1491] BaseHTTPServer incorrectly implements response code 100

2010-09-22 Thread Senthil Kumaran

Changes by Senthil Kumaran orsent...@gmail.com:


--
assignee:  - orsenthil

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



[issue1595365] Urllib2 user-agent header added by an opener is frozen

2010-09-22 Thread Senthil Kumaran

Senthil Kumaran orsent...@gmail.com added the comment:

This is still a valid bug.

--
assignee:  - orsenthil
resolution:  - accepted
stage: unit test needed - needs patch

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



[issue8998] add crypto routines to stdlib

2010-09-22 Thread Marc-Andre Lemburg

Marc-Andre Lemburg m...@egenix.com added the comment:

geremy condra wrote:
 
 geremy condra debat...@gmail.com added the comment:
 
 The pyOpenSSL port to Python3 is closing in on completion. Jean-Paul
 is planning for an alpha release next month.

 Do you know if he's looking for help with that? There's been some talk of
 a porting sprint here and I'd be happy to put that at the top of the list.

 I don't know. You might want to contact him directly.
 
 Sent.
 
 By the way, if you've used the keyphrene API and wouldn't mind sharing
 how it compares with the proposed crypto API I'd appreciate it, I
 don't think it came up in any of the initial conversations about this.

No, I haven't used the APIs. I do have some experience with mxCrypto,
though, which is a low-level wrapper for the ciphers and hashes in
OpenSSL:

http://www.egenix.com/www2002/python/mxCrypto.html

--

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



[issue9918] Installation make test, two fails if non-ascii path

2010-09-22 Thread ingemar

New submission from ingemar inge...@sijohansson.com:

I am using Kubuntu 10.4 on a no-brand box with a 64-bit CPU.
I use my own download and install of Python 3.1, SIP and PyQt.

The default download directory as set up by the Kubuntu install is 
/home/ingemar/Hämtningar,
where Hämtningar is Swedish and corresponds to Download. 
This is where the download of Python-3.1.2.tar.bz2 gets stored by default.
And this is where I let Krusader store the Python-3.1.2 folder that it pulls 
out of the bz2.
So I step into that folder and run ./configure,  make,  make test,  -- whoops, 
two tests fail:
-

test_cmd
test_cmd_line
Warning: os.environ was modified by test_cmd_line
test test_cmd_line failed -- Traceback (most recent call last):
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/test/test_cmd_line.py, line 
181, in test_large_PYTHONPATH
self.assertTrue(path1.encode('ascii') in stdout)
AssertionError: False is not True

test_cmd_line_script
test_code




test_xdrlib
test_xml_etree
test_xml_etree_c
test_xmlrpc
Traceback (most recent call last):
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/xmlrpc/server.py, line 448, 
in do_POST
size_remaining = int(self.headers[content-length])
ValueError: invalid literal for int() with base 10: 'I am broken'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/socketserver.py, line 281, 
in _handle_request_noblock
self.process_request(request, client_address)
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/socketserver.py, line 307, 
in process_request
self.finish_request(request, client_address)
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/socketserver.py, line 320, 
in finish_request
self.RequestHandlerClass(request, client_address, self)
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/socketserver.py, line 614, 
in __init__
self.handle()
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/http/server.py, line 352, in 
handle
self.handle_one_request()
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/http/server.py, line 346, in 
handle_one_request
method()
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/xmlrpc/server.py, line 472, 
in do_POST
self.send_header(X-traceback, traceback.format_exc())
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/http/server.py, line 410, in 
send_header
self.wfile.write((%s: %s\r\n % (keyword, value)).encode('ASCII', 
'strict'))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe4' in position 71: 
ordinal not in range(128)
test test_xmlrpc failed -- Traceback (most recent call last):
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/test/test_xmlrpc.py, line 
555, in test_fail_with_info
p.pow(6,8)
xmlrpc.client.ProtocolError: ProtocolError for 127.0.0.1:46081/RPC2: 500 
Internal Server Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File /home/ingemar/Hämtningar/Python-3.1.2/Lib/test/test_xmlrpc.py, line 
562, in test_fail_with_info
self.assertTrue(e.headers.get(X-traceback) is not None)
AssertionError: False is not True

test_xmlrpc_net
test_xmlrpc_net skipped -- Use of the `network' resource not enabled
test_zipfile
test_zipfile64
test_zipfile64 skipped -- test requires loads of disk-space bytes and a long 
time to run
test_zipimport
test_zipimport_support
test_zlib
312 tests OK.
2 tests failed:
test_cmd_line test_xmlrpc
22 tests skipped:
test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp
test_codecmaps_kr test_codecmaps_tw test_curses test_kqueue
test_nis test_ossaudiodev test_pep277 test_smtpnet
test_socketserver test_startfile test_timeout test_tk
test_ttk_guionly test_urllib2net test_urllibnet test_winreg
test_winsound test_xmlrpc_net test_zipfile64
Those skips are all expected on linux2.
make: *** [test] Fel 1
...
-







Those two test don't like the Swedish dotted character ä in the folder name.
I renamed the folder into pure ASCII and restarted: 
./configure,  make,  make test,  sudo make install.
Everything worked as expected:
.
314 tests OK.
22 tests skipped:
.

--
components: None
messages: 117128
nosy: ingemar
priority: normal
severity: normal
status: open
title: Installation make test, two fails if non-ascii path
versions: Python 3.1

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



[issue678250] test_mmap failling on AIX

2010-09-22 Thread Sébastien Sablé

Sébastien Sablé sa...@users.sourceforge.net added the comment:

After Antoine commit concerning issue2643, here is a new patch (just removing 
the changes in close).

Could you commit it?

--
Added file: http://bugs.python.org/file18963/patch_mmap_flush_updated.diff

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



[issue678264] test_resource fails when file size is limited

2010-09-22 Thread Sébastien Sablé

Sébastien Sablé sa...@users.sourceforge.net added the comment:

The ideal would be to check that RLIMIT_FSIZE corresponds to the ulimit as it 
has been suggested by Neal Norwitz in msg14345, but since the value reported by 
ulimit has a different unit for each platform, that would be quite a lot of 
trouble.

All I can suggest is the following, which checks that both values are somewhat 
reasonable.

Index: Lib/test/test_resource.py
===
--- Lib/test/test_resource.py   (révision 84964)
+++ Lib/test/test_resource.py   (copie de travail)
@@ -20,12 +20,17 @@
 except AttributeError:
 pass
 else:
-# RLIMIT_FSIZE should be RLIM_INFINITY, which will be a really big
-# number on a platform with large file support.  On these 
platforms,
-# we need to test that the get/setrlimit functions properly convert
-# the number to a C long long and that the conversion doesn't raise
-# an error.
-self.assertEqual(resource.RLIM_INFINITY, max)
+# RLIMIT_FSIZE should be RLIM_INFINITY if 'ulimit -f' is
+# set to unlimited
+# RLIM_INFINITY will be a really big number on a platform
+# with large file support.  On these platforms, we need to
+# test that the get/setrlimit functions properly convert
+# the number to a C long long and that the conversion
+# doesn't raise an error.
+self.assertGreater(resource.RLIM_INFINITY, 0)
+self.assertLessEqual(cur, max)
+self.assertGreater(max, 0)
+self.assertLessEqual(max, resource.RLIM_INFINITY)
 resource.setrlimit(resource.RLIMIT_FSIZE, (cur, max))
 
 def test_fsize_enforced(self):

--

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



[issue1675951] Performance for small reads and fix seek problem

2010-09-22 Thread Florian Festi

Florian Festi florianfe...@users.sourceforge.net added the comment:

Stupid me! I ran the tests against my systems gzip version (Py 3.1). The 
performance issue is basically fixed by rev 77289. Performance is even a bit 
better that my original patch by may be 10-20%. The only test case where it 
performs worse is 

Random 10485760 byte block test
Original gzip Write:   20.452 s Read:2.931 s
New gzip  Write:   20.518 s Read:1.247 s

Don't know if it is worth bothering. May be increasing the maximum chunk size 
improves this - but I didn't try that out yet.

WRT to seeking:

I now have two patches that eliminate the need for seek() on normal operation 
(rewind obviously still needs seek()). Both are based on the PaddedFile class. 
The first patch just creates a PaddedFile object while switching from an old to 
a new member while the second just wraps the fileobj all the time. Performance 
test show that wrapping is cheap. The first patch is a bit ugly while the 
second requires a implementation of seek() and may create problems if new 
methods of the fileobj are used that may interfere with the PaddedFile's 
internals.

So I leave the choice which one is preferred to the module owner.

The patch creates another problem with is not yet fixed: The implementation of 
.seekable() is becoming wrong. As one can now use non seekable files the 
implementation should check if the file object used for reading is really 
seekable. As this is my first PY3k work I'd prefer if this can be solved by 
someone else (But that should be pretty easy).

--
Added file: 
http://bugs.python.org/file18964/0001-Avoid-the-need-of-seek-ing-on-the-file-read.patch

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



[issue1675951] Performance for small reads and fix seek problem

2010-09-22 Thread Florian Festi

Changes by Florian Festi florianfe...@users.sourceforge.net:


Added file: 
http://bugs.python.org/file18965/0002-Avoid-the-need-of-seek-ing-on-the-file-read-2.patch

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



[issue730467] Not detecting AIX_GENUINE_CPLUSPLUS

2010-09-22 Thread Sébastien Sablé

Sébastien Sablé sa...@users.sourceforge.net added the comment:

I can confirm this is still a problem in py3k for AIX 5.3 and AIX 6.1.
The file /usr/lpp/xlC/include/load.h does not exist anymore; it is now 
/usr/include/load.h.

The proposed patch would only create a problem for very old versions of AIX and 
xlc (which are no longer supported by IBM anyway and I doubt anybody is going 
to compile Python 3.x on them some day), while the current state is that it is 
broken for current versions (current being released in the last 7 years!).

--

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



[issue9919] gdbinit lineno result is one line in excess

2010-09-22 Thread qpatata

New submission from qpatata qpat...@gmail.com:

Thanks a lot to all python teams for your excel.lent work.

When latest version of gdbinit macros is used to debug with gdb a python 2.4 
session, the result from lineno macro seems one line more than the correct one.

If we compare the gdb macro:

define lineno
set $__continue = 1
set $__co = f-f_code
set $__lasti = f-f_lasti
set $__sz = ((PyStringObject *)$__co-co_lnotab)-ob_size/2
set $__p = (unsigned char *)((PyStringObject *)$__co-co_lnotab)-ob_sval
set $__li = $__co-co_firstlineno
set $__ad = 0
while ($__sz-1 = 0  $__continue)
  set $__sz = $__sz - 1
  set $__ad = $__ad + *$__p
  set $__p = $__p + 1
  if ($__ad  $__lasti)
set $__continue = 0
  end
  set $__li = $__li + *$__p
  set $__p = $__p + 1
end
printf %d, $__li
end

with the related C source code in libpython.py

def addr2line(self, addrq):
'''
Get the line number for a given bytecode offset

Analogous to PyCode_Addr2Line; translated from pseudocode in
Objects/lnotab_notes.txt
'''
co_lnotab = self.pyop_field('co_lnotab').proxyval(set())

# Initialize lineno to co_firstlineno as per PyCode_Addr2Line
# not 0, as lnotab_notes.txt has it:
lineno = int_from_int(self.field('co_firstlineno'))

addr = 0
for addr_incr, line_incr in zip(co_lnotab[::2], co_lnotab[1::2]):
addr += ord(addr_incr)
if addr  addrq:
return lineno
lineno += ord(line_incr)
return lineno

we see that if addr  is greater than addrq, the python codes returns 
immedialty, but the gdb macro adds a new delta of lines before exit the loop.

Kind regards.

--
messages: 117133
nosy: qpatata
priority: normal
severity: normal
status: open
title: gdbinit lineno result is one line in excess
type: behavior
versions: Python 2.5

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



[issue730467] Not detecting AIX_GENUINE_CPLUSPLUS

2010-09-22 Thread Sébastien Sablé

Sébastien Sablé sa...@users.sourceforge.net added the comment:

It should also be changed in Python/dynload_aix.c:

Index: Python/dynload_aix.c
===
--- Python/dynload_aix.c(révision 84964)
+++ Python/dynload_aix.c(copie de travail)
@@ -12,7 +12,7 @@
 
 
 #ifdef AIX_GENUINE_CPLUSPLUS
-#include /usr/lpp/xlC/include/load.h
+#include load.h
 #define aix_load loadAndInit
 #else
 #define aix_load load

--

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



[issue9918] Installation make test, two fails if non-ascii path

2010-09-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I'm amazed you only got two failures.  Victor has been doing a lot of work in 
3.2 trying to make non-ascii paths work reliably.

--
nosy: +haypo, r.david.murray

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



[issue9918] Installation make test, two fails if non-ascii path

2010-09-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

oh, wait, victor's work is for undecodable non-ascii characters.  I think flox 
did the work on decodable non-ascii characters, and that may well have gone 
into 3.1.

--
nosy: +flox

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



[issue9918] Installation make test, two fails if non-ascii path

2010-09-22 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

See issue7606 and issue7605: both fixed in SVN. All is needed is a new 3.1.x 
release :)

--
nosy: +pitrou
resolution:  - out of date
status: open - closed
versions: +Python 3.2

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



[issue9917] resource max value represented as signed when should be unsigned

2010-09-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

And here is Martin's summary of the issue:

I think we really should create new issues for any remaining problems.

AFAICT, the remaining problems are:
- resource.RLIM_INFINITY is -1 on Linux, when it is meant to be
   a really large value
- (as you reported) getrlimit returns -1 to indicate RLIM_INFINITY.

I think the core of the problem is that the resource module considers
rlim_t to be a signed type (or at least representable in long long).
Using FromUnsignedLongLong in the appropriate place might solve the
issue.

--

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



[issue1692335] Fix exception pickling: Move initial args assignment to BaseException.__new__

2010-09-22 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

In msg108954, I believe belopolsky is mistaken in stating that it would be 
easy to simply provide custom __getinitargs__ or __reduce__ to support it. It 
appears __getinitargs__ does not work on Python 2.5 or Python 2.7. Exceptions 
of the following class still raise a TypeError on unpickling:

class D(Exception):
Extension with values, init called with no args.
def __init__(self, foo):
self.foo = foo
Exception.__init__(self)

def __getinitargs__(self):
return self.foo,

Using __reduce__ does seem to work. I suspect this is because Exceptions are 
extension types.

I think the fundamental problem is that pickling exceptions does not follow the 
principle of least surprise. In particular:

 - Other built-in objects (dicts, lists, etc) don't require special handling 
(replace Exception with dict in the above example and it works).
 - It's not obvious how to write an Exception subclass that takes additional 
arguments and make it pickleable.
 - Neither the pickle documentation nor the Exception documentation describe 
how pickling is implemented in Exceptions.

Eric has provided some good use cases. Furthermore, it seems counter-intuitive 
to me to pass a subclass' custom arguments to the parent class. Indeed, even 
the official tutorial defines exception classes that are unpickleable 
(http://docs.python.org/tutorial/errors.html#tut-userexceptions).

If the use case is obvious enough that it shows up in the hello world tutorial, 
I don't think there should be any argument that it's not a common use case.

At the very least, there should be a section in the pickle documentation or 
Exception documentation describing how one should make a pickleable subclass. 
What would be better is for Exceptions to behave like most other classes when 
being pickled.

--
nosy: +jaraco

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



[issue7296] OverflowError: signed integer is greater than maximum on mips64

2010-09-22 Thread jasper

jasper jas...@humppa.nl added the comment:

FYI, the issue has been fixed now in the mips64 port of OpenBSD by replacing 
the previous/old floating point completion code with a C interface to the MI 
softfloat code, implementing all MIPS IV specified floating point
operations.

--

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



[issue9920] test_cmath on atan fails on AIX

2010-09-22 Thread Sébastien Sablé

New submission from Sébastien Sablé sa...@users.sourceforge.net:

test_cmath will fail with the following error on AIX:

==
FAIL: test_specific_values (test.test_cmath.CMathTests)
--
Traceback (most recent call last):
  File 
/san_cis/home/cis/buildbot/buildbot-aix6/py3k-aix6-xlc/build/Lib/test/test_cmath.py,
 line 350, in test_specific_values
msg=error_message)
  File 
/san_cis/home/cis/buildbot/buildbot-aix6/py3k-aix6-xlc/build/Lib/test/test_cmath.py,
 line 94, in rAssertAlmostEqual
'got {!r}'.format(a, b))
AssertionError: atan: atan(complex(0.0, 0.0))
Expected: complex(0.0, 0.0)
Received: complex(0.0, -0.0)
Received value insufficiently close to expected value.


There is a test concerning tanh in configure, which may be related:
checking whether tanh preserves the sign of zero... yes

--
components: Library (Lib)
messages: 117141
nosy: sable
priority: normal
severity: normal
status: open
title: test_cmath on atan fails on AIX
type: behavior
versions: Python 2.7, Python 3.2

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



[issue9920] test_cmath on atan fails on AIX

2010-09-22 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks for the report.  This looks like it's probably a bug (not a particularly 
serious one, but worth reporting) on AIX.

The 'tanh' configure test diagnoses a similar wrong-sign-of-zero problem on 
FreeBSD;  it looks as though AIX is happy here---that is, 'yes' is the expected 
and desired result for that configure test.

--
assignee:  - mark.dickinson
nosy: +mark.dickinson

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



[issue9920] test_cmath on atan fails on AIX

2010-09-22 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

P.S.  Was the test with a debug build of Python?  If not, could you see if the 
test failure still occurs with a debug build (i.e., when --with-pydebug is 
passed as a configure argument)?  That would help eliminate compiler 
optimization bugs as a possible cause.

--

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



[issue9920] test_cmath on atan fails on AIX

2010-09-22 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Sorry---one more question:  could you tell me what the following gives on the 
AIX machine?

Python 2.7 (r27:82500, Aug 15 2010, 14:21:15) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type help, copyright, credits or license for more information.
 from cmath import tanh
 tanh(complex(-0.0, 0.0))
(-0+0j)


Thanks.

--

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



[issue1692335] Fix exception pickling: Move initial args assignment to BaseException.__new__

2010-09-22 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

After some further reading, I found that PEP-352 
(http://www.python.org/dev/peps/pep-0352/) explicitly states that Including 
programmatic information (e.g., an error code number) should be stored as a 
separate attribute in a subclass [and not in the args attribute]. The 
parameter to Exception.__init__ should always be a single, human-readable 
string. The default pickler doesn't handle this officially-prescribed use-case 
without overriding __reduce__.

class F(Exception):
def __init__(self, message, code):
Exception.__init__(self, message)
self.code = code

Of course, as belopolsky observed, __repr__ must also be overridden.

--

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



[issue9921] os.path.join('x','') behavior

2010-09-22 Thread Radu Grigore

New submission from Radu Grigore radugrig...@gmail.com:

The docs say that the return value is the concatenation of path1, and 
optionally path2, etc., with exactly one directory separator (os.sep) inserted 
between components, unless path2 is empty.

But os.path.join('x','') returns 'x/' in which path1 and path2 *are* separated 
by exactly one os.sep, even though path2 is empty.

Either the docs or the implementation should be updated.

--
components: Library (Lib)
messages: 117146
nosy: rgrig
priority: normal
severity: normal
status: open
title: os.path.join('x','') behavior
versions: Python 2.7, Python 3.1

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



[issue9915] speeding up sorting with a key

2010-09-22 Thread Daniel Stutzbach

Daniel Stutzbach dan...@stutzbachenterprises.com added the comment:

Attached is my script for running a more comprehensive battery of speed tests.  
The script itself requires Python 2.6 with argparse installed or Python 2.7 
(which includes argparse).

For obvious reasons, please make sure that your unpatched and patched versions 
of python are otherwise identical (same source, same compiler, same configure 
and compiler settings, etc.).

The script will create subdirectories to store data, so please run it in the 
speed_test directory.

Example usage:

otto:~/speed_test$ ./speed_test.py ../py3k-unpatched/ ../py3k-patched/ 'sort 
random'


otto:~/speed_test$ ./speed_test.py --help
usage: speed_test.py [-h] [--minn MINN] [--maxn MAXN]
 [-r, --repetitions REPETITIONS] [--graphs]
 control experiment [tests [tests ...]]

Compare the speed of two list implementations

positional arguments:
  control   control/python
  experimentexperiment/python
  tests Names of tests to conduct

optional arguments:
  -h, --helpshow this help message and exit
  --minn MINN   Minimum list size
  --maxn MAXN   Maximum list size
  -r, --repetitions REPETITIONS
Repetitions; how many times to repeat each experiment
  --graphs  Generate performance graphs as a function of n;
requires gnuplot

Available experiments:
sort random tuples
sort random key
sort reversed
sort random objects
sort sorted
sort sorted key
sort random
sort sorted objects
sort reversed key

--
Added file: http://bugs.python.org/file18966/speed_test.zip

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



[issue9919] gdbinit lineno result is one line in excess

2010-09-22 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Can you show an example which shows an incorrect lineno?

--
nosy: +amaury.forgeotdarc

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



[issue1692335] Fix exception pickling: Move initial args assignment to BaseException.__new__

2010-09-22 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

On Wed, Sep 22, 2010 at 9:39 AM, Jason R. Coombs rep...@bugs.python.org wrote:
 .. It appears __getinitargs__ does not work on Python 2.5 or Python 2.7.

Yes,  __getinitargs__  is only used for old style classes.  I was
wrong on that point.

 Exceptions of the following class still raise a TypeError on unpickling:

 class D(Exception):
    Extension with values, init called with no args.
    def __init__(self, foo):
        self.foo = foo
        Exception.__init__(self)

    def __getinitargs__(self):
        return self.foo,


The problem with your D class is that it does not provide correct args
attribute which is expected from an exception class:

()

 Using __reduce__ does seem to work. I suspect this is because Exceptions are 
 extension types.


There are two ways to fix this class.  Both fix the args issue as well:

1. Pass foo to Exception.__init__  like this: Exception.__init__(self,
foo) in D.__init__.

2. Explicitly initialize self.args: self.args   = foo,

 I think the fundamental problem is that pickling exceptions does not follow 
 the principle of least surprise. In particular:

  - Other built-in objects (dicts, lists, etc) don't require special handling 
 (replace Exception with dict in the above example and it works).

Other built-in objects don't provide an API for retrieving their init arguments.

  - It's not obvious how to write an Exception subclass that takes additional 
 arguments and make it pickleable.

AFAICT, this is python subclassing 101: if base class __init__ uses
arguments, they should be passed to it by subclass' __init__.

  - Neither the pickle documentation nor the Exception documentation describe 
 how pickling is implemented in Exceptions.


Exception documentation may be improved by adding a section on
subclassing.  Note that the args argument was not even mentioned in
2.7 documentation, so some discussion of its role may be helpful
somewhere.

 Eric has provided some good use cases. Furthermore, it seems 
 counter-intuitive to me to pass a subclass' custom
 arguments to the parent class. Indeed, even the official tutorial defines 
 exception classes that are unpickleable
 (http://docs.python.org/tutorial/errors.html#tut-userexceptions).


Well, the tutorial examples should probably be changed.  In these
examples base class __init__ is not called at all which is probably
not a good style.

 If the use case is obvious enough that it shows up in the hello world 
 tutorial, I don't think
 there should be any argument that it's not a common use case.


I am not arguing against simplifying Exception subclassing.  I just
don't see an easy solution that would not promote subclasses with
unusable args attribute.  I also disagree with this issue classified
as a bug.  It may be a valid feature request, but not a bug.

In any case, no proponent of this feature has come up with a patch for
3.2 so far and in my view, this would be a prerequisite for moving
this forward.

 At the very least, there should be a section in the pickle documentation or 
 Exception
 documentation describing how one should make a pickleable subclass. ..

I agree, but again someone has to step in to write such section.
Improving documentation may also be the only solution for the 2.x
series.

--

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



[issue9801] Can not use append/extend to lists in a multiprocessing manager dict

2010-09-22 Thread Ask Solem

Ask Solem a...@opera.com added the comment:

Maybe surprising but not so weird if you think about what happens
behind the scenes.

When you do

 x = man.list()
 x.append({})

You send an empty dict to the manager to be appended to x

when do:

x[0]
   {}

you receive a local copy of the empty dict from the manager process.


So this:

 x[0][a] = 5

will only modify the local copy.

What you would have to do is:

 x.append({})
 t = x[0]
 t[a] = 5
 x[0] = t

This will not be atomic of course, so this may be something
to take into account.

What maybe could be supported is something like:
 x[0] = manager.dict()
x[0][foo] = bar

but otherwise I wouldn't consider this a bug.

--
nosy: +asksol

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



[issue7707] multiprocess.Queue operations during import can lead to deadlocks

2010-09-22 Thread Ask Solem

Ask Solem a...@opera.com added the comment:

I created a small doc patch for this (attached).

--
keywords: +needs review, patch
nosy: +asksol
versions: +Python 3.1 -Python 2.6
Added file: http://bugs.python.org/file18967/multiprocessing-issue7707.patch

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



[issue9919] gdbinit lineno result is one line in excess

2010-09-22 Thread qpatata

qpatata qpat...@gmail.com added the comment:

Hello,

Thanks for your colaboration.

Starting by the following python file, called prueba.py:

 cat prueba.py
import time

def bar():
time.sleep(10);
print hello;

def foo():
  while True:
bar();

foo();




Open a gdb session with python2-6 as target:

 gdb /usr/bin/python2.6

and run the python program. 

gdb run prueba.py

After a few seconds, type Ctrl-C to break the program. Usually, break will 
interrupt it when execution is in the sleep statement. A bt gives:

#0  0xb7fe2424 in __kernel_vsyscall ()
#1  0xb7d42fdd in select () from /lib/i686/cmov/libc.so.6
#2  0x08119a3f in floatsleep (self=0x0, args=(10,)) at 
../Modules/timemodule.c:918
#3  time_sleep (self=0x0, args=(10,)) at ../Modules/timemodule.c:206
#4  0x080e0721 in call_function (f=Frame 0x82e17ac, for file prueba.py, line 4, 
in bar (), 
throwflag=0) at ../Python/ceval.c:3750
#5  PyEval_EvalFrameEx (f=Frame 0x82e17ac, for file prueba.py, line 4, in bar 
(), throwflag=0)
at ../Python/ceval.c:2412
...

If we go until C frame #5 (up, up, ...) and execute the lineno macro:

#5  PyEval_EvalFrameEx (f=Frame 0x82e17ac, for file prueba.py, line 4, in bar 
(), throwflag=0)
at ../Python/ceval.c:2412
2412in ../Python/ceval.c

(gdb) lineno
5
(gdb) 

It is clear the mismatch between the line reported by lineno (5), the one in 
the source file (4) and the one displayed by gdb (4).

In addition, if we look at the version history of the gdbinit file, we can 
see how version 39276 has an implementation of lineno who matches the related C 
code in Python project, but next version (39492) introduces a boolean to 
control the end of loop. This change is, probably, the origen of the mismatch.

Thanks a lot.

--

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



[issue9921] os.path.join('x','') behavior

2010-09-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Since changing the implementation would be a backward incompatible behavior 
change to a behavior that has existed for a long time, it's the docs that 
should be updated.

--
assignee:  - d...@python
components: +Documentation -Library (Lib)
nosy: +d...@python, r.david.murray
stage:  - needs patch
versions: +Python 3.2

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



[issue9916] errno module is missing some symbols

2010-09-22 Thread Barry A. Warsaw

Barry A. Warsaw ba...@python.org added the comment:

r84966

--
resolution:  - fixed
status: open - closed

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



[issue1462440] socket and threading: udp multicast setsockopt fails

2010-09-22 Thread Charles-Francois Natali

Charles-Francois Natali neolo...@free.fr added the comment:

I tested it on a Windows XP box, and encountered the same problem.
The error is raised because Windows XP requires the socket to be bound before 
calling setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq).
So calling bind() before setsockopt() solves this error.
But then you also need to specify for the sender the interface to use using 
setsockopt(IPPROTO_IP, IP_MULTICAST_IF, address)

Here's a working example:

 sender 
from socket import *

s = socket(AF_INET, SOCK_DGRAM)
s.setsockopt(IPPROTO_IP, IP_MULTICAST_IF, inet_aton('127.0.0.1'))
s.sendto(b'foo', ('224.0.0.1', 4242))


--- receiver ---
from socket import *

s = socket(AF_INET, SOCK_DGRAM)
s.bind(('127.0.0.1', 4242))
mreq = inet_aton('224.0.0.1') + inet_aton('127.0.0.1')
s.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, mreq)
s.recv(100)


So it's not a Python bug.
Since multicast is tricky, it might be a good idea to add a short example 
somewhere in the documentation though.

--
nosy: +neologix

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



[issue9922] subprocess.getstatusoutput and bytes

2010-09-22 Thread geremy condra

New submission from geremy condra debat...@gmail.com:

It looks like subprocess.getstatusoutput on 3.2a1 tries to coerce to UTF-8, 
which fails when dealing with bytes. This demonstrates the behavior nearly all 
the time for me on Ubuntu 10.04:

 import subprocess
 subprocess.getstatusoutput('dd if=/dev/random bs=1K count=1')

Here's the tracebacks from a few runs:

 subprocess.getstatusoutput('dd if=/dev/random bs=1K count=1')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.2/subprocess.py, line 585, in getstatusoutput
text = pipe.read()
  File /usr/local/lib/python3.2/codecs.py, line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xcb in position 3: invalid 
continuation byte
 subprocess.getstatusoutput('dd if=/dev/random bs=1K count=1')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.2/subprocess.py, line 585, in getstatusoutput
text = pipe.read()
  File /usr/local/lib/python3.2/codecs.py, line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe4 in position 2: invalid 
continuation byte
 subprocess.getstatusoutput('dd if=/dev/random bs=1K count=1')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.2/subprocess.py, line 585, in getstatusoutput
text = pipe.read()
  File /usr/local/lib/python3.2/codecs.py, line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xac in position 0: invalid 
start byte
 subprocess.getstatusoutput('dd if=/dev/random bs=1K count=1')
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.2/subprocess.py, line 585, in getstatusoutput
text = pipe.read()
  File /usr/local/lib/python3.2/codecs.py, line 300, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xf1 in position 0: invalid 
continuation byte
 

And here's the version info:

Python 3.2a1 (r32a1:83318, Aug 13 2010, 22:32:03) 
[GCC 4.4.3] on linux2
Type help, copyright, credits or license for more information.

--
components: Library (Lib)
messages: 117156
nosy: debatem1
priority: normal
severity: normal
status: open
title: subprocess.getstatusoutput and bytes
type: behavior
versions: Python 3.2

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



[issue9621] Graphviz output for 2to3 fixer patterns

2010-09-22 Thread Matt Bond

Matt Bond gmattb...@gmail.com added the comment:

As requested, attached is the output for the fix_buffer fixer, as an example of 
the kind of output this patch can produce.

--
Added file: http://bugs.python.org/file18968/fix_buf_pytree_1.png

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



[issue9919] gdbinit lineno result is one line in excess

2010-09-22 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

OK, I reproduce the issue. It is now clear to me as well that r39492 was 
slightly wrong: the replacement of break should avoid to execute the end of 
the loop.

The following patch fixes the issue for me, can someone with better gdb 
knowledge check it?

Index: Misc/gdbinit
===
--- Misc/gdbinit(revision 84966)
+++ Misc/gdbinit(working copy)
@@ -59,9 +59,10 @@
   set $__p = $__p + 1
   if ($__ad  $__lasti)
set $__continue = 0
+  else
+set $__li = $__li + *$__p
+set $__p = $__p + 1
   end
-  set $__li = $__li + *$__p
-  set $__p = $__p + 1
 end
 printf %d, $__li
 end

--
stage:  - patch review

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



[issue1257] atexit errors should result in nonzero exit code

2010-09-22 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

exit code = 128 + # of failed atexits

I don't agree with the feature. Do we need something so complex?

--
nosy: +amaury.forgeotdarc

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



[issue9621] Graphviz output for 2to3 fixer patterns

2010-09-22 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 When I was working with 2to3 this summer I was running it via python3,
 so I think the patch should work
Code in the patch uses print as a keyword (2.x), not a function (3.x).  How 
does that work?

 however, if I've submitted it to the wrong place or the wrong branch,
 where should I be looking at to ensure my code does work on 3.2 and
 is submitted to the right place?
This tracker is the right place for bugs relevant to any CPython version.  To 
ensure your code works on 3.2, just apply the diff on a 3.2 checkout.  More 
info on http://www.python.org/dev/ (especially 
http://www.python.org/dev/patches/).

 In regard to the import gvgraph, I wasn't sure what to do with it
If the implicit relative import doesn’t work, as I suspect, 
sys.path.append(os.path.dirname(__file__)) should be enough.

(Cheers from a fellow GSoCer, by the way :)

--

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



[issue9552] ssl build under Windows always rebuilds OpenSSL

2010-09-22 Thread Hirokazu Yamamoto

Changes by Hirokazu Yamamoto ocean-c...@m2.ccsnet.ne.jp:


--
resolution:  - fixed
status: open - closed
versions:  -Python 2.7, Python 3.1

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



[issue1491804] Simple slice support for list.sort() and .reverse()

2010-09-22 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

In fact, I find the proposed syntax *less* obvious than the slice syntax, for 
sorted.  IOW, I'd be -1 on adding these to sorted.  The potentially useful case 
is between

l[a:b] = sorted(l[a:b})

vs

l.sort(start=a, stop=b)

where the interesting bit is that the sort takes place in place (no memory 
copy).

I still find the slice syntax clearer :), and it's not clear that the savings 
of the memory copy for a few programs that use it is worth the added complexity 
for all other programs.  So I concur with Raymond's rejection.

--
nosy: +r.david.murray

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



[issue9923] mailcap module may will not work on non-POSIX platforms if MAILCAPS env variable is set

2010-09-22 Thread Gregory Nofi

New submission from Gregory Nofi crackityjones200...@yahoo.com:

mailcap.getcaps() has a call to mailcap.listmailcapfiles(), which returns a 
list of all mailcap files found on the system.

listmailcapfiles() first looks for the MAILCAPS environment variable. If it 
exists, it converts the string value into a list by splitting it on :. This 
will not work on platforms that use other path separators, like Windows (;).

Attached are patches that use os.pathsep instead.

For more information about the MAILCAPS variable, see Appendix A in RFC 1524 
(http://tools.ietf.org/html/rfc1524.html).

--
assignee: ronaldoussoren
components: Library (Lib), Macintosh, Windows
files: mailcap_trunk.py
messages: 117163
nosy: gnofi, ronaldoussoren
priority: normal
severity: normal
status: open
title: mailcap module may will not work on non-POSIX platforms if MAILCAPS env 
variable is set
type: behavior
versions: Python 2.7, Python 3.1
Added file: http://bugs.python.org/file18969/mailcap_trunk.py

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



[issue9923] mailcap module may will not work on non-POSIX platforms if MAILCAPS env variable is set

2010-09-22 Thread Gregory Nofi

Changes by Gregory Nofi crackityjones200...@yahoo.com:


Added file: http://bugs.python.org/file18970/mailcap_py3k.py

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



[issue9923] mailcap module may not work on non-POSIX platforms if MAILCAPS env variable is set

2010-09-22 Thread Gregory Nofi

Gregory Nofi crackityjones200...@yahoo.com added the comment:

Fixing typo in title

--
title: mailcap module may will not work on non-POSIX platforms if MAILCAPS env 
variable is set - mailcap module may not work on non-POSIX platforms if 
MAILCAPS env variable is set

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



[issue9864] email.utils.{parsedate, parsedate_tz} should have better return types

2010-09-22 Thread Jeffrey Finkelstein

Jeffrey Finkelstein jeffrey.finkelst...@gmail.com added the comment:

Where does email6 live?

--

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



[issue9801] Can not use append/extend to lists in a multiprocessing manager dict

2010-09-22 Thread Alex

Alex alex.gay...@gmail.com added the comment:

It should be documented though.  Similar scenario in the Django docs: 
http://docs.djangoproject.com/en/1.2/topics/http/sessions/#when-sessions-are-saved

--
nosy: +alex

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



[issue9924] sqlite3 SELECT does not BEGIN a transaction, but should according to spec

2010-09-22 Thread mike bayer

New submission from mike bayer mike...@zzzcomputing.com:

Copying this bug from the pysqlite tracker, at 
http://code.google.com/p/pysqlite/issues/detail?id=21 , as the issue has been 
opened for two days with no reply. (side node - should sqlite3 bugs be reported 
here or on the pysqlite tracker ?)  The text below was originally written by 
Randall Nortman:

Pysqlite does not open a transaction in the database until a DML statement is 
encountered (INSERT, UPDATE, or DELETE).  A DQL (SELECT) statement will not 
cause a transaction to be opened if one is not already opened.  This is the 
documented behavior, but it is not what is intended by the spec (PEP 249).  The 
spec intends a transaction to always be open (per the spec author), and this is 
what happens in other DB-API drivers.  For more information, see the this 
DB-SIG mailing list post (by the PEP 249 author):

http://mail.python.org/pipermail/db-sig/2010-September/005645.html

For additional background, see this thread on the SQLAlchemy mailing list, 
which is the source of the attached test case:

http://groups.google.com/group/sqlalchemy/browse_thread/thread/2f47e28c1fcdf9e6/0ef1666759ce0724#0ef1666759ce0724

What steps will reproduce the problem?
1. See attached test case.  Run it as is, and the final conn1.commit() 
statement will complete successfully.
2. Uncomment the c2.execute(BEGIN) line and run again; this time 
conn1.commit() hangs until a timeout, then a Database is locked error is 
returned.

What is the expected output? What do you see instead?

The BEGIN should be issued implicitly, and even without doing it explicitly, 
the commit should block and then return the DB locked error.

What version of the product are you using? On what operating system?

Python 2.6.6 with its built-in sqlite3 module, on Debian Squeeze x86.

import sqlite3
import os

if os.path.exists(file.db):
os.unlink(file.db)

conn1 = sqlite3.connect(file.db)

c1 = conn1.cursor()

c1.execute(PRAGMA read_uncommitted=SERIALIZABLE)

c1.execute(create table foo (id integer primary key, data varchar(30)))
c1.execute(insert into foo(id, data) values (1, 'data1'))
c1.close()
conn1.commit()

c1 = conn1.cursor()
c1.execute(select * from foo where id=1)
row1 = c1.fetchone()
c1.close()

conn2 = sqlite3.connect(file.db)
c2 = conn2.cursor()

c2.execute(PRAGMA read_uncommitted=SERIALIZABLE)

# sqlite3 should be doing this automatically.
# when called, conn1's commit blocks
#c2.execute(BEGIN)
c2.execute(select * from foo where id=1)
row2 = c2.fetchone()
c2.close()

c1 = conn1.cursor()
c1.execute(update foo set data='data2')

print About to commit conn1...
conn1.commit()

--
components: Library (Lib)
messages: 117167
nosy: zzzeek
priority: normal
severity: normal
status: open
title: sqlite3 SELECT does not BEGIN a transaction, but should according to spec
type: behavior
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

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



[issue9924] sqlite3 SELECT does not BEGIN a transaction, but should according to spec

2010-09-22 Thread mike bayer

mike bayer mike...@zzzcomputing.com added the comment:

My own comment here is that I'm supposing the late BEGIN behavior is to cut 
down on SQLite's file locking.I think a way to maintain that convenience 
for most cases, while allowing the stricter behavior that makes SERIALIZABLE 
isolation worthwhile, would be an option to sqlite3.connect() that moves the 
implicit BEGIN to before any DQL, not just DML, statement.

--

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