arduino/Arduino · error · RuntimeError

RuntimeError

Error message

RuntimeError

What it means

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.

Source

Thrown at arduino-core/src/processing/app/i18n/python/update.py:7

#!/usr/bin/env python2
#vim:set fileencoding=utf-8 sw=2 expandtab

def unquote(s):
  s = s.strip()
  if s[0] != '"' or s[-1] != '"':
    raise RuntimeError
  return s[1:-1]

def read_po(fp):
  if isinstance(fp, str):
    fp = open(fp)

  d = {}
  st = 1
  comment = key = rkey = rvalue = ''
  for line in fp:
    if line[0] == '#' or line.strip() == '':
      if st == 2:
        d[key] = (comment, rkey, rvalue)
        st = 1
        comment = key = rkey = rvalue = ''
      comment += line
    elif line[0] == '"':
      if st == 1:

View on GitHub (pinned to a0df6e0e83)

Solutions

  1. Open the .po file at the offending line and wrap the value in matching double quotes: msgid "text".
  2. Check for smart/curly quotes (“ ”) from editors or word processors and replace them with ASCII ".
  3. Validate the .po with gettext tooling (msgfmt) to locate malformed entries before running update.py.
  4. Ensure the file is read with the correct encoding (utf-8) so quote characters are preserved.

Example fix

// before
msgid: Hello
# after
msgid "Hello"
Defensive patterns

Strategy: validation

Validate before calling

def is_quoted(s):
    s = s.strip()
    return len(s) >= 2 and s[0] == '"' and s[-1] == '"'

Type guard

def looks_quoted(s):
    return isinstance(s, str) and len(s) >= 2 and s.startswith('"') and s.endswith('"')

Try / catch

try:
    val = unquote(raw)
except RuntimeError:
    print('unquoted value in po file:', repr(raw))
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06). Data as JSON: /api/errors/d6f2f60743d2bba8. Report an issue: GitHub.