From 760719892cd4251bdde6d1096dabb02f70941206 Mon Sep 17 00:00:00 2001 From: Bryce Gattis Date: Sat, 2 Mar 2024 22:33:20 -0600 Subject: [PATCH] Remove Python 2 support for utils/json.py Signed-off-by: Bryce Gattis --- src/rez/utils/json.py | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) diff --git a/src/rez/utils/json.py b/src/rez/utils/json.py index 079260df12..31a6506177 100644 --- a/src/rez/utils/json.py +++ b/src/rez/utils/json.py @@ -4,36 +4,7 @@ import json from json import dumps # noqa (forwarded) -import sys -if sys.version_info.major >= 3: - - def loads(data): - return json.loads(data) - -# py2 -else: - - def loads(json_text): - """Avoids returning unicodes in py2. - - https://stackoverflow.com/questions/956867/how-to-get-string-objects-instead-of-unicode-from-json - """ - def _byteify(input, ignore_dicts=False): - if isinstance(input, list): - return [_byteify(x) for x in input] - elif isinstance(input, unicode): - try: - return str(input) - except UnicodeEncodeError: - return input - elif isinstance(input, dict) and not ignore_dicts: - return { - _byteify(k, ignore_dicts=True): _byteify(v, True) - for k, v in input.items() - } - else: - return input - - return _byteify(json.loads(json_text, object_hook=_byteify)) +def loads(data): + return json.loads(data)