-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Avoid multi-megabyte error message #1683
Avoid multi-megabyte error message #1683
Conversation
If the incorrect data was large, this error message was very large. Ended up with a 300MB error log output because of this on a single real dicom.
Hello @chris-remedy! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found: There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻 Comment last updated at 2022-08-25 15:06:04 UTC |
Codecov Report
@@ Coverage Diff @@
## master #1683 +/- ##
==========================================
+ Coverage 97.58% 97.68% +0.10%
==========================================
Files 66 66
Lines 10712 10712
==========================================
+ Hits 10453 10464 +11
+ Misses 259 248 -11
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -388,7 +389,8 @@ def convert_numbers( | |||
if length % bytes_per_value != 0: | |||
raise BytesLengthException( | |||
"Expected total bytes to be an even multiple of bytes per value. " | |||
f"Instead received {byte_string!r} with length {length} and " | |||
f"Instead received {shorten(repr(byte_string), width=10_000)} " | |||
f"with length {length} and " | |||
f"struct format '{struct_format}' which corresponds to bytes per " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this, it's a good idea to clip this output somehow.
But when I try shorten
on some binary values I always get "[...]", so it's not very helpful.
E.g.
b = b"\5" * 100
shorten(repr(b), 50)
'[...]'
Also, I think 10_000 is still too large to display and be helpful.
I would suggest if length
is less than say, a few hundred, print the whole repr, otherwise the message can skip the repr(byte_string)
and just print the length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, how's that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add an entry to the Release Notes?
@mrbean-bremen done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Describe the changes
If the incorrect data was large, this error message was very large. Ended up with a 300MB error log output because of this on a single real dicom.
Tasks
doc/_build/html/index.html
)