Skip to content

Commit 514198a

Browse files
committed
New release
1 parent 4118482 commit 514198a

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

codext/VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.5.5
1+
1.6.1

codext/binary/baudot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
__CODES = ["ccitt1", "ccitt2", "eu", "ita1", "ita2", "ita2_us", "murray", "uk"]
1414
if PY3:
1515
__CODES.extend(["ita2_meteo", "mtk2"])
16-
__guess__ = ["baudot%s-{}-{}".format(a, b) for a in __CODES for b in ["lsb", "msb"]]
16+
__guess__ = ["baudot%s-{}-{}".format(x, y) for x in __CODES for y in ["lsb", "msb"]]
1717
__examples1__ = {
1818
'enc(baudot-BAD_ALPHABET)': None,
1919
'enc(baudot_ccitt2_lsb)': {'TEST 1234': "00001100001010000001001001101111101110011000001010"},

tests/test_common.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
import codecs
77
import codext
88
import random
9-
from six import b, ensure_str
9+
import sys
10+
from six import b, binary_type, text_type
1011
from unittest import TestCase
1112

1213

14+
PY3 = sys.version[0] == "3"
15+
16+
1317
def dummy_encode(input, errors="strict"):
1418
return input, len(input)
1519

@@ -18,6 +22,18 @@ def dummy_decode(input, errors="strict"):
1822
return input, len(input)
1923

2024

25+
def ensure_str(s, encoding='utf-8', errors='strict'):
26+
""" Similar to six.ensure_str. Adapted here to avoid messing up with six version errors. """
27+
if not PY3 and isinstance(s, text_type):
28+
return s.encode(encoding, errors)
29+
elif PY3 and isinstance(s, binary_type):
30+
try:
31+
return s.decode(encoding, errors)
32+
except:
33+
return s.decode("latin-1")
34+
return s
35+
36+
2137
def getregentry(encoding):
2238
if encoding == "dummy3":
2339
return codecs.CodecInfo(name="dummy3", encode=dummy_encode, decode=dummy_decode)

0 commit comments

Comments
 (0)