Merge pull request #5003 from blueyed/off

Fix off-by-one error with lineno in mark collection error
This commit is contained in:
Daniel Hahler
2019-03-28 00:09:53 +01:00
committed by GitHub
4 changed files with 30 additions and 12 deletions

View File

@@ -203,7 +203,9 @@ def compile_(source, filename=None, mode="exec", flags=0, dont_inherit=0):
def getfslineno(obj):
""" Return source location (path, lineno) for the given object.
If the source cannot be determined return ("", -1)
If the source cannot be determined return ("", -1).
The line number is 0-based.
"""
from .code import Code

View File

@@ -44,7 +44,7 @@ def get_empty_parameterset_mark(config, argnames, func):
f_name = func.__name__
_, lineno = getfslineno(func)
raise Collector.CollectError(
"Empty parameter set in '%s' at line %d" % (f_name, lineno)
"Empty parameter set in '%s' at line %d" % (f_name, lineno + 1)
)
else:
raise LookupError(requested_mark)