mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
multiline KeyError msg python bug workaround (#18557)
Summary: make multiline KeyError msg readable by working around a python bug https://bugs.python.org/issue2651 discussion: https://github.com/pytorch/pytorch/issues/16647 Pull Request resolved: https://github.com/pytorch/pytorch/pull/18557 Differential Revision: D14681086 Pulled By: soumith fbshipit-source-id: acbd13a823302c854c3d364028ed414fd8ce6bc8
This commit is contained in:
committed by
Facebook Github Bot
parent
95d3825e48
commit
c0a2452ffe
@ -569,7 +569,12 @@ class _DataLoaderIter(object):
|
||||
self.rcvd_idx += 1
|
||||
self._put_indices()
|
||||
if isinstance(batch, _utils.ExceptionWrapper):
|
||||
raise batch.exc_type(batch.exc_msg)
|
||||
# make multiline KeyError msg readable by working around
|
||||
# a python bug https://bugs.python.org/issue2651
|
||||
if batch.exc_type == KeyError and "\n" in batch.exc_msg:
|
||||
raise Exception("KeyError:" + batch.exc_msg)
|
||||
else:
|
||||
raise batch.exc_type(batch.exc_msg)
|
||||
return batch
|
||||
|
||||
def __getstate__(self):
|
||||
|
Reference in New Issue
Block a user