Skip to content

Commit

Permalink
use codecs.decode with unicode_escape instead of unichr. Fixes RDFLib…
Browse files Browse the repository at this point in the history
  • Loading branch information
ymph committed Feb 18, 2015
1 parent 5f41263 commit 30f0f8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rdflib/plugins/parsers/notation3.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def becauseSubexpression(*args, **kargs):

def unicodeExpand(m):
try:
return unichr(int(m.group(1), 16))
return codecs.decode(m.group(0), 'unicode_escape')
except:
raise Exception("Invalid unicode code point: " + m.group(1))

Expand Down
2 changes: 1 addition & 1 deletion rdflib/py3compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def sign(n):
r_unicodeEscape = re.compile(r'(\\u[0-9A-Fa-f]{4}|\\U[0-9A-Fa-f]{8})')

def _unicodeExpand(s):
return r_unicodeEscape.sub(lambda m: unichr(int(m.group(0)[2:], 16)), s)
return r_unicodeEscape.sub(lambda m: codecs.decode(m.group(0), 'unicode_escape'), s)

def decodeStringEscape(s):

Expand Down

0 comments on commit 30f0f8c

Please sign in to comment.