Rev 3563: Switch from os.name to bzrlib.win32utils.winver. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/win32_find_files

John Arbash Meinel john at arbash-meinel.com
Thu Jul 17 21:16:52 BST 2008


At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/win32_find_files

------------------------------------------------------------
revno: 3563
revision-id: john at arbash-meinel.com-20080717201643-qrbe6thvki1izwig
parent: john at arbash-meinel.com-20080717152900-0qm7pf511hjgutzy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: win32_find_files
timestamp: Thu 2008-07-17 15:16:43 -0500
message:
  Switch from os.name to bzrlib.win32utils.winver.
  os.name is always 'nt' for any Windows platform... :(
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py	2008-07-17 15:21:34 +0000
+++ b/bzrlib/osutils.py	2008-07-17 20:16:43 +0000
@@ -1198,7 +1198,7 @@
     global _real_walkdirs_utf8
     if _real_walkdirs_utf8 is None:
         fs_encoding = _fs_enc.upper()
-        if sys.platform == 'win32' and os.name == 'nt':
+        if win32utils.winver == 'Windows NT':
             # Win98 doesn't have unicode apis like FindFirstFileW
             # TODO: We possibly could support Win98 by falling back to the
             #       original FindFirstFile, and using TCHAR instead of WCHAR,

=== modified file 'bzrlib/tests/test_osutils.py'
--- a/bzrlib/tests/test_osutils.py	2008-07-17 15:29:00 +0000
+++ b/bzrlib/tests/test_osutils.py	2008-07-17 20:16:43 +0000
@@ -842,13 +842,11 @@
                           osutils._real_walkdirs_utf8)
 
     def _save_platform_info(self):
-        cur_platform = sys.platform
-        cur_os_name = os.name
+        cur_winver = win32utils.winver
         cur_fs_enc = osutils._fs_enc
         cur_real_walkdirs_utf8 = osutils._real_walkdirs_utf8
         def restore():
-            sys.platform = cur_platform
-            os.name = cur_os_name
+            win32utils.winver = cur_winver
             osutils._fs_enc = cur_fs_enc
             osutils._real_walkdirs_utf8 = cur_real_walkdirs_utf8
         self.addCleanup(restore)
@@ -863,41 +861,39 @@
 
     def test_force_walkdirs_utf8_fs_utf8(self):
         self._save_platform_info()
-        sys.platform = 'not-win32' # Avoid the win32 detection code
+        win32utils.winver = None # Avoid the win32 detection code
         osutils._fs_enc = 'UTF-8'
         self.assertWalkdirsUtf8Is(osutils._walkdirs_fs_utf8)
 
     def test_force_walkdirs_utf8_fs_ascii(self):
         self._save_platform_info()
-        sys.platform = 'not-win32' # Avoid the win32 detection code
+        win32utils.winver = None # Avoid the win32 detection code
         osutils._fs_enc = 'US-ASCII'
         self.assertWalkdirsUtf8Is(osutils._walkdirs_fs_utf8)
 
     def test_force_walkdirs_utf8_fs_ANSI(self):
         self._save_platform_info()
-        sys.platform = 'not-win32' # Avoid the win32 detection code
+        win32utils.winver = None # Avoid the win32 detection code
         osutils._fs_enc = 'ANSI_X3.4-1968'
         self.assertWalkdirsUtf8Is(osutils._walkdirs_fs_utf8)
 
     def test_force_walkdirs_utf8_fs_latin1(self):
         self._save_platform_info()
-        sys.platform = 'not-win32' # Avoid the win32 detection code
+        win32utils.winver = None # Avoid the win32 detection code
         osutils._fs_enc = 'latin1'
         self.assertWalkdirsUtf8Is(osutils._walkdirs_unicode_to_utf8)
 
     def test_force_walkdirs_utf8_nt(self):
         self.requireFeature(WalkdirsWin32Feature)
         self._save_platform_info()
-        sys.platform = 'win32'
-        os.name = 'nt'
+        win32utils.winver = 'Windows NT'
         from bzrlib._walkdirs_win32 import _walkdirs_utf8_win32_find_file
         self.assertWalkdirsUtf8Is(_walkdirs_utf8_win32_find_file)
 
     def test_force_walkdirs_utf8_nt(self):
         self.requireFeature(WalkdirsWin32Feature)
         self._save_platform_info()
-        sys.platform = 'win32'
-        os.name = 'NOT-nt'
+        win32utils.winver = 'Windows 98'
         self.assertWalkdirsUtf8Is(osutils._walkdirs_unicode_to_utf8)
 
     def test_unicode_walkdirs(self):



More information about the bazaar-commits mailing list