def infer_ast_from_something(self, obj, context=None):
if hasattr(obj, "<STR_LIT>") and not isinstance(obj, type):<EOL><INDENT>klass = obj.__class__<EOL><DEDENT>else:<EOL><INDENT>klass = obj<EOL><DEDENT>try:<EOL><INDENT>modname = klass.__module__<EOL><DEDENT>except AttributeError as exc:<EOL><INDENT>raise exceptions.AstroidBuildingError(<EOL>"<STR_LIT>",<EOL>cls=klass,<EOL>class_repr=safe_repr(klass),<EOL>) from exc<EOL><DEDENT>except Exception as exc:<EOL><INDENT>raise exceptions.AstroidImportError(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>cls=klass,<EOL>class_repr=safe_repr(klass),<EOL>) from exc<EOL><DEDENT>try:<EOL><INDENT>name = klass.__name__<EOL><DEDENT>except AttributeError as exc:<EOL><INDENT>raise exceptions.AstroidBuildingError(<EOL>"<STR_LIT>",<EOL>cls=klass,<EOL>class_repr=safe_repr(klass),<EOL>) from exc<EOL><DEDENT>except Exception as exc:<EOL><INDENT>raise exceptions.AstroidImportError(<EOL>"<STR_LIT>" "<STR_LIT>",<EOL>cls=klass,<EOL>class_repr=safe_repr(klass),<EOL>) from exc<EOL><DEDENT>modastroid = self.ast_from_module_name(modname)<EOL>if klass is obj:<EOL><INDENT>for inferred in modastroid.igetattr(name, context):<EOL><INDENT>yield inferred<EOL><DEDENT><DEDENT>else:<EOL><INDENT>for inferred in modastroid.igetattr(name, context):<EOL><INDENT>yield inferred.instantiate_class()<EOL><DEDENT><DEDENT>
infer astroid for the given class