Skip to content
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

Allow Salmon to do something other than raise an exception when encountering certain decoding errors #148

Open
moggers87 opened this issue Feb 27, 2021 · 0 comments
Labels
enhancement It's not a bug, but it could be a feature

Comments

@moggers87
Copy link
Owner

It would be great if Salmon could be told to treat errors in byte decoding with something other than "strict". For example, it might be desirable to use "replace" instead if half an email was better than no email.

guess_encoding_and_decode has an optional argument errors which is set to DEFAULT_ERROR_HANDLING by default. Because this is set in the function signature it's impossible to monkey-patch the default to some other value without monkey-patching the entire function.

I imagine this was the original intention behind errors/DEFAULT_ERROR_HANDLING as other variables can be monkey-patched at runtime in lieu of a proper settings sytems.

  1. Change the default value of errors to None and then set errors to DEFAULT_ERROR_HANDLING if errors is still None when the function is called.
  2. Go up the function chain, all the way up to calls from MailRequest and give each one an errors argument. Also give MailRequest some property which can be set after object initialisation that controls the value of errors.

1 is required to be done to close this issue, 2 would be nice if there aren't too many functions between MailRequest and guess_encoding_and_decode

@moggers87 moggers87 added the enhancement It's not a bug, but it could be a feature label Feb 27, 2021
moggers87 added a commit to Inboxen/Inboxen that referenced this issue Feb 27, 2021
moggers87 added a commit to Inboxen/Inboxen that referenced this issue Feb 27, 2021
moggers87 added a commit to Inboxen/Inboxen that referenced this issue Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement It's not a bug, but it could be a feature
Projects
None yet
Development

No branches or pull requests

1 participant