Skip to content

Commit 82c56e7

Browse files
mthomasfblundun
authored andcommitted
support python2 unicode strings through six library (closes snowplow#138)
1 parent 849f8c6 commit 82c56e7

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ requests==2.2.1
33
celery==3.1.11
44
gevent==1.0.0
55
redis==2.9.1
6+
six==1.9.0

snowplow_tracker/tracker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import time
2323
import uuid
24+
import six
2425
from snowplow_tracker import payload, _version
2526
from snowplow_tracker import subject as _subject
2627
from contracts import contract, new_contract
@@ -44,9 +45,9 @@
4445

4546
class Tracker:
4647

47-
new_contract("non_empty_string", lambda s: isinstance(s, str)
48+
new_contract("non_empty_string", lambda s: isinstance(s, six.string_types)
4849
and len(s) > 0)
49-
new_contract("string_or_none", lambda s: (isinstance(s, str)
50+
new_contract("string_or_none", lambda s: (isinstance(s, six.string_types)
5051
and len(s) > 0) or s is None)
5152
new_contract("payload", lambda s: isinstance(s, payload.Payload))
5253

0 commit comments

Comments
 (0)