zhikrullah / pyshp

Automatically exported from code.google.com/p/pyshp
MIT License
0 stars 0 forks source link

column name with exactly maximum number of characters crashes #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Load shapefile with column name that has maximum allowed number of 
characters (then there is no \x00 behind the column name).
2. .index("\x00") raises ValueError

What is the expected output? What do you see instead?

Expected behaviour: read shapefile with such a column name

What version of the product are you using? On what operating system?

Latest download provided.

Please provide any additional information below.

These lines (around 250) should fix the problem (not thoroughly tested, though):

                        if "\x00" in fieldDesc[name]:
                                indx = fieldDesc[name].index("\x00")
                        else:
                                indx = len(fieldDesc[name]) - 1
                        fieldDesc[name] = fieldDesc[name][:indx]

replacing the line

fieldDesc[name] = fieldDesc[name][:fieldDesc[name].index("\x00")]

Original issue reported on code.google.com by marti...@gmail.com on 9 Aug 2011 at 6:42

GoogleCodeExporter commented 8 years ago
This bug was verified and the recommended patch was used.

Original comment by geospati...@gmail.com on 5 Sep 2011 at 4:08