diff options
author | Erlend E. Aasland <erlend@python.org> | 2023-08-02 12:40:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 12:40:23 (GMT) |
commit | 9ff7b4af137b8028b04b52addf003c4b0607113b (patch) | |
tree | 70dc9399f7500c12cc115f9047017c19daac2afb /Tools/clinic | |
parent | 439466a02b145b522a8969267264743706336501 (diff) | |
download | cpython-9ff7b4af137b8028b04b52addf003c4b0607113b.zip cpython-9ff7b4af137b8028b04b52addf003c4b0607113b.tar.gz cpython-9ff7b4af137b8028b04b52addf003c4b0607113b.tar.bz2 |
gh-107559: Argument Clinic: complain about non-ASCII chars in param docstrings (#107560)
Previously, only function docstrings were checked for non-ASCII characters.
Also, improve the warn() message.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Tools/clinic')
-rwxr-xr-x | Tools/clinic/clinic.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Tools/clinic/clinic.py b/Tools/clinic/clinic.py index 5f7d41e..1f46166 100755 --- a/Tools/clinic/clinic.py +++ b/Tools/clinic/clinic.py @@ -785,9 +785,6 @@ class CLanguage(Language): self, f: Function ) -> str: - if re.search(r'[^\x00-\x7F]', f.docstring): - warn("Non-ascii character appear in docstring.") - text, add, output = _text_accumulator() # turn docstring into a properly quoted C string for line in f.docstring.split('\n'): @@ -5266,6 +5263,11 @@ class DSLParser: def docstring_append(self, obj: Function | Parameter, line: str) -> None: """Add a rstripped line to the current docstring.""" + matches = re.finditer(r'[^\x00-\x7F]', line) + if offending := ", ".join([repr(m[0]) for m in matches]): + warn("Non-ascii characters are not allowed in docstrings:", + offending) + docstring = obj.docstring if docstring: docstring += "\n" |