From bd405169fbf039cd1c3a209ec0114184e7e4fe1f Mon Sep 17 00:00:00 2001 From: Victor Costan Date: Sat, 5 Sep 2015 17:30:43 -0400 Subject: [PATCH] Fix #12258: don't wrap None in UnsafeProxy. --- lib/ansible/vars/__init__.py | 2 +- lib/ansible/vars/unsafe_proxy.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/vars/__init__.py b/lib/ansible/vars/__init__.py index d2f40382d7a..6fa3c90ccdb 100644 --- a/lib/ansible/vars/__init__.py +++ b/lib/ansible/vars/__init__.py @@ -183,7 +183,7 @@ class VariableManager: try: host_facts = self._fact_cache.get(host.name, dict()) for k in host_facts.keys(): - if not isinstance(host_facts[k], UnsafeProxy): + if host_facts[k] is not None and not isinstance(host_facts[k], UnsafeProxy): host_facts[k] = UnsafeProxy(host_facts[k]) all_vars = combine_vars(all_vars, host_facts) except KeyError: diff --git a/lib/ansible/vars/unsafe_proxy.py b/lib/ansible/vars/unsafe_proxy.py index 69163802e03..a8bca351ae3 100644 --- a/lib/ansible/vars/unsafe_proxy.py +++ b/lib/ansible/vars/unsafe_proxy.py @@ -72,6 +72,8 @@ class UnsafeProxy(object): return bool(object.__getattribute__(self, "_obj")) def __str__(self): return str(object.__getattribute__(self, "_obj")) + def __unicode__(self): + return unicode(object.__getattribute__(self, "_obj")) def __repr__(self): return repr(object.__getattribute__(self, "_obj")) @@ -89,7 +91,7 @@ class UnsafeProxy(object): '__long__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__oct__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__', '__reduce_ex__', - '__repr__', '__reversed__', '__rfloorfiv__', '__rlshift__', '__rmod__', + '__repr__', '__reversed__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setitem__', '__setslice__', '__sub__', '__truediv__', '__xor__', 'next', @@ -127,6 +129,5 @@ class UnsafeProxy(object): except KeyError: cache[obj.__class__] = theclass = cls._create_class_proxy(obj.__class__) ins = object.__new__(theclass) - theclass.__init__(ins, obj, *args, **kwargs) return ins