Showing 1 of 3 files from the diff.

@@ -2395,6 +2395,10 @@
Loading
2395 2395
                self);
2396 2396
        return -1;
2397 2397
    }
2398 +
    if ((flags & PyBUF_WRITEABLE) == PyBUF_WRITEABLE) {
2399 +
        PyErr_SetString(PyExc_BufferError, "scalar buffer is readonly");
2400 +
        return -1;
2401 +
    }
2398 2402
    PyArray_Descr *descr = PyArray_DescrFromScalar(self);
2399 2403
    if (descr == NULL) {
2400 2404
        return -1;
@@ -2413,6 +2417,7 @@
Loading
2413 2417
    view->shape = NULL;
2414 2418
    view->strides = NULL;
2415 2419
    view->suboffsets = NULL;
2420 +
    view->readonly = 1;  /* assume general (user) scalars are readonly. */
2416 2421
    Py_INCREF(self);
2417 2422
    view->obj = self;
2418 2423
    view->buf = scalar_value(self, descr);
@@ -2444,6 +2449,7 @@
Loading
2444 2449
@name@_getbuffer(PyObject *self, Py_buffer *view, int flags)
2445 2450
{
2446 2451
    if ((flags & PyBUF_WRITEABLE) == PyBUF_WRITEABLE) {
2452 +
        PyErr_SetString(PyExc_BufferError, "scalar buffer is readonly");
2447 2453
        return -1;
2448 2454
    }
2449 2455
    Py@Name@ScalarObject *scalar = (Py@Name@ScalarObject *)self;
@@ -2456,6 +2462,7 @@
Loading
2456 2462
    view->shape = NULL;
2457 2463
    view->strides = NULL;
2458 2464
    view->suboffsets = NULL;
2465 +
    view->readonly = 1;
2459 2466
    Py_INCREF(self);
2460 2467
    view->obj = self;
2461 2468
    view->buf = &(scalar->obval);
@@ -2482,6 +2489,7 @@
Loading
2482 2489
unicode_getbuffer(PyObject *self, Py_buffer *view, int flags)
2483 2490
{
2484 2491
    if ((flags & PyBUF_WRITEABLE) == PyBUF_WRITEABLE) {
2492 +
        PyErr_SetString(PyExc_BufferError, "scalar buffer is readonly");
2485 2493
        return -1;
2486 2494
    }
2487 2495
    PyUnicodeScalarObject *scalar = (PyUnicodeScalarObject *)self;
@@ -2493,6 +2501,7 @@
Loading
2493 2501
    view->shape = NULL;
2494 2502
    view->strides = NULL;
2495 2503
    view->suboffsets = NULL;
2504 +
    view->readonly = 1;
2496 2505
    Py_INCREF(self);
2497 2506
    view->obj = self;
2498 2507
@@ -2522,7 +2531,7 @@
Loading
2522 2531
        view->format = scalar->buffer_fmt;
2523 2532
    }
2524 2533
    else {
2525 -
        scalar->buffer_fmt = PyObject_Malloc(22);
2534 +
        scalar->buffer_fmt = PyMem_Malloc(22);
2526 2535
        if (scalar->buffer_fmt == NULL) {
2527 2536
            Py_SETREF(view->obj, NULL);
2528 2537
            return -1;
@@ -2549,6 +2558,7 @@
Loading
2549 2558
@name@_getbuffer(PyObject *self, Py_buffer *view, int flags)
2550 2559
{
2551 2560
    if ((flags & PyBUF_WRITEABLE) == PyBUF_WRITEABLE) {
2561 +
        PyErr_SetString(PyExc_BufferError, "scalar buffer is readonly");
2552 2562
        return -1;
2553 2563
    }
2554 2564
    Py@Name@ScalarObject *scalar = (Py@Name@ScalarObject *)self;
@@ -2560,6 +2570,7 @@
Loading
2560 2570
    view->shape = &length;
2561 2571
    view->strides = NULL;
2562 2572
    view->suboffsets = NULL;
2573 +
    view->readonly = 1;
2563 2574
    Py_INCREF(self);
2564 2575
    view->obj = self;
2565 2576
@@ -2651,6 +2662,7 @@
Loading
2651 2662
{
2652 2663
    /* note: may be null if it was never requested */
2653 2664
    PyMem_Free(PyArrayScalar_VAL(v, Unicode));
2665 +
    PyMem_Free(((PyUnicodeScalarObject *)v)->buffer_fmt);
2654 2666
    /* delegate to the base class */
2655 2667
    PyUnicode_Type.tp_dealloc(v);
2656 2668
}
Files Coverage
numpy 83.76%
Project Totals (157 files) 83.76%
1
codecov:
2
  notify:
3
    require_ci_to_pass: no
4
    after_n_builds: 1
5
coverage:
6
  status:
7
    project:
8
      default:
9
        # Require 1% coverage, i.e., always succeed
10
        target: 1
11
    patch: true
12
    changes: false
13
comment: off
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading