aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/python23compat.py
diff options
context:
space:
mode:
authorJohannes Krampf <johannes.krampf@googlemail.com>2014-01-19 16:03:49 +0100
committerKevin O'Connor <kevin@koconnor.net>2014-01-20 12:42:44 -0500
commit19f789bdfd58eba2ed8fe604bbabf8df0fcc0771 (patch)
tree51c49104aec5b420382f82f71e3b4a8edf0be8f1 /scripts/python23compat.py
parent0a82fc743c5ec1553f745bec6fc8bc8780088fd8 (diff)
downloadseabios-19f789bdfd58eba2ed8fe604bbabf8df0fcc0771.tar.gz
build: Be careful with unicode and byte strings for python3 compatibility.
Signed-off-by: Johannes Krampf <johannes.krampf@googlemail.com>
Diffstat (limited to 'scripts/python23compat.py')
-rw-r--r--scripts/python23compat.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/python23compat.py b/scripts/python23compat.py
new file mode 100644
index 00000000..572b7f18
--- /dev/null
+++ b/scripts/python23compat.py
@@ -0,0 +1,14 @@
+# Helper code for compatibility of the code with both Python 2 and Python 3
+#
+# Copyright (C) 2014 Johannes Krampf <johannes.krampf@googlemail.com>
+#
+# This file may be distributed under the terms of the GNU GPLv3 license.
+
+import sys
+
+if (sys.version_info > (3, 0)):
+ def as_bytes(str):
+ return bytes(str, "ASCII")
+else:
+ def as_bytes(str):
+ return str