[Numpy-discussion] [PATCH] F2Py on Python 3

Charles R Harris charlesr.harris@gmail....
Wed Sep 22 21:16:48 CDT 2010


On Wed, Sep 22, 2010 at 12:08 PM, Lisandro Dalcin <dalcinl@gmail.com> wrote:

> On 22 September 2010 13:48, Charles R Harris <charlesr.harris@gmail.com>
> wrote:
> >
> >
> > On Wed, Sep 22, 2010 at 8:35 AM, Lisandro Dalcin <dalcinl@gmail.com>
> wrote:
> >>
> >> It seems that lib2to3 does not process the main f2py bootstrap script
> >> that gets autogenerated by f2py's setup.py. The trivial patch below
> >> replaces the print statements with sys.stderr.write() calls. After
> >> that change, f2py works just fine in Python 3.2
> >>
> >>
> >> Index: numpy/f2py/setup.py
> >> ===================================================================
> >> --- numpy/f2py/setup.py (revision 8716)
> >> +++ numpy/f2py/setup.py (working copy)
> >> @@ -62,7 +62,7 @@
> >>     except ValueError: pass
> >>  os.environ["NO_SCIPY_IMPORT"]="f2py"
> >>  if mode=="g3-numpy":
> >> -    print >> sys.stderr, "G3 f2py support is not implemented, yet."
> >> +    sys.stderr.write("G3 f2py support is not implemented, yet.\n")
> >>     sys.exit(1)
> >>  elif mode=="2e-numeric":
> >>     from f2py2e import main
> >> @@ -72,7 +72,7 @@
> >>  elif mode=="2e-numpy":
> >>     from numpy.f2py import main
> >>  else:
> >> -    print >> sys.stderr, "Unknown mode:",`mode`
> >> +    sys.stderr.write("Unknown mode: '%s'\n" % mode)
> >>     sys.exit(1)
> >>  main()
> >>  '''%(os.path.basename(sys.executable)))
> >>
> >>
> >
> > I'm also wondering if we shouldn't raise an error instead of writing to
> > stderr.
> >
>
> sys.exit(1) below the sys.stderr.write() is supposed to exit Python
> with an error status to the invoker of f2py. So I think nothing more
> have to be done.
>
>
>
Done in  29cccb6.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20100922/c6073ec2/attachment.html 


More information about the NumPy-Discussion mailing list