[Patches] [ python-Patches-1575506 ] Mailbox will not lock properly after flush()

SourceForge.net noreply at sourceforge.net
Fri Oct 27 18:58:10 CEST 2006


Patches item #1575506, was opened at 2006-10-11 15:56
Message generated for change (Comment added) made by akuchling
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1575506&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.5
>Status: Closed
>Resolution: Accepted
Priority: 5
Private: No
Submitted By: Philippe Gauthier (deuxpi)
Assigned to: A.M. Kuchling (akuchling)
Summary: Mailbox will not lock properly after flush()

Initial Comment:
The _singlefileMailbox class will try to lock the wrong
file object after a flush(), resulting into an
operation on a closed file object. 

The following code should illustrate the bug. See also
the attached patch.

>>> import mailbox
>>>
>>> box = mailbox.mbox('mbox')
>>> msg = "Subject: sub\n\nbody\n"
>>> box.add(msg)
0
>>> box.flush()
>>> box.close()
>>>
>>> box = mailbox.mbox('mbox')
>>> box.lock()
>>> box.add(msg)
1
>>> box.flush()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/mailbox.py", line 581, in flush
    _lock_file(new_file, dotlock=False)
  File "/usr/lib/python2.5/mailbox.py", line 1847, in
_lock_file
    fcntl.lockf(f, fcntl.LOCK_UN)
ValueError: I/O operation on closed file

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

>Comment By: A.M. Kuchling (akuchling)
Date: 2006-10-27 12:58

Message:
Logged In: YES 
user_id=11375

Good catch!  I think your analysis and patch are correct,
and have applied the changes to the trunk (rev. 52478) and
25-maint (rev. 52479).  Thanks!


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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1575506&group_id=5470


More information about the Patches mailing list