python 3 only has "__self__", the "im_self" should be replace by "__self_"

Bug #1282514 reported by Shuangtai Tian
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Wishlist
Shuangtai Tian
Ironic
Fix Released
Wishlist
Fengqian
OpenStack Compute (nova)
Won't Fix
Wishlist
Xurong Yang
oslo-incubator
Fix Released
Medium
David Stanek
tuskar
Fix Released
Medium
Fengqian

Bug Description

for code compatible with Python 3, we should use the "__self__" instead of "im_self".
for example :
cinder/volume/flows/common.py

def make_pretty_name(method):
    """Makes a pretty name for a function/method."""
    meth_pieces = [method.__name__]
    # If its an instance method attempt to tack on the class name
    if hasattr(method, 'im_self') and method.im_self is not None:
        try:
            meth_pieces.insert(0, method.im_self.__class__.__name__)
        except AttributeError:
            pass
    return ".".join(meth_pieces)

For reference here(thanks Alex for adding this):
"Changed in version 2.6: For Python 3 forward-compatibility, im_func is also available as __func__, and im_self as __self__."
http://docs.python.org/2/reference/datamodel.html

Changed in cinder:
assignee: nobody → Shuangtai Tian (shuangtai-tian)
Changed in cinder:
status: New → In Progress
Revision history for this message
Alex Meade (alex-meade) wrote :

For reference here:

"Changed in version 2.6: For Python 3 forward-compatibility, im_func is also available as __func__, and im_self as __self__."
http://docs.python.org/2/reference/datamodel.html

description: updated
Fengqian (fengqian-gao)
Changed in ironic:
assignee: nobody → Fengqian (fengqian-gao)
status: New → In Progress
Changed in tuskar:
assignee: nobody → Fengqian (fengqian-gao)
Changed in tuskar:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to ironic (master)

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

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tuskar (master)

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

Changed in tuskar:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tuskar (master)

Reviewed: https://review.openstack.org/76522
Committed: https://git.openstack.org/cgit/openstack/tuskar/commit/?id=c07b38f806687a99ff60b60145e571f8faac64a4
Submitter: Jenkins
Branch: master

commit c07b38f806687a99ff60b60145e571f8faac64a4
Author: Fengqian Gao <email address hidden>
Date: Wed Feb 26 20:34:19 2014 +0800

    Python 3: replace "im_self" by "__self__"

    The Python 3 removed the "im_self" attribute. This patch
    replaces "im_self" by "__self__" attribute.
    Partial-Bug: #1282514

    Change-Id: I53567c856b81c9b2fceaf131ee918dd850ac4f03

Xurong Yang (idopra)
Changed in oslo:
assignee: nobody → Xurong Yang (idopra)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo-incubator (master)

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

Xurong Yang (idopra)
Changed in nova:
assignee: nobody → Xurong Yang (idopra)
status: New → In Progress
Revision history for this message
Joe Gordon (jogo) wrote :

nova isn't python 3 compatible yet primarily due to incompatible dependencies, until we have a roadmap and a timeline to fix those I see little value in making nova itself python 3 compatible. It will just cause unnecessary churn that is hard to gate on.

Changed in nova:
status: In Progress → Invalid
Revision history for this message
John Griffith (john-griffith) wrote :

So to Joe's point if that's the case and there isn't an agreement on doing these conversions across the board there's no point in doing it in any of the projects IMO. It's a minor patch so I don't have a problem approving it but I think as a whole we need to get a handle on our plans for PY3.3 and come to an agreement and maybe a strategy rather than the continued one off patches every day.

Changed in cinder:
importance: Undecided → Wishlist
Fengqian (fengqian-gao)
Changed in tuskar:
status: In Progress → Fix Committed
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/77036

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

Reviewed: https://review.openstack.org/74946
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=14903b4ca7d625b8e93fe431f854263bbe26e4bc
Submitter: Jenkins
Branch: master

commit 14903b4ca7d625b8e93fe431f854263bbe26e4bc
Author: Shuangtai Tian <email address hidden>
Date: Thu Feb 20 14:43:11 2014 +0800

    Python 3: replace "im_self" by "__self__"

    The Python 3 removed the "im_self" attribute and only supports the
    "__self__". This patch replaces "im_self" by "__self__" attribute.

    Closes-Bug: #1282514
    Change-Id: Ib017fff4b720a5dd7ee27fd01b36a531d9b6ca9c

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

Reviewed: https://review.openstack.org/76517
Committed: https://git.openstack.org/cgit/openstack/ironic/commit/?id=3db0e35f0b669192f4d91671217b8cf5fdab4a0a
Submitter: Jenkins
Branch: master

commit 3db0e35f0b669192f4d91671217b8cf5fdab4a0a
Author: Fengqian Gao <email address hidden>
Date: Wed Feb 26 20:24:13 2014 +0800

    Python 3: replace "im_self" by "__self__"

    The Python 3 removed the "im_self" attribute. This patch
    replaces "im_self" by "__self__" attribute.

    Partial-Bug: #1282514

    Change-Id: Icd255eec61f225e2dc66a7efd51551f4b78ac258

Thierry Carrez (ttx)
Changed in cinder:
milestone: none → icehouse-3
status: Fix Committed → Fix Released
Changed in oslo:
importance: Undecided → Medium
aeva black (tenbrae)
Changed in ironic:
status: In Progress → Fix Committed
importance: Undecided → Wishlist
Thierry Carrez (ttx)
Changed in ironic:
milestone: none → icehouse-rc1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: icehouse-3 → 2014.1
Thierry Carrez (ttx)
Changed in ironic:
milestone: icehouse-rc1 → 2014.1
Changed in oslo:
assignee: Xurong Yang (idopra) → David Stanek (dstanek)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo-incubator (master)

Reviewed: https://review.openstack.org/76725
Committed: https://git.openstack.org/cgit/openstack/oslo-incubator/commit/?id=011fc276eaacf371c35f890930b9229ca779b443
Submitter: Jenkins
Branch: master

commit 011fc276eaacf371c35f890930b9229ca779b443
Author: yangxurong <email address hidden>
Date: Thu Feb 27 09:33:45 2014 +0800

    Python 3: replace "im_self" by "__self__"

    The Python 3 removed the "im_self" attribute. This patch
    replaces "im_self" by "__self__" attribute.
    Original description http://docs.python.org/2/reference/datamodel.html

    Change-Id: I0e66553ccebfcae750693177354723f332637cf5
    Partial-Bug: #1282514

Changed in oslo:
status: In Progress → Fix Committed
Changed in oslo:
milestone: none → juno-2
status: Fix Committed → Fix Released
Revision history for this message
Sean Dague (sdague) wrote :

The only place this still exists in nova is code that will be removed when python 2.6 is dropped.

Changed in nova:
status: In Progress → Won't Fix
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.