LLDB mainline
PythonDataObjects.cpp File Reference
#include "PythonDataObjects.h"
#include "ScriptInterpreterPython.h"
#include "lldb/Host/File.h"
#include "lldb/Host/FileSystem.h"
#include "lldb/Interpreter/ScriptInterpreter.h"
#include "lldb/Utility/LLDBLog.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/Errno.h"
#include <cstdio>
#include <variant>

Go to the source code of this file.

Functions

template<>
Expected< std::string > python::As< std::string > (Expected< PythonObject > &&obj)
llvm::Expected< File::OpenOptionsGetOptionsForPyObject (const PythonObject &obj)

Variables

static const char get_arg_info_script []
const char read_exception_script []

Function Documentation

◆ GetOptionsForPyObject()

◆ python::As< std::string >()

template<>
Expected< std::string > python::As< std::string > ( Expected< PythonObject > && obj)

Definition at line 1 of file PythonDataObjects.cpp.

Variable Documentation

◆ get_arg_info_script

const char get_arg_info_script[]
static
Initial value:
= R"(
from inspect import signature, Parameter, ismethod
from collections import namedtuple
ArgInfo = namedtuple('ArgInfo', ['count', 'has_varargs'])
def main(f):
count = 0
varargs = False
for parameter in signature(f).parameters.values():
kind = parameter.kind
if kind in (Parameter.POSITIONAL_ONLY,
Parameter.POSITIONAL_OR_KEYWORD):
count += 1
elif kind == Parameter.VAR_POSITIONAL:
varargs = True
elif kind in (Parameter.KEYWORD_ONLY,
Parameter.VAR_KEYWORD):
pass
else:
raise Exception(f'unknown parameter kind: {kind}')
return ArgInfo(count, varargs)
)"

Definition at line 821 of file PythonDataObjects.cpp.

Referenced by lldb_private::python::PythonCallable::GetArgInfo().

◆ read_exception_script

const char read_exception_script[]
Initial value:
= R"(
import sys
from traceback import print_exception
if sys.version_info.major < 3:
from StringIO import StringIO
else:
from io import StringIO
def main(exc_type, exc_value, tb):
f = StringIO()
print_exception(exc_type, exc_value, tb, file=f)
return f.getvalue()
)"

Definition at line 965 of file PythonDataObjects.cpp.

Referenced by lldb_private::python::PythonException::ReadBacktrace().