{"record":{"id":"d6f2f60743d2bba8","repo":"arduino/Arduino","slug":"runtimeerror","errorCode":null,"errorMessage":"RuntimeError","messagePattern":"RuntimeError","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"arduino-core/src/processing/app/i18n/python/update.py","lineNumber":7,"sourceCode":"#!/usr/bin/env python2\n#vim:set fileencoding=utf-8 sw=2 expandtab\n\ndef unquote(s):\n  s = s.strip()\n  if s[0] != '\"' or s[-1] != '\"':\n    raise RuntimeError\n  return s[1:-1]\n\ndef read_po(fp):\n  if isinstance(fp, str):\n    fp = open(fp)\n\n  d = {}\n  st = 1\n  comment = key = rkey = rvalue = ''\n  for line in fp:\n    if line[0] == '#' or line.strip() == '':\n      if st == 2:\n        d[key] = (comment, rkey, rvalue)\n        st = 1\n        comment = key = rkey = rvalue = ''\n      comment += line\n    elif line[0] == '\"':\n      if st == 1:","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/arduino/Arduino/blob/a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee/arduino-core/src/processing/app/i18n/python/update.py#L1-L25","documentation":"Generic sentinel guard in the .po parser's unquote helper: it fires whenever the given string is not a double-quoted literal — after strip() it must start and end with '\"'. Callers read_po and add_headers pass lines/fragments of gettext .po files, so a malformed or unquoted token (bare value, corrupted line, or empty string) triggers this bare RuntimeError with no message. Ensure the input is a properly quoted string before parsing.","triggerScenarios":"Parsing a .po file line whose value after a keyword (e.g. msgid/msgstr continuation or header value passed via add_headers/read_po) is not wrapped in quotes: empty line, single quotes, missing closing quote, or unquoted token.","commonSituations":"Hand-edited or machine-generated .po files with malformed quoting; UTF-8/encoding issues replacing quotes with smart quotes; blank lines or comments fed to unquote by an overly simple parser.","solutions":["Open the .po file at the offending line and wrap the value in matching double quotes: msgid \"text\".","Check for smart/curly quotes (“ ”) from editors or word processors and replace them with ASCII \".","Validate the .po with gettext tooling (msgfmt) to locate malformed entries before running update.py.","Ensure the file is read with the correct encoding (utf-8) so quote characters are preserved."],"exampleFix":"// before\nmsgid: Hello\n# after\nmsgid \"Hello\"","handlingStrategy":"validation","validationCode":"def is_quoted(s):\n    s = s.strip()\n    return len(s) >= 2 and s[0] == '\"' and s[-1] == '\"'","typeGuard":"def looks_quoted(s):\n    return isinstance(s, str) and len(s) >= 2 and s.startswith('\"') and s.endswith('\"')","tryCatchPattern":"try:\n    val = unquote(raw)\nexcept RuntimeError:\n    print('unquoted value in po file:', repr(raw))\n    raise","preventionTips":["Validate .po files with msgfmt before parsing","Ensure editors save ASCII double quotes, not smart quotes","Read files as utf-8 to preserve quote characters"],"tags":["python","i18n","gettext","po-files","parsing"],"backgroundTag":"invalid-argument-format","analyzedSha":"a0df6e0e83b652c72bc78b0a1376c54d6ebc3bee","analyzedAt":"2026-09-06T10:13:38.901Z","contentChangedAt":"2026-09-06T10:13:38.901Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}