Errro on using Mesheditor in python3 for FeniCS 2019.1.0

I have been trying to generate the element for a square mesh following this post, https://fenicsproject.org/qa/8483/how-to-specify-cell-type-in-mesheditor-open/
from dolfin import *

mesh0 = UnitSquareMesh(2, 2)

mesh = Mesh()
editor = MeshEditor()

gdim = mesh0.geometry().dim()
tdim = mesh0.topology().dim()
c_type = mesh0.type()
c_str = c_type.type2string(c_type.cell_type())

editor.open(mesh, c_str, tdim, gdim)
editor.close()

it is working in FeniCS 2017.1.0 in docker.

But when I use FeniCS 2019.1.0 with python3, using the exact code, it does not work out. It posted the following error message, any clue?

$ python3 test.py
Traceback (most recent call last):
  File "test.py", line 11, in <module>
    c_str = c_type.type2string(c_type.cell_type())
TypeError: type2string(): incompatible function arguments. The following argument types are supported:
    1. (self: dolfin.cpp.mesh.CellType.Type) -> str

The following change removes the error for me in 2019.2:

#c_str = c_type.type2string(c_type.cell_type())
c_str = CellType.type2string(c_type.cell_type())
1 Like

Thanks @Kamensky, that works like a charm!