[Biopython-dev] TravisCI BioSQL - TypeError: unhashable type: 'bytearray'

Evan Parker eparker05 at gmail.com
Fri Oct 10 00:22:24 UTC 2014


I tried a few things today and came up with a fix. I can't speak to the
efficiency of this fix but it does pass local tests and Travis-CI. I made a
helper function to filter out bytearrays (and byte strings) and convert
them to the Python version appropriate string type. I then applied this
function to query methods in the Adaptor class of BioSQL/BioSeqDatabase.py.
See the following commit.

https://github.com/eparker05/biopython/commit/c6f0d17a37321b512818b8070b9e8a82bbc4493e

It would be nice if there was a more direct way to fix this, but the mysql
database connector isn't documented all that well. My hope initially was to
use the MySQL cursor to prevent the return of bytearrays in favor of a more
typical string type, but I couldn't find any way to do this. If somebody
figures that out, it would probably be a better fix.


On Thu, Oct 9, 2014 at 4:18 PM, Chris Mitchell <chris.mit7 at gmail.com> wrote:

> Also for a fix, i haven't tried this yet but my guess is the
> mysql-connector-python update is returning bytearrays (maybe a python3
> move?). So we need to wrap the cursor for each result. Currently, we check
> if each element is of type bytes, which is an str but a bytearray is an
> array of ints. So we should be doing something like if isinstance(xxx[],
> (bytes, int)): xxx[0].decode('utf-8')
>
> Sent from my phone.
> On Oct 9, 2014 6:04 PM, "Peter Cock" <p.j.a.cock at googlemail.com> wrote:
>
>> On Thu, Oct 9, 2014 at 6:27 PM, Chris Mitchell <chris.mit7 at gmail.com>
>> wrote:
>> > Have you tried specifying the working version of mysql-connector-python
>> with
>> > pip?
>> >
>> > ie. pip install mysql-connector-python==xxx
>>
>> No, but that might be nicer in the short term than simply skipping
>> installing and testing with mysql-connector-python on TravisCI.
>>
>>
>> https://github.com/biopython/biopython/commit/4d54e46549df2a6cfc9815af38066ede1ce7f280
>> https://github.com/biopython/biopython/issues/370
>>
>> Anyone can fork Biopython, enable TravisCI on your fork, and
>> then try modifying the .travis.yml file to test this... ;)
>>
>> Peter
>>
>
> _______________________________________________
> Biopython-dev mailing list
> Biopython-dev at mailman.open-bio.org
> http://mailman.open-bio.org/mailman/listinfo/biopython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython-dev/attachments/20141009/243b055f/attachment.html>


More information about the Biopython-dev mailing list