summaryrefslogtreecommitdiff
path: root/sphinx/directives/code.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r--sphinx/directives/code.py17
1 files changed, 8 insertions, 9 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index 41a593aa3..4d7e7a48d 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -256,7 +256,7 @@ class LiteralIncludeReader(object):
else:
start = tags[pyobject][1]
end = tags[pyobject][2]
- lines = lines[start - 1:end - 1]
+ lines = lines[start - 1:end]
if 'lineno-match' in self.options:
self.lineno_start = start
@@ -311,11 +311,11 @@ class LiteralIncludeReader(object):
self.lineno_start += lineno
return lines[lineno:]
+
+ if inclusive is True:
+ raise ValueError('start-after pattern not found: %s' % start)
else:
- if inclusive is True:
- raise ValueError('start-after pattern not found: %s' % start)
- else:
- raise ValueError('start-at pattern not found: %s' % start)
+ raise ValueError('start-at pattern not found: %s' % start)
return lines
@@ -340,11 +340,10 @@ class LiteralIncludeReader(object):
return []
else:
return lines[:lineno]
+ if inclusive is True:
+ raise ValueError('end-at pattern not found: %s' % end)
else:
- if inclusive is True:
- raise ValueError('end-at pattern not found: %s' % end)
- else:
- raise ValueError('end-before pattern not found: %s' % end)
+ raise ValueError('end-before pattern not found: %s' % end)
return lines