Rev 6394: (gz) Fix deprecations of win32utils path function unicode wrappers (Martin in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 21 14:17:34 UTC 2011
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6394 [merge]
revision-id: pqm at pqm.ubuntu.com-20111221141733-gmep8iobns97q3eo
parent: pqm at pqm.ubuntu.com-20111221000749-jnw2o645cdjr961f
parent: martin.packman at canonical.com-20111219103937-41v8oxpifnm9hao0
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-12-21 14:17:33 +0000
message:
(gz) Fix deprecations of win32utils path function unicode wrappers (Martin
Packman)
modified:
bzrlib/tests/test_win32utils.py test_win32utils.py-20070713181630-8xsrjymd3e8mgw23-108
bzrlib/win32utils.py win32console.py-20051021033308-123c6c929d04973d
=== modified file 'bzrlib/tests/test_win32utils.py'
--- a/bzrlib/tests/test_win32utils.py 2011-12-05 12:50:21 +0000
+++ b/bzrlib/tests/test_win32utils.py 2011-12-19 10:37:57 +0000
@@ -20,6 +20,7 @@
from bzrlib import (
osutils,
+ symbol_versioning,
tests,
win32utils,
)
@@ -187,6 +188,51 @@
self.assertEquals('not-existing', p)
+class TestLocations(TestCase):
+ """Tests for windows specific path and name retrieving functions"""
+
+ def test__ensure_unicode_deprecated(self):
+ s = "text"
+ u1 = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
+ win32utils._ensure_unicode, s)
+ self.assertEqual(s, u1)
+ self.assertIsInstance(u1, unicode)
+ u2 = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
+ win32utils._ensure_unicode, u1)
+ self.assertIs(u1, u2)
+
+ def test_appdata_unicode_deprecated(self):
+ self.overrideEnv("APPDATA", "fakepath")
+ s = win32utils.get_appdata_location()
+ u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
+ win32utils.get_appdata_location_unicode)
+ self.assertEqual(s, u)
+ self.assertIsInstance(s, unicode)
+
+ def test_home_unicode_deprecated(self):
+ s = win32utils.get_home_location()
+ u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
+ win32utils.get_home_location_unicode)
+ self.assertEqual(s, u)
+ self.assertIsInstance(s, unicode)
+
+ def test_user_unicode_deprecated(self):
+ self.overrideEnv("USERNAME", "alien")
+ s = win32utils.get_user_name()
+ u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
+ win32utils.get_user_name_unicode)
+ self.assertEqual(s, u)
+ self.assertIsInstance(s, unicode)
+
+ def test_host_unicode_deprecated(self):
+ self.overrideEnv("COMPUTERNAME", "alienbox")
+ s = win32utils.get_host_name()
+ u = self.applyDeprecated(symbol_versioning.deprecated_in((2, 5, 0)),
+ win32utils.get_host_name_unicode)
+ self.assertEqual(s, u)
+ self.assertIsInstance(s, unicode)
+
+
class TestLocationsCtypes(TestCase):
_test_needs_features = [CtypesFeature]
=== modified file 'bzrlib/win32utils.py'
--- a/bzrlib/win32utils.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/win32utils.py 2011-12-21 14:17:33 +0000
@@ -372,7 +372,7 @@
return get_environ_unicode('COMPUTERNAME')
- at symbol_versioning.deprecated_method(
+ at symbol_versioning.deprecated_function(
symbol_versioning.deprecated_in((2, 5, 0)))
def _ensure_unicode(s):
if s and type(s) != unicode:
@@ -381,16 +381,16 @@
return s
-get_appdata_location_unicode = symbol_versioning.deprecated_method(
+get_appdata_location_unicode = symbol_versioning.deprecated_function(
symbol_versioning.deprecated_in((2, 5, 0)))(get_appdata_location)
-get_home_location_unicode = symbol_versioning.deprecated_method(
+get_home_location_unicode = symbol_versioning.deprecated_function(
symbol_versioning.deprecated_in((2, 5, 0)))(get_home_location)
-get_user_name_unicode = symbol_versioning.deprecated_method(
+get_user_name_unicode = symbol_versioning.deprecated_function(
symbol_versioning.deprecated_in((2, 5, 0)))(get_user_name)
-get_host_name_unicode = symbol_versioning.deprecated_method(
+get_host_name_unicode = symbol_versioning.deprecated_function(
symbol_versioning.deprecated_in((2, 5, 0)))(get_host_name)
@@ -594,8 +594,9 @@
Fallback version that should basically never be needed.
"""
+ from bzrlib import osutils
try:
- return os.environ[key].decode("mbcs")
+ return os.environ[key].decode(osutils.get_user_encoding())
except KeyError:
return default
More information about the bazaar-commits
mailing list