Skip to content

gh-133158: Adjust c-analyzer max_sizes for typeobject.c #133159

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extend error messages if too much code to c-analyzer
  • Loading branch information
sergey-miryanov committed Apr 30, 2025
commit 45be756b3dd96b5fd0902dab825badad4c28913c
24 changes: 22 additions & 2 deletions Tools/c-analyzer/c_parser/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,27 @@ def _iter_source(lines, *, maxtext=11_000, maxlines=200, showtext=False):
return
# At this point either the file ended prematurely
# or there's "too much" text.
filename, lno, text = srcinfo.filename, srcinfo._start, srcinfo.text
filename, lno_from, lno_to = srcinfo.filename, srcinfo.start, srcinfo.end
text = srcinfo.text
if len(text) > 500:
text = text[:500] + '...'
raise Exception(f'unmatched text ({filename} starting at line {lno}):\n{text}')

if srcinfo.too_much_text(maxtext):
msg = [
'too much text, try to increase MAX_SIZES[MAXTEXT] in cpython/_parser.py',
f'{filename} starting at line {lno_from} to {lno_to}',
f'has code with length {len(text)} greater than {maxtext}:',
text
]
raise Exception('\n'.join(msg))

if srcinfo.too_much_lines(maxlines):
msg = [
'too much lines, try to increase MAX_SIZES[MAXLINES] in cpython/_parser.py',
f'{filename} starting at line {lno_from} to {lno_to}',
f'has code with number of lines {lno_to - lno_from} greater than {maxlines}:',
text
]
raise Exception('\n'.join(msg))

raise Exception(f'unmatched text ({filename} starting at line {lno_from}):\n{text}')
10 changes: 8 additions & 2 deletions Tools/c-analyzer/c_parser/parser/_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,16 @@ def resolve(self, kind, data, name, parent=None):
def done(self):
self._set_ready()

def too_much_text(self, maxtext):
return maxtext and len(self.text) > maxtext

def too_much_lines(self, maxlines):
return maxlines and self.end - self.start > maxlines

def too_much(self, maxtext, maxlines):
if maxtext and len(self.text) > maxtext:
if self.too_much_text(maxtext):
pass
elif maxlines and self.end - self.start > maxlines:
elif self.too_much_lines(maxlines):
pass
else:
return False
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy