Reputation: 79
I'm working on an open source project. Python was upgraded, I THINK from 2.5 to 2.6, and this problem came up.
get_custom_fields(self.env)
was called. self.env was None.
def get_custom_fields(self, customfield=None):
if not customfield:
...
else:
...
Previously this worked fine, and the 'if not' part went through. After the upgrade though, the else started going instead. After removing the self.env, it again goes through the first part. This fixes the problem, but I'm curious why this happened. Did the python upgrade change how optional arguments handle None for some conditionals?
Upvotes: 0
Views: 103
Reputation: 3081
Although None
is still false, it is always recommended to compare to it using is
for performance and correctness reasons (i.e. if foo is None
).
Upvotes: 1
Reputation: 363767
Did the python upgrade change how optional arguments handle
None
for some conditionals?
No. None
is still false. Check the value of self.env
, it might have been set in a way that relied on implementation details. Someone may have compared strings with is
instead of ==
, for example.
Upvotes: 0