Bmesh - Append selected vertices to a List (Working script not "Reloading" correctly) In Blender2.79,the script below calculates the selected vertices and stores them in a list.
As there were issues with calculating these vertices directly on a mesh instance ,the object's mesh had to be converted to a "bmesh" instance.

When the script is run it works fine in the "First run".  

But in the subsequent runs it gives the following error- AttributeError: 'bytes' object has no attribute 'verts'  

Also,on updating the bmesh with bmesh.update_edit_mesh(me)results in this error-  ReferenceError: BMesh data of type BMesh has been removed

How to resolve these bmesh errors?  

#-------------------------MAIN SCRIPT--------------------------
#Select vertices of default cube in Edit mode

from os import system
system("cls")

import bpy 
import bmesh

scene = bpy.context.scene
ob = scene.objects.active
vert = ob.data.vertices

#Set default mode == Edit 
if bpy.ops.object.mode_set.poll():
    bpy.ops.object.mode_set(mode='EDIT')

print("Active object = ",ob.name)
print("")

#Create Bmesh instance and calculate vertices 
print("Vert_selected")

me = ob.data
bm = bmesh.new()
bm = bmesh.from_edit_mesh(me) 

vert_selected = [v.co for v in bm.verts if v.select] #AttributeError: 'bytes' object has no attribute 'verts'   
for vs_s in vert_selected :
    print(vs_s)

bpy.ops.mesh.select_all(action='DESELECT')
bm.select_flush(True)


#bm.bmesh.update_edit_mesh(me) #If mode ==Object  -&gt; ReferenceError: BMesh data of type BMesh has been removed (Uncommenting results in Blender crash)
bm.free() 
ob.update_from_editmode()

print("Script exited")
Since there was no change in the actual mesh,updating the mesh with update_edit_mesh() was not required.Also setting object context directly to "Edit"mode as opposed to a context mode_set poll() works.

Code can be found here.