Why does my Python script "Onionize" my cone?
As commented above, the lines

active.modifiers.new(name='mysubsurf', type='SUBSURF')
active.modifiers["mysubsurf"].levels = 5
bpy.ops.object.modifier_apply(apply_as='DATA',modifier="mysubsurf")


in the code confirm that the problem is the interaction between subsurface modifier and tris in the mesh geometry. Remove or comment these lines and you will get beautiful cones.

The code can be used if the primitve added is based on quads.