Skip to content

Commit d9546e2

Browse files
committed
Add support for Python 3.12 and 3.13
1 parent 2c975a1 commit d9546e2

File tree

8 files changed

+37
-8
lines changed

8 files changed

+37
-8
lines changed

.github/workflows/python-package.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@ jobs:
1717
fail-fast: false
1818
matrix:
1919
os: [ubuntu-20.04, ubuntu-latest, windows-latest, macos-latest]
20-
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11']
20+
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
2121
exclude:
22+
# ubuntu-latest (24.04) doesn't support Python 3.6-3.7 (EOL)
2223
- os: ubuntu-latest
2324
python-version: '3.6'
25+
- os: ubuntu-latest
26+
python-version: '3.7'
27+
# ubuntu-20.04 only tests Python 3.6 (not available on ubuntu-latest)
2428
- os: ubuntu-20.04
2529
python-version: '3.7'
2630
- os: ubuntu-20.04
@@ -31,6 +35,13 @@ jobs:
3135
python-version: '3.10'
3236
- os: ubuntu-20.04
3337
python-version: '3.11'
38+
- os: ubuntu-20.04
39+
python-version: '3.12'
40+
- os: ubuntu-20.04
41+
python-version: '3.13'
42+
# macos-latest (ARM64) doesn't support Python 3.6 (never built for ARM64)
43+
- os: macos-latest
44+
python-version: '3.6'
3445

3546
steps:
3647
- uses: actions/checkout@v3

CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
CHANGELOG
33
=========
44

5+
1.2.6 (layer_v13)
6+
===================
7+
* Add support for Python 3.12 and 3.13
8+
59
1.2.5 (layer_v12)
610
===================
711
* Fix bug which causes agent to crash if line_no was None.

codeguru_profiler_agent/agent_metadata/agent_metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# NOTE: Please do not alter the value for the following constants without the full knowledge of the use of them.
1010
# These constants are used in several scripts, including setup.py.
1111
__agent_name__ = "CodeGuruProfiler-python"
12-
__agent_version__ = "1.2.5"
12+
__agent_version__ = "1.2.6"
1313

1414

1515
def look_up_fleet_info(

codeguru_profiler_agent/sampler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ def _threads_to_sample_from(self, all_threads):
6262
if len(all_threads) > self._max_threads:
6363
if isinstance(all_threads, dict):
6464
all_threads = list(all_threads.keys())
65-
return random.sample(all_threads, self._max_threads)
65+
return random.sample(all_threads, self._max_threads) # nosec B311
6666
else:
6767
return list(all_threads)

codeguru_profiler_agent/utils/time.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
from __future__ import absolute_import
22

33
import time
4-
from datetime import datetime
4+
from datetime import datetime, timezone
55

66

77
def to_iso(epoch_milli):
88
try:
9-
return datetime.utcfromtimestamp(epoch_milli / 1000).isoformat(
10-
timespec='milliseconds') + "Z" # ISO 8601 date-time format
9+
return datetime.fromtimestamp(epoch_milli / 1000, timezone.utc).replace(
10+
tzinfo=None).isoformat(timespec='milliseconds') + "Z" # ISO 8601 date-time format
1111
except ValueError:
1212
return str(epoch_milli)
1313

setup.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def find_version(*file_paths):
3535
download_url="https://github.com/aws/amazon-codeguru-profiler-python-agent",
3636
classifiers=[
3737
"Programming Language :: Python :: 3",
38+
"Programming Language :: Python :: 3.6",
39+
"Programming Language :: Python :: 3.7",
40+
"Programming Language :: Python :: 3.8",
41+
"Programming Language :: Python :: 3.9",
42+
"Programming Language :: Python :: 3.10",
43+
"Programming Language :: Python :: 3.11",
44+
"Programming Language :: Python :: 3.12",
45+
"Programming Language :: Python :: 3.13",
3846
"Development Status :: 5 - Production/Stable",
3947
"Topic :: Utilities",
4048
"License :: OSI Approved :: Apache Software License"

test/unit/metrics/test_with_timer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ def foo_wall(self):
1919
def foo_cpu(self):
2020
# Call set_int_max_str for specific versions to test as its limited to resolve CVE-2020-10735
2121
# (https://docs.python.org/3/library/stdtypes.html#integer-string-conversion-length-limitation)
22-
if (sys.version_info >= (3, 7) and platform.system() != 'Windows') or (sys.version_info >= (3, 10) and platform.system() == 'Windows'):
22+
# Note: set_int_max_str_digits was added in 3.10.2, 3.9.10, 3.8.12 (security backport)
23+
if hasattr(sys, 'set_int_max_str_digits'):
2324
sys.set_int_max_str_digits(0)
2425
len(str(2 ** 500_000))
2526
return

test/unit/model/test_memory_counter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,10 @@ def test_sanity_check_it_counts_frame_file_path_line_no_class_name_size(self):
6969
subject.count_create_node(frame="test/frame", file_path="test/file/path", class_name="TestClass")
7070
# [Oct-2020 Python-3.7.7] "test/frame" size: 59 bytes; "test/file/path" size: 63 bytes; "TestClass" size:
7171
# 58 bytes; fixed line_no size: 2 * 32 = 64; sum = 244
72-
expected_size = subject.empty_node_size_bytes + 244
72+
# [Dec-2025 Python-3.13] Internal string memory optimization reduced size by 24 bytes; sum = 220
73+
import sys
74+
if sys.version_info >= (3, 13):
75+
expected_size = subject.empty_node_size_bytes + 220
76+
else:
77+
expected_size = subject.empty_node_size_bytes + 244
7378
assert (subject.get_memory_usage_bytes() == expected_size)

0 commit comments

Comments
 (0)