Issue 1:
integer function breaksf2py(arg)
integer, intent(in) :: arg

breaksf2py = 2 * arg
end

Compiling with f2py -m foo breaksf2py.f90 works fine, but f2py -m foo -h foo.pyf breaksf2py.f90 gives the following error for python3 f2py (tested with 3.2 and 3.3)

Reading fortran codes...

Reading file 'breaksf2py.f90' (format:free)

Post-processing...

Block: foo

Block: breaksf2py

Post-processing (stage 2)...

Saving signatures to file "./foo.pyf"

Traceback (most recent call last):

File "/usr/bin/f2py-3.2", line 24, in

main()

File "/usr/lib64/python3.2/site-packages/numpy/f2py/f2py2e.py", line 590, in main

run_main(sys.argv[1:])

File "/usr/lib64/python3.2/site-packages/numpy/f2py/f2py2e.py", line 361, in run_main

postlist=callcrackfortran(files,options)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/f2py2e.py", line 286, in callcrackfortran

pyf=crackfortran.crack2fortran(postlist)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2749, in crack2fortran

pyf=crack2fortrangen(block)+'\n'

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2517, in crack2fortrangen

ret=ret+crack2fortrangen(g,tab,as_interface=as_interface)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2561, in crack2fortrangen

vars=vars2fortran(block,block['vars'],argsl,tab+tabchar, as_interface=as_interface)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2711, in vars2fortran

lst = true_intent_list(vars[a])

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2612, in true_intent_list

if c:

UnboundLocalError: local variable 'c' referenced before assignment

Python2 f2py can run f2py-2.7 -m foo -h foo.pyf breaksf2py.f90 fine, and python3 f2py can compile the resulting pyf file with f2py-3.3 -m foo -c foo.pyf breaksf2py.f90.

Issue 2:
Original ticket http://projects.scipy.org/numpy/ticket/1932 on 2011-08-12 by trac user josdekloe, assigned to @pearu.

I have been trying to use the f2py routinely to build an interface around the ECMWF BUFR library. See http://code.google.com/p/pybufr-ecmwf/ for details. This works fine for the python 2.x versions.

However, I also tried to add the possibility to use python3 and here I encountered some trouble. My python code converts properly to python3 using to 2to3 tool, but when I try to use the python3 version of f2py I encounter this error somewhere deep inside the f2py internals:

Post-processing (stage 2)...

Saving signatures to file "f2py_build/signatures.pyf"

Traceback (most recent call last):

File "./run_f2py_tool.py", line 11, in

main()

File "/usr/lib64/python3.2/site-packages/numpy/f2py/f2py2e.py", line 563, in main

run_main(sys.argv[1:])

File "/usr/lib64/python3.2/site-packages/numpy/f2py/f2py2e.py", line 342, in run_main

postlist=callcrackfortran(files,options)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/f2py2e.py", line 279, in callcrackfortran

pyf=crackfortran.crack2fortran(postlist)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2693, in crack2fortran

pyf=crack2fortrangen(block)+'\n'

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2465, in crack2fortrangen

ret=ret+crack2fortrangen(g,tab)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2505, in crack2fortrangen

body=crack2fortrangen(block['body'],tab+tabchar)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2465, in crack2fortrangen

ret=ret+crack2fortrangen(g,tab)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2505, in crack2fortrangen

body=crack2fortrangen(block['body'],tab+tabchar)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2465, in crack2fortrangen

ret=ret+crack2fortrangen(g,tab)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2506, in crack2fortrangen

vars=vars2fortran(block,block['vars'],al,tab+tabchar)

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2655, in vars2fortran

lst = true_intent_list(vars[a])

File "/usr/lib64/python3.2/site-packages/numpy/f2py/crackfortran.py", line 2557, in true_intent_list

if c:

UnboundLocalError: local variable 'c' referenced before assignment

ERROR: build of python wrapper failed

the signatures file could not be found

Traceback (most recent call last):

File "./build_interface.py", line 1803, in

BI.build()

File "./build_interface.py", line 543, in build

self.generate_python_wrapper(source_dir)

File "./build_interface.py", line 1667, in generate_python_wrapper

raise InterfaceBuildError

main.InterfaceBuildError

I any additional information is needed I would be happy to provide it.