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

BUG: Handle --lower for F2PY directives and callbacks #27728

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG: Fix handling of f2py directives with --lower
  • Loading branch information
HaoZeke committed Nov 9, 2024
commit ab3aee356d3ee0877fba4a5319b5f14d0978894b
10 changes: 7 additions & 3 deletions 10 numpy/f2py/crackfortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,14 @@ def readfortrancode(ffile, dowithline=show, istop=1):
if l[-1] not in "\n\r\f":
break
l = l[:-1]
# Do not lower for directives, gh-2547, gh-27697, gh-26681
is_f2py_directive = False
# Unconditionally remove comments
(l, rl) = split_by_unquoted(l, '!')
l += ' '
if rl[:5].lower() == '!f2py': # f2py directive
l, _ = split_by_unquoted(l + 4 * ' ' + rl[5:], '!')
is_f2py_directive = True
if l.strip() == '': # Skip empty line
if sourcecodeform == 'free':
# In free form, a statement continues in the next line
Expand All @@ -449,6 +452,7 @@ def readfortrancode(ffile, dowithline=show, istop=1):
if l[0] in ['*', 'c', '!', 'C', '#']:
if l[1:5].lower() == 'f2py': # f2py directive
l = ' ' + l[5:]
is_f2py_directive = True
else: # Skip comment line
cont = False
continue
Expand Down Expand Up @@ -476,7 +480,7 @@ def readfortrancode(ffile, dowithline=show, istop=1):
else:
# clean up line beginning from possible digits.
l = ' ' + l[5:]
if localdolowercase:
if localdolowercase and not is_f2py_directive:
finalline = ll.lower()
else:
finalline = ll
Expand Down Expand Up @@ -504,7 +508,7 @@ def readfortrancode(ffile, dowithline=show, istop=1):
finalline = ''
origfinalline = ''
else:
if localdolowercase:
if localdolowercase and not is_f2py_directive:
finalline = ll.lower()
else:
finalline = ll
Expand Down Expand Up @@ -537,7 +541,7 @@ def readfortrancode(ffile, dowithline=show, istop=1):
else:
dowithline(finalline)
l1 = ll
if localdolowercase:
if localdolowercase and not is_f2py_directive:
finalline = ll.lower()
else:
finalline = ll
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.