Skip to content

Code objects with non-equal co_linetables compare equal #95150

Closed
@15r10nk

Description

@15r10nk

Bug report

def f(a, b):
    return dict((k.lower(), v) for k, v in a.items()) == dict(
        (k.lower(), v) for k, v in b.items()
    )

f({"a": 5}, {1: 1})

output:

Traceback (most recent call last):
  File "/home/frank/projects/executing/test8.py", line 8, in <module>
    f({"a": 5}, {1: 1})
  File "/home/frank/projects/executing/test8.py", line 2, in f
    return dict((k.lower(), v) for k, v in a.items()) == dict(
                                                         ^^^^^
  File "/home/frank/projects/executing/test8.py", line 2, in <genexpr>
    return dict((k.lower(), v) for k, v in a.items()) == dict(
                 ^^^^^^^
AttributeError: 'int' object has no attribute 'lower'

The error should be reported at line 3 and not at line 2, because the integer is passed to b

Your environment

  • current cpython 3.11 branch (3a33e9b)
  • and the Python 3.11.0b4

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.11only security fixes3.12only security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)release-blockertriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions