ResourceClass.normalize_name produces different results for py2 vs. py3

Bug #1762789 reported by Eric Fried
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Eric Fried

Bug Description

Due to a py3 quirk (read: bug they decided not to fix) [1], .upper() works differently in py2 vs. py3 for the sharp S ('ß'). In py2, it stays the same (like all other characters not in the a-z range); in py3 it becomes the two-character string 'SS'. This means that, as written, ResourceClass.normalize_name('ß') will yield 'CUSTOM__' in py2, but 'CUSTOM_SS' in py3.

[1] https://bugs.python.org/issue4610

Tags: placement
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix proposed to nova (master)

Related fix proposed to branch: master
Review: https://review.openstack.org/560092

Changed in nova:
assignee: nobody → Eric Fried (efried)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

melanie witt (melwitt)
Changed in nova:
importance: Undecided → Low
Revision history for this message
melanie witt (melwitt) wrote :

FWIW, reading through the bug in [1], it looks like it was the opposite -- that:

  >>> x='ß'
  >>> print(x, x.upper())
  ß ß

was considered a bug [2] that was later fixed [3] to behave like:

  >>> 'ß'.upper()
  'SS'

in a later python3 version.

[1] https://bugs.python.org/issue4610
[2] https://bugs.python.org/msg77417
[3] https://bugs.python.org/msg191740

Revision history for this message
Eric Fried (efried) wrote :

Shrug, I can see it both ways. Nevertheless, it results in some busted behavior in environments where both py2 and py3 need to be supported.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to nova (master)

Reviewed: https://review.openstack.org/560092
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=443980399b03282c37e64e7a529be4960689b34d
Submitter: Zuul
Branch: master

commit 443980399b03282c37e64e7a529be4960689b34d
Author: Eric Fried <email address hidden>
Date: Tue Apr 10 12:17:17 2018 -0500

    Test case: ResourceClass.normalize_name with ß

    Demonstrates the cited bug by invoking ResourceClass.normalize_name on a
    string containing sharp S ('ß'). The result is different for py2 and
    py3.

    Change-Id: I632995c1a234f26f05ef0b5675e0e22b9866b03d
    Related-Bug: #1762789

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/560093
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=7fd2de85b632575315df0dce2287b3a7b44492f1
Submitter: Zuul
Branch: master

commit 7fd2de85b632575315df0dce2287b3a7b44492f1
Author: Eric Fried <email address hidden>
Date: Tue Apr 10 12:24:40 2018 -0500

    Make ResourceClass.normalize_name handle sharp S

    Fixes ResourceClass.normalize_name to produce the same result in py2 and
    py3 even when sharp S ('ß') is part of the input.

    We do this by waiting until after replacing non-alphanumerics to upcase.

    Change-Id: I431fa29d36d0d633374973fc25168344042d6c1a
    Closes-Bug: #1762789

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 18.0.0.0b1

This issue was fixed in the openstack/nova 18.0.0.0b1 development milestone.

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.