Skip to content

Commit 2951c59

Browse files
committed
Check for linenum being None in Node.warn
This might happen when emitting a warning on PyPy
1 parent d9a2e70 commit 2951c59

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

_pytest/main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ def warn(self, code, message):
310310
if fslocation is None:
311311
fslocation = getattr(self, "fspath", None)
312312
else:
313-
fslocation = "%s:%s" % (fslocation[0], fslocation[1] + 1)
313+
path, linenum = fslocation
314+
if linenum is not None:
315+
linenum += 1
316+
fslocation = "%s:%s" % (path, linenum)
314317

315318
self.ihook.pytest_logwarning.call_historic(kwargs=dict(
316319
code=code, message=message,

0 commit comments

Comments
 (0)