◐ Shell
reader mode source ↗
Skip to content

bpo-42064: Pass module state to trace, progress, and authorizer callbacks#27940

Merged
encukou merged 17 commits into
python:mainfrom
erlend-aasland:sqlite-callback-state/part2
Sep 7, 2021
Merged

bpo-42064: Pass module state to trace, progress, and authorizer callbacks#27940
encukou merged 17 commits into
python:mainfrom
erlend-aasland:sqlite-callback-state/part2

Conversation

@erlend-aasland

@erlend-aasland erlend-aasland commented Aug 25, 2021

Copy link
Copy Markdown
Contributor
  • add print-or-clear traceback helper
  • add helpers to clear and visit saved contexts
  • modify callbacks to use the new callback_context struct

https://bugs.python.org/issue42064

@erlend-aasland

erlend-aasland commented Aug 25, 2021

Copy link
Copy Markdown
Contributor Author

On hold until #27934 is merged. There should be no conflicts with #27931.

This PR will need a rebase after #27934 is merged.

@erlend-aasland erlend-aasland marked this pull request as ready for review August 31, 2021 12:41
@erlend-aasland erlend-aasland requested a review from encukou August 31, 2021 12:41

@encukou encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Nitpick:
SET_CALLBACK_CONTEXT and CLEAR_CALLBACK_CONTEXT can both be regular functions rather than macros, making them shorter and more readable.
That leaves VISIT_CALLBACK_CONTEXT, which I think is too robust for the 3 uses. But that's very much a personal opinion.

@erlend-aasland

Copy link
Copy Markdown
Contributor Author

SET_CALLBACK_CONTEXT and CLEAR_CALLBACK_CONTEXT can both be regular functions rather than macros, making them shorter and more readable.
That leaves VISIT_CALLBACK_CONTEXT, which I think is too robust for the 3 uses. But that's very much a personal opinion.

  • VISIT_CALLBACK_CONTEXT cannot be implemented as a regular function since it uses Py_VISIT; I prefer to keep the macro
  • I'll change CLEAR_CALLBACK_CONTEXT to a regular function; I have no strong opinion about this :)
  • SET_CALLBACK_CONTEXT will IMO be more complex as a function, since it would take a pointer to a pointer as an argument; if you have a strong opinion about this, I'll of course change it

@erlend-aasland

Copy link
Copy Markdown
Contributor Author

NB, this needs to be rebased onto main after #28088 is merged, assuming of course that it'll be easier to land that PR.

@encukou

encukou commented Sep 7, 2021

Copy link
Copy Markdown
Member

will IMO be more complex as a function, since it would take a pointer to a pointer as an argument

Personally I'd prefer a type-safe function with a more complex argument, but as I said, this is nitpicking. Feel free to make them all macros for consistency, if you find it easier to read :)

I plan to review #28088 first.

@erlend-aasland

Copy link
Copy Markdown
Contributor Author

will IMO be more complex as a function, since it would take a pointer to a pointer as an argument

Personally I'd prefer a type-safe function with a more complex argument, but as I said, this is nitpicking. Feel free to make them all macros for consistency, if you find it easier to read :)

I'll keep VISIT_CALLBACK_CONTEXT function a macro in any case, but I'll think thrice about SET_CALLBACK_CONTEXT before deciding :)

I plan to review #28088 first.

Great, thanks!

BTW, I'm creating a bpo for cleaning up connection __init__; I've got a WIP branch lying around already, so you can expect a PR anytime soon :)

@erlend-aasland

Copy link
Copy Markdown
Contributor Author

All right, no more changes comin' up, unless you've got further remarks :)

@encukou encukou left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hide comment

Looks good, thanks!

@erlend-aasland

Copy link
Copy Markdown
Contributor Author

Looks good, thanks!

Likewise!

@encukou encukou merged commit 979336d into python:main Sep 7, 2021
@erlend-aasland erlend-aasland deleted the sqlite-callback-state/part2 branch September 7, 2021 13:06
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.

4 participants