Compare commits

...

6 Commits

Author SHA1 Message Date
Andre Delfino bc662c0bd7
[doc] Fix abc.update_abstractmethods markup (GH-23576)
Add link to ABCMeta while at it.
2020-12-01 01:45:11 -08:00
Andre Delfino 80a429eae9
Fix bz2 examples markup (#23580) 2020-12-01 10:41:12 +01:00
Victor Stinner 32bd68c839
bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)
No longer use deprecated aliases to functions:

* Replace PyObject_MALLOC() with PyObject_Malloc()
* Replace PyObject_REALLOC() with PyObject_Realloc()
* Replace PyObject_FREE() with PyObject_Free()
* Replace PyObject_Del() with PyObject_Free()
* Replace PyObject_DEL() with PyObject_Free()
2020-12-01 10:37:39 +01:00
Victor Stinner 00d7abd7ef
bpo-42519: Replace PyMem_MALLOC() with PyMem_Malloc() (GH-23586)
No longer use deprecated aliases to functions:

* Replace PyMem_MALLOC() with PyMem_Malloc()
* Replace PyMem_REALLOC() with PyMem_Realloc()
* Replace PyMem_FREE() with PyMem_Free()
* Replace PyMem_Del() with PyMem_Free()
* Replace PyMem_DEL() with PyMem_Free()

Modify also the PyMem_DEL() macro to use directly PyMem_Free().
2020-12-01 09:56:42 +01:00
pxinwr b2d0c66e88
bpo-31904: Fix fifo test cases for VxWorks (GH-20254) 2020-12-01 09:20:50 +01:00
Raymond Hettinger cc061d0e6f
bpo-38200: Add itertools.pairwise() (GH-23549) 2020-11-30 20:42:54 -08:00
74 changed files with 515 additions and 325 deletions

View File

@ -336,6 +336,7 @@ The :mod:`abc` module also provides the following functions:
.. versionadded:: 3.4
.. function:: update_abstractmethods(cls)
A function to recalculate an abstract class's abstraction status. This
function should be called if a class's abstract methods have been
implemented or changed after it was created. Usually, this function should
@ -343,7 +344,7 @@ The :mod:`abc` module also provides the following functions:
Returns *cls*, to allow usage as a class decorator.
If *cls* is not an instance of ABCMeta, does nothing.
If *cls* is not an instance of :class:`ABCMeta`, does nothing.
.. note::

View File

@ -266,7 +266,6 @@ Below are some examples of typical usage of the :mod:`bz2` module.
Using :func:`compress` and :func:`decompress` to demonstrate round-trip compression:
>>> import bz2
>>> data = b"""\
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
@ -275,11 +274,9 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
>>> c = bz2.compress(data)
>>> len(data) / len(c) # Data compression ratio
1.513595166163142
>>> d = bz2.decompress(c)
>>> data == d # Check equality to original object after round-trip
True
@ -287,7 +284,6 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
Using :class:`BZ2Compressor` for incremental compression:
>>> import bz2
>>> def gen_data(chunks=10, chunksize=1000):
... """Yield incremental blocks of chunksize bytes."""
... for _ in range(chunks):
@ -310,7 +306,6 @@ while ordered, repetitive data usually yields a high compression ratio.
Writing and reading a bzip2-compressed file in binary mode:
>>> import bz2
>>> data = b"""\
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
@ -319,14 +314,11 @@ Writing and reading a bzip2-compressed file in binary mode:
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
>>> with bz2.open("myfile.bz2", "wb") as f:
... # Write compressed data to file
... unused = f.write(data)
>>> with bz2.open("myfile.bz2", "rb") as f:
... # Decompress data from file
... content = f.read()
>>> content == data # Check equality to original object after round-trip
True

View File

@ -55,6 +55,7 @@ Iterator Arguments Results
:func:`filterfalse` pred, seq elements of seq where pred(elem) is false ``filterfalse(lambda x: x%2, range(10)) --> 0 2 4 6 8``
:func:`groupby` iterable[, key] sub-iterators grouped by value of key(v)
:func:`islice` seq, [start,] stop [, step] elements from seq[start:stop:step] ``islice('ABCDEFG', 2, None) --> C D E F G``
:func:`pairwise` iterable (p[0], p[1]), (p[1], p[2]) ``pairwise('ABCDEFG') --> AB BC CD DE EF FG``
:func:`starmap` func, seq func(\*seq[0]), func(\*seq[1]), ... ``starmap(pow, [(2,5), (3,2), (10,3)]) --> 32 9 1000``
:func:`takewhile` pred, seq seq[0], seq[1], until pred fails ``takewhile(lambda x: x<5, [1,4,6,4,1]) --> 1 4``
:func:`tee` it, n it1, it2, ... itn splits one iterator into n
@ -475,6 +476,22 @@ loops that truncate the stream.
If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
then the step defaults to one.
.. function:: pairwise(iterable)
Return successive overlapping pairs taken from the input *iterable*.
The number of 2-tuples in the output iterator will be one fewer than the
number of inputs. It will be empty if the input iterable has fewer than
two values.
Roughly equivalent to::
def pairwise(iterable):
# pairwise('ABCDEFG') --> AB BC CD DE EF FG
a, b = tee(iterable)
next(b, None)
return zip(a, b)
.. function:: permutations(iterable, r=None)
@ -782,12 +799,6 @@ which incur interpreter overhead.
return starmap(func, repeat(args))
return starmap(func, repeat(args, times))
def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return zip(a, b)
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"

View File

@ -38,7 +38,7 @@ Functions and macros for modules that implement new object types.
object with room for n items. In addition to the refcount and type pointer
fields, this also fills in the ob_size field.
- PyObject_Del(op) releases the memory allocated for an object. It does not
- PyObject_Free(op) releases the memory allocated for an object. It does not
run a destructor -- it only frees the memory. PyObject_Free is identical.
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't
@ -102,7 +102,9 @@ PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyObject_Free(void *ptr);
/* Macros */
// Deprecated aliases only kept for backward compatibility.
// PyObject_Del and PyObject_DEL are defined with no parameter to be able to
// use them as function pointers (ex: tp_free = PyObject_Del).
#define PyObject_MALLOC PyObject_Malloc
#define PyObject_REALLOC PyObject_Realloc
#define PyObject_FREE PyObject_Free
@ -138,8 +140,8 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
#define PyObject_NewVar(type, typeobj, n) \
( (type *) _PyObject_NewVar((typeobj), (n)) )
// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
// PyObject_MALLOC() with _PyObject_VAR_SIZE().
// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)

View File

@ -53,18 +53,6 @@ PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
PyAPI_FUNC(void) PyMem_Free(void *ptr);
/* Macros. */
/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL
for malloc(0), which would be treated as an error. Some platforms
would return a pointer with no memory behind it, which would break
pymalloc. To solve these problems, allocate an extra byte. */
/* Returns NULL to indicate error if a negative size or size larger than
Py_ssize_t can represent is supplied. Helps prevents security holes. */
#define PyMem_MALLOC(n) PyMem_Malloc(n)
#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
#define PyMem_FREE(p) PyMem_Free(p)
/*
* Type-oriented memory interface
* ==============================
@ -78,9 +66,6 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_New(type, n) \
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
#define PyMem_NEW(type, n) \
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
( (type *) PyMem_MALLOC((n) * sizeof(type)) ) )
/*
* The value of (p) is always clobbered by this macro regardless of success.
@ -91,15 +76,18 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
#define PyMem_Resize(p, type, n) \
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
#define PyMem_RESIZE(p, type, n) \
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
(type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
* anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
*/
#define PyMem_Del PyMem_Free
#define PyMem_DEL PyMem_FREE
// Deprecated aliases only kept for backward compatibility.
// PyMem_Del and PyMem_DEL are defined with no parameter to be able to use
// them as function pointers (ex: dealloc = PyMem_Del).
#define PyMem_MALLOC(n) PyMem_Malloc(n)
#define PyMem_NEW(type, n) PyMem_New(type, n)
#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n)
#define PyMem_RESIZE(p, type, n) PyMem_Resize(p, type, n)
#define PyMem_FREE(p) PyMem_Free(p)
#define PyMem_Del PyMem_Free
#define PyMem_DEL PyMem_Free
#ifndef Py_LIMITED_API

View File

@ -1024,6 +1024,25 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(next(it), (1, 2))
self.assertRaises(RuntimeError, next, it)
def test_pairwise(self):
self.assertEqual(list(pairwise('')), [])
self.assertEqual(list(pairwise('a')), [])
self.assertEqual(list(pairwise('ab')),
[('a', 'b')]),
self.assertEqual(list(pairwise('abcde')),
[('a', 'b'), ('b', 'c'), ('c', 'd'), ('d', 'e')])
self.assertEqual(list(pairwise(range(10_000))),
list(zip(range(10_000), range(1, 10_000))))
with self.assertRaises(TypeError):
pairwise() # too few arguments
with self.assertRaises(TypeError):
pairwise('abc', 10) # too many arguments
with self.assertRaises(TypeError):
pairwise(iterable='abc') # keyword arguments
with self.assertRaises(TypeError):
pairwise(None) # non-iterable argument
def test_product(self):
for args, result in [
([], [()]), # zero iterables
@ -1787,6 +1806,10 @@ class TestGC(unittest.TestCase):
a = []
self.makecycle(islice([a]*2, None), a)
def test_pairwise(self):
a = []
self.makecycle(pairwise([a]*5), a)
def test_permutations(self):
a = []
self.makecycle(permutations([1,2,a,3], 3), a)
@ -1995,6 +2018,17 @@ class TestVariousIteratorArgs(unittest.TestCase):
self.assertRaises(TypeError, islice, N(s), 10)
self.assertRaises(ZeroDivisionError, list, islice(E(s), 10))
def test_pairwise(self):
for s in ("123", "", range(1000), ('do', 1.2), range(2000,2200,5)):
for g in (G, I, Ig, S, L, R):
seq = list(g(s))
expected = list(zip(seq, seq[1:]))
actual = list(pairwise(g(s)))
self.assertEqual(actual, expected)
self.assertRaises(TypeError, pairwise, X(s))
self.assertRaises(TypeError, pairwise, N(s))
self.assertRaises(ZeroDivisionError, list, pairwise(E(s)))
def test_starmap(self):
for s in (range(10), range(0), range(100), (7,11), range(20,50,5)):
for g in (G, I, Ig, S, L, R):
@ -2312,15 +2346,6 @@ Samuele
... else:
... return starmap(func, repeat(args, times))
>>> def pairwise(iterable):
... "s -> (s0,s1), (s1,s2), (s2, s3), ..."
... a, b = tee(iterable)
... try:
... next(b)
... except StopIteration:
... pass
... return zip(a, b)
>>> def grouper(n, iterable, fillvalue=None):
... "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
... args = [iter(iterable)] * n
@ -2451,15 +2476,6 @@ True
>>> take(5, map(int, repeatfunc(random.random)))
[0, 0, 0, 0, 0]
>>> list(pairwise('abcd'))
[('a', 'b'), ('b', 'c'), ('c', 'd')]
>>> list(pairwise([]))
[]
>>> list(pairwise('a'))
[]
>>> list(islice(pad_none('abc'), 0, 6))
['a', 'b', 'c', None, None, None]

View File

@ -642,12 +642,17 @@ class PosixTester(unittest.TestCase):
@unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
def test_mkfifo(self):
os_helper.unlink(os_helper.TESTFN)
if sys.platform == "vxworks":
fifo_path = os.path.join("/fifos/", os_helper.TESTFN)
else:
fifo_path = os_helper.TESTFN
os_helper.unlink(fifo_path)
self.addCleanup(os_helper.unlink, fifo_path)
try:
posix.mkfifo(os_helper.TESTFN, stat.S_IRUSR | stat.S_IWUSR)
posix.mkfifo(fifo_path, stat.S_IRUSR | stat.S_IWUSR)
except PermissionError as e:
self.skipTest('posix.mkfifo(): %s' % e)
self.assertTrue(stat.S_ISFIFO(posix.stat(os_helper.TESTFN).st_mode))
self.assertTrue(stat.S_ISFIFO(posix.stat(fifo_path).st_mode))
@unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'),
"don't have mknod()/S_IFIFO")

View File

@ -2,6 +2,7 @@ import unittest
import os
import socket
import sys
from test.support import os_helper
from test.support import socket_helper
from test.support.import_helper import import_fresh_module
from test.support.os_helper import TESTFN
@ -173,11 +174,16 @@ class TestFilemode:
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'os.mkfifo not available')
def test_fifo(self):
if sys.platform == "vxworks":
fifo_path = os.path.join("/fifos/", TESTFN)
else:
fifo_path = TESTFN
self.addCleanup(os_helper.unlink, fifo_path)
try:
os.mkfifo(TESTFN, 0o700)
os.mkfifo(fifo_path, 0o700)
except PermissionError as e:
self.skipTest('os.mkfifo(): %s' % e)
st_mode, modestr = self.get_mode()
st_mode, modestr = self.get_mode(fifo_path)
self.assertEqual(modestr, 'prwx------')
self.assertS_IS("FIFO", st_mode)

View File

@ -0,0 +1 @@
Added itertools.pairwise()

View File

@ -0,0 +1 @@
Fix fifo test cases for VxWorks RTOS.

View File

@ -393,7 +393,7 @@ py_blake2b_dealloc(PyObject *self)
}
PyTypeObject *type = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(type);
}

View File

@ -392,7 +392,7 @@ py_blake2s_dealloc(PyObject *self)
}
PyTypeObject *type = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(type);
}

View File

@ -475,7 +475,7 @@ static void
PyCArg_dealloc(PyCArgObject *self)
{
Py_XDECREF(self->obj);
PyObject_Del(self);
PyObject_Free(self);
}
static int

View File

@ -282,7 +282,7 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po)
Py_DECREF(po->wo);
remove_lop(po);
}
PyObject_DEL(po);
PyObject_Free(po);
Py_DECREF(tp);
}

View File

@ -689,7 +689,7 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
if (wo->win != stdscr) delwin(wo->win);
if (wo->encoding != NULL)
PyMem_Free(wo->encoding);
PyObject_DEL(wo);
PyObject_Free(wo);
}
/* Addch, Addstr, Addnstr */

View File

@ -1765,7 +1765,7 @@ ctxmanager_dealloc(PyDecContextManagerObject *self)
{
Py_XDECREF(self->local);
Py_XDECREF(self->global);
PyObject_Del(self);
PyObject_Free(self);
}
static PyObject *

View File

@ -478,7 +478,7 @@ keyobject_dealloc(keyobject *ko)
{
Py_DECREF(ko->cmp);
Py_XDECREF(ko->object);
PyObject_FREE(ko);
PyObject_Free(ko);
}
static int
@ -742,7 +742,7 @@ lru_list_elem_dealloc(lru_list_elem *link)
{
Py_XDECREF(link->key);
Py_XDECREF(link->result);
PyObject_Del(link);
PyObject_Free(link);
}
static PyTypeObject lru_list_elem_type = {

View File

@ -341,7 +341,7 @@ EVP_dealloc(EVPobject *self)
if (self->lock != NULL)
PyThread_free_lock(self->lock);
EVP_MD_CTX_free(self->ctx);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -1453,7 +1453,7 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
error:
if (ctx) HMAC_CTX_free(ctx);
if (self) PyObject_Del(self);
if (self) PyObject_Free(self);
return NULL;
}
@ -1546,7 +1546,7 @@ _hmac_dealloc(HMACobject *self)
PyThread_free_lock(self->lock);
}
HMAC_CTX_free(self->ctx);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}

View File

@ -370,8 +370,8 @@ _locale_strcoll_impl(PyObject *module, PyObject *os1, PyObject *os2)
result = PyLong_FromLong(wcscoll(ws1, ws2));
done:
/* Deallocate everything. */
if (ws1) PyMem_FREE(ws1);
if (ws2) PyMem_FREE(ws2);
if (ws1) PyMem_Free(ws1);
if (ws2) PyMem_Free(ws2);
return result;
}
#endif

View File

@ -571,7 +571,7 @@ semlock_dealloc(SemLockObject* self)
if (self->handle != SEM_FAILED)
SEM_CLOSE(self->handle);
PyMem_Free(self->name);
PyObject_Del(self);
PyObject_Free(self);
}
/*[clinic input]

View File

@ -442,8 +442,8 @@ Pdata_dealloc(Pdata *self)
while (--i >= 0) {
Py_DECREF(self->data[i]);
}
PyMem_FREE(self->data);
PyObject_Del(self);
PyMem_Free(self->data);
PyObject_Free(self);
}
static PyTypeObject Pdata_Type = {
@ -465,7 +465,7 @@ Pdata_New(void)
self->mark_set = 0;
self->fence = 0;
self->allocated = 8;
self->data = PyMem_MALLOC(self->allocated * sizeof(PyObject *));
self->data = PyMem_Malloc(self->allocated * sizeof(PyObject *));
if (self->data)
return (PyObject *)self;
Py_DECREF(self);
@ -726,7 +726,7 @@ static PyTypeObject Unpickler_Type;
static PyMemoTable *
PyMemoTable_New(void)
{
PyMemoTable *memo = PyMem_MALLOC(sizeof(PyMemoTable));
PyMemoTable *memo = PyMem_Malloc(sizeof(PyMemoTable));
if (memo == NULL) {
PyErr_NoMemory();
return NULL;
@ -735,9 +735,9 @@ PyMemoTable_New(void)
memo->mt_used = 0;
memo->mt_allocated = MT_MINSIZE;
memo->mt_mask = MT_MINSIZE - 1;
memo->mt_table = PyMem_MALLOC(MT_MINSIZE * sizeof(PyMemoEntry));
memo->mt_table = PyMem_Malloc(MT_MINSIZE * sizeof(PyMemoEntry));
if (memo->mt_table == NULL) {
PyMem_FREE(memo);
PyMem_Free(memo);
PyErr_NoMemory();
return NULL;
}
@ -758,10 +758,10 @@ PyMemoTable_Copy(PyMemoTable *self)
new->mt_mask = self->mt_mask;
/* The table we get from _New() is probably smaller than we wanted.
Free it and allocate one that's the right size. */
PyMem_FREE(new->mt_table);
PyMem_Free(new->mt_table);
new->mt_table = PyMem_NEW(PyMemoEntry, self->mt_allocated);
if (new->mt_table == NULL) {
PyMem_FREE(new);
PyMem_Free(new);
PyErr_NoMemory();
return NULL;
}
@ -800,8 +800,8 @@ PyMemoTable_Del(PyMemoTable *self)
return;
PyMemoTable_Clear(self);
PyMem_FREE(self->mt_table);
PyMem_FREE(self);
PyMem_Free(self->mt_table);
PyMem_Free(self);
}
/* Since entries cannot be deleted from this hashtable, _PyMemoTable_Lookup()
@ -880,7 +880,7 @@ _PyMemoTable_ResizeTable(PyMemoTable *self, size_t min_size)
}
/* Deallocate the old table. */
PyMem_FREE(oldtable);
PyMem_Free(oldtable);
return 0;
}
@ -1582,7 +1582,7 @@ _Unpickler_MemoCleanup(UnpicklerObject *self)
while (--i >= 0) {
Py_XDECREF(memo[i]);
}
PyMem_FREE(memo);
PyMem_Free(memo);
}
static UnpicklerObject *
@ -7544,7 +7544,7 @@ Unpickler_set_memo(UnpicklerObject *self, PyObject *obj, void *Py_UNUSED(ignored
for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
Py_XDECREF(new_memo[i]);
}
PyMem_FREE(new_memo);
PyMem_Free(new_memo);
}
return -1;
}

View File

@ -274,7 +274,7 @@ SHA3_dealloc(SHA3object *self)
}
PyTypeObject *tp = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}

View File

@ -197,7 +197,7 @@ static void
data_stack_dealloc(SRE_STATE* state)
{
if (state->data_stack) {
PyMem_FREE(state->data_stack);
PyMem_Free(state->data_stack);
state->data_stack = NULL;
}
state->data_stack_size = state->data_stack_base = 0;
@ -213,7 +213,7 @@ data_stack_grow(SRE_STATE* state, Py_ssize_t size)
void* stack;
cursize = minsize+minsize/4+1024;
TRACE(("allocate/grow stack %zd\n", cursize));
stack = PyMem_REALLOC(state->data_stack, cursize);
stack = PyMem_Realloc(state->data_stack, cursize);
if (!stack) {
data_stack_dealloc(state);
return SRE_ERROR_MEMORY;
@ -472,7 +472,7 @@ state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string,
/* We add an explicit cast here because MSVC has a bug when
compiling C code where it believes that `const void**` cannot be
safely casted to `void*`, see bpo-39943 for details. */
PyMem_Del((void*) state->mark);
PyMem_Free((void*) state->mark);
state->mark = NULL;
if (state->buffer.buf)
PyBuffer_Release(&state->buffer);
@ -487,7 +487,7 @@ state_fini(SRE_STATE* state)
Py_XDECREF(state->string);
data_stack_dealloc(state);
/* See above PyMem_Del for why we explicitly cast here. */
PyMem_Del((void*) state->mark);
PyMem_Free((void*) state->mark);
state->mark = NULL;
}
@ -571,7 +571,7 @@ pattern_dealloc(PatternObject* self)
Py_XDECREF(self->pattern);
Py_XDECREF(self->groupindex);
Py_XDECREF(self->indexgroup);
PyObject_DEL(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -1944,7 +1944,7 @@ match_dealloc(MatchObject* self)
Py_XDECREF(self->regs);
Py_XDECREF(self->string);
Py_DECREF(self->pattern);
PyObject_DEL(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -2450,7 +2450,7 @@ scanner_dealloc(ScannerObject* self)
state_fini(&self->state);
Py_XDECREF(self->pattern);
PyObject_DEL(self);
PyObject_Free(self);
Py_DECREF(tp);
}

View File

@ -2295,7 +2295,7 @@ PySSL_dealloc(PySSLSocket *self)
Py_XDECREF(self->ctx);
Py_XDECREF(self->server_hostname);
Py_XDECREF(self->owner);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -3306,10 +3306,10 @@ context_dealloc(PySSLContext *self)
context_clear(self);
SSL_CTX_free(self->ctx);
#if HAVE_NPN
PyMem_FREE(self->npn_protocols);
PyMem_Free(self->npn_protocols);
#endif
#if HAVE_ALPN
PyMem_FREE(self->alpn_protocols);
PyMem_Free(self->alpn_protocols);
#endif
Py_TYPE(self)->tp_free(self);
Py_DECREF(tp);
@ -3510,7 +3510,7 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
return NULL;
}
PyMem_FREE(self->alpn_protocols);
PyMem_Free(self->alpn_protocols);
self->alpn_protocols = PyMem_Malloc(protos->len);
if (!self->alpn_protocols)
return PyErr_NoMemory();

View File

@ -1373,14 +1373,14 @@ prepare_s(PyStructObject *self)
self->s_size = size;
self->s_len = len;
codes = PyMem_MALLOC((ncodes + 1) * sizeof(formatcode));
codes = PyMem_Malloc((ncodes + 1) * sizeof(formatcode));
if (codes == NULL) {
PyErr_NoMemory();
return -1;
}
/* Free any s_codes value left over from a previous initialization. */
if (self->s_codes != NULL)
PyMem_FREE(self->s_codes);
PyMem_Free(self->s_codes);
self->s_codes = codes;
s = fmt;
@ -1502,7 +1502,7 @@ s_dealloc(PyStructObject *s)
if (s->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *)s);
if (s->s_codes != NULL) {
PyMem_FREE(s->s_codes);
PyMem_Free(s->s_codes);
}
Py_XDECREF(s->s_format);
freefunc free_func = PyType_GetSlot(Py_TYPE(s), Py_tp_free);

View File

@ -236,7 +236,7 @@ ndarray_dealloc(NDArrayObject *self)
ndbuf_pop(self);
}
}
PyObject_Del(self);
PyObject_Free(self);
}
static int
@ -2734,7 +2734,7 @@ staticarray_init(PyObject *self, PyObject *args, PyObject *kwds)
static void
staticarray_dealloc(StaticArrayObject *self)
{
PyObject_Del(self);
PyObject_Free(self);
}
/* Return a buffer for a PyBUF_FULL_RO request. Flags are not checked,

View File

@ -1988,12 +1988,12 @@ unicode_asucs4(PyObject *self, PyObject *args)
buffer[str_len] = 0xffffU;
if (!PyUnicode_AsUCS4(unicode, buffer, buf_len, copy_null)) {
PyMem_FREE(buffer);
PyMem_Free(buffer);
return NULL;
}
result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
PyMem_FREE(buffer);
PyMem_Free(buffer);
return result;
}
@ -6010,7 +6010,7 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
static void
test_structmembers_free(PyObject *ob)
{
PyObject_FREE(ob);
PyObject_Free(ob);
}
static PyTypeObject test_structmembersType = {
@ -6664,7 +6664,7 @@ static void
heapctype_dealloc(HeapCTypeObject *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -6854,7 +6854,7 @@ heapctypewithdict_dealloc(HeapCTypeWithDictObject* self)
PyTypeObject *tp = Py_TYPE(self);
Py_XDECREF(self->dict);
PyObject_DEL(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -6925,7 +6925,7 @@ heapctypewithweakref_dealloc(HeapCTypeWithWeakrefObject* self)
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Py_XDECREF(self->weakreflist);
PyObject_DEL(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -6968,7 +6968,7 @@ static void
heapctypesetattr_dealloc(HeapCTypeSetattrObject *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}

View File

@ -34,7 +34,7 @@ lock_dealloc(lockobject *self)
PyThread_release_lock(self->lock_lock);
PyThread_free_lock(self->lock_lock);
}
PyObject_Del(self);
PyObject_Free(self);
}
/* Helper to acquire an interruptible lock with a timeout. If the lock acquire
@ -1056,7 +1056,7 @@ t_bootstrap(void *boot_raw)
Py_DECREF(boot->func);
Py_DECREF(boot->args);
Py_XDECREF(boot->keyw);
PyMem_DEL(boot_raw);
PyMem_Free(boot_raw);
tstate->interp->num_threads--;
PyThreadState_Clear(tstate);
_PyThreadState_DeleteCurrent(tstate);
@ -1107,7 +1107,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
boot->tstate = _PyThreadState_Prealloc(boot->interp);
boot->runtime = runtime;
if (boot->tstate == NULL) {
PyMem_DEL(boot);
PyMem_Free(boot);
return PyErr_NoMemory();
}
Py_INCREF(func);
@ -1121,7 +1121,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
Py_DECREF(args);
Py_XDECREF(keyw);
PyThreadState_Clear(boot->tstate);
PyMem_DEL(boot);
PyMem_Free(boot);
return NULL;
}
return PyLong_FromUnsignedLong(ident);

View File

@ -904,7 +904,7 @@ PyTclObject_dealloc(PyTclObject *self)
PyObject *tp = (PyObject *) Py_TYPE(self);
Tcl_DecrRefCount(self->value);
Py_XDECREF(self->string);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -2472,7 +2472,7 @@ PythonCmdDelete(ClientData clientData)
ENTER_PYTHON
Py_XDECREF(data->self);
Py_XDECREF(data->func);
PyMem_DEL(data);
PyMem_Free(data);
LEAVE_PYTHON
}
@ -2545,7 +2545,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
if (ev == NULL) {
PyErr_NoMemory();
PyMem_DEL(data);
PyMem_Free(data);
return NULL;
}
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
@ -2568,7 +2568,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
}
if (err) {
PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
PyMem_DEL(data);
PyMem_Free(data);
return NULL;
}
@ -2666,7 +2666,7 @@ DeleteFHCD(int id)
*pp = p->next;
Py_XDECREF(p->func);
Py_XDECREF(p->file);
PyMem_DEL(p);
PyMem_Free(p);
}
else
pp = &p->next;
@ -2823,7 +2823,7 @@ Tktt_Dealloc(PyObject *self)
Py_XDECREF(func);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}
@ -3096,7 +3096,7 @@ Tkapp_Dealloc(PyObject *self)
ENTER_TCL
Tcl_DeleteInterp(Tkapp_Interp(self));
LEAVE_TCL
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
DisableEventHook();
}

View File

@ -133,7 +133,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
}
if (newsize == 0) {
PyMem_FREE(self->ob_item);
PyMem_Free(self->ob_item);
self->ob_item = NULL;
Py_SET_SIZE(self, 0);
self->allocated = 0;
@ -652,7 +652,7 @@ array_dealloc(arrayobject *op)
if (op->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) op);
if (op->ob_item != NULL)
PyMem_DEL(op->ob_item);
PyMem_Free(op->ob_item);
Py_TYPE(op)->tp_free((PyObject *)op);
}

View File

@ -691,7 +691,7 @@ static struct PyMethodDef multibytecodec_methods[] = {
static void
multibytecodec_dealloc(MultibyteCodecObject *self)
{
PyObject_Del(self);
PyObject_Free(self);
}
static PyTypeObject MultibyteCodec_Type = {
@ -1191,13 +1191,13 @@ _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDeco
goto errorexit;
if (wdata != data)
PyMem_Del(wdata);
PyMem_Free(wdata);
Py_XDECREF(buf.excobj);
return res;
errorexit:
if (wdata != NULL && wdata != data)
PyMem_Del(wdata);
PyMem_Free(wdata);
Py_XDECREF(buf.excobj);
_PyUnicodeWriter_Dealloc(&buf.writer);
return NULL;

View File

@ -2,6 +2,37 @@
preserve
[clinic start generated code]*/
PyDoc_STRVAR(pairwise_new__doc__,
"pairwise(iterable, /)\n"
"--\n"
"\n"
"Return an iterator of overlapping pairs taken from the input iterator.\n"
"\n"
" s -> (s0,s1), (s1,s2), (s2, s3), ...");
static PyObject *
pairwise_new_impl(PyTypeObject *type, PyObject *iterable);
static PyObject *
pairwise_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
PyObject *return_value = NULL;
PyObject *iterable;
if ((type == &pairwise_type) &&
!_PyArg_NoKeywords("pairwise", kwargs)) {
goto exit;
}
if (!_PyArg_CheckPositional("pairwise", PyTuple_GET_SIZE(args), 1, 1)) {
goto exit;
}
iterable = PyTuple_GET_ITEM(args, 0);
return_value = pairwise_new_impl(type, iterable);
exit:
return return_value;
}
PyDoc_STRVAR(itertools_groupby__doc__,
"groupby(iterable, key=None)\n"
"--\n"
@ -627,4 +658,4 @@ skip_optional_pos:
exit:
return return_value;
}
/*[clinic end generated code: output=d7f58dc477814b45 input=a9049054013a1b77]*/
/*[clinic end generated code: output=889c4afc3b13574f input=a9049054013a1b77]*/

View File

@ -2290,7 +2290,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
}
PyGC_Head *g = AS_GC(op);
g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
g = (PyGC_Head *)PyObject_Realloc(g, sizeof(PyGC_Head) + basicsize);
if (g == NULL)
return (PyVarObject *)PyErr_NoMemory();
op = (PyVarObject *) FROM_GC(g);
@ -2309,7 +2309,7 @@ PyObject_GC_Del(void *op)
if (gcstate->generations[0].count > 0) {
gcstate->generations[0].count--;
}
PyObject_FREE(g);
PyObject_Free(g);
}
int

View File

@ -1,4 +1,5 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#include "pycore_long.h" // _PyLong_GetZero()
@ -27,8 +28,9 @@ class itertools.accumulate "accumulateobject *" "&accumulate_type"
class itertools.compress "compressobject *" "&compress_type"
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
class itertools.count "countobject *" "&count_type"
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ea05c93c6d94726a]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=6498ed21fbe1bf94]*/
static PyTypeObject groupby_type;
static PyTypeObject _grouper_type;
@ -45,9 +47,140 @@ static PyTypeObject accumulate_type;
static PyTypeObject compress_type;
static PyTypeObject filterfalse_type;
static PyTypeObject count_type;
static PyTypeObject pairwise_type;
#include "clinic/itertoolsmodule.c.h"
/* pairwise object ***********************************************************/
typedef struct {
PyObject_HEAD
PyObject *it;
PyObject *old;
} pairwiseobject;
/*[clinic input]
@classmethod
itertools.pairwise.__new__ as pairwise_new
iterable: object
/
Return an iterator of overlapping pairs taken from the input iterator.
s -> (s0,s1), (s1,s2), (s2, s3), ...
[clinic start generated code]*/
static PyObject *
pairwise_new_impl(PyTypeObject *type, PyObject *iterable)
/*[clinic end generated code: output=9f0267062d384456 input=6e7c3cddb431a8d6]*/
{
PyObject *it;
pairwiseobject *po;
it = PyObject_GetIter(iterable);
if (it == NULL) {
return NULL;
}
po = (pairwiseobject *)type->tp_alloc(type, 0);
if (po == NULL) {
Py_DECREF(it);
return NULL;
}
po->it = it;
po->old = NULL;
return (PyObject *)po;
}
static void
pairwise_dealloc(pairwiseobject *po)
{
PyObject_GC_UnTrack(po);
Py_XDECREF(po->it);
Py_XDECREF(po->old);
Py_TYPE(po)->tp_free(po);
}
static int
pairwise_traverse(pairwiseobject *po, visitproc visit, void *arg)
{
Py_VISIT(po->it);
Py_VISIT(po->old);
return 0;
}
static PyObject *
pairwise_next(pairwiseobject *po)
{
PyObject *it = po->it;
PyObject *old = po->old;
PyObject *new, *result;
if (it == NULL) {
return NULL;
}
if (old == NULL) {
po->old = old = (*Py_TYPE(it)->tp_iternext)(it);
if (old == NULL) {
Py_CLEAR(po->it);
return NULL;
}
}
new = (*Py_TYPE(it)->tp_iternext)(it);
if (new == NULL) {
Py_CLEAR(po->it);
Py_CLEAR(po->old);
return NULL;
}
/* Future optimization: Reuse the result tuple as we do in enumerate() */
result = PyTuple_Pack(2, old, new);
Py_SETREF(po->old, new);
return result;
}
static PyTypeObject pairwise_type = {
PyVarObject_HEAD_INIT(&PyType_Type, 0)
"itertools.pairwise", /* tp_name */
sizeof(pairwiseobject), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)pairwise_dealloc, /* tp_dealloc */
0, /* tp_vectorcall_offset */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_as_async */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
pairwise_new__doc__, /* tp_doc */
(traverseproc)pairwise_traverse, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
PyObject_SelfIter, /* tp_iter */
(iternextfunc)pairwise_next, /* tp_iternext */
0, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
PyType_GenericAlloc, /* tp_alloc */
pairwise_new, /* tp_new */
PyObject_GC_Del, /* tp_free */
};
/* groupby object ************************************************************/
@ -4666,6 +4799,7 @@ groupby(iterable[, keyfunc]) --> sub-iterators grouped by value of keyfunc(v)\n\
filterfalse(pred, seq) --> elements of seq where pred(elem) is False\n\
islice(seq, [start,] stop [, step]) --> elements from\n\
seq[start:stop:step]\n\
pairwise(s) --> (s[0],s[1]), (s[1],s[2]), (s[2], s[3]), ...\n\
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\
tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\n\
takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\
@ -4695,6 +4829,7 @@ itertoolsmodule_exec(PyObject *m)
&filterfalse_type,
&count_type,
&ziplongest_type,
&pairwise_type,
&permutations_type,
&product_type,
&repeat_type,

View File

@ -342,7 +342,7 @@ static void
MD5_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
PyObject_Del(ptr);
PyObject_Free(ptr);
Py_DECREF(tp);
}

View File

@ -154,7 +154,7 @@ oss_dealloc(oss_audio_t *self)
/* if already closed, don't reclose it */
if (self->fd != -1)
close(self->fd);
PyObject_Del(self);
PyObject_Free(self);
}
@ -199,7 +199,7 @@ oss_mixer_dealloc(oss_mixer_t *self)
/* if already closed, don't reclose it */
if (self->fd != -1)
close(self->fd);
PyObject_Del(self);
PyObject_Free(self);
}

View File

@ -722,7 +722,7 @@ Overlapped_dealloc(OverlappedObject *self)
SetLastError(olderr);
PyTypeObject *tp = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}

View File

@ -5480,7 +5480,7 @@ free_string_array(EXECV_CHAR **array, Py_ssize_t count)
Py_ssize_t i;
for (i = 0; i < count; i++)
PyMem_Free(array[i]);
PyMem_DEL(array);
PyMem_Free(array);
}
static int
@ -6510,9 +6510,10 @@ os_spawnve_impl(PyObject *module, int mode, path_t *path, PyObject *argv,
res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval);
fail_2:
while (--envc >= 0)
PyMem_DEL(envlist[envc]);
PyMem_DEL(envlist);
while (--envc >= 0) {
PyMem_Free(envlist[envc]);
}
PyMem_Free(envlist);
fail_1:
free_string_array(argvlist, lastarg);
fail_0:
@ -7444,7 +7445,7 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
list = PyList_New(ngroups);
if (list == NULL) {
PyMem_Del(groups);
PyMem_Free(groups);
return NULL;
}
@ -7456,13 +7457,13 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
#endif
if (o == NULL) {
Py_DECREF(list);
PyMem_Del(groups);
PyMem_Free(groups);
return NULL;
}
PyList_SET_ITEM(list, i, o);
}
PyMem_Del(groups);
PyMem_Free(groups);
return list;
}
@ -9407,7 +9408,7 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
*buf = PyMem_New(Py_buffer, cnt);
if (*buf == NULL) {
PyMem_Del(*iov);
PyMem_Free(*iov);
PyErr_NoMemory();
return -1;
}
@ -9427,11 +9428,11 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
return 0;
fail:
PyMem_Del(*iov);
PyMem_Free(*iov);
for (j = 0; j < i; j++) {
PyBuffer_Release(&(*buf)[j]);
}
PyMem_Del(*buf);
PyMem_Free(*buf);
return -1;
}
@ -9439,11 +9440,11 @@ static void
iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
{
int i;
PyMem_Del(iov);
PyMem_Free(iov);
for (i = 0; i < cnt; i++) {
PyBuffer_Release(&buf[i]);
}
PyMem_Del(buf);
PyMem_Free(buf);
}
#endif
@ -12815,7 +12816,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
path_error(path);
break;
}
buffer = PyMem_MALLOC(buffer_size);
buffer = PyMem_Malloc(buffer_size);
if (!buffer) {
PyErr_NoMemory();
break;
@ -12832,7 +12833,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
if (length < 0) {
if (errno == ERANGE) {
PyMem_FREE(buffer);
PyMem_Free(buffer);
buffer = NULL;
continue;
}
@ -12870,7 +12871,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
}
exit:
if (buffer)
PyMem_FREE(buffer);
PyMem_Free(buffer);
return result;
}
#endif /* USE_XATTRS */

View File

@ -294,9 +294,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
if (rfd2obj) PyMem_DEL(rfd2obj);
if (wfd2obj) PyMem_DEL(wfd2obj);
if (efd2obj) PyMem_DEL(efd2obj);
if (rfd2obj) PyMem_Free(rfd2obj);
if (wfd2obj) PyMem_Free(wfd2obj);
if (efd2obj) PyMem_Free(efd2obj);
return PyErr_NoMemory();
}
#endif /* SELECT_USES_HEAP */
@ -381,9 +381,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
reap_obj(wfd2obj);
reap_obj(efd2obj);
#ifdef SELECT_USES_HEAP
PyMem_DEL(rfd2obj);
PyMem_DEL(wfd2obj);
PyMem_DEL(efd2obj);
PyMem_Free(rfd2obj);
PyMem_Free(wfd2obj);
PyMem_Free(efd2obj);
#endif /* SELECT_USES_HEAP */
return ret;
}
@ -740,9 +740,9 @@ poll_dealloc(pollObject *self)
{
PyObject* type = (PyObject *)Py_TYPE(self);
if (self->ufds != NULL)
PyMem_DEL(self->ufds);
PyMem_Free(self->ufds);
Py_XDECREF(self->dict);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(type);
}
@ -1106,7 +1106,7 @@ newDevPollObject(PyObject *module)
self = PyObject_New(devpollObject, get_select_state(module)->devpoll_Type);
if (self == NULL) {
close(fd_devpoll);
PyMem_DEL(fds);
PyMem_Free(fds);
return NULL;
}
self->fd_devpoll = fd_devpoll;
@ -1129,8 +1129,8 @@ devpoll_dealloc(devpollObject *self)
{
PyObject *type = (PyObject *)Py_TYPE(self);
(void)devpoll_internal_close(self);
PyMem_DEL(self->fds);
PyObject_Del(self);
PyMem_Free(self->fds);
PyObject_Free(self);
Py_DECREF(type);
}

View File

@ -320,7 +320,7 @@ static void
SHA1_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
PyObject_Del(ptr);
PyObject_Free(ptr);
Py_DECREF(tp);
}

View File

@ -397,7 +397,7 @@ static void
SHA_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
PyObject_Del(ptr);
PyObject_Free(ptr);
Py_DECREF(tp);
}

View File

@ -453,7 +453,7 @@ static void
SHA512_dealloc(PyObject *ptr)
{
PyTypeObject *tp = Py_TYPE(ptr);
PyObject_Del(ptr);
PyObject_Free(ptr);
Py_DECREF(tp);
}

View File

@ -986,7 +986,7 @@ entrance:
ctx->pattern[1], ctx->pattern[2]));
/* install new repeat context */
ctx->u.rep = (SRE_REPEAT*) PyObject_MALLOC(sizeof(*ctx->u.rep));
ctx->u.rep = (SRE_REPEAT*) PyObject_Malloc(sizeof(*ctx->u.rep));
if (!ctx->u.rep) {
PyErr_NoMemory();
RETURN_FAILURE;
@ -1000,7 +1000,7 @@ entrance:
state->ptr = ctx->ptr;
DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]);
state->repeat = ctx->u.rep->prev;
PyObject_FREE(ctx->u.rep);
PyObject_Free(ctx->u.rep);
if (ret) {
RETURN_ON_ERROR(ret);

View File

@ -1418,7 +1418,7 @@ static void
ucd_dealloc(PreviousDBVersion *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(tp);
}

View File

@ -44,7 +44,7 @@ static void
Xxo_dealloc(XxoObject *self)
{
Py_XDECREF(self->x_attr);
PyObject_Del(self);
PyObject_Free(self);
}
static PyObject *

View File

@ -591,7 +591,7 @@ Dealloc(compobject *self)
Py_XDECREF(self->unused_data);
Py_XDECREF(self->unconsumed_tail);
Py_XDECREF(self->zdict);
PyObject_Del(self);
PyObject_Free(self);
Py_DECREF(type);
}

View File

@ -198,7 +198,7 @@ PyBytes_FromString(const char *str)
}
/* Inline PyObject_NewVar */
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size);
op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size);
if (op == NULL) {
return PyErr_NoMemory();
}
@ -1475,7 +1475,7 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n)
"repeated bytes are too long");
return NULL;
}
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + nbytes);
op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + nbytes);
if (op == NULL) {
return PyErr_NoMemory();
}
@ -3054,9 +3054,9 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
_Py_ForgetReference(v);
#endif
*pv = (PyObject *)
PyObject_REALLOC(v, PyBytesObject_SIZE + newsize);
PyObject_Realloc(v, PyBytesObject_SIZE + newsize);
if (*pv == NULL) {
PyObject_Del(v);
PyObject_Free(v);
PyErr_NoMemory();
return -1;
}

View File

@ -198,7 +198,7 @@ PyCapsule_Import(const char *name, int no_block)
void *return_value = NULL;
char *trace;
size_t name_length = (strlen(name) + 1) * sizeof(char);
char *name_dup = (char *)PyMem_MALLOC(name_length);
char *name_dup = (char *)PyMem_Malloc(name_length);
if (!name_dup) {
return PyErr_NoMemory();
@ -247,7 +247,7 @@ PyCapsule_Import(const char *name, int no_block)
EXIT:
Py_XDECREF(object);
if (name_dup) {
PyMem_FREE(name_dup);
PyMem_Free(name_dup);
}
return return_value;
}
@ -260,7 +260,7 @@ capsule_dealloc(PyObject *o)
if (capsule->destructor) {
capsule->destructor(o);
}
PyObject_DEL(o);
PyObject_Free(o);
}

View File

@ -213,7 +213,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
PyObject *arg = PyTuple_GET_ITEM(varnames, j);
int cmp = PyUnicode_Compare(cell, arg);
if (cmp == -1 && PyErr_Occurred()) {
PyMem_FREE(cell2arg);
PyMem_Free(cell2arg);
return NULL;
}
if (cmp == 0) {
@ -224,14 +224,14 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
}
}
if (!used_cell2arg) {
PyMem_FREE(cell2arg);
PyMem_Free(cell2arg);
cell2arg = NULL;
}
}
co = PyObject_New(PyCodeObject, &PyCode_Type);
if (co == NULL) {
if (cell2arg)
PyMem_FREE(cell2arg);
PyMem_Free(cell2arg);
return NULL;
}
co->co_argcount = argcount;
@ -314,12 +314,12 @@ _PyCode_InitOpcache(PyCodeObject *co)
if (opts) {
co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache));
if (co->co_opcache == NULL) {
PyMem_FREE(co->co_opcache_map);
PyMem_Free(co->co_opcache_map);
return -1;
}
}
else {
PyMem_FREE(co->co_opcache_map);
PyMem_Free(co->co_opcache_map);
co->co_opcache_map = NULL;
co->co_opcache = NULL;
}
@ -631,10 +631,10 @@ static void
code_dealloc(PyCodeObject *co)
{
if (co->co_opcache != NULL) {
PyMem_FREE(co->co_opcache);
PyMem_Free(co->co_opcache);
}
if (co->co_opcache_map != NULL) {
PyMem_FREE(co->co_opcache_map);
PyMem_Free(co->co_opcache_map);
}
co->co_opcache_flag = 0;
co->co_opcache_size = 0;
@ -664,12 +664,12 @@ code_dealloc(PyCodeObject *co)
Py_XDECREF(co->co_name);
Py_XDECREF(co->co_linetable);
if (co->co_cell2arg != NULL)
PyMem_FREE(co->co_cell2arg);
PyMem_Free(co->co_cell2arg);
if (co->co_zombieframe != NULL)
PyObject_GC_Del(co->co_zombieframe);
if (co->co_weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject*)co);
PyObject_DEL(co);
PyObject_Free(co);
}
static PyObject *

View File

@ -233,7 +233,7 @@ PyObject *
PyComplex_FromCComplex(Py_complex cval)
{
/* Inline PyObject_New */
PyComplexObject *op = PyObject_MALLOC(sizeof(PyComplexObject));
PyComplexObject *op = PyObject_Malloc(sizeof(PyComplexObject));
if (op == NULL) {
return PyErr_NoMemory();
}

View File

@ -269,7 +269,7 @@ _PyDict_ClearFreeList(PyThreadState *tstate)
PyObject_GC_Del(op);
}
while (state->keys_numfree) {
PyObject_FREE(state->keys_free_list[--state->keys_numfree]);
PyObject_Free(state->keys_free_list[--state->keys_numfree]);
}
}
@ -597,7 +597,7 @@ new_keys_object(Py_ssize_t size)
}
else
{
dk = PyObject_MALLOC(sizeof(PyDictKeysObject)
dk = PyObject_Malloc(sizeof(PyDictKeysObject)
+ es * size
+ sizeof(PyDictKeyEntry) * usable);
if (dk == NULL) {
@ -636,11 +636,11 @@ free_keys_object(PyDictKeysObject *keys)
state->keys_free_list[state->keys_numfree++] = keys;
return;
}
PyObject_FREE(keys);
PyObject_Free(keys);
}
#define new_values(size) PyMem_NEW(PyObject *, size)
#define free_values(values) PyMem_FREE(values)
#define free_values(values) PyMem_Free(values)
/* Consumes a reference to the keys object */
static PyObject *
@ -1303,7 +1303,7 @@ dictresize(PyDictObject *mp, Py_ssize_t newsize)
state->keys_free_list[state->keys_numfree++] = oldkeys;
}
else {
PyObject_FREE(oldkeys);
PyObject_Free(oldkeys);
}
}

View File

@ -237,7 +237,7 @@ float_dealloc(PyFloatObject *op)
assert(state->numfree != -1);
#endif
if (state->numfree >= PyFloat_MAXFREELIST) {
PyObject_FREE(op);
PyObject_Free(op);
return;
}
state->numfree++;
@ -2032,7 +2032,7 @@ _PyFloat_ClearFreeList(PyThreadState *tstate)
PyFloatObject *f = state->free_list;
while (f != NULL) {
PyFloatObject *next = (PyFloatObject*) Py_TYPE(f);
PyObject_FREE(f);
PyObject_Free(f);
f = next;
}
state->free_list = NULL;

View File

@ -341,7 +341,7 @@ list_dealloc(PyListObject *op)
while (--i >= 0) {
Py_XDECREF(op->ob_item[i]);
}
PyMem_FREE(op->ob_item);
PyMem_Free(op->ob_item);
}
struct _Py_list_state *state = get_list_state();
#ifdef Py_DEBUG
@ -592,7 +592,7 @@ _list_clear(PyListObject *a)
while (--i >= 0) {
Py_XDECREF(item[i]);
}
PyMem_FREE(item);
PyMem_Free(item);
}
/* Never fails; the return value can be ignored.
Note that there is no guarantee that the list is actually empty
@ -668,7 +668,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
/* If norig == 0, item might be NULL, in which case we may not memcpy from it. */
if (s) {
if (s > sizeof(recycle_on_stack)) {
recycle = (PyObject **)PyMem_MALLOC(s);
recycle = (PyObject **)PyMem_Malloc(s);
if (recycle == NULL) {
PyErr_NoMemory();
goto Error;
@ -706,7 +706,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
result = 0;
Error:
if (recycle != recycle_on_stack)
PyMem_FREE(recycle);
PyMem_Free(recycle);
Py_XDECREF(v_as_SF);
return result;
#undef b
@ -2230,7 +2230,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
/* Leverage stack space we allocated but won't otherwise use */
keys = &ms.temparray[saved_ob_size+1];
else {
keys = PyMem_MALLOC(sizeof(PyObject *) * saved_ob_size);
keys = PyMem_Malloc(sizeof(PyObject *) * saved_ob_size);
if (keys == NULL) {
PyErr_NoMemory();
goto keyfunc_fail;
@ -2243,7 +2243,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
for (i=i-1 ; i>=0 ; i--)
Py_DECREF(keys[i]);
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
PyMem_FREE(keys);
PyMem_Free(keys);
goto keyfunc_fail;
}
}
@ -2414,7 +2414,7 @@ fail:
for (i = 0; i < saved_ob_size; i++)
Py_DECREF(keys[i]);
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
PyMem_FREE(keys);
PyMem_Free(keys);
}
if (self->allocated != -1 && result != NULL) {
@ -2442,7 +2442,7 @@ keyfunc_fail:
while (--i >= 0) {
Py_XDECREF(final_ob_item[i]);
}
PyMem_FREE(final_ob_item);
PyMem_Free(final_ob_item);
}
Py_XINCREF(result);
return result;
@ -2908,7 +2908,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
garbage = (PyObject**)
PyMem_MALLOC(slicelength*sizeof(PyObject*));
PyMem_Malloc(slicelength*sizeof(PyObject*));
if (!garbage) {
PyErr_NoMemory();
return -1;
@ -2949,7 +2949,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
for (i = 0; i < slicelength; i++) {
Py_DECREF(garbage[i]);
}
PyMem_FREE(garbage);
PyMem_Free(garbage);
return res;
}
@ -2990,7 +2990,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
}
garbage = (PyObject**)
PyMem_MALLOC(slicelength*sizeof(PyObject*));
PyMem_Malloc(slicelength*sizeof(PyObject*));
if (!garbage) {
Py_DECREF(seq);
PyErr_NoMemory();
@ -3011,7 +3011,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
Py_DECREF(garbage[i]);
}
PyMem_FREE(garbage);
PyMem_Free(garbage);
Py_DECREF(seq);
return 0;

View File

@ -131,7 +131,7 @@ _PyLong_New(Py_ssize_t size)
"too many digits in integer");
return NULL;
}
result = PyObject_MALLOC(offsetof(PyLongObject, ob_digit) +
result = PyObject_Malloc(offsetof(PyLongObject, ob_digit) +
size*sizeof(digit));
if (!result) {
PyErr_NoMemory();

View File

@ -211,7 +211,7 @@ _PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
return NULL;
if (module->m_size > 0) {
m->md_state = PyMem_MALLOC(module->m_size);
m->md_state = PyMem_Malloc(module->m_size);
if (!m->md_state) {
PyErr_NoMemory();
Py_DECREF(m);
@ -377,7 +377,7 @@ PyModule_ExecDef(PyObject *module, PyModuleDef *def)
if (md->md_state == NULL) {
/* Always set a state pointer; this serves as a marker to skip
* multiple initialization (importlib.reload() is no-op) */
md->md_state = PyMem_MALLOC(def->m_size);
md->md_state = PyMem_Malloc(def->m_size);
if (!md->md_state) {
PyErr_NoMemory();
return -1;
@ -681,7 +681,7 @@ module_dealloc(PyModuleObject *m)
Py_XDECREF(m->md_dict);
Py_XDECREF(m->md_name);
if (m->md_state != NULL)
PyMem_FREE(m->md_state);
PyMem_Free(m->md_state);
Py_TYPE(m)->tp_free((PyObject *)m);
}

View File

@ -161,7 +161,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
PyObject *
_PyObject_New(PyTypeObject *tp)
{
PyObject *op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
PyObject *op = (PyObject *) PyObject_Malloc(_PyObject_SIZE(tp));
if (op == NULL) {
return PyErr_NoMemory();
}
@ -174,7 +174,7 @@ _PyObject_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
{
PyVarObject *op;
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
op = (PyVarObject *) PyObject_MALLOC(size);
op = (PyVarObject *) PyObject_Malloc(size);
if (op == NULL) {
return (PyVarObject *)PyErr_NoMemory();
}

View File

@ -459,7 +459,7 @@ later:
- implement a fuller MutableMapping API in C?
- move the MutableMapping implementation to abstract.c?
- optimize mutablemapping_update
- use PyObject_MALLOC (small object allocator) for odict nodes?
- use PyObject_Malloc (small object allocator) for odict nodes?
- support subclasses better (e.g. in odict_richcompare)
*/
@ -567,14 +567,14 @@ _odict_resize(PyODictObject *od)
i = _odict_get_index_raw(od, _odictnode_KEY(node),
_odictnode_HASH(node));
if (i < 0) {
PyMem_FREE(fast_nodes);
PyMem_Free(fast_nodes);
return -1;
}
fast_nodes[i] = node;
}
/* Replace the old fast nodes table. */
PyMem_FREE(od->od_fast_nodes);
PyMem_Free(od->od_fast_nodes);
od->od_fast_nodes = fast_nodes;
od->od_fast_nodes_size = size;
od->od_resize_sentinel = ((PyDictObject *)od)->ma_keys;
@ -683,7 +683,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
}
/* must not be added yet */
node = (_ODictNode *)PyMem_MALLOC(sizeof(_ODictNode));
node = (_ODictNode *)PyMem_Malloc(sizeof(_ODictNode));
if (node == NULL) {
Py_DECREF(key);
PyErr_NoMemory();
@ -701,7 +701,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
#define _odictnode_DEALLOC(node) \
do { \
Py_DECREF(_odictnode_KEY(node)); \
PyMem_FREE((void *)node); \
PyMem_Free((void *)node); \
} while (0)
/* Repeated calls on the same node are no-ops. */
@ -776,7 +776,7 @@ _odict_clear_nodes(PyODictObject *od)
{
_ODictNode *node, *next;
PyMem_FREE(od->od_fast_nodes);
PyMem_Free(od->od_fast_nodes);
od->od_fast_nodes = NULL;
od->od_fast_nodes_size = 0;
od->od_resize_sentinel = NULL;

View File

@ -171,7 +171,7 @@ range_dealloc(rangeobject *r)
Py_DECREF(r->stop);
Py_DECREF(r->step);
Py_DECREF(r->length);
PyObject_Del(r);
PyObject_Free(r);
}
/* Return number of items in range (lo, hi, step) as a PyLong object,
@ -1021,7 +1021,7 @@ longrangeiter_dealloc(longrangeiterobject *r)
Py_XDECREF(r->start);
Py_XDECREF(r->step);
Py_XDECREF(r->len);
PyObject_Del(r);
PyObject_Free(r);
}
static PyObject *

View File

@ -289,7 +289,7 @@ set_table_resize(PySetObject *so, Py_ssize_t minused)
}
if (is_oldtable_malloced)
PyMem_DEL(oldtable);
PyMem_Free(oldtable);
return 0;
}
@ -424,7 +424,7 @@ set_clear_internal(PySetObject *so)
}
if (table_is_malloced)
PyMem_DEL(table);
PyMem_Free(table);
return 0;
}
@ -484,7 +484,7 @@ set_dealloc(PySetObject *so)
}
}
if (so->table != so->smalltable)
PyMem_DEL(so->table);
PyMem_Free(so->table);
Py_TYPE(so)->tp_free(so);
Py_TRASHCAN_END
}

View File

@ -155,7 +155,7 @@ done:
for (i = 0; i < nbufs; i++)
PyBuffer_Release(&buffers[i]);
if (buffers != static_buffers)
PyMem_FREE(buffers);
PyMem_Free(buffers);
return res;
}

View File

@ -983,7 +983,7 @@ static void
formatteriter_dealloc(formatteriterobject *it)
{
Py_XDECREF(it->str);
PyObject_FREE(it);
PyObject_Free(it);
}
/* returns a tuple:
@ -1147,7 +1147,7 @@ static void
fieldnameiter_dealloc(fieldnameiterobject *it)
{
Py_XDECREF(it->str);
PyObject_FREE(it);
PyObject_Free(it);
}
/* returns a tuple:

View File

@ -467,14 +467,14 @@ PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
type->tp_members = members;
if (PyType_Ready(type) < 0) {
PyMem_FREE(members);
PyMem_Free(members);
return -1;
}
Py_INCREF(type);
if (initialize_structseq_dict(
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
PyMem_FREE(members);
PyMem_Free(members);
Py_DECREF(type);
return -1;
}
@ -526,7 +526,7 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc)
spec.slots = slots;
type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type);
PyMem_FREE(members);
PyMem_Free(members);
if (type == NULL) {
return NULL;
}

View File

@ -1059,7 +1059,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
obj = _PyObject_GC_Malloc(size);
}
else {
obj = (PyObject *)PyObject_MALLOC(size);
obj = (PyObject *)PyObject_Malloc(size);
}
if (obj == NULL) {
@ -1779,7 +1779,7 @@ pmerge(PyObject *acc, PyObject **to_merge, Py_ssize_t to_merge_size)
}
out:
PyMem_Del(remain);
PyMem_Free(remain);
return res;
}
@ -1859,7 +1859,7 @@ mro_implementation(PyTypeObject *type)
result = PyList_New(1);
if (result == NULL) {
PyMem_Del(to_merge);
PyMem_Free(to_merge);
return NULL;
}
@ -1869,7 +1869,7 @@ mro_implementation(PyTypeObject *type)
Py_CLEAR(result);
}
PyMem_Del(to_merge);
PyMem_Free(to_merge);
return result;
}
@ -2707,7 +2707,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
goto error;
/* Silently truncate the docstring if it contains null bytes. */
len = strlen(doc_str);
tp_doc = (char *)PyObject_MALLOC(len + 1);
tp_doc = (char *)PyObject_Malloc(len + 1);
if (tp_doc == NULL) {
PyErr_NoMemory();
goto error;
@ -3047,7 +3047,7 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
continue;
}
size_t len = strlen(slot->pfunc)+1;
char *tp_doc = PyObject_MALLOC(len);
char *tp_doc = PyObject_Malloc(len);
if (tp_doc == NULL) {
type->tp_doc = NULL;
PyErr_NoMemory();

View File

@ -1061,7 +1061,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
new_size = (struct_size + (length + 1) * char_size);
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_UTF8(unicode));
PyObject_Free(_PyUnicode_UTF8(unicode));
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
@ -1072,7 +1072,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
_Py_ForgetReference(unicode);
#endif
new_unicode = (PyObject *)PyObject_REALLOC(unicode, new_size);
new_unicode = (PyObject *)PyObject_Realloc(unicode, new_size);
if (new_unicode == NULL) {
_Py_NewReference(unicode);
PyErr_NoMemory();
@ -1088,7 +1088,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
_PyUnicode_WSTR_LENGTH(unicode) = length;
}
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_WSTR(unicode));
PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
if (!PyUnicode_IS_ASCII(unicode))
_PyUnicode_WSTR_LENGTH(unicode) = 0;
@ -1131,12 +1131,12 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
if (!share_utf8 && _PyUnicode_HAS_UTF8_MEMORY(unicode))
{
PyObject_DEL(_PyUnicode_UTF8(unicode));
PyObject_Free(_PyUnicode_UTF8(unicode));
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
data = (PyObject *)PyObject_REALLOC(data, new_size);
data = (PyObject *)PyObject_Realloc(data, new_size);
if (data == NULL) {
PyErr_NoMemory();
return -1;
@ -1169,7 +1169,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
}
new_size = sizeof(wchar_t) * (length + 1);
wstr = _PyUnicode_WSTR(unicode);
wstr = PyObject_REALLOC(wstr, new_size);
wstr = PyObject_Realloc(wstr, new_size);
if (!wstr) {
PyErr_NoMemory();
return -1;
@ -1259,7 +1259,7 @@ _PyUnicode_New(Py_ssize_t length)
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
_PyUnicode_WSTR(unicode) = (Py_UNICODE*) PyObject_MALLOC(new_size);
_PyUnicode_WSTR(unicode) = (Py_UNICODE*) PyObject_Malloc(new_size);
if (!_PyUnicode_WSTR(unicode)) {
Py_DECREF(unicode);
PyErr_NoMemory();
@ -1456,7 +1456,7 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
* PyObject_New() so we are able to allocate space for the object and
* it's data buffer.
*/
obj = (PyObject *) PyObject_MALLOC(struct_size + (size + 1) * char_size);
obj = (PyObject *) PyObject_Malloc(struct_size + (size + 1) * char_size);
if (obj == NULL) {
return PyErr_NoMemory();
}
@ -1838,7 +1838,7 @@ _PyUnicode_Ready(PyObject *unicode)
return -1;
if (maxchar < 256) {
_PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(_PyUnicode_WSTR_LENGTH(unicode) + 1);
_PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(_PyUnicode_WSTR_LENGTH(unicode) + 1);
if (!_PyUnicode_DATA_ANY(unicode)) {
PyErr_NoMemory();
return -1;
@ -1859,7 +1859,7 @@ _PyUnicode_Ready(PyObject *unicode)
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
PyObject_FREE(_PyUnicode_WSTR(unicode));
PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
_PyUnicode_WSTR_LENGTH(unicode) = 0;
}
@ -1879,7 +1879,7 @@ _PyUnicode_Ready(PyObject *unicode)
_PyUnicode_UTF8_LENGTH(unicode) = 0;
#else
/* sizeof(wchar_t) == 4 */
_PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(
_PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(
2 * (_PyUnicode_WSTR_LENGTH(unicode) + 1));
if (!_PyUnicode_DATA_ANY(unicode)) {
PyErr_NoMemory();
@ -1893,7 +1893,7 @@ _PyUnicode_Ready(PyObject *unicode)
_PyUnicode_STATE(unicode).kind = PyUnicode_2BYTE_KIND;
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
PyObject_FREE(_PyUnicode_WSTR(unicode));
PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
_PyUnicode_WSTR_LENGTH(unicode) = 0;
#endif
@ -1908,7 +1908,7 @@ _PyUnicode_Ready(PyObject *unicode)
PyErr_NoMemory();
return -1;
}
_PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(4 * (length_wo_surrogates + 1));
_PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(4 * (length_wo_surrogates + 1));
if (!_PyUnicode_DATA_ANY(unicode)) {
PyErr_NoMemory();
return -1;
@ -1920,7 +1920,7 @@ _PyUnicode_Ready(PyObject *unicode)
/* unicode_convert_wchar_to_ucs4() requires a ready string */
_PyUnicode_STATE(unicode).ready = 1;
unicode_convert_wchar_to_ucs4(_PyUnicode_WSTR(unicode), end, unicode);
PyObject_FREE(_PyUnicode_WSTR(unicode));
PyObject_Free(_PyUnicode_WSTR(unicode));
_PyUnicode_WSTR(unicode) = NULL;
_PyUnicode_WSTR_LENGTH(unicode) = 0;
#else
@ -1973,13 +1973,13 @@ unicode_dealloc(PyObject *unicode)
}
if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_WSTR(unicode));
PyObject_Free(_PyUnicode_WSTR(unicode));
}
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
PyObject_DEL(_PyUnicode_UTF8(unicode));
PyObject_Free(_PyUnicode_UTF8(unicode));
}
if (!PyUnicode_IS_COMPACT(unicode) && _PyUnicode_DATA_ANY(unicode)) {
PyObject_DEL(_PyUnicode_DATA_ANY(unicode));
PyObject_Free(_PyUnicode_DATA_ANY(unicode));
}
Py_TYPE(unicode)->tp_free(unicode);
@ -3298,7 +3298,7 @@ PyUnicode_AsWideCharString(PyObject *unicode,
*size = buflen;
}
else if (wcslen(buffer) != (size_t)buflen) {
PyMem_FREE(buffer);
PyMem_Free(buffer);
PyErr_SetString(PyExc_ValueError,
"embedded null character");
return NULL;
@ -4199,7 +4199,7 @@ PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size)
PyErr_NoMemory();
return NULL;
}
w = (wchar_t *) PyObject_MALLOC(sizeof(wchar_t) * (wlen + 1));
w = (wchar_t *) PyObject_Malloc(sizeof(wchar_t) * (wlen + 1));
if (w == NULL) {
PyErr_NoMemory();
return NULL;
@ -5627,7 +5627,7 @@ unicode_fill_utf8(PyObject *unicode)
PyBytes_AS_STRING(writer.buffer);
Py_ssize_t len = end - start;
char *cache = PyObject_MALLOC(len + 1);
char *cache = PyObject_Malloc(len + 1);
if (cache == NULL) {
_PyBytesWriter_Dealloc(&writer);
PyErr_NoMemory();
@ -8544,7 +8544,7 @@ PyUnicode_BuildEncodingMap(PyObject* string)
}
/* Create a three-level trie */
result = PyObject_MALLOC(sizeof(struct encoding_map) +
result = PyObject_Malloc(sizeof(struct encoding_map) +
16*count2 + 128*count3 - 1);
if (!result) {
return PyErr_NoMemory();
@ -10211,7 +10211,7 @@ case_operation(PyObject *self,
PyErr_SetString(PyExc_OverflowError, "string is too long");
return NULL;
}
tmp = PyMem_MALLOC(sizeof(Py_UCS4) * 3 * length);
tmp = PyMem_Malloc(sizeof(Py_UCS4) * 3 * length);
if (tmp == NULL)
return PyErr_NoMemory();
newlength = perform(kind, data, length, tmp, &maxchar);
@ -10235,7 +10235,7 @@ case_operation(PyObject *self,
Py_UNREACHABLE();
}
leave:
PyMem_FREE(tmp);
PyMem_Free(tmp);
return res;
}
@ -11050,11 +11050,11 @@ replace(PyObject *self, PyObject *str1,
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
if (srelease)
PyMem_FREE((void *)sbuf);
PyMem_Free((void *)sbuf);
if (release1)
PyMem_FREE((void *)buf1);
PyMem_Free((void *)buf1);
if (release2)
PyMem_FREE((void *)buf2);
PyMem_Free((void *)buf2);
assert(_PyUnicode_CheckConsistency(u, 1));
return u;
@ -11064,11 +11064,11 @@ replace(PyObject *self, PyObject *str1,
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
if (srelease)
PyMem_FREE((void *)sbuf);
PyMem_Free((void *)sbuf);
if (release1)
PyMem_FREE((void *)buf1);
PyMem_Free((void *)buf1);
if (release2)
PyMem_FREE((void *)buf2);
PyMem_Free((void *)buf2);
return unicode_result_unchanged(self);
error:
@ -11076,11 +11076,11 @@ replace(PyObject *self, PyObject *str1,
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
if (srelease)
PyMem_FREE((void *)sbuf);
PyMem_Free((void *)sbuf);
if (release1)
PyMem_FREE((void *)buf1);
PyMem_Free((void *)buf1);
if (release2)
PyMem_FREE((void *)buf2);
PyMem_Free((void *)buf2);
return NULL;
}
@ -15567,7 +15567,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *unicode)
PyErr_NoMemory();
goto onError;
}
data = PyObject_MALLOC((length + 1) * char_size);
data = PyObject_Malloc((length + 1) * char_size);
if (data == NULL) {
PyErr_NoMemory();
goto onError;

View File

@ -351,7 +351,7 @@ msiobj_dealloc(msiobj* msidb)
{
MsiCloseHandle(msidb->h);
msidb->h = 0;
PyObject_Del(msidb);
PyObject_Free(msidb);
}
static PyObject*

View File

@ -145,7 +145,7 @@ PyHKEY_deallocFunc(PyObject *ob)
PyHKEYObject *obkey = (PyHKEYObject *)ob;
if (obkey->hkey)
RegCloseKey((HKEY)obkey->hkey);
PyObject_DEL(ob);
PyObject_Free(ob);
}
static int
@ -459,7 +459,7 @@ PyObject *
PyHKEY_FromHKEY(HKEY h)
{
/* Inline PyObject_New */
PyHKEYObject *op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject));
PyHKEYObject *op = (PyHKEYObject *) PyObject_Malloc(sizeof(PyHKEYObject));
if (op == NULL) {
return PyErr_NoMemory();
}
@ -1818,7 +1818,7 @@ winreg_SetValueEx_impl(PyObject *module, HKEY key,
Py_BEGIN_ALLOW_THREADS
rc = RegSetValueExW(key, value_name, 0, type, data, len);
Py_END_ALLOW_THREADS
PyMem_DEL(data);
PyMem_Free(data);
if (rc != ERROR_SUCCESS)
return PyErr_SetFromWindowsErrWithFunction(rc,
"RegSetValueEx");

View File

@ -384,7 +384,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
int lines, cols;
if (!fstring_find_expr_location(t, str, &lines, &cols)) {
PyMem_FREE(str);
PyMem_Free(str);
return NULL;
}

View File

@ -51,7 +51,7 @@ static const char* type_comment_prefix = "# type: ";
static struct tok_state *
tok_new(void)
{
struct tok_state *tok = (struct tok_state *)PyMem_MALLOC(
struct tok_state *tok = (struct tok_state *)PyMem_Malloc(
sizeof(struct tok_state));
if (tok == NULL)
return NULL;
@ -93,7 +93,7 @@ tok_new(void)
static char *
new_string(const char *s, Py_ssize_t len, struct tok_state *tok)
{
char* result = (char *)PyMem_MALLOC(len + 1);
char* result = (char *)PyMem_Malloc(len + 1);
if (!result) {
tok->done = E_NOMEM;
return NULL;
@ -108,7 +108,7 @@ error_ret(struct tok_state *tok) /* XXX */
{
tok->decoding_erred = 1;
if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */
PyMem_FREE(tok->buf);
PyMem_Free(tok->buf);
tok->buf = tok->cur = tok->inp = NULL;
tok->start = NULL;
tok->end = NULL;
@ -184,7 +184,7 @@ get_coding_spec(const char *s, char **spec, Py_ssize_t size, struct tok_state *t
return 0;
q = get_normal_name(r);
if (r != q) {
PyMem_FREE(r);
PyMem_Free(r);
r = new_string(q, strlen(q), tok);
if (!r)
return 0;
@ -244,7 +244,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
else {
PyErr_Format(PyExc_SyntaxError,
"encoding problem: %s", cs);
PyMem_FREE(cs);
PyMem_Free(cs);
}
}
} else { /* then, compare cs with BOM */
@ -252,7 +252,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
if (!r)
PyErr_Format(PyExc_SyntaxError,
"encoding problem: %s with BOM", cs);
PyMem_FREE(cs);
PyMem_Free(cs);
}
return r;
}
@ -315,7 +315,7 @@ check_bom(int get_char(struct tok_state *),
return 1;
}
if (tok->encoding != NULL)
PyMem_FREE(tok->encoding);
PyMem_Free(tok->encoding);
tok->encoding = new_string("utf-8", 5, tok);
if (!tok->encoding)
return 0;
@ -620,7 +620,7 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
size_t needed_length = strlen(s) + 2, final_length;
char *buf, *current;
char c = '\0';
buf = PyMem_MALLOC(needed_length);
buf = PyMem_Malloc(needed_length);
if (buf == NULL) {
tok->done = E_NOMEM;
return NULL;
@ -651,9 +651,9 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
final_length = current - buf + 1;
if (final_length < needed_length && final_length) {
/* should never fail */
char* result = PyMem_REALLOC(buf, final_length);
char* result = PyMem_Realloc(buf, final_length);
if (result == NULL) {
PyMem_FREE(buf);
PyMem_Free(buf);
}
buf = result;
}
@ -757,7 +757,7 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
tok->read_coding_spec = 1;
tok->enc = NULL;
tok->str = translated;
tok->encoding = (char *)PyMem_MALLOC(6);
tok->encoding = (char *)PyMem_Malloc(6);
if (!tok->encoding) {
PyTokenizer_Free(tok);
return NULL;
@ -778,7 +778,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
struct tok_state *tok = tok_new();
if (tok == NULL)
return NULL;
if ((tok->buf = (char *)PyMem_MALLOC(BUFSIZ)) == NULL) {
if ((tok->buf = (char *)PyMem_Malloc(BUFSIZ)) == NULL) {
PyTokenizer_Free(tok);
return NULL;
}
@ -790,7 +790,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
if (enc != NULL) {
/* Must copy encoding declaration since it
gets copied into the parse tree. */
tok->encoding = PyMem_MALLOC(strlen(enc)+1);
tok->encoding = PyMem_Malloc(strlen(enc)+1);
if (!tok->encoding) {
PyTokenizer_Free(tok);
return NULL;
@ -808,15 +808,15 @@ void
PyTokenizer_Free(struct tok_state *tok)
{
if (tok->encoding != NULL)
PyMem_FREE(tok->encoding);
PyMem_Free(tok->encoding);
Py_XDECREF(tok->decoding_readline);
Py_XDECREF(tok->decoding_buffer);
Py_XDECREF(tok->filename);
if (tok->fp != NULL && tok->buf != NULL)
PyMem_FREE(tok->buf);
PyMem_Free(tok->buf);
if (tok->input)
PyMem_FREE(tok->input);
PyMem_FREE(tok);
PyMem_Free(tok->input);
PyMem_Free(tok);
}
/* Get next char, updating state; error code goes into tok->done */
@ -852,7 +852,7 @@ tok_nextc(struct tok_state *tok)
char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
if (newtok != NULL) {
char *translated = translate_newlines(newtok, 0, tok);
PyMem_FREE(newtok);
PyMem_Free(newtok);
if (translated == NULL)
return EOF;
newtok = translated;
@ -862,14 +862,14 @@ tok_nextc(struct tok_state *tok)
Py_ssize_t buflen;
const char* buf;
PyObject *u = translate_into_utf8(newtok, tok->encoding);
PyMem_FREE(newtok);
PyMem_Free(newtok);
if (!u) {
tok->done = E_DECODE;
return EOF;
}
buflen = PyBytes_GET_SIZE(u);
buf = PyBytes_AS_STRING(u);
newtok = PyMem_MALLOC(buflen+1);
newtok = PyMem_Malloc(buflen+1);
if (newtok == NULL) {
Py_DECREF(u);
tok->done = E_NOMEM;
@ -883,7 +883,7 @@ tok_nextc(struct tok_state *tok)
if (newtok == NULL)
tok->done = E_INTR;
else if (*newtok == '\0') {
PyMem_FREE(newtok);
PyMem_Free(newtok);
tok->done = E_EOF;
}
else if (tok->start != NULL) {
@ -892,12 +892,12 @@ tok_nextc(struct tok_state *tok)
size_t newlen = oldlen + strlen(newtok);
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
char *buf = tok->buf;
buf = (char *)PyMem_REALLOC(buf, newlen+1);
buf = (char *)PyMem_Realloc(buf, newlen+1);
tok->lineno++;
if (buf == NULL) {
PyMem_FREE(tok->buf);
PyMem_Free(tok->buf);
tok->buf = NULL;
PyMem_FREE(newtok);
PyMem_Free(newtok);
tok->done = E_NOMEM;
return EOF;
}
@ -906,7 +906,7 @@ tok_nextc(struct tok_state *tok)
tok->multi_line_start = tok->buf + cur_multi_line_start;
tok->line_start = tok->cur;
strcpy(tok->buf + oldlen, newtok);
PyMem_FREE(newtok);
PyMem_Free(newtok);
tok->inp = tok->buf + newlen;
tok->end = tok->inp + 1;
tok->start = tok->buf + start;
@ -914,7 +914,7 @@ tok_nextc(struct tok_state *tok)
else {
tok->lineno++;
if (tok->buf != NULL)
PyMem_FREE(tok->buf);
PyMem_Free(tok->buf);
tok->buf = newtok;
tok->cur = tok->buf;
tok->line_start = tok->buf;
@ -929,7 +929,7 @@ tok_nextc(struct tok_state *tok)
if (tok->start == NULL) {
if (tok->buf == NULL) {
tok->buf = (char *)
PyMem_MALLOC(BUFSIZ);
PyMem_Malloc(BUFSIZ);
if (tok->buf == NULL) {
tok->done = E_NOMEM;
return EOF;
@ -966,7 +966,7 @@ tok_nextc(struct tok_state *tok)
Py_ssize_t curvalid = tok->inp - tok->buf;
Py_ssize_t newsize = curvalid + BUFSIZ;
char *newbuf = tok->buf;
newbuf = (char *)PyMem_REALLOC(newbuf,
newbuf = (char *)PyMem_Realloc(newbuf,
newsize);
if (newbuf == NULL) {
tok->done = E_NOMEM;
@ -1851,7 +1851,7 @@ PyTokenizer_Get(struct tok_state *tok, const char **p_start, const char **p_end)
encoding in the first or second line of the file (in which case the encoding
should be assumed to be UTF-8).
The char* returned is malloc'ed via PyMem_MALLOC() and thus must be freed
The char* returned is malloc'ed via PyMem_Malloc() and thus must be freed
by the caller. */
char *
@ -1894,7 +1894,7 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
}
fclose(fp);
if (tok->encoding) {
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
encoding = (char *)PyMem_Malloc(strlen(tok->encoding) + 1);
if (encoding)
strcpy(encoding, tok->encoding);
}

View File

@ -2089,7 +2089,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
Py_DECREF(stdin_encoding);
Py_DECREF(stdin_errors);
Py_XDECREF(po);
PyMem_FREE(s);
PyMem_Free(s);
if (result != NULL) {
if (PySys_Audit("builtins.input/result", "O", result) < 0) {

View File

@ -202,7 +202,7 @@ static int
cleanup_ptr(PyObject *self, void *ptr)
{
if (ptr) {
PyMem_FREE(ptr);
PyMem_Free(ptr);
}
return 0;
}
@ -246,7 +246,7 @@ cleanreturn(int retval, freelist_t *freelist)
}
}
if (freelist->entries_malloced)
PyMem_FREE(freelist->entries);
PyMem_Free(freelist->entries);
return retval;
}

View File

@ -638,7 +638,7 @@ r_string(Py_ssize_t n, RFILE *p)
return res;
}
if (p->buf == NULL) {
p->buf = PyMem_MALLOC(n);
p->buf = PyMem_Malloc(n);
if (p->buf == NULL) {
PyErr_NoMemory();
return NULL;
@ -646,7 +646,7 @@ r_string(Py_ssize_t n, RFILE *p)
p->buf_size = n;
}
else if (p->buf_size < n) {
char *tmp = PyMem_REALLOC(p->buf, n);
char *tmp = PyMem_Realloc(p->buf, n);
if (tmp == NULL) {
PyErr_NoMemory();
return NULL;
@ -1453,7 +1453,7 @@ PyMarshal_ReadShortFromFile(FILE *fp)
rf.buf = NULL;
res = r_short(&rf);
if (rf.buf != NULL)
PyMem_FREE(rf.buf);
PyMem_Free(rf.buf);
return res;
}
@ -1468,7 +1468,7 @@ PyMarshal_ReadLongFromFile(FILE *fp)
rf.buf = NULL;
res = r_long(&rf);
if (rf.buf != NULL)
PyMem_FREE(rf.buf);
PyMem_Free(rf.buf);
return res;
}
@ -1501,11 +1501,11 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
off_t filesize;
filesize = getfilesize(fp);
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
char* pBuf = (char *)PyMem_MALLOC(filesize);
char* pBuf = (char *)PyMem_Malloc(filesize);
if (pBuf != NULL) {
size_t n = fread(pBuf, 1, (size_t)filesize, fp);
PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n);
PyMem_FREE(pBuf);
PyMem_Free(pBuf);
return v;
}
@ -1534,7 +1534,7 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
result = r_object(&rf);
Py_DECREF(rf.refs);
if (rf.buf != NULL)
PyMem_FREE(rf.buf);
PyMem_Free(rf.buf);
return result;
}
@ -1555,7 +1555,7 @@ PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
result = r_object(&rf);
Py_DECREF(rf.refs);
if (rf.buf != NULL)
PyMem_FREE(rf.buf);
PyMem_Free(rf.buf);
return result;
}
@ -1684,7 +1684,7 @@ marshal_load(PyObject *module, PyObject *file)
result = read_object(&rf);
Py_DECREF(rf.refs);
if (rf.buf != NULL)
PyMem_FREE(rf.buf);
PyMem_Free(rf.buf);
} else
result = NULL;
}

View File

@ -255,7 +255,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
char *copy, *c;
/* Create a copy of the input, with the '.' converted to the
locale-specific decimal point */
copy = (char *)PyMem_MALLOC(end - digits_pos +
copy = (char *)PyMem_Malloc(end - digits_pos +
1 + decimal_point_len);
if (copy == NULL) {
*endptr = (char *)nptr;
@ -286,7 +286,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
(fail_pos - copy);
}
PyMem_FREE(copy);
PyMem_Free(copy);
}
else {

View File

@ -128,7 +128,7 @@ ste_dealloc(PySTEntryObject *ste)
Py_XDECREF(ste->ste_varnames);
Py_XDECREF(ste->ste_children);
Py_XDECREF(ste->ste_directives);
PyObject_Del(ste);
PyObject_Free(ste);
}
#define OFF(x) offsetof(PySTEntryObject, x)

View File

@ -419,12 +419,12 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
Py_DECREF(io);
Py_DECREF(binary);
PyMem_FREE(found_encoding);
PyMem_Free(found_encoding);
return 0;
}
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
Py_DECREF(io);
PyMem_FREE(found_encoding);
PyMem_Free(found_encoding);
if (fob == NULL) {
PyErr_Clear();