Skip to content

Commit dfa9774

Browse files
committed
style: make these macros more bullet-proof
1 parent f3a70c9 commit dfa9774

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Diff for: coverage/ctracer/tracer.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ CTracer_handle_call(CTracer *self, PyFrameObject *frame)
523523
* re-entering a generator also. f_lasti is -1 for a true call, and a
524524
* real byte offset for a generator re-entry.
525525
*/
526-
if (frame->f_lasti < 0) {
526+
if (MyFrame_lasti(frame) < 0) {
527527
self->pcur_entry->last_line = -MyFrame_GetCode(frame)->co_firstlineno;
528528
}
529529
else {

Diff for: coverage/ctracer/util.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
// The f_lasti field changed meaning in 3.10.0a7. It had been bytes, but
1616
// now is instructions, so we need to adjust it to use it as a byte index.
1717
#if PY_VERSION_HEX >= 0x030A00A7
18-
#define MyFrame_lasti(f) (f->f_lasti * 2)
18+
#define MyFrame_lasti(f) ((f)->f_lasti * 2)
1919
#else
20-
#define MyFrame_lasti(f) f->f_lasti
21-
#endif // 3.10.0a7
20+
#define MyFrame_lasti(f) ((f)->f_lasti)
21+
#endif
2222

2323
// Access f_code should be done through a helper starting in 3.9.
2424
#if PY_VERSION_HEX >= 0x03090000
2525
#define MyFrame_GetCode(f) (PyFrame_GetCode(f))
2626
#else
2727
#define MyFrame_GetCode(f) ((f)->f_code)
28-
#endif // 3.11
28+
#endif
2929

3030
/* The values returned to indicate ok or error. */
3131
#define RET_OK 0

0 commit comments

Comments
 (0)