Skip to content

Conversation

AA-Turner
Copy link
Member

@AA-Turner AA-Turner commented Sep 18, 2025

cc @ericsnowcurrently.

The implementation of channel_id_arg_converter is a bit hacky, but I took advice from @erlend-aasland here, and it does work. Perhaps we could use a different mechanism to obtain module state in channel_id_converter() rather than stuffing the module object into channel_id_converter_data, but that is existing code & may have other design considerations, so I haven't proposed anything in this direction.

A

/*[python end generated code: output=da39a3ee5e6b4b0d input=78e17eef989afa6b]*/

static int
channel_id_arg_converter(PyObject *module, PyObject *arg, void *ptr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to use a void pointer here. (Implying you can also get rid of the casting and temporary cid_ptr stuff below.

Suggested change
channel_id_arg_converter(PyObject *module, PyObject *arg, void *ptr)
channel_id_arg_converter(PyObject *module, PyObject *arg, int64_t *cid)

Copy link
Member

@ericsnowcurrently ericsnowcurrently left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I left a few random comments, but they probably don't need any changes since this is a private, low-level module.

Comment on lines +2354 to +2364
broken_limited_capi = True

def parse_arg(self, argname, displayname, *, limited_capi):
assert not limited_capi
return self.format_code("""
if (!{converter}(module, {argname}, &{paramname})) {{{{
goto exit;
}}}}
""",
argname=argname,
converter=self.converter)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is all this needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it because of the "module" argument?

unboundop as unboundarg: int = -1
fallback as fallbackarg: int = -1
*
blocking: bool = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default for blocking depends on timeout, rather than just being True.

unboundop as unboundarg: int = -1
fallback as fallbackarg: int = -1
*
blocking: bool = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise, the default for blocking depends on timeout.

Comment on lines +3323 to +3324
* recv is None and send is None:
- raise ChannelNotEmptyError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, None isn't actually allowed is it? That really isn't something you've changed and I'm not sure I'd worry about it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is None converted to False for p? Does that continue to work under argument clinic?

Comment on lines +3305 to +3306
send: bool = False
recv: bool = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, it isn't exactly just True or False. The default is "close both" (the same as when both are True), which is why I described it as None in the original docstring. Saying the default is both False could be confusing. Then again, this is a private, low-level module so I suppose it doesn't matter much.

Comment on lines +3352 to +3353
send: bool = False
recv: bool = False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise about True/False.

Comment on lines +3471 to +3472
send: object(subclass_of='&PyType_Type', type='PyTypeObject *')
recv: object(subclass_of='&PyType_Type', type='PyTypeObject *')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

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

Successfully merging this pull request may close these issues.

3 participants