Skip to content

Conversation

@OneRaynyDay
Copy link

@OneRaynyDay OneRaynyDay commented Nov 23, 2021

According to CPython documentation: https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_name

For example, a type named T defined in module M in subpackage Q in package P should have the tp_name initializer "P.Q.M.T".

Here, the module we're talking about is cimpl, and the package is confluent_kafka, so therefore it should be confluent_kafka.cimpl.KafkaError and such for the rest of the classes defined.

Also, I add reduce for KafkaError so we can properly pickle it:

>>> import confluent_kafka >>> import pickle >>> err = confluent_kafka.cimpl.KafkaError(1) >>> err.__reduce__() (<class 'confluent_kafka.cimpl.KafkaError'>, (1, 'Broker: Offset out of range', 0, 0, 0)) >>> pickle.loads(pickle.dumps(err)) KafkaError{code=OFFSET_OUT_OF_RANGE,val=1,str="Broker: Offset out of range"} >>> pickle.loads(pickle.dumps(err)) == err True 
@OneRaynyDay
Copy link
Author

Also happy to sign a CLA if necessary.

@joaoe
Copy link

joaoe commented Jun 15, 2023

According to CPython documentation: https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_name

Nice catch. I think that affects all classes implemented in cimpl.

@joaoe
Copy link

joaoe commented Jun 16, 2023

I also added another PR which also includes support for "reducing" Message objects, which end up benefiting from this pull request, if the Message has error set.

@cla-assistant
Copy link

cla-assistant bot commented Aug 15, 2023

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants