mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 23:57:45 +08:00
Remove six and cloudpickle from setup.py. (#7694)
This commit is contained in:
+4
-23
@@ -5,7 +5,6 @@ import inspect
|
||||
import logging
|
||||
import numpy as np
|
||||
import os
|
||||
import six
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
@@ -223,32 +222,14 @@ def decode(byte_str, allow_none=False):
|
||||
def ensure_str(s, encoding="utf-8", errors="strict"):
|
||||
"""Coerce *s* to `str`.
|
||||
|
||||
To keep six with lower version, see Issue 4169, we copy this function
|
||||
from six == 1.12.0.
|
||||
|
||||
TODO(yuhguo): remove this function when six >= 1.12.0.
|
||||
|
||||
For Python 2:
|
||||
- `unicode` -> encoded to `str`
|
||||
- `str` -> `str`
|
||||
|
||||
For Python 3:
|
||||
- `str` -> `str`
|
||||
- `bytes` -> decoded to `str`
|
||||
"""
|
||||
if six.PY3:
|
||||
text_type = str
|
||||
binary_type = bytes
|
||||
if isinstance(s, str):
|
||||
return s
|
||||
else:
|
||||
text_type = unicode # noqa: F821
|
||||
binary_type = str
|
||||
if not isinstance(s, (text_type, binary_type)):
|
||||
raise TypeError("not expecting type '%s'" % type(s))
|
||||
if six.PY2 and isinstance(s, text_type):
|
||||
s = s.encode(encoding, errors)
|
||||
elif six.PY3 and isinstance(s, binary_type):
|
||||
s = s.decode(encoding, errors)
|
||||
return s
|
||||
assert isinstance(s, bytes)
|
||||
return s.decode(encoding, errors)
|
||||
|
||||
|
||||
def binary_to_object_id(binary_object_id):
|
||||
|
||||
Reference in New Issue
Block a user