Seems code-block in Sphinx does the right thing with line numbering. Kind of unfortunate that there are different directives in Sphinx doing more or less the same thing...