Skip to content

Conversation

@Forest-Newark
Copy link
Contributor

@Forest-Newark Forest-Newark commented Dec 9, 2025

Add support for Python 3.12 and 3.13

Summary

This PR adds support for Python 3.12 and 3.13 to the CodeGuru Profiler Python agent while maintaining full backwards compatibility with Python 3.6-3.11.

Changes

Core Python 3.12/3.13 Support:

  • Fixed deprecated datetime.utcfromtimestamp() usage in codeguru_profiler_agent/utils/time.py

    • Replaced with datetime.fromtimestamp(epoch, timezone.utc) to eliminate deprecation warnings in Python 3.12+
    • Maintains identical output format and backwards compatibility
  • Updated memory counter test in test/unit/model/test_memory_counter.py

    • Added version-aware expectations for Python 3.12+ optimized string memory allocation (24 bytes reduction)
  • Updated package metadata in setup.py

    • Added Python 3.12 and 3.13 classifiers for PyPI
  • Updated CI/CD pipeline in .github/workflows/python-package.yml

    • Added Python 3.12 and 3.13 to test matrix
    • Fixed platform exclusions for EOL Python versions (3.6-3.7 on ubuntu-latest and macos-latest ARM64)

Test Fixes (Pre-existing Issues):

  • Fixed sys.set_int_max_str_digits test in test/unit/metrics/test_with_timer.py

    • Changed version check to hasattr() to handle backport variations across Python 3.8.x versions
  • Fixed Bandit security warning in codeguru_profiler_agent/sampler.py

    • Added # nosec B311 to suppress false positive for random.sample() (not used for cryptographic purposes)

Version bump: 1.2.5 → 1.2.6

Updated CHANGELOG.rst

Testing

  • ✅ All 337 unit tests pass on Python 3.13.2
  • ✅ All 336 unit tests pass on Python 3.12.12
  • ✅ No deprecation warnings
  • ✅ Backwards compatible with Python 3.6-3.11
  • ✅ CI/CD pipeline tests all versions 3.6-3.13 across ubuntu, windows, and macos

Motivation

Python 3.12 deprecated datetime.utcfromtimestamp() which will be removed in a future version. This change ensures the agent works without warnings on Python 3.12+ and is ready for AWS Lambda Python 3.13
runtime support.

@Forest-Newark Forest-Newark force-pushed the forestjn-python-version-3.13-update branch 2 times, most recently from d9546e2 to 58ebf42 Compare December 9, 2025 21:11
@Forest-Newark Forest-Newark force-pushed the forestjn-python-version-3.13-update branch from 58ebf42 to 6e43be2 Compare December 9, 2025 22:21
@Forest-Newark Forest-Newark linked an issue Dec 9, 2025 that may be closed by this pull request
@Forest-Newark Forest-Newark merged commit 4856d1d into main Dec 10, 2025
42 checks passed
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.

Add support for python 3.11 and 3.12

2 participants