diff options
author | Johannes Krampf <johannes.krampf@googlemail.com> | 2014-01-19 16:03:49 +0100 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2014-01-20 12:42:44 -0500 |
commit | 19f789bdfd58eba2ed8fe604bbabf8df0fcc0771 (patch) | |
tree | 51c49104aec5b420382f82f71e3b4a8edf0be8f1 /scripts/python23compat.py | |
parent | 0a82fc743c5ec1553f745bec6fc8bc8780088fd8 (diff) | |
download | seabios-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.py | 14 |
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 |