f90nml: Write bug in v0.20

I’m getting an odd bug when trying the write the following namelist:

 &a
 b%c_d_E(1)%ID = 1,
 b%c_d_E(2)%ID = 2,
 /

Code is:

    import f90nml
    data = f90nml.read('test.nml')
    with open('test_RESAVED.nml','w') as f:
        data.write(f, force=True)

Error message is:

Traceback (most recent call last):
  File "test.py", line 309, in <module>
    data.write(f, force=True)
  File "C:\Anaconda3\lib\site-packages\f90nml\namelist.py", line 232, in write
    self.write_nmlgrp(grp_name, grp_vars, nml_file)
  File "C:\Anaconda3\lib\site-packages\f90nml\namelist.py", line 253, in write_nmlgrp
    for v_str in self.var_strings(v_name, v_val, v_start=v_start):
  File "C:\Anaconda3\lib\site-packages\f90nml\namelist.py", line 302, in var_strings
    v_strs = self.var_strings(v_title, f_vals, v_start=v_start_new)
  File "C:\Anaconda3\lib\site-packages\f90nml\namelist.py", line 313, in var_strings
    i_s = v_start[::-1][len(v_idx)]
TypeError: 'NoneType' object is not subscriptable

Oddly, when I change c_d_E to c_d_e, it works fine.

I just updated to the latest release using pip. I’ve been able to read variables like this before, so something has changed.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 20 (12 by maintainers)

Commits related to this issue

Most upvoted comments

Sorry about that, I had hoped to look into that 72+ character variable name bug, but never got a chance. I’ve done a version update containing the derived type changes though and sent it to pypi

On Thu, Feb 2, 2017 at 7:21 AM, Jacob Williams notifications@github.com wrote:

Any chance of getting an 0.21 release that includes these fixes?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/marshallward/f90nml/issues/40#issuecomment-276770662, or mute the thread https://github.com/notifications/unsubscribe-auth/AAcN63RdPTaAmc9Rb-wyJPYNKgK2H0K3ks5rYOlWgaJpZM4LaIOW .