diff options
author | Armin Rigo <arigo@tunes.org> | 2019-06-19 11:59:57 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2019-06-19 11:59:57 +0200 |
commit | a5452f15828d44fa18bec4f4b849efcd2255b37f (patch) | |
tree | 50feeb0655c728bce0454f6d9d29c53a1d6726f0 /cffi | |
parent | 3b94e9f046b014c07902a26ad722fed56292bf36 (diff) | |
download | cffi-a5452f15828d44fa18bec4f4b849efcd2255b37f.tar.gz |
(brendan on mailing list) Ignore preprocessor stuff when looking for '"'
Diffstat (limited to 'cffi')
-rw-r--r-- | cffi/cparser.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cffi/cparser.py b/cffi/cparser.py index e8ea23a..9cb3412 100644 --- a/cffi/cparser.py +++ b/cffi/cparser.py @@ -145,12 +145,16 @@ def _preprocess_extern_python(csource): return ''.join(parts) def _warn_for_string_literal(csource): - if '"' in csource: - import warnings - warnings.warn("String literal found in cdef() or type source. " - "String literals are ignored here, but you should " - "remove them anyway because some character sequences " - "confuse pre-parsing.") + if '"' not in csource: + return + for line in csource.splitlines(): + if '"' in line and not line.lstrip().startswith('#'): + import warnings + warnings.warn("String literal found in cdef() or type source. " + "String literals are ignored here, but you should " + "remove them anyway because some character sequences " + "confuse pre-parsing.") + break def _preprocess(csource): # Remove comments. NOTE: this only work because the cdef() section |