[Biopython-dev] [Bug 2754] Bio.PDB: Parse warnings should print to stderr, not stdout

bugzilla-daemon at portal.open-bio.org bugzilla-daemon at portal.open-bio.org
Thu Feb 12 15:14:33 UTC 2009


http://bugzilla.open-bio.org/show_bug.cgi?id=2754





------- Comment #3 from bsouthey at gmail.com  2009-02-12 10:14 EST -------
(In reply to comment #2)
> Created an attachment (id=1236)
 --> (http://bugzilla.open-bio.org/attachment.cgi?id=1236&action=view) [details]
> Print errors and warnings in Bio.PDB to sys.stderr



(In reply to comment #1)
> This may have implications for how we write further Bio.PDB unit tests, see Bug
> 2759.
> 
> [I still agree that any warnings from Bio.PDB should go to stderr rather than
> stdout]
> 

I believe that we should be using the using Python warnings module for these
types of messages:
http://docs.python.org/library/warnings.html 

This permits the user to have a greater control over the output and also allows
redirecting the output as required. In the Bio directory, there are currently
36 and 25 uses of stderr and stdout, respectively.

In terms of the patch, my limited understanding is that local import sys will
override any global redirection of the output which in my opinion is a bad
idea.

Further it probably implications for the current test_PDB.py (greping stderr):
test_PDB.py:14:# Redirect stderr so user does not see warnings
test_PDB.py:37:    # Class to hide stderr output
test_PDB.py:94:old_stderr = sys.stderr
test_PDB.py:95:# Hide stderr output for user
test_PDB.py:96:sys.stderr=TheVoid()
test_PDB.py:100:    sys.stderr = old_stderr

Also redirection is already being used by the PDB module (from greping):
PDB/NACCESS.py:51:    stdout = out.readlines() 
PDB/NACCESS.py:53:    stderr = err.readlines()

Bruce


-- 
Configure bugmail: http://bugzilla.open-bio.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the Biopython-dev mailing list