Mercurial > pytave
comparison __py_struct_from_dict__.cc @ 386:668fcb0f68ef
Fix extraction of class name for Python types without a module (fixes issue #79)
* oct-py-util.cc (pytave::py_object_class_name): Handle object types with
__module__ set to None, just return the value of __name__.
* __py_struct_from_dict__.cc (F__py_class_name__): Add test case.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Mon, 03 Apr 2017 08:30:20 -0700 |
parents | d0a7f66393fc |
children | 3644df6564bc |
comparison
equal
deleted
inserted
replaced
385:132fec49e438 | 386:668fcb0f68ef |
---|---|
63 %!assert (__py_class_name__ (pyeval ("{}")), "dict") | 63 %!assert (__py_class_name__ (pyeval ("{}")), "dict") |
64 %!assert (__py_class_name__ (pyeval ("[]")), "list") | 64 %!assert (__py_class_name__ (pyeval ("[]")), "list") |
65 %!assert (__py_class_name__ (pyeval ("()")), "tuple") | 65 %!assert (__py_class_name__ (pyeval ("()")), "tuple") |
66 %!assert (__py_class_name__ (pyeval ("__import__('array').array('d')")), "array.array") | 66 %!assert (__py_class_name__ (pyeval ("__import__('array').array('d')")), "array.array") |
67 | 67 |
68 %% Test an anonymous class with its __module__ property set to None | |
69 %!assert (__py_class_name__ (pyeval ("[[t() for t.__module__ in (None,)][0] for t in (type('foo', (), {}),)][0]")), "foo") | |
70 | |
68 %!error __py_class_name__ () | 71 %!error __py_class_name__ () |
69 %!error __py_class_name__ (1) | 72 %!error __py_class_name__ (1) |
70 %!error __py_class_name__ (1, 2) | 73 %!error __py_class_name__ (1, 2) |
71 */ | 74 */ |
72 | 75 |