Skip to content

linenumbers in python inspect are 0-based #819

@nbruin

Description

@nbruin

python's inspect.findsource returns a line number that is 0-based, because the source
file is considered to be a list of lines. sage.misc.sageinspect._extract_embedded_position tries to return similar data, but does so 1-based. We should probably be consistent about how line numbers are handled.

Line numbers SHOULD be 1-based, of course, but we cannot change python's library.

At the same time, python's "inspect" does not have a routine to just give back a line number. It always gives the source itself as well.

Perhaps the solution is to include into sageinspect a routine that gives back file name and line number? The routine "fileandline" included in patch #768 tries to do this. Perhaps it should be included in sageinspect and thus hide the discrepancy between 0- and 1-based line numbers that currently becomes visible because functionality has to be borrowed from both "inspect" and "sageinspect"?

Component: user interface

Issue created by migration from https://trac.sagemath.org/ticket/819

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions