bpo-42823: Fix frame lineno when frame.f_trace is set (GH-24099)

* Add test for frame.f_lineno with/without tracing.

* Make sure that frame.f_lineno is correct regardless of whether frame.f_trace is set.

* Update importlib

* Add NEWS
diff --git a/Objects/codeobject.c b/Objects/codeobject.c
index 0b0b8f9..f7613e8 100644
--- a/Objects/codeobject.c
+++ b/Objects/codeobject.c
@@ -1261,7 +1261,8 @@ PyLineTable_InitAddressRange(char *linetable, int firstlineno, PyCodeAddressRang
     range->lo_next = linetable;
     range->ar_start = -1;
     range->ar_end = 0;
-    range->ar_computed_line = range->ar_line = firstlineno;
+    range->ar_computed_line = firstlineno;
+    range->ar_line = -1;
 }
 
 int
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 787cd8b..4c5eaa2 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -44,7 +44,7 @@ int
 PyFrame_GetLineNumber(PyFrameObject *f)
 {
     assert(f != NULL);
-    if (f->f_trace) {
+    if (f->f_lineno != 0) {
         return f->f_lineno;
     }
     else {
@@ -476,8 +476,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignore
         start_block_stack = pop_block(start_block_stack);
     }
 
-    /* Finally set the new f_lineno and f_lasti and return OK. */
-    f->f_lineno = new_lineno;
+    /* Finally set the new f_lasti and return OK. */
+    f->f_lineno = 0;
     f->f_lasti = best_addr;
     return 0;
 }
@@ -498,11 +498,9 @@ frame_gettrace(PyFrameObject *f, void *closure)
 static int
 frame_settrace(PyFrameObject *f, PyObject* v, void *closure)
 {
-    /* We rely on f_lineno being accurate when f_trace is set. */
-    f->f_lineno = PyFrame_GetLineNumber(f);
-
-    if (v == Py_None)
+    if (v == Py_None) {
         v = NULL;
+    }
     Py_XINCREF(v);
     Py_XSETREF(f->f_trace, v);