Skip to content

Commit

Permalink
style: make these macros more bullet-proof
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Nov 10, 2021
1 parent f3a70c9 commit dfa9774
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion coverage/ctracer/tracer.c
Expand Up @@ -523,7 +523,7 @@ CTracer_handle_call(CTracer *self, PyFrameObject *frame)
* re-entering a generator also. f_lasti is -1 for a true call, and a
* real byte offset for a generator re-entry.
*/
if (frame->f_lasti < 0) {
if (MyFrame_lasti(frame) < 0) {
self->pcur_entry->last_line = -MyFrame_GetCode(frame)->co_firstlineno;
}
else {
Expand Down
8 changes: 4 additions & 4 deletions coverage/ctracer/util.h
Expand Up @@ -15,17 +15,17 @@
// The f_lasti field changed meaning in 3.10.0a7. It had been bytes, but
// now is instructions, so we need to adjust it to use it as a byte index.
#if PY_VERSION_HEX >= 0x030A00A7
#define MyFrame_lasti(f) (f->f_lasti * 2)
#define MyFrame_lasti(f) ((f)->f_lasti * 2)
#else
#define MyFrame_lasti(f) f->f_lasti
#endif // 3.10.0a7
#define MyFrame_lasti(f) ((f)->f_lasti)
#endif

// Access f_code should be done through a helper starting in 3.9.
#if PY_VERSION_HEX >= 0x03090000
#define MyFrame_GetCode(f) (PyFrame_GetCode(f))
#else
#define MyFrame_GetCode(f) ((f)->f_code)
#endif // 3.11
#endif

/* The values returned to indicate ok or error. */
#define RET_OK 0
Expand Down

0 comments on commit dfa9774

Please sign in to comment.