Commit 65498cc
committed
schema: support encoding=None connections
Several different problems are fixed here, but all have the same root.
When a connection encoding is None (it is default on Python 2 and may be
set explicitly on Python 3), all mp_str values are decoded into bytes,
not Unicode strings (note that bytes is alias for str in Python 2). But
the database schema parsing code have assumptions that _vspace / _vindex
values are Unicode strings.
The resolved problems are the following:
1. Default encoding in bytes#decode() method is 'ascii', however names
in tarantool can contain symbols beyond ASCII symbol table. Set
'utf-8' for names decoding.
2. Convert all binary values into Unicode strings before parse or store
them. This allows further correct accesses to the local schema
representation.
3. Convert binary parameters like space, index or field name into
Unicode strings, when a schema is accessed to don't trigger redundant
schema refetching.
Those problems are briefly mentioned in [1].
Tested manually with Python 2 and Python 3: my testing tarantool
instance has a space with name '©' and after the changes I'm able to
connect to it when the connection encoding is set to None. Also I
verified that schema is not fetched each time when I do
<connection>.select('©') in Python 2 (where such string literal is str /
bytes, not Unicode string).
[1]: #105 (comment)1 parent 4f79627 commit 65498cc
1 file changed
+29
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
| |||
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | | - | |
| 59 | + | |
58 | 60 | | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
65 | 77 | | |
66 | 78 | | |
67 | 79 | | |
| |||
78 | 90 | | |
79 | 91 | | |
80 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
81 | 96 | | |
82 | 97 | | |
83 | 98 | | |
| |||
135 | 150 | | |
136 | 151 | | |
137 | 152 | | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
138 | 158 | | |
139 | 159 | | |
140 | 160 | | |
| |||
203 | 223 | | |
204 | 224 | | |
205 | 225 | | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
206 | 231 | | |
207 | 232 | | |
208 | 233 | | |
| |||
0 commit comments