How to access the 3D cursor with 'Local View' support?
Here's an example of 2 different ways to access the cursor.

Checking the space type and using only 3D views.

def context_cursor(context):
    scene = context.scene
    space = context.space_data

    cursor = (space if space and space.type == 'VIEW_3D'
              else scene).cursor_location
    return cursor


Using getattr with a fallback, however this isn't so reliable since it may return a 2D cursor for the image space (which probably isn't what you want).

# don't use this example!
def context_cursor(context):
    cursor = getattr(context.space_data, "cursor_location",
                     context.scene.cursor_location)
    return cursor


Note that when the 3D view isn't a Local View. context.space_data.cursor_location  will use the scene's cursor.