Ticket #8 (closed defect: fixed)

Opened 4 years ago

Last modified 5 months ago

Optional attributes always being set in dataforms.Option and dataforms.Field

Reported by: Stelminator@… Owned by: jajcus
Priority: trivial Component: pyxmpp
Keywords: dataforms 0004 Cc:

Description

dataforms.Option.label and dataforms.Field.type are optional as per JEP-0004

dataforms.py always attaches these attributes when building the xml.

patch below:

Index: pyxmpp/jabber/dataforms.py
===================================================================
--- pyxmpp/jabber/dataforms.py	(revision 661)
+++ pyxmpp/jabber/dataforms.py	(working copy)
@@ -70,7 +70,8 @@
             - `xmlnode`: `libxml2.xmlNode`
             - `doc`: `libxml2.xmlDoc`"""
         _unused = doc
-        xmlnode.setProp("label", self.label.encode("utf-8"))
+        if self.label is not None:
+            xmlnode.setProp("label", self.label.encode("utf-8"))
         for value in self.values:
             xmlnode.newTextChild(xmlnode.ns(), "value", value.encode("utf-8"))
         return xmlnode
@@ -259,7 +260,8 @@
             - `doc`: `libxml2.xmlDoc`"""
         if self.type is not None and self.type not in self.allowed_types:
             raise ValueError, "Invalid form field type: %r" % (self.type,)
-        xmlnode.setProp("type", self.type)
+        if self.type is not None:
+            xmlnode.setProp("type", self.type)
         if not self.label is None:
             xmlnode.setProp("label", self.label)
         if not self.name is None:

Change History

Changed 5 months ago by jajcus

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

(In [710]) - Option.label and Field.type are optional. Patch by Stelminator. closes #8

Note: See TracTickets for help on using tickets.