The following issues were found
pandas/_libs/src/ujson/lib/ultrajsondec.c
2 issues
Line: 718
Column: 13
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
return SetError(ds, -1, "Could not reserve memory block");
}
ds->escHeap = 1;
memcpy(ds->escStart, oldStart, escLen * sizeof(wchar_t));
}
ds->escEnd = ds->escStart + newSize;
}
Reported by FlawFinder.
Line: 1159
Column: 5
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
escaping doesn't run into the wall each time */
char *locale;
struct DecoderState ds;
wchar_t escBuffer[(JSON_MAX_STACK_BUFFER_SIZE / sizeof(wchar_t))];
JSOBJ ret;
ds.start = (char *)buffer;
ds.end = ds.start + cbBuffer;
Reported by FlawFinder.
pandas/tests/frame/methods/test_add_prefix_suffix.py
2 issues
Line: 1
Column: 1
from pandas import Index
import pandas._testing as tm
def test_add_prefix_suffix(float_frame):
with_prefix = float_frame.add_prefix("foo#")
expected = Index([f"foo#{c}" for c in float_frame.columns])
tm.assert_index_equal(with_prefix.columns, expected)
Reported by Pylint.
Line: 5
Column: 1
import pandas._testing as tm
def test_add_prefix_suffix(float_frame):
with_prefix = float_frame.add_prefix("foo#")
expected = Index([f"foo#{c}" for c in float_frame.columns])
tm.assert_index_equal(with_prefix.columns, expected)
with_suffix = float_frame.add_suffix("#foo")
Reported by Pylint.
pandas/core/window/doc.py
2 issues
Line: 14
Column: 1
return "\n".join((header, "-" * len(header))) + "\n"
template_header = "Calculate the {window_method} {aggregation_description}.\n\n"
template_returns = dedent(
"""
Series or DataFrame
Return type is the same as the original object with ``np.float64`` dtype.\n
Reported by Pylint.
Line: 96
Column: 1
"""
).replace("\n", "", 1)
numba_notes = (
"See :ref:`window.numba_engine` and :ref:`enhancingperf.numba` for "
"extended documentation and performance considerations for the Numba engine.\n\n"
)
window_agg_numba_parameters = dedent(
Reported by Pylint.
pandas/_libs/src/klib/khash_python.h
2 issues
Line: 88
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
khuint64_t PANDAS_INLINE asuint64(double key) {
khuint64_t val;
memcpy(&val, &key, sizeof(double));
return val;
}
khuint32_t PANDAS_INLINE asuint32(float key) {
khuint32_t val;
Reported by FlawFinder.
Line: 94
Column: 5
CWE codes:
120
Suggestion:
Make sure destination can always hold the source data
khuint32_t PANDAS_INLINE asuint32(float key) {
khuint32_t val;
memcpy(&val, &key, sizeof(float));
return val;
}
#define ZERO_HASH 0
#define NAN_HASH 0
Reported by FlawFinder.
pandas/core/ops/invalid.py
2 issues
Line: 51
Column: 26
invalid_op : function
"""
def invalid_op(self, other=None):
typ = type(self).__name__
raise TypeError(f"cannot perform {name} with this index type: {typ}")
invalid_op.__name__ = name
return invalid_op
Reported by Pylint.
Line: 9
Column: 1
import numpy as np
def invalid_comparison(left, right, op):
"""
If a comparison has mismatched types and is not necessarily meaningful,
follow python3 conventions by:
- returning all-False for equality
Reported by Pylint.
pandas/_config/dates.py
2 issues
Line: 6
Column: 1
"""
from pandas._config import config as cf
pc_date_dayfirst_doc = """
: boolean
When True, prints and parses dates with the day first, eg 20/01/2005
"""
pc_date_yearfirst_doc = """
Reported by Pylint.
Line: 11
Column: 1
When True, prints and parses dates with the day first, eg 20/01/2005
"""
pc_date_yearfirst_doc = """
: boolean
When True, prints and parses dates with the year first, eg 2005/01/20
"""
with cf.config_prefix("display"):
Reported by Pylint.
pandas/core/groupby/numba_.py
2 issues
Line: 98
Column: 5
numba = import_optional_dependency("numba")
@numba.jit(nopython=nopython, nogil=nogil, parallel=parallel)
def group_agg(
values: np.ndarray,
index: np.ndarray,
begin: np.ndarray,
end: np.ndarray,
num_groups: int,
Reported by Pylint.
Line: 158
Column: 5
numba = import_optional_dependency("numba")
@numba.jit(nopython=nopython, nogil=nogil, parallel=parallel)
def group_transform(
values: np.ndarray,
index: np.ndarray,
begin: np.ndarray,
end: np.ndarray,
num_groups: int,
Reported by Pylint.
pandas/core/computation/common.py
2 issues
Line: 1
Column: 1
from functools import reduce
import numpy as np
from pandas._config import get_option
def ensure_decoded(s):
"""
Reported by Pylint.
Line: 8
Column: 1
from pandas._config import get_option
def ensure_decoded(s):
"""
If we have bytes, decode them to unicode.
"""
if isinstance(s, (np.bytes_, bytes)):
s = s.decode(get_option("display.encoding"))
Reported by Pylint.
pandas/compat/chainmap.py
2 issues
Line: 1
Column: 1
from typing import (
ChainMap,
MutableMapping,
TypeVar,
cast,
)
_KT = TypeVar("_KT")
_VT = TypeVar("_VT")
Reported by Pylint.
Line: 12
Column: 1
_VT = TypeVar("_VT")
class DeepChainMap(ChainMap[_KT, _VT]):
"""
Variant of ChainMap that allows direct updates to inner scopes.
Only works when all passed mapping are mutable.
"""
Reported by Pylint.
pandas/api/types/__init__.py
2 issues
Line: 5
Column: 1
Public toolkit API.
"""
from pandas._libs.lib import infer_dtype
from pandas.core.dtypes.api import * # noqa: F401, F403
from pandas.core.dtypes.concat import union_categoricals
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
Reported by Pylint.
Line: 5
Column: 1
Public toolkit API.
"""
from pandas._libs.lib import infer_dtype
from pandas.core.dtypes.api import * # noqa: F401, F403
from pandas.core.dtypes.concat import union_categoricals
from pandas.core.dtypes.dtypes import (
CategoricalDtype,
Reported by Pylint.