The following issues were found

numpy/fft/_pocketfft.c
6 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 930 Column: 7 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      c[i].i = ch[i].i*fct;
        }
    else
      memcpy (c,p1,len*sizeof(cmplx));
    }
  else
    if (fct!=1.)
      for (size_t i=0; i<len; ++i)
        {

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 1704 Column: 7 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                    for (size_t i=0; i<n; ++i)
        c[i] = fct*p1[i];
    else
      memcpy (c,p1,n*sizeof(double));
    }
  else
    if (fct!=1.)
      for (size_t i=0; i<n; ++i)
        c[i] *= fct;

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 2038 Column: 3 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                if (!tmp) return -1;
  tmp[0]=c[0];
  tmp[1]=0.;
  memcpy (tmp+2,c+1, (n-1)*sizeof(double));
  if ((n&1)==0) tmp[n+1]=0.;
  for (size_t m=2; m<n; m+=2)
    {
    tmp[2*n-m]=tmp[m];
    tmp[2*n-m+1]=-tmp[m+1];

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 2067 Column: 3 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                if (fftblue_fft(plan,tmp,-1,fct)!=0)
    { DEALLOC(tmp); return -1; }
  c[0] = tmp[0];
  memcpy (c+1, tmp+2, (n-1)*sizeof(double));
  DEALLOC(tmp);
  return 0;
  }

typedef struct cfft_plan_i

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 2264 Column: 13 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                    if (!fail)
        for (int i = 0; i < nrepeats; i++) {
            rptr[rstep-1] = 0.0;
            memcpy((char *)(rptr+1), dptr, npts*sizeof(double));
            if (rfft_forward(plan, rptr+1, fct)!=0) {fail=1; break;}
            rptr[0] = rptr[1];
            rptr[1] = 0.0;
            rptr += rstep;
            dptr += npts;

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 2306 Column: 11 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                    if (!plan) fail=1;
      if (!fail) {
        for (int i = 0; i < nrepeats; i++) {
          memcpy((char *)(rptr + 1), (dptr + 2), (npts - 1)*sizeof(double));
          rptr[0] = dptr[0];
          if (rfft_backward(plan, rptr, fct)!=0) {fail=1; break;}
          rptr += npts;
          dptr += npts*2;
        }

            

Reported by FlawFinder.

numpy/typing/tests/data/pass/ndarray_misc.py
6 issues
Value 'np.ndarray' is unsubscriptable
Error

Line: 19 Column: 4

              class SubClass(np.ndarray): ...

i4 = np.int32(1)
A: np.ndarray[Any, np.dtype[np.int32]] = np.array([[1]], dtype=np.int32)
B0 = np.empty((), dtype=np.int32).view(SubClass)
B1 = np.empty((1,), dtype=np.int32).view(SubClass)
B2 = np.empty((1, 1), dtype=np.int32).view(SubClass)
C: np.ndarray[Any, np.dtype[np.int32]] = np.array([0, 1, 2], dtype=np.int32)
D = np.empty(3).view(SubClass)

            

Reported by Pylint.

Value 'np.ndarray' is unsubscriptable
Error

Line: 23 Column: 4

              B0 = np.empty((), dtype=np.int32).view(SubClass)
B1 = np.empty((1,), dtype=np.int32).view(SubClass)
B2 = np.empty((1, 1), dtype=np.int32).view(SubClass)
C: np.ndarray[Any, np.dtype[np.int32]] = np.array([0, 1, 2], dtype=np.int32)
D = np.empty(3).view(SubClass)

i4.all()
A.all()
A.all(axis=0)

            

Reported by Pylint.

Unexpected keyword argument 'keepdims' in method call
Error

Line: 85 Column: 1

              i4.max()
A.max()
A.max(axis=0)
A.max(keepdims=True)
A.max(out=B0)

i4.mean()
A.mean()
A.mean(axis=0)

            

Reported by Pylint.

Unexpected keyword argument 'keepdims' in method call
Error

Line: 113 Column: 1

              i4.ptp()
A.ptp()
A.ptp(axis=0)
A.ptp(keepdims=True)
A.astype(int).ptp(out=B0)

i4.round()
A.round()
A.round(out=B2)

            

Reported by Pylint.

More than one statement on a single line
Error

Line: 16 Column: 29

              
import numpy as np

class SubClass(np.ndarray): ...

i4 = np.int32(1)
A: np.ndarray[Any, np.dtype[np.int32]] = np.array([[1]], dtype=np.int32)
B0 = np.empty((), dtype=np.int32).view(SubClass)
B1 = np.empty((1,), dtype=np.int32).view(SubClass)

            

Reported by Pylint.

Missing class docstring
Error

Line: 16 Column: 1

              
import numpy as np

class SubClass(np.ndarray): ...

i4 = np.int32(1)
A: np.ndarray[Any, np.dtype[np.int32]] = np.array([[1]], dtype=np.int32)
B0 = np.empty((), dtype=np.int32).view(SubClass)
B1 = np.empty((1,), dtype=np.int32).view(SubClass)

            

Reported by Pylint.

numpy/core/src/umath/_scaled_float_dtype.c
6 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 103 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  PyArray_SFloatDescr *descr = (PyArray_SFloatDescr *)PyArray_DESCR(arr);
    double value;

    memcpy(&value, data, sizeof(double));
    return PyFloat_FromDouble(value * descr->scaling);
}


static int

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 121 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  double value = PyFloat_AsDouble(obj);
    value /= descr->scaling;

    memcpy(data, &value, sizeof(double));
    return 0;
}


/* Special DType methods and the descr->f slot storage */

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 160 Column: 5 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      return NULL;
    }
    /* Don't copy PyObject_HEAD part */
    memcpy((char *)new + sizeof(PyObject),
            (char *)self + sizeof(PyObject),
            sizeof(PyArray_SFloatDescr) - sizeof(PyObject));

    new->scaling = new->scaling * factor;
    return (PyArray_Descr *)new;

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 288 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  char *out = data[1];
    for (npy_intp i = 0; i < N; i++) {
        double tmp;
        memcpy(&tmp, in, sizeof(double));
        tmp *= factor;
        memcpy(out, &tmp, sizeof(double));

        in += strides[0];
        out += strides[1];

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 290 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      double tmp;
        memcpy(&tmp, in, sizeof(double));
        tmp *= factor;
        memcpy(out, &tmp, sizeof(double));

        in += strides[0];
        out += strides[1];
    }
    return 0;

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 591 Column: 16 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              

static int
add_loop(const char *ufunc_name,
        PyArray_DTypeMeta *dtypes[3], PyObject *meth_or_promoter)
{
    PyObject *mod = PyImport_ImportModule("numpy");
    if (mod == NULL) {
        return -1;

            

Reported by FlawFinder.

numpy/core/src/multiarray/buffer.c
6 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 209 Column: 9 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      Py_ssize_t total_count = 1;
        Py_ssize_t dim_size;
        Py_ssize_t old_offset;
        char buf[128];
        int ret;

        if (PyTuple_Check(descr->subarray->shape)) {
            subarray_tuple = descr->subarray->shape;
            Py_INCREF(subarray_tuple);

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 398 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      /* XXX NPY_TIMEDELTA */
        case NPY_OBJECT:       if (_append_char(str, 'O') < 0) return -1; break;
        case NPY_STRING: {
            char buf[128];
            PyOS_snprintf(buf, sizeof(buf), "%ds", descr->elsize);
            if (_append_str(str, buf) < 0) return -1;
            break;
        }
        case NPY_UNICODE: {

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 405 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      }
        case NPY_UNICODE: {
            /* NumPy Unicode is always 4-byte */
            char buf[128];
            assert(descr->elsize % 4 == 0);
            PyOS_snprintf(buf, sizeof(buf), "%dw", descr->elsize / 4);
            if (_append_str(str, buf) < 0) return -1;
            break;
        }

            

Reported by FlawFinder.

char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 413 Column: 13 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

                      }
        case NPY_VOID: {
            /* Insert padding bytes */
            char buf[128];
            PyOS_snprintf(buf, sizeof(buf), "%dx", descr->elsize);
            if (_append_str(str, buf) < 0) return -1;
            break;
        }
        default:

            

Reported by FlawFinder.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 928 Column: 18 CWE codes: 126

                  }

    /* Strip whitespace, except from field names */
    buf = malloc(strlen(s) + 1);
    if (buf == NULL) {
        PyErr_NoMemory();
        return NULL;
    }
    p = buf;

            

Reported by FlawFinder.

strlen - Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected)
Security

Line: 948 Column: 44 CWE codes: 126

                  }
    *p = '\0';

    str = PyUnicode_FromStringAndSize(buf, strlen(buf));
    if (str == NULL) {
        free(buf);
        return NULL;
    }


            

Reported by FlawFinder.

pavement.py
6 issues
Unable to import 'paver'
Error

Line: 32 Column: 1

              import textwrap

# The paver package needs to be installed to run tasks
import paver
from paver.easy import Bunch, options, task, sh


#-----------------------------------
# Things to be changed for a release

            

Reported by Pylint.

Unable to import 'paver.easy'
Error

Line: 33 Column: 1

              
# The paver package needs to be installed to run tasks
import paver
from paver.easy import Bunch, options, task, sh


#-----------------------------------
# Things to be changed for a release
#-----------------------------------

            

Reported by Pylint.

Redefining name 'options' from outer scope (line 33)
Error

Line: 85 Column: 11

              

@task
def sdist(options):
    """Make source distributions.

    Parameters
    ----------
    options :

            

Reported by Pylint.

Redefining name 'options' from outer scope (line 33)
Error

Line: 168 Column: 24

                  return _compute_hash(idirs, hashlib.sha256)


def write_release_task(options, filename='README'):
    """Append hashes of release files to release notes.

    This appends file hashes to the release notes ane creates
    four README files of the result in various formats:


            

Reported by Pylint.

Redefining name 'options' from outer scope (line 33)
Error

Line: 237 Column: 19

              

@task
def write_release(options):
    """Write the README files.

    Two README files are generated from the release notes, one in ``rst``
    markup for the general release, the other in ``md`` markup for the github
    release notes.

            

Reported by Pylint.

Unnecessary "elif" after "return"
Error

Line: 77 Column: 5

              
    """
    root = f'numpy-{FULLVERSION}'
    if ftype == 'gztar':
        return root + '.tar.gz'
    elif ftype == 'zip':
        return root + '.zip'
    raise ValueError(f"Unknown type {type}")


            

Reported by Pylint.

numpy/random/src/pcg64/pcg64-test-data-gen.c
6 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 26 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

                s = (__uint128_t)seed;
  inc = (__uint128_t)0;
  pcg64_srandom_r(&rng, s, inc);
  printf("0x%" PRIx64, (uint64_t)(rng.state >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.state);
  printf("0x%" PRIx64, (uint64_t)(rng.inc >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.inc);
  for (i = 0; i < N; i++) {
    store[i] = pcg64_random_r(&rng);

            

Reported by FlawFinder.

printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 28 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

                pcg64_srandom_r(&rng, s, inc);
  printf("0x%" PRIx64, (uint64_t)(rng.state >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.state);
  printf("0x%" PRIx64, (uint64_t)(rng.inc >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.inc);
  for (i = 0; i < N; i++) {
    store[i] = pcg64_random_r(&rng);
  }


            

Reported by FlawFinder.

printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 53 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

                s = (__uint128_t)seed;
  i = (__uint128_t)0;
  pcg64_srandom_r(&rng, s, i);
  printf("0x%" PRIx64, (uint64_t)(rng.state >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.state);
  printf("0x%" PRIx64, (uint64_t)(rng.inc >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.inc);
  for (i = 0; i < N; i++) {
    store[i] = pcg64_random_r(&rng);

            

Reported by FlawFinder.

printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 55 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

                pcg64_srandom_r(&rng, s, i);
  printf("0x%" PRIx64, (uint64_t)(rng.state >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.state);
  printf("0x%" PRIx64, (uint64_t)(rng.inc >> 64));
  printf("%" PRIx64 "\n", (uint64_t)rng.inc);
  for (i = 0; i < N; i++) {
    store[i] = pcg64_random_r(&rng);
  }
  fp = fopen("pcg64-testset-2.csv", "w");

            

Reported by FlawFinder.

fopen - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 35 Column: 8 CWE codes: 362

                }

  FILE *fp;
  fp = fopen("pcg64-testset-1.csv", "w");
  if (fp == NULL) {
    printf("Couldn't open file\n");
    return -1;
  }
  fprintf(fp, "seed, 0x%" PRIx64 "\n", seed);

            

Reported by FlawFinder.

fopen - Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents?
Security

Line: 60 Column: 8 CWE codes: 362

                for (i = 0; i < N; i++) {
    store[i] = pcg64_random_r(&rng);
  }
  fp = fopen("pcg64-testset-2.csv", "w");
  if (fp == NULL) {
    printf("Couldn't open file\n");
    return -1;
  }
  fprintf(fp, "seed, 0x%" PRIx64 "\n", seed);

            

Reported by FlawFinder.

numpy/distutils/fcompiler/g95.py
6 issues
Method 'runtime_library_dir_option' is abstract in class 'CCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['G95FCompiler']

class G95FCompiler(FCompiler):
    compiler_type = 'g95'
    description = 'G95 Fortran Compiler'

#    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
    # $ g95 --version

            

Reported by Pylint.

Method 'find_library_file' is abstract in class 'CCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['G95FCompiler']

class G95FCompiler(FCompiler):
    compiler_type = 'g95'
    description = 'G95 Fortran Compiler'

#    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
    # $ g95 --version

            

Reported by Pylint.

Method 'wrap_unlinkable_objects' is abstract in class 'FCompiler' but is not overridden
Error

Line: 6 Column: 1

              
compilers = ['G95FCompiler']

class G95FCompiler(FCompiler):
    compiler_type = 'g95'
    description = 'G95 Fortran Compiler'

#    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
    # $ g95 --version

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              # http://g95.sourceforge.net/
from numpy.distutils.fcompiler import FCompiler

compilers = ['G95FCompiler']

class G95FCompiler(FCompiler):
    compiler_type = 'g95'
    description = 'G95 Fortran Compiler'


            

Reported by Pylint.

Missing class docstring
Error

Line: 6 Column: 1

              
compilers = ['G95FCompiler']

class G95FCompiler(FCompiler):
    compiler_type = 'g95'
    description = 'G95 Fortran Compiler'

#    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95!\) (?P<version>.*)\).*'
    # $ g95 --version

            

Reported by Pylint.

Line too long (105/100)
Error

Line: 14 Column: 1

                  # $ g95 --version
    # G95 (GCC 4.0.3 (g95!) May 22 2006)

    version_pattern = r'G95 \((GCC (?P<gccversion>[\d.]+)|.*?) \(g95 (?P<version>.*)!\) (?P<date>.*)\).*'
    # $ g95 --version
    # G95 (GCC 4.0.3 (g95 0.90!) Aug 22 2006)

    executables = {
        'version_cmd'  : ["<F90>", "--version"],

            

Reported by Pylint.

numpy/testing/__init__.py
6 issues
Unable to import '__init__._private.utils'
Error

Line: 10 Column: 1

              """
from unittest import TestCase

from ._private.utils import *
from ._private.utils import (_assert_valid_refcount, _gen_alignment_data,
                             IS_PYSTON)
from ._private import decorators as dec
from ._private.nosetester import (
    run_module_suite, NoseTester as Tester

            

Reported by Pylint.

Unable to import '__init__._private.utils'
Error

Line: 11 Column: 1

              from unittest import TestCase

from ._private.utils import *
from ._private.utils import (_assert_valid_refcount, _gen_alignment_data,
                             IS_PYSTON)
from ._private import decorators as dec
from ._private.nosetester import (
    run_module_suite, NoseTester as Tester
    )

            

Reported by Pylint.

Unable to import '__init__._private'
Error

Line: 13 Column: 1

              from ._private.utils import *
from ._private.utils import (_assert_valid_refcount, _gen_alignment_data,
                             IS_PYSTON)
from ._private import decorators as dec
from ._private.nosetester import (
    run_module_suite, NoseTester as Tester
    )

__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite']

            

Reported by Pylint.

Unable to import '__init__._private.nosetester'
Error

Line: 14 Column: 1

              from ._private.utils import (_assert_valid_refcount, _gen_alignment_data,
                             IS_PYSTON)
from ._private import decorators as dec
from ._private.nosetester import (
    run_module_suite, NoseTester as Tester
    )

__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite']


            

Reported by Pylint.

Undefined variable '_private'
Error

Line: 18 Column: 11

                  run_module_suite, NoseTester as Tester
    )

__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite']

from numpy._pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester

            

Reported by Pylint.

third party import "from numpy._pytesttester import PytestTester" should be placed before "from ._private.utils import *"
Error

Line: 20 Column: 1

              
__all__ = _private.utils.__all__ + ['TestCase', 'run_module_suite']

from numpy._pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester

            

Reported by Pylint.

numpy/core/src/multiarray/scalarapi.c
6 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 212 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      *ct = newptr;
    }
    else {
        memcpy(ctypeptr, newptr, typecode->elsize);
    }
    Py_DECREF(typecode);
    return;
}


            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 337 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                  else {
        char *memptr = scalar_value(scalar, typecode);

        memcpy(PyArray_DATA(r), memptr, PyArray_ITEMSIZE(r));
        if (PyDataType_FLAGCHK(typecode, NPY_ITEM_HASOBJECT)) {
            /* Need to INCREF just the PyObject portion */
            PyArray_Item_INCREF(memptr, typecode);
        }
    }

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 610 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                          return NULL;
        }
        dt_data = &(((PyArray_DatetimeDTypeMetaData *)descr->c_metadata)->meta);
        memcpy(dt_data, &((PyDatetimeScalarObject *)sc)->obmeta,
               sizeof(PyArray_DatetimeMetaData));

        return descr;
    }


            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 761 Column: 9 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      PyArray_DatetimeMetaData *dt_data;

        dt_data = &(((PyArray_DatetimeDTypeMetaData *)descr->c_metadata)->meta);
        memcpy(&(((PyDatetimeScalarObject *)obj)->obmeta), dt_data,
               sizeof(PyArray_DatetimeMetaData));
    }
    if (PyTypeNum_ISFLEXIBLE(type_num)) {
        if (type_num == NPY_STRING) {
            destptr = PyBytes_AS_STRING(obj);

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 768 Column: 13 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                      if (type_num == NPY_STRING) {
            destptr = PyBytes_AS_STRING(obj);
            ((PyBytesObject *)obj)->ob_shash = -1;
            memcpy(destptr, data, itemsize);
            return obj;
        }
        else {
            PyVoidScalarObject *vobj = (PyVoidScalarObject *)obj;
            vobj->base = NULL;

            

Reported by FlawFinder.

memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 805 Column: 17 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

                           * Copy data directly into dest.
             */
            if (base == NULL) {
                memcpy(destptr, data, itemsize);
                return obj;
            }
        }
    }
    else {

            

Reported by FlawFinder.

numpy/distutils/command/build.py
6 issues
String statement has no effect
Error

Line: 41 Column: 9

                      self.cpu_baseline = "min"
        self.cpu_dispatch = "max -xop -fma4" # drop AMD legacy features by default
        self.disable_optimization = False
        """
        the '_simd' module is a very large. Adding more dispatched features
        will increase binary size and compile time. By default we minimize
        the targeted features to those most commonly used by the NumPy SIMD interface(NPYV),
        NOTE: any specified features will be ignored if they're:
            - part of the baseline(--cpu-baseline)

            

Reported by Pylint.

Attribute 'build_scripts' defined outside __init__
Error

Line: 57 Column: 13

                      old_build.finalize_options(self)
        plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2])
        if build_scripts is None:
            self.build_scripts = os.path.join(self.build_base,
                                              'scripts' + plat_specifier)

    def run(self):
        old_build.run(self)

            

Reported by Pylint.

Missing module docstring
Error

Line: 1 Column: 1

              import os
import sys
from distutils.command.build import build as old_build
from distutils.util import get_platform
from numpy.distutils.command.config_compiler import show_fortran_compilers

class build(old_build):

    sub_commands = [('config_cc',     lambda *args: True),

            

Reported by Pylint.

Class name "build" doesn't conform to PascalCase naming style
Error

Line: 7 Column: 1

              from distutils.util import get_platform
from numpy.distutils.command.config_compiler import show_fortran_compilers

class build(old_build):

    sub_commands = [('config_cc',     lambda *args: True),
                    ('config_fc',     lambda *args: True),
                    ('build_src',     old_build.has_ext_modules),
                    ] + old_build.sub_commands

            

Reported by Pylint.

Missing class docstring
Error

Line: 7 Column: 1

              from distutils.util import get_platform
from numpy.distutils.command.config_compiler import show_fortran_compilers

class build(old_build):

    sub_commands = [('config_cc',     lambda *args: True),
                    ('config_fc',     lambda *args: True),
                    ('build_src',     old_build.has_ext_modules),
                    ] + old_build.sub_commands

            

Reported by Pylint.

Line too long (111/100)
Error

Line: 50 Column: 1

                          - not part of dispatch-able features(--cpu-dispatch)
            - not supported by compiler or platform
        """
        self.simd_test = "BASELINE SSE2 SSE42 XOP FMA4 (FMA3 AVX2) AVX512F AVX512_SKX VSX VSX2 VSX3 NEON ASIMD"

    def finalize_options(self):
        build_scripts = self.build_scripts
        old_build.finalize_options(self)
        plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2])

            

Reported by Pylint.