Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a81d220

Browse files
committed
SF patch # 580411, move frame macros from frameobject.h into ceval.c
remove unused macros use co alias instead of f->f_code in macros
1 parent b6d29b7 commit a81d220

2 files changed

Lines changed: 10 additions & 23 deletions

File tree

Include/frameobject.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,6 @@ DL_IMPORT(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
5454

5555
/* The rest of the interface is specific for frame objects */
5656

57-
/* Tuple access macros */
58-
59-
#ifndef Py_DEBUG
60-
#define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i))
61-
#define GETITEMNAME(v, i) \
62-
PyString_AS_STRING((PyStringObject *)GETITEM((v), (i)))
63-
#else
64-
#define GETITEM(v, i) PyTuple_GetItem((v), (i))
65-
#define GETITEMNAME(v, i) PyString_AsString(GETITEM(v, i))
66-
#endif
67-
68-
#define GETUSTRINGVALUE(s) ((unsigned char *)PyString_AS_STRING(s))
69-
70-
/* Code access macros */
71-
72-
#define Getconst(f, i) (GETITEM((f)->f_code->co_consts, (i)))
73-
#define Getname(f, i) (GETITEMNAME((f)->f_code->co_names, (i)))
74-
#define Getnamev(f, i) (GETITEM((f)->f_code->co_names, (i)))
75-
76-
7757
/* Block management functions */
7858

7959
DL_IMPORT(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);

Python/ceval.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -521,11 +521,18 @@ eval_frame(PyFrameObject *f)
521521
char *filename;
522522
#endif
523523

524+
/* Tuple access macros */
525+
526+
#ifndef Py_DEBUG
527+
#define GETITEM(v, i) PyTuple_GET_ITEM((PyTupleObject *)(v), (i))
528+
#else
529+
#define GETITEM(v, i) PyTuple_GetItem((v), (i))
530+
#endif
531+
524532
/* Code access macros */
525533

526-
#define GETCONST(i) Getconst(f, i)
527-
#define GETNAME(i) Getname(f, i)
528-
#define GETNAMEV(i) Getnamev(f, i)
534+
#define GETCONST(i) (GETITEM(co->co_consts, (i)))
535+
#define GETNAMEV(i) (GETITEM(co->co_names, (i)))
529536
#define INSTR_OFFSET() (next_instr - first_instr)
530537
#define NEXTOP() (*next_instr++)
531538
#define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2])

0 commit comments

Comments
 (0)