Bug #3932

assertion triggered with multipart strings

Added by foobar over 5 years ago. Updated about 5 years ago.

Status:ClosedStart date:2012-04-22
Priority:NormalDue date:
Assignee:-% Done:

100%

Category:-
Target version:-

Description

possibly related to #3642

When I compose a multipart string, e.g.:

additional_text: return string(str_purchase_svc_len_lsp, string(str_purchase_svc_lpxx), string(str_purchase_len_2_10), string(str_purchase_lsp_5));

And one of the parameter-strings is not defined in the language file, I get an assertion rather then a "string xxx missing".

nmlc: An internal error has occurred:
nmlc-version: r1880 (9404bd6a9426)
Error:      (AssertionError) .
Command:    ['/usr/bin/nmlc', '-p', 'DOS', 'dutchtrains.nml']
Location:   File "/usr/lib/python2.7/site-packages/nml-r1880-py2.7.egg/nml/grfstrings.py", line 670, in get_string

andy_crash.patch Magnifier (724 Bytes) Alberth, 2012-07-09 18:07

Associated revisions

Revision 1910:a5a804dc81fa
Added by Hirundo about 5 years ago

Fix #3932: Provide a proper error message if a substring is missing, instead of an assertion error (also closes #3674).

Revision 2021:fd13ebe9ccc5
Added by Hirundo about 5 years ago

Fix #3932: Provide a proper error message if a substring is missing, instead of an assertion error (also closes #3674).

Revision 1910:a5a804dc81fa
Added by Hirundo about 5 years ago

Fix #3932: Provide a proper error message if a substring is missing, instead of an assertion error (also closes #3674).

Revision 2021:fd13ebe9ccc5
Added by Hirundo about 5 years ago

Fix #3932: Provide a proper error message if a substring is missing, instead of an assertion error (also closes #3674).

History

#1 Updated by Alberth about 5 years ago

Andythenorth had a similar problem in the FISH project, in revision 749.
Stack-dump (of nml r1908):

Traceback (most recent call last):
  File "~/bin/nmlc", line 6, in <module>
    main.run()
  File "~/nml/hg_trunk/nml/main.py", line 305, in run
    main(sys.argv[1:])
  File "~/nml/hg_trunk/nml/main.py", line 154, in main
    ret = nml(input, input_filename, opts.debug, outputs, opts.sprites_dir, opts.start_sprite_num, opts.forced_palette, opts.md5_filename)
  File "~/nml/hg_trunk/nml/main.py", line 216, in nml
    lang_actions.extend(action4.get_global_string_actions())
  File "~/nml/hg_trunk/nml/actions/action4.py", line 100, in get_global_string_actions
    texts.append( (0x7F, (string_range << 8) | id, grfstrings.get_translation(string_name), feature) )
  File "~/nml/hg_trunk/nml/grfstrings.py", line 127, in get_translation
    return default_lang.get_string(string)
  File "~/nml/hg_trunk/nml/grfstrings.py", line 817, in get_string
    parsed_string += self.strings[string_id].parse_string(str_type, self, string.params)
  File "~/nml/hg_trunk/nml/grfstrings.py", line 547, in parse_string
    ret += comp.parse_string(str_type, lang, stack, static_args)
  File "~/nml/hg_trunk/nml/grfstrings.py", line 334, in parse_string
    return commands[self.name]['parse'](static_args[self.str_pos], lang.langid)
  File "~/nml/hg_trunk/nml/grfstrings.py", line 160, in com_parse_string
    return get_translation(val, lang_id)
  File "~/nml/hg_trunk/nml/grfstrings.py", line 127, in get_translation
    return default_lang.get_string(string)
  File "~/nml/hg_trunk/nml/grfstrings.py", line 806, in get_string
    assert string_id in self.strings

grfstrings.get_translation() seemed to be a good entry point for a check, so I wrote the attached patch which checks whether the string exists in the default language before querying it and raises an exception if not.

#2 Updated by Alberth about 5 years ago

#3674 also seems related

#3 Updated by Hirundo about 5 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

Applied in changeset a5a804dc81fa.

Also available in: Atom PDF