@@ -256,15 +256,15 @@ PyDict_ToAMQTable(amqp_connection_state_t conn, PyObject *src, amqp_pool_t *pool
256256 uint64_t clong_value = 0 ;
257257 double cdouble_value = 0.0 ;
258258 int is_unicode = 0 ;
259- amqp_table_t dst = AMQP_EMPTY_TABLE ;
259+ amqp_table_t dst = amqp_empty_table ;
260260
261261 size = PyDict_Size (src );
262262
263263 /* allocate new table */
264264 dst .num_entries = 0 ;
265265 dst .entries = amqp_pool_alloc (pool , size * sizeof (amqp_table_entry_t ));
266266 while (PyDict_Next (src , & pos , & dkey , & dvalue )) {
267-
267+ dkey = Maybe_Unicode ( dkey );
268268 if (dvalue == Py_None ) {
269269 /* None */
270270 AMQTable_SetNilValue (& dst , PyString_AS_AMQBYTES (dkey ));
@@ -340,7 +340,7 @@ PyDict_ToAMQTable(amqp_connection_state_t conn, PyObject *src, amqp_pool_t *pool
340340 return dst ;
341341error :
342342 assert (PyErr_Occurred ());
343- return AMQP_EMPTY_TABLE ;
343+ return amqp_empty_table ;
344344}
345345
346346static amqp_array_t
@@ -349,7 +349,7 @@ PyIter_ToAMQArray(amqp_connection_state_t conn, PyObject *src, amqp_pool_t *pool
349349 Py_ssize_t pos = 0 ;
350350 uint64_t clong_value = 0 ;
351351 int is_unicode = 0 ;
352- amqp_array_t dst = AMQP_EMPTY_ARRAY ;
352+ amqp_array_t dst = amqp_empty_array ;
353353
354354 Py_ssize_t size = PySequence_Size (src );
355355 if (size == -1 ) return dst ;
@@ -684,7 +684,7 @@ PyDict_to_basic_properties(PyObject *p,
684684 amqp_pool_t * pool )
685685{
686686 PyObject * value = NULL ;
687- props -> headers = AMQP_EMPTY_TABLE ;
687+ props -> headers = amqp_empty_table ;
688688 props -> _flags = AMQP_BASIC_HEADERS_FLAG ;
689689
690690 if ((value = PyDict_GetItemString (p , "content_type" )) != NULL ) {
@@ -1461,7 +1461,7 @@ PyRabbitMQ_Connection_queue_bind(PyRabbitMQ_Connection *self,
14611461 PyObject * routing_key = NULL ;
14621462 PyObject * arguments = NULL ;
14631463
1464- amqp_table_t bargs = AMQP_EMPTY_TABLE ;
1464+ amqp_table_t bargs = amqp_empty_table ;
14651465 amqp_pool_t * channel_pool = NULL ;
14661466 amqp_rpc_reply_t reply ;
14671467
@@ -1516,7 +1516,7 @@ PyRabbitMQ_Connection_queue_unbind(PyRabbitMQ_Connection *self,
15161516 PyObject * routing_key = NULL ;
15171517 PyObject * arguments = NULL ;
15181518
1519- amqp_table_t uargs = AMQP_EMPTY_TABLE ;
1519+ amqp_table_t uargs = amqp_empty_table ;
15201520 amqp_pool_t * channel_pool = NULL ;
15211521 amqp_rpc_reply_t reply ;
15221522
@@ -1618,7 +1618,7 @@ PyRabbitMQ_Connection_queue_declare(PyRabbitMQ_Connection *self,
16181618 amqp_queue_declare_ok_t * ok ;
16191619 amqp_rpc_reply_t reply ;
16201620 amqp_pool_t * channel_pool = NULL ;
1621- amqp_table_t qargs = AMQP_EMPTY_TABLE ;
1621+ amqp_table_t qargs = amqp_empty_table ;
16221622 PyObject * ret = NULL ;
16231623
16241624 if (PyRabbitMQ_Not_Connected (self ))
@@ -1717,7 +1717,7 @@ PyRabbitMQ_Connection_exchange_declare(PyRabbitMQ_Connection *self,
17171717 * as it has been decided that it's not that useful after all. */
17181718 unsigned int auto_delete = 0 ;
17191719
1720- amqp_table_t eargs = AMQP_EMPTY_TABLE ;
1720+ amqp_table_t eargs = amqp_empty_table ;
17211721 amqp_pool_t * channel_pool = NULL ;
17221722 amqp_rpc_reply_t reply ;
17231723
@@ -1983,7 +1983,7 @@ PyRabbitMQ_Connection_basic_consume(PyRabbitMQ_Connection *self,
19831983 amqp_basic_consume_ok_t * ok ;
19841984 amqp_rpc_reply_t reply ;
19851985 amqp_pool_t * channel_pool = NULL ;
1986- amqp_table_t cargs = AMQP_EMPTY_TABLE ;
1986+ amqp_table_t cargs = amqp_empty_table ;
19871987
19881988 if (PyRabbitMQ_Not_Connected (self ))
19891989 goto bail ;
@@ -2263,7 +2263,11 @@ PYRABBITMQ_MOD_INIT(_librabbitmq)
22632263 PyObject * module , * socket_module ;
22642264
22652265 if (PyType_Ready (& PyRabbitMQ_ConnectionType ) < 0 ) {
2266+ #if PY_MAJOR_VERSION >= 3
2267+ return NULL ;
2268+ #else
22662269 return ;
2270+ #endif
22672271 }
22682272
22692273#if PY_MAJOR_VERSION >= 3
@@ -2274,13 +2278,22 @@ PYRABBITMQ_MOD_INIT(_librabbitmq)
22742278#endif
22752279
22762280 if (module == NULL ) {
2281+ #if PY_MAJOR_VERSION >= 3
2282+ return NULL ;
2283+ #else
22772284 return ;
2285+ #endif
22782286 }
22792287
22802288 /* Get socket.error */
22812289 socket_module = PyImport_ImportModule ("socket" );
2282- if (!socket_module )
2290+ if (!socket_module ) {
2291+ #if PY_MAJOR_VERSION >= 3
2292+ return NULL ;
2293+ #else
22832294 return ;
2295+ #endif
2296+ }
22842297 PyRabbitMQ_socket_timeout = PyObject_GetAttrString (socket_module , "timeout" );
22852298 Py_XDECREF (socket_module );
22862299
0 commit comments