bpo-46841: Add a _Py_SET_OPCODE macro (GH-31780)

This commit is contained in:
Brandt Bucher 2022-03-11 16:31:50 -08:00 committed by GitHub
parent 882d8096c2
commit a89c29fbcc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 81 deletions

View file

@ -23,6 +23,9 @@ typedef uint16_t _Py_CODEUNIT;
# define _Py_MAKECODEUNIT(opcode, oparg) ((opcode)|((oparg)<<8))
#endif
// Use "unsigned char" instead of "uint8_t" here to avoid illegal aliasing:
#define _Py_SET_OPCODE(word, opcode) (((unsigned char *)&(word))[0] = (opcode))
/* Bytecode object */
struct PyCodeObject {