mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 05:31:20 +00:00 
			
		
		
		
	Get mailbox module working on OS/2 EMX port.
This commit is contained in:
		
							parent
							
								
									82247cb7d1
								
							
						
					
					
						commit
						afa358fabf
					
				
					 2 changed files with 12 additions and 4 deletions
				
			
		|  | @ -15,6 +15,9 @@ | ||||||
| import rfc822 | import rfc822 | ||||||
| import StringIO | import StringIO | ||||||
| try: | try: | ||||||
|  |     if sys.platform == 'os2emx': | ||||||
|  |         # OS/2 EMX fcntl() not adequate | ||||||
|  |         raise ImportError | ||||||
|     import fcntl |     import fcntl | ||||||
| except ImportError: | except ImportError: | ||||||
|     fcntl = None |     fcntl = None | ||||||
|  | @ -565,7 +568,8 @@ def flush(self): | ||||||
|         try: |         try: | ||||||
|             os.rename(new_file.name, self._path) |             os.rename(new_file.name, self._path) | ||||||
|         except OSError, e: |         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.remove(self._path) | ||||||
|                 os.rename(new_file.name, self._path) |                 os.rename(new_file.name, self._path) | ||||||
|             else: |             else: | ||||||
|  | @ -1030,6 +1034,9 @@ def pack(self): | ||||||
|                         if hasattr(os, 'link'): |                         if hasattr(os, 'link'): | ||||||
|                             os.link(os.path.join(self._path, str(key)), |                             os.link(os.path.join(self._path, str(key)), | ||||||
|                                     os.path.join(self._path, str(prev + 1))) |                                     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))) |                             os.unlink(os.path.join(self._path, str(key))) | ||||||
|                         else: |                         else: | ||||||
|                             f.close() |                             f.close() | ||||||
|  | @ -1828,7 +1835,8 @@ def _lock_file(f, dotlock=True): | ||||||
|                     os.rename(pre_lock.name, f.name + '.lock') |                     os.rename(pre_lock.name, f.name + '.lock') | ||||||
|                     dotlock_done = True |                     dotlock_done = True | ||||||
|             except OSError, e: |             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) |                     os.remove(pre_lock.name) | ||||||
|                     raise ExternalClashError('dot lock unavailable: %s' % |                     raise ExternalClashError('dot lock unavailable: %s' % | ||||||
|                                              f.name) |                                              f.name) | ||||||
|  |  | ||||||
|  | @ -461,7 +461,7 @@ class TestMaildir(TestMailbox): | ||||||
| 
 | 
 | ||||||
|     def setUp(self): |     def setUp(self): | ||||||
|         TestMailbox.setUp(self) |         TestMailbox.setUp(self) | ||||||
|         if os.name == 'nt': |         if os.name in ('nt', 'os2'): | ||||||
|             self._box.colon = '!' |             self._box.colon = '!' | ||||||
| 
 | 
 | ||||||
|     def test_add_MM(self): |     def test_add_MM(self): | ||||||
|  | @ -520,7 +520,7 @@ def test_initialize_existing(self): | ||||||
|         # Initialize an existing mailbox |         # Initialize an existing mailbox | ||||||
|         self.tearDown() |         self.tearDown() | ||||||
|         for subdir in '', 'tmp', 'new', 'cur': |         for subdir in '', 'tmp', 'new', 'cur': | ||||||
|             os.mkdir(os.path.join(self._path, subdir)) |             os.mkdir(os.path.normpath(os.path.join(self._path, subdir))) | ||||||
|         self._box = mailbox.Maildir(self._path) |         self._box = mailbox.Maildir(self._path) | ||||||
|         self._check_basics(factory=rfc822.Message) |         self._check_basics(factory=rfc822.Message) | ||||||
|         self._box = mailbox.Maildir(self._path, factory=None) |         self._box = mailbox.Maildir(self._path, factory=None) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andrew MacIntyre
						Andrew MacIntyre