-
-
Notifications
You must be signed in to change notification settings - Fork 611
import error when installed into cyrilic path under windows #139
Copy link
Copy link
Closed
Description
I have python 2.7 installed in non ascii folder and when i try to import jsonschema i got the following (it's important to run python by full path):
E:\ximik\ìîé ïèòîí÷èê>"e:\ximik\ìîé ïèòîí÷èê\python.exe"
Python 2.7.4 (default, Oct 16 2013, 19:36:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import jsonschema
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "e:\ximik\üþù ÿøªþý¢øú\lib\site-packages\jsonschema\__init__.py", line 18, in <module>
from jsonschema.validators import (
File "e:\ximik\üþù ÿøªþý¢øú\lib\site-packages\jsonschema\validators.py", line 161, in <module>
meta_schema=_utils.load_schema("draft3"),
File "e:\ximik\üþù ÿøªþý¢øú\lib\site-packages\jsonschema\_utils.py", line 60, in load_schema
schemapath = os.path.join(schemadir, '%s.json' % (name,))
File "e:\ximik\üþù ÿøªþý¢øú\lib\ntpath.py", line 108, in join
path += "\\" + b
UnicodeDecodeError: 'ascii' codec can't decode byte 0xec in position 9: ordinal not in range(128)
as you can see load_schema function uses file which is not encoded in filesystem encoding. possible fix:
*** /tmp/opt/linux-CentOS_4.4-x64/1.0.12/PSE/python-2.7.4-dbg/lib/python2.7/site-packages/jsonschema/_utils.py 2013-09-25 05:50:22.000000000 +0400
--- _utils.py 2013-11-18 20:05:13.575529898 +0400
***************
*** 2,7 ****
--- 2,8 ----
import json
import re
import os
+ import sys
from jsonschema.compat import str_types, MutableMapping, urlsplit
***************
*** 54,64 ****
"""
schemadir = os.path.join(
! os.path.dirname(os.path.abspath(__file__)),
'schemas'
)
schemapath = os.path.join(schemadir, '%s.json' % (name,))
! with open(schemapath) as f:
return json.load(f)
--- 55,65 ----
"""
schemadir = os.path.join(
! os.path.dirname(os.path.abspath(__file__.decode(sys.getfilesystemencoding()))),
'schemas'
)
schemapath = os.path.join(schemadir, '%s.json' % (name,))
! with open(schemapath.encode(sys.getfilesystemencoding())) as f:
return json.load(f)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels