Ticket #248 (closed defect: fixed)

Opened 22 months ago

Last modified 22 months ago

Classic class decoding throws an error

Reported by: nick Owned by: feisley
Priority: critical Milestone: 0.3
Component: Decoder Version: 0.3
Keywords: review Cc:
Fixed in revision: Branch:
Author:

Description

import pyamf

class Spam:
    pass

pyamf.register_class(Spam, 'spam.eggs')

x = Spam()
x.foo = 'bar'

bytes = pyamf.encode(x)

print [x for x in pyamf.decode(bytes)]

Using AMF3 encoding, results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/__init__.py", line 849, in decode
    yield decoder.readElement()
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/__init__.py", line 493, in readElement
    return func()
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/amf3.py", line 1121, in readObject
    obj.__setattr__(k, v)
AttributeError: Spam instance has no attribute '__setattr__'

Using AMF0 encoding, results in:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/__init__.py", line 849, in decode
    yield decoder.readElement()
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/__init__.py", line 493, in readElement
    return func()
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/amf0.py", line 309, in readTypedObject
    self._readObject(ret, alias)
  File "/Users/nick/projects/pyamf-examples/google_appengine/pyamf/amf0.py", line 370, in _readObject
    obj.__setattr__(key, obj_attrs[key])
AttributeError: Spam instance has no attribute '__setattr__'

Attachments

test-248.py Download (167 bytes) - added by thijs 22 months ago.

Change History

Changed 22 months ago by nick

  • keywords review added
  • owner changed from nick to darkhorse
  • status changed from new to assigned

Branch is ready for review in r1181

Changed 22 months ago by nick

  • owner changed from darkhorse to feisley

Changed 22 months ago by thijs

Attached test-248.py returns this on my mac:

[<__main__.Spam instance at 0xbd0dc8>]

Changed 22 months ago by thijs

Changed 22 months ago by nick

  • status changed from assigned to closed
  • resolution set to fixed

Fixed in r1199.

Note: See TracTickets for help on using tickets.