SF bug #1048870:  call arg of lambda not updating
diff --git a/Lib/test/test_compile.py b/Lib/test/test_compile.py
index 5011d03..c567fa4 100644
--- a/Lib/test/test_compile.py
+++ b/Lib/test/test_compile.py
@@ -252,6 +252,15 @@
         for stmt in fail:
             self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'exec')
 
+    def test_for_distinct_code_objects(self):
+        # SF bug 1048870
+        def f():
+            f1 = lambda x=1: x
+            f2 = lambda x=2: x
+            return f1, f2
+        f1, f2 = f()
+        self.assertNotEqual(id(f1.func_code), id(f2.func_code))
+
 def test_main():
     test_support.run_unittest(TestSpecifics)
 
diff --git a/Misc/NEWS b/Misc/NEWS
index e12621d..d0a5af5 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -37,7 +37,10 @@
 Extension Modules
 -----------------
 
-...
+- Bug #1048870:  the compiler now generates distinct code objects for
+  functions with identical bodies.  This was producing confusing
+  traceback messages which pointed to the function where the code
+  object was first defined rather than the function being executed.
 
 Library
 -------
diff --git a/Python/compile.c b/Python/compile.c
index dc636c0..dfb94d3 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -261,6 +261,8 @@
 	if (cmp) return (cmp<0)?-1:1;
 	cmp = co->co_flags - cp->co_flags;
 	if (cmp) return (cmp<0)?-1:1;
+	cmp = co->co_firstlineno - cp->co_firstlineno;
+	if (cmp) return (cmp<0)?-1:1;
 	cmp = PyObject_Compare(co->co_code, cp->co_code);
 	if (cmp) return cmp;
 	cmp = PyObject_Compare(co->co_consts, cp->co_consts);