opentraveldata / geobases

Data services and visualization
http://opentraveldata.github.com/geobases/
Other
193 stars 41 forks source link

encoding-caused crash on windows (python 3.3 x64) #21

Closed matvict closed 7 years ago

matvict commented 9 years ago

Hello, Please, consider whether it is an issue. I tried to install and run the Geobases module on Windows with locale encoding set to 1252 and it crashed while reading the csv file. The following patch (setting the text file encodings explicitly to Unicode) seems to fix this.
Best regards, Victor


 GeoBases/GeoBaseModule.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/GeoBases/GeoBaseModule.py b/GeoBases/GeoBaseModule.py
index a57a950..11f2f50 100755
--- a/GeoBases/GeoBaseModule.py
+++ b/GeoBases/GeoBaseModule.py
@@ -344,7 +344,7 @@ class GeoBase(object):
                     continue

                 try:
-                    with open(file_) as source_fl:
+                    with open(file_, encoding="utf-8") as source_fl:
                         self._load(source_fl, self._verbose)
                 except IOError:
                     if self._verbose:

how to reproduce the crash (Windows, branch 3000, last rev 29bf01...)

from GeoBases import GeoBase
geo = GeoBase(data='airports', verbose=False)
alexprengere commented 7 years ago

Hello, Sorry for the 2 years delay :wink: , I do not really use it on Windows so it was not easy to test. Anyway, 46a85cc should fix the problem, as you said.

Thanks for reporting this!