Rhino6 "Unable to add mesh to document"

I have just opened a Grasshopper document that I created in Rhino5. It contains a Python Script component that worked fine in Rhino5 and GH.

The error is:
Runtime error (PythonException): unable to add mesh to document

Traceback:
line 78, in AddMesh, “C:\Users\andrew.mole\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib\rhinoscript\mesh.py”
line 204, in script

Any ideas why? The relevant line in the script is:

meshes = [rs.AddMesh(pt4[:-1], fv4) if len(pt4) == 5 else rs.AddMesh(pt4[:-1], fv3) for pt4 in z]