Fix error_code() reporting errors in Data::BitStream instead of caller#1
Open
Stevie-O wants to merge 3 commits intodanaj:masterfrom
Open
Fix error_code() reporting errors in Data::BitStream instead of caller#1Stevie-O wants to merge 3 commits intodanaj:masterfrom
Stevie-O wants to merge 3 commits intodanaj:masterfrom
Conversation
error_code() uses 'confess' to raise errors from the perspective of the caller. However, that caller is always a component of Data::BitStream, so the result looks like this: invalid parameters: bits must be <= 64 at C:/Perl64/site/lib/Data/BitStream/WordVec.pm line 107. By including 'ref $self' in @CARP_NOT, the error message points to the correct location: invalid parameters: bits must be <= 64 at myscript.pl line 125.
WordVec::to_raw returns the raw internal buffer directly, which may not be correct in all cases, due to optimizations elsewhere. The two cases in particular are as follows: * write(N, 0) does not actually store N '0' bits in the buffer; instead, it simply increments the internal length indicator. As such, if the last write to the stream wrote a zero value, to_raw() may be shorter than it ought to be. * Other write operations increase the size by multiples of 32 bits. Therefore, the return value could be up to 3 bytes longer than it should have been.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
error_code() uses 'confess' to raise errors from the perspective of the
caller. However, that caller is always a component of Data::BitStream, so
the result looks like this:
invalid parameters: bits must be <= 64 at C:/Perl64/site/lib/Data/BitStream/WordVec.pm line 107.
By including 'ref $self' in @CARP_NOT, the error message points to the correct
location:
invalid parameters: bits must be <= 64 at myscript.pl line 125.