Skip to content

Commit

Permalink
lcmgen python: remove py 2 cStringIO compatibility
Browse files Browse the repository at this point in the history
Python 2 support has been dropped so the `try ... execpt` of the py 2
module can be removed.

`import cStringIO.StringIO as BytesIO` was confusing pylance with
`Module is not callable`. Therefore it couldn't determain that `encode`
returned `bytes`.
  • Loading branch information
judfs authored and nosracd committed Oct 13, 2023
1 parent 14f63c5 commit 0d6009c
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lcmgen/emit_python.c
Original file line number Diff line number Diff line change
Expand Up @@ -834,10 +834,7 @@ emit_package (lcmgen_t *lcm, _package_contents_t *pc)
"DO NOT MODIFY BY HAND!!!!\n"
"\"\"\"\n"
"\n"
"try:\n"
" import cStringIO.StringIO as BytesIO\n"
"except ImportError:\n"
" from io import BytesIO\n"
"from io import BytesIO\n"
"import struct\n\n");

// enums always encoded as int32
Expand Down Expand Up @@ -919,10 +916,7 @@ emit_package (lcmgen_t *lcm, _package_contents_t *pc)
"DO NOT MODIFY BY HAND!!!!\n"
"\"\"\"\n"
"\n"
"try:\n"
" import cStringIO.StringIO as BytesIO\n"
"except ImportError:\n"
" from io import BytesIO\n"
"from io import BytesIO\n"
"import struct\n\n");

emit_python_dependencies(lcm, f, ls);
Expand Down

0 comments on commit 0d6009c

Please sign in to comment.