Staging
v0.5.1
https://github.com/python/cpython
Revision a993658f94a8bc894cfe44fd67eee26c06b4bf8f authored by Miss Islington (bot) on 10 January 2020, 12:12:30 UTC, committed by GitHub on 10 January 2020, 12:12:30 UTC


* Add test cases for dataclasses.

* Add test for repr output of field.
* Add test for ValueError to be raised when both default and default_factory are passed.
(cherry picked from commit eef1b027ab70704bcaa60a089e4ae1592c504b86)


Co-authored-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>

Automerge-Triggered-By: @ericvsmith
1 parent 00ac28a
Raw File
Tip revision: a993658f94a8bc894cfe44fd67eee26c06b4bf8f authored by Miss Islington (bot) on 10 January 2020, 12:12:30 UTC
[3.7] Add test cases for dataclasses. (GH-17909) (GH-17920)
Tip revision: a993658
wordcode_helpers.h
/* This file contains code shared by the compiler and the peephole
   optimizer.
 */

#ifdef WORDS_BIGENDIAN
#  define PACKOPARG(opcode, oparg) ((_Py_CODEUNIT)(((opcode) << 8) | (oparg)))
#else
#  define PACKOPARG(opcode, oparg) ((_Py_CODEUNIT)(((oparg) << 8) | (opcode)))
#endif

/* Minimum number of code units necessary to encode instruction with
   EXTENDED_ARGs */
static int
instrsize(unsigned int oparg)
{
    return oparg <= 0xff ? 1 :
        oparg <= 0xffff ? 2 :
        oparg <= 0xffffff ? 3 :
        4;
}

/* Spits out op/oparg pair using ilen bytes. codestr should be pointed at the
   desired location of the first EXTENDED_ARG */
static void
write_op_arg(_Py_CODEUNIT *codestr, unsigned char opcode,
    unsigned int oparg, int ilen)
{
    switch (ilen) {
        case 4:
            *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 24) & 0xff);
            /* fall through */
        case 3:
            *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 16) & 0xff);
            /* fall through */
        case 2:
            *codestr++ = PACKOPARG(EXTENDED_ARG, (oparg >> 8) & 0xff);
            /* fall through */
        case 1:
            *codestr++ = PACKOPARG(opcode, oparg & 0xff);
            break;
        default:
            Py_UNREACHABLE();
    }
}
back to top