Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Column info near attribute/method lookups is sometimes incorrect #94036

Closed
Assignees
brandtbucher
Labels
3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error
@brandtbucher

Description

@brandtbucher

We perform some manual fiddling with positions for attribute lookups at afewdifferentpoints in the compiler. However, the extended position information for these locations can be nonsensical in some edge cases. Here is one (admittedly contrived) example:

>>>deffoo():...     (bar....baz)...>>>forinstructionindis.get_instructions(foo):...print(instruction.positions,instruction.opname)...Positions(lineno=1,end_lineno=1,col_offset=0,end_col_offset=0)RESUMEPositions(lineno=2,end_lineno=2,col_offset=5,end_col_offset=8)LOAD_GLOBALPositions(lineno=3,end_lineno=3,col_offset=5,end_col_offset=3)LOAD_ATTRPositions(lineno=3,end_lineno=3,col_offset=5,end_col_offset=3)POP_TOPPositions(lineno=3,end_lineno=3,col_offset=5,end_col_offset=3)LOAD_CONSTPositions(lineno=3,end_lineno=3,col_offset=5,end_col_offset=3)RETURN_VALUE

The last four instructions claim to be located on line 3, starting with at column 5 and ending at column 3 (which doesn't make sense).

A slight variation (using a method call) is even weirder:

>>>deffoo():...     (bar....baz(... ))...>>>forinstructionindis.get_instructions(foo):...print(instruction.positions,instruction.opname)...Positions(lineno=1,end_lineno=1,col_offset=0,end_col_offset=0)RESUMEPositions(lineno=2,end_lineno=2,col_offset=5,end_col_offset=8)LOAD_GLOBALPositions(lineno=3,end_lineno=3,col_offset=None,end_col_offset=None)LOAD_ATTRPositions(lineno=3,end_lineno=4,col_offset=None,end_col_offset=1)CALLPositions(lineno=3,end_lineno=4,col_offset=None,end_col_offset=1)POP_TOPPositions(lineno=3,end_lineno=4,col_offset=None,end_col_offset=1)LOAD_CONSTPositions(lineno=3,end_lineno=4,col_offset=None,end_col_offset=1)RETURN_VALUE

Here thecol_offset is totally nonexistent, even in cases whereend_col_offset is set! I suspect that this may be because the column math just happened to underflow the valid column range (>=0) and end up at-1, which is a special value we use to mean "missing".

@markshannon@pablogsal

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp