Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit883cb23

Browse files
[3.13]gh-128152: Argument Clinic: ignore pre-processor directives inside C comments (GH-128464) (#128478)
(cherry picked from commita4e773c)Co-authored-by: Erlend E. Aasland <erlend@python.org>
1 parent855af3b commit883cb23

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

‎Lib/test/test_clinic.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,16 @@ def test_cloned_forced_text_signature_illegal(self):
731731
err="Cannot use @text_signature when cloning a function"
732732
self.expect_failure(block,err,lineno=11)
733733

734+
deftest_ignore_preprocessor_in_comments(self):
735+
fordslin"clinic","python":
736+
raw=dedent(f"""\
737+
/*[{dsl} input]
738+
# CPP directives, valid or not, should be ignored in C comments.
739+
#
740+
[{dsl} start generated code]*/
741+
""")
742+
self.clinic.parse(raw)
743+
734744

735745
classParseFileUnitTest(TestCase):
736746
defexpect_parsing_failure(
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix a bug where Argument Clinic's C pre-processor parser tried to parse
2+
pre-processor directives inside C comments. Patch by Erlend Aasland.

‎Tools/clinic/libclinic/cpp.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ def pop_stack() -> TokenAndCondition:
132132
ifline_comment:
133133
line=before.rstrip()
134134

135+
ifself.in_comment:
136+
return
137+
135138
ifnotline.startswith('#'):
136139
return
137140

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp