From: Alex Morega Date: Tue, 7 Jan 2014 06:16:16 +0000 (+0200) Subject: fix warning for deprecated array.tostring X-Git-Tag: 2.0~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7bad77ded77f658c2b8a478e4a35a672d143606e;p=thirdparty%2Fbabel.git fix warning for deprecated array.tostring fixes #75 --- diff --git a/Makefile b/Makefile index 48120c6c..5bb68a9a 100644 --- a/Makefile +++ b/Makefile @@ -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 86096daa..0f7640de 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 5dd20aee..18503287 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)