summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2022-03-18 11:43:34 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2022-03-18 11:48:29 +0000
commit1ed006333b576ecfbbfa2ab93a02688de9a4eb07 (patch)
treeb73a1e9bc44f575195a46c05e3bf4b951d5281d8
parentc887488affefb6f83094b28675e91e1153c17978 (diff)
downloadgobject-introspection-1ed006333b576ecfbbfa2ab93a02688de9a4eb07.tar.gz
scanner: Check before accessing an optional field
It seems that optparse might just ignore storing options without a default. In this case, the `--compiler` option should be initialised to `None`, but instead it just gets ignored. Without the `hasattr()` check, updating the introspection data for GLib fails with a Python backtrace.
-rw-r--r--giscanner/scannermain.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 64575557..1d39ab84 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -461,7 +461,8 @@ def create_source_scanner(options, args):
# Run the preprocessor, tokenize and construct simple
# objects representing the raw C symbols
ss = SourceScanner()
- ss.set_compiler(options.compiler)
+ if hasattr(options, 'compiler') and options.compiler:
+ ss.set_compiler(options.compiler)
ss.set_cpp_options(options.cpp_includes,
options.cpp_defines,
options.cpp_undefines,