-
Notifications
You must be signed in to change notification settings - Fork 293
Fix error text when array tag typecode is invalid #1235
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
Fix error text when array tag typecode is invalid #1235
Conversation
|
Thanks! I think your fix is the appropriate one. |
|
Digging a bit deeper I think this is obfuscating a deeper bug in this function. It seems that when the |
|
I am relatively certain that this is a bug now. It looks like the overloading of the |
|
I have been looking into this in the context of #1233. The correct fix to the error message is to change that to The function is unnecessarily incomprehensible because “typecode” is used to mean two different things: the Python array type code and the SAM/BAM aux type code. So the variables representing the SAM thing need to be renamed to Your last comment has been misled by this: |
I think we are saying the same thing here (made confusing by the overloaded meaning put on the In any case if you are working on this method and it will be fixed in the next release I will leave it to you. If you'd like for me to have a go at it I'd be more than happy to do so. I guess google has not scraped issue #1233 as I did not get this hit when starting to look into this issue. |
There is no `array.typecode` class attribute, so the `array.array` arm produced an AttributeError instead of the intended ValueError. Perhaps `value.typecode` was intended; but this error only arises when a `value_type` has been specified, so the array's typecode has no influence on `typecode` anyway. So we simplify the message. Also add a similar check in the scalar arm of this if-else to avoid an invalid `typecode` here being reported as a raw KeyError. Fixes pysam-developers#1233. Closes pysam-developers#1235 -- hat tip @marcus1487 for issue analysis. [TODO] All this code is confusing and should be rewritten using HTSlib's more recent aux field manipulation APIs.
Revisiting this again now, I think your version is closer to the right answer. This error only arises when a non-None However I also think it's intentional and reasonable that the The “further improvements” I had planned were to raise a bespoke exception that would track the read's QNAME etc so that you could identify where problems occurred more easily. But that can be deferred to another time. |
In current master when, this line is hit it raises an error reporting:
AttributeError: module 'array' has no attribute 'typecode'. This is due to an apparent bug in the formatting of the intended error text. In order to report the valid error text this should be resolved. I believe the intent here is to report the typecode ordinal value (with the character provided earlier), but the intent may have been to report thevalue.typecodein this error text. I can revert that in this PR if that is indeed the intent.