Skip to content

Commit

Permalink
Merge pull request #184 from P403n1x87/fix/311-version-detection
Browse files Browse the repository at this point in the history
fix: version detection on Python 3.11
  • Loading branch information
P403n1x87 authored Aug 12, 2023
2 parents 456d787 + 891b3e1 commit dbe26eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/python/symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ enum {
#ifdef PY_PROC_C

#ifdef PL_MACOS
#define SYM_PREFIX "__"
#else
#define SYM_PREFIX "_"
#else
#define SYM_PREFIX ""
#endif


static const char * _dynsym_array[] = {
SYM_PREFIX "PyThreadState_Current",
SYM_PREFIX "PyRuntime",
SYM_PREFIX "_PyThreadState_Current",
SYM_PREFIX "_PyRuntime",
"interp_head",
"Py_Version",
SYM_PREFIX "Py_Version",
};

static long _dynsym_hash_array[DYNSYM_COUNT] = {0};
Expand Down
17 changes: 17 additions & 0 deletions test/test_pipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from subprocess import check_output

from test.utils import allpythons
from test.utils import austin
from test.utils import compress
Expand Down Expand Up @@ -115,3 +117,18 @@ def test_pipe_wall_time_multiprocess_output(py, tmp_path):
d = int(meta["duration"])

assert 0 < 0.8 * d < a < 2.2 * d


@allpythons(min=(3, 11))
def test_python_version(py):
result = austin("-Pi", "1s", *python(py), target())
assert result.returncode == 0

meta = metadata(result.stdout)

reported_version = ".".join((str(_) for _ in meta["python"]))
actual_version = (
check_output([*python(py), "-V"]).decode().strip().partition(" ")[-1]
)

assert reported_version == actual_version, meta

0 comments on commit dbe26eb

Please sign in to comment.