Browse Source

[1258] improved type error string for Message.from_wire()

JINMEI Tatuya 13 years ago
parent
commit
84ada921a2

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+288.?	[func]		jinmei
+	libdns++/pydnspp: added an option parameter to the "from wire"
+	methods of the Message class.  One option is defined,
+	PRESERVE_ORDER, which specifies the parser to handle each RR
+	separately, preserving the order, and construct RRsets in the
+	message sections so that each RRset contains only one RR.
+	(Trac #1258, git TBD)
+
 287.	[bug]*		jinmei
 	Python script files for log messages (xxx_messages.py) should have
 	been installed under the "isc" package.  This fix itself should

+ 4 - 1
src/lib/dns/python/message_python.cc

@@ -647,6 +647,7 @@ Message_fromWire(PyObject* const pyself, PyObject* args) {
     const char* b;
     Py_ssize_t len;
     unsigned int options = Message::PARSE_DEFAULT;
+        
     if (PyArg_ParseTuple(args, "y#", &b, &len) ||
         PyArg_ParseTuple(args, "y#I", &b, &len, &options)) {
         // We need to clear the error in case the first call to ParseTuple
@@ -685,7 +686,9 @@ Message_fromWire(PyObject* const pyself, PyObject* args) {
         }
     }
 
-    PyErr_SetString(PyExc_TypeError, "Invalid arguments to Message.from_wire");
+    PyErr_SetString(PyExc_TypeError,
+                    "from_wire() arguments must be a byte object and "
+                    "(optional) parse options");
     return (NULL);
 }
 

+ 1 - 0
src/lib/dns/python/tests/message_python_test.py

@@ -427,6 +427,7 @@ test.example.com. 3600 IN A 192.0.2.2
         self.assertRaises(InvalidMessageOperation, self.r.to_text)
 
     def test_from_wire(self):
+        self.r.from_wire(2, 2)
         self.assertRaises(TypeError, self.r.from_wire, 1)
         self.assertRaises(InvalidMessageOperation,
                           Message.from_wire, self.r, bytes())