Message.translate is not compatible with str.translate

Bug #1656831 reported by Thomas Herve
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.i18n
Expired
Undecided
Unassigned

Bug Description

The Message class inherits from str, but implements an incompatible version of the translate method : instead of taking an escape table [1], it takes an optional locale name. See http://paste.openstack.org/show/595050/ for an example of the issue, here with pymysql

It's hard to know what to do at this point. We should rename the translate method, but it looks like part of the public API, though I doubt it's used a lot.

[1] https://docs.python.org/3/library/stdtypes.html?highlight=translate#str.translate

Revision history for this message
Thomas Herve (therve) wrote :
Revision history for this message
Doug Hellmann (doug-hellmann) wrote :

The entire Message class is declared private, since the _message module starts with _. It's likely safe to change the API, but who knows what people are doing in real code.

Where in an application is this issue being triggered? I'm not suggesting you're wrong in renaming the method, but if we have something using a Message without calling oslo_i18n.translate() on the string first, that's an application-level bug and we need that to be fixed, too.

Revision history for this message
Thomas Herve (therve) wrote :

I don't know where the issue is triggered in Heat, I only have the traceback attached. From what I can tell, we don't want to translate the string, we want to store the original message. Presumably the Message docstring indicates that it ought to be possible.

It's unclear why it works in py2 and not in py3, but probably because of some pymysql shenanigans.

Changed in oslo.i18n:
status: New → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for oslo.i18n because there has been no activity for 60 days.]

Changed in oslo.i18n:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.