summaryrefslogtreecommitdiff
path: root/sphinx/directives/code.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-05 01:28:15 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-05 01:28:15 +0900
commitb268963709dc9256cf711d4cc054a86e70226702 (patch)
treed45c1f1954b677f8d21c8dab1593ef7be4e6e037 /sphinx/directives/code.py
parenteb07b070e468025c91c8c4adc615effcb62f8057 (diff)
parent05c65163ecd0ce7bdb7c6807de683266b98e5b28 (diff)
downloadsphinx-git-b268963709dc9256cf711d4cc054a86e70226702.tar.gz
Merge commit '05c65163ecd0ce7bdb7c6807de683266b98e5b28'
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r--sphinx/directives/code.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index fabf259e8..b79950ea4 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -215,12 +215,13 @@ class LiteralIncludeReader:
text = text.expandtabs(self.options['tab-width'])
return text.splitlines(True)
- except OSError:
- raise OSError(__('Include file %r not found or reading it failed') % filename)
- except UnicodeError:
+ except OSError as exc:
+ raise OSError(__('Include file %r not found or reading it failed') %
+ filename) from exc
+ except UnicodeError as exc:
raise UnicodeError(__('Encoding %r used for reading included file %r seems to '
'be wrong, try giving an :encoding: option') %
- (self.encoding, filename))
+ (self.encoding, filename)) from exc
def read(self, location: Tuple[str, int] = None) -> Tuple[str, int]:
if 'diff' in self.options: