summaryrefslogtreecommitdiff
path: root/dev-python/ijson/files/ijson-3.2.0_p0-py312.patch
blob: 52db9704f1f3315b34384b8a413c222f49c10941 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From e076d8343f63698355fd52dc2d6983fd1c1a745e Mon Sep 17 00:00:00 2001
From: Rodrigo Tobar <rtobar@icrar.org>
Date: Mon, 29 May 2023 12:24:27 +0800
Subject: [PATCH] Obtain gi_code by attribute lookup

We were previously getting it by intrusively examining the structure,
which was flaky and indeed broke during the transition to 3.12, where
the gi_code struct member was re-implemented via get/set methods.

This should address #95.

Signed-off-by: Rodrigo Tobar <rtobar@icrar.org>
---
 ijson/backends/yajl2_c/async_reading_generator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ijson/backends/yajl2_c/async_reading_generator.c b/ijson/backends/yajl2_c/async_reading_generator.c
index 25947cb..0e52a7d 100644
--- a/ijson/backends/yajl2_c/async_reading_generator.c
+++ b/ijson/backends/yajl2_c/async_reading_generator.c
@@ -77,7 +77,7 @@ static PyObject *maybe_pop_event(async_reading_generator *self)
 static int is_gen_coroutine(PyObject *o)
 {
 	if (PyGen_CheckExact(o)) {
-		PyCodeObject *code = (PyCodeObject *)((PyGenObject*) o)->gi_code;
+		PyCodeObject *code = (PyCodeObject *)PyObject_GetAttrString(o, "gi_code");
 		return code->co_flags & CO_ITERABLE_COROUTINE;
 	}
 	return 0;