def getAttributeCheckBoolCode(source_name, attr_name, needs_check, emit, context):
    res_name = context.getIntResName()

    emit(
        "%s = PyObject_HasAttr( %s, %s );" % (
            res_name,
            source_name,
            attr_name
        )
    )

    getReleaseCodes(
        release_names = (source_name, attr_name),
        emit          = emit,
        context       = context
    )

    getErrorExitBoolCode(
        condition   = "%s == -1" % res_name,
        needs_check = needs_check,
        emit        = emit,
        context     = context
    )

    getBranchingCode("%s == 1" % res_name, emit, context)
dataset/ETHPy150Open kayhayen/Nuitka/nuitka/codegen/AttributeCodes.py/getAttributeCheckBoolCode/original