[ 
https://issues.apache.org/jira/browse/DISPATCH-1735?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17170984#comment-17170984
 ] 

Ganesh Murthy edited comment on DISPATCH-1735 at 8/4/20, 5:57 PM:
------------------------------------------------------------------

I am on Fedora 32
{noformat}
[gmurthy@localhost qpid-dispatch]$ python --version
Python 3.8.3
[gmurthy@localhost qpid-dispatch]$ {noformat}
I added the following to python_embedded.c
{noformat}
[gmurthy@localhost qpid-dispatch]$ git diff src/python_embedded.c
diff --git a/src/python_embedded.c b/src/python_embedded.c
index 7265eb29..60bae6df 100644
--- a/src/python_embedded.c
+++ b/src/python_embedded.c
@@ -656,6 +656,17 @@ static void qd_io_rx_handler(void *context, qd_message_t 
*msg, int link_id, int
     iter_to_py_attr(qd_message_field_iterator(msg, 
QD_FIELD_APPLICATION_PROPERTIES), py_iter_parse, py_msg, "properties");
     iter_to_py_attr(qd_message_field_iterator(msg, QD_FIELD_BODY), 
py_iter_parse, py_msg, "body");
 
+
+    PyObject* properties_map = PyObject_GetAttrString(py_msg, "properties");
+    PyObject* data = PyDict_GetItemString(properties_map, "data");
+    if (data) {
+        if (PyBytes_CheckExact(data)) {
+            printf ("BATMAN qd_io_rx_handler PyBytes_CheckExact is True\n");
+        }
+    }
+
     PyObject *value = PyObject_CallFunction(self->handler, "Oil", py_msg, 
link_id, inter_router_cost);
 
     Py_DECREF(py_msg);
[gmurthy@localhost qpid-dispatch]$ 
 {noformat}
 

When I run the failing test -
{noformat}
/usr/bin/python "/home/gmurthy/opensource/qpid-dispatch/build/tests/run.py" 
"-m" "unittest" "-v" "system_tests_management.ManagementTest.test_dummy" 
{noformat}
I see the output 
{noformat}
BATMAN qd_io_rx_handler PyBytes_CheckExact is True {noformat}
 

So, the C code is doing the right thing here by setting the the type of the 
value in the dict to byte. The python code is called from the c  code (in 
python_embedded.c) using the following line
{noformat}
PyObject *value = PyObject_CallFunction(self->handler, "Oil", py_msg, link_id, 
inter_router_cost); {noformat}
 

which in turn calls this function - 
[https://github.com/apache/qpid-dispatch/blob/1.12.0/python/qpid_dispatch_internal/management/agent.py#L821]

When you try to get the type of key 'data' in request.properties, it prints 
<str>

 

In summary, I think the Python object API (PyObject*) has a bug. This test does 
not fail in Python 3.6
{noformat}
 {noformat}
 


was (Author: ganeshmurthy):
I am on Fedora 32
{noformat}
[gmurthy@localhost qpid-dispatch]$ python --version
Python 3.8.3
[gmurthy@localhost qpid-dispatch]$ {noformat}
I added the following to python_embedded.c
{noformat}
[gmurthy@localhost qpid-dispatch]$ git diff src/python_embedded.c
diff --git a/src/python_embedded.c b/src/python_embedded.c
index 7265eb29..60bae6df 100644
--- a/src/python_embedded.c
+++ b/src/python_embedded.c
@@ -656,6 +656,17 @@ static void qd_io_rx_handler(void *context, qd_message_t 
*msg, int link_id, int
     iter_to_py_attr(qd_message_field_iterator(msg, 
QD_FIELD_APPLICATION_PROPERTIES), py_iter_parse, py_msg, "properties");
     iter_to_py_attr(qd_message_field_iterator(msg, QD_FIELD_BODY), 
py_iter_parse, py_msg, "body");
 
+
+    PyObject* properties_map = PyObject_GetAttrString(py_msg, "properties");
+    PyObject* data = PyDict_GetItemString(properties_map, "data");
+    if (data) {
+        if (PyBytes_CheckExact(data)) {
+            printf ("BATMAN qd_io_rx_handler PyBytes_CheckExact is True\n");
+        }
+    }
+
     PyObject *value = PyObject_CallFunction(self->handler, "Oil", py_msg, 
link_id, inter_router_cost);
 
     Py_DECREF(py_msg);
[gmurthy@localhost qpid-dispatch]$ 
 {noformat}
 

And I see the output
{noformat}
BATMAN qd_io_rx_handler PyBytes_CheckExact is True {noformat}
 

So, the C code is doing the right thing here by setting the the type of the 
value in the dict to byte. The python code is called using the following line
{noformat}
PyObject *value = PyObject_CallFunction(self->handler, "Oil", py_msg, link_id, 
inter_router_cost); {noformat}
 

which in turn calls this function - 
[https://github.com/apache/qpid-dispatch/blob/1.12.0/python/qpid_dispatch_internal/management/agent.py#L821]

When you try to get the type of key 'data' in request.properties, it prints 
<str>

 

In summary, I think the Python object API (PyObject*) has a bug. This test does 
not fail in Python 3.6
{noformat}
 {noformat}

> system_tests_management failing on Fedora 32
> --------------------------------------------
>
>                 Key: DISPATCH-1735
>                 URL: https://issues.apache.org/jira/browse/DISPATCH-1735
>             Project: Qpid Dispatch
>          Issue Type: Bug
>          Components: Tests
>            Reporter: Ganesh Murthy
>            Assignee: Ganesh Murthy
>            Priority: Major
>
> {noformat}
> 19: ======================================================================
> 19: FAIL: test_dummy (system_tests_management.ManagementTest)
> 19: Test all operations on the dummy test entity
> 19: ----------------------------------------------------------------------
> 19: Traceback (most recent call last):
> 19:   File 
> "/home/gmurthy/opensource/qpid-dispatch/tests/system_tests_management.py", 
> line 347, in test_dummy
> 19:     self.assertEqual(
> 19: AssertionError: {'operation': 'callme', 'type': 'org.apache[58 
> chars]tes'} != {'type': 'org.apache.qpid.dispatch.dummy', [57 chars]y/0'}
> 19: - {'data': b'bytes',
> 19: ?          -
> 19: 
> 19: + {'data': 'bytes',
> 19:    'identity': 'dummy/0',
> 19:    'operation': 'callme',
> 19:    'type': 'org.apache.qpid.dispatch.dummy'}
> 19: 
> 19: ----------------------------------------------------------------------
> 19: Ran 21 tests in 9.483s
> 19: 
> 19: FAILED (failures=1)
> 1/1 Test #19: system_tests_management ..........***Failed    9.69 sec
>  {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to