Skip to content

Commit d340003

Browse files
committed
Fix for python 3
1 parent d3f69d4 commit d340003

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pathvalidate/_sqlite.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
from __future__ import absolute_import
88
import re
99

10+
import six
11+
1012
from ._common import _validate_null_string
1113
from ._error import (
1214
InvalidCharError,
@@ -101,13 +103,13 @@ def validate_sqlite_table_name(name):
101103

102104
match = __RE_INVALID_SQLITE_NAME_HEAD.search(name)
103105
if match is not None:
104-
name = match.group()
106+
name = six.u(match.group())
105107

106108
try:
107-
name.decode("ascii")
108-
except UnicodeDecodeError:
109+
name.encode("ascii")
110+
except UnicodeEncodeError:
109111
try:
110-
name.decode("utf8")
112+
name.encode("utf8")
111113
except:
112114
raise
113115
else:
@@ -145,13 +147,13 @@ def validate_sqlite_attr_name(name):
145147

146148
match = __RE_INVALID_SQLITE_NAME_HEAD.search(name)
147149
if match is not None:
148-
name = match.group()
150+
name = six.u(match.group())
149151

150152
try:
151-
name.decode("ascii")
152-
except UnicodeDecodeError:
153+
name.encode("ascii")
154+
except UnicodeEncodeError:
153155
try:
154-
name.decode("utf8")
156+
name.encode("utf8")
155157
except:
156158
raise
157159
else:

0 commit comments

Comments
 (0)