wf49670 / ppgen

Post-processing generator for DP
6 stars 4 forks source link

Fix issue where ppgen long line warning sometimes cause a crash #74

Closed davem2 closed 9 years ago

davem2 commented 9 years ago

Hi Walt,

I came across this issue today that causes ppgen to crash during processing:

[david@bob the-impending-crisis]$ ppgen -i testbug.txt
ppgen 3.46g
creating Latin-1 text file
**warning: wide line: +-------------------+---------------+----------------+-------------+---------------------+
Traceback (most recent call last):
  File "/home/david/pp/tools/ppgen", line 5580, in <module>
    main()
  File "/home/david/pp/tools/ppgen", line 5560, in main
    ppt.run()
  File "/home/david/pp/tools/ppgen", line 2629, in run
    self.saveLat1(self.outfile) # Latin-1
  File "/home/david/pp/tools/ppgen", line 1669, in saveLat1
    self.warn("long line (>{}) beginning:\n  {}....".format(self.linelimitwarning, m.group(0)))
AttributeError: 'NoneType' object has no attribute 'group'
[david@bob the-impending-crisis]$

testbug.txt contains one line:

+-------------------+---------------+----------------+-------------+---------------------+

The problem is the regex two lines above doesn't consider the line above a match (I think because there is no whitespace until after 60 characters).

m = re.match(r".{0,60}\s", s)

I believe the intention here was to limit the size of the warning message and break on a word boundry. This patch changes this behavior to simple truncate the line at 60 characters.

-David

wf49670 commented 9 years ago

Thanks, David.

Walt