Skip to content

Expose return_errors parameter to Python wrapper APIs. #618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2023

Conversation

gregtws
Copy link
Contributor

@gregtws gregtws commented Sep 12, 2023

Creating this draft PR based on discussion in #617. I've tried to keep the API compatible with defaults reflecting existing behavior. I'm not super familiar with pybind and if there were specific doc patterns you'd prefer so hopefully what I've done is reasonable.

One challenge is since existing APIs return None when there's no match (regardless of errors), with return_errors=True we have a somewhat awkward mode where it could return None (nothing at all found) or a result with errors (something found, but errors occurred). This forces callers in this mode to check twice for a clean scan result via if result is not None and result.valid. I'm not super excited about this, but seemed like the least bad way without changing the API completely (like a separate function).

By default errors will not be returned (so API compatible with defaults). When errors are requested, results with errors will only be returned when possible barcodes were found.

Copy link
Collaborator

@axxel axxel left a comment

Choose a reason for hiding this comment

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

That looks pretty nice. Could you fix the merge conflict and update the 3 doc strings? Thanks for your contribution.

@axxel
Copy link
Collaborator

axxel commented Sep 14, 2023

we have a somewhat awkward mode where it could return None (nothing at all found) or a result with errors (something found, but errors occurred).

I don't see anything awkward with this approach at all. That is exactly how the c++ API works and if the caller is not interested in erroneous symbols, then they can simply leave the return_errors parameter alone.

By default errors will not be returned.  When requested,
results with errors will only be returned when possible
barcodes were found.
@gregtws gregtws force-pushed the python-return-errors branch from 4ef3817 to 73761c0 Compare September 14, 2023 16:07
@gregtws
Copy link
Contributor Author

gregtws commented Sep 14, 2023

Made fixes, pushed a rebased version of the branch.

@gregtws gregtws marked this pull request as ready for review September 14, 2023 16:08
@axxel axxel merged commit c4887bf into zxing-cpp:master Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy