In my subsequent work on a similar issue, I've found that this code has another misunderstanding ...
It seems that the gribapi defaults have changed so that default access to this parameter (as in "message.attribute") now returns a string instead of a number as previously.  So instead of numbers 1 and 100, we now get **'sfc'** and **'pl'**  (i.e. "surface" and "pressure level").
Also note, the alternative parameters levelType and indicatorOfTypeOfLevel aren't different (as you might expect), but behave exactly the same  (and they both now return  strings in this way).

So, I believe this whole section *should* now read : 
```
IF
grib.edition == 1
grib.levelType == 'pl'
THEN
CoordAndDims(DimCoord(points=grib.level, long_name="pressure", units="hPa"))

IF
grib.edition == 1
grib.levelType = 'sfc'
THEN
CoordAndDims(DimCoord(points=0, long_name="height", units="m"))
```