[issue2198] code_hash() can be the same for different code objects

Alexander Belopolsky report at bugs.python.org
Mon Mar 3 21:55:02 CET 2008

Alexander Belopolsky added the comment:

I would say filename/lineno are excluded from hash on purpose because
they are ignored in comparisons:

>>> compile("0", "a", "eval") == compile("0", "b", "eval")

Include/code.h has the following comment:

   /* The rest doesn't count for hash/cmp */ 
    PyObject *co_filename;      /* string (where it was loaded from) */ 
    PyObject *co_name;          /* string (name, for reference) */ 
    int co_firstlineno;         /* first source line number */ 

Can you describe your specific problem in more detail?  Why does your
debugger need to hash/compare code objects?

nosy: +belopolsky

Tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list