Merge lp:~cjwatson/storm/bytes-rawstr into lp:storm

Proposed by Colin Watson
Status: Merged
Merged at revision: 543
Proposed branch: lp:~cjwatson/storm/bytes-rawstr
Merge into: lp:storm
Diff against target: 349 lines (+47/-34)
13 files modified
NEWS (+7/-0)
storm/databases/sqlite.py (+2/-2)
storm/expr.py (+2/-2)
storm/locals.py (+1/-1)
storm/properties.py (+8/-7)
storm/sqlobject.py (+2/-2)
storm/tests/databases/base.py (+3/-3)
storm/tests/databases/postgres.py (+2/-2)
storm/tests/expr.py (+5/-5)
storm/tests/properties.py (+4/-4)
storm/tests/store/base.py (+2/-2)
storm/tests/variables.py (+3/-3)
storm/variables.py (+6/-1)
To merge this branch: bzr merge lp:~cjwatson/storm/bytes-rawstr
Reviewer Review Type Date Requested Status
Simon Poirier (community) Approve
Review via email: mp+378816@code.launchpad.net

Commit message

Rename RawStr to Bytes.

Description of the change

Rename RawStr and RawStrVariable to Bytes and BytesVariable respectively, since that matches Python 3's terminology. RawStr and RawStrVariable still exist as deprecated aliases.

To post a comment you must log in.
Revision history for this message
Simon Poirier (simpoir) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2019-12-09 17:34:54 +0000
3+++ NEWS 2020-02-10 15:32:46 +0000
4@@ -14,6 +14,13 @@
5
6 - Stop using deprecated assertEquals/assertNotEquals unittest methods.
7
8+API changes
9+-----------
10+
11+- Rename RawStr and RawStrVariable to Bytes and BytesVariable respectively,
12+ since that matches Python 3's terminology. RawStr and RawStrVariable
13+ still exist as deprecated aliases.
14+
15 0.22 (2019-11-21)
16 =================
17
18
19=== modified file 'storm/databases/sqlite.py'
20--- storm/databases/sqlite.py 2019-08-11 16:57:24 +0000
21+++ storm/databases/sqlite.py 2020-02-10 15:32:46 +0000
22@@ -36,7 +36,7 @@
23 except ImportError:
24 sqlite = dummy
25
26-from storm.variables import Variable, RawStrVariable
27+from storm.variables import Variable, BytesVariable
28 from storm.database import Database, Connection, ConnectionWrapper, Result
29 from storm.exceptions import (
30 DatabaseModuleError, OperationalError, wrap_exceptions)
31@@ -85,7 +85,7 @@
32
33 @staticmethod
34 def set_variable(variable, value):
35- if (isinstance(variable, RawStrVariable) and
36+ if (isinstance(variable, BytesVariable) and
37 isinstance(value, six.text_type)):
38 # pysqlite2 may return unicode.
39 value = value.encode("UTF-8")
40
41=== modified file 'storm/expr.py'
42--- storm/expr.py 2019-12-09 17:34:54 +0000
43+++ storm/expr.py 2020-02-10 15:32:46 +0000
44@@ -30,7 +30,7 @@
45
46 from storm.exceptions import CompileError, NoTableError, ExprError
47 from storm.variables import (
48- Variable, RawStrVariable, UnicodeVariable, LazyValue,
49+ Variable, BytesVariable, UnicodeVariable, LazyValue,
50 DateTimeVariable, DateVariable, TimeVariable, TimeDeltaVariable,
51 BoolVariable, IntVariable, FloatVariable, DecimalVariable)
52 from storm import Undef, has_cextensions
53@@ -310,7 +310,7 @@
54
55 @compile.when(bytes)
56 def compile_bytes(compile, expr, state):
57- state.parameters.append(RawStrVariable(expr))
58+ state.parameters.append(BytesVariable(expr))
59 return "?"
60
61 @compile.when(six.text_type)
62
63=== modified file 'storm/locals.py'
64--- storm/locals.py 2019-06-05 11:41:07 +0000
65+++ storm/locals.py 2020-02-10 15:32:46 +0000
66@@ -20,7 +20,7 @@
67 #
68 from __future__ import print_function
69
70-from storm.properties import Bool, Int, Float, RawStr, Chars, Unicode
71+from storm.properties import Bool, Int, Float, Bytes, RawStr, Chars, Unicode
72 from storm.properties import List, Decimal, DateTime, Date, Time, Enum, UUID
73 from storm.properties import TimeDelta, Pickle, JSON
74 from storm.references import Reference, ReferenceSet, Proxy
75
76=== modified file 'storm/properties.py'
77--- storm/properties.py 2019-08-11 16:57:24 +0000
78+++ storm/properties.py 2020-02-10 15:32:46 +0000
79@@ -29,14 +29,14 @@
80 from storm.expr import Column, Undef
81 from storm.variables import (
82 Variable, VariableFactory, BoolVariable, IntVariable, FloatVariable,
83- DecimalVariable, RawStrVariable, UnicodeVariable, DateTimeVariable,
84+ DecimalVariable, BytesVariable, UnicodeVariable, DateTimeVariable,
85 DateVariable, TimeVariable, TimeDeltaVariable, UUIDVariable,
86 PickleVariable, JSONVariable, ListVariable, EnumVariable)
87
88
89
90 __all__ = ["Property", "SimpleProperty",
91- "Bool", "Int", "Float", "Decimal", "RawStr", "Unicode",
92+ "Bool", "Int", "Float", "Decimal", "Bytes", "RawStr", "Unicode",
93 "DateTime", "Date", "Time", "TimeDelta", "UUID", "Enum",
94 "Pickle", "JSON", "List", "PropertyRegistry"]
95
96@@ -147,12 +147,13 @@
97 class Decimal(SimpleProperty):
98 variable_class = DecimalVariable
99
100-# Bytes might be a clearer name nowadays, but we keep this for compatibility.
101-class RawStr(SimpleProperty):
102- variable_class = RawStrVariable
103+class Bytes(SimpleProperty):
104+ variable_class = BytesVariable
105
106-# OBSOLETE RawStr was Chars in 0.9. This will die soon.
107-Chars = RawStr
108+# OBSOLETE: Bytes was Chars in 0.9. This will die soon.
109+Chars = Bytes
110+# DEPRECATED: Bytes was RawStr until 0.22.
111+RawStr = Bytes
112
113 class Unicode(SimpleProperty):
114 variable_class = UnicodeVariable
115
116=== modified file 'storm/sqlobject.py'
117--- storm/sqlobject.py 2019-09-29 14:10:47 +0000
118+++ storm/sqlobject.py 2020-02-10 15:32:46 +0000
119@@ -31,7 +31,7 @@
120 import six
121
122 from storm.properties import (
123- RawStr, Int, Bool, Float, DateTime, Date, TimeDelta)
124+ Bytes, Int, Bool, Float, DateTime, Date, TimeDelta)
125 from storm.references import Reference, ReferenceSet
126 from storm.properties import SimpleProperty, PropertyPublisherMeta
127 from storm.variables import Variable
128@@ -211,7 +211,7 @@
129
130
131 id_type = dict.setdefault("_idType", int)
132- id_cls = {int: Int, bytes: RawStr, six.text_type: AutoUnicode}[id_type]
133+ id_cls = {int: Int, bytes: Bytes, six.text_type: AutoUnicode}[id_type]
134 dict["id"] = id_cls(id_name, primary=True, default=AutoReload)
135 attr_to_prop[id_name] = "id"
136
137
138=== modified file 'storm/tests/databases/base.py'
139--- storm/tests/databases/base.py 2019-11-21 16:06:52 +0000
140+++ storm/tests/databases/base.py 2020-02-10 15:32:46 +0000
141@@ -32,7 +32,7 @@
142
143 from storm.uri import URI
144 from storm.expr import Select, Column, SQLToken, SQLRaw, Count, Alias
145-from storm.variables import (Variable, PickleVariable, RawStrVariable,
146+from storm.variables import (Variable, PickleVariable, BytesVariable,
147 DecimalVariable, DateTimeVariable, DateVariable,
148 TimeVariable, TimeDeltaVariable)
149 from storm.database import *
150@@ -279,7 +279,7 @@
151 self.connection.execute("INSERT INTO bin_test (b) VALUES (?)",
152 (value,))
153 result = self.connection.execute("SELECT b FROM bin_test")
154- variable = RawStrVariable()
155+ variable = BytesVariable()
156 result.set_variable(variable, result.get_one()[0])
157 self.assertEqual(variable.get(), value)
158
159@@ -287,7 +287,7 @@
160 """Some databases like pysqlite2 may return unicode for strings."""
161 self.connection.execute("INSERT INTO bin_test VALUES (10, 'Value')")
162 result = self.connection.execute("SELECT b FROM bin_test")
163- variable = RawStrVariable()
164+ variable = BytesVariable()
165 # If the following doesn't raise a TypeError we're good.
166 result.set_variable(variable, result.get_one()[0])
167 self.assertEqual(variable.get(), b"Value")
168
169=== modified file 'storm/tests/databases/postgres.py'
170--- storm/tests/databases/postgres.py 2019-12-09 17:34:54 +0000
171+++ storm/tests/databases/postgres.py 2020-02-10 15:32:46 +0000
172@@ -33,7 +33,7 @@
173 from storm.database import create_database
174 from storm.store import Store
175 from storm.exceptions import InterfaceError, ProgrammingError
176-from storm.variables import DateTimeVariable, RawStrVariable
177+from storm.variables import DateTimeVariable, BytesVariable
178 from storm.variables import ListVariable, IntVariable, Variable
179 from storm.properties import Int
180 from storm.exceptions import DisconnectionError, OperationalError
181@@ -360,7 +360,7 @@
182 Verify that the logic to enforce fix E''-styled strings isn't
183 breaking on NULL values.
184 """
185- variable = RawStrVariable(value=None)
186+ variable = BytesVariable(value=None)
187 result = self.connection.execute(Select(variable))
188 self.assertEqual(result.get_one(), (None,))
189
190
191=== modified file 'storm/tests/expr.py'
192--- storm/tests/expr.py 2019-12-09 17:34:54 +0000
193+++ storm/tests/expr.py 2020-02-10 15:32:46 +0000
194@@ -574,7 +574,7 @@
195 state = State()
196 statement = compile(b"str", state)
197 self.assertEqual(statement, "?")
198- self.assertVariablesEqual(state.parameters, [RawStrVariable(b"str")])
199+ self.assertVariablesEqual(state.parameters, [BytesVariable(b"str")])
200
201 def test_unicode(self):
202 state = State()
203@@ -1224,7 +1224,7 @@
204 state = State()
205 statement = compile(expr, state)
206 self.assertEqual(statement, "func1() LIKE ?")
207- self.assertVariablesEqual(state.parameters, [RawStrVariable(b"value")])
208+ self.assertVariablesEqual(state.parameters, [BytesVariable(b"value")])
209
210 expr = Func1().like("Hello")
211 state = State()
212@@ -1238,14 +1238,14 @@
213 statement = compile(expr, state)
214 self.assertEqual(statement, "func1() LIKE ? ESCAPE ?")
215 self.assertVariablesEqual(state.parameters,
216- [RawStrVariable(b"value"), RawStrVariable(b"!")])
217+ [BytesVariable(b"value"), BytesVariable(b"!")])
218
219 expr = Func1().like("Hello", b"!")
220 state = State()
221 statement = compile(expr, state)
222 self.assertEqual(statement, "func1() LIKE ? ESCAPE ?")
223 self.assertVariablesEqual(state.parameters,
224- [Variable("Hello"), RawStrVariable(b"!")])
225+ [Variable("Hello"), BytesVariable(b"!")])
226
227 def test_like_compareable_case(self):
228 expr = Func1().like("Hello")
229@@ -1260,7 +1260,7 @@
230 state = State()
231 statement = compile(expr, state)
232 self.assertEqual(statement, "func1() IN (?)")
233- self.assertVariablesEqual(state.parameters, [RawStrVariable(b"value")])
234+ self.assertVariablesEqual(state.parameters, [BytesVariable(b"value")])
235
236 expr = In(Func1(), elem1)
237 state = State()
238
239=== modified file 'storm/tests/properties.py'
240--- storm/tests/properties.py 2019-11-21 16:06:52 +0000
241+++ storm/tests/properties.py 2020-02-10 15:32:46 +0000
242@@ -420,7 +420,7 @@
243 self.assertTrue(isinstance(self.obj.prop1, decimal))
244
245 def test_bytes(self):
246- self.setup(RawStr, default=b"def", allow_none=False)
247+ self.setup(Bytes, default=b"def", allow_none=False)
248
249 self.assertTrue(isinstance(self.column1, Column))
250 self.assertTrue(isinstance(self.column2, Column))
251@@ -428,8 +428,8 @@
252 self.assertEqual(self.column1.table, self.SubClass)
253 self.assertEqual(self.column2.name, "prop2")
254 self.assertEqual(self.column2.table, self.SubClass)
255- self.assertTrue(isinstance(self.variable1, RawStrVariable))
256- self.assertTrue(isinstance(self.variable2, RawStrVariable))
257+ self.assertTrue(isinstance(self.variable1, BytesVariable))
258+ self.assertTrue(isinstance(self.variable2, BytesVariable))
259
260 self.assertEqual(self.obj.prop1, b"def")
261 self.assertRaises(NoneError, setattr, self.obj, "prop1", None)
262@@ -815,7 +815,7 @@
263 (Bool, BoolVariable, True),
264 (Int, IntVariable, 1),
265 (Float, FloatVariable, 1.1),
266- (RawStr, RawStrVariable, b"str"),
267+ (Bytes, BytesVariable, b"str"),
268 (Unicode, UnicodeVariable, u"unicode"),
269 (DateTime, DateTimeVariable, datetime.now()),
270 (Date, DateVariable, date.today()),
271
272=== modified file 'storm/tests/store/base.py'
273--- storm/tests/store/base.py 2019-11-21 16:06:52 +0000
274+++ storm/tests/store/base.py 2020-02-10 15:32:46 +0000
275@@ -34,7 +34,7 @@
276 from storm.references import Reference, ReferenceSet, Proxy
277 from storm.database import Result, STATE_DISCONNECTED
278 from storm.properties import (
279- Int, Float, RawStr, Unicode, Property, Pickle, UUID)
280+ Int, Float, Bytes, Unicode, Property, Pickle, UUID)
281 from storm.properties import PropertyPublisherMeta, Decimal
282 from storm.variables import PickleVariable
283 from storm.expr import (
284@@ -73,7 +73,7 @@
285 class Blob(object):
286 __storm_table__ = "bin"
287 id = Int(primary=True)
288- bin = RawStr()
289+ bin = Bytes()
290
291 class Link(object):
292 __storm_table__ = "link"
293
294=== modified file 'storm/tests/variables.py'
295--- storm/tests/variables.py 2019-11-21 16:06:52 +0000
296+++ storm/tests/variables.py 2020-02-10 15:32:46 +0000
297@@ -440,10 +440,10 @@
298 self.assertEqual(variable.get(to_db=True), "1.1")
299
300
301-class RawStrVariableTest(TestHelper):
302+class BytesVariableTest(TestHelper):
303
304 def test_set_get(self):
305- variable = RawStrVariable()
306+ variable = BytesVariable()
307 variable.set(b"str")
308 self.assertEqual(variable.get(), b"str")
309 buffer_type = memoryview if six.PY3 else buffer
310@@ -961,7 +961,7 @@
311 def test_list_events(self):
312 event = EventSystem(marker)
313
314- variable = ListVariable(RawStrVariable, event=event,
315+ variable = ListVariable(BytesVariable, event=event,
316 value_factory=list)
317
318 changes = []
319
320=== modified file 'storm/variables.py'
321--- storm/variables.py 2019-09-29 14:10:47 +0000
322+++ storm/variables.py 2020-02-10 15:32:46 +0000
323@@ -43,6 +43,7 @@
324 "IntVariable",
325 "FloatVariable",
326 "DecimalVariable",
327+ "BytesVariable",
328 "RawStrVariable",
329 "UnicodeVariable",
330 "DateTimeVariable",
331@@ -369,7 +370,7 @@
332 return value
333
334
335-class RawStrVariable(Variable):
336+class BytesVariable(Variable):
337 __slots__ = ()
338
339 def parse_set(self, value, from_db):
340@@ -381,6 +382,10 @@
341 return value
342
343
344+# DEPRECATED: BytesVariable was RawStrVariable until 0.22.
345+RawStrVariable = BytesVariable
346+
347+
348 class UnicodeVariable(Variable):
349 __slots__ = ()
350

Subscribers

People subscribed via source and target branches

to status/vote changes: