[Biopython-dev] Leaked handles in PAML unit tests

Brandon Invergo b.invergo at gmail.com
Thu Aug 4 15:38:23 UTC 2011


Hi Peter,
(I'm CCing this to the dev list for the info in the second paragraph)
Thanks for the reply. I solved the Python2 problem by fixing my
PYTHONPATH. Running the tests from the Tests directory couldn't find the
Bio module due to a mistake in the PYTHONPATH, so I tried to run them
from the parent directory, resulting in test failures. A dumb mistake
but anyway it's fixed. Sorry for wasting your time with that.

I still have the following error with Python 3.2, though, which prevents
me from figuring out the leaked handle problem in Py3k:
[brandon at brandon-linux Tests]$ python test_PAML_baseml.py
Traceback (most recent call last):
  File "test_PAML_baseml.py", line 10, in <module>
    from Bio.Phylo.PAML import baseml
  File "/home/brandon/Projects/pypaml/biopython/Bio/Phylo/__init__.py",
line 12, in <module>
    from Bio.Phylo._io import parse, read, write, convert
  File "/home/brandon/Projects/pypaml/biopython/Bio/Phylo/_io.py", line
12, in <module>
    from Bio.Phylo import BaseTree, NewickIO, NexusIO
  File "/home/brandon/Projects/pypaml/biopython/Bio/Phylo/BaseTree.py",
line 222
    return u'%s(%s)' % (self.__class__.__name__,

SyntaxError: invalid syntax

Regarding that specific error, I think all strings are implicitly
unicode in Python 3, aren't they? I don't have much experience with
maintaing Py2/3 compatibility, though, so I don't know how to best
handle this. Searching for the unicode operator (u') in the entire Bio
file tree shows that it only exists in Phylo/PhyloXML.py and
Phylo/BaseTree.py.

-brandon

On Wed, 2011-08-03 at 13:33 +0100, Peter Cock wrote:
> On Wed, Aug 3, 2011 at 11:18 AM, Brandon Invergo <b.invergo at gmail.com> wrote:
> > Hi Peter,
> > I'm still in the process of looking at them now but I'm running into a
> > side issue that maybe you can help with. I've tried running the unit
> > tests myself using both Python 2.7.2 and Python 3.2.1, the two versions
> > I have, and both times it fails.
> 
> Python 3 takes a bit more effort to debug due to the 2to3 thing
> and different paths - so I'd focus on Python 2.7 initially.
> 
> > Just looking at test_PAML_baseml.py, for example, with Python 2 I get a
> > lot of test failures due to baseml.py now (correctly) throwing IOErrors
> > rather than AttributeErrors or TypeErrors. With Python 3, on the other
> > hand, I get syntax errors in BaseTree.py (I'll include the output of
> > both below). I did a git pull upstream master before doing this, so my
> > code should be up-to-date (it seems like the unit tests are out-of-date,
> > re: the error types). Now, clearly these have passed on the build
> > machine so I'm wondering what I could be doing wrong.  Being able to
> > replicate the test failures in Python 3 on my machine will really help
> > in fixing them.
> > Sorry about the probable-newbie question...
> 
> What does "git status" give you?
> 
> My usual routine is as follows, but I clone from the official repository
> (which is therefore called origin), and have my personal one setup
> as peterjc via "git remote add ...":
> 
> git checkout master #if not there already
> git fetch origin
> git status #should say behind and can FF merge
> git merge origin/master #should now have latest code
> 
> I'm guessing you're working from a clone of your github repo?
> 
> An easy thing to try is a fresh clone of the official biopython.
> 
> The other key point is all the unit tests expect the current
> directory to be the Tests directory NOT the parent directory
> where setup.py lives.
> 
> Note if you just do "python test_PAML_baseml.py" this will
> pickup the installed Biopython (via PYTHONPATH etc).
> 
> One option is "runtests.py test_PAML_baseml.py" which
> will use the local code for you.
> 
> If you do "python Tests/test_PAML_baseml.py" this should
> pickup the source code for Biopython (won't work for any
> compiled modules IIRC).
> 
> Peter

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: This is a digitally signed message part
URL: <http://lists.open-bio.org/pipermail/biopython-dev/attachments/20110804/e63fea3a/attachment.sig>


More information about the Biopython-dev mailing list