summaryrefslogtreecommitdiffstats
path: root/Lib/mailbox.py
diff options
context:
space:
mode:
authorAndrew MacIntyre <andymac@bullseye.apana.org.au>2006-07-23 13:04:00 (GMT)
committerAndrew MacIntyre <andymac@bullseye.apana.org.au>2006-07-23 13:04:00 (GMT)
commitafa358fabf2632c218d106550a1a4dba9b6957b0 (patch)
tree7acd0086522492df6c9a883aa9015d6a1e6db01f /Lib/mailbox.py
parent82247cb7d1a5363dbe40ba14207916f0f939e6f6 (diff)
downloadcpython-afa358fabf2632c218d106550a1a4dba9b6957b0.zip
cpython-afa358fabf2632c218d106550a1a4dba9b6957b0.tar.gz
cpython-afa358fabf2632c218d106550a1a4dba9b6957b0.tar.bz2
Get mailbox module working on OS/2 EMX port.
Diffstat (limited to 'Lib/mailbox.py')
-rwxr-xr-xLib/mailbox.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/mailbox.py b/Lib/mailbox.py
index d054628..b72128b 100755
--- a/Lib/mailbox.py
+++ b/Lib/mailbox.py
@@ -15,6 +15,9 @@ import email.Generator
import rfc822
import StringIO
try:
+ if sys.platform == 'os2emx':
+ # OS/2 EMX fcntl() not adequate
+ raise ImportError
import fcntl
except ImportError:
fcntl = None
@@ -565,7 +568,8 @@ class _singlefileMailbox(Mailbox):
try:
os.rename(new_file.name, self._path)
except OSError, e:
- if e.errno == errno.EEXIST:
+ if e.errno == errno.EEXIST or \
+ (os.name == 'os2' and e.errno == errno.EACCES):
os.remove(self._path)
os.rename(new_file.name, self._path)
else:
@@ -1030,6 +1034,9 @@ class MH(Mailbox):
if hasattr(os, 'link'):
os.link(os.path.join(self._path, str(key)),
os.path.join(self._path, str(prev + 1)))
+ if sys.platform == 'os2emx':
+ # cannot unlink an open file on OS/2
+ f.close()
os.unlink(os.path.join(self._path, str(key)))
else:
f.close()
@@ -1828,7 +1835,8 @@ def _lock_file(f, dotlock=True):
os.rename(pre_lock.name, f.name + '.lock')
dotlock_done = True
except OSError, e:
- if e.errno == errno.EEXIST:
+ if e.errno == errno.EEXIST or \
+ (os.name == 'os2' and e.errno == errno.EACCES):
os.remove(pre_lock.name)
raise ExternalClashError('dot lock unavailable: %s' %
f.name)