diff options
author | Alex Morega <alex@grep.ro> | 2014-01-07 08:16:16 +0200 |
---|---|---|
committer | Alex Morega <alex@grep.ro> | 2014-01-07 08:16:16 +0200 |
commit | 7bad77ded77f658c2b8a478e4a35a672d143606e (patch) | |
tree | 1295d4f1ff094073f7c20853a20a819b44d0b67a | |
parent | 2af2c176b09b0fd90b91e6678e2afaf1355f838b (diff) | |
download | babel-7bad77ded77f658c2b8a478e4a35a672d143606e.tar.gz |
fix warning for deprecated array.tostring
fixes #75
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | babel/_compat.py | 5 | ||||
-rw-r--r-- | babel/messages/mofile.py | 4 |
3 files changed, 8 insertions, 3 deletions
@@ -1,5 +1,5 @@ test: import-cldr - @py.test + @PYTHONWARNINGS=default py.test test-env: @virtualenv test-env diff --git a/babel/_compat.py b/babel/_compat.py index 86096da..0f7640d 100644 --- a/babel/_compat.py +++ b/babel/_compat.py @@ -1,4 +1,5 @@ import sys +import array PY2 = sys.version_info[0] == 2 @@ -26,6 +27,8 @@ if not PY2: cmp = lambda a, b: (a > b) - (a < b) + array_tobytes = array.array.tobytes + else: text_type = unicode string_types = (str, unicode) @@ -47,5 +50,7 @@ else: cmp = cmp + array_tobytes = array.array.tostring + number_types = integer_types + (float,) diff --git a/babel/messages/mofile.py b/babel/messages/mofile.py index 5dd20ae..1850328 100644 --- a/babel/messages/mofile.py +++ b/babel/messages/mofile.py @@ -13,7 +13,7 @@ import array import struct from babel.messages.catalog import Catalog, Message -from babel._compat import range_type +from babel._compat import range_type, array_tobytes LE_MAGIC = 0x950412de @@ -206,4 +206,4 @@ def write_mo(fileobj, catalog, use_fuzzy=False): 7 * 4, # start of key index 7 * 4 + len(messages) * 8, # start of value index 0, 0 # size and offset of hash table - ) + array.array("i", offsets).tostring() + ids + strs) + ) + array_tobytes(array.array("i", offsets)) + ids + strs) |