This is because your mesh is very coarse, and thus the accuracy of the circle is reduced. Increasing the tolerance in near solves the problem:
from fenics import *
import numpy as np
import matplotlib.pyplot as plt
from mshr import *
#create mesh
domain1 = Rectangle(Point(0.0, 0.0), Point(10.0, 1.0))
domain2 = Circle(Point(0.5, 0.5), 0.25)
mesh = generate_mesh(domain1 - domain2, 100)
class Internal_Boundary(SubDomain):
def inside(self, x, on_boundary):
return near((x[0]-0.5)**2 + (x[1]-0.5)**2, 0.25**2, 1e-2) and on_boundary
internal_boundary = Internal_Boundary()
#boundary marks
bmf = MeshFunction("size_t", mesh, mesh.topology().dim()-1)
internal_boundary.mark(bmf, 5)
ds = Measure("ds", domain= mesh, subdomain_data= bmf)
print(assemble(1*ds(5)))
File("mesh.pvd")<< bmf