[Python-3000-checkins] r58735 - in python/branches/py3k-pep3137: Lib/gettext.py Lib/test/test_dumbdbm.py Lib/test/test_gettext.py Modules/_fileio.c

christian.heimes python-3000-checkins at python.org
Wed Oct 31 20:43:23 CET 2007


Author: christian.heimes
Date: Wed Oct 31 20:43:22 2007
New Revision: 58735

Modified:
   python/branches/py3k-pep3137/   (props changed)
   python/branches/py3k-pep3137/Lib/gettext.py
   python/branches/py3k-pep3137/Lib/test/test_dumbdbm.py
   python/branches/py3k-pep3137/Lib/test/test_gettext.py
   python/branches/py3k-pep3137/Modules/_fileio.c
Log:
Merged revisions 58721-58734 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r58732 | christian.heimes | 2007-10-31 19:53:44 +0100 (Wed, 31 Oct 2007) | 1 line
  
  Fixed gettext module for Windows. The metadata lines always end in \n and not in os.linesep
........
  r58733 | christian.heimes | 2007-10-31 20:20:48 +0100 (Wed, 31 Oct 2007) | 1 line
  
  Fixed bug in _fileio.c and test_pep277. On Windows IOError.filename was not set because the name is stored in widename.
........
  r58734 | christian.heimes | 2007-10-31 20:40:17 +0100 (Wed, 31 Oct 2007) | 2 lines
  
  Fixed test_dumbdbm
  The test failed on Windows. I hope the change follows the spirit of the test. On Unix it checks if dumbdbm can handle Windows line separators and on Windows it tests with Unix line separators.
........


Modified: python/branches/py3k-pep3137/Lib/gettext.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/gettext.py	(original)
+++ python/branches/py3k-pep3137/Lib/gettext.py	Wed Oct 31 20:43:22 2007
@@ -291,7 +291,7 @@
             if mlen == 0:
                 # Catalog description
                 lastk = k = None
-                for b_item in tmsg.split(os.linesep.encode("ascii")):
+                for b_item in tmsg.split('\n'.encode("ascii")):
                     item = str(b_item).strip()
                     if not item:
                         continue

Modified: python/branches/py3k-pep3137/Lib/test/test_dumbdbm.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_dumbdbm.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/test_dumbdbm.py	Wed Oct 31 20:43:22 2007
@@ -113,9 +113,12 @@
         f[b'2'] = b'hello2'
         f.close()
 
-        # Mangle the file by adding \r before each newline
+        # Mangle the file by changing the line separator to Windows or Unix
         data = io.open(_fname + '.dir', 'rb').read()
-        data = data.replace(b'\n', b'\r\n')
+        if os.linesep == b'\n':
+            data = data.replace(b'\n', b'\r\n')
+        else:
+            data = data.replace(b'\r\n', b'\n')
         io.open(_fname + '.dir', 'wb').write(data)
 
         f = dumbdbm.open(_fname)

Modified: python/branches/py3k-pep3137/Lib/test/test_gettext.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_gettext.py	(original)
+++ python/branches/py3k-pep3137/Lib/test/test_gettext.py	Wed Oct 31 20:43:22 2007
@@ -332,6 +332,7 @@
 
     def test_weird_metadata(self):
         info = self.t.info()
+        self.assertEqual(len(info), 9)
         self.assertEqual(info['last-translator'],
            'John Doe <jdoe at example.com>\nJane Foobar <jfoobar at example.com>')
 

Modified: python/branches/py3k-pep3137/Modules/_fileio.c
==============================================================================
--- python/branches/py3k-pep3137/Modules/_fileio.c	(original)
+++ python/branches/py3k-pep3137/Modules/_fileio.c	Wed Oct 31 20:43:22 2007
@@ -267,7 +267,11 @@
 			self->fd = open(name, flags, 0666);
 		Py_END_ALLOW_THREADS
 		if (self->fd < 0 || dircheck(self) < 0) {
+#ifdef MS_WINDOWS
+			PyErr_SetFromErrnoWithUnicodeFilename(PyExc_IOError, widename);
+#else
 			PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
+#endif
 			goto error;
 		}
 	}


More information about the Python-3000-checkins mailing list