parseListOfPoints sometimes has empty "nums"

Bug #1075592 reported by Sébastien Pierre
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Scour
Fix Released
Undecided
Patrick Storz

Bug Description

I get the following traceback

```
scour.py -i lib/images/cover-chapter-2.svg -o build/lib/images/cover-chapter-2.svg --remove-metadata --quiet
Traceback (most recent call last):
  File "/home/sebastien/Local/share/scour/scour.py", line 3183, in <module>
    out_string = scourString(in_string, options).encode("UTF-8")
  File "/home/sebastien/Local/share/scour/scour.py", line 2952, in scourString
    cleanPolygon(polygon, options)
  File "/home/sebastien/Local/share/scour/scour.py", line 2164, in cleanPolygon
    pts = parseListOfPoints(elem.getAttribute('points'))
  File "/home/sebastien/Local/share/scour/scour.py", line 2136, in parseListOfPoints
    prev = nums[len(nums)-1]
IndexError: list index out of range
```

and the following fixes it

```
diff scour-fixed.py scour.py
2136,2141c2136,2138
< if len(nums) > 0:
< prev = nums[len(nums)-1]
< if prev[len(prev)-1] in ['e', 'E']:
< nums[len(nums)-1] = prev + '-' + negcoords[j]
< else:
< nums.append( '-'+negcoords[j] )
---
> prev = nums[len(nums)-1]
> if prev[len(prev)-1] in ['e', 'E']:
> nums[len(nums)-1] = prev + '-' + negcoords[j]
```

Revision history for this message
Sébastien Pierre (sebastien-type-z) wrote :
Revision history for this message
Louis Simard (louis-simard-deactivatedaccount) wrote :

cynthia@alakazam ~/scour/scour$ ./scour.py -i ~/temp/cover-chapter-2.svg -o ~/temp/cover-chapter-2.opt.svg --remove-metadata --quiet
cynthia@alakazam ~/scour/scour$ ./scour.py --version
0.26
cynthia@alakazam ~/scour/scour$ ls -la ~/temp/cover*
-rw-rw-r-- 1 cynthia cynthia 26918 Nov 6 13:55 /home/cynthia/temp/cover-chapter-2.opt.svg
-rw-rw-r-- 1 cynthia cynthia 32477 Nov 6 13:53 /home/cynthia/temp/cover-chapter-2.svg

I'm not positive this bug still occurs. What version of Scour are you running, and is it the latest code in the Bazaar repository? (See Code, above in Launchpad, to know how to get the code freom Bazaar.)

Revision history for this message
Chris Horn (u-chris-k) wrote :

I'm using 0.26 and see this error, as well.

$ python ~/Applications/scour/scour.py -i oak-color.svg -o output.svg
scour 0.26
Copyright Jeff Schiller, Louis Simard, 2010
Traceback (most recent call last):
  File "/Users/chrish/Applications/scour/scour.py", line 3183, in <module>
    out_string = scourString(in_string, options).encode("UTF-8")
  File "/Users/chrish/Applications/scour/scour.py", line 2952, in scourString
    cleanPolygon(polygon, options)
  File "/Users/chrish/Applications/scour/scour.py", line 2164, in cleanPolygon
    pts = parseListOfPoints(elem.getAttribute('points'))
  File "/Users/chrish/Applications/scour/scour.py", line 2136, in parseListOfPoints
    prev = nums[len(nums)-1]
IndexError: list index out of range

Revision history for this message
Alexandru Băluț (a13b) wrote :

I also see this bug with two files, one of them being:
http://upload.wikimedia.org/wikipedia/commons/c/c2/Dublin_Rail_Network3.svg

The "s" parameter received by parseListOfPoints(s) is:
-7.227,-7.227 7.227,-7.227 7.227,7.227 -7.227,7.227

The parseListOfPoints method crashes if the first number is negative. That method needs some cleanup.

Revision history for this message
Patrick Storz (ede123) wrote :

Fixed in scour 0.32 [1]

See copy of this bug on GitHub for details
https://github.com/scour-project/scour/issues/87

[1] https://pypi.python.org/pypi/scour

Changed in scour:
status: New → Fix Released
assignee: nobody → Eduard Braun (eduard-braun2)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.