Skip to content

Commit 56b0eee

Browse files
committed
Merge pull request #4856 from jreback/hdf_unicode
COMPAT: unicode compat issue fix (GH4854)
2 parents 9e9d134 + f5cbb71 commit 56b0eee

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pandas/compat/__init__.py

+8
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@ class to receive bound method
180180

181181
def u(s):
182182
return s
183+
def u_safe(s):
184+
return s
183185
else:
184186
string_types = basestring,
185187
integer_types = (int, long)
@@ -190,6 +192,12 @@ def u(s):
190192
def u(s):
191193
return unicode(s, "unicode_escape")
192194

195+
def u_safe(s):
196+
try:
197+
return unicode(s, "unicode_escape")
198+
except:
199+
return s
200+
193201

194202
string_and_binary_types = string_types + (binary_type,)
195203

pandas/io/pytables.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import pandas.core.common as com
3030
from pandas.tools.merge import concat
3131
from pandas import compat
32-
from pandas.compat import u, PY3, range, lrange
32+
from pandas.compat import u_safe as u, PY3, range, lrange
3333
from pandas.io.common import PerformanceWarning
3434
from pandas.core.config import get_option
3535
from pandas.computation.pytables import Expr, maybe_expression

0 commit comments

Comments
 (0)