未验证 提交 8c888eea 编写于 作者: I Infinity_lee 提交者: GitHub

[CodeStyle][UP024] Replace aliased errors with OSError (#52024)

上级 b166581a
......@@ -318,7 +318,7 @@ def cvt_to_device(x, dev_id, blocking=True):
elif paddle.is_compiled_with_xpu():
place = paddle.XPUPlace(dev_id)
else:
raise EnvironmentError(
raise OSError(
"Only supported compiled paddle with gpu/rocm, npu and xpu , but current verison is compiled with cpu."
)
return x._copy_to(place, blocking)
......@@ -288,7 +288,7 @@ def convert_call(func):
# If func is not in __globals__, it does not need to be transformed
# because it has been transformed before.
converted_call = None
except (IOError, OSError):
except OSError:
# NOTE:
# If func has been decorated, its source code can not be get
# so that it can not be transformed to static function.
......@@ -297,7 +297,7 @@ def convert_call(func):
try:
converted_call = convert_to_static(func)
func_self = getattr(func, '__self__', None)
except (IOError, OSError):
except OSError:
# NOTE: func may have been decorated.
converted_call = None
......@@ -313,7 +313,7 @@ def convert_call(func):
# So descriptor mechanism is used to bound `self` instance on function to
# keep it as bound method.
func.forward = forward_func.__get__(func)
except (IOError, OSError, TypeError):
except (OSError, TypeError):
# NOTE: func.forward may have been decorated.
func_self = None if func_self else func_self
converted_call = func
......@@ -322,7 +322,7 @@ def convert_call(func):
call_func = func.__class__.__call__
converted_call = convert_to_static(call_func)
func_self = func
except (IOError, OSError, TypeError):
except (OSError, TypeError):
# NOTE:
# If `func` is a class which is being initialized, for example `convert_call(Foo)()`,
# it doesn't need to be transformed
......
......@@ -139,7 +139,7 @@ class FileReader:
self._checkArgsKey("dataPath", str)
if not os.path.exists(self._dataPath):
raise IOError(
raise OSError(
"input data path [%s] not existed!" % (self._dataPath)
)
......@@ -220,7 +220,7 @@ class FileReader:
)
if not os.path.isfile(fileName):
raise IOError("[%s] is not a valid file!" % (fileName))
raise OSError("[%s] is not a valid file!" % (fileName))
try:
prefix_str = fileName.split(sed)[-1]
......@@ -298,7 +298,7 @@ class FileReader:
def getDict(self, name, groupId, gpuId, tmpPath="./tmp"):
fileName = self.getFileName(name, groupId, gpuId, tmpPath)
if not os.path.isfile(fileName):
raise IOError("[%s] is not existed!" % fileName)
raise OSError("[%s] is not existed!" % fileName)
data = {}
with open(fileName, "r") as rf:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册