Skip to content

Commit fc630bb

Browse files
authored
Fix text character truncation in py3 + bump to next version
- Fixes issue in Py3 when converting text characters to byte strings, but in Py3 converts to unicode instead, because uses the Py2 specific str() function, instead of the version neutral b(). When the text contains non-ascii 2-byte unicode values this results in truncating the unicode length instead of the byte length, and thus results in incorrectly padded byte lengths and data values ending up in the wrong field/column. See #157, and also #148. - Also bump to next version.
1 parent a53f022 commit fc630bb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

shapefile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
shapefile.py
33
Provides read and write support for ESRI Shapefiles.
44
author: jlawhead<at>geospatialpython.com
5-
date: 2017/08/24
6-
version: 1.2.12
5+
date: 2018/09/8
6+
version: 1.2.13
77
Compatible with Python versions 2.7-3.x
88
"""
99

10-
__version__ = "1.2.12"
10+
__version__ = "1.2.13"
1111

1212
from struct import pack, unpack, calcsize, error, Struct
1313
import os
@@ -989,8 +989,8 @@ def __dbfRecords(self):
989989
else:
990990
value = b(' ') # unknown is set to space
991991
else:
992-
# anything else is forced to string
993-
value = str(value)[:size].ljust(size)
992+
# anything else is forced to byte string
993+
value = b(value)[:size].ljust(size)
994994
if len(value) != size:
995995
raise ShapefileException(
996996
"Shapefile Writer unable to pack incorrect sized value"

0 commit comments

Comments
 (0)