aboutsummaryrefslogtreecommitdiffstats
path: root/pathod
diff options
context:
space:
mode:
authorShadab Zafar <dufferzafar0@gmail.com>2016-06-02 13:34:18 +0530
committerShadab Zafar <dufferzafar0@gmail.com>2016-06-02 13:34:18 +0530
commit75ce2498e8c98ec3fd6583985990a56eeb03f2b8 (patch)
tree55c9d0756ebea84f3a2af66ae369170e33f3ebb0 /pathod
parentc4da7e026cc6dc076a1230afd514ef40561f8ed0 (diff)
downloadmitmproxy-75ce2498e8c98ec3fd6583985990a56eeb03f2b8.tar.gz
mitmproxy-75ce2498e8c98ec3fd6583985990a56eeb03f2b8.tar.bz2
mitmproxy-75ce2498e8c98ec3fd6583985990a56eeb03f2b8.zip
Simplify rand_byte by creating a special case for Python 2
Diffstat (limited to 'pathod')
-rw-r--r--pathod/language/generators.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/pathod/language/generators.py b/pathod/language/generators.py
index e736e043..20bb7ae1 100644
--- a/pathod/language/generators.py
+++ b/pathod/language/generators.py
@@ -2,6 +2,8 @@ import string
import random
import mmap
+import six
+
DATATYPES = dict(
ascii_letters=string.ascii_letters.encode(),
ascii_lowercase=string.ascii_lowercase.encode(),
@@ -47,7 +49,9 @@ def rand_byte(chars):
"""
# bytearray has consistent behaviour on both Python 2 and 3
# while bytes does not
- return bytes(bytearray([random.choice(chars)]))
+ if six.PY2:
+ return random.choice(chars)
+ return bytes([random.choice(chars)])
class RandomGenerator(object):