This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [AST] distinct code objects not created
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: brett.cannon Nosy List: brett.cannon, ncoghlan
Priority: normal Keywords:

Created on 2005-04-26 06:10 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ast_code_object_first_line_cmp.diff ncoghlan, 2005-05-28 12:11 Compare first line number when comparing code objects
Messages (5)
msg25125 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-04-26 06:10
>> def f(): return ((lambda x=1: x), (lambda x=2: x))
>> f1, f2 = f()
>> id(f1.func_code) != id(f2.func_code)

The above does not hold true.  It should according to
test_compile (reported in HEAD as bug #1048870).
msg25126 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2005-05-28 08:26
Logged In: YES 
user_id=1038590

This seems to be the least of lambda's problems. A number of
regression tests currently fail with UnboundLocalErrors,
after an argument of the form "lambda (x, y): x" is passed
to a function for invocation.

Assigning to myself, since I'm about to take a look at the
current misbehaviour of lambdas (they must be simpler than
genexps, right?)
msg25127 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2005-05-28 11:02
Logged In: YES 
user_id=1038590

For the code above, Python 2.4.1 actually generates a single
code object (that is, the comparison returns False).

Looking closer at 1048870, this is expected, as the two
lambdas are created on the same line. I'll look into this on
the AST branch - I suspect the culprit may be our problems
with getting the line numbering right.

(FWIW, I worked out the UnboundLocal problem, and followed
it up in the relevant bug, 1186353)
msg25128 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2005-05-28 12:11
Logged In: YES 
user_id=1038590

The same fix mwh used for HEAD appears to work for the AST 
branch, too (it's just in a different source file). Patch attached, and 
kicking in Brett's direction for review. 
msg25129 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-07-11 03:37
Logged In: YES 
user_id=357491

Looks fine to me.  Checked in as rev. 1.1.2.3 . 
test_compile now passes!
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 41900
2005-04-26 06:10:10brett.cannoncreate