Comment 1 for bug 1799406

Revision history for this message
Corey Bryant (corey.bryant) wrote : Re: Alarms fail on Rocky

The problem looks to be that pymysql/converters.py is calling oslo_i18n's translate() method with a list argument (named _escape_table). translate expects desired_locale (string) to be passed in, not a list.

1) The call to translate is in /usr/lib/python3/dist-packages/pymysql/converters.py:
     value.translate(_escape_table).

2) This calls into the translate() function in /usr/lib/python3/dist-packages/oslo_i18n/_message.py

3) Looking at the argument that gets passed to 'def translate(self, desired_locale=None)' looks like the _escape_table:

desired_locale=['\\0', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\t', '\\n', '\x0b', '\x0c', '\\r', '\x0e', '\x0f', '
\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\\Z', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', ' ', '!', '\\"', '#', '$', '%', '&', "\\'", '(', ')', '*', '+', ',', '-', '.',
 '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'
, 'X', 'Y', 'Z', '[', '\\\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~', '\x7
f']

4) languages ends up as a nested list in /usr/lib/python3/dist-packages/oslo_i18n/_message.py:
    lang = gettext.translation(domain,
                               localedir=locale_dir,
                               languages=[desired_locale],
                               fallback=True)

5) languages are looped through in /usr/lib/python3.6/gettext.py:
  for lang in languages:
      for nelang in _expand_lang(lang):

6) _expand_lang calls local.normalize with a list (_escape_table) and that causes the "AttributeError: 'list' object has no attribute 'lower'":
  locale.normalize(loc)

The normalize() call should instead be getting called with a locale string, something such as: locale.normalize('EN_US.utf-8').