-
-
Notifications
You must be signed in to change notification settings - Fork 600
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
Print NSData's hash instead of byte description in error messages #263
Conversation
Hey @inket, Looks good to me. Although I would like to have a test to make sure this doesn't regress at a later period before merging this in. |
Alright 👍 |
Do you think it would be useful to also include the data's byte count in the output? |
Thought about it but couldn't think of an appropriate format to represent it: It is indeed useful to show the byte count as it would make it easy to tell whether an NSData is empty or not (and other things) at a glance. |
I like the first one, myself! |
After implementing tests, it seems that the Linux test fails because NSData's hash() causes a segmentation fault. Using the REPL on Mac:
on Linux:
I fixed that by using |
Oh shoot, that's unfortunate. There are a number of places where we have introduced conditionals for Linux behavior already, and it seems reasonable to me to do so here as well. Please do leave a comment indicating the reason for it so that it is easier to try again in a few weeks/months and see if the issue has been fixed. It'd be great if you could log an issue in bugs.swift.org as well! |
Printing the byte description of a 1MB NSData is long enough to keep printing for a while, and to freeze Xcode because of the length of the resulting message. Print "NSData<hash=*,length=*>" instead as it's a decent representation of identity/equality.
Thanks! This PR is good for a last review now 😁 Will report the bug on the Swift bug tracker later. |
Print NSData's hash instead of byte description in error messages
LGTM, thanks @inket! |
Print NSData's hash instead of byte description in error messages
closes #259
Printing the byte description of a 1MB NSData is long enough to keep printing for a while, and to freeze Xcode because of the length of the resulting message.
Print "NSData" instead as it's a decent representation of identity/equality (although not perfect).