I don't have a patch, but I do have some analysis. The following refers to vobject/base.py.<br><br> def setBehaviorFromVersionLine(self, versionLine):<br> v=getBehavior(<a href="http://self.name">self.name</a>, versionLine.value)<br>
if v: self.setBehavior(v)<br><br>For a vcard that contains "VERSION:3.0", this sets the behavior to an instance of vobject.vcard.VCard3_0.<br>For a vcard that contains "VERSION:2.1", this does not set the behavior since, v is None.<br>
<br>Later, valueRepr (not used in v.n.family, for example, but it illustrates the point) is called by prettyPrint:<br><br> def valueRepr( self ): <br> v = self.value<br> if self.behavior:<br> v = self.behavior.valueRepr( self )<br>
return ascii( v )<br><br>For a vcard that contains "VERSION:3.0", and the content line name is FN, behavior is an instance of vobject.vcard.FN.<br>For a vcard that contains "VERSION:3.0", and the content line name is N, behavior is an instance of vobject.vcard.NameBehavior.<br>
For a vcard that contains "VERSION:2.1", and the content line name is FN, behavior is None.<br>
For a vcard that contains "VERSION:2.1", and the content line name is N, behavior is None.<br><br>Looking at how we retrieve a behavior:<br><br>def getBehavior(name, id=None):<br> name=name.upper()<br> if name in __behaviorRegistry:<br>
if id:<br> for n, behavior in __behaviorRegistry[name]:<br> if n==id:<br> return behavior<br> else:<br> return __behaviorRegistry[name][0][1]<br> return None<br>
<br>'VCARD' is in the registry. The only entry in the list is for 3.0: [('3.0', <class 'vobject.vcard.VCard3_0'>)]. The id that comes in, for a name of VCARD, is the version; either 2.1 or 3.0. It then tries to match that version in the list, but 2.1 does not exist in the list, so it returns None in the end. So, it seems like the fallback behavior doesn't exist in this method. Since this method is used for all behaviors (VCARD, N, FN, etc.), I would be hesistant to make a blanket rule of picking the first one in the list, if a match was not found.<br>
<br>What do you think?<br>