-
Notifications
You must be signed in to change notification settings - Fork 153
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
PaddedString decoding error handling #1073
Comments
No any solution :(? |
That's not support since it looks like it just does a call to decode/encode with just the encoding. A solution would be to update construct to support it, or to make your own custom adapter. Alternatively, if you okay with a sneaky hack, you could temporarily change the default "strict" error handler that is used with import codecs
spec = PaddedString(5, "ascii")
try:
codecs.register_error("strict", codecs.replace_errors) # set "strict" to use the "replace" handler
my_str = spec.parse(b"he\xfflo")
finally:
codecs.register_error("strict", codecs.strict_errors) # restore proper handler |
Sorry, I'm bad with my git... And bad in python :D
|
Seems good. I would make a PR. But a couple notes on first observation:
|
Sorry, my knowledge of Python is bad ;( |
@jpsnyder still need my updated patch? Thank you |
Sorry, I"m not the maintainer for this project. I'm just a lurker. I would make the PR yourself, best way to learn how to do it :) |
Ohhh :D |
Hello
If I have in code something like that PaddedString(11, "ascii"), is it possible error handling behavior like in bytes.decode('ascii', errors='replace')?
Thank you.
The text was updated successfully, but these errors were encountered: