Parcourir la source

[1452b] added some more comments abot what happens if the given param
for receiver constructor doesn't have fileno

JINMEI Tatuya il y a 13 ans
Parent
commit
6c8cde4eb7
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      src/lib/python/isc/util/io/socketsessionreceiver_python.cc

+ 5 - 0
src/lib/python/isc/util/io/socketsessionreceiver_python.cc

@@ -64,6 +64,11 @@ SocketSessionReceiver_init(PyObject* po_self, PyObject* args, PyObject*) {
         // The constructor expects a Python socket object.  We'll extract
         // the underlying file descriptor using the fileno method (in the
         // duck typing manner) and pass it to the C++ constructor.
+        // PyObject_CallMethod() could return NULL (especially if the given
+        // object is of the wrong type and doesn't have the "fileno" method),
+        // in which case PyObjectContainer will detect it and throw
+        // PyCPPWrapperException, which will be converted to the Python
+        // TypeError below.
         PyObject* po_sock;
         if (PyArg_ParseTuple(args, "O", &po_sock)) {
             PyObjectContainer fd_container(PyObject_CallMethod(