Skip to content

Commit

Permalink
DOC: exclude autogenerated c/cpp/html files from 'trailing whitespace…
Browse files Browse the repository at this point in the history
…' checks (pandas-dev#24549)
  • Loading branch information
saurav-chakravorty authored and Pingviinituutti committed Feb 28, 2019
1 parent 5fc4c39 commit 671f3fe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
7 changes: 4 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
# this particular codebase (e.g. src/headers, src/klib, src/msgpack). However,
# we can lint all header files since they aren't "generated" like C files are.
MSG='Linting .c and .h' ; echo $MSG
cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime
cpplint --quiet --extensions=c,h --headers=h --recursive --filter=-readability/casting,-runtime/int,-build/include_subdir pandas/_libs/src/*.h pandas/_libs/src/parser pandas/_libs/ujson pandas/_libs/tslibs/src/datetime pandas/io/msgpack pandas/_libs/*.cpp pandas/util
RET=$(($RET + $?)) ; echo $MSG "DONE"

echo "isort --version-number"
Expand Down Expand Up @@ -174,9 +174,10 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
MSG='Check that no file in the repo contains tailing whitespaces' ; echo $MSG
set -o pipefail
if [[ "$AZURE" == "true" ]]; then
! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
# we exclude all c/cpp files as the c/cpp files of pandas code base are tested when Linting .c and .h files
! grep -n '--exclude=*.'{svg,c,cpp,html} -RI "\s$" * | awk -F ":" '{print "##vso[task.logissue type=error;sourcepath=" $1 ";linenumber=" $2 ";] Tailing whitespaces found: " $3}'
else
! grep -n --exclude="*.svg" -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
! grep -n '--exclude=*.'{svg,c,cpp,html} -RI "\s$" * | awk -F ":" '{print $1 ":" $2 ":Tailing whitespaces found: " $3}'
fi
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi
Expand Down
25 changes: 15 additions & 10 deletions pandas/util/move.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
Copyright (c) 2019, PyData Development Team
All rights reserved.
Distributed under the terms of the BSD Simplified License.
The full license is in the LICENSE file, distributed with this software.
*/

#include <Python.h>

#define COMPILING_IN_PY2 (PY_VERSION_HEX <= 0x03000000)
Expand Down Expand Up @@ -31,15 +40,13 @@ typedef struct {
static PyTypeObject stolenbuf_type; /* forward declare type */

static void
stolenbuf_dealloc(stolenbufobject *self)
{
stolenbuf_dealloc(stolenbufobject *self) {
Py_DECREF(self->invalid_bytes);
PyObject_Del(self);
}

static int
stolenbuf_getbuffer(stolenbufobject *self, Py_buffer *view, int flags)
{
stolenbuf_getbuffer(stolenbufobject *self, Py_buffer *view, int flags) {
return PyBuffer_FillInfo(view,
(PyObject*) self,
(void*) PyString_AS_STRING(self->invalid_bytes),
Expand All @@ -51,8 +58,8 @@ stolenbuf_getbuffer(stolenbufobject *self, Py_buffer *view, int flags)
#if COMPILING_IN_PY2

static Py_ssize_t
stolenbuf_getreadwritebuf(stolenbufobject *self, Py_ssize_t segment, void **out)
{
stolenbuf_getreadwritebuf(stolenbufobject *self,
Py_ssize_t segment, void **out) {
if (segment != 0) {
PyErr_SetString(PyExc_SystemError,
"accessing non-existent string segment");
Expand All @@ -63,8 +70,7 @@ stolenbuf_getreadwritebuf(stolenbufobject *self, Py_ssize_t segment, void **out)
}

static Py_ssize_t
stolenbuf_getsegcount(stolenbufobject *self, Py_ssize_t *len)
{
stolenbuf_getsegcount(stolenbufobject *self, Py_ssize_t *len) {
if (len) {
*len = PyString_GET_SIZE(self->invalid_bytes);
}
Expand Down Expand Up @@ -157,8 +163,7 @@ PyDoc_STRVAR(
however, if called through *unpacking like ``stolenbuf(*(a,))`` it would
only have the one reference (the tuple). */
static PyObject*
move_into_mutable_buffer(PyObject *self, PyObject *bytes_rvalue)
{
move_into_mutable_buffer(PyObject *self, PyObject *bytes_rvalue) {
stolenbufobject *ret;

if (!PyString_CheckExact(bytes_rvalue)) {
Expand Down

0 comments on commit 671f3fe

Please sign in to comment.