Comment 3 for bug 1841796

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.i18n (master)

Reviewed: https://review.opendev.org/679092
Committed: https://git.openstack.org/cgit/openstack/oslo.i18n/commit/?id=f8fa059c46fed84514004ece7dccacf6380cf263
Submitter: Zuul
Branch: master

commit f8fa059c46fed84514004ece7dccacf6380cf263
Author: Ben Nemec <email address hidden>
Date: Wed Aug 28 15:07:53 2019 +0000

    Allow Message.translate to handle unhashable inputs

    We made a mistake with the API of the Message class and shadowed the
    built-in function 'translate' from the unicode class that it inherits
    from. This means that our translate may be called with things like
    dicts and lists that are not hashable, which is problematic because
    we use that value as a dict key. Unhashable types are not allowed as
    dict keys so this fails.

    While ideally we would address this shadowing by renaming our version
    of translate, it is part of the public API of the library and thus
    we can't just change it arbitrarily. As a partial fix, this change
    adds a type check on the input parameter, and if it finds a type
    other than a string it calls the superclass's implementation of
    translate instead. This should handle most common uses of the stdlib
    translate, but since technically it is possible to use a string as
    input to that as well it doesn't fully address the problem.

    Change-Id: Ie68cba6af19d11de8968ee80ac10107f488acb92
    Partial-Bug: 1841796