majek / puka

Puka - the opinionated RabbitMQ client
https://github.com/majek/puka
Other
182 stars 34 forks source link

Add support for python3 #69

Closed justinfx closed 5 years ago

justinfx commented 5 years ago

This is a large merge which adds support for python 3.6+ It was a bit time consuming and took 3 full days. Some of the time was spent improving the tests and a good majority was spent dealing with the bytes/str handling between the api and the underlying sockets, buffers, and encoder/decoder.

Summary of changes:

I had to make a decision on the option for handling bytes vs str between python 2 and 3, and opted to keep a compatible experience for existing py2 users. And in py3 I went with encoding to bytes at the buffer/socket layer to allow for str type at the api layer. I had also encountered a new situation in my porting experience, where dictionaries unmarshaled directly from bytes produce bytes format keys. This means b'key' != 'key'. So I went with updating the codegen so the spec will decode the keys to a more natural str type.

Caveats: There are 4 tests that originally failed for me in python2 using the master branch or 0.0.7 release tag (tested against RabbitMQ 3.6.6)

  1. test_basic_qos
  2. test_shared_qos
  3. test_exchange_delete_not_found
  4. test_queue_delete_not_found

For the qos tests, I was finding that the failure happened after the setting of the basic_qos, when the expected remaining messages were not read. For the delete tests, I was finding that the expected NotFound exception no longer raises when deleting a queue or exchange that does not exist. I have not spent time investigating these tests since they have not impacted our own higher level library consumption of puka.

Fixes #7 Refs #68

justinfx commented 5 years ago

Thanks for merging. It this going to get a new minor tag?

majek commented 5 years ago

v0.0.8 is yours. Thanks for the hard work.