Handle unicode exception messages

Bug #1295443 reported by Liang Chen
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Heat
Fix Released
Undecided
Liang Chen

Bug Description

There are many places in the code that explicitly ask for byte code strings while using exception messages. They should be able to work with unicode string and use it in a way that is PY3 compatible.

Liang Chen (cbjchen)
Changed in heat:
assignee: nobody → Liang Chen (cbjchen)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to heat (master)

Fix proposed to branch: master
Review: https://review.openstack.org/81956

Changed in heat:
status: New → In Progress
Lee Li (lilinguo)
Changed in neutron:
assignee: nobody → Lee Li (lilinguo)
Changed in python-neutronclient:
assignee: nobody → Lee Li (lilinguo)
Changed in neutron:
importance: Undecided → Low
status: New → Triaged
Changed in python-neutronclient:
importance: Undecided → Low
status: New → Triaged
Changed in neutron:
assignee: Lee Li (lilinguo) → Harikrishna (harikrishna-mallavolu)
Changed in python-neutronclient:
assignee: Lee Li (lilinguo) → Harikrishna (harikrishna-mallavolu)
Changed in python-neutronclient:
assignee: Harikrishna (harikrishna-mallavolu) → usha veepuri (usha-veepuri)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to heat (master)

Reviewed: https://review.openstack.org/81956
Committed: https://git.openstack.org/cgit/openstack/heat/commit/?id=ca90c984ec656df512647a26114cc7095acff617
Submitter: Jenkins
Branch: master

commit ca90c984ec656df512647a26114cc7095acff617
Author: Liang Chen <email address hidden>
Date: Fri Feb 21 18:22:58 2014 +0800

    Replace str with six.text_type

    Replace str with six.text_type so that unicode exception messages can be
    safely processed, and the change is PY3 compatible.

    Closes-bug: #1295443

    Change-Id: Ic27ec365b82797df37ae53f38d5d31e70cb65c67

Changed in heat:
status: In Progress → Fix Committed
Changed in python-neutronclient:
status: Triaged → In Progress
Thierry Carrez (ttx)
Changed in heat:
milestone: none → juno-1
status: Fix Committed → Fix Released
Changed in python-neutronclient:
assignee: usha veepuri (usha-veepuri) → Harikrishna (harikrishna-mallavolu)
Thierry Carrez (ttx)
Changed in heat:
milestone: juno-1 → 2014.2
Changed in neutron:
assignee: Harikrishna (harikrishna-mallavolu) → nobody
Changed in python-neutronclient:
assignee: Harikrishna (harikrishna-mallavolu) → nobody
Changed in neutron:
assignee: nobody → Ann Kamyshnikova (akamyshnikova)
Revision history for this message
Ann Taraday (akamyshnikova) wrote :

I've analyzed codebase and came to conclusion that this bug is invalid for Neutron. Places where we have str() conversion around exceptions divide into two categories:
- where stringified exceptions are checked for equiality with or inclusion of literal strings which are of str type in both Python 2.x and 3.x, converting them to unicode will only add one more implicit unicode->str conversion step;
- where exceptions are immediately passed as arguments to string formatting operator, in these cases explicit str() conversion is not needed since %s substitution already does the same conversion.
Both of these cases need no special unicode handling. For the second case I've filed a bug here:https://bugs.launchpad.net/neutron/+bug/1398839

Changed in neutron:
status: Triaged → Invalid
Changed in python-neutronclient:
assignee: nobody → Numan Siddique (numansiddique)
Revision history for this message
Numan Siddique (numansiddique) wrote :

The fix is required in python-neutronclient.
With the opencontrail neutron plugin, I am facing this issue.
When a network resource is created for instance, opencontrail neutron plugin returns {"contrail:fq_name" : ["default-demo", "default-project", "network-name"]} in the response body.

If the name of the network has a unicode character, the neutron client fails since it calls str(i).
https://github.com/openstack/python-neutronclient/blob/master/neutronclient/neutron/v2_0/__init__.py#L421

Revision history for this message
Akihiro Motoki (amotoki) wrote :

I created a network whose name is unicode (Japanese character is 3 byte unicode) and net-list succeeded.

$ neutron net-create あああ
Created a new network:
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| admin_state_up | True |
| id | efb975fc-8a2f-4bd6-a734-1912d587cdfa |
| mtu | 0 |
| name | あああ |
| port_security_enabled | True |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 8f0ebf767043483a987736c8c684178d |
+-----------------------+--------------------------------------+
ubuntu@dev16:/opt/stack/python-neutronclient (review/akihiro_motoki/bug/1102897)$ neutron net-list
+--------------------------------------+-----------+----------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+-----------+----------------------------------------------------------+
| 14a1f133-e0b9-4de9-87b2-1dc92c1cd12b | testnet | f9d66570-1ae8-450e-8c83-df3ede6ea9a1 10.2.2.0/24 |
| 3698d3c7-d581-443e-bf86-53c4e3a738f7 | mynetwork | 5b7ef5ce-df82-4c73-b480-29aacdf4d22e 192.168.100.0/24 |
| a11600dc-cac9-4934-970b-0fa44d5097b8 | ext_net | 2b86127b-424b-40a9-9a85-9f7be470bc25 |
| | | 7e268119-891b-447e-97f8-8e900fb0664e |
| e8cbf82d-9f26-4d6f-ab02-dc3bdf05ffce | net1 | 6b832dfe-f271-443c-abad-629961414a73 10.0.0.0/24 |
| | | cdcc616b-0cff-482f-96f5-06fc63d21247 fd12:877c:1d66::/64 |
| efb975fc-8a2f-4bd6-a734-1912d587cdfa | あああ | |
+--------------------------------------+-----------+----------------------------------------------------------+

Revision history for this message
Akihiro Motoki (amotoki) wrote :

If the bug still exists, report it again.

Changed in python-neutronclient:
status: In Progress → Incomplete
assignee: Numan Siddique (numansiddique) → nobody
importance: Low → Undecided
Revision history for this message
Armando Migliaccio (armando-migliaccio) wrote :

This bug is > 180 days without activity. We are unsetting assignee and milestone and setting status to Incomplete in order to allow its expiry in 60 days.

If the bug is still valid, then update the bug status.

no longer affects: neutron
Revision history for this message
Akihiro Motoki (amotoki) wrote :

It looks like neutron CLI is not affected. There has been no addition bug report.

no longer affects: python-neutronclient
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.