ValueError: depythonifying 'pointer', got 'int'

Issue #115 resolved
Justin Nesselrotte
created an issue

I'm trying to figure out how to pass an unsigned int pointer to an objc.function. I keep getting this error: ValueError: depythonifying 'pointer', got 'int'

I read that this area previously had some issues, so I didn't know if I was doing it correctly or not. What is the correct way to interface with an unsigned int?

I need to be able to use the unsigned int value later, so I'm a little confused about that.

Comments (8)

  1. Ronald Oussoren repo owner

    The function likely needs additional metadata to describe how the pointer is used.

    That is, given a C function like: void use_int(int* p_value);

    PyObjC doesn't know how "p_value" is used: it it used to read or write a value (or both), and is it a single value or an array of some size.

  2. Justin Nesselrotte reporter

    It's the IOPMAssertionCreateWithName function. I imported the IOKit bundle using this command:

    bundle = objc.initFrameworkWrapper("IOKit", frameworkIdentifier="", frameworkPath=objc.pathForFramework("/System/Library/Frameworks/IOKit.framework"), globals=globals())

    I assume that it's written in this function.

  3. Ronald Oussoren repo owner

    That's using Apple's metadata, and as I expected that file is incomplete.

    The easiest workaround is to create the wrapper for this function manually after the call to objcinitFrameworkWrapper:

    objc.loadBundleFunctions(bundle, globals(), [("IOPMAssertionCreateWithName", b"i@I@o^I")])

    Then you can use the function:

    success, assertionID = IOPMAssertionCreateWithName(kIOPMAssertionTypeNoDisplaySleep, kIOPMAssertionLevelOn, "hello", None)
  4. Silver Kuusik

    I get the same error:

    Traceback (most recent call last):
      File "", line 11, in <module>
        sock.connect(("00:12:09:25:90:82", 1))
      File "build/bdist.macosx-10.11-intel/egg/bluetooth/", line 119, in connect
      File "build/bdist.macosx-10.11-intel/egg/lightblue/", line 351, in connect
    ValueError: depythonifying 'pointer', got 'tuple'

    so it's Apple's frameworks problem ?

  5. Log in to comment