提交 ec994f62 authored 作者: Michael Osthege's avatar Michael Osthege 提交者: Brandon T. Willard

Remove unnecessary decode util

上级 a4ca0cba
......@@ -68,8 +68,8 @@ def test_mpi_roundtrip():
)
(stdout, stderr) = p.communicate()
result = theano.utils.decode(stdout)
assert "True" in result, theano.utils.decode(stderr)
result = stdout.decode()
assert "True" in result, stderr.decode()
def test_mpi_send_wait_cmp():
......
......@@ -28,7 +28,7 @@ from theano.configdefaults import gcc_version_str, local_bitwidth
# we will abuse the lockfile mechanism when reading and writing the registry
from theano.gof import compilelock
from theano.gof.utils import flatten, hash_from_code
from theano.utils import decode, decode_iter, output_subprocess_Popen, subprocess_Popen
from theano.utils import output_subprocess_Popen, subprocess_Popen
importlib = None
......@@ -2042,7 +2042,7 @@ class GCC_compiler(Compiler):
return None
lines = BytesIO(stdout + stderr).readlines()
lines = decode_iter(lines)
lines = (l.decode() for l in lines)
if parse:
selected_lines = []
for line in lines:
......@@ -2471,7 +2471,7 @@ class GCC_compiler(Compiler):
try:
p_out = output_subprocess_Popen(cmd)
compile_stderr = decode(p_out[1])
compile_stderr = p_out[1].decode()
except Exception:
# An exception can occur e.g. if `g++` is not found.
print_command_line_error()
......
......@@ -5,7 +5,6 @@ from locale import getpreferredencoding
from optparse import OptionParser
import theano
from theano.utils import decode_with
console_encoding = getpreferredencoding()
......@@ -37,7 +36,7 @@ def runScript(N):
if err:
print(err)
sys.exit()
return list(map(float, decode_with(out, console_encoding).split(" ")))
return list(map(float, out.decode(console_encoding).split(" ")))
if __name__ == "__main__":
......
......@@ -13,19 +13,22 @@ from functools import wraps
__all__ = [
"cmp",
"decode",
"decode_with",
"decode_iter",
"get_unbound_function",
"maybe_add_to_os_environ_pathlist",
"DefaultOrderedDict",
"deprecated",
"subprocess_Popen",
"call_subprocess_Popen",
"output_subprocess_Popen",
]
# In python 3.x, when an exception is reraised it saves original
# exception in its args, therefore in order to find the actual
# message, we need to unpack arguments recursively.
def exc_message(e):
"""
In python 3.x, when an exception is reraised it saves original
exception in its args, therefore in order to find the actual
message, we need to unpack arguments recursively.
"""
msg = e.args[0]
if isinstance(msg, Exception):
return exc_message(msg)
......@@ -46,19 +49,6 @@ def get_unbound_function(unbound):
return unbound
def decode(x):
return x.decode()
def decode_iter(itr):
for x in itr:
yield x.decode()
def decode_with(x, encoding):
return x.decode(encoding)
class DefaultOrderedDict(OrderedDict):
def __init__(self, default_factory=None, *a, **kw):
if default_factory is not None and not isinstance(default_factory, Callable):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论