Nir Soffer has posted comments on this change. Change subject: vmDevices: add __slots__ to devices ......................................................................
Patch Set 4: (1 comment) http://gerrit.ovirt.org/#/c/21036/4/vdsm/vm.py File vdsm/vm.py: Line 1253: self.log.debug('Ignoring param (%s, %s) in %s', attr, value, Line 1254: self.__class__.__name__) Line 1255: pass Line 1256: self.conf = conf Line 1257: self._deviceXML = None Having slots is not enough - you must initialize *all* attributes, we will still get AttributeError when accessing uninitialized attribute. For example: >>> class Foo(object): ... __slots__ = ('a',) ... >>> Foo().a Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: a Then, initializing attributes to default value is still not enough, because some objects have required arguments. For example, when creating a Drive, we must have a "format" attribute. When we don't enforce this, we get this kind of bugs: https://bugzilla.redhat.com/1055437. The whole point of this patch, is to make such bugs impossible. I suggest to handle required arguments in a separate patch, because it will be much harder to get right, and having format=None is little better then not having format at all. Line 1258: Line 1259: def __str__(self): Line 1260: attrs = [':'.join((a, str(getattr(self, a, None)))) for a in dir(self) Line 1261: if not a.startswith('__')] -- To view, visit http://gerrit.ovirt.org/21036 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I6e8dadabdd02d3b44606f215c4bc7b7e306a591a Gerrit-PatchSet: 4 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Martin Polednik <[email protected]> Gerrit-Reviewer: Dan Kenigsberg <[email protected]> Gerrit-Reviewer: Federico Simoncelli <[email protected]> Gerrit-Reviewer: Francesco Romani <[email protected]> Gerrit-Reviewer: Martin Polednik <[email protected]> Gerrit-Reviewer: Michal Skrivanek <[email protected]> Gerrit-Reviewer: Nir Soffer <[email protected]> Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
