[Biopython-dev] Python 3 status (ignoring our C code and most dependencies)

Eric Talevich eric.talevich at gmail.com
Fri Sep 10 16:30:56 UTC 2010


On Thu, Sep 9, 2010 at 1:08 PM, Peter <biopython at maubp.freeserve.co.uk> wrote:
> Eric - Can you reproduce this test_Phylo.py failure on your machine?
> And is there any chance you'll be able to look at the Bio.PDB issue
> with DisorderedResidue?

I'll try to give these a shot this weekend:

> ------------------------------------------------------------------------
> test_PDB ... FAIL
>
> TypeError: 'DisorderedResidue' object is not subscriptable
>
> See:
> http://lists.open-bio.org/pipermail/biopython-dev/2010-August/008159.html

I took an initial look at it and was baffled. 2to3 doesn't seem to do
anything that would affect it, and the relevant part of the code is an
interesting tangle of if-else clauses related to the state of
something non-local. So, this will take some careful stepping-through.

Does anyone else have any hints on why this might be happening?


> ------------------------------------------------------------------------
> test_Phylo ... FAIL
>
> Traceback (most recent call last):
>  File "test_Phylo.py", line 47, in test_convert
>    Phylo.convert(self.mem_file, 'nexus', mem_file_2, 'phyloxml')
>  File "/home/xxx/repositories/biopython/Bio/Phylo/_io.py", line 102, in convert
>    return write(trees, out_file, out_format, **kwargs)
>  File "/home/xxx/repositories/biopython/Bio/Phylo/_io.py", line 92, in write
>    n = getattr(supported_formats[format], 'write')(trees, file, **kwargs)
>  File "/home/xxx/repositories/biopython/Bio/Phylo/PhyloXMLIO.py",
> line 148, in write
>    return Writer(obj).write(file, encoding=encoding, indent=indent)
>  File "/home/xxx/repositories/biopython/Bio/Phylo/PhyloXMLIO.py",
> line 684, in write
>    self._tree.write(file, encoding)
>  File "/home/xxx/lib/python3.1/xml/etree/ElementTree.py", line 659, in write
>    self._write(file, self._root, encoding, {})
>  File "/home/xxx/lib/python3.1/xml/etree/ElementTree.py", line 677, in _write
>    file.write(_encode("<" + tag, encoding))
> TypeError: string argument expected, got 'bytes'
>

Neat. I added this test shortly before the Biopython 1.55 release, and
I guess it's doing its job. It might have something to do with the
'encoding' argument triggering some string/byte incompatibility in
ElementTree; I'll check it out.

-Eric




More information about the Biopython-dev mailing list