[Biopython] Bio.Entrez.epost error with Python 3.2
Nicolas Joannin
nicolas.joannin at gmail.com
Fri Mar 22 01:50:15 UTC 2013
Hello Peter,
I might not have followed the correct procedure for reporting the problem.
If that is the case, please let me know the correct procedure.
What I had done was email the biopython mailing list with my question,
including an example and the
output<http://lists.open-bio.org/pipermail/biopython/2013-January/008307.html>
.
>From that question, I received two replies from Michiel de Hoon
(first<http://lists.open-bio.org/pipermail/biopython/2013-January/008309.html>and
second<http://lists.open-bio.org/pipermail/biopython/2013-January/008310.html>),
to which I replied
to<http://lists.open-bio.org/pipermail/biopython/2013-January/008313.html>
...
After that, you replied as
well<http://lists.open-bio.org/pipermail/biopython/2013-January/008314.html>.
At that point, my wife gave birth and I was off the grid until recently...
As I mentioned, am still in need of a solution, which is why I emailed
again (in reply to your last email).
Seeing your response, I am guessing that emailing the mailing list is not
quite the proper way, so, could you tell me the proper way to report
problems?
Regarding my and your suggested solutions, I have never worked with Python
2.X, so I don't know if my solution would break it when used with Python 2.
But I guess so.
I have tested your solution and that works as well in my testing.
(My testing, after modifying the Entrez.__init__.py file:
>>>from Bio import Entrez
>>>Entrez.email='my at email'
>>>post_h=Entrez.epost("nuccore",id="160418,160351")
>>>
)
Best regards,
Nicolas
"Because the world owes me nothing, and we owe each other the world"
Ani Difranco
On Thu, Mar 21, 2013 at 7:44 PM, Peter Cock <p.j.a.cock at googlemail.com>wrote:
> On Thu, Mar 21, 2013 at 8:30 AM, Nicolas Joannin
> <nicolas.joannin at gmail.com> wrote:
> > Hi everyone,
> >
> > I am still in need of a fix for this problem...
>
> Is this a new problem which you have not previously reported?
>
> > I have made an attempt at fixing it myself by adding a line of code in
> > Bio.Entrez.__init__.py:
> >
> > At line 451 there is:
> >
> > try:
> > if post:
> > #HTTP POST
> > options = options.encode('utf-8') #Line added by Nicolas
> > handle = urllib.request.urlopen(cgi, data=options)
> > else:
> > #HTTP GET
> > cgi += "?" + options
> > handle = urllib.request.urlopen(cgi)
> > except urllib.error.HTTPError as exception:
> > raise exception
> >
> > In my (limited) testing, it seems to work...
> > Would this be suitable?
> >
> > Best regards,
> > Nicolas
>
> Assuming you are running this on Python 3.2, it is likely a
> bytes versus unicode issue. I'm guessing, but we'd probably
> want something like this to handle both Python 2 and 3
> (untested):
>
> from Bio._py3k import _as_byte
> ...
> handle = urllib.request.urlopen(cgi, data=_as_bytes(options))
>
> Could you share an example script (just a few lines) to reproduce
> the problem please? And include the error message you get.
>
> Thanks,
>
> Peter
>
More information about the Biopython
mailing list