diff options
| author | bwarsaw | 2000-09-14 04:04:17 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-09-14 04:04:17 +0000 |
| commit | c9286082111b1a5b33219ceef0643d3bb2efcfcf (patch) | |
| tree | 7c58f9c1d6baef740f098b133cc18a3efe1369f2 /Mailman/Mailbox.py | |
| parent | fb6258d849f2cca9bd1e789e6f509b35d511f218 (diff) | |
| download | mailman-c9286082111b1a5b33219ceef0643d3bb2efcfcf.tar.gz mailman-c9286082111b1a5b33219ceef0643d3bb2efcfcf.tar.zst mailman-c9286082111b1a5b33219ceef0643d3bb2efcfcf.zip | |
Diffstat (limited to 'Mailman/Mailbox.py')
| -rw-r--r-- | Mailman/Mailbox.py | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/Mailman/Mailbox.py b/Mailman/Mailbox.py index 47f18ea0b..290c0715c 100644 --- a/Mailman/Mailbox.py +++ b/Mailman/Mailbox.py @@ -17,20 +17,29 @@ "Extend mailbox.UnixMailbox." - +import errno import mailbox + + class Mailbox(mailbox.UnixMailbox): # msg should be an rfc822 message or a subclass. def AppendMessage(self, msg): - # seek to the last char of the mailbox - self.fp.seek(1,2) - if self.fp.read(1) <> '\n': - self.fp.write('\n') + # Check the last character of the file and write a newline if it isn't + # a newline (but not at the beginning of an empty file. + try: + self.fp.seek(-1, 2) + except IOError, e: + if e.errno <> errno.EINVAL: raise + # the file must be empty + else: + if self.fp.read(1) <> '\n': + self.fp.write('\n') + # seek to the last char of the mailbox + self.fp.seek(1, 2) self.fp.write(msg.unixfrom) for line in msg.headers: self.fp.write(line) if not msg.body or msg.body[0] <> '\n': self.fp.write('\n') self.fp.write(msg.body) - |
