ERROR: 'Namespace' object has no attribute 'func'

Bug #1295356 reported by Johannes Erdfelt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance Client
Fix Released
Undecided
ZhiQiang Fan
Python client library for Sahara
Fix Released
Medium
ZhiQiang Fan
python-magnumclient
Fix Released
Undecided
Unassigned
python-novaclient
Fix Released
Undecided
Johannes Erdfelt

Bug Description

When running just 'nova' under Python 2, you get the usage (same as 'nova help').

When running just 'nova' under Python 3, you get the error: ERROR: 'Namespace' object has no attribute 'func'

This is because map() is used to decode sys.argv, but under Python 3 it returns a map object which is an iterable. Some code later tries to use this in a boolean context and it will always return True, even if it's empty.

Python 2 would return a list from the map built-in which is why it doesn't exhibit this failure.

Changed in python-novaclient:
assignee: nobody → Johannes Erdfelt (johannes.erdfelt)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-novaclient (master)

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

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

Reviewed: https://review.openstack.org/81911
Committed: https://git.openstack.org/cgit/openstack/python-novaclient/commit/?id=656cf91f898ff1a20986f358bedc64f410f5ee4a
Submitter: Jenkins
Branch: master

commit 656cf91f898ff1a20986f358bedc64f410f5ee4a
Author: Johannes Erdfelt <email address hidden>
Date: Thu Mar 20 13:29:10 2014 -0700

    Fix error when run with no arguments on Python 3

    Python 3 changed the map built-in to return an iterable instead of a list.
    When tested in a boolean context, this always returns True, even if it
    would not return anything when iterated.

    Instead of the usage being printed, this error was printed:
    ERROR: 'Namespace' object has no attribute 'func'

    Use list comprehension instead to ensure that an iterable isn't returned

    Change-Id: Ie15f2fa8ee93ab26490e371133fa0f944430737b
    Closes-bug: 1295356

Changed in python-novaclient:
status: In Progress → Fix Committed
Michael Still (mikal)
Changed in python-novaclient:
milestone: none → 2.18.0
Michael Still (mikal)
Changed in python-novaclient:
status: Fix Committed → Fix Released
Revision history for this message
XavierAntoviaque (xavier-antoviaque) wrote :

I also get this with glance on Python 3:

$ python --version
Python 3.4.3

$ pip freeze |grep glance
python-glanceclient==1.1.0

$ glance image-create --disk-format=qcow2 --container-format=bare --file=~/dl/precise-server-cloudimg-amd64-disk1.img --name=ubuntu-12.04-ref-ul
'Namespace' object has no attribute 'func'

Changed in python-glanceclient:
status: New → Confirmed
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :
Changed in python-glanceclient:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
ZhiQiang Fan (aji-zqfan)
Changed in python-saharaclient:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-saharaclient (master)

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

Changed in python-saharaclient:
status: New → In Progress
ZhiQiang Fan (aji-zqfan)
Changed in python-magnumclient:
assignee: nobody → ZhiQiang Fan (aji-zqfan)
ZhiQiang Fan (aji-zqfan)
Changed in python-glanceclient:
status: Confirmed → In Progress
Revision history for this message
ZhiQiang Fan (aji-zqfan) wrote :

patch https://review.openstack.org/224565 can fix python-magnumclient as well

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

Reviewed: https://review.openstack.org/228257
Committed: https://git.openstack.org/cgit/openstack/python-saharaclient/commit/?id=d7cad3a7c337a4adcabfa577070b9f715d69e30b
Submitter: Jenkins
Branch: master

commit d7cad3a7c337a4adcabfa577070b9f715d69e30b
Author: Zhiqiang Fan <email address hidden>
Date: Sun Sep 27 10:06:59 2015 -0600

    print usage when no argument is specified for python3

    When running just sahara' under python3, we will get the error:
    ERROR: b"'Namespace' object has no attribute 'func'"

    This is because map() is used to decode sys.argv, but under Python3
    it returns a map object which is an iterable. Some code later tries
    to use this in a boolean context and it will always return True,
    even if it's empty.

    Change-Id: I508b093e30814645b2bd4c32cf469204bb696207
    Closes-Bug: #1295356

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

Reviewed: https://review.openstack.org/228256
Committed: https://git.openstack.org/cgit/openstack/python-glanceclient/commit/?id=a8a7c689905f816db0e73e3cf643cd5daef76932
Submitter: Jenkins
Branch: master

commit a8a7c689905f816db0e73e3cf643cd5daef76932
Author: Zhiqiang Fan <email address hidden>
Date: Sun Sep 27 09:38:04 2015 -0600

    print usage when no argument is specified for python3

    When running just 'glance' under python3, we will get the error:
    ERROR: 'Namespace' object has no attribute 'func'

    This is because map() is used to decode sys.argv, but under Python3
    it returns a map object which is an iterable. Some code later tries
    to use this in a boolean context and it will always return True,
    even if it's empty.

    Change-Id: I2f03e462cb813833b75b9f2de7badd10b10cddff
    Closes-Bug: #1295356

Changed in python-glanceclient:
status: In Progress → Fix Committed
ZhiQiang Fan (aji-zqfan)
Changed in python-magnumclient:
status: New → Fix Committed
assignee: ZhiQiang Fan (aji-zqfan) → nobody
Changed in python-glanceclient:
milestone: none → 1.2.0
status: Fix Committed → Fix Released
Adrian Otto (aotto)
Changed in python-magnumclient:
status: Fix Committed → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/python-saharaclient 0.12.0

This issue was fixed in the openstack/python-saharaclient 0.12.0 release.

Changed in python-saharaclient:
milestone: none → 0.12.0
Changed in python-saharaclient:
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.