Can't remove object via python once grouped I'm writing a script that is adding and removing about 50 objects every frame. That part is working fine, but once I add the objects to a group, it creates odd errors. 

In tracking down the error, I simplified my project and ran into the same issue

I could understand if the group were one of the users of the object, but the object.users count doesn't increase when grouped.

Try it yourself:

import bpy

scn = bpy.data.scenes['Scene']
ob = bpy.data.objects['Cube']

scn.objects.unlink(ob)
bpy.data.objects.remove(ob)


works fine, but:

import bpy

scn = bpy.data.scenes['Scene']
ob = bpy.data.objects['Cube']

testgroup = bpy.data.groups.new('testgroup')
testgroup.objects.link(ob)
testgroup.objects.unlink(ob)

scn.objects.unlink(ob)
bpy.data.objects.remove(ob)


throws the following error:

RuntimeError: Error: Object 'Cube' must have zero users to be removed, found 1


What's going on? Am I missing something, or do I need to file a bug report?
So, I submitted a bug report, and got a same day response from Bastien. Turns out, the problem is related to the Fake User restructuring that is going on and there isn't a straightforward way to do it. Here's a link to the bug report: Blender Bug Tracker

He also pointed me in the direction of an effective workaround that I thought I'd share. Here is the working code:

import bpy

scn = bpy.data.scenes['Scene']
ob = bpy.data.objects['Cube']

testgroup = bpy.data.groups.new('testgroup')
testgroup.objects.link(ob)
testgroup.objects.unlink(ob)

scn.objects.unlink(ob)

ob.user_clear()    #manually clears all users, frees the object to be removed

bpy.data.objects.remove(ob)