Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dfdd35a

Browse filesBrowse files
authored
Merge pull request #28175 from charris/backport-28056
BUG: Fix f2py directives and --lower casing
2 parents e4517a8 + a19acf1 commit dfdd35a
Copy full SHA for dfdd35a

File tree

Expand file treeCollapse file tree

4 files changed

+23
-6
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+23
-6
lines changed

‎numpy/f2py/auxfuncs.py

Copy file name to clipboardExpand all lines: numpy/f2py/auxfuncs.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
'hasexternals', 'hasinitvalue', 'hasnote', 'hasresultnote',
2727
'isallocatable', 'isarray', 'isarrayofstrings',
2828
'ischaracter', 'ischaracterarray', 'ischaracter_or_characterarray',
29-
'iscomplex',
29+
'iscomplex', 'iscstyledirective',
3030
'iscomplexarray', 'iscomplexfunction', 'iscomplexfunction_warn',
3131
'isdouble', 'isdummyroutine', 'isexternal', 'isfunction',
3232
'isfunction_wrap', 'isint1', 'isint1array', 'isinteger', 'isintent_aux',
@@ -423,6 +423,11 @@ def isrequired(var):
423423
return not isoptional(var) and isintent_nothide(var)
424424

425425

426+
def iscstyledirective(f2py_line):
427+
directives = {"callstatement", "callprotoargument", "pymethoddef"}
428+
return any(directive in f2py_line.lower() for directive in directives)
429+
430+
426431
def isintent_in(var):
427432
if 'intent' not in var:
428433
return 1

‎numpy/f2py/crackfortran.py

Copy file name to clipboardExpand all lines: numpy/f2py/crackfortran.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -510,11 +510,9 @@ def readfortrancode(ffile, dowithline=show, istop=1):
510510
origfinalline = ''
511511
else:
512512
if localdolowercase:
513-
# lines with intent() should be lowered otherwise
514-
# TestString::test_char fails due to mixed case
515-
# f2py directives without intent() should be left untouched
516-
# gh-2547, gh-27697, gh-26681
517-
finalline = ll.lower() if "intent" in ll.lower() or not is_f2py_directive else ll
513+
# only skip lowering for C style constructs
514+
# gh-2547, gh-27697, gh-26681, gh-28014
515+
finalline = ll.lower() if not (is_f2py_directive and iscstyledirective(ll)) else ll
518516
else:
519517
finalline = ll
520518
origfinalline = ll
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
subroutine inquire_next(IU)
2+
IMPLICIT NONE
3+
integer :: IU
4+
!f2py intent(in) IU
5+
end subroutine

‎numpy/f2py/tests/test_regression.py

Copy file name to clipboardExpand all lines: numpy/f2py/tests/test_regression.py
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,15 @@ def test_gh26148b(self):
122122
assert(res[0] == 8)
123123
assert(res[1] == 15)
124124

125+
class TestLowerF2PYDirectives(util.F2PyTest):
126+
# Check variables are cased correctly
127+
sources = [util.getpath("tests", "src", "regression", "lower_f2py_fortran.f90")]
128+
129+
@pytest.mark.slow
130+
def test_gh28014(self):
131+
self.module.inquire_next(3)
132+
assert True
133+
125134
@pytest.mark.slow
126135
def test_gh26623():
127136
# Including libraries with . should not generate an incorrect meson.build

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.