[Python-bugs-list] [ python-Bugs-416199 ] mailbox.py seek problems

noreply@sourceforge.net noreply@sourceforge.net
Sun, 15 Apr 2001 06:33:14 -0700


Bugs item #416199, was updated on 2001-04-14 16:30
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416199&group_id=5470

Category: Python Library
Group: None
>Status: Closed
Priority: 7
Submitted By: Andrew Dalke (dalke)
Assigned to: Guido van Rossum (gvanrossum)
Summary: mailbox.py seek problems

Initial Comment:
Here's some bugs I see in mailbox.py

>>> import mailbox, os
>>> mb = mailbox.UnixMailbox(open(os.environ["MAIL"]))
>>> mb.seek(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/dalke/local/lib/python2.0/mailbox.py", 
line 20, in seek
    self.pos = self.start + pos
AttributeError: UnixMailbox instance has no 
attribute 'start'
>>> mb.seek(0, whence = 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/home/dalke/local/lib/python2.0/mailbox.py", 
line 18, in seek
    self.pos = self.stop + pos
AttributeError: UnixMailbox instance has no 
attribute 'stop'
>>>

Looking at the seek code for mailbox._Mailbox:

    def seek(self, pos, whence=0):
        if whence==1:           # Relative to current 
position
            self.pos = self.pos + pos
        if whence==2:           # Relative to file's 
end
            self.pos = self.stop + pos
        else:                   # Default - absolute 
position
            self.pos = self.start + pos

The values for "self.start" and "self.stop" are never 
defined.  Instead, it appears mailbox._Mailbox.seek 
was copied from mailbox._Subfile.seek without making 
the needed changes.

I also think there needs to be a tell() method
on the _Mailbox if there's a seek() method.  I
needed in since I was trying to index my mailbox.



----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2001-04-15 06:33

Message:
Logged In: YES 
user_id=6380

Hm.  The seek() method was never documented and never 
worked!  I'm getting rid of it.  If you want to do random 
access on your mailbox file, you'll have to subclass it and 
use self.fp directly.  Maybe someday we'll support seek() 
and tell(), but not in 2.1.  (Seek was never documented.)

Closing this bug report now.

----------------------------------------------------------------------

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-04-14 19:58

Message:
Logged In: YES 
user_id=6380

Sigh.  This module has been riddled with bugs ever since it
was created, it seems.  I'll fix this before releasing
2.1final!

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=416199&group_id=5470