Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve warnings seen in SWIG generation reporting use of Python keywords and name conflicts. Re-enable -Werror flag. #155

Open
gapisback opened this issue Jul 19, 2023 · 0 comments
Assignees
Labels
code-cleanup Minor code cleanup changes, to simplify, improve code. No logic changes.

Comments

@gapisback
Copy link
Collaborator

gapisback commented Jul 19, 2023

With the introduction of new policy_store (under PR #151) and the integration with SWIG-support to generate Python bindings (PR #144), we are now seeing warnings generated from the make step that issues swig. Here is an example:

Generating certifier_framework_wrap.cc
swig -v -python -c++ -Wall -interface libcertifier_framework -o ./certifier_framework_wrap.cc ../include/certifier_framework.i
Language subdirectory: python
Search paths:
   ./
   ./swig_lib/python/
   /usr/share/swig4.0/python/
   ./swig_lib/
   /usr/share/swig4.0/
Preprocessing...
Starting language-specific parse...
../include/certifier_framework.h:48: Warning 314: 'print' is a python keyword, renaming to '_print'         ... [1]
../include/certifier_framework.h:77: Warning 321: 'type' conflicts with a built-in name in python              ... [2]
../include/certifier_framework.h:89: Warning 314: 'print' is a python keyword, renaming to '_print'          ... [3]
Processing types...
C++ analysis...

During dev of the Python bindings, swig was invoked with -Wall -Werror flags. Due to the use of -Werror flag, above warnings caused the build to fail.

A short-term workaround has been implemented in src/certifier.mak to not use -Werror. We do get the warning messages, but the build itself succeeds with 0 $rc.

Longer-term, it is better to use both flags, so that any Python / C++ wrapper integration issues are spotted and caught early on.

We need to resolve above warnings so that -Werror can be re-enabled.

---- (7/20/2023: Update) Another issue seem due to name of print() method is this pylint error:

cc-sdb-vm:[89] $ PYTHONPATH=../../ pylint *.py
************* Module pytests.test_certifier_framework
test_certifier_framework.py:30:4: W0212: Access to a protected member _print of a client class (protected-access)
test_certifier_framework.py:67:4: W0212: Access to a protected member _print of a client class (protected-access)

A w/a fix for this has been implemented in build.yml to use pylint --disable W0212. That can be removed once this name-issue is resolved.


Potential solutions, some need to be further investigated:

  • Use warning-suppression Swig-directives to avoid [1] and [2]. But these didn't work in presence of -Werror.
  • Rename these print methods to, say, print_entry() and print_store().
  • Rename policy_store{} methods to, say, entry_type() and entry_tag()
@gapisback gapisback self-assigned this Jul 19, 2023
@gapisback gapisback added the code-cleanup Minor code cleanup changes, to simplify, improve code. No logic changes. label Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-cleanup Minor code cleanup changes, to simplify, improve code. No logic changes.
Projects
None yet
Development

No branches or pull requests

1 participant