co_lnotab supports negative line number delta

Issue #26107: The format of the co_lnotab attribute of code objects changes to
support negative line number delta.

Changes:

* assemble_lnotab(): if line number delta is less than -128 or greater than
  127, emit multiple (offset_delta, lineno_delta) in co_lnotab
* update functions decoding co_lnotab to use signed 8-bit integers

  - dis.findlinestarts()
  - PyCode_Addr2Line()
  - _PyCode_CheckLineNumber()
  - frame_setlineno()

* update lnotab_notes.txt
* increase importlib MAGIC_NUMBER to 3361
* document the change in What's New in Python 3.6
* cleanup also PyCode_Optimize() to use better variable names
diff --git a/Python/compile.c b/Python/compile.c
index 0f619c4..f362ac6 100644
--- a/Python/compile.c
+++ b/Python/compile.c
@@ -4452,7 +4452,6 @@
     d_lineno = i->i_lineno - a->a_lineno;
 
     assert(d_bytecode >= 0);
-    assert(d_lineno >= 0);
 
     if(d_bytecode == 0 && d_lineno == 0)
         return 1;
@@ -4482,9 +4481,21 @@
         d_bytecode -= ncodes * 255;
         a->a_lnotab_off += ncodes * 2;
     }
-    assert(d_bytecode <= 255);
-    if (d_lineno > 255) {
-        int j, nbytes, ncodes = d_lineno / 255;
+    assert(0 <= d_bytecode && d_bytecode <= 255);
+
+    if (d_lineno < -128 || 127 < d_lineno) {
+        int j, nbytes, ncodes, k;
+        if (d_lineno < 0) {
+            k = -128;
+            /* use division on positive numbers */
+            ncodes = (-d_lineno) / 128;
+        }
+        else {
+            k = 127;
+            ncodes = d_lineno / 127;
+        }
+        d_lineno -= ncodes * k;
+        assert(ncodes >= 1);
         nbytes = a->a_lnotab_off + 2 * ncodes;
         len = PyBytes_GET_SIZE(a->a_lnotab);
         if (nbytes >= len) {
@@ -4502,15 +4513,15 @@
         lnotab = (unsigned char *)
                    PyBytes_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
         *lnotab++ = d_bytecode;
-        *lnotab++ = 255;
+        *lnotab++ = k;
         d_bytecode = 0;
         for (j = 1; j < ncodes; j++) {
             *lnotab++ = 0;
-            *lnotab++ = 255;
+            *lnotab++ = k;
         }
-        d_lineno -= ncodes * 255;
         a->a_lnotab_off += ncodes * 2;
     }
+    assert(-128 <= d_lineno && d_lineno <= 127);
 
     len = PyBytes_GET_SIZE(a->a_lnotab);
     if (a->a_lnotab_off + 2 >= len) {