Skip to content

Replace deprecated sre_compile with re - #589

Merged
scpeters merged 1 commit into
gazebosim:mainfrom
C88-YQ:codecheck
Sep 22, 2026
Merged

scpeters merged 1 commit into
gazebosim:mainfrom
C88-YQ:codecheck

Conversation

@C88-YQ

@C88-YQ C88-YQ commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦟 Bug fix

Summary

Python 3.11 deprecated the undocumented sre_compile module, causing a warning when running make codecheck:

DeprecationWarning: module 'sre_compile' is deprecated

This change replaces sre_compile.compile with the public re.compile API and removes the deprecated import.

Backport Policy

  • This is safe to backport to the following versions:
    • Jetty
    • Ionic
    • Harmonic
    • Fortress
  • This should not be backported
  • I am not sure
  • Other (fill in yourself)

Checklist

  • Signed all commits for DCO
  • Added a screen capture or video to the PR description that demonstrates the fix (as needed)
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • Updated Bazel files (if adding new files). Created an issue otherwise.
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers
  • Was GenAI used to generate this PR? If so, make sure to add "Assisted-by" to your commits. (See this policy for more info.)

Signed-off-by: C88-YQ <1409947012@qq.com>

@scpeters scpeters left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like there was a similar change in cpplint/cpplint#214

can you look briefly at those changes and see if there are meaningful differences?

we should also consider importing a new version of cpplint from that repo

@C88-YQ

C88-YQ commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@scpeters Thanks a lot for the review and suggestions!

I took a look at cpplint/cpplint#214. It contains two commits:

  1. replacing the deprecated sre_compile usage with re (same as the change in this PR)
  2. removes cpplint's own regex cache and relies on Python re's internal cache instead.

There was some discussion in that PR about the second change potentially causing a performance regression, so I did a small local test on gz-sim.

I ran make codecheck 10 times for both versions:

So there is some slowdown, although I think it is still within a reasonable range for codecheck.

For reference, I ran the test on the following system:

  • CPU: Intel Core Ultra 5 125H (14 cores / 18 threads)
  • RAM: 30 GiB
  • OS: Ubuntu 24.04.4 LTS
  • Kernel: 6.8.0-138-generic

@C88-YQ

C88-YQ commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor Author

Regarding importing a newer cpplint version, I agree that this would probably be a better long-term solution. I noticed that upstream cpplint is now at version 2.0.2, so this may be a good opportunity to update it.

I did a quick comparison and tried running the newer version locally. The changes are fairly large. Some are only formatting changes, but there are also behavioral differences in the checks. I made a few small adjustments to the areas that I thought needed updating, but I still wasn't able to get gz-sim to produce results comparable to the current version. I think this would need a more careful and comprehensive review before updating it.

Given that, perhaps it would make more sense to close this PR and open a separate PR to update cpplint directly to 2.0.2.

@scpeters what do you think would be the preferred direction here?

@github-project-automation github-project-automation Bot moved this from Inbox to In review in Core development Sep 22, 2026
@scpeters

Copy link
Copy Markdown
Member

@scpeters Thanks a lot for the review and suggestions!

I took a look at cpplint/cpplint#214. It contains two commits:

  1. replacing the deprecated sre_compile usage with re (same as the change in this PR)
  2. removes cpplint's own regex cache and relies on Python re's internal cache instead.

There was some discussion in that PR about the second change potentially causing a performance regression, so I did a small local test on gz-sim.

I ran make codecheck 10 times for both versions:

So there is some slowdown, although I think it is still within a reasonable range for codecheck.

yeah, this is a small change; I think it makes sense to just merge this and open a separate issue to evaluate updating the cpplint version

thanks for the contribution!

@scpeters
scpeters merged commit 5d8d37c into gazebosim:main Sep 22, 2026
10 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in Core development Sep 22, 2026
@scpeters

Copy link
Copy Markdown
Member

I'm going to let this live on main for a week before backporting

@C88-YQ
C88-YQ deleted the codecheck branch September 26, 2026 13:43
@C88-YQ C88-YQ mentioned this pull request Oct 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants