~smoser/ubuntu/wily/maas/lp1474417

« back to all changes in this revision

Viewing changes to src/maasserver/fields.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-10-04 12:33:05 UTC
  • mto: (1.4.1)
  • mto: This revision was merged to the branch mainline in revision 40.
  • Revision ID: package-import@ubuntu.com-20131004123305-vzkyhovgnvn1arco
Tags: upstream-1.4+bzr1693+dfsg
ImportĀ upstreamĀ versionĀ 1.4+bzr1693+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
    unicode_literals,
10
10
    )
11
11
 
 
12
str = None
 
13
 
12
14
__metaclass__ = type
13
15
__all__ = [
14
16
    "MAC",
157
159
            # Avoid double-wrapping.  It's the value that matters, not the
158
160
            # MAC object that wraps it.
159
161
            value = value.get_raw()
160
 
        # TODO bug=1215447: Remove this assertion.
161
 
        assert value is None or isinstance(value, basestring)
 
162
        elif isinstance(value, bytes):
 
163
            value = value.decode("ascii")
 
164
        else:
 
165
            # TODO bug=1215447: Remove this assertion.
 
166
            assert value is None or isinstance(value, unicode)
162
167
        # The wrapped attribute is stored as self._wrapped, following
163
168
        # ISQLQuote's example.
164
169
        self._wrapped = value
242
247
 
243
248
    def to_python(self, value):
244
249
        """db -> python: json load."""
 
250
        assert not isinstance(value, bytes)
245
251
        if value is not None:
246
 
            if isinstance(value, basestring):
 
252
            if isinstance(value, unicode):
247
253
                try:
248
254
                    return loads(value)
249
255
                except ValueError: