python/cpython

Permalink

  1. Fix possibly-unitialized warning in string_parser.c. (GH-21503)

    GCC says
    ```
    ../cpython/Parser/string_parser.c: In function ‘fstring_find_expr’:
    ../cpython/Parser/string_parser.c:404:93: warning: ‘cols’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      404 |     p2->starting_col_offset = p->tok->first_lineno == p->tok->lineno ? t->col_offset + cols : cols;
          |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
    ../cpython/Parser/string_parser.c:384:16: note: ‘cols’ was declared here
      384 |     int lines, cols;
          |                ^~~~
    ../cpython/Parser/string_parser.c:403:45: warning: ‘lines’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      403 |     p2->starting_lineno = t->lineno + lines - 1;
          |                           ~~~~~~~~~~~~~~~~~~^~~
    ../cpython/Parser/string_parser.c:384:9: note: ‘lines’ was declared here
      384 |     int lines, cols;
          |         ^~~~~
    ```
    
    and, indeed, if `PyBytes_AsString` somehow fails, lines & cols will not be initialized.
  1. bpo-41302: Fix build with system libmpdec (GH-21481)

    Move definition of UNUSED from modified headers of libmpdec to
    _decimal.c itself. This makes the vendored source closer to the
    standalone library and fixes build with --with-system-libmpdec.
    
    Tested to build fine with either system libmpdec or the vendored one.