I looked a bit into it and it seems that it's an oversight when moving on to Python 3. In line 204, the division should be an integer division (note the double slash):
o = self.pitch // 12 - 4 https://github.com/lilypond/lilypond/blob/master/scripts/midi2ly.py#L204