Menu

#6 property-setter functions do not work

1.0
open
nobody
None
2016-02-21
2016-02-21
Jens Engel
No

PYASN1: Version 0.1.9
PYTHON: 2.7.x

The following property-setter function will never be called:

class Example(univ.Sequence):
    componentType = namedtype.NamedTypes(
        namedtype.NamedType("number", univ.Integer(0)),
    )

    @property
    def number(self):
        return int(self.getComponentByName("number"))

    @number.setter
    def number(self, value):
        self.setComponentByName("number", value)

The problem is caused by "pyasn1.type.base.Asn1Item" that is not derived from object.
If you make the following change, everything will work:

# -- FILE: pyasn1/type/base.py
class Asn1Item(object): pass

WORKAROUNG (until problem is fixed):

# USE-THIS: Add "object" to inherited base-classes (but not on first position).
class Example(univ.Sequence, object):
...
1 Attachments

Discussion


Log in to post a comment.

MongoDB Logo MongoDB