diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-08-22 08:28:12 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-08-22 08:28:12 -0400 |
| commit | ba218353bcc905fd40ca4838c625fdbc371b9974 (patch) | |
| tree | 082a088131f46394242ef74b6fd86bf8ec299bcf /nova/utils.py | |
| parent | 4d9cd63c2f269f795e476869557f6bd3d7dcc777 (diff) | |
| parent | 0af1508c38bcf027153dd91c0d862307e90a164e (diff) | |
| download | nova-ba218353bcc905fd40ca4838c625fdbc371b9974.tar.gz nova-ba218353bcc905fd40ca4838c625fdbc371b9974.tar.xz nova-ba218353bcc905fd40ca4838c625fdbc371b9974.zip | |
merge with trunk
Diffstat (limited to 'nova/utils.py')
| -rw-r--r-- | nova/utils.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/nova/utils.py b/nova/utils.py index 4e07b021e..f6e98c2eb 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -547,11 +547,17 @@ def to_primitive(value, convert_instances=False, level=0): Therefore, convert_instances=True is lossy ... be aware. """ - if inspect.isclass(value): - return unicode(value) + nasty = [inspect.ismodule, inspect.isclass, inspect.ismethod, + inspect.isfunction, inspect.isgeneratorfunction, + inspect.isgenerator, inspect.istraceback, inspect.isframe, + inspect.iscode, inspect.isbuiltin, inspect.isroutine, + inspect.isabstract] + for test in nasty: + if test(value): + return unicode(value) if level > 3: - return [] + return '?' # The try block may not be necessary after the class check above, # but just in case ... |
