Jump to content

Fix GetAsUnsignedLong


Recommended Posts

  • Developer


I noticed that every my client have the same bug, maybe sharing the fix prevents me from having to apply it to everyone and it also helps others who try the function and have problems.

an example of buggy usage:

File: scriptLib\PythonUtils.cpp


bool PyTuple_GetUnsignedLong(PyObject* poArgs, int pos, unsigned long* ret)
{
	if (pos >= PyTuple_Size(poArgs))
		return false;

	PyObject * poItem = PyTuple_GetItem(poArgs, pos);

	if (!poItem)
		return false;

	*ret = PyLong_AsUnsignedLong(poItem);
	return true;
}

 

the problem seems to be PyLong_AsUnsignedLongLong which is buggy:

#define PyLong_AsUnsignedLong PyLong_AsUnsignedLongLong

 

 

how we could fix it?

//replacing
#define PyLong_AsUnsignedLong (unsigned long)PyLong_AsLongLong

 

  • Love 10

My youtube channel  on which you can see my works here

Link to comment
Share on other sites

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.