classification
Title: test_peg_generator compilation warnings
Type: Stage: resolved
Components: Tests Versions: Python 3.10
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: lys.nikolaou, pablogsal, skip.montanaro
Priority: normal Keywords: patch

Created on 2020-09-21 17:56 by skip.montanaro, last changed 2020-10-03 14:33 by pablogsal. This issue is now closed.

Files
File name Uploaded Description Edit
test_peg_gen.diff skip.montanaro, 2020-09-25 11:47
Pull Requests
URL Status Linked Edit
PR 22412 closed skip.montanaro, 2020-09-25 20:19
PR 22455 merged pablogsal, 2020-09-29 21:43
Messages (7)
msg377265 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2020-09-21 17:56
I don't see anything like this while building Python proper, but when test_peg_generator is run, it spews a few compiler warnings. Platform is Ubuntu 20.04. Seems low-ish priority, but I saw no mention of it in a quick bpo search, so thought I would toss it out there.

-------------------------------------------------
% ./python ./Tools/scripts/run_tests.py test_peg_generator
/home/skip/src/python/cpython/python -u -W default -bb -E -m test -r -w -j 0 -u all,-largefile,-audio,-gui test_peg_generator
Using random seed 1793668
0:00:00 load avg: 0.09 Run tests in parallel using 10 child processes
0:00:30 load avg: 0.45 running: test_peg_generator (30.0 sec)
0:00:54 load avg: 0.64 [1/1] test_peg_generator passed (54.8 sec)
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmp3fq3wryo/parse.c:2:
/tmp/tmp3fq3wryo/parse.c: In function ‘start_rule’:
/tmp/tmp3fq3wryo/parse.c:59:29: warning: passing argument 1 of ‘_Py_Module’ from incompatible pointer type [-Wincompatible-pointer-types]
   59 |             _res = Module ( a , NULL , p -> arena );
      |                             ^
      |                             |
      |                             asdl_seq * {aka struct <anonymous> *}
/home/skip/src/python/cpython/Include/Python-ast.h:541:39: note: in definition of macro ‘Module’
  541 | #define Module(a0, a1, a2) _Py_Module(a0, a1, a2)
      |                                       ^~
/home/skip/src/python/cpython/Include/Python-ast.h:542:35: note: expected ‘asdl_stmt_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  542 | mod_ty _Py_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
      |                   ~~~~~~~~~~~~~~~~^~~~
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmpybnujtsb/parse.c:2:
/tmp/tmpybnujtsb/parse.c: In function ‘start_rule’:
/tmp/tmpybnujtsb/parse.c:61:29: warning: passing argument 1 of ‘_Py_Module’ from incompatible pointer type [-Wincompatible-pointer-types]
   61 |             _res = Module ( a , NULL , p -> arena );
      |                             ^
      |                             |
      |                             asdl_seq * {aka struct <anonymous> *}
/home/skip/src/python/cpython/Include/Python-ast.h:541:39: note: in definition of macro ‘Module’
  541 | #define Module(a0, a1, a2) _Py_Module(a0, a1, a2)
      |                                       ^~
/home/skip/src/python/cpython/Include/Python-ast.h:542:35: note: expected ‘asdl_stmt_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  542 | mod_ty _Py_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
      |                   ~~~~~~~~~~~~~~~~^~~~
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmpgbehpd3_/parse.c:2:
/tmp/tmpgbehpd3_/parse.c: In function ‘start_rule’:
/tmp/tmpgbehpd3_/parse.c:77:29: warning: passing argument 1 of ‘_Py_Module’ from incompatible pointer type [-Wincompatible-pointer-types]
   77 |             _res = Module ( a , NULL , p -> arena );
      |                             ^
      |                             |
      |                             asdl_seq * {aka struct <anonymous> *}
/home/skip/src/python/cpython/Include/Python-ast.h:541:39: note: in definition of macro ‘Module’
  541 | #define Module(a0, a1, a2) _Py_Module(a0, a1, a2)
      |                                       ^~
/home/skip/src/python/cpython/Include/Python-ast.h:542:35: note: expected ‘asdl_stmt_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  542 | mod_ty _Py_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
      |                   ~~~~~~~~~~~~~~~~^~~~
/tmp/tmpgbehpd3_/parse.c: In function ‘import_from_rule’:
/tmp/tmpgbehpd3_/parse.c:148:58: warning: passing argument 2 of ‘_Py_ImportFrom’ from incompatible pointer type [-Wincompatible-pointer-types]
  148 |             _res = _Py_ImportFrom ( c -> v . Name . id , d , 0 , EXTRA );
      |                                                          ^
      |                                                          |
      |                                                          asdl_seq * {aka struct <anonymous> *}
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmpgbehpd3_/parse.c:2:
/home/skip/src/python/cpython/Include/Python-ast.h:625:60: note: expected ‘asdl_alias_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  625 | stmt_ty _Py_ImportFrom(identifier module, asdl_alias_seq * names, int level,
      |                                           ~~~~~~~~~~~~~~~~~^~~~~
/tmp/tmpgbehpd3_/parse.c:190:44: warning: passing argument 2 of ‘_Py_ImportFrom’ from incompatible pointer type [-Wincompatible-pointer-types]
  190 |             _res = _Py_ImportFrom ( NULL , c , 1 , EXTRA );
      |                                            ^
      |                                            |
      |                                            asdl_seq * {aka struct <anonymous> *}
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmpgbehpd3_/parse.c:2:
/home/skip/src/python/cpython/Include/Python-ast.h:625:60: note: expected ‘asdl_alias_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  625 | stmt_ty _Py_ImportFrom(identifier module, asdl_alias_seq * names, int level,
      |                                           ~~~~~~~~~~~~~~~~~^~~~~
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmplmi91q5h/parse.c:2:
/tmp/tmplmi91q5h/parse.c: In function ‘start_rule’:
/tmp/tmplmi91q5h/parse.c:69:29: warning: passing argument 1 of ‘_Py_Module’ from incompatible pointer type [-Wincompatible-pointer-types]
   69 |             _res = Module ( a , NULL , p -> arena );
      |                             ^
      |                             |
      |                             asdl_seq * {aka struct <anonymous> *}
/home/skip/src/python/cpython/Include/Python-ast.h:541:39: note: in definition of macro ‘Module’
  541 | #define Module(a0, a1, a2) _Py_Module(a0, a1, a2)
      |                                       ^~
/home/skip/src/python/cpython/Include/Python-ast.h:542:35: note: expected ‘asdl_stmt_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  542 | mod_ty _Py_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
      |                   ~~~~~~~~~~~~~~~~^~~~
/tmp/tmplmi91q5h/parse.c: In function ‘listcomp_rule’:
/tmp/tmplmi91q5h/parse.c:199:39: warning: passing argument 2 of ‘_Py_ListComp’ from incompatible pointer type [-Wincompatible-pointer-types]
  199 |             _res = _Py_ListComp ( b , c , EXTRA );
      |                                       ^
      |                                       |
      |                                       asdl_seq * {aka struct <anonymous> *}
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmplmi91q5h/parse.c:2:
/home/skip/src/python/cpython/Include/Python-ast.h:676:60: note: expected ‘asdl_comprehension_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  676 | expr_ty _Py_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/tmp/tmplmi91q5h/parse.c: In function ‘_tmp_2_rule’:
/tmp/tmplmi91q5h/parse.c:385:110: warning: passing argument 3 of ‘_Py_comprehension’ from incompatible pointer type [-Wincompatible-pointer-types]
  385 |             _res = _Py_comprehension ( _Py_Name ( ( ( expr_ty ) a ) -> v . Name . id , Store , EXTRA ) , b , c , ( y == NULL ) ? 0 : 1 , p -> arena );
      |                                                                                                              ^
      |                                                                                                              |
      |                                                                                                              asdl_seq * {aka struct <anonymous> *}
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmplmi91q5h/parse.c:2:
/home/skip/src/python/cpython/Include/Python-ast.h:748:38: note: expected ‘asdl_expr_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  747 | comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq
      |                                                                  ~~~~~~~~~~~~~
  748 |                                    * ifs, int is_async, PyArena *arena);
      |                                    ~~^~~
/tmp/tmpmg0f1xoj/parse.c: In function ‘with_stmt_rule’:
/tmp/tmpmg0f1xoj/parse.c:270:31: warning: passing argument 1 of ‘_Py_With’ from incompatible pointer type [-Wincompatible-pointer-types]
  270 |             _res = _Py_With ( b , _PyPegen_singleton_seq ( p , c ) , NULL , EXTRA );
      |                               ^
      |                               |
      |                               asdl_seq * {aka struct <anonymous> *}
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmpmg0f1xoj/parse.c:2:
/home/skip/src/python/cpython/Include/Python-ast.h:603:38: note: expected ‘asdl_withitem_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  603 | stmt_ty _Py_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
      |                  ~~~~~~~~~~~~~~~~~~~~^~~~~
/tmp/tmpmg0f1xoj/parse.c:270:35: warning: passing argument 2 of ‘_Py_With’ from incompatible pointer type [-Wincompatible-pointer-types]
  270 |             _res = _Py_With ( b , _PyPegen_singleton_seq ( p , c ) , NULL , EXTRA );
      |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                   |
      |                                   asdl_seq * {aka struct <anonymous> *}
In file included from /home/skip/src/python/cpython/Parser/pegen.h:7,
                 from /tmp/tmpmg0f1xoj/parse.c:2:
/home/skip/src/python/cpython/Include/Python-ast.h:603:61: note: expected ‘asdl_stmt_seq *’ {aka ‘struct <anonymous> *’} but argument is of type ‘asdl_seq *’ {aka ‘struct <anonymous> *’}
  603 | stmt_ty _Py_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
      |                                             ~~~~~~~~~~~~~~~~^~~~

== Tests result: SUCCESS ==

1 test OK.

Total duration: 55.0 sec
Tests result: SUCCESS
msg377271 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-09-21 19:06
This is because the types of the grammars in Lib/test/test_peg_generator/test_c_parser.py needs to be updated to use the new sequences
msg377382 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2020-09-23 13:09
> This is because the types of the grammars in
Lib/test/test_peg_generator/test_c_parser.py needs to be updated to use the
new sequences

I'm sorry, that doesn't mean much to me. Is it simply a matter of applying
suitable casts to the various parameters in the C code fragments in those?
For example:

*** /tmp/ediffGoXpTW 2020-09-23 08:06:38.671061988 -0500
---
/home/skip/src/python/cpython/Lib/test/test_peg_generator/test_c_parser.py
2020-09-21 15:54:43.106258797 -0500
***************
*** 325,331 ****
          compound_stmt[stmt_ty]: with_stmt
          with_stmt[stmt_ty]: (
              a='with' '(' b=','.with_item+ ')' ':' c=block {
!                 _Py_With(b, _PyPegen_singleton_seq(p, c), NULL, EXTRA) }
          )
          with_item[withitem_ty]: (
              e=NAME o=['as' t=NAME { t }] { _Py_withitem(e,
_PyPegen_set_expr_context(p, o, Store), p->arena) }
--- 325,331 ----
          compound_stmt[stmt_ty]: with_stmt
          with_stmt[stmt_ty]: (
              a='with' '(' b=','.with_item+ ')' ':' c=block {
!                 _Py_With((asdl_withitem_seq *)b, *(asdl_stmt_seq
*)*_PyPegen_singleton_seq(p,
c), NULL, EXTRA) }
          )
          with_item[withitem_ty]: (
              e=NAME o=['as' t=NAME { t }] { _Py_withitem(e,
_PyPegen_set_expr_context(p, o, Store), p->arena) }

If so, that's pretty mechanical. Even a dummy like me could produce a patch.
msg377429 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-09-23 22:33
> I'm sorry, that doesn't mean much to me. Is it simply a matter of applying
suitable casts to the various parameters in the C code fragments in those?

Yep, and in the capture variables and in the rule types. Check https://github.com/python/cpython/pull/22223 for more info (changes in Grammar/python.gram file).
msg377487 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2020-09-25 11:47
Possible patch. All this does is add some C casts. @pablogsal suggested there was more to be done, but my glance at the reference he gave suggested that's already been done. My apologies if I misinterpreted his reference.
msg377507 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2020-09-25 20:23
I created a PR from my patch, but it includes all the merges to my smontanaro/cpython master branch from python/cpython. I thought I was following the instructions properly (https://devguide.python.org/gitbootcamp/#creating-a-pull-request), but I guess I'm missing something. See:

https://github.com/python/cpython/pull/22412

Can someone help me make a PR which only differs from the current python/cpython master?
msg377881 - (view) Author: Lysandros Nikolaou (lys.nikolaou) * (Python committer) Date: 2020-10-03 14:28
New changeset c111355480ff51b50a671679c5099f534cb01cae by Pablo Galindo in branch 'master':
bpo-41826: Fix compiler warnings in test_peg_generator (GH-22455)
https://github.com/python/cpython/commit/c111355480ff51b50a671679c5099f534cb01cae
History
Date User Action Args
2020-10-03 14:33:07pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-10-03 14:28:59lys.nikolaousetnosy: + lys.nikolaou
messages: + msg377881
2020-09-29 21:43:53pablogsalsetpull_requests: + pull_request21484
2020-09-25 20:23:32skip.montanarosetmessages: + msg377507
2020-09-25 20:19:29skip.montanarosetstage: patch review
pull_requests: + pull_request21450
2020-09-25 11:47:05skip.montanarosetfiles: + test_peg_gen.diff
keywords: + patch
messages: + msg377487
2020-09-23 22:33:21pablogsalsetmessages: + msg377429
2020-09-23 13:09:09skip.montanarosetmessages: + msg377382
2020-09-21 19:06:56pablogsalsetmessages: + msg377271
2020-09-21 18:35:03xtreaksetnosy: + pablogsal
2020-09-21 17:56:12skip.montanarocreate