Jump to content

[C++] SMALL FIX - GetAsUnsignedLong

Recommended Posts

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?

#define PyLong_AsUnsignedLong (unsigned long)PyLong_AsLongLong


  • Love 7

Share this post

Link to post

@Ikarus_ Where can be found this function: bool PyTuple_GetUnsignedLong? Can't find it in my src.

Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • 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.