diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 82ff62ff758f18d14b8dc65b098b28c7d4b26abb..3d7c29c6ea33ebc49b071681c5f9746b97445aa3 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -533,6 +533,10 @@ class Operator(object): in_arg_names.append(arg.name) elif isinstance(arg.name, six.binary_type): in_arg_names.append(arg.name.decode()) + else: + raise TypeError( + "arguments require unicode, str or bytes, but get %s instead." + % (type(arg.name))) self.desc.set_input(in_proto.name, in_arg_names) else: self.desc.set_input(in_proto.name, []) @@ -566,7 +570,9 @@ class Operator(object): elif isinstance(arg.name, six.binary_type): out_arg_names.append(arg.name.decode()) else: - out_arg_names.append(six.u(arg.name)) + raise TypeError( + "arguments require unicode, str or bytes, but get %s instead." + % (type(arg.name))) arg.op = self self.desc.set_output(out_proto.name, out_arg_names) diff --git a/python/paddle/fluid/layer_helper.py b/python/paddle/fluid/layer_helper.py index 64337465ed0778edf89c5c4fda06cd27b3f386f2..0c2b1eb795860373220eb254612161f7dc816ffd 100644 --- a/python/paddle/fluid/layer_helper.py +++ b/python/paddle/fluid/layer_helper.py @@ -401,6 +401,8 @@ class LayerHelper(object): return input_var if isinstance(act, six.string_types): act = {'type': act} + else: + raise TypeError(str(act) + " should be unicode or str") if 'use_cudnn' in self.kwargs and self.kwargs.get('use_cudnn'): act['use_cudnn'] = self.kwargs.get('use_cudnn') diff --git a/python/paddle/fluid/unique_name.py b/python/paddle/fluid/unique_name.py index d4e28f4b9193d0b233344c0acb39ef956a7007c7..36af91eab45e1b2dfe9bb26cf57d192c05f5091f 100644 --- a/python/paddle/fluid/unique_name.py +++ b/python/paddle/fluid/unique_name.py @@ -70,6 +70,10 @@ def switch(new_generator=None): def guard(new_generator=None): if isinstance(new_generator, six.string_types): new_generator = UniqueNameGenerator(new_generator) + elif isinstance(new_generator, six.binary_type): + new_generator = UniqueNameGenerator(new_generator.decode()) + else: + raise TypeError(str(new_generator) + " should be unicode or str") old = switch(new_generator) yield switch(old) diff --git a/python/paddle/reader/creator.py b/python/paddle/reader/creator.py index 369ff5e22b75cf33054d51f8075507d613d93468..c861020225fb6fe0a29653363c2151b20dc8f578 100644 --- a/python/paddle/reader/creator.py +++ b/python/paddle/reader/creator.py @@ -73,6 +73,8 @@ def recordio(paths, buf_size=100): def reader(): if isinstance(paths, six.string_types): path = paths + elif isinstance(paths, six.binary_type): + path = paths.decode() else: path = ",".join(paths) f = rec.reader(path)