[issue10045] poor cStringIO.StringO seek performance

2010-10-07 Thread Patrick Strawderman

New submission from Patrick Strawderman :

cStringIO.StringO's seek method has O(n) characteristics in certain,
albeit pathological, cases, while the pure Python implementation and
cStringIO.StringI's seek methods both execute in constant time in all cases.

When the file offset is set n bytes beyond the end of actual data,
the gap is filled in with n bytes in cStringIO.StringO's seek method.

however, POSIX states that reads of data in the gap will return null bytes
only if a subsequent write has taken place, so filling in the gap is not
required at the time of the seek.

This patch for 2.7 corrects the behavior by unifying StringO and StringI's
seek methods, and moving the writing of null bytes to StringO's write
method.  There may be a more elegant way to write this, I don't know.
I believe this issue affects Python 3 as well, though I have yet to
test it.

NOTE: Perhaps this seems like an extreme edge case not worthy of a fix, but
this actually caused problems for us when parsing images with malformed
EXIF data; a web request for uploading such a photo was taking on the order
of 15 minutes.  When we stopped using cStringIO.StringO, it took seconds.

--
files: cStringIO.diff
keywords: patch
messages: 118123
nosy: boogenhagn
priority: normal
severity: normal
status: open
title: poor cStringIO.StringO seek performance
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file19150/cStringIO.diff

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



[issue10045] poor cStringIO.StringO seek performance

2010-10-07 Thread Patrick Strawderman

Changes by Patrick Strawderman :


--
components: +None
type:  -> performance

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



[issue10045] poor cStringIO.StringO seek performance

2010-10-07 Thread Patrick Strawderman

Changes by Patrick Strawderman :


--
components:  -None

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



[issue10045] poor cStringIO.StringO seek performance

2010-10-07 Thread Patrick Strawderman

Patrick Strawderman  added the comment:

The second sentence should have said "the gap is filled in with n null bytes"

--

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



[issue10045] poor cStringIO.StringO seek performance

2010-10-08 Thread Patrick Strawderman

Patrick Strawderman  added the comment:

Fair enough, but there is a great deal of existing code that already 
uses cStringIO.

--

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



[issue6553] cPickle "binunicode" segmentation fault

2009-07-23 Thread Patrick Strawderman

New submission from Patrick Strawderman :

When reading from a file-like object (like StringIO), cPickle uses the
read_other function, which doesn't check that the number of bytes
requested is the actual number of bytes read (like the read_cStringIO
function does).

Functions like load_binunicode falsely assume that the number of bytes
specified after the BINUNICODE instruction are the actual number of
bytes read.  This can eventually lead to a segmentation fault, as
demonstrated in the following example:

import cPickle, StringIO

cPickle.Unpickler(StringIO.StringIO("X''.")).load()


I have tested and reproduced this on Python 2.4.6 (OS X 32-bit), 2.5.1
(OS X 32-bit), and 2.6.2 (Linux 64-bit).

I have not tested Python 3.x, but I believe this problem may be akin to
the one in issue4298.

--
messages: 90847
nosy: boogenhagn
severity: normal
status: open
title: cPickle "binunicode" segmentation fault
versions: Python 2.4, Python 2.5, Python 2.6

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

New submission from Patrick Strawderman :

doctest.DocFileTest inserts the test's path into the globs as "__file__",
but doctest.DocTestCase's tearDown method simply calls globs.clear(),
so that subsequent runs of the test case will not receive the same
initial globals.

This means that doctests referencing __file__ cannot be run repeatedly
without using a custom setUp that restores __file__.

I think most would expect symmetry between setUp and tearDown, and in
fact zope.testrunner operates with this false assumption when run
with the "-N" option to repeat a test N times.

--
components: Library (Lib)
messages: 27
nosy: boogenhagn, fdrake
priority: normal
severity: normal
status: open
title: doctest DocFileCase setUp/tearDown asymmetry
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

Changes by Patrick Strawderman :


Added file: http://bugs.python.org/file18114/doctestbug.py

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

Changes by Patrick Strawderman :


Added file: http://bugs.python.org/file18115/doctestbugpy3.py

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

Changes by Patrick Strawderman :


--
versions:  -Python 3.3

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

Changes by Patrick Strawderman :


Removed file: http://bugs.python.org/file18114/doctestbug.py

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

Changes by Patrick Strawderman :


Removed file: http://bugs.python.org/file18115/doctestbugpy3.py

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2010-07-21 Thread Patrick Strawderman

Changes by Patrick Strawderman :


Added file: http://bugs.python.org/file18116/doctestbug.py

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