@@ -208,7 +208,27 @@ def _iter_source(lines, *, maxtext=11_000, maxlines=200, showtext=False):
208208 return
209209 # At this point either the file ended prematurely
210210 # or there's "too much" text.
211- filename , lno , text = srcinfo .filename , srcinfo ._start , srcinfo .text
211+ filename , lno_from , lno_to = srcinfo .filename , srcinfo .start , srcinfo .end
212+ text = srcinfo .text
212213 if len (text ) > 500 :
213214 text = text [:500 ] + '...'
214- raise Exception (f'unmatched text ({ filename } starting at line { lno } ):\n { text } ' )
215+
216+ if srcinfo .too_much_text (maxtext ):
217+ msg = [
218+ 'too much text, try to increase MAX_SIZES[MAXTEXT] in cpython/_parser.py' ,
219+ f'{ filename } starting at line { lno_from } to { lno_to } ' ,
220+ f'has code with length { len (text )} greater than { maxtext } :' ,
221+ text
222+ ]
223+ raise Exception ('\n ' .join (msg ))
224+
225+ if srcinfo .too_much_lines (maxlines ):
226+ msg = [
227+ 'too much lines, try to increase MAX_SIZES[MAXLINES] in cpython/_parser.py' ,
228+ f'{ filename } starting at line { lno_from } to { lno_to } ' ,
229+ f'has code with number of lines { lno_to - lno_from } greater than { maxlines } :' ,
230+ text
231+ ]
232+ raise Exception ('\n ' .join (msg ))
233+
234+ raise Exception (f'unmatched text ({ filename } starting at line { lno_from } ):\n { text } ' )
0 commit comments