It's worth noting that the documentation of the .set_version() method being called here is itself wrong: it references RFC 2459 Section 4.1.2.1 (which specifies the Version field for Certificates), when it should instead reference RFC 2986 Section 4.1 (which specifies the Version field for CSRs). Consider also filing a bug/PR with pyopenssl to update that documentation.
More context: certbot/certbot#9334 (comment)