← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1414556] [NEW] "if not host:" never holds in function get_instance_availability_zone() of module nova.availability_zones

 

Public bug reported:

Version: stable/juno

Description:
This bug report is created to separate two issues found in this link: https://bugs.launchpad.net/nova/+bug/1390033.
The purpose is to fix at first the bug that the "if not host:" never holds in function get_instance_availability_zone() of module nova.availability_zones in case host is None. This is because str(None) is never interpreted False.

For proof, please look at the output of the Python interactive session:

Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> host = str(None)
>>> print host
None
>>> if not host:
.......print "if not host"
....else:
...... print "else"
...
else

>>> var = None
>>> if not var:
.......print "if not var"
....else:
.......print "else"
...
if not var

So, it can be seen that str(None) returns an object whose value is None,
but it is not interpreted False as expected!

** Affects: nova
     Importance: Undecided
     Assignee: Trung Trinh (trung-t-trinh)
         Status: In Progress

** Description changed:

  Version: stable/juno
  
  Description:
  This bug report is created to separate two issues found in this link: https://bugs.launchpad.net/nova/+bug/1390033.
  The purpose is to fix at first the bug that the "if not host:" never holds in function get_instance_availability_zone() of module nova.availability_zones in case host is None. This is because str(None) is never interpreted False.
  
  For proof, please look at the output of the Python interactive session:
  
  Python 2.7.6 (default, Mar 22 2014, 22:59:56)
  [GCC 4.8.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> host = str(None)
  >>> print host
  None
  >>> if not host:
- .......... print "if not host"
- ........else:
- .......... print "else"
+ .......print "if not host"
+ ....else:
+ ...... print "else"
  ...
  else
  
  >>> var = None
  >>> if not var:
- .......... print "if not var"
- ....... else:
- .......... print "else"
+ .......print "if not var"
+ ....else:
+ .......print "else"
  ...
  if not var
  
  So, it can be seen that str(None) returns an object whose value is None,
  but it is not interpreted False as expected!

** Changed in: nova
     Assignee: (unassigned) => Trung Trinh (trung-t-trinh)

** Changed in: nova
       Status: New => In Progress

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/1414556

Title:
  "if not host:" never holds in function
  get_instance_availability_zone() of module nova.availability_zones

Status in OpenStack Compute (Nova):
  In Progress

Bug description:
  Version: stable/juno

  Description:
  This bug report is created to separate two issues found in this link: https://bugs.launchpad.net/nova/+bug/1390033.
  The purpose is to fix at first the bug that the "if not host:" never holds in function get_instance_availability_zone() of module nova.availability_zones in case host is None. This is because str(None) is never interpreted False.

  For proof, please look at the output of the Python interactive
  session:

  Python 2.7.6 (default, Mar 22 2014, 22:59:56)
  [GCC 4.8.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> host = str(None)
  >>> print host
  None
  >>> if not host:
  .......print "if not host"
  ....else:
  ...... print "else"
  ...
  else

  >>> var = None
  >>> if not var:
  .......print "if not var"
  ....else:
  .......print "else"
  ...
  if not var

  So, it can be seen that str(None) returns an object whose value is
  None, but it is not interpreted False as expected!

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/1414556/+subscriptions


Follow ups

References