Skip to content

[fix]: make mongoshake-stat compatible with Python 2 and Python 3#983

Open
hyeonghwa wants to merge 1 commit into
alibaba:developfrom
hyeonghwa:fix/mongoshake-stat-python-compat
Open

[fix]: make mongoshake-stat compatible with Python 2 and Python 3#983
hyeonghwa wants to merge 1 commit into
alibaba:developfrom
hyeonghwa:fix/mongoshake-stat-python-compat

Conversation

@hyeonghwa

@hyeonghwa hyeonghwa commented Jun 15, 2026

Copy link
Copy Markdown

Summary

  • Replace urllib2 with try/except import for Python 2/3 compatibility
  • Add from __future__ import print_function for print() compatibility
  • Replace unicode type check with str
  • Replace dict.has_key() with in operator
  • Wrap dict.keys() with list() for sortability in Python 3

Test plan

  • Run python2 ./mongoshake-stat --port=9100 and verify no SyntaxError
  • Run python3 ./mongoshake-stat --port=9100 and verify no SyntaxError
  • Verify output table formatting is intact on both versions

- Replace `urllib2` with try/except import for Python 2/3 compatibility
- Add `from __future__ import print_function` for print() compatibility
- Replace `unicode` type check with `str`
- Replace `dict.has_key()` with `in` operator
- Wrap `dict.keys()` with `list()` for sortability in Python 3
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


hyeonghwa seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@zhongli-james zhongli-james self-assigned this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants