static int convert_meta(struct srd_proto_data *pdata, PyObject *obj) { long long intvalue; double dvalue; if (pdata->pdo->meta_type == G_VARIANT_TYPE_INT64) { if (!PyLong_Check(obj)) { PyErr_Format(PyExc_TypeError, "This output was registered " "as 'int', but something else was passed."); return SRD_ERR_PYTHON; } intvalue = PyLong_AsLongLong(obj); if (PyErr_Occurred()) return SRD_ERR_PYTHON; pdata->data = g_variant_new_int64(intvalue); } else if (pdata->pdo->meta_type == G_VARIANT_TYPE_DOUBLE) { if (!PyFloat_Check(obj)) { PyErr_Format(PyExc_TypeError, "This output was registered " "as 'float', but something else was passed."); return SRD_ERR_PYTHON; } dvalue = PyFloat_AsDouble(obj); if (PyErr_Occurred()) return SRD_ERR_PYTHON; pdata->data = g_variant_new_double(dvalue); } return SRD_OK; }
CValue* CValue::ConvertPythonToValue(PyObject* pyobj, const char *error_prefix) { CValue* vallie = NULL; /* refcounting is broking here! - this crashes anyway, just store a python list for KX_GameObject */ #if 0 if (PyList_Check(pyobj)) { CListValue* listval = new CListValue(); bool error = false; int i; int numitems = PyList_Size(pyobj); for (i=0;i<numitems;i++) { PyObject* listitem = PyList_GetItem(pyobj,i); /* borrowed ref */ CValue* listitemval = ConvertPythonToValue(listitem, error_prefix); if (listitemval) { listval->Add(listitemval); } else { error = true; } } if (!error) { // jippie! could be converted vallie = listval; } else { // list could not be converted... bad luck listval->Release(); } } else #endif if (PyFloat_Check(pyobj)) { vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) ); } else if (PyLong_Check(pyobj)) { vallie = new CIntValue( (cInt)PyLong_AsLongLong(pyobj) ); } else if (PyUnicode_Check(pyobj)) { vallie = new CStringValue(_PyUnicode_AsString(pyobj),""); } else if (PyObject_TypeCheck(pyobj, &CValue::Type)) /* Note, dont let these get assigned to GameObject props, must check elsewhere */ { vallie = (static_cast<CValue *>(BGE_PROXY_REF(pyobj)))->AddRef(); } else { /* return an error value from the caller */ PyErr_Format(PyExc_TypeError, "%scould convert python value to a game engine property", error_prefix); } return vallie; }
static int pyobject_to_ligotimegps(PyObject *obj, LIGOTimeGPS *gps) { if(pylal_LIGOTimeGPS_Check(obj)) { *gps = ((pylal_LIGOTimeGPS *) obj)->gps; } else if(PyInt_Check(obj)) { XLALGPSSet(gps, PyInt_AsLong(obj), 0); } else if(PyLong_Check(obj)) { XLALGPSSet(gps, PyLong_AsLongLong(obj), 0); } else if(PyFloat_Check(obj)) { XLALGPSSetREAL8(gps, PyFloat_AsDouble(obj)); } else if(PyComplex_Check(obj)) { if(PyComplex_ImagAsDouble(obj) != 0.0) { XLALGPSSet(gps, 0, 0); PyErr_SetObject(PyExc_ValueError, obj); return 0; } XLALGPSSetREAL8(gps, PyComplex_RealAsDouble(obj)); } else { PyObject *s_attr = PyObject_GetAttrString(obj, "seconds"); PyObject *n_attr = PyObject_GetAttrString(obj, "nanoseconds"); XLALGPSSet(gps, PyInt_AsLong(s_attr), PyInt_AsLong(n_attr)); Py_XDECREF(s_attr); Py_XDECREF(n_attr); if(PyErr_Occurred()) { PyErr_SetObject(PyExc_TypeError, obj); return 0; } } return 1; }
static PyObject *Triton_stopAnalysisFromAddr(PyObject *self, PyObject *addr) { if (!PyLong_Check(addr) && !PyInt_Check(addr)) return PyErr_Format(PyExc_TypeError, "stopAnalysisFromAddr(): expected an address (integer) as argument"); PyTritonOptions::stopAnalysisFromAddr.insert(PyLong_AsLongLong(addr)); Py_INCREF(Py_None); return Py_None; }
static PyObject *Triton_stopAnalysisFromOffset(PyObject *self, PyObject *offset) { if (!PyLong_Check(offset) && !PyInt_Check(offset)) return PyErr_Format(PyExc_TypeError, "stopAnalysisFromOffset(): expected an offset (integer) as argument"); PyTritonOptions::stopAnalysisFromOffset.insert(PyLong_AsLongLong(offset)); Py_INCREF(Py_None); return Py_None; }
static int convert_binop(PyObject *v, PyObject *w, LONG_LONG *a, LONG_LONG *b) { if (PgInt8_Check(v)) { *a = PgInt8_AS_LONGLONG(v); } else if (PyLong_Check(v)) { *a = PyLong_AsLongLong(v); if (*a == -1 && PyErr_Occurred()) return 0; } else if (PyInt_Check(v)) { *a = (LONG_LONG)(PyInt_AS_LONG(v)); } else { return 0; } if (w == Py_None) return 1; else if (PgInt8_Check(w)) { *b = PgInt8_AS_LONGLONG(w); } else if (PyLong_Check(w)) { *b = PyLong_AsLongLong(w); if (*b == -1 && PyErr_Occurred()) return 0; } else if (PyInt_Check(w)) { *b = (LONG_LONG)(PyInt_AS_LONG(w)); } else { return 0; } return 1; }
static PyObject *Triton_concretizeReg(PyObject *self, PyObject *regId) { if (!PyLong_Check(regId) && !PyInt_Check(regId)) return PyErr_Format(PyExc_TypeError, "concretizeReg(): expected a IDREF.REG as argument"); RegisterOperand reg = createTmpReg(PyLong_AsLongLong(regId)); ap.concretizeReg(reg); Py_INCREF(Py_None); return Py_None; }
static PyObject *Triton_taintReg(PyObject *self, PyObject *reg) { if (!PyLong_Check(reg) && !PyInt_Check(reg)) return PyErr_Format(PyExc_TypeError, "taintReg(): expected a register id (integer) as argument"); RegisterOperand ro = createTmpReg(PyLong_AsLongLong(reg)); ap.taintReg(ro); Py_INCREF(Py_None); return Py_None; }
static PyObject *Triton_concretizeMem(PyObject *self, PyObject *addr) { if (!PyLong_Check(addr) && !PyInt_Check(addr)) return PyErr_Format(PyExc_TypeError, "concretizeMem(): expected an address (integer) as argument"); MemoryOperand mem(PyLong_AsLongLong(addr), 1); ap.concretizeMem(mem); Py_INCREF(Py_None); return Py_None; }
static PyObject *Triton_taintMem(PyObject *self, PyObject *mem) { if (!PyLong_Check(mem) && !PyInt_Check(mem)) return PyErr_Format(PyExc_TypeError, "TaintMem(): expected a memory address (integer) as argument"); MemoryOperand mo(PyLong_AsLongLong(mem), 1); ap.taintMem(mo); Py_INCREF(Py_None); return Py_None; }
void _extract(PyObject *obj, unsigned long long &val) { if (PyInt_Check(obj)) val = (unsigned long long)PyInt_AsUnsignedLongLongMask(obj); else if (PyFloat_Check(obj)) val = (unsigned long long)PyFloat_AsDouble(obj); else val = (unsigned long long)PyLong_AsLongLong(obj); }
PyObject* extra_read_post(Reader* r, PyObject* extra, int version) { PyObject* result = NULL; if (PyDict_Check(extra)) { if (is_listlike_dict(extra)) { result = PyList_New(PyDict_Size(extra)); PyObject *key, *value; Py_ssize_t pos = 0; while (PyDict_Next(extra, &pos, &key, &value)) { // is_listlike_dict already checked for overflow. int64_t idx = PyLong_AsLongLong(key); PyObject* new_value = extra_read_post(r, value, version); FAIL_IF(new_value == NULL); // Subtract 1 to adjust for Lua's 1-based lists. if (PyList_SetItem(result, idx - 1, new_value) < 0) { Py_DECREF(new_value); goto fail; } } } else { result = PyDict_New(); PyObject *key, *value; Py_ssize_t pos = 0; while (PyDict_Next(extra, &pos, &key, &value)) { PyObject* new_value = extra_read_post(r, value, version); FAIL_IF(new_value == NULL); // Subtract 1 to adjust for Lua's 1-based lists. if (PyDict_SetItem(result, key, new_value) < 0) { Py_DECREF(new_value); goto fail; } } } } else if (PyObject_TypeCheck(extra, &ClientIdType) || PyObject_TypeCheck(extra, &EntityIdType) || PyObject_TypeCheck(extra, &InventoryIdType) || PyObject_TypeCheck(extra, &StructureIdType)) { uint32_t id = ((AnyId*)extra)->id; result = read_find_object(r, id); FAIL_IF(result == NULL); Py_INCREF(result); } else { result = extra; Py_INCREF(result); } return result; fail: SET_EXC(); Py_XDECREF(result); return NULL; }
// Register a timed callback. // First argument should be the time in picoseconds // Second argument is the function to call // Remaining arguments and keyword arguments are to be passed to the callback static PyObject *register_timed_callback(PyObject *self, PyObject *args) { FENTER PyObject *fArgs; PyObject *function; gpi_sim_hdl hdl; uint64_t time_ps; p_callback_data callback_data_p; Py_ssize_t numargs = PyTuple_Size(args); if (numargs < 2) { fprintf(stderr, "Attempt to register timed callback without enough arguments!\n"); return NULL; } // Extract the time PyObject *pTime = PyTuple_GetItem(args, 0); time_ps = PyLong_AsLongLong(pTime); // Extract the callback function function = PyTuple_GetItem(args, 1); if (!PyCallable_Check(function)) { fprintf(stderr, "Attempt to register timed callback without passing a callable callback!\n"); return NULL; } Py_INCREF(function); // Remaining args for function fArgs = PyTuple_GetSlice(args, 2, numargs); // New reference if (fArgs == NULL) { return NULL; } callback_data_p = (p_callback_data)malloc(sizeof(s_callback_data)); if (callback_data_p == NULL) { return PyErr_NoMemory(); } // Set up the user data (no more python API calls after this!) callback_data_p->_saved_thread_state = PyThreadState_Get(); callback_data_p->id_value = COCOTB_ACTIVE_ID; callback_data_p->function = function; callback_data_p->args = fArgs; callback_data_p->kwargs = NULL; hdl = gpi_register_timed_callback((gpi_function_t)handle_gpi_callback, callback_data_p, time_ps); // Check success PyObject *rv = PyLong_FromVoidPtr(hdl); FEXIT return rv; }
static void to_td_val(td_val_t *out, PyObject *pVal) { PyObject *pStr; td_array_t *arr; PyArrayObject *pArr; td_tag_t tag = py_type_to_td(pVal); switch (tag) { case TD_INT32: out->tag = TD_INT32; if (PyInt_Check(pVal)) out->int32_val = PyInt_AS_LONG(pVal); else out->int32_val = PyLong_AsLong(pVal); break; case TD_UINT32: out->tag = TD_UINT32; out->uint32_val = PyLong_AsUnsignedLong(pVal); break; case TD_INT64: out->tag = TD_INT64; out->int64_val = PyLong_AsLongLong(pVal); break; case TD_UINT64: out->tag = TD_UINT64; out->uint64_val = PyLong_AsUnsignedLongLong(pVal); break; case TD_DOUBLE: out->tag = TD_DOUBLE; out->double_val = PyFloat_AsDouble(pVal); break; case TD_UTF8: pStr = pVal; if (PyUnicode_Check(pStr)) pStr = PyUnicode_AsUTF8String(pStr); size_t len = PyString_Size(pStr); char* data = malloc((len+1)*sizeof(char)); strcpy(PyString_AsString(pStr), data); td_string_t *obj = malloc(sizeof(td_string_t)); obj->length = len; obj->data = (void*) data; out->tag = TD_UTF8; out->object = (void*) obj; break; case TD_ARRAY: arr = (td_array_t *)malloc(sizeof(td_array_t)); pArr = (PyArrayObject *) pVal; arr->data = PyArray_DATA(pArr); arr->length = PyArray_SIZE(pArr); arr->eltype = numpy_type_to_td(PyArray_TYPE(pArr)); arr->ndims = PyArray_NDIM(pArr); break; default: out->tag = TD_OBJECT; out->owner = td_env_python(NULL, NULL); out->object = pVal; } }
/** ******************************************************************************************************* * This function checks for metadata and if present set it into the * as_operations. * * @param py_meta The dictionary of metadata. * @param ops The as_operations object. * @param err The as_error to be populated by the function * with the encountered error if any. * * Returns nothing. ******************************************************************************************************* */ static void AerospikeClient_CheckForMeta(PyObject * py_meta, as_operations * ops, as_error *err) { if ( py_meta && PyDict_Check(py_meta) ) { PyObject * py_gen = PyDict_GetItemString(py_meta, "gen"); PyObject * py_ttl = PyDict_GetItemString(py_meta, "ttl"); uint32_t ttl = 0; uint16_t gen = 0; if ( py_ttl != NULL ){ if ( PyInt_Check(py_ttl) ) { ttl = (uint32_t) PyInt_AsLong(py_ttl); } else if ( PyLong_Check(py_ttl) ) { ttl = (uint32_t) PyLong_AsLongLong(py_ttl); } else { as_error_update(err, AEROSPIKE_ERR_PARAM, "Ttl should be an int or long"); } if((uint32_t)-1 == ttl) { as_error_update(err, AEROSPIKE_ERR_PARAM, "integer value for ttl exceeds sys.maxsize"); return; } ops->ttl = ttl; } if( py_gen != NULL ){ if ( PyInt_Check(py_gen) ) { gen = (uint16_t) PyInt_AsLong(py_gen); } else if ( PyLong_Check(py_gen) ) { gen = (uint16_t) PyLong_AsLongLong(py_gen); } else { as_error_update(err, AEROSPIKE_ERR_PARAM, "Generation should be an int or long"); } if((uint16_t)-1 == gen) { as_error_update(err, AEROSPIKE_ERR_PARAM, "integer value for gen exceeds sys.maxsize"); return; } ops->gen = gen; } } else { as_error_update(err, AEROSPIKE_ERR_PARAM, "Metadata should be of type dictionary"); } }
static PyObject *Triton_isRegTainted(PyObject *self, PyObject *reg) { if (!PyLong_Check(reg) && !PyInt_Check(reg)) return PyErr_Format(PyExc_TypeError, "isRegTainted(): expected a register id (integer) as argument"); RegisterOperand ro = createTmpReg(PyLong_AsLongLong(reg)); if (ap.isRegTainted(ro) == true) Py_RETURN_TRUE; Py_RETURN_FALSE; }
static PyObject *Triton_isMemTainted(PyObject *self, PyObject *mem) { if (!PyLong_Check(mem) && !PyInt_Check(mem)) return PyErr_Format(PyExc_TypeError, "isMemTainted(): expected an address (integer) as argument"); MemoryOperand mo(PyLong_AsLongLong(mem), 1); if (ap.isMemTainted(mo) == true) Py_RETURN_TRUE; Py_RETURN_FALSE; }
static PyObject *smt2lib_extract(PyObject *self, PyObject *args) { PyObject *op1 = nullptr; PyObject *op2 = nullptr; PyObject *op3 = nullptr; /* Extract arguments */ PyArg_ParseTuple(args, "|OOO", &op1, &op2, &op3); if (op1 == nullptr || (!PyLong_Check(op1) && !PyInt_Check(op1))) return PyErr_Format(PyExc_TypeError, "extract(): expected an integer as first argument"); if (op2 == nullptr || (!PyLong_Check(op2) && !PyInt_Check(op2))) return PyErr_Format(PyExc_TypeError, "extract(): expected an integer as second argument"); if (op3 == nullptr || !PySmtAstNode_Check(op3)) return PyErr_Format(PyExc_TypeError, "extract(): expected a SmtAstNode as third argument"); return PySmtAstNode(smt2lib::extract(PyLong_AsLongLong(op1), PyLong_AsLongLong(op2), PySmtAstNode_AsSmtAstNode(op3))); }
long long pylong_to_int64(PyObject *pyid) { long long id; id = PyLong_AsLongLong(pyid); if (id < 1 && !PyErr_Occurred()) { set_error(PyExc_OverflowError, "key is lesser than minimum"); } return id; }
static td_tag_t py_type_to_td(PyObject *pVal) { if (PyInt_Check(pVal)){ #if INT32_MAX==LONG_MAX return TD_INT32; #else return longlong_to_td(PyInt_AS_LONG(pVal)); #endif } else if (PyLong_Check(pVal)){ PyObject *pErr; long long v; v = PyLong_AsLongLong(pVal); if ( v == -1 && PyErr_Occurred()) { // could not eval as long long try unsigned long long later PyErr_Clear(); } else { return longlong_to_td(PyInt_AS_LONG(v)); } unsigned long long vv; vv = PyLong_AsUnsignedLongLong(pVal); if ( v == (unsigned long long) -1 && PyErr_Occurred() ) { PyErr_Clear(); return TD_OBJECT; } else { return TD_UINT64; } } else if (PyFloat_Check(pVal)) { return TD_DOUBLE; } else if (PyUnicode_Check(pVal)){ PyObject *pStr; pStr = PyUnicode_AsUTF8String(pVal); if ( pStr && PyErr_Occurred() ){ PyErr_Clear(); return TD_OBJECT; } else { return TD_UTF8; } } else if (PyString_Check(pVal)) { return TD_UTF8; } else if (PyArray_Check(pVal)) { return TD_ARRAY; } return TD_OBJECT; }
static void *PyDateTimeToINT64(JSOBJ _obj, JSONTypeContext *tc, void *outValue, size_t *_outLen) { PyObject *obj = (PyObject *) _obj; PyObject* timetuple = PyObject_CallMethod(obj, "utctimetuple", NULL); PyObject* unixTimestamp = PyObject_CallMethodObjArgs(mod_calendar, meth_timegm, timetuple, NULL); *( (JSINT64 *) outValue) = PyLong_AsLongLong (unixTimestamp); Py_DECREF(timetuple); Py_DECREF(unixTimestamp); return NULL; }
int64_t pyobject_to_int64(PyObject * py_obj) { if ( PyInt_Check(py_obj) ) { return PyInt_AsLong(py_obj); } else if ( PyLong_Check(py_obj) ) { return PyLong_AsLongLong(py_obj); } else { return 0; } }
static int Command_setattr(twopence_Command *self, char *name, PyObject *v) { if (!strcmp(name, "stdout")) { if (v != Py_None && !PyByteArray_Check(v)) goto bad_attr; assign_object(&self->stdout, v); return 0; } if (!strcmp(name, "stderr")) { if (v != Py_None && !PyByteArray_Check(v)) goto bad_attr; assign_object(&self->stderr, v); return 0; } if (!strcmp(name, "user")) { char *s; if (!PyString_Check(v) || (s = PyString_AsString(v)) == NULL) goto bad_attr; assign_string(&self->user, s); return 0; } if (!strcmp(name, "timeout")) { if (PyInt_Check(v)) self->timeout = PyInt_AsLong(v); else if (PyLong_Check(v)) self->timeout = PyLong_AsLongLong(v); else goto bad_attr; return 0; } if (!strcmp(name, "quiet")) { self->quiet = !!(PyObject_IsTrue(v)); return 0; } if (!strcmp(name, "useTty")) { self->useTty = !!(PyObject_IsTrue(v)); return 0; } if (!strcmp(name, "background")) { self->background = !!(PyObject_IsTrue(v)); return 0; } (void) PyErr_Format(PyExc_AttributeError, "Unknown attribute: %s", name); return -1; bad_attr: (void) PyErr_Format(PyExc_AttributeError, "Incompatible value for attribute: %s", name); return -1; }
static PyObject *Triton_checkWriteAccess(PyObject *self, PyObject *addr) { uint64 ad; if (!PyLong_Check(addr) && !PyInt_Check(addr)) return PyErr_Format(PyExc_TypeError, "checkWriteAccess(): expected an address (integer) as argument"); ad = PyLong_AsLongLong(addr); if (PIN_CheckWriteAccess(reinterpret_cast<void*>(ad)) == true) Py_RETURN_TRUE; Py_RETURN_FALSE; }
static PyObject *Triton_getSyscallArgument(PyObject *self, PyObject *args) { PyObject *num = nullptr; PyObject *std = nullptr; uint64 ret; /* Extract arguments */ PyArg_ParseTuple(args, "|OO", &std, &num); if (std == nullptr || (!PyLong_Check(std) && !PyInt_Check(std))) return PyErr_Format(PyExc_TypeError, "getSyscallArgument(): expected an id (integer) as first argument"); if (num == nullptr || (!PyLong_Check(num) && !PyInt_Check(num))) return PyErr_Format(PyExc_TypeError, "getSyscallArgument(): expected an id (integer) as second argument"); LEVEL_CORE::SYSCALL_STANDARD standard = static_cast<LEVEL_CORE::SYSCALL_STANDARD>(PyLong_AsLongLong(std));; CONTEXT *ctx = static_cast<CONTEXT*>(ap.getCurrentCtxH()->getCtx()); ret = PIN_GetSyscallArgument(ctx, standard, PyLong_AsLongLong(num)); return PyLong_FromLongLong(ret); }
static PyObject *Triton_getRegSymbolicID(PyObject *self, PyObject *reg) { RegisterOperand ro; uint64 regId = 0; if (!PyLong_Check(reg) && !PyInt_Check(reg)) return PyErr_Format(PyExc_TypeError, "getRegSymbolicID(): expected a register id (integer) as argument"); regId = PyLong_AsLongLong(reg); ro = createTmpReg(regId); return Py_BuildValue("k", ap.getRegSymbolicID(ro)); }
static PyObject *Triton_getFlagValue(PyObject *self, PyObject *flagId) { RegisterOperand flag; if (!PyLong_Check(flagId) && !PyInt_Check(flagId)) return PyErr_Format(PyExc_TypeError, "getFlagValue(): expected a flag id (IDREF.FLAG) as argument"); if (!ap.getCurrentCtxH()) return PyErr_Format(PyExc_TypeError, "getFlagValue(): Can't call getFlagValue() right now. You must run the program before."); flag = createTmpFlag(PyLong_AsLongLong(flagId)); return Py_BuildValue("k", ap.getFlagValue(flag)); }
static PyObject *Triton_getSyscallReturn(PyObject *self, PyObject *std) { uint64 ret; if (!PyLong_Check(std) && !PyInt_Check(std)) return PyErr_Format(PyExc_TypeError, "getSyscallReturn(): expected an id (integer) as argument"); LEVEL_CORE::SYSCALL_STANDARD standard = static_cast<LEVEL_CORE::SYSCALL_STANDARD>(PyLong_AsLongLong(std));; CONTEXT *ctx = static_cast<CONTEXT*>(ap.getCurrentCtxH()->getCtx()); ret = PIN_GetSyscallReturn(ctx, standard); return PyLong_FromLongLong(ret); }
BOOL PyObject_AsPROPVARIANT(PyObject *ob, PROPVARIANT *pVar) { if (ob==Py_None) { PropVariantInit(pVar); } else if (ob==Py_True) { pVar->boolVal = -1; pVar->vt = VT_BOOL; } else if (ob==Py_False) { pVar->boolVal = 0; pVar->vt = VT_BOOL; } else if (PyLong_Check(ob)) { pVar->hVal.QuadPart = PyLong_AsLongLong(ob); if (pVar->hVal.QuadPart == -1 && PyErr_Occurred()){ // Could still fit in an unsigned long long PyErr_Clear(); pVar->uhVal.QuadPart = PyLong_AsUnsignedLongLong(ob); if (pVar->uhVal.QuadPart == -1 && PyErr_Occurred()) return FALSE; pVar->vt = VT_UI8; } else{ pVar->vt=VT_I8; // Could still fit in a regular long if (pVar->hVal.QuadPart >= LONG_MIN && pVar->hVal.QuadPart <= LONG_MAX){ pVar->lVal = (long)pVar->hVal.QuadPart; pVar->vt = VT_I4; } // ... or an unsigned long else if (pVar->hVal.QuadPart >=0 && pVar->hVal.QuadPart <= ULONG_MAX){ pVar->ulVal = (unsigned long)pVar->hVal.QuadPart; pVar->vt = VT_UI4; } } #if (PY_VERSION_HEX < 0x03000000) // Not needed in Py3k, as PyInt_Check is defined to PyLong_Check } else if (PyInt_Check(ob)) { pVar->lVal = PyInt_AsLong(ob); pVar->vt = VT_I4; #endif } else if (PyFloat_Check(ob)) { pVar->dblVal = PyFloat_AsDouble(ob); pVar->vt = VT_R8; } else if (PyUnicode_Check(ob) || PyString_Check(ob)) { PyWinObject_AsBstr(ob, &pVar->bstrVal); pVar->vt = VT_BSTR; } else { PyErr_SetString(PyExc_TypeError, "Unsupported object for PROPVARIANT"); return FALSE; } return TRUE; }
static int py_auth_user_info_set_force_password_change(PyObject *py_obj, PyObject *value, void *closure) { struct auth_user_info *object = (struct auth_user_info *)py_talloc_get_ptr(py_obj); if (PyLong_Check(value)) { object->force_password_change = PyLong_AsLongLong(value); } else if (PyInt_Check(value)) { object->force_password_change = PyInt_AsLong(value); } else { PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\ PyInt_Type.tp_name, PyLong_Type.tp_name); return -1; } return 0; }