timifasubaa closed pull request #6124: remove more python2 stuff
URL: https://github.com/apache/incubator-superset/pull/6124
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index da9ca53c75..a9de6db218 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -305,7 +305,6 @@ tox -e <environment>
i.e.,
```bash
-tox -e py27
tox -e py36
```
diff --git a/superset/utils.py b/superset/utils.py
index a15f382533..f41e4dae84 100644
--- a/superset/utils.py
+++ b/superset/utils.py
@@ -14,7 +14,6 @@
import os
import signal
import smtplib
-import sys
import uuid
import zlib
@@ -42,7 +41,6 @@
logging.getLogger('MARKDOWN').setLevel(logging.INFO)
-PY3K = sys.version_info >= (3, 0)
EPOCH = datetime(1970, 1, 1)
DTTM_ALIAS = '__timestamp'
ADHOC_METRIC_EXPRESSION_TYPES = {
@@ -668,33 +666,29 @@ def setup_cache(app, cache_config):
def zlib_compress(data):
"""
- Compress things in a py2/3 safe fashion
+ Compress things
>>> json_str = '{"test": 1}'
>>> blob = zlib_compress(json_str)
"""
- if PY3K:
- if isinstance(data, str):
- return zlib.compress(bytes(data, 'utf-8'))
- return zlib.compress(data)
+ if isinstance(data, str):
+ return zlib.compress(bytes(data, 'utf-8'))
return zlib.compress(data)
def zlib_decompress_to_string(blob):
"""
- Decompress things to a string in a py2/3 safe fashion
+ Decompress things to a string
>>> json_str = '{"test": 1}'
>>> blob = zlib_compress(json_str)
>>> got_str = zlib_decompress_to_string(blob)
>>> got_str == json_str
True
"""
- if PY3K:
- if isinstance(blob, bytes):
- decompressed = zlib.decompress(blob)
- else:
- decompressed = zlib.decompress(bytes(blob, 'utf-8'))
- return decompressed.decode('utf-8')
- return zlib.decompress(blob)
+ if not isinstance(blob, bytes):
+ decompressed = zlib.decompress(blob)
+ else:
+ decompressed = zlib.decompress(str(blob, 'utf-8'))
+ return decompressed.decode('utf-8')
_celery_app = None
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]