Commit 665f559a authored by Jim Fulton's avatar Jim Fulton

implement excellent reviewer suggestions

parent 32bd5a7a
...@@ -175,15 +175,16 @@ class TransactionManager(object): ...@@ -175,15 +175,16 @@ class TransactionManager(object):
doc = func.__doc__ doc = func.__doc__
if name != '_': if name != '_':
if doc: if doc:
doc = name + u'\n\n' + doc doc = name + '\n\n' + doc
else: else:
doc = name doc = name
if doc and not isinstance(doc, text_type):
doc = doc.decode('utf-8')
for i in range(1, tries + 1): for i in range(1, tries + 1):
txn = self.begin() txn = self.begin()
if doc: if doc:
if not isinstance(doc, text_type):
doc = doc.decode('ascii')
txn.note(doc) txn.note(doc)
try: try:
......
...@@ -548,7 +548,7 @@ class Transaction(object): ...@@ -548,7 +548,7 @@ class Transaction(object):
if not isinstance(user_name, text_type): if not isinstance(user_name, text_type):
raise TypeError("User name must be text (unicode)") raise TypeError("User name must be text (unicode)")
if not isinstance(path, text_type): if not isinstance(path, text_type):
raise TypeError("User name must be text (unicode)") raise TypeError("Path must be text (unicode)")
self.user = u"%s %s" % (path, user_name) self.user = u"%s %s" % (path, user_name)
def setExtendedInfo(self, name, value): def setExtendedInfo(self, name, value):
......
...@@ -992,7 +992,7 @@ class TransactionTests(unittest.TestCase): ...@@ -992,7 +992,7 @@ class TransactionTests(unittest.TestCase):
def test_description_bytes(self): def test_description_bytes(self):
txn = self._makeOne() txn = self._makeOne()
with self.assertRaises((UnicodeDecodeError, TypeError)): with self.assertRaises(TypeError):
txn.description = b'haha' txn.description = b'haha'
def test_setUser_default_path(self): def test_setUser_default_path(self):
...@@ -1007,13 +1007,13 @@ class TransactionTests(unittest.TestCase): ...@@ -1007,13 +1007,13 @@ class TransactionTests(unittest.TestCase):
def test_user_bytes(self): def test_user_bytes(self):
txn = self._makeOne() txn = self._makeOne()
with self.assertRaises((UnicodeDecodeError, TypeError)): with self.assertRaises(TypeError):
txn.user = b'phreddy' txn.user = b'phreddy'
with self.assertRaises((UnicodeDecodeError, TypeError)): with self.assertRaises(TypeError):
txn.setUser(b'phreddy', u'/bedrock') txn.setUser(b'phreddy', u'/bedrock')
with self.assertRaises((UnicodeDecodeError, TypeError)): with self.assertRaises(TypeError):
txn.setUser(u'phreddy', b'/bedrock') txn.setUser(u'phreddy', b'/bedrock')
with self.assertRaises((UnicodeDecodeError, TypeError)): with self.assertRaises(TypeError):
txn.setUser(b'phreddy') txn.setUser(b'phreddy')
def test_setExtendedInfo_single(self): def test_setExtendedInfo_single(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment