reflection: need clean nested class's name with prefix in Python 3

Bug #1513067 reported by ChangBo Guo(gcb)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.utils
Fix Released
Low
ChangBo Guo(gcb)

Bug Description

A nested class returns class name with nested prefix in Python 3,
but only returns class name in Python 2, in order to keep consistent
need remove the prefix

Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

This is an example:

[gcb@localhost tests]$ cat test_reflect.py

import pdb
from oslo_utils import reflection

class ClassA(object):

    def __init__(self):

        class ClassB(object):
            pass
        self.api = ClassB()

    def test_get_nested_class_name(self):
        class_name = reflection.get_class_name(self.api, fully_qualified=False)
        print(class_name)
        class_name = reflection.get_class_name(self.api, fully_qualified=True)
        print(class_name)

a = ClassA()
a.test_get_nested_class_name()

[gcb@localhost tests]$ python test_reflect.py
ClassB
__main__.ClassB

[gcb@localhost tests]$ python3 test_reflect.py
ClassA.__init__.<locals>.ClassB
__main__.ClassA.__init__.<locals>.ClassB

Changed in oslo.utils:
assignee: nobody → ChangBo Guo(gcb) (glongwave)
Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :
Changed in oslo.utils:
status: New → In Progress
Revision history for this message
ChangBo Guo(gcb) (glongwave) wrote :

The fix was merged.

Changed in oslo.utils:
status: In Progress → Fix Committed
importance: Undecided → Low
Changed in oslo.utils:
milestone: none → 2.8.0
status: Fix Committed → Fix Released
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.