Merge branch 'master' of https://github.com/python/cpython into bpo-42513
This commit is contained in:
commit
d755a45ed6
|
@ -336,6 +336,7 @@ The :mod:`abc` module also provides the following functions:
|
||||||
.. versionadded:: 3.4
|
.. versionadded:: 3.4
|
||||||
|
|
||||||
.. function:: update_abstractmethods(cls)
|
.. function:: update_abstractmethods(cls)
|
||||||
|
|
||||||
A function to recalculate an abstract class's abstraction status. This
|
A function to recalculate an abstract class's abstraction status. This
|
||||||
function should be called if a class's abstract methods have been
|
function should be called if a class's abstract methods have been
|
||||||
implemented or changed after it was created. Usually, this function should
|
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.
|
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::
|
.. note::
|
||||||
|
|
||||||
|
|
|
@ -1133,20 +1133,9 @@ container should match the type_ specified::
|
||||||
|
|
||||||
Any container can be passed as the *choices* value, so :class:`list` objects,
|
Any container can be passed as the *choices* value, so :class:`list` objects,
|
||||||
:class:`set` objects, and custom containers are all supported.
|
:class:`set` objects, and custom containers are all supported.
|
||||||
This includes :class:`enum.Enum`, which could be used to restrain
|
|
||||||
argument's choices; if we reuse previous rock/paper/scissors game example,
|
|
||||||
this could be as follows::
|
|
||||||
|
|
||||||
>>> from enum import Enum
|
Use of :class:`enum.Enum` is not recommended because it is difficult to
|
||||||
>>> class GameMove(Enum):
|
control its appearance in usage, help, and error messages.
|
||||||
... ROCK = 'rock'
|
|
||||||
... PAPER = 'paper'
|
|
||||||
... SCISSORS = 'scissors'
|
|
||||||
...
|
|
||||||
>>> parser = argparse.ArgumentParser(prog='game.py')
|
|
||||||
>>> parser.add_argument('move', type=GameMove, choices=GameMove)
|
|
||||||
>>> parser.parse_args(['rock'])
|
|
||||||
Namespace(move=<GameMove.ROCK: 'rock'>)
|
|
||||||
|
|
||||||
|
|
||||||
required
|
required
|
||||||
|
|
|
@ -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:
|
Using :func:`compress` and :func:`decompress` to demonstrate round-trip compression:
|
||||||
|
|
||||||
>>> import bz2
|
>>> import bz2
|
||||||
|
|
||||||
>>> data = b"""\
|
>>> data = b"""\
|
||||||
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
|
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
|
||||||
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
|
... 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
|
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
|
||||||
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
|
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
|
||||||
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
|
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
|
||||||
|
|
||||||
>>> c = bz2.compress(data)
|
>>> c = bz2.compress(data)
|
||||||
>>> len(data) / len(c) # Data compression ratio
|
>>> len(data) / len(c) # Data compression ratio
|
||||||
1.513595166163142
|
1.513595166163142
|
||||||
|
|
||||||
>>> d = bz2.decompress(c)
|
>>> d = bz2.decompress(c)
|
||||||
>>> data == d # Check equality to original object after round-trip
|
>>> data == d # Check equality to original object after round-trip
|
||||||
True
|
True
|
||||||
|
@ -287,7 +284,6 @@ Using :func:`compress` and :func:`decompress` to demonstrate round-trip compress
|
||||||
Using :class:`BZ2Compressor` for incremental compression:
|
Using :class:`BZ2Compressor` for incremental compression:
|
||||||
|
|
||||||
>>> import bz2
|
>>> import bz2
|
||||||
|
|
||||||
>>> def gen_data(chunks=10, chunksize=1000):
|
>>> def gen_data(chunks=10, chunksize=1000):
|
||||||
... """Yield incremental blocks of chunksize bytes."""
|
... """Yield incremental blocks of chunksize bytes."""
|
||||||
... for _ in range(chunks):
|
... 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:
|
Writing and reading a bzip2-compressed file in binary mode:
|
||||||
|
|
||||||
>>> import bz2
|
>>> import bz2
|
||||||
|
|
||||||
>>> data = b"""\
|
>>> data = b"""\
|
||||||
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
|
... Donec rhoncus quis sapien sit amet molestie. Fusce scelerisque vel augue
|
||||||
... nec ullamcorper. Nam rutrum pretium placerat. Aliquam vel tristique lorem,
|
... 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
|
... Aliquam pharetra lacus non risus vehicula rutrum. Maecenas aliquam leo
|
||||||
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
|
... felis. Pellentesque semper nunc sit amet nibh ullamcorper, ac elementum
|
||||||
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
|
... dolor luctus. Curabitur lacinia mi ornare consectetur vestibulum."""
|
||||||
|
|
||||||
>>> with bz2.open("myfile.bz2", "wb") as f:
|
>>> with bz2.open("myfile.bz2", "wb") as f:
|
||||||
... # Write compressed data to file
|
... # Write compressed data to file
|
||||||
... unused = f.write(data)
|
... unused = f.write(data)
|
||||||
|
|
||||||
>>> with bz2.open("myfile.bz2", "rb") as f:
|
>>> with bz2.open("myfile.bz2", "rb") as f:
|
||||||
... # Decompress data from file
|
... # Decompress data from file
|
||||||
... content = f.read()
|
... content = f.read()
|
||||||
|
|
||||||
>>> content == data # Check equality to original object after round-trip
|
>>> content == data # Check equality to original object after round-trip
|
||||||
True
|
True
|
||||||
|
|
|
@ -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:`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:`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:`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:`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:`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
|
: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``,
|
If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
|
||||||
then the step defaults to one.
|
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)
|
.. function:: permutations(iterable, r=None)
|
||||||
|
|
||||||
|
@ -782,12 +799,6 @@ which incur interpreter overhead.
|
||||||
return starmap(func, repeat(args))
|
return starmap(func, repeat(args))
|
||||||
return starmap(func, repeat(args, times))
|
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):
|
def grouper(iterable, n, fillvalue=None):
|
||||||
"Collect data into fixed-length chunks or blocks"
|
"Collect data into fixed-length chunks or blocks"
|
||||||
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
|
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
|
||||||
|
|
|
@ -253,3 +253,41 @@ Unix Platforms
|
||||||
using :program:`gcc`.
|
using :program:`gcc`.
|
||||||
|
|
||||||
The file is read and scanned in chunks of *chunksize* bytes.
|
The file is read and scanned in chunks of *chunksize* bytes.
|
||||||
|
|
||||||
|
|
||||||
|
Linux Platforms
|
||||||
|
---------------
|
||||||
|
|
||||||
|
.. function:: freedesktop_os_release()
|
||||||
|
|
||||||
|
Get operating system identification from ``os-release`` file and return
|
||||||
|
it as a dict. The ``os-release`` file is a `freedesktop.org standard
|
||||||
|
<https://www.freedesktop.org/software/systemd/man/os-release.html>`_ and
|
||||||
|
is available in most Linux distributions. A noticeable exception is
|
||||||
|
Android and Android-based distributions.
|
||||||
|
|
||||||
|
Raises :exc:`OSError` or subclass when neither ``/etc/os-release`` nor
|
||||||
|
``/usr/lib/os-release`` can be read.
|
||||||
|
|
||||||
|
On success, the function returns a dictionary where keys and values are
|
||||||
|
strings. Values have their special characters like ``"`` and ``$``
|
||||||
|
unquoted. The fields ``NAME``, ``ID``, and ``PRETTY_NAME`` are always
|
||||||
|
defined according to the standard. All other fields are optional. Vendors
|
||||||
|
may include additional fields.
|
||||||
|
|
||||||
|
Note that fields like ``NAME``, ``VERSION``, and ``VARIANT`` are strings
|
||||||
|
suitable for presentation to users. Programs should use fields like
|
||||||
|
``ID``, ``ID_LIKE``, ``VERSION_ID``, or ``VARIANT_ID`` to identify
|
||||||
|
Linux distributions.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
def get_like_distro():
|
||||||
|
info = platform.freedesktop_os_release()
|
||||||
|
ids = [info["ID"]]
|
||||||
|
if "ID_LIKE" in info:
|
||||||
|
# ids are space separated and ordered by precedence
|
||||||
|
ids.extend(info["ID_LIKE"].split())
|
||||||
|
return ids
|
||||||
|
|
||||||
|
.. versionadded:: 3.10
|
||||||
|
|
|
@ -13,7 +13,8 @@ In particular, ``&`` followed by a symbol, token or parenthesized
|
||||||
group indicates a positive lookahead (i.e., is required to match but
|
group indicates a positive lookahead (i.e., is required to match but
|
||||||
not consumed), while ``!`` indicates a negative lookahead (i.e., is
|
not consumed), while ``!`` indicates a negative lookahead (i.e., is
|
||||||
required _not_ to match). We use the ``|`` separator to mean PEG's
|
required _not_ to match). We use the ``|`` separator to mean PEG's
|
||||||
"ordered choice" (written as ``/`` in traditional PEG grammars).
|
"ordered choice" (written as ``/`` in traditional PEG grammars). See
|
||||||
|
:pep:`617` for more details on the grammar's syntax.
|
||||||
|
|
||||||
.. literalinclude:: ../../Grammar/python.gram
|
.. literalinclude:: ../../Grammar/python.gram
|
||||||
:language: peg
|
:language: peg
|
||||||
|
|
|
@ -254,6 +254,14 @@ Added negative indexing support to :attr:`PurePath.parents
|
||||||
<pathlib.PurePath.parents>`.
|
<pathlib.PurePath.parents>`.
|
||||||
(Contributed by Yaroslav Pankovych in :issue:`21041`)
|
(Contributed by Yaroslav Pankovych in :issue:`21041`)
|
||||||
|
|
||||||
|
platform
|
||||||
|
--------
|
||||||
|
|
||||||
|
Added :func:`platform.freedesktop_os_release()` to retrieve operation system
|
||||||
|
identification from `freedesktop.org os-release
|
||||||
|
<https://www.freedesktop.org/software/systemd/man/os-release.html>`_ standard file.
|
||||||
|
(Contributed by Christian Heimes in :issue:`28468`)
|
||||||
|
|
||||||
py_compile
|
py_compile
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
|
|
@ -52,18 +52,18 @@ type_expressions[asdl_expr_seq*]:
|
||||||
| a[asdl_expr_seq*]=','.expression+ {a}
|
| a[asdl_expr_seq*]=','.expression+ {a}
|
||||||
|
|
||||||
statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
|
statements[asdl_stmt_seq*]: a=statement+ { (asdl_stmt_seq*)_PyPegen_seq_flatten(p, a) }
|
||||||
statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmt { a }
|
statement[asdl_stmt_seq*]: a=compound_stmt { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } | a[asdl_stmt_seq*]=simple_stmts { a }
|
||||||
statement_newline[asdl_stmt_seq*]:
|
statement_newline[asdl_stmt_seq*]:
|
||||||
| a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
|
| a=compound_stmt NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) }
|
||||||
| simple_stmt
|
| simple_stmts
|
||||||
| NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _Py_Pass(EXTRA))) }
|
| NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, CHECK(stmt_ty, _Py_Pass(EXTRA))) }
|
||||||
| ENDMARKER { _PyPegen_interactive_exit(p) }
|
| ENDMARKER { _PyPegen_interactive_exit(p) }
|
||||||
simple_stmt[asdl_stmt_seq*]:
|
simple_stmts[asdl_stmt_seq*]:
|
||||||
| a=small_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
|
| a=simple_stmt !';' NEWLINE { (asdl_stmt_seq*)_PyPegen_singleton_seq(p, a) } # Not needed, there for speedup
|
||||||
| a[asdl_stmt_seq*]=';'.small_stmt+ [';'] NEWLINE { a }
|
| a[asdl_stmt_seq*]=';'.simple_stmt+ [';'] NEWLINE { a }
|
||||||
# NOTE: assignment MUST precede expression, else parsing a simple assignment
|
# NOTE: assignment MUST precede expression, else parsing a simple assignment
|
||||||
# will throw a SyntaxError.
|
# will throw a SyntaxError.
|
||||||
small_stmt[stmt_ty] (memo):
|
simple_stmt[stmt_ty] (memo):
|
||||||
| assignment
|
| assignment
|
||||||
| e=star_expressions { _Py_Expr(e, EXTRA) }
|
| e=star_expressions { _Py_Expr(e, EXTRA) }
|
||||||
| &'return' return_stmt
|
| &'return' return_stmt
|
||||||
|
@ -308,7 +308,7 @@ class_def_raw[stmt_ty]:
|
||||||
|
|
||||||
block[asdl_stmt_seq*] (memo):
|
block[asdl_stmt_seq*] (memo):
|
||||||
| NEWLINE INDENT a=statements DEDENT { a }
|
| NEWLINE INDENT a=statements DEDENT { a }
|
||||||
| simple_stmt
|
| simple_stmts
|
||||||
| invalid_block
|
| invalid_block
|
||||||
|
|
||||||
star_expressions[expr_ty]:
|
star_expressions[expr_ty]:
|
||||||
|
|
|
@ -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
|
object with room for n items. In addition to the refcount and type pointer
|
||||||
fields, this also fills in the ob_size field.
|
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.
|
run a destructor -- it only frees the memory. PyObject_Free is identical.
|
||||||
|
|
||||||
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't
|
- 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);
|
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_MALLOC PyObject_Malloc
|
||||||
#define PyObject_REALLOC PyObject_Realloc
|
#define PyObject_REALLOC PyObject_Realloc
|
||||||
#define PyObject_FREE PyObject_Free
|
#define PyObject_FREE PyObject_Free
|
||||||
|
@ -138,8 +140,8 @@ PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||||
#define PyObject_NewVar(type, typeobj, n) \
|
#define PyObject_NewVar(type, typeobj, n) \
|
||||||
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
||||||
|
|
||||||
// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
|
// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
|
||||||
// PyObject_MALLOC() with _PyObject_VAR_SIZE().
|
// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
|
||||||
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)
|
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, typeobj, n)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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_Realloc(void *ptr, size_t new_size);
|
||||||
PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
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
|
* Type-oriented memory interface
|
||||||
* ==============================
|
* ==============================
|
||||||
|
@ -78,9 +66,6 @@ PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
||||||
#define PyMem_New(type, n) \
|
#define PyMem_New(type, n) \
|
||||||
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||||
( (type *) PyMem_Malloc((n) * sizeof(type)) ) )
|
( (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.
|
* 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) \
|
#define PyMem_Resize(p, type, n) \
|
||||||
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \
|
||||||
(type *) PyMem_Realloc((p), (n) * sizeof(type)) )
|
(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.
|
// 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
|
||||||
#define PyMem_DEL PyMem_FREE
|
#define PyMem_DEL PyMem_Free
|
||||||
|
|
||||||
|
|
||||||
#ifndef Py_LIMITED_API
|
#ifndef Py_LIMITED_API
|
||||||
|
|
|
@ -1001,7 +1001,7 @@ class ChainMap(_collections_abc.MutableMapping):
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
d = {}
|
d = {}
|
||||||
for mapping in reversed(self.maps):
|
for mapping in reversed(self.maps):
|
||||||
d.update(mapping) # reuses stored hash values if possible
|
d.update(dict.fromkeys(mapping)) # reuses stored hash values if possible
|
||||||
return iter(d)
|
return iter(d)
|
||||||
|
|
||||||
def __contains__(self, key):
|
def __contains__(self, key):
|
||||||
|
|
|
@ -757,7 +757,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
def runcode(self, code):
|
def runcode(self, code):
|
||||||
"Override base class method"
|
"Override base class method"
|
||||||
if self.tkconsole.executing:
|
if self.tkconsole.executing:
|
||||||
self.interp.restart_subprocess()
|
self.restart_subprocess()
|
||||||
self.checklinecache()
|
self.checklinecache()
|
||||||
debugger = self.debugger
|
debugger = self.debugger
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1230,6 +1230,63 @@ def platform(aliased=0, terse=0):
|
||||||
_platform_cache[(aliased, terse)] = platform
|
_platform_cache[(aliased, terse)] = platform
|
||||||
return platform
|
return platform
|
||||||
|
|
||||||
|
### freedesktop.org os-release standard
|
||||||
|
# https://www.freedesktop.org/software/systemd/man/os-release.html
|
||||||
|
|
||||||
|
# NAME=value with optional quotes (' or "). The regular expression is less
|
||||||
|
# strict than shell lexer, but that's ok.
|
||||||
|
_os_release_line = re.compile(
|
||||||
|
"^(?P<name>[a-zA-Z0-9_]+)=(?P<quote>[\"\']?)(?P<value>.*)(?P=quote)$"
|
||||||
|
)
|
||||||
|
# unescape five special characters mentioned in the standard
|
||||||
|
_os_release_unescape = re.compile(r"\\([\\\$\"\'`])")
|
||||||
|
# /etc takes precedence over /usr/lib
|
||||||
|
_os_release_candidates = ("/etc/os-release", "/usr/lib/os-relesase")
|
||||||
|
_os_release_cache = None
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_os_release(lines):
|
||||||
|
# These fields are mandatory fields with well-known defaults
|
||||||
|
# in pratice all Linux distributions override NAME, ID, and PRETTY_NAME.
|
||||||
|
info = {
|
||||||
|
"NAME": "Linux",
|
||||||
|
"ID": "linux",
|
||||||
|
"PRETTY_NAME": "Linux",
|
||||||
|
}
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
mo = _os_release_line.match(line)
|
||||||
|
if mo is not None:
|
||||||
|
info[mo.group('name')] = _os_release_unescape.sub(
|
||||||
|
r"\1", mo.group('value')
|
||||||
|
)
|
||||||
|
|
||||||
|
return info
|
||||||
|
|
||||||
|
|
||||||
|
def freedesktop_os_release():
|
||||||
|
"""Return operation system identification from freedesktop.org os-release
|
||||||
|
"""
|
||||||
|
global _os_release_cache
|
||||||
|
|
||||||
|
if _os_release_cache is None:
|
||||||
|
errno = None
|
||||||
|
for candidate in _os_release_candidates:
|
||||||
|
try:
|
||||||
|
with open(candidate, encoding="utf-8") as f:
|
||||||
|
_os_release_cache = _parse_os_release(f)
|
||||||
|
break
|
||||||
|
except OSError as e:
|
||||||
|
errno = e.errno
|
||||||
|
else:
|
||||||
|
raise OSError(
|
||||||
|
errno,
|
||||||
|
f"Unable to read files {', '.join(_os_release_candidates)}"
|
||||||
|
)
|
||||||
|
|
||||||
|
return _os_release_cache.copy()
|
||||||
|
|
||||||
|
|
||||||
### Command line interface
|
### Command line interface
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -196,6 +196,22 @@ class TestChainMap(unittest.TestCase):
|
||||||
('e', 55), ('f', 666), ('g', 777), ('h', 88888),
|
('e', 55), ('f', 666), ('g', 777), ('h', 88888),
|
||||||
('i', 9999), ('j', 0)])
|
('i', 9999), ('j', 0)])
|
||||||
|
|
||||||
|
def test_iter_not_calling_getitem_on_maps(self):
|
||||||
|
class DictWithGetItem(UserDict):
|
||||||
|
def __init__(self, *args, **kwds):
|
||||||
|
self.called = False
|
||||||
|
UserDict.__init__(self, *args, **kwds)
|
||||||
|
def __getitem__(self, item):
|
||||||
|
self.called = True
|
||||||
|
UserDict.__getitem__(self, item)
|
||||||
|
|
||||||
|
d = DictWithGetItem(a=1)
|
||||||
|
c = ChainMap(d)
|
||||||
|
d.called = False
|
||||||
|
|
||||||
|
set(c) # iterate over chain map
|
||||||
|
self.assertFalse(d.called, '__getitem__ was called')
|
||||||
|
|
||||||
def test_dict_coercion(self):
|
def test_dict_coercion(self):
|
||||||
d = ChainMap(dict(a=1, b=2), dict(b=20, c=30))
|
d = ChainMap(dict(a=1, b=2), dict(b=20, c=30))
|
||||||
self.assertEqual(dict(d), dict(a=1, b=2, c=30))
|
self.assertEqual(dict(d), dict(a=1, b=2, c=30))
|
||||||
|
|
|
@ -1024,6 +1024,25 @@ class TestBasicOps(unittest.TestCase):
|
||||||
self.assertEqual(next(it), (1, 2))
|
self.assertEqual(next(it), (1, 2))
|
||||||
self.assertRaises(RuntimeError, next, it)
|
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):
|
def test_product(self):
|
||||||
for args, result in [
|
for args, result in [
|
||||||
([], [()]), # zero iterables
|
([], [()]), # zero iterables
|
||||||
|
@ -1787,6 +1806,10 @@ class TestGC(unittest.TestCase):
|
||||||
a = []
|
a = []
|
||||||
self.makecycle(islice([a]*2, None), a)
|
self.makecycle(islice([a]*2, None), a)
|
||||||
|
|
||||||
|
def test_pairwise(self):
|
||||||
|
a = []
|
||||||
|
self.makecycle(pairwise([a]*5), a)
|
||||||
|
|
||||||
def test_permutations(self):
|
def test_permutations(self):
|
||||||
a = []
|
a = []
|
||||||
self.makecycle(permutations([1,2,a,3], 3), 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(TypeError, islice, N(s), 10)
|
||||||
self.assertRaises(ZeroDivisionError, list, islice(E(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):
|
def test_starmap(self):
|
||||||
for s in (range(10), range(0), range(100), (7,11), range(20,50,5)):
|
for s in (range(10), range(0), range(100), (7,11), range(20,50,5)):
|
||||||
for g in (G, I, Ig, S, L, R):
|
for g in (G, I, Ig, S, L, R):
|
||||||
|
@ -2312,15 +2346,6 @@ Samuele
|
||||||
... else:
|
... else:
|
||||||
... return starmap(func, repeat(args, times))
|
... 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):
|
>>> def grouper(n, iterable, fillvalue=None):
|
||||||
... "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
|
... "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
|
||||||
... args = [iter(iterable)] * n
|
... args = [iter(iterable)] * n
|
||||||
|
@ -2451,15 +2476,6 @@ True
|
||||||
>>> take(5, map(int, repeatfunc(random.random)))
|
>>> take(5, map(int, repeatfunc(random.random)))
|
||||||
[0, 0, 0, 0, 0]
|
[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))
|
>>> list(islice(pad_none('abc'), 0, 6))
|
||||||
['a', 'b', 'c', None, None, None]
|
['a', 'b', 'c', None, None, None]
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,70 @@ from unittest import mock
|
||||||
from test import support
|
from test import support
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
|
|
||||||
|
FEDORA_OS_RELEASE = """\
|
||||||
|
NAME=Fedora
|
||||||
|
VERSION="32 (Thirty Two)"
|
||||||
|
ID=fedora
|
||||||
|
VERSION_ID=32
|
||||||
|
VERSION_CODENAME=""
|
||||||
|
PLATFORM_ID="platform:f32"
|
||||||
|
PRETTY_NAME="Fedora 32 (Thirty Two)"
|
||||||
|
ANSI_COLOR="0;34"
|
||||||
|
LOGO=fedora-logo-icon
|
||||||
|
CPE_NAME="cpe:/o:fedoraproject:fedora:32"
|
||||||
|
HOME_URL="https://fedoraproject.org/"
|
||||||
|
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f32/system-administrators-guide/"
|
||||||
|
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
|
||||||
|
BUG_REPORT_URL="https://bugzilla.redhat.com/"
|
||||||
|
REDHAT_BUGZILLA_PRODUCT="Fedora"
|
||||||
|
REDHAT_BUGZILLA_PRODUCT_VERSION=32
|
||||||
|
REDHAT_SUPPORT_PRODUCT="Fedora"
|
||||||
|
REDHAT_SUPPORT_PRODUCT_VERSION=32
|
||||||
|
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
|
||||||
|
"""
|
||||||
|
|
||||||
|
UBUNTU_OS_RELEASE = """\
|
||||||
|
NAME="Ubuntu"
|
||||||
|
VERSION="20.04.1 LTS (Focal Fossa)"
|
||||||
|
ID=ubuntu
|
||||||
|
ID_LIKE=debian
|
||||||
|
PRETTY_NAME="Ubuntu 20.04.1 LTS"
|
||||||
|
VERSION_ID="20.04"
|
||||||
|
HOME_URL="https://www.ubuntu.com/"
|
||||||
|
SUPPORT_URL="https://help.ubuntu.com/"
|
||||||
|
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
|
||||||
|
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
|
||||||
|
VERSION_CODENAME=focal
|
||||||
|
UBUNTU_CODENAME=focal
|
||||||
|
"""
|
||||||
|
|
||||||
|
TEST_OS_RELEASE = r"""
|
||||||
|
# test data
|
||||||
|
ID_LIKE="egg spam viking"
|
||||||
|
EMPTY=
|
||||||
|
# comments and empty lines are ignored
|
||||||
|
|
||||||
|
SINGLE_QUOTE='single'
|
||||||
|
EMPTY_SINGLE=''
|
||||||
|
DOUBLE_QUOTE="double"
|
||||||
|
EMPTY_DOUBLE=""
|
||||||
|
QUOTES="double\'s"
|
||||||
|
SPECIALS="\$\`\\\'\""
|
||||||
|
# invalid lines
|
||||||
|
=invalid
|
||||||
|
=
|
||||||
|
INVALID
|
||||||
|
IN-VALID=value
|
||||||
|
IN VALID=value
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
class PlatformTest(unittest.TestCase):
|
class PlatformTest(unittest.TestCase):
|
||||||
def clear_caches(self):
|
def clear_caches(self):
|
||||||
platform._platform_cache.clear()
|
platform._platform_cache.clear()
|
||||||
platform._sys_version_cache.clear()
|
platform._sys_version_cache.clear()
|
||||||
platform._uname_cache = None
|
platform._uname_cache = None
|
||||||
|
platform._os_release_cache = None
|
||||||
|
|
||||||
def test_architecture(self):
|
def test_architecture(self):
|
||||||
res = platform.architecture()
|
res = platform.architecture()
|
||||||
|
@ -382,6 +440,54 @@ class PlatformTest(unittest.TestCase):
|
||||||
self.assertEqual(platform.platform(terse=1), expected_terse)
|
self.assertEqual(platform.platform(terse=1), expected_terse)
|
||||||
self.assertEqual(platform.platform(), expected)
|
self.assertEqual(platform.platform(), expected)
|
||||||
|
|
||||||
|
def test_freedesktop_os_release(self):
|
||||||
|
self.addCleanup(self.clear_caches)
|
||||||
|
self.clear_caches()
|
||||||
|
|
||||||
|
if any(os.path.isfile(fn) for fn in platform._os_release_candidates):
|
||||||
|
info = platform.freedesktop_os_release()
|
||||||
|
self.assertIn("NAME", info)
|
||||||
|
self.assertIn("ID", info)
|
||||||
|
|
||||||
|
info["CPYTHON_TEST"] = "test"
|
||||||
|
self.assertNotIn(
|
||||||
|
"CPYTHON_TEST",
|
||||||
|
platform.freedesktop_os_release()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
with self.assertRaises(OSError):
|
||||||
|
platform.freedesktop_os_release()
|
||||||
|
|
||||||
|
def test_parse_os_release(self):
|
||||||
|
info = platform._parse_os_release(FEDORA_OS_RELEASE.splitlines())
|
||||||
|
self.assertEqual(info["NAME"], "Fedora")
|
||||||
|
self.assertEqual(info["ID"], "fedora")
|
||||||
|
self.assertNotIn("ID_LIKE", info)
|
||||||
|
self.assertEqual(info["VERSION_CODENAME"], "")
|
||||||
|
|
||||||
|
info = platform._parse_os_release(UBUNTU_OS_RELEASE.splitlines())
|
||||||
|
self.assertEqual(info["NAME"], "Ubuntu")
|
||||||
|
self.assertEqual(info["ID"], "ubuntu")
|
||||||
|
self.assertEqual(info["ID_LIKE"], "debian")
|
||||||
|
self.assertEqual(info["VERSION_CODENAME"], "focal")
|
||||||
|
|
||||||
|
info = platform._parse_os_release(TEST_OS_RELEASE.splitlines())
|
||||||
|
expected = {
|
||||||
|
"ID": "linux",
|
||||||
|
"NAME": "Linux",
|
||||||
|
"PRETTY_NAME": "Linux",
|
||||||
|
"ID_LIKE": "egg spam viking",
|
||||||
|
"EMPTY": "",
|
||||||
|
"DOUBLE_QUOTE": "double",
|
||||||
|
"EMPTY_DOUBLE": "",
|
||||||
|
"SINGLE_QUOTE": "single",
|
||||||
|
"EMPTY_SINGLE": "",
|
||||||
|
"QUOTES": "double's",
|
||||||
|
"SPECIALS": "$`\\'\"",
|
||||||
|
}
|
||||||
|
self.assertEqual(info, expected)
|
||||||
|
self.assertEqual(len(info["SPECIALS"]), 5)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
@ -642,12 +642,17 @@ class PosixTester(unittest.TestCase):
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
|
@unittest.skipUnless(hasattr(posix, 'mkfifo'), "don't have mkfifo()")
|
||||||
def test_mkfifo(self):
|
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:
|
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:
|
except PermissionError as e:
|
||||||
self.skipTest('posix.mkfifo(): %s' % 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'),
|
@unittest.skipUnless(hasattr(posix, 'mknod') and hasattr(stat, 'S_IFIFO'),
|
||||||
"don't have mknod()/S_IFIFO")
|
"don't have mknod()/S_IFIFO")
|
||||||
|
|
|
@ -519,10 +519,14 @@ class WakeupSocketSignalTests(unittest.TestCase):
|
||||||
else:
|
else:
|
||||||
write.setblocking(False)
|
write.setblocking(False)
|
||||||
|
|
||||||
|
written = 0
|
||||||
|
if sys.platform == "vxworks":
|
||||||
|
CHUNK_SIZES = (1,)
|
||||||
|
else:
|
||||||
# Start with large chunk size to reduce the
|
# Start with large chunk size to reduce the
|
||||||
# number of send needed to fill the buffer.
|
# number of send needed to fill the buffer.
|
||||||
written = 0
|
CHUNK_SIZES = (2 ** 16, 2 ** 8, 1)
|
||||||
for chunk_size in (2 ** 16, 2 ** 8, 1):
|
for chunk_size in CHUNK_SIZES:
|
||||||
chunk = b"x" * chunk_size
|
chunk = b"x" * chunk_size
|
||||||
try:
|
try:
|
||||||
while True:
|
while True:
|
||||||
|
@ -595,6 +599,7 @@ class WakeupSocketSignalTests(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
|
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
|
||||||
|
@unittest.skipUnless(hasattr(signal, 'siginterrupt'), "needs signal.siginterrupt()")
|
||||||
class SiginterruptTest(unittest.TestCase):
|
class SiginterruptTest(unittest.TestCase):
|
||||||
|
|
||||||
def readpipe_interrupted(self, interrupt):
|
def readpipe_interrupted(self, interrupt):
|
||||||
|
@ -680,6 +685,8 @@ class SiginterruptTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
|
@unittest.skipIf(sys.platform == "win32", "Not valid on Windows")
|
||||||
|
@unittest.skipUnless(hasattr(signal, 'getitimer') and hasattr(signal, 'setitimer'),
|
||||||
|
"needs signal.getitimer() and signal.setitimer()")
|
||||||
class ItimerTest(unittest.TestCase):
|
class ItimerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.hndl_called = False
|
self.hndl_called = False
|
||||||
|
|
|
@ -2,6 +2,7 @@ import unittest
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
from test.support import os_helper
|
||||||
from test.support import socket_helper
|
from test.support import socket_helper
|
||||||
from test.support.import_helper import import_fresh_module
|
from test.support.import_helper import import_fresh_module
|
||||||
from test.support.os_helper import TESTFN
|
from test.support.os_helper import TESTFN
|
||||||
|
@ -173,11 +174,16 @@ class TestFilemode:
|
||||||
|
|
||||||
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'os.mkfifo not available')
|
@unittest.skipUnless(hasattr(os, 'mkfifo'), 'os.mkfifo not available')
|
||||||
def test_fifo(self):
|
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:
|
try:
|
||||||
os.mkfifo(TESTFN, 0o700)
|
os.mkfifo(fifo_path, 0o700)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
self.skipTest('os.mkfifo(): %s' % 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.assertEqual(modestr, 'prwx------')
|
||||||
self.assertS_IS("FIFO", st_mode)
|
self.assertS_IS("FIFO", st_mode)
|
||||||
|
|
||||||
|
|
|
@ -1123,6 +1123,18 @@ class TestTracebackException(unittest.TestCase):
|
||||||
self.assertEqual(exc_info[0], exc.exc_type)
|
self.assertEqual(exc_info[0], exc.exc_type)
|
||||||
self.assertEqual(str(exc_info[1]), str(exc))
|
self.assertEqual(str(exc_info[1]), str(exc))
|
||||||
|
|
||||||
|
def test_no_refs_to_exception_and_traceback_objects(self):
|
||||||
|
try:
|
||||||
|
1/0
|
||||||
|
except Exception:
|
||||||
|
exc_info = sys.exc_info()
|
||||||
|
|
||||||
|
refcnt1 = sys.getrefcount(exc_info[1])
|
||||||
|
refcnt2 = sys.getrefcount(exc_info[2])
|
||||||
|
exc = traceback.TracebackException(*exc_info)
|
||||||
|
self.assertEqual(sys.getrefcount(exc_info[1]), refcnt1)
|
||||||
|
self.assertEqual(sys.getrefcount(exc_info[2]), refcnt2)
|
||||||
|
|
||||||
def test_comparison_basic(self):
|
def test_comparison_basic(self):
|
||||||
try:
|
try:
|
||||||
1/0
|
1/0
|
||||||
|
@ -1172,6 +1184,16 @@ class TestTracebackException(unittest.TestCase):
|
||||||
exc7 = traceback.TracebackException(*exc_info, limit=-2, capture_locals=True)
|
exc7 = traceback.TracebackException(*exc_info, limit=-2, capture_locals=True)
|
||||||
self.assertNotEqual(exc6, exc7)
|
self.assertNotEqual(exc6, exc7)
|
||||||
|
|
||||||
|
def test_comparison_equivalent_exceptions_are_equal(self):
|
||||||
|
excs = []
|
||||||
|
for _ in range(2):
|
||||||
|
try:
|
||||||
|
1/0
|
||||||
|
except:
|
||||||
|
excs.append(traceback.TracebackException(*sys.exc_info()))
|
||||||
|
self.assertEqual(excs[0], excs[1])
|
||||||
|
self.assertEqual(list(excs[0].format()), list(excs[1].format()))
|
||||||
|
|
||||||
def test_unhashable(self):
|
def test_unhashable(self):
|
||||||
class UnhashableException(Exception):
|
class UnhashableException(Exception):
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
|
|
|
@ -510,7 +510,6 @@ class TracebackException:
|
||||||
_seen=_seen)
|
_seen=_seen)
|
||||||
else:
|
else:
|
||||||
context = None
|
context = None
|
||||||
self.exc_traceback = exc_traceback
|
|
||||||
self.__cause__ = cause
|
self.__cause__ = cause
|
||||||
self.__context__ = context
|
self.__context__ = context
|
||||||
self.__suppress_context__ = \
|
self.__suppress_context__ = \
|
||||||
|
@ -627,7 +626,7 @@ class TracebackException:
|
||||||
not self.__suppress_context__):
|
not self.__suppress_context__):
|
||||||
yield from self.__context__.format(chain=chain)
|
yield from self.__context__.format(chain=chain)
|
||||||
yield _context_message
|
yield _context_message
|
||||||
if self.exc_traceback is not None:
|
if self.stack:
|
||||||
yield 'Traceback (most recent call last):\n'
|
yield 'Traceback (most recent call last):\n'
|
||||||
yield from self.stack.format()
|
yield from self.stack.format()
|
||||||
yield from self.format_exception_only()
|
yield from self.format_exception_only()
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Support signal module on VxWorks.
|
|
@ -0,0 +1,2 @@
|
||||||
|
Add :func:`platform.freedesktop_os_release` function to parse freedesktop.org
|
||||||
|
``os-release`` files.
|
|
@ -0,0 +1 @@
|
||||||
|
:class:`~traceback.TracebackException` no longer holds a reference to the exception's traceback object. Consequently, instances of TracebackException for equivalent but non-equal exceptions now compare as equal.
|
|
@ -0,0 +1 @@
|
||||||
|
ChainMap.__iter__ no longer calls __getitem__ on underlying maps
|
|
@ -0,0 +1 @@
|
||||||
|
Added itertools.pairwise()
|
|
@ -0,0 +1 @@
|
||||||
|
Fix fifo test cases for VxWorks RTOS.
|
|
@ -393,7 +393,7 @@ py_blake2b_dealloc(PyObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyTypeObject *type = Py_TYPE(self);
|
PyTypeObject *type = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -392,7 +392,7 @@ py_blake2s_dealloc(PyObject *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyTypeObject *type = Py_TYPE(self);
|
PyTypeObject *type = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -475,7 +475,7 @@ static void
|
||||||
PyCArg_dealloc(PyCArgObject *self)
|
PyCArg_dealloc(PyCArgObject *self)
|
||||||
{
|
{
|
||||||
Py_XDECREF(self->obj);
|
Py_XDECREF(self->obj);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -282,7 +282,7 @@ PyCursesPanel_Dealloc(PyCursesPanelObject *po)
|
||||||
Py_DECREF(po->wo);
|
Py_DECREF(po->wo);
|
||||||
remove_lop(po);
|
remove_lop(po);
|
||||||
}
|
}
|
||||||
PyObject_DEL(po);
|
PyObject_Free(po);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -689,7 +689,7 @@ PyCursesWindow_Dealloc(PyCursesWindowObject *wo)
|
||||||
if (wo->win != stdscr) delwin(wo->win);
|
if (wo->win != stdscr) delwin(wo->win);
|
||||||
if (wo->encoding != NULL)
|
if (wo->encoding != NULL)
|
||||||
PyMem_Free(wo->encoding);
|
PyMem_Free(wo->encoding);
|
||||||
PyObject_DEL(wo);
|
PyObject_Free(wo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Addch, Addstr, Addnstr */
|
/* Addch, Addstr, Addnstr */
|
||||||
|
|
|
@ -1765,7 +1765,7 @@ ctxmanager_dealloc(PyDecContextManagerObject *self)
|
||||||
{
|
{
|
||||||
Py_XDECREF(self->local);
|
Py_XDECREF(self->local);
|
||||||
Py_XDECREF(self->global);
|
Py_XDECREF(self->global);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -478,7 +478,7 @@ keyobject_dealloc(keyobject *ko)
|
||||||
{
|
{
|
||||||
Py_DECREF(ko->cmp);
|
Py_DECREF(ko->cmp);
|
||||||
Py_XDECREF(ko->object);
|
Py_XDECREF(ko->object);
|
||||||
PyObject_FREE(ko);
|
PyObject_Free(ko);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -742,7 +742,7 @@ lru_list_elem_dealloc(lru_list_elem *link)
|
||||||
{
|
{
|
||||||
Py_XDECREF(link->key);
|
Py_XDECREF(link->key);
|
||||||
Py_XDECREF(link->result);
|
Py_XDECREF(link->result);
|
||||||
PyObject_Del(link);
|
PyObject_Free(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject lru_list_elem_type = {
|
static PyTypeObject lru_list_elem_type = {
|
||||||
|
|
|
@ -341,7 +341,7 @@ EVP_dealloc(EVPobject *self)
|
||||||
if (self->lock != NULL)
|
if (self->lock != NULL)
|
||||||
PyThread_free_lock(self->lock);
|
PyThread_free_lock(self->lock);
|
||||||
EVP_MD_CTX_free(self->ctx);
|
EVP_MD_CTX_free(self->ctx);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1453,7 +1453,7 @@ _hashlib_hmac_new_impl(PyObject *module, Py_buffer *key, PyObject *msg_obj,
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (ctx) HMAC_CTX_free(ctx);
|
if (ctx) HMAC_CTX_free(ctx);
|
||||||
if (self) PyObject_Del(self);
|
if (self) PyObject_Free(self);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1546,7 +1546,7 @@ _hmac_dealloc(HMACobject *self)
|
||||||
PyThread_free_lock(self->lock);
|
PyThread_free_lock(self->lock);
|
||||||
}
|
}
|
||||||
HMAC_CTX_free(self->ctx);
|
HMAC_CTX_free(self->ctx);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -370,8 +370,8 @@ _locale_strcoll_impl(PyObject *module, PyObject *os1, PyObject *os2)
|
||||||
result = PyLong_FromLong(wcscoll(ws1, ws2));
|
result = PyLong_FromLong(wcscoll(ws1, ws2));
|
||||||
done:
|
done:
|
||||||
/* Deallocate everything. */
|
/* Deallocate everything. */
|
||||||
if (ws1) PyMem_FREE(ws1);
|
if (ws1) PyMem_Free(ws1);
|
||||||
if (ws2) PyMem_FREE(ws2);
|
if (ws2) PyMem_Free(ws2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -571,7 +571,7 @@ semlock_dealloc(SemLockObject* self)
|
||||||
if (self->handle != SEM_FAILED)
|
if (self->handle != SEM_FAILED)
|
||||||
SEM_CLOSE(self->handle);
|
SEM_CLOSE(self->handle);
|
||||||
PyMem_Free(self->name);
|
PyMem_Free(self->name);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*[clinic input]
|
/*[clinic input]
|
||||||
|
|
|
@ -442,8 +442,8 @@ Pdata_dealloc(Pdata *self)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_DECREF(self->data[i]);
|
Py_DECREF(self->data[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(self->data);
|
PyMem_Free(self->data);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject Pdata_Type = {
|
static PyTypeObject Pdata_Type = {
|
||||||
|
@ -465,7 +465,7 @@ Pdata_New(void)
|
||||||
self->mark_set = 0;
|
self->mark_set = 0;
|
||||||
self->fence = 0;
|
self->fence = 0;
|
||||||
self->allocated = 8;
|
self->allocated = 8;
|
||||||
self->data = PyMem_MALLOC(self->allocated * sizeof(PyObject *));
|
self->data = PyMem_Malloc(self->allocated * sizeof(PyObject *));
|
||||||
if (self->data)
|
if (self->data)
|
||||||
return (PyObject *)self;
|
return (PyObject *)self;
|
||||||
Py_DECREF(self);
|
Py_DECREF(self);
|
||||||
|
@ -726,7 +726,7 @@ static PyTypeObject Unpickler_Type;
|
||||||
static PyMemoTable *
|
static PyMemoTable *
|
||||||
PyMemoTable_New(void)
|
PyMemoTable_New(void)
|
||||||
{
|
{
|
||||||
PyMemoTable *memo = PyMem_MALLOC(sizeof(PyMemoTable));
|
PyMemoTable *memo = PyMem_Malloc(sizeof(PyMemoTable));
|
||||||
if (memo == NULL) {
|
if (memo == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -735,9 +735,9 @@ PyMemoTable_New(void)
|
||||||
memo->mt_used = 0;
|
memo->mt_used = 0;
|
||||||
memo->mt_allocated = MT_MINSIZE;
|
memo->mt_allocated = MT_MINSIZE;
|
||||||
memo->mt_mask = MT_MINSIZE - 1;
|
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) {
|
if (memo->mt_table == NULL) {
|
||||||
PyMem_FREE(memo);
|
PyMem_Free(memo);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -758,10 +758,10 @@ PyMemoTable_Copy(PyMemoTable *self)
|
||||||
new->mt_mask = self->mt_mask;
|
new->mt_mask = self->mt_mask;
|
||||||
/* The table we get from _New() is probably smaller than we wanted.
|
/* The table we get from _New() is probably smaller than we wanted.
|
||||||
Free it and allocate one that's the right size. */
|
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);
|
new->mt_table = PyMem_NEW(PyMemoEntry, self->mt_allocated);
|
||||||
if (new->mt_table == NULL) {
|
if (new->mt_table == NULL) {
|
||||||
PyMem_FREE(new);
|
PyMem_Free(new);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -800,8 +800,8 @@ PyMemoTable_Del(PyMemoTable *self)
|
||||||
return;
|
return;
|
||||||
PyMemoTable_Clear(self);
|
PyMemoTable_Clear(self);
|
||||||
|
|
||||||
PyMem_FREE(self->mt_table);
|
PyMem_Free(self->mt_table);
|
||||||
PyMem_FREE(self);
|
PyMem_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Since entries cannot be deleted from this hashtable, _PyMemoTable_Lookup()
|
/* 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. */
|
/* Deallocate the old table. */
|
||||||
PyMem_FREE(oldtable);
|
PyMem_Free(oldtable);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,7 +1582,7 @@ _Unpickler_MemoCleanup(UnpicklerObject *self)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(memo[i]);
|
Py_XDECREF(memo[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(memo);
|
PyMem_Free(memo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static UnpicklerObject *
|
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--) {
|
for (size_t i = new_memo_size - 1; i != SIZE_MAX; i--) {
|
||||||
Py_XDECREF(new_memo[i]);
|
Py_XDECREF(new_memo[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(new_memo);
|
PyMem_Free(new_memo);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,7 @@ SHA3_dealloc(SHA3object *self)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ static void
|
||||||
data_stack_dealloc(SRE_STATE* state)
|
data_stack_dealloc(SRE_STATE* state)
|
||||||
{
|
{
|
||||||
if (state->data_stack) {
|
if (state->data_stack) {
|
||||||
PyMem_FREE(state->data_stack);
|
PyMem_Free(state->data_stack);
|
||||||
state->data_stack = NULL;
|
state->data_stack = NULL;
|
||||||
}
|
}
|
||||||
state->data_stack_size = state->data_stack_base = 0;
|
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;
|
void* stack;
|
||||||
cursize = minsize+minsize/4+1024;
|
cursize = minsize+minsize/4+1024;
|
||||||
TRACE(("allocate/grow stack %zd\n", cursize));
|
TRACE(("allocate/grow stack %zd\n", cursize));
|
||||||
stack = PyMem_REALLOC(state->data_stack, cursize);
|
stack = PyMem_Realloc(state->data_stack, cursize);
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
data_stack_dealloc(state);
|
data_stack_dealloc(state);
|
||||||
return SRE_ERROR_MEMORY;
|
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
|
/* We add an explicit cast here because MSVC has a bug when
|
||||||
compiling C code where it believes that `const void**` cannot be
|
compiling C code where it believes that `const void**` cannot be
|
||||||
safely casted to `void*`, see bpo-39943 for details. */
|
safely casted to `void*`, see bpo-39943 for details. */
|
||||||
PyMem_Del((void*) state->mark);
|
PyMem_Free((void*) state->mark);
|
||||||
state->mark = NULL;
|
state->mark = NULL;
|
||||||
if (state->buffer.buf)
|
if (state->buffer.buf)
|
||||||
PyBuffer_Release(&state->buffer);
|
PyBuffer_Release(&state->buffer);
|
||||||
|
@ -487,7 +487,7 @@ state_fini(SRE_STATE* state)
|
||||||
Py_XDECREF(state->string);
|
Py_XDECREF(state->string);
|
||||||
data_stack_dealloc(state);
|
data_stack_dealloc(state);
|
||||||
/* See above PyMem_Del for why we explicitly cast here. */
|
/* See above PyMem_Del for why we explicitly cast here. */
|
||||||
PyMem_Del((void*) state->mark);
|
PyMem_Free((void*) state->mark);
|
||||||
state->mark = NULL;
|
state->mark = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -571,7 +571,7 @@ pattern_dealloc(PatternObject* self)
|
||||||
Py_XDECREF(self->pattern);
|
Py_XDECREF(self->pattern);
|
||||||
Py_XDECREF(self->groupindex);
|
Py_XDECREF(self->groupindex);
|
||||||
Py_XDECREF(self->indexgroup);
|
Py_XDECREF(self->indexgroup);
|
||||||
PyObject_DEL(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1944,7 +1944,7 @@ match_dealloc(MatchObject* self)
|
||||||
Py_XDECREF(self->regs);
|
Py_XDECREF(self->regs);
|
||||||
Py_XDECREF(self->string);
|
Py_XDECREF(self->string);
|
||||||
Py_DECREF(self->pattern);
|
Py_DECREF(self->pattern);
|
||||||
PyObject_DEL(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2450,7 +2450,7 @@ scanner_dealloc(ScannerObject* self)
|
||||||
|
|
||||||
state_fini(&self->state);
|
state_fini(&self->state);
|
||||||
Py_XDECREF(self->pattern);
|
Py_XDECREF(self->pattern);
|
||||||
PyObject_DEL(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2295,7 +2295,7 @@ PySSL_dealloc(PySSLSocket *self)
|
||||||
Py_XDECREF(self->ctx);
|
Py_XDECREF(self->ctx);
|
||||||
Py_XDECREF(self->server_hostname);
|
Py_XDECREF(self->server_hostname);
|
||||||
Py_XDECREF(self->owner);
|
Py_XDECREF(self->owner);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3306,10 +3306,10 @@ context_dealloc(PySSLContext *self)
|
||||||
context_clear(self);
|
context_clear(self);
|
||||||
SSL_CTX_free(self->ctx);
|
SSL_CTX_free(self->ctx);
|
||||||
#if HAVE_NPN
|
#if HAVE_NPN
|
||||||
PyMem_FREE(self->npn_protocols);
|
PyMem_Free(self->npn_protocols);
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_ALPN
|
#if HAVE_ALPN
|
||||||
PyMem_FREE(self->alpn_protocols);
|
PyMem_Free(self->alpn_protocols);
|
||||||
#endif
|
#endif
|
||||||
Py_TYPE(self)->tp_free(self);
|
Py_TYPE(self)->tp_free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
|
@ -3510,7 +3510,7 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_FREE(self->alpn_protocols);
|
PyMem_Free(self->alpn_protocols);
|
||||||
self->alpn_protocols = PyMem_Malloc(protos->len);
|
self->alpn_protocols = PyMem_Malloc(protos->len);
|
||||||
if (!self->alpn_protocols)
|
if (!self->alpn_protocols)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
|
|
@ -1373,14 +1373,14 @@ prepare_s(PyStructObject *self)
|
||||||
|
|
||||||
self->s_size = size;
|
self->s_size = size;
|
||||||
self->s_len = len;
|
self->s_len = len;
|
||||||
codes = PyMem_MALLOC((ncodes + 1) * sizeof(formatcode));
|
codes = PyMem_Malloc((ncodes + 1) * sizeof(formatcode));
|
||||||
if (codes == NULL) {
|
if (codes == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Free any s_codes value left over from a previous initialization. */
|
/* Free any s_codes value left over from a previous initialization. */
|
||||||
if (self->s_codes != NULL)
|
if (self->s_codes != NULL)
|
||||||
PyMem_FREE(self->s_codes);
|
PyMem_Free(self->s_codes);
|
||||||
self->s_codes = codes;
|
self->s_codes = codes;
|
||||||
|
|
||||||
s = fmt;
|
s = fmt;
|
||||||
|
@ -1502,7 +1502,7 @@ s_dealloc(PyStructObject *s)
|
||||||
if (s->weakreflist != NULL)
|
if (s->weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *)s);
|
PyObject_ClearWeakRefs((PyObject *)s);
|
||||||
if (s->s_codes != NULL) {
|
if (s->s_codes != NULL) {
|
||||||
PyMem_FREE(s->s_codes);
|
PyMem_Free(s->s_codes);
|
||||||
}
|
}
|
||||||
Py_XDECREF(s->s_format);
|
Py_XDECREF(s->s_format);
|
||||||
freefunc free_func = PyType_GetSlot(Py_TYPE(s), Py_tp_free);
|
freefunc free_func = PyType_GetSlot(Py_TYPE(s), Py_tp_free);
|
||||||
|
|
|
@ -236,7 +236,7 @@ ndarray_dealloc(NDArrayObject *self)
|
||||||
ndbuf_pop(self);
|
ndbuf_pop(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -2734,7 +2734,7 @@ staticarray_init(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
static void
|
static void
|
||||||
staticarray_dealloc(StaticArrayObject *self)
|
staticarray_dealloc(StaticArrayObject *self)
|
||||||
{
|
{
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a buffer for a PyBUF_FULL_RO request. Flags are not checked,
|
/* Return a buffer for a PyBUF_FULL_RO request. Flags are not checked,
|
||||||
|
|
|
@ -1988,12 +1988,12 @@ unicode_asucs4(PyObject *self, PyObject *args)
|
||||||
buffer[str_len] = 0xffffU;
|
buffer[str_len] = 0xffffU;
|
||||||
|
|
||||||
if (!PyUnicode_AsUCS4(unicode, buffer, buf_len, copy_null)) {
|
if (!PyUnicode_AsUCS4(unicode, buffer, buf_len, copy_null)) {
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
|
result = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND, buffer, buf_len);
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6010,7 +6010,7 @@ test_structmembers_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
|
||||||
static void
|
static void
|
||||||
test_structmembers_free(PyObject *ob)
|
test_structmembers_free(PyObject *ob)
|
||||||
{
|
{
|
||||||
PyObject_FREE(ob);
|
PyObject_Free(ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject test_structmembersType = {
|
static PyTypeObject test_structmembersType = {
|
||||||
|
@ -6664,7 +6664,7 @@ static void
|
||||||
heapctype_dealloc(HeapCTypeObject *self)
|
heapctype_dealloc(HeapCTypeObject *self)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6854,7 +6854,7 @@ heapctypewithdict_dealloc(HeapCTypeWithDictObject* self)
|
||||||
|
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
Py_XDECREF(self->dict);
|
Py_XDECREF(self->dict);
|
||||||
PyObject_DEL(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6925,7 +6925,7 @@ heapctypewithweakref_dealloc(HeapCTypeWithWeakrefObject* self)
|
||||||
if (self->weakreflist != NULL)
|
if (self->weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *) self);
|
PyObject_ClearWeakRefs((PyObject *) self);
|
||||||
Py_XDECREF(self->weakreflist);
|
Py_XDECREF(self->weakreflist);
|
||||||
PyObject_DEL(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6968,7 +6968,7 @@ static void
|
||||||
heapctypesetattr_dealloc(HeapCTypeSetattrObject *self)
|
heapctypesetattr_dealloc(HeapCTypeSetattrObject *self)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ lock_dealloc(lockobject *self)
|
||||||
PyThread_release_lock(self->lock_lock);
|
PyThread_release_lock(self->lock_lock);
|
||||||
PyThread_free_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
|
/* 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->func);
|
||||||
Py_DECREF(boot->args);
|
Py_DECREF(boot->args);
|
||||||
Py_XDECREF(boot->keyw);
|
Py_XDECREF(boot->keyw);
|
||||||
PyMem_DEL(boot_raw);
|
PyMem_Free(boot_raw);
|
||||||
tstate->interp->num_threads--;
|
tstate->interp->num_threads--;
|
||||||
PyThreadState_Clear(tstate);
|
PyThreadState_Clear(tstate);
|
||||||
_PyThreadState_DeleteCurrent(tstate);
|
_PyThreadState_DeleteCurrent(tstate);
|
||||||
|
@ -1107,7 +1107,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
||||||
boot->tstate = _PyThreadState_Prealloc(boot->interp);
|
boot->tstate = _PyThreadState_Prealloc(boot->interp);
|
||||||
boot->runtime = runtime;
|
boot->runtime = runtime;
|
||||||
if (boot->tstate == NULL) {
|
if (boot->tstate == NULL) {
|
||||||
PyMem_DEL(boot);
|
PyMem_Free(boot);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
Py_INCREF(func);
|
Py_INCREF(func);
|
||||||
|
@ -1121,7 +1121,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
|
||||||
Py_DECREF(args);
|
Py_DECREF(args);
|
||||||
Py_XDECREF(keyw);
|
Py_XDECREF(keyw);
|
||||||
PyThreadState_Clear(boot->tstate);
|
PyThreadState_Clear(boot->tstate);
|
||||||
PyMem_DEL(boot);
|
PyMem_Free(boot);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return PyLong_FromUnsignedLong(ident);
|
return PyLong_FromUnsignedLong(ident);
|
||||||
|
|
|
@ -904,7 +904,7 @@ PyTclObject_dealloc(PyTclObject *self)
|
||||||
PyObject *tp = (PyObject *) Py_TYPE(self);
|
PyObject *tp = (PyObject *) Py_TYPE(self);
|
||||||
Tcl_DecrRefCount(self->value);
|
Tcl_DecrRefCount(self->value);
|
||||||
Py_XDECREF(self->string);
|
Py_XDECREF(self->string);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2472,7 +2472,7 @@ PythonCmdDelete(ClientData clientData)
|
||||||
ENTER_PYTHON
|
ENTER_PYTHON
|
||||||
Py_XDECREF(data->self);
|
Py_XDECREF(data->self);
|
||||||
Py_XDECREF(data->func);
|
Py_XDECREF(data->func);
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
LEAVE_PYTHON
|
LEAVE_PYTHON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2545,7 +2545,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
|
||||||
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
|
CommandEvent *ev = (CommandEvent*)attemptckalloc(sizeof(CommandEvent));
|
||||||
if (ev == NULL) {
|
if (ev == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
|
ev->ev.proc = (Tcl_EventProc*)Tkapp_CommandProc;
|
||||||
|
@ -2568,7 +2568,7 @@ _tkinter_tkapp_createcommand_impl(TkappObject *self, const char *name,
|
||||||
}
|
}
|
||||||
if (err) {
|
if (err) {
|
||||||
PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
|
PyErr_SetString(Tkinter_TclError, "can't create Tcl command");
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2666,7 +2666,7 @@ DeleteFHCD(int id)
|
||||||
*pp = p->next;
|
*pp = p->next;
|
||||||
Py_XDECREF(p->func);
|
Py_XDECREF(p->func);
|
||||||
Py_XDECREF(p->file);
|
Py_XDECREF(p->file);
|
||||||
PyMem_DEL(p);
|
PyMem_Free(p);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
pp = &p->next;
|
pp = &p->next;
|
||||||
|
@ -2823,7 +2823,7 @@ Tktt_Dealloc(PyObject *self)
|
||||||
|
|
||||||
Py_XDECREF(func);
|
Py_XDECREF(func);
|
||||||
|
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3096,7 +3096,7 @@ Tkapp_Dealloc(PyObject *self)
|
||||||
ENTER_TCL
|
ENTER_TCL
|
||||||
Tcl_DeleteInterp(Tkapp_Interp(self));
|
Tcl_DeleteInterp(Tkapp_Interp(self));
|
||||||
LEAVE_TCL
|
LEAVE_TCL
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
DisableEventHook();
|
DisableEventHook();
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,7 +133,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newsize == 0) {
|
if (newsize == 0) {
|
||||||
PyMem_FREE(self->ob_item);
|
PyMem_Free(self->ob_item);
|
||||||
self->ob_item = NULL;
|
self->ob_item = NULL;
|
||||||
Py_SET_SIZE(self, 0);
|
Py_SET_SIZE(self, 0);
|
||||||
self->allocated = 0;
|
self->allocated = 0;
|
||||||
|
@ -652,7 +652,7 @@ array_dealloc(arrayobject *op)
|
||||||
if (op->weakreflist != NULL)
|
if (op->weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject *) op);
|
PyObject_ClearWeakRefs((PyObject *) op);
|
||||||
if (op->ob_item != NULL)
|
if (op->ob_item != NULL)
|
||||||
PyMem_DEL(op->ob_item);
|
PyMem_Free(op->ob_item);
|
||||||
Py_TYPE(op)->tp_free((PyObject *)op);
|
Py_TYPE(op)->tp_free((PyObject *)op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -691,7 +691,7 @@ static struct PyMethodDef multibytecodec_methods[] = {
|
||||||
static void
|
static void
|
||||||
multibytecodec_dealloc(MultibyteCodecObject *self)
|
multibytecodec_dealloc(MultibyteCodecObject *self)
|
||||||
{
|
{
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyTypeObject MultibyteCodec_Type = {
|
static PyTypeObject MultibyteCodec_Type = {
|
||||||
|
@ -1191,13 +1191,13 @@ _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDeco
|
||||||
goto errorexit;
|
goto errorexit;
|
||||||
|
|
||||||
if (wdata != data)
|
if (wdata != data)
|
||||||
PyMem_Del(wdata);
|
PyMem_Free(wdata);
|
||||||
Py_XDECREF(buf.excobj);
|
Py_XDECREF(buf.excobj);
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
errorexit:
|
errorexit:
|
||||||
if (wdata != NULL && wdata != data)
|
if (wdata != NULL && wdata != data)
|
||||||
PyMem_Del(wdata);
|
PyMem_Free(wdata);
|
||||||
Py_XDECREF(buf.excobj);
|
Py_XDECREF(buf.excobj);
|
||||||
_PyUnicodeWriter_Dealloc(&buf.writer);
|
_PyUnicodeWriter_Dealloc(&buf.writer);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -2,6 +2,37 @@
|
||||||
preserve
|
preserve
|
||||||
[clinic start generated code]*/
|
[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__,
|
PyDoc_STRVAR(itertools_groupby__doc__,
|
||||||
"groupby(iterable, key=None)\n"
|
"groupby(iterable, key=None)\n"
|
||||||
"--\n"
|
"--\n"
|
||||||
|
@ -627,4 +658,4 @@ skip_optional_pos:
|
||||||
exit:
|
exit:
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
/*[clinic end generated code: output=d7f58dc477814b45 input=a9049054013a1b77]*/
|
/*[clinic end generated code: output=889c4afc3b13574f input=a9049054013a1b77]*/
|
||||||
|
|
|
@ -2290,7 +2290,7 @@ _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyGC_Head *g = AS_GC(op);
|
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)
|
if (g == NULL)
|
||||||
return (PyVarObject *)PyErr_NoMemory();
|
return (PyVarObject *)PyErr_NoMemory();
|
||||||
op = (PyVarObject *) FROM_GC(g);
|
op = (PyVarObject *) FROM_GC(g);
|
||||||
|
@ -2309,7 +2309,7 @@ PyObject_GC_Del(void *op)
|
||||||
if (gcstate->generations[0].count > 0) {
|
if (gcstate->generations[0].count > 0) {
|
||||||
gcstate->generations[0].count--;
|
gcstate->generations[0].count--;
|
||||||
}
|
}
|
||||||
PyObject_FREE(g);
|
PyObject_Free(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
#define PY_SSIZE_T_CLEAN
|
#define PY_SSIZE_T_CLEAN
|
||||||
#include "Python.h"
|
#include "Python.h"
|
||||||
#include "pycore_long.h" // _PyLong_GetZero()
|
#include "pycore_long.h" // _PyLong_GetZero()
|
||||||
|
@ -27,8 +28,9 @@ class itertools.accumulate "accumulateobject *" "&accumulate_type"
|
||||||
class itertools.compress "compressobject *" "&compress_type"
|
class itertools.compress "compressobject *" "&compress_type"
|
||||||
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
|
class itertools.filterfalse "filterfalseobject *" "&filterfalse_type"
|
||||||
class itertools.count "countobject *" "&count_type"
|
class itertools.count "countobject *" "&count_type"
|
||||||
|
class itertools.pairwise "pairwiseobject *" "&pairwise_type"
|
||||||
[clinic start generated code]*/
|
[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 groupby_type;
|
||||||
static PyTypeObject _grouper_type;
|
static PyTypeObject _grouper_type;
|
||||||
|
@ -45,9 +47,140 @@ static PyTypeObject accumulate_type;
|
||||||
static PyTypeObject compress_type;
|
static PyTypeObject compress_type;
|
||||||
static PyTypeObject filterfalse_type;
|
static PyTypeObject filterfalse_type;
|
||||||
static PyTypeObject count_type;
|
static PyTypeObject count_type;
|
||||||
|
static PyTypeObject pairwise_type;
|
||||||
|
|
||||||
#include "clinic/itertoolsmodule.c.h"
|
#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 ************************************************************/
|
/* 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\
|
filterfalse(pred, seq) --> elements of seq where pred(elem) is False\n\
|
||||||
islice(seq, [start,] stop [, step]) --> elements from\n\
|
islice(seq, [start,] stop [, step]) --> elements from\n\
|
||||||
seq[start:stop:step]\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\
|
starmap(fun, seq) --> fun(*seq[0]), fun(*seq[1]), ...\n\
|
||||||
tee(it, n=2) --> (it1, it2 , ... itn) splits one iterator into n\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\
|
takewhile(pred, seq) --> seq[0], seq[1], until pred fails\n\
|
||||||
|
@ -4695,6 +4829,7 @@ itertoolsmodule_exec(PyObject *m)
|
||||||
&filterfalse_type,
|
&filterfalse_type,
|
||||||
&count_type,
|
&count_type,
|
||||||
&ziplongest_type,
|
&ziplongest_type,
|
||||||
|
&pairwise_type,
|
||||||
&permutations_type,
|
&permutations_type,
|
||||||
&product_type,
|
&product_type,
|
||||||
&repeat_type,
|
&repeat_type,
|
||||||
|
|
|
@ -342,7 +342,7 @@ static void
|
||||||
MD5_dealloc(PyObject *ptr)
|
MD5_dealloc(PyObject *ptr)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(ptr);
|
PyTypeObject *tp = Py_TYPE(ptr);
|
||||||
PyObject_Del(ptr);
|
PyObject_Free(ptr);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ oss_dealloc(oss_audio_t *self)
|
||||||
/* if already closed, don't reclose it */
|
/* if already closed, don't reclose it */
|
||||||
if (self->fd != -1)
|
if (self->fd != -1)
|
||||||
close(self->fd);
|
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 already closed, don't reclose it */
|
||||||
if (self->fd != -1)
|
if (self->fd != -1)
|
||||||
close(self->fd);
|
close(self->fd);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -722,7 +722,7 @@ Overlapped_dealloc(OverlappedObject *self)
|
||||||
SetLastError(olderr);
|
SetLastError(olderr);
|
||||||
|
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5480,7 +5480,7 @@ free_string_array(EXECV_CHAR **array, Py_ssize_t count)
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
PyMem_Free(array[i]);
|
PyMem_Free(array[i]);
|
||||||
PyMem_DEL(array);
|
PyMem_Free(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
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);
|
res = Py_BuildValue(_Py_PARSE_INTPTR, spawnval);
|
||||||
|
|
||||||
fail_2:
|
fail_2:
|
||||||
while (--envc >= 0)
|
while (--envc >= 0) {
|
||||||
PyMem_DEL(envlist[envc]);
|
PyMem_Free(envlist[envc]);
|
||||||
PyMem_DEL(envlist);
|
}
|
||||||
|
PyMem_Free(envlist);
|
||||||
fail_1:
|
fail_1:
|
||||||
free_string_array(argvlist, lastarg);
|
free_string_array(argvlist, lastarg);
|
||||||
fail_0:
|
fail_0:
|
||||||
|
@ -7444,7 +7445,7 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
|
||||||
|
|
||||||
list = PyList_New(ngroups);
|
list = PyList_New(ngroups);
|
||||||
if (list == NULL) {
|
if (list == NULL) {
|
||||||
PyMem_Del(groups);
|
PyMem_Free(groups);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7456,13 +7457,13 @@ os_getgrouplist_impl(PyObject *module, const char *user, gid_t basegid)
|
||||||
#endif
|
#endif
|
||||||
if (o == NULL) {
|
if (o == NULL) {
|
||||||
Py_DECREF(list);
|
Py_DECREF(list);
|
||||||
PyMem_Del(groups);
|
PyMem_Free(groups);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
PyList_SET_ITEM(list, i, o);
|
PyList_SET_ITEM(list, i, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_Del(groups);
|
PyMem_Free(groups);
|
||||||
|
|
||||||
return list;
|
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);
|
*buf = PyMem_New(Py_buffer, cnt);
|
||||||
if (*buf == NULL) {
|
if (*buf == NULL) {
|
||||||
PyMem_Del(*iov);
|
PyMem_Free(*iov);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -9427,11 +9428,11 @@ iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, Py_ssize_t cnt, in
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
PyMem_Del(*iov);
|
PyMem_Free(*iov);
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
PyBuffer_Release(&(*buf)[j]);
|
PyBuffer_Release(&(*buf)[j]);
|
||||||
}
|
}
|
||||||
PyMem_Del(*buf);
|
PyMem_Free(*buf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9439,11 +9440,11 @@ static void
|
||||||
iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
|
iov_cleanup(struct iovec *iov, Py_buffer *buf, int cnt)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
PyMem_Del(iov);
|
PyMem_Free(iov);
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
PyBuffer_Release(&buf[i]);
|
PyBuffer_Release(&buf[i]);
|
||||||
}
|
}
|
||||||
PyMem_Del(buf);
|
PyMem_Free(buf);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -12815,7 +12816,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
path_error(path);
|
path_error(path);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
buffer = PyMem_MALLOC(buffer_size);
|
buffer = PyMem_Malloc(buffer_size);
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
break;
|
break;
|
||||||
|
@ -12832,7 +12833,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
|
|
||||||
if (length < 0) {
|
if (length < 0) {
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
buffer = NULL;
|
buffer = NULL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -12870,7 +12871,7 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
}
|
}
|
||||||
exit:
|
exit:
|
||||||
if (buffer)
|
if (buffer)
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
#endif /* USE_XATTRS */
|
#endif /* USE_XATTRS */
|
||||||
|
|
|
@ -294,9 +294,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
|
||||||
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
||||||
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 1);
|
||||||
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
|
if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
|
||||||
if (rfd2obj) PyMem_DEL(rfd2obj);
|
if (rfd2obj) PyMem_Free(rfd2obj);
|
||||||
if (wfd2obj) PyMem_DEL(wfd2obj);
|
if (wfd2obj) PyMem_Free(wfd2obj);
|
||||||
if (efd2obj) PyMem_DEL(efd2obj);
|
if (efd2obj) PyMem_Free(efd2obj);
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
#endif /* SELECT_USES_HEAP */
|
#endif /* SELECT_USES_HEAP */
|
||||||
|
@ -381,9 +381,9 @@ select_select_impl(PyObject *module, PyObject *rlist, PyObject *wlist,
|
||||||
reap_obj(wfd2obj);
|
reap_obj(wfd2obj);
|
||||||
reap_obj(efd2obj);
|
reap_obj(efd2obj);
|
||||||
#ifdef SELECT_USES_HEAP
|
#ifdef SELECT_USES_HEAP
|
||||||
PyMem_DEL(rfd2obj);
|
PyMem_Free(rfd2obj);
|
||||||
PyMem_DEL(wfd2obj);
|
PyMem_Free(wfd2obj);
|
||||||
PyMem_DEL(efd2obj);
|
PyMem_Free(efd2obj);
|
||||||
#endif /* SELECT_USES_HEAP */
|
#endif /* SELECT_USES_HEAP */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -740,9 +740,9 @@ poll_dealloc(pollObject *self)
|
||||||
{
|
{
|
||||||
PyObject* type = (PyObject *)Py_TYPE(self);
|
PyObject* type = (PyObject *)Py_TYPE(self);
|
||||||
if (self->ufds != NULL)
|
if (self->ufds != NULL)
|
||||||
PyMem_DEL(self->ufds);
|
PyMem_Free(self->ufds);
|
||||||
Py_XDECREF(self->dict);
|
Py_XDECREF(self->dict);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1106,7 +1106,7 @@ newDevPollObject(PyObject *module)
|
||||||
self = PyObject_New(devpollObject, get_select_state(module)->devpoll_Type);
|
self = PyObject_New(devpollObject, get_select_state(module)->devpoll_Type);
|
||||||
if (self == NULL) {
|
if (self == NULL) {
|
||||||
close(fd_devpoll);
|
close(fd_devpoll);
|
||||||
PyMem_DEL(fds);
|
PyMem_Free(fds);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
self->fd_devpoll = fd_devpoll;
|
self->fd_devpoll = fd_devpoll;
|
||||||
|
@ -1129,8 +1129,8 @@ devpoll_dealloc(devpollObject *self)
|
||||||
{
|
{
|
||||||
PyObject *type = (PyObject *)Py_TYPE(self);
|
PyObject *type = (PyObject *)Py_TYPE(self);
|
||||||
(void)devpoll_internal_close(self);
|
(void)devpoll_internal_close(self);
|
||||||
PyMem_DEL(self->fds);
|
PyMem_Free(self->fds);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -320,7 +320,7 @@ static void
|
||||||
SHA1_dealloc(PyObject *ptr)
|
SHA1_dealloc(PyObject *ptr)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(ptr);
|
PyTypeObject *tp = Py_TYPE(ptr);
|
||||||
PyObject_Del(ptr);
|
PyObject_Free(ptr);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -397,7 +397,7 @@ static void
|
||||||
SHA_dealloc(PyObject *ptr)
|
SHA_dealloc(PyObject *ptr)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(ptr);
|
PyTypeObject *tp = Py_TYPE(ptr);
|
||||||
PyObject_Del(ptr);
|
PyObject_Free(ptr);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -453,7 +453,7 @@ static void
|
||||||
SHA512_dealloc(PyObject *ptr)
|
SHA512_dealloc(PyObject *ptr)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(ptr);
|
PyTypeObject *tp = Py_TYPE(ptr);
|
||||||
PyObject_Del(ptr);
|
PyObject_Free(ptr);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,11 @@ static volatile struct {
|
||||||
#else
|
#else
|
||||||
#define INVALID_FD (-1)
|
#define INVALID_FD (-1)
|
||||||
static volatile struct {
|
static volatile struct {
|
||||||
|
#ifdef __VXWORKS__
|
||||||
|
int fd;
|
||||||
|
#else
|
||||||
sig_atomic_t fd;
|
sig_atomic_t fd;
|
||||||
|
#endif
|
||||||
int warn_on_full_buffer;
|
int warn_on_full_buffer;
|
||||||
} wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1};
|
} wakeup = {.fd = INVALID_FD, .warn_on_full_buffer = 1};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -986,7 +986,7 @@ entrance:
|
||||||
ctx->pattern[1], ctx->pattern[2]));
|
ctx->pattern[1], ctx->pattern[2]));
|
||||||
|
|
||||||
/* install new repeat context */
|
/* 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) {
|
if (!ctx->u.rep) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
RETURN_FAILURE;
|
RETURN_FAILURE;
|
||||||
|
@ -1000,7 +1000,7 @@ entrance:
|
||||||
state->ptr = ctx->ptr;
|
state->ptr = ctx->ptr;
|
||||||
DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]);
|
DO_JUMP(JUMP_REPEAT, jump_repeat, ctx->pattern+ctx->pattern[0]);
|
||||||
state->repeat = ctx->u.rep->prev;
|
state->repeat = ctx->u.rep->prev;
|
||||||
PyObject_FREE(ctx->u.rep);
|
PyObject_Free(ctx->u.rep);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
RETURN_ON_ERROR(ret);
|
RETURN_ON_ERROR(ret);
|
||||||
|
|
|
@ -1418,7 +1418,7 @@ static void
|
||||||
ucd_dealloc(PreviousDBVersion *self)
|
ucd_dealloc(PreviousDBVersion *self)
|
||||||
{
|
{
|
||||||
PyTypeObject *tp = Py_TYPE(self);
|
PyTypeObject *tp = Py_TYPE(self);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(tp);
|
Py_DECREF(tp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ static void
|
||||||
Xxo_dealloc(XxoObject *self)
|
Xxo_dealloc(XxoObject *self)
|
||||||
{
|
{
|
||||||
Py_XDECREF(self->x_attr);
|
Py_XDECREF(self->x_attr);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -591,7 +591,7 @@ Dealloc(compobject *self)
|
||||||
Py_XDECREF(self->unused_data);
|
Py_XDECREF(self->unused_data);
|
||||||
Py_XDECREF(self->unconsumed_tail);
|
Py_XDECREF(self->unconsumed_tail);
|
||||||
Py_XDECREF(self->zdict);
|
Py_XDECREF(self->zdict);
|
||||||
PyObject_Del(self);
|
PyObject_Free(self);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ PyBytes_FromString(const char *str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inline PyObject_NewVar */
|
/* Inline PyObject_NewVar */
|
||||||
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size);
|
op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size);
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
@ -1475,7 +1475,7 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n)
|
||||||
"repeated bytes are too long");
|
"repeated bytes are too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + nbytes);
|
op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + nbytes);
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
@ -3054,9 +3054,9 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize)
|
||||||
_Py_ForgetReference(v);
|
_Py_ForgetReference(v);
|
||||||
#endif
|
#endif
|
||||||
*pv = (PyObject *)
|
*pv = (PyObject *)
|
||||||
PyObject_REALLOC(v, PyBytesObject_SIZE + newsize);
|
PyObject_Realloc(v, PyBytesObject_SIZE + newsize);
|
||||||
if (*pv == NULL) {
|
if (*pv == NULL) {
|
||||||
PyObject_Del(v);
|
PyObject_Free(v);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,7 +198,7 @@ PyCapsule_Import(const char *name, int no_block)
|
||||||
void *return_value = NULL;
|
void *return_value = NULL;
|
||||||
char *trace;
|
char *trace;
|
||||||
size_t name_length = (strlen(name) + 1) * sizeof(char);
|
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) {
|
if (!name_dup) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
@ -247,7 +247,7 @@ PyCapsule_Import(const char *name, int no_block)
|
||||||
EXIT:
|
EXIT:
|
||||||
Py_XDECREF(object);
|
Py_XDECREF(object);
|
||||||
if (name_dup) {
|
if (name_dup) {
|
||||||
PyMem_FREE(name_dup);
|
PyMem_Free(name_dup);
|
||||||
}
|
}
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ capsule_dealloc(PyObject *o)
|
||||||
if (capsule->destructor) {
|
if (capsule->destructor) {
|
||||||
capsule->destructor(o);
|
capsule->destructor(o);
|
||||||
}
|
}
|
||||||
PyObject_DEL(o);
|
PyObject_Free(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
|
||||||
PyObject *arg = PyTuple_GET_ITEM(varnames, j);
|
PyObject *arg = PyTuple_GET_ITEM(varnames, j);
|
||||||
int cmp = PyUnicode_Compare(cell, arg);
|
int cmp = PyUnicode_Compare(cell, arg);
|
||||||
if (cmp == -1 && PyErr_Occurred()) {
|
if (cmp == -1 && PyErr_Occurred()) {
|
||||||
PyMem_FREE(cell2arg);
|
PyMem_Free(cell2arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
|
@ -224,14 +224,14 @@ PyCode_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!used_cell2arg) {
|
if (!used_cell2arg) {
|
||||||
PyMem_FREE(cell2arg);
|
PyMem_Free(cell2arg);
|
||||||
cell2arg = NULL;
|
cell2arg = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
co = PyObject_New(PyCodeObject, &PyCode_Type);
|
co = PyObject_New(PyCodeObject, &PyCode_Type);
|
||||||
if (co == NULL) {
|
if (co == NULL) {
|
||||||
if (cell2arg)
|
if (cell2arg)
|
||||||
PyMem_FREE(cell2arg);
|
PyMem_Free(cell2arg);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
co->co_argcount = argcount;
|
co->co_argcount = argcount;
|
||||||
|
@ -314,12 +314,12 @@ _PyCode_InitOpcache(PyCodeObject *co)
|
||||||
if (opts) {
|
if (opts) {
|
||||||
co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache));
|
co->co_opcache = (_PyOpcache *)PyMem_Calloc(opts, sizeof(_PyOpcache));
|
||||||
if (co->co_opcache == NULL) {
|
if (co->co_opcache == NULL) {
|
||||||
PyMem_FREE(co->co_opcache_map);
|
PyMem_Free(co->co_opcache_map);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyMem_FREE(co->co_opcache_map);
|
PyMem_Free(co->co_opcache_map);
|
||||||
co->co_opcache_map = NULL;
|
co->co_opcache_map = NULL;
|
||||||
co->co_opcache = NULL;
|
co->co_opcache = NULL;
|
||||||
}
|
}
|
||||||
|
@ -631,10 +631,10 @@ static void
|
||||||
code_dealloc(PyCodeObject *co)
|
code_dealloc(PyCodeObject *co)
|
||||||
{
|
{
|
||||||
if (co->co_opcache != NULL) {
|
if (co->co_opcache != NULL) {
|
||||||
PyMem_FREE(co->co_opcache);
|
PyMem_Free(co->co_opcache);
|
||||||
}
|
}
|
||||||
if (co->co_opcache_map != NULL) {
|
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_flag = 0;
|
||||||
co->co_opcache_size = 0;
|
co->co_opcache_size = 0;
|
||||||
|
@ -664,12 +664,12 @@ code_dealloc(PyCodeObject *co)
|
||||||
Py_XDECREF(co->co_name);
|
Py_XDECREF(co->co_name);
|
||||||
Py_XDECREF(co->co_linetable);
|
Py_XDECREF(co->co_linetable);
|
||||||
if (co->co_cell2arg != NULL)
|
if (co->co_cell2arg != NULL)
|
||||||
PyMem_FREE(co->co_cell2arg);
|
PyMem_Free(co->co_cell2arg);
|
||||||
if (co->co_zombieframe != NULL)
|
if (co->co_zombieframe != NULL)
|
||||||
PyObject_GC_Del(co->co_zombieframe);
|
PyObject_GC_Del(co->co_zombieframe);
|
||||||
if (co->co_weakreflist != NULL)
|
if (co->co_weakreflist != NULL)
|
||||||
PyObject_ClearWeakRefs((PyObject*)co);
|
PyObject_ClearWeakRefs((PyObject*)co);
|
||||||
PyObject_DEL(co);
|
PyObject_Free(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -233,7 +233,7 @@ PyObject *
|
||||||
PyComplex_FromCComplex(Py_complex cval)
|
PyComplex_FromCComplex(Py_complex cval)
|
||||||
{
|
{
|
||||||
/* Inline PyObject_New */
|
/* Inline PyObject_New */
|
||||||
PyComplexObject *op = PyObject_MALLOC(sizeof(PyComplexObject));
|
PyComplexObject *op = PyObject_Malloc(sizeof(PyComplexObject));
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ _PyDict_ClearFreeList(PyThreadState *tstate)
|
||||||
PyObject_GC_Del(op);
|
PyObject_GC_Del(op);
|
||||||
}
|
}
|
||||||
while (state->keys_numfree) {
|
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
|
else
|
||||||
{
|
{
|
||||||
dk = PyObject_MALLOC(sizeof(PyDictKeysObject)
|
dk = PyObject_Malloc(sizeof(PyDictKeysObject)
|
||||||
+ es * size
|
+ es * size
|
||||||
+ sizeof(PyDictKeyEntry) * usable);
|
+ sizeof(PyDictKeyEntry) * usable);
|
||||||
if (dk == NULL) {
|
if (dk == NULL) {
|
||||||
|
@ -636,11 +636,11 @@ free_keys_object(PyDictKeysObject *keys)
|
||||||
state->keys_free_list[state->keys_numfree++] = keys;
|
state->keys_free_list[state->keys_numfree++] = keys;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PyObject_FREE(keys);
|
PyObject_Free(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define new_values(size) PyMem_NEW(PyObject *, size)
|
#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 */
|
/* Consumes a reference to the keys object */
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -1303,7 +1303,7 @@ dictresize(PyDictObject *mp, Py_ssize_t newsize)
|
||||||
state->keys_free_list[state->keys_numfree++] = oldkeys;
|
state->keys_free_list[state->keys_numfree++] = oldkeys;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PyObject_FREE(oldkeys);
|
PyObject_Free(oldkeys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ float_dealloc(PyFloatObject *op)
|
||||||
assert(state->numfree != -1);
|
assert(state->numfree != -1);
|
||||||
#endif
|
#endif
|
||||||
if (state->numfree >= PyFloat_MAXFREELIST) {
|
if (state->numfree >= PyFloat_MAXFREELIST) {
|
||||||
PyObject_FREE(op);
|
PyObject_Free(op);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
state->numfree++;
|
state->numfree++;
|
||||||
|
@ -2032,7 +2032,7 @@ _PyFloat_ClearFreeList(PyThreadState *tstate)
|
||||||
PyFloatObject *f = state->free_list;
|
PyFloatObject *f = state->free_list;
|
||||||
while (f != NULL) {
|
while (f != NULL) {
|
||||||
PyFloatObject *next = (PyFloatObject*) Py_TYPE(f);
|
PyFloatObject *next = (PyFloatObject*) Py_TYPE(f);
|
||||||
PyObject_FREE(f);
|
PyObject_Free(f);
|
||||||
f = next;
|
f = next;
|
||||||
}
|
}
|
||||||
state->free_list = NULL;
|
state->free_list = NULL;
|
||||||
|
|
|
@ -341,7 +341,7 @@ list_dealloc(PyListObject *op)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(op->ob_item[i]);
|
Py_XDECREF(op->ob_item[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(op->ob_item);
|
PyMem_Free(op->ob_item);
|
||||||
}
|
}
|
||||||
struct _Py_list_state *state = get_list_state();
|
struct _Py_list_state *state = get_list_state();
|
||||||
#ifdef Py_DEBUG
|
#ifdef Py_DEBUG
|
||||||
|
@ -592,7 +592,7 @@ _list_clear(PyListObject *a)
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(item[i]);
|
Py_XDECREF(item[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(item);
|
PyMem_Free(item);
|
||||||
}
|
}
|
||||||
/* Never fails; the return value can be ignored.
|
/* Never fails; the return value can be ignored.
|
||||||
Note that there is no guarantee that the list is actually empty
|
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 norig == 0, item might be NULL, in which case we may not memcpy from it. */
|
||||||
if (s) {
|
if (s) {
|
||||||
if (s > sizeof(recycle_on_stack)) {
|
if (s > sizeof(recycle_on_stack)) {
|
||||||
recycle = (PyObject **)PyMem_MALLOC(s);
|
recycle = (PyObject **)PyMem_Malloc(s);
|
||||||
if (recycle == NULL) {
|
if (recycle == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto Error;
|
goto Error;
|
||||||
|
@ -706,7 +706,7 @@ list_ass_slice(PyListObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v)
|
||||||
result = 0;
|
result = 0;
|
||||||
Error:
|
Error:
|
||||||
if (recycle != recycle_on_stack)
|
if (recycle != recycle_on_stack)
|
||||||
PyMem_FREE(recycle);
|
PyMem_Free(recycle);
|
||||||
Py_XDECREF(v_as_SF);
|
Py_XDECREF(v_as_SF);
|
||||||
return result;
|
return result;
|
||||||
#undef b
|
#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 */
|
/* Leverage stack space we allocated but won't otherwise use */
|
||||||
keys = &ms.temparray[saved_ob_size+1];
|
keys = &ms.temparray[saved_ob_size+1];
|
||||||
else {
|
else {
|
||||||
keys = PyMem_MALLOC(sizeof(PyObject *) * saved_ob_size);
|
keys = PyMem_Malloc(sizeof(PyObject *) * saved_ob_size);
|
||||||
if (keys == NULL) {
|
if (keys == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto keyfunc_fail;
|
goto keyfunc_fail;
|
||||||
|
@ -2243,7 +2243,7 @@ list_sort_impl(PyListObject *self, PyObject *keyfunc, int reverse)
|
||||||
for (i=i-1 ; i>=0 ; i--)
|
for (i=i-1 ; i>=0 ; i--)
|
||||||
Py_DECREF(keys[i]);
|
Py_DECREF(keys[i]);
|
||||||
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
||||||
PyMem_FREE(keys);
|
PyMem_Free(keys);
|
||||||
goto keyfunc_fail;
|
goto keyfunc_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2414,7 +2414,7 @@ fail:
|
||||||
for (i = 0; i < saved_ob_size; i++)
|
for (i = 0; i < saved_ob_size; i++)
|
||||||
Py_DECREF(keys[i]);
|
Py_DECREF(keys[i]);
|
||||||
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
if (saved_ob_size >= MERGESTATE_TEMP_SIZE/2)
|
||||||
PyMem_FREE(keys);
|
PyMem_Free(keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->allocated != -1 && result != NULL) {
|
if (self->allocated != -1 && result != NULL) {
|
||||||
|
@ -2442,7 +2442,7 @@ keyfunc_fail:
|
||||||
while (--i >= 0) {
|
while (--i >= 0) {
|
||||||
Py_XDECREF(final_ob_item[i]);
|
Py_XDECREF(final_ob_item[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(final_ob_item);
|
PyMem_Free(final_ob_item);
|
||||||
}
|
}
|
||||||
Py_XINCREF(result);
|
Py_XINCREF(result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -2908,7 +2908,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
}
|
}
|
||||||
|
|
||||||
garbage = (PyObject**)
|
garbage = (PyObject**)
|
||||||
PyMem_MALLOC(slicelength*sizeof(PyObject*));
|
PyMem_Malloc(slicelength*sizeof(PyObject*));
|
||||||
if (!garbage) {
|
if (!garbage) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -2949,7 +2949,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
for (i = 0; i < slicelength; i++) {
|
for (i = 0; i < slicelength; i++) {
|
||||||
Py_DECREF(garbage[i]);
|
Py_DECREF(garbage[i]);
|
||||||
}
|
}
|
||||||
PyMem_FREE(garbage);
|
PyMem_Free(garbage);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -2990,7 +2990,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
}
|
}
|
||||||
|
|
||||||
garbage = (PyObject**)
|
garbage = (PyObject**)
|
||||||
PyMem_MALLOC(slicelength*sizeof(PyObject*));
|
PyMem_Malloc(slicelength*sizeof(PyObject*));
|
||||||
if (!garbage) {
|
if (!garbage) {
|
||||||
Py_DECREF(seq);
|
Py_DECREF(seq);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -3011,7 +3011,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
|
||||||
Py_DECREF(garbage[i]);
|
Py_DECREF(garbage[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_FREE(garbage);
|
PyMem_Free(garbage);
|
||||||
Py_DECREF(seq);
|
Py_DECREF(seq);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -131,7 +131,7 @@ _PyLong_New(Py_ssize_t size)
|
||||||
"too many digits in integer");
|
"too many digits in integer");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
result = PyObject_MALLOC(offsetof(PyLongObject, ob_digit) +
|
result = PyObject_Malloc(offsetof(PyLongObject, ob_digit) +
|
||||||
size*sizeof(digit));
|
size*sizeof(digit));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
|
|
@ -211,7 +211,7 @@ _PyModule_CreateInitialized(struct PyModuleDef* module, int module_api_version)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (module->m_size > 0) {
|
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) {
|
if (!m->md_state) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
Py_DECREF(m);
|
Py_DECREF(m);
|
||||||
|
@ -377,7 +377,7 @@ PyModule_ExecDef(PyObject *module, PyModuleDef *def)
|
||||||
if (md->md_state == NULL) {
|
if (md->md_state == NULL) {
|
||||||
/* Always set a state pointer; this serves as a marker to skip
|
/* Always set a state pointer; this serves as a marker to skip
|
||||||
* multiple initialization (importlib.reload() is no-op) */
|
* 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) {
|
if (!md->md_state) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -681,7 +681,7 @@ module_dealloc(PyModuleObject *m)
|
||||||
Py_XDECREF(m->md_dict);
|
Py_XDECREF(m->md_dict);
|
||||||
Py_XDECREF(m->md_name);
|
Py_XDECREF(m->md_name);
|
||||||
if (m->md_state != NULL)
|
if (m->md_state != NULL)
|
||||||
PyMem_FREE(m->md_state);
|
PyMem_Free(m->md_state);
|
||||||
Py_TYPE(m)->tp_free((PyObject *)m);
|
Py_TYPE(m)->tp_free((PyObject *)m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size)
|
||||||
PyObject *
|
PyObject *
|
||||||
_PyObject_New(PyTypeObject *tp)
|
_PyObject_New(PyTypeObject *tp)
|
||||||
{
|
{
|
||||||
PyObject *op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp));
|
PyObject *op = (PyObject *) PyObject_Malloc(_PyObject_SIZE(tp));
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
@ -174,7 +174,7 @@ _PyObject_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
|
||||||
{
|
{
|
||||||
PyVarObject *op;
|
PyVarObject *op;
|
||||||
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
|
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
|
||||||
op = (PyVarObject *) PyObject_MALLOC(size);
|
op = (PyVarObject *) PyObject_Malloc(size);
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
return (PyVarObject *)PyErr_NoMemory();
|
return (PyVarObject *)PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
|
|
@ -459,7 +459,7 @@ later:
|
||||||
- implement a fuller MutableMapping API in C?
|
- implement a fuller MutableMapping API in C?
|
||||||
- move the MutableMapping implementation to abstract.c?
|
- move the MutableMapping implementation to abstract.c?
|
||||||
- optimize mutablemapping_update
|
- 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)
|
- 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),
|
i = _odict_get_index_raw(od, _odictnode_KEY(node),
|
||||||
_odictnode_HASH(node));
|
_odictnode_HASH(node));
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
PyMem_FREE(fast_nodes);
|
PyMem_Free(fast_nodes);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fast_nodes[i] = node;
|
fast_nodes[i] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Replace the old fast nodes table. */
|
/* 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 = fast_nodes;
|
||||||
od->od_fast_nodes_size = size;
|
od->od_fast_nodes_size = size;
|
||||||
od->od_resize_sentinel = ((PyDictObject *)od)->ma_keys;
|
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 */
|
/* must not be added yet */
|
||||||
node = (_ODictNode *)PyMem_MALLOC(sizeof(_ODictNode));
|
node = (_ODictNode *)PyMem_Malloc(sizeof(_ODictNode));
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
Py_DECREF(key);
|
Py_DECREF(key);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -701,7 +701,7 @@ _odict_add_new_node(PyODictObject *od, PyObject *key, Py_hash_t hash)
|
||||||
#define _odictnode_DEALLOC(node) \
|
#define _odictnode_DEALLOC(node) \
|
||||||
do { \
|
do { \
|
||||||
Py_DECREF(_odictnode_KEY(node)); \
|
Py_DECREF(_odictnode_KEY(node)); \
|
||||||
PyMem_FREE((void *)node); \
|
PyMem_Free((void *)node); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* Repeated calls on the same node are no-ops. */
|
/* Repeated calls on the same node are no-ops. */
|
||||||
|
@ -776,7 +776,7 @@ _odict_clear_nodes(PyODictObject *od)
|
||||||
{
|
{
|
||||||
_ODictNode *node, *next;
|
_ODictNode *node, *next;
|
||||||
|
|
||||||
PyMem_FREE(od->od_fast_nodes);
|
PyMem_Free(od->od_fast_nodes);
|
||||||
od->od_fast_nodes = NULL;
|
od->od_fast_nodes = NULL;
|
||||||
od->od_fast_nodes_size = 0;
|
od->od_fast_nodes_size = 0;
|
||||||
od->od_resize_sentinel = NULL;
|
od->od_resize_sentinel = NULL;
|
||||||
|
|
|
@ -171,7 +171,7 @@ range_dealloc(rangeobject *r)
|
||||||
Py_DECREF(r->stop);
|
Py_DECREF(r->stop);
|
||||||
Py_DECREF(r->step);
|
Py_DECREF(r->step);
|
||||||
Py_DECREF(r->length);
|
Py_DECREF(r->length);
|
||||||
PyObject_Del(r);
|
PyObject_Free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return number of items in range (lo, hi, step) as a PyLong object,
|
/* 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->start);
|
||||||
Py_XDECREF(r->step);
|
Py_XDECREF(r->step);
|
||||||
Py_XDECREF(r->len);
|
Py_XDECREF(r->len);
|
||||||
PyObject_Del(r);
|
PyObject_Free(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
|
@ -289,7 +289,7 @@ set_table_resize(PySetObject *so, Py_ssize_t minused)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_oldtable_malloced)
|
if (is_oldtable_malloced)
|
||||||
PyMem_DEL(oldtable);
|
PyMem_Free(oldtable);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ set_clear_internal(PySetObject *so)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (table_is_malloced)
|
if (table_is_malloced)
|
||||||
PyMem_DEL(table);
|
PyMem_Free(table);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +484,7 @@ set_dealloc(PySetObject *so)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (so->table != so->smalltable)
|
if (so->table != so->smalltable)
|
||||||
PyMem_DEL(so->table);
|
PyMem_Free(so->table);
|
||||||
Py_TYPE(so)->tp_free(so);
|
Py_TYPE(so)->tp_free(so);
|
||||||
Py_TRASHCAN_END
|
Py_TRASHCAN_END
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ done:
|
||||||
for (i = 0; i < nbufs; i++)
|
for (i = 0; i < nbufs; i++)
|
||||||
PyBuffer_Release(&buffers[i]);
|
PyBuffer_Release(&buffers[i]);
|
||||||
if (buffers != static_buffers)
|
if (buffers != static_buffers)
|
||||||
PyMem_FREE(buffers);
|
PyMem_Free(buffers);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -983,7 +983,7 @@ static void
|
||||||
formatteriter_dealloc(formatteriterobject *it)
|
formatteriter_dealloc(formatteriterobject *it)
|
||||||
{
|
{
|
||||||
Py_XDECREF(it->str);
|
Py_XDECREF(it->str);
|
||||||
PyObject_FREE(it);
|
PyObject_Free(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns a tuple:
|
/* returns a tuple:
|
||||||
|
@ -1147,7 +1147,7 @@ static void
|
||||||
fieldnameiter_dealloc(fieldnameiterobject *it)
|
fieldnameiter_dealloc(fieldnameiterobject *it)
|
||||||
{
|
{
|
||||||
Py_XDECREF(it->str);
|
Py_XDECREF(it->str);
|
||||||
PyObject_FREE(it);
|
PyObject_Free(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* returns a tuple:
|
/* returns a tuple:
|
||||||
|
|
|
@ -467,14 +467,14 @@ PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc *desc)
|
||||||
type->tp_members = members;
|
type->tp_members = members;
|
||||||
|
|
||||||
if (PyType_Ready(type) < 0) {
|
if (PyType_Ready(type) < 0) {
|
||||||
PyMem_FREE(members);
|
PyMem_Free(members);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Py_INCREF(type);
|
Py_INCREF(type);
|
||||||
|
|
||||||
if (initialize_structseq_dict(
|
if (initialize_structseq_dict(
|
||||||
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
desc, type->tp_dict, n_members, n_unnamed_members) < 0) {
|
||||||
PyMem_FREE(members);
|
PyMem_Free(members);
|
||||||
Py_DECREF(type);
|
Py_DECREF(type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -526,7 +526,7 @@ PyStructSequence_NewType(PyStructSequence_Desc *desc)
|
||||||
spec.slots = slots;
|
spec.slots = slots;
|
||||||
|
|
||||||
type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type);
|
type = (PyTypeObject *)PyType_FromSpecWithBases(&spec, (PyObject *)&PyTuple_Type);
|
||||||
PyMem_FREE(members);
|
PyMem_Free(members);
|
||||||
if (type == NULL) {
|
if (type == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1059,7 +1059,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
|
||||||
obj = _PyObject_GC_Malloc(size);
|
obj = _PyObject_GC_Malloc(size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
obj = (PyObject *)PyObject_MALLOC(size);
|
obj = (PyObject *)PyObject_Malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
|
@ -1779,7 +1779,7 @@ pmerge(PyObject *acc, PyObject **to_merge, Py_ssize_t to_merge_size)
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
PyMem_Del(remain);
|
PyMem_Free(remain);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1859,7 +1859,7 @@ mro_implementation(PyTypeObject *type)
|
||||||
|
|
||||||
result = PyList_New(1);
|
result = PyList_New(1);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
PyMem_Del(to_merge);
|
PyMem_Free(to_merge);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1869,7 +1869,7 @@ mro_implementation(PyTypeObject *type)
|
||||||
Py_CLEAR(result);
|
Py_CLEAR(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_Del(to_merge);
|
PyMem_Free(to_merge);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2707,7 +2707,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
|
||||||
goto error;
|
goto error;
|
||||||
/* Silently truncate the docstring if it contains null bytes. */
|
/* Silently truncate the docstring if it contains null bytes. */
|
||||||
len = strlen(doc_str);
|
len = strlen(doc_str);
|
||||||
tp_doc = (char *)PyObject_MALLOC(len + 1);
|
tp_doc = (char *)PyObject_Malloc(len + 1);
|
||||||
if (tp_doc == NULL) {
|
if (tp_doc == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -3047,7 +3047,7 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
size_t len = strlen(slot->pfunc)+1;
|
size_t len = strlen(slot->pfunc)+1;
|
||||||
char *tp_doc = PyObject_MALLOC(len);
|
char *tp_doc = PyObject_Malloc(len);
|
||||||
if (tp_doc == NULL) {
|
if (tp_doc == NULL) {
|
||||||
type->tp_doc = NULL;
|
type->tp_doc = NULL;
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
|
|
@ -1061,7 +1061,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
|
||||||
new_size = (struct_size + (length + 1) * char_size);
|
new_size = (struct_size + (length + 1) * char_size);
|
||||||
|
|
||||||
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
|
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
|
||||||
PyObject_DEL(_PyUnicode_UTF8(unicode));
|
PyObject_Free(_PyUnicode_UTF8(unicode));
|
||||||
_PyUnicode_UTF8(unicode) = NULL;
|
_PyUnicode_UTF8(unicode) = NULL;
|
||||||
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
||||||
}
|
}
|
||||||
|
@ -1072,7 +1072,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
|
||||||
_Py_ForgetReference(unicode);
|
_Py_ForgetReference(unicode);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
new_unicode = (PyObject *)PyObject_REALLOC(unicode, new_size);
|
new_unicode = (PyObject *)PyObject_Realloc(unicode, new_size);
|
||||||
if (new_unicode == NULL) {
|
if (new_unicode == NULL) {
|
||||||
_Py_NewReference(unicode);
|
_Py_NewReference(unicode);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -1088,7 +1088,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
|
||||||
_PyUnicode_WSTR_LENGTH(unicode) = length;
|
_PyUnicode_WSTR_LENGTH(unicode) = length;
|
||||||
}
|
}
|
||||||
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
|
else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
|
||||||
PyObject_DEL(_PyUnicode_WSTR(unicode));
|
PyObject_Free(_PyUnicode_WSTR(unicode));
|
||||||
_PyUnicode_WSTR(unicode) = NULL;
|
_PyUnicode_WSTR(unicode) = NULL;
|
||||||
if (!PyUnicode_IS_ASCII(unicode))
|
if (!PyUnicode_IS_ASCII(unicode))
|
||||||
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
_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))
|
if (!share_utf8 && _PyUnicode_HAS_UTF8_MEMORY(unicode))
|
||||||
{
|
{
|
||||||
PyObject_DEL(_PyUnicode_UTF8(unicode));
|
PyObject_Free(_PyUnicode_UTF8(unicode));
|
||||||
_PyUnicode_UTF8(unicode) = NULL;
|
_PyUnicode_UTF8(unicode) = NULL;
|
||||||
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = (PyObject *)PyObject_REALLOC(data, new_size);
|
data = (PyObject *)PyObject_Realloc(data, new_size);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1169,7 +1169,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
|
||||||
}
|
}
|
||||||
new_size = sizeof(wchar_t) * (length + 1);
|
new_size = sizeof(wchar_t) * (length + 1);
|
||||||
wstr = _PyUnicode_WSTR(unicode);
|
wstr = _PyUnicode_WSTR(unicode);
|
||||||
wstr = PyObject_REALLOC(wstr, new_size);
|
wstr = PyObject_Realloc(wstr, new_size);
|
||||||
if (!wstr) {
|
if (!wstr) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1259,7 +1259,7 @@ _PyUnicode_New(Py_ssize_t length)
|
||||||
_PyUnicode_UTF8(unicode) = NULL;
|
_PyUnicode_UTF8(unicode) = NULL;
|
||||||
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
_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)) {
|
if (!_PyUnicode_WSTR(unicode)) {
|
||||||
Py_DECREF(unicode);
|
Py_DECREF(unicode);
|
||||||
PyErr_NoMemory();
|
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
|
* PyObject_New() so we are able to allocate space for the object and
|
||||||
* it's data buffer.
|
* 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) {
|
if (obj == NULL) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
@ -1838,7 +1838,7 @@ _PyUnicode_Ready(PyObject *unicode)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (maxchar < 256) {
|
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)) {
|
if (!_PyUnicode_DATA_ANY(unicode)) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1859,7 +1859,7 @@ _PyUnicode_Ready(PyObject *unicode)
|
||||||
_PyUnicode_UTF8(unicode) = NULL;
|
_PyUnicode_UTF8(unicode) = NULL;
|
||||||
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
||||||
}
|
}
|
||||||
PyObject_FREE(_PyUnicode_WSTR(unicode));
|
PyObject_Free(_PyUnicode_WSTR(unicode));
|
||||||
_PyUnicode_WSTR(unicode) = NULL;
|
_PyUnicode_WSTR(unicode) = NULL;
|
||||||
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
||||||
}
|
}
|
||||||
|
@ -1879,7 +1879,7 @@ _PyUnicode_Ready(PyObject *unicode)
|
||||||
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
||||||
#else
|
#else
|
||||||
/* sizeof(wchar_t) == 4 */
|
/* sizeof(wchar_t) == 4 */
|
||||||
_PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(
|
_PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(
|
||||||
2 * (_PyUnicode_WSTR_LENGTH(unicode) + 1));
|
2 * (_PyUnicode_WSTR_LENGTH(unicode) + 1));
|
||||||
if (!_PyUnicode_DATA_ANY(unicode)) {
|
if (!_PyUnicode_DATA_ANY(unicode)) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -1893,7 +1893,7 @@ _PyUnicode_Ready(PyObject *unicode)
|
||||||
_PyUnicode_STATE(unicode).kind = PyUnicode_2BYTE_KIND;
|
_PyUnicode_STATE(unicode).kind = PyUnicode_2BYTE_KIND;
|
||||||
_PyUnicode_UTF8(unicode) = NULL;
|
_PyUnicode_UTF8(unicode) = NULL;
|
||||||
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
_PyUnicode_UTF8_LENGTH(unicode) = 0;
|
||||||
PyObject_FREE(_PyUnicode_WSTR(unicode));
|
PyObject_Free(_PyUnicode_WSTR(unicode));
|
||||||
_PyUnicode_WSTR(unicode) = NULL;
|
_PyUnicode_WSTR(unicode) = NULL;
|
||||||
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1908,7 +1908,7 @@ _PyUnicode_Ready(PyObject *unicode)
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
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)) {
|
if (!_PyUnicode_DATA_ANY(unicode)) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1920,7 +1920,7 @@ _PyUnicode_Ready(PyObject *unicode)
|
||||||
/* unicode_convert_wchar_to_ucs4() requires a ready string */
|
/* unicode_convert_wchar_to_ucs4() requires a ready string */
|
||||||
_PyUnicode_STATE(unicode).ready = 1;
|
_PyUnicode_STATE(unicode).ready = 1;
|
||||||
unicode_convert_wchar_to_ucs4(_PyUnicode_WSTR(unicode), end, unicode);
|
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(unicode) = NULL;
|
||||||
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
_PyUnicode_WSTR_LENGTH(unicode) = 0;
|
||||||
#else
|
#else
|
||||||
|
@ -1973,13 +1973,13 @@ unicode_dealloc(PyObject *unicode)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
|
if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) {
|
||||||
PyObject_DEL(_PyUnicode_WSTR(unicode));
|
PyObject_Free(_PyUnicode_WSTR(unicode));
|
||||||
}
|
}
|
||||||
if (_PyUnicode_HAS_UTF8_MEMORY(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)) {
|
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);
|
Py_TYPE(unicode)->tp_free(unicode);
|
||||||
|
@ -3298,7 +3298,7 @@ PyUnicode_AsWideCharString(PyObject *unicode,
|
||||||
*size = buflen;
|
*size = buflen;
|
||||||
}
|
}
|
||||||
else if (wcslen(buffer) != (size_t)buflen) {
|
else if (wcslen(buffer) != (size_t)buflen) {
|
||||||
PyMem_FREE(buffer);
|
PyMem_Free(buffer);
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"embedded null character");
|
"embedded null character");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -4199,7 +4199,7 @@ PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size)
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
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) {
|
if (w == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -5627,7 +5627,7 @@ unicode_fill_utf8(PyObject *unicode)
|
||||||
PyBytes_AS_STRING(writer.buffer);
|
PyBytes_AS_STRING(writer.buffer);
|
||||||
Py_ssize_t len = end - start;
|
Py_ssize_t len = end - start;
|
||||||
|
|
||||||
char *cache = PyObject_MALLOC(len + 1);
|
char *cache = PyObject_Malloc(len + 1);
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
_PyBytesWriter_Dealloc(&writer);
|
_PyBytesWriter_Dealloc(&writer);
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
|
@ -8544,7 +8544,7 @@ PyUnicode_BuildEncodingMap(PyObject* string)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a three-level trie */
|
/* Create a three-level trie */
|
||||||
result = PyObject_MALLOC(sizeof(struct encoding_map) +
|
result = PyObject_Malloc(sizeof(struct encoding_map) +
|
||||||
16*count2 + 128*count3 - 1);
|
16*count2 + 128*count3 - 1);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
|
@ -10211,7 +10211,7 @@ case_operation(PyObject *self,
|
||||||
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
PyErr_SetString(PyExc_OverflowError, "string is too long");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
tmp = PyMem_MALLOC(sizeof(Py_UCS4) * 3 * length);
|
tmp = PyMem_Malloc(sizeof(Py_UCS4) * 3 * length);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
newlength = perform(kind, data, length, tmp, &maxchar);
|
newlength = perform(kind, data, length, tmp, &maxchar);
|
||||||
|
@ -10235,7 +10235,7 @@ case_operation(PyObject *self,
|
||||||
Py_UNREACHABLE();
|
Py_UNREACHABLE();
|
||||||
}
|
}
|
||||||
leave:
|
leave:
|
||||||
PyMem_FREE(tmp);
|
PyMem_Free(tmp);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11050,11 +11050,11 @@ replace(PyObject *self, PyObject *str1,
|
||||||
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
||||||
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
||||||
if (srelease)
|
if (srelease)
|
||||||
PyMem_FREE((void *)sbuf);
|
PyMem_Free((void *)sbuf);
|
||||||
if (release1)
|
if (release1)
|
||||||
PyMem_FREE((void *)buf1);
|
PyMem_Free((void *)buf1);
|
||||||
if (release2)
|
if (release2)
|
||||||
PyMem_FREE((void *)buf2);
|
PyMem_Free((void *)buf2);
|
||||||
assert(_PyUnicode_CheckConsistency(u, 1));
|
assert(_PyUnicode_CheckConsistency(u, 1));
|
||||||
return u;
|
return u;
|
||||||
|
|
||||||
|
@ -11064,11 +11064,11 @@ replace(PyObject *self, PyObject *str1,
|
||||||
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
||||||
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
||||||
if (srelease)
|
if (srelease)
|
||||||
PyMem_FREE((void *)sbuf);
|
PyMem_Free((void *)sbuf);
|
||||||
if (release1)
|
if (release1)
|
||||||
PyMem_FREE((void *)buf1);
|
PyMem_Free((void *)buf1);
|
||||||
if (release2)
|
if (release2)
|
||||||
PyMem_FREE((void *)buf2);
|
PyMem_Free((void *)buf2);
|
||||||
return unicode_result_unchanged(self);
|
return unicode_result_unchanged(self);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
@ -11076,11 +11076,11 @@ replace(PyObject *self, PyObject *str1,
|
||||||
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
assert(release1 == (buf1 != PyUnicode_DATA(str1)));
|
||||||
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
assert(release2 == (buf2 != PyUnicode_DATA(str2)));
|
||||||
if (srelease)
|
if (srelease)
|
||||||
PyMem_FREE((void *)sbuf);
|
PyMem_Free((void *)sbuf);
|
||||||
if (release1)
|
if (release1)
|
||||||
PyMem_FREE((void *)buf1);
|
PyMem_Free((void *)buf1);
|
||||||
if (release2)
|
if (release2)
|
||||||
PyMem_FREE((void *)buf2);
|
PyMem_Free((void *)buf2);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15567,7 +15567,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *unicode)
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto onError;
|
goto onError;
|
||||||
}
|
}
|
||||||
data = PyObject_MALLOC((length + 1) * char_size);
|
data = PyObject_Malloc((length + 1) * char_size);
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
goto onError;
|
goto onError;
|
||||||
|
|
|
@ -351,7 +351,7 @@ msiobj_dealloc(msiobj* msidb)
|
||||||
{
|
{
|
||||||
MsiCloseHandle(msidb->h);
|
MsiCloseHandle(msidb->h);
|
||||||
msidb->h = 0;
|
msidb->h = 0;
|
||||||
PyObject_Del(msidb);
|
PyObject_Free(msidb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
|
|
|
@ -145,7 +145,7 @@ PyHKEY_deallocFunc(PyObject *ob)
|
||||||
PyHKEYObject *obkey = (PyHKEYObject *)ob;
|
PyHKEYObject *obkey = (PyHKEYObject *)ob;
|
||||||
if (obkey->hkey)
|
if (obkey->hkey)
|
||||||
RegCloseKey((HKEY)obkey->hkey);
|
RegCloseKey((HKEY)obkey->hkey);
|
||||||
PyObject_DEL(ob);
|
PyObject_Free(ob);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -459,7 +459,7 @@ PyObject *
|
||||||
PyHKEY_FromHKEY(HKEY h)
|
PyHKEY_FromHKEY(HKEY h)
|
||||||
{
|
{
|
||||||
/* Inline PyObject_New */
|
/* Inline PyObject_New */
|
||||||
PyHKEYObject *op = (PyHKEYObject *) PyObject_MALLOC(sizeof(PyHKEYObject));
|
PyHKEYObject *op = (PyHKEYObject *) PyObject_Malloc(sizeof(PyHKEYObject));
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
|
@ -1818,7 +1818,7 @@ winreg_SetValueEx_impl(PyObject *module, HKEY key,
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
rc = RegSetValueExW(key, value_name, 0, type, data, len);
|
rc = RegSetValueExW(key, value_name, 0, type, data, len);
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
PyMem_DEL(data);
|
PyMem_Free(data);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
return PyErr_SetFromWindowsErrWithFunction(rc,
|
return PyErr_SetFromWindowsErrWithFunction(rc,
|
||||||
"RegSetValueEx");
|
"RegSetValueEx");
|
||||||
|
|
188
Parser/parser.c
188
Parser/parser.c
|
@ -75,8 +75,8 @@ static KeywordToken *reserved_keywords[] = {
|
||||||
#define statements_type 1006
|
#define statements_type 1006
|
||||||
#define statement_type 1007
|
#define statement_type 1007
|
||||||
#define statement_newline_type 1008
|
#define statement_newline_type 1008
|
||||||
#define simple_stmt_type 1009
|
#define simple_stmts_type 1009
|
||||||
#define small_stmt_type 1010
|
#define simple_stmt_type 1010
|
||||||
#define compound_stmt_type 1011
|
#define compound_stmt_type 1011
|
||||||
#define assignment_type 1012
|
#define assignment_type 1012
|
||||||
#define augassign_type 1013
|
#define augassign_type 1013
|
||||||
|
@ -391,8 +391,8 @@ static asdl_expr_seq* type_expressions_rule(Parser *p);
|
||||||
static asdl_stmt_seq* statements_rule(Parser *p);
|
static asdl_stmt_seq* statements_rule(Parser *p);
|
||||||
static asdl_stmt_seq* statement_rule(Parser *p);
|
static asdl_stmt_seq* statement_rule(Parser *p);
|
||||||
static asdl_stmt_seq* statement_newline_rule(Parser *p);
|
static asdl_stmt_seq* statement_newline_rule(Parser *p);
|
||||||
static asdl_stmt_seq* simple_stmt_rule(Parser *p);
|
static asdl_stmt_seq* simple_stmts_rule(Parser *p);
|
||||||
static stmt_ty small_stmt_rule(Parser *p);
|
static stmt_ty simple_stmt_rule(Parser *p);
|
||||||
static stmt_ty compound_stmt_rule(Parser *p);
|
static stmt_ty compound_stmt_rule(Parser *p);
|
||||||
static stmt_ty assignment_rule(Parser *p);
|
static stmt_ty assignment_rule(Parser *p);
|
||||||
static AugOperator* augassign_rule(Parser *p);
|
static AugOperator* augassign_rule(Parser *p);
|
||||||
|
@ -1213,7 +1213,7 @@ statements_rule(Parser *p)
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// statement: compound_stmt | simple_stmt
|
// statement: compound_stmt | simple_stmts
|
||||||
static asdl_stmt_seq*
|
static asdl_stmt_seq*
|
||||||
statement_rule(Parser *p)
|
statement_rule(Parser *p)
|
||||||
{
|
{
|
||||||
|
@ -1248,18 +1248,18 @@ statement_rule(Parser *p)
|
||||||
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt"));
|
||||||
}
|
}
|
||||||
{ // simple_stmt
|
{ // simple_stmts
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
|
D(fprintf(stderr, "%*c> statement[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
|
||||||
asdl_stmt_seq* a;
|
asdl_stmt_seq* a;
|
||||||
if (
|
if (
|
||||||
(a = (asdl_stmt_seq*)simple_stmt_rule(p)) // simple_stmt
|
(a = (asdl_stmt_seq*)simple_stmts_rule(p)) // simple_stmts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
|
D(fprintf(stderr, "%*c+ statement[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
|
||||||
_res = a;
|
_res = a;
|
||||||
if (_res == NULL && PyErr_Occurred()) {
|
if (_res == NULL && PyErr_Occurred()) {
|
||||||
p->error_indicator = 1;
|
p->error_indicator = 1;
|
||||||
|
@ -1270,7 +1270,7 @@ statement_rule(Parser *p)
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s statement[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
|
||||||
}
|
}
|
||||||
_res = NULL;
|
_res = NULL;
|
||||||
done:
|
done:
|
||||||
|
@ -1278,7 +1278,7 @@ statement_rule(Parser *p)
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// statement_newline: compound_stmt NEWLINE | simple_stmt | NEWLINE | $
|
// statement_newline: compound_stmt NEWLINE | simple_stmts | NEWLINE | $
|
||||||
static asdl_stmt_seq*
|
static asdl_stmt_seq*
|
||||||
statement_newline_rule(Parser *p)
|
statement_newline_rule(Parser *p)
|
||||||
{
|
{
|
||||||
|
@ -1325,24 +1325,24 @@ statement_newline_rule(Parser *p)
|
||||||
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "compound_stmt NEWLINE"));
|
||||||
}
|
}
|
||||||
{ // simple_stmt
|
{ // simple_stmts
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
|
D(fprintf(stderr, "%*c> statement_newline[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
|
||||||
asdl_stmt_seq* simple_stmt_var;
|
asdl_stmt_seq* simple_stmts_var;
|
||||||
if (
|
if (
|
||||||
(simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
|
(simple_stmts_var = simple_stmts_rule(p)) // simple_stmts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
|
D(fprintf(stderr, "%*c+ statement_newline[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
|
||||||
_res = simple_stmt_var;
|
_res = simple_stmts_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s statement_newline[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
|
||||||
}
|
}
|
||||||
{ // NEWLINE
|
{ // NEWLINE
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
|
@ -1407,9 +1407,9 @@ statement_newline_rule(Parser *p)
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// simple_stmt: small_stmt !';' NEWLINE | ';'.small_stmt+ ';'? NEWLINE
|
// simple_stmts: simple_stmt !';' NEWLINE | ';'.simple_stmt+ ';'? NEWLINE
|
||||||
static asdl_stmt_seq*
|
static asdl_stmt_seq*
|
||||||
simple_stmt_rule(Parser *p)
|
simple_stmts_rule(Parser *p)
|
||||||
{
|
{
|
||||||
D(p->level++);
|
D(p->level++);
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
|
@ -1418,23 +1418,23 @@ simple_stmt_rule(Parser *p)
|
||||||
}
|
}
|
||||||
asdl_stmt_seq* _res = NULL;
|
asdl_stmt_seq* _res = NULL;
|
||||||
int _mark = p->mark;
|
int _mark = p->mark;
|
||||||
{ // small_stmt !';' NEWLINE
|
{ // simple_stmt !';' NEWLINE
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
|
D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE"));
|
||||||
stmt_ty a;
|
stmt_ty a;
|
||||||
Token * newline_var;
|
Token * newline_var;
|
||||||
if (
|
if (
|
||||||
(a = small_stmt_rule(p)) // small_stmt
|
(a = simple_stmt_rule(p)) // simple_stmt
|
||||||
&&
|
&&
|
||||||
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
|
_PyPegen_lookahead_with_int(0, _PyPegen_expect_token, p, 13) // token=';'
|
||||||
&&
|
&&
|
||||||
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt !';' NEWLINE"));
|
D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt !';' NEWLINE"));
|
||||||
_res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a );
|
_res = ( asdl_stmt_seq * ) _PyPegen_singleton_seq ( p , a );
|
||||||
if (_res == NULL && PyErr_Occurred()) {
|
if (_res == NULL && PyErr_Occurred()) {
|
||||||
p->error_indicator = 1;
|
p->error_indicator = 1;
|
||||||
|
@ -1444,28 +1444,28 @@ simple_stmt_rule(Parser *p)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt !';' NEWLINE"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt !';' NEWLINE"));
|
||||||
}
|
}
|
||||||
{ // ';'.small_stmt+ ';'? NEWLINE
|
{ // ';'.simple_stmt+ ';'? NEWLINE
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
|
D(fprintf(stderr, "%*c> simple_stmts[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
|
||||||
void *_opt_var;
|
void *_opt_var;
|
||||||
UNUSED(_opt_var); // Silence compiler warnings
|
UNUSED(_opt_var); // Silence compiler warnings
|
||||||
asdl_stmt_seq* a;
|
asdl_stmt_seq* a;
|
||||||
Token * newline_var;
|
Token * newline_var;
|
||||||
if (
|
if (
|
||||||
(a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.small_stmt+
|
(a = (asdl_stmt_seq*)_gather_12_rule(p)) // ';'.simple_stmt+
|
||||||
&&
|
&&
|
||||||
(_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
|
(_opt_var = _PyPegen_expect_token(p, 13), 1) // ';'?
|
||||||
&&
|
&&
|
||||||
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
(newline_var = _PyPegen_expect_token(p, NEWLINE)) // token='NEWLINE'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
|
D(fprintf(stderr, "%*c+ simple_stmts[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
|
||||||
_res = a;
|
_res = a;
|
||||||
if (_res == NULL && PyErr_Occurred()) {
|
if (_res == NULL && PyErr_Occurred()) {
|
||||||
p->error_indicator = 1;
|
p->error_indicator = 1;
|
||||||
|
@ -1475,8 +1475,8 @@ simple_stmt_rule(Parser *p)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmts[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.small_stmt+ ';'? NEWLINE"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';'.simple_stmt+ ';'? NEWLINE"));
|
||||||
}
|
}
|
||||||
_res = NULL;
|
_res = NULL;
|
||||||
done:
|
done:
|
||||||
|
@ -1484,7 +1484,7 @@ simple_stmt_rule(Parser *p)
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// small_stmt:
|
// simple_stmt:
|
||||||
// | assignment
|
// | assignment
|
||||||
// | star_expressions
|
// | star_expressions
|
||||||
// | &'return' return_stmt
|
// | &'return' return_stmt
|
||||||
|
@ -1499,7 +1499,7 @@ simple_stmt_rule(Parser *p)
|
||||||
// | &'global' global_stmt
|
// | &'global' global_stmt
|
||||||
// | &'nonlocal' nonlocal_stmt
|
// | &'nonlocal' nonlocal_stmt
|
||||||
static stmt_ty
|
static stmt_ty
|
||||||
small_stmt_rule(Parser *p)
|
simple_stmt_rule(Parser *p)
|
||||||
{
|
{
|
||||||
D(p->level++);
|
D(p->level++);
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
|
@ -1507,7 +1507,7 @@ small_stmt_rule(Parser *p)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
stmt_ty _res = NULL;
|
stmt_ty _res = NULL;
|
||||||
if (_PyPegen_is_memoized(p, small_stmt_type, &_res)) {
|
if (_PyPegen_is_memoized(p, simple_stmt_type, &_res)) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
@ -1526,18 +1526,18 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "assignment"));
|
||||||
stmt_ty assignment_var;
|
stmt_ty assignment_var;
|
||||||
if (
|
if (
|
||||||
(assignment_var = assignment_rule(p)) // assignment
|
(assignment_var = assignment_rule(p)) // assignment
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "assignment"));
|
||||||
_res = assignment_var;
|
_res = assignment_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "assignment"));
|
||||||
}
|
}
|
||||||
{ // star_expressions
|
{ // star_expressions
|
||||||
|
@ -1545,13 +1545,13 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "star_expressions"));
|
||||||
expr_ty e;
|
expr_ty e;
|
||||||
if (
|
if (
|
||||||
(e = star_expressions_rule(p)) // star_expressions
|
(e = star_expressions_rule(p)) // star_expressions
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "star_expressions"));
|
||||||
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
||||||
if (_token == NULL) {
|
if (_token == NULL) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
|
@ -1570,7 +1570,7 @@ small_stmt_rule(Parser *p)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "star_expressions"));
|
||||||
}
|
}
|
||||||
{ // &'return' return_stmt
|
{ // &'return' return_stmt
|
||||||
|
@ -1578,7 +1578,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
|
||||||
stmt_ty return_stmt_var;
|
stmt_ty return_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 500) // token='return'
|
||||||
|
@ -1586,12 +1586,12 @@ small_stmt_rule(Parser *p)
|
||||||
(return_stmt_var = return_stmt_rule(p)) // return_stmt
|
(return_stmt_var = return_stmt_rule(p)) // return_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'return' return_stmt"));
|
||||||
_res = return_stmt_var;
|
_res = return_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'return' return_stmt"));
|
||||||
}
|
}
|
||||||
{ // &('import' | 'from') import_stmt
|
{ // &('import' | 'from') import_stmt
|
||||||
|
@ -1599,7 +1599,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
|
||||||
stmt_ty import_stmt_var;
|
stmt_ty import_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead(1, _tmp_14_rule, p)
|
_PyPegen_lookahead(1, _tmp_14_rule, p)
|
||||||
|
@ -1607,12 +1607,12 @@ small_stmt_rule(Parser *p)
|
||||||
(import_stmt_var = import_stmt_rule(p)) // import_stmt
|
(import_stmt_var = import_stmt_rule(p)) // import_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&('import' | 'from') import_stmt"));
|
||||||
_res = import_stmt_var;
|
_res = import_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&('import' | 'from') import_stmt"));
|
||||||
}
|
}
|
||||||
{ // &'raise' raise_stmt
|
{ // &'raise' raise_stmt
|
||||||
|
@ -1620,7 +1620,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
|
||||||
stmt_ty raise_stmt_var;
|
stmt_ty raise_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 501) // token='raise'
|
||||||
|
@ -1628,12 +1628,12 @@ small_stmt_rule(Parser *p)
|
||||||
(raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
|
(raise_stmt_var = raise_stmt_rule(p)) // raise_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'raise' raise_stmt"));
|
||||||
_res = raise_stmt_var;
|
_res = raise_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'raise' raise_stmt"));
|
||||||
}
|
}
|
||||||
{ // 'pass'
|
{ // 'pass'
|
||||||
|
@ -1641,13 +1641,13 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'pass'"));
|
||||||
Token * _keyword;
|
Token * _keyword;
|
||||||
if (
|
if (
|
||||||
(_keyword = _PyPegen_expect_token(p, 502)) // token='pass'
|
(_keyword = _PyPegen_expect_token(p, 502)) // token='pass'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'pass'"));
|
||||||
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
||||||
if (_token == NULL) {
|
if (_token == NULL) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
|
@ -1666,7 +1666,7 @@ small_stmt_rule(Parser *p)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'pass'"));
|
||||||
}
|
}
|
||||||
{ // &'del' del_stmt
|
{ // &'del' del_stmt
|
||||||
|
@ -1674,7 +1674,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
|
||||||
stmt_ty del_stmt_var;
|
stmt_ty del_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 503) // token='del'
|
||||||
|
@ -1682,12 +1682,12 @@ small_stmt_rule(Parser *p)
|
||||||
(del_stmt_var = del_stmt_rule(p)) // del_stmt
|
(del_stmt_var = del_stmt_rule(p)) // del_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'del' del_stmt"));
|
||||||
_res = del_stmt_var;
|
_res = del_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'del' del_stmt"));
|
||||||
}
|
}
|
||||||
{ // &'yield' yield_stmt
|
{ // &'yield' yield_stmt
|
||||||
|
@ -1695,7 +1695,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
|
||||||
stmt_ty yield_stmt_var;
|
stmt_ty yield_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 504) // token='yield'
|
||||||
|
@ -1703,12 +1703,12 @@ small_stmt_rule(Parser *p)
|
||||||
(yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
|
(yield_stmt_var = yield_stmt_rule(p)) // yield_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'yield' yield_stmt"));
|
||||||
_res = yield_stmt_var;
|
_res = yield_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'yield' yield_stmt"));
|
||||||
}
|
}
|
||||||
{ // &'assert' assert_stmt
|
{ // &'assert' assert_stmt
|
||||||
|
@ -1716,7 +1716,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
|
||||||
stmt_ty assert_stmt_var;
|
stmt_ty assert_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 505) // token='assert'
|
||||||
|
@ -1724,12 +1724,12 @@ small_stmt_rule(Parser *p)
|
||||||
(assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
|
(assert_stmt_var = assert_stmt_rule(p)) // assert_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'assert' assert_stmt"));
|
||||||
_res = assert_stmt_var;
|
_res = assert_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'assert' assert_stmt"));
|
||||||
}
|
}
|
||||||
{ // 'break'
|
{ // 'break'
|
||||||
|
@ -1737,13 +1737,13 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'break'"));
|
||||||
Token * _keyword;
|
Token * _keyword;
|
||||||
if (
|
if (
|
||||||
(_keyword = _PyPegen_expect_token(p, 506)) // token='break'
|
(_keyword = _PyPegen_expect_token(p, 506)) // token='break'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'break'"));
|
||||||
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
||||||
if (_token == NULL) {
|
if (_token == NULL) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
|
@ -1762,7 +1762,7 @@ small_stmt_rule(Parser *p)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'break'"));
|
||||||
}
|
}
|
||||||
{ // 'continue'
|
{ // 'continue'
|
||||||
|
@ -1770,13 +1770,13 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "'continue'"));
|
||||||
Token * _keyword;
|
Token * _keyword;
|
||||||
if (
|
if (
|
||||||
(_keyword = _PyPegen_expect_token(p, 507)) // token='continue'
|
(_keyword = _PyPegen_expect_token(p, 507)) // token='continue'
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'continue'"));
|
||||||
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
Token *_token = _PyPegen_get_last_nonnwhitespace_token(p);
|
||||||
if (_token == NULL) {
|
if (_token == NULL) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
|
@ -1795,7 +1795,7 @@ small_stmt_rule(Parser *p)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "'continue'"));
|
||||||
}
|
}
|
||||||
{ // &'global' global_stmt
|
{ // &'global' global_stmt
|
||||||
|
@ -1803,7 +1803,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
|
||||||
stmt_ty global_stmt_var;
|
stmt_ty global_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 508) // token='global'
|
||||||
|
@ -1811,12 +1811,12 @@ small_stmt_rule(Parser *p)
|
||||||
(global_stmt_var = global_stmt_rule(p)) // global_stmt
|
(global_stmt_var = global_stmt_rule(p)) // global_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'global' global_stmt"));
|
||||||
_res = global_stmt_var;
|
_res = global_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'global' global_stmt"));
|
||||||
}
|
}
|
||||||
{ // &'nonlocal' nonlocal_stmt
|
{ // &'nonlocal' nonlocal_stmt
|
||||||
|
@ -1824,7 +1824,7 @@ small_stmt_rule(Parser *p)
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> small_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
|
D(fprintf(stderr, "%*c> simple_stmt[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
|
||||||
stmt_ty nonlocal_stmt_var;
|
stmt_ty nonlocal_stmt_var;
|
||||||
if (
|
if (
|
||||||
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
|
_PyPegen_lookahead_with_int(1, _PyPegen_expect_token, p, 509) // token='nonlocal'
|
||||||
|
@ -1832,17 +1832,17 @@ small_stmt_rule(Parser *p)
|
||||||
(nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
|
(nonlocal_stmt_var = nonlocal_stmt_rule(p)) // nonlocal_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ small_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
|
D(fprintf(stderr, "%*c+ simple_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
|
||||||
_res = nonlocal_stmt_var;
|
_res = nonlocal_stmt_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s small_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s simple_stmt[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "&'nonlocal' nonlocal_stmt"));
|
||||||
}
|
}
|
||||||
_res = NULL;
|
_res = NULL;
|
||||||
done:
|
done:
|
||||||
_PyPegen_insert_memo(p, _mark, small_stmt_type, _res);
|
_PyPegen_insert_memo(p, _mark, simple_stmt_type, _res);
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
@ -6235,7 +6235,7 @@ class_def_raw_rule(Parser *p)
|
||||||
return _res;
|
return _res;
|
||||||
}
|
}
|
||||||
|
|
||||||
// block: NEWLINE INDENT statements DEDENT | simple_stmt | invalid_block
|
// block: NEWLINE INDENT statements DEDENT | simple_stmts | invalid_block
|
||||||
static asdl_stmt_seq*
|
static asdl_stmt_seq*
|
||||||
block_rule(Parser *p)
|
block_rule(Parser *p)
|
||||||
{
|
{
|
||||||
|
@ -6283,24 +6283,24 @@ block_rule(Parser *p)
|
||||||
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "NEWLINE INDENT statements DEDENT"));
|
||||||
}
|
}
|
||||||
{ // simple_stmt
|
{ // simple_stmts
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
|
D(fprintf(stderr, "%*c> block[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
|
||||||
asdl_stmt_seq* simple_stmt_var;
|
asdl_stmt_seq* simple_stmts_var;
|
||||||
if (
|
if (
|
||||||
(simple_stmt_var = simple_stmt_rule(p)) // simple_stmt
|
(simple_stmts_var = simple_stmts_rule(p)) // simple_stmts
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt"));
|
D(fprintf(stderr, "%*c+ block[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmts"));
|
||||||
_res = simple_stmt_var;
|
_res = simple_stmts_var;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s block[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmts"));
|
||||||
}
|
}
|
||||||
if (p->call_invalid_rules) { // invalid_block
|
if (p->call_invalid_rules) { // invalid_block
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
|
@ -16274,7 +16274,7 @@ _loop1_11_rule(Parser *p)
|
||||||
return _seq;
|
return _seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _loop0_13: ';' small_stmt
|
// _loop0_13: ';' simple_stmt
|
||||||
static asdl_seq *
|
static asdl_seq *
|
||||||
_loop0_13_rule(Parser *p)
|
_loop0_13_rule(Parser *p)
|
||||||
{
|
{
|
||||||
|
@ -16295,18 +16295,18 @@ _loop0_13_rule(Parser *p)
|
||||||
}
|
}
|
||||||
ssize_t _children_capacity = 1;
|
ssize_t _children_capacity = 1;
|
||||||
ssize_t _n = 0;
|
ssize_t _n = 0;
|
||||||
{ // ';' small_stmt
|
{ // ';' simple_stmt
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' small_stmt"));
|
D(fprintf(stderr, "%*c> _loop0_13[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "';' simple_stmt"));
|
||||||
Token * _literal;
|
Token * _literal;
|
||||||
stmt_ty elem;
|
stmt_ty elem;
|
||||||
while (
|
while (
|
||||||
(_literal = _PyPegen_expect_token(p, 13)) // token=';'
|
(_literal = _PyPegen_expect_token(p, 13)) // token=';'
|
||||||
&&
|
&&
|
||||||
(elem = small_stmt_rule(p)) // small_stmt
|
(elem = simple_stmt_rule(p)) // simple_stmt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
_res = elem;
|
_res = elem;
|
||||||
|
@ -16332,7 +16332,7 @@ _loop0_13_rule(Parser *p)
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s _loop0_13[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' small_stmt"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "';' simple_stmt"));
|
||||||
}
|
}
|
||||||
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
|
asdl_seq *_seq = (asdl_seq*)_Py_asdl_generic_seq_new(_n, p->arena);
|
||||||
if (!_seq) {
|
if (!_seq) {
|
||||||
|
@ -16349,7 +16349,7 @@ _loop0_13_rule(Parser *p)
|
||||||
return _seq;
|
return _seq;
|
||||||
}
|
}
|
||||||
|
|
||||||
// _gather_12: small_stmt _loop0_13
|
// _gather_12: simple_stmt _loop0_13
|
||||||
static asdl_seq *
|
static asdl_seq *
|
||||||
_gather_12_rule(Parser *p)
|
_gather_12_rule(Parser *p)
|
||||||
{
|
{
|
||||||
|
@ -16360,27 +16360,27 @@ _gather_12_rule(Parser *p)
|
||||||
}
|
}
|
||||||
asdl_seq * _res = NULL;
|
asdl_seq * _res = NULL;
|
||||||
int _mark = p->mark;
|
int _mark = p->mark;
|
||||||
{ // small_stmt _loop0_13
|
{ // simple_stmt _loop0_13
|
||||||
if (p->error_indicator) {
|
if (p->error_indicator) {
|
||||||
D(p->level--);
|
D(p->level--);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
|
D(fprintf(stderr, "%*c> _gather_12[%d-%d]: %s\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13"));
|
||||||
stmt_ty elem;
|
stmt_ty elem;
|
||||||
asdl_seq * seq;
|
asdl_seq * seq;
|
||||||
if (
|
if (
|
||||||
(elem = small_stmt_rule(p)) // small_stmt
|
(elem = simple_stmt_rule(p)) // simple_stmt
|
||||||
&&
|
&&
|
||||||
(seq = _loop0_13_rule(p)) // _loop0_13
|
(seq = _loop0_13_rule(p)) // _loop0_13
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "small_stmt _loop0_13"));
|
D(fprintf(stderr, "%*c+ _gather_12[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "simple_stmt _loop0_13"));
|
||||||
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
_res = _PyPegen_seq_insert_in_front(p, elem, seq);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
p->mark = _mark;
|
p->mark = _mark;
|
||||||
D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ',
|
D(fprintf(stderr, "%*c%s _gather_12[%d-%d]: %s failed!\n", p->level, ' ',
|
||||||
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "small_stmt _loop0_13"));
|
p->error_indicator ? "ERROR!" : "-", _mark, p->mark, "simple_stmt _loop0_13"));
|
||||||
}
|
}
|
||||||
_res = NULL;
|
_res = NULL;
|
||||||
done:
|
done:
|
||||||
|
|
|
@ -384,7 +384,7 @@ fstring_compile_expr(Parser *p, const char *expr_start, const char *expr_end,
|
||||||
|
|
||||||
int lines, cols;
|
int lines, cols;
|
||||||
if (!fstring_find_expr_location(t, str, &lines, &cols)) {
|
if (!fstring_find_expr_location(t, str, &lines, &cols)) {
|
||||||
PyMem_FREE(str);
|
PyMem_Free(str);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ static const char* type_comment_prefix = "# type: ";
|
||||||
static struct tok_state *
|
static struct tok_state *
|
||||||
tok_new(void)
|
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));
|
sizeof(struct tok_state));
|
||||||
if (tok == NULL)
|
if (tok == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -93,7 +93,7 @@ tok_new(void)
|
||||||
static char *
|
static char *
|
||||||
new_string(const char *s, Py_ssize_t len, struct tok_state *tok)
|
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) {
|
if (!result) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -108,7 +108,7 @@ error_ret(struct tok_state *tok) /* XXX */
|
||||||
{
|
{
|
||||||
tok->decoding_erred = 1;
|
tok->decoding_erred = 1;
|
||||||
if (tok->fp != NULL && tok->buf != NULL) /* see PyTokenizer_Free */
|
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->buf = tok->cur = tok->inp = NULL;
|
||||||
tok->start = NULL;
|
tok->start = NULL;
|
||||||
tok->end = 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;
|
return 0;
|
||||||
q = get_normal_name(r);
|
q = get_normal_name(r);
|
||||||
if (r != q) {
|
if (r != q) {
|
||||||
PyMem_FREE(r);
|
PyMem_Free(r);
|
||||||
r = new_string(q, strlen(q), tok);
|
r = new_string(q, strlen(q), tok);
|
||||||
if (!r)
|
if (!r)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -244,7 +244,7 @@ check_coding_spec(const char* line, Py_ssize_t size, struct tok_state *tok,
|
||||||
else {
|
else {
|
||||||
PyErr_Format(PyExc_SyntaxError,
|
PyErr_Format(PyExc_SyntaxError,
|
||||||
"encoding problem: %s", cs);
|
"encoding problem: %s", cs);
|
||||||
PyMem_FREE(cs);
|
PyMem_Free(cs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { /* then, compare cs with BOM */
|
} 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)
|
if (!r)
|
||||||
PyErr_Format(PyExc_SyntaxError,
|
PyErr_Format(PyExc_SyntaxError,
|
||||||
"encoding problem: %s with BOM", cs);
|
"encoding problem: %s with BOM", cs);
|
||||||
PyMem_FREE(cs);
|
PyMem_Free(cs);
|
||||||
}
|
}
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ check_bom(int get_char(struct tok_state *),
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (tok->encoding != NULL)
|
if (tok->encoding != NULL)
|
||||||
PyMem_FREE(tok->encoding);
|
PyMem_Free(tok->encoding);
|
||||||
tok->encoding = new_string("utf-8", 5, tok);
|
tok->encoding = new_string("utf-8", 5, tok);
|
||||||
if (!tok->encoding)
|
if (!tok->encoding)
|
||||||
return 0;
|
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;
|
size_t needed_length = strlen(s) + 2, final_length;
|
||||||
char *buf, *current;
|
char *buf, *current;
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
buf = PyMem_MALLOC(needed_length);
|
buf = PyMem_Malloc(needed_length);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -651,9 +651,9 @@ translate_newlines(const char *s, int exec_input, struct tok_state *tok) {
|
||||||
final_length = current - buf + 1;
|
final_length = current - buf + 1;
|
||||||
if (final_length < needed_length && final_length) {
|
if (final_length < needed_length && final_length) {
|
||||||
/* should never fail */
|
/* should never fail */
|
||||||
char* result = PyMem_REALLOC(buf, final_length);
|
char* result = PyMem_Realloc(buf, final_length);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
PyMem_FREE(buf);
|
PyMem_Free(buf);
|
||||||
}
|
}
|
||||||
buf = result;
|
buf = result;
|
||||||
}
|
}
|
||||||
|
@ -757,7 +757,7 @@ PyTokenizer_FromUTF8(const char *str, int exec_input)
|
||||||
tok->read_coding_spec = 1;
|
tok->read_coding_spec = 1;
|
||||||
tok->enc = NULL;
|
tok->enc = NULL;
|
||||||
tok->str = translated;
|
tok->str = translated;
|
||||||
tok->encoding = (char *)PyMem_MALLOC(6);
|
tok->encoding = (char *)PyMem_Malloc(6);
|
||||||
if (!tok->encoding) {
|
if (!tok->encoding) {
|
||||||
PyTokenizer_Free(tok);
|
PyTokenizer_Free(tok);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -778,7 +778,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
|
||||||
struct tok_state *tok = tok_new();
|
struct tok_state *tok = tok_new();
|
||||||
if (tok == NULL)
|
if (tok == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((tok->buf = (char *)PyMem_MALLOC(BUFSIZ)) == NULL) {
|
if ((tok->buf = (char *)PyMem_Malloc(BUFSIZ)) == NULL) {
|
||||||
PyTokenizer_Free(tok);
|
PyTokenizer_Free(tok);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -790,7 +790,7 @@ PyTokenizer_FromFile(FILE *fp, const char* enc,
|
||||||
if (enc != NULL) {
|
if (enc != NULL) {
|
||||||
/* Must copy encoding declaration since it
|
/* Must copy encoding declaration since it
|
||||||
gets copied into the parse tree. */
|
gets copied into the parse tree. */
|
||||||
tok->encoding = PyMem_MALLOC(strlen(enc)+1);
|
tok->encoding = PyMem_Malloc(strlen(enc)+1);
|
||||||
if (!tok->encoding) {
|
if (!tok->encoding) {
|
||||||
PyTokenizer_Free(tok);
|
PyTokenizer_Free(tok);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -808,15 +808,15 @@ void
|
||||||
PyTokenizer_Free(struct tok_state *tok)
|
PyTokenizer_Free(struct tok_state *tok)
|
||||||
{
|
{
|
||||||
if (tok->encoding != NULL)
|
if (tok->encoding != NULL)
|
||||||
PyMem_FREE(tok->encoding);
|
PyMem_Free(tok->encoding);
|
||||||
Py_XDECREF(tok->decoding_readline);
|
Py_XDECREF(tok->decoding_readline);
|
||||||
Py_XDECREF(tok->decoding_buffer);
|
Py_XDECREF(tok->decoding_buffer);
|
||||||
Py_XDECREF(tok->filename);
|
Py_XDECREF(tok->filename);
|
||||||
if (tok->fp != NULL && tok->buf != NULL)
|
if (tok->fp != NULL && tok->buf != NULL)
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
if (tok->input)
|
if (tok->input)
|
||||||
PyMem_FREE(tok->input);
|
PyMem_Free(tok->input);
|
||||||
PyMem_FREE(tok);
|
PyMem_Free(tok);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get next char, updating state; error code goes into tok->done */
|
/* 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);
|
char *newtok = PyOS_Readline(stdin, stdout, tok->prompt);
|
||||||
if (newtok != NULL) {
|
if (newtok != NULL) {
|
||||||
char *translated = translate_newlines(newtok, 0, tok);
|
char *translated = translate_newlines(newtok, 0, tok);
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
if (translated == NULL)
|
if (translated == NULL)
|
||||||
return EOF;
|
return EOF;
|
||||||
newtok = translated;
|
newtok = translated;
|
||||||
|
@ -862,14 +862,14 @@ tok_nextc(struct tok_state *tok)
|
||||||
Py_ssize_t buflen;
|
Py_ssize_t buflen;
|
||||||
const char* buf;
|
const char* buf;
|
||||||
PyObject *u = translate_into_utf8(newtok, tok->encoding);
|
PyObject *u = translate_into_utf8(newtok, tok->encoding);
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
if (!u) {
|
if (!u) {
|
||||||
tok->done = E_DECODE;
|
tok->done = E_DECODE;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
buflen = PyBytes_GET_SIZE(u);
|
buflen = PyBytes_GET_SIZE(u);
|
||||||
buf = PyBytes_AS_STRING(u);
|
buf = PyBytes_AS_STRING(u);
|
||||||
newtok = PyMem_MALLOC(buflen+1);
|
newtok = PyMem_Malloc(buflen+1);
|
||||||
if (newtok == NULL) {
|
if (newtok == NULL) {
|
||||||
Py_DECREF(u);
|
Py_DECREF(u);
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
|
@ -883,7 +883,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
if (newtok == NULL)
|
if (newtok == NULL)
|
||||||
tok->done = E_INTR;
|
tok->done = E_INTR;
|
||||||
else if (*newtok == '\0') {
|
else if (*newtok == '\0') {
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
tok->done = E_EOF;
|
tok->done = E_EOF;
|
||||||
}
|
}
|
||||||
else if (tok->start != NULL) {
|
else if (tok->start != NULL) {
|
||||||
|
@ -892,12 +892,12 @@ tok_nextc(struct tok_state *tok)
|
||||||
size_t newlen = oldlen + strlen(newtok);
|
size_t newlen = oldlen + strlen(newtok);
|
||||||
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
|
Py_ssize_t cur_multi_line_start = tok->multi_line_start - tok->buf;
|
||||||
char *buf = tok->buf;
|
char *buf = tok->buf;
|
||||||
buf = (char *)PyMem_REALLOC(buf, newlen+1);
|
buf = (char *)PyMem_Realloc(buf, newlen+1);
|
||||||
tok->lineno++;
|
tok->lineno++;
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
tok->buf = NULL;
|
tok->buf = NULL;
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
@ -906,7 +906,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
tok->multi_line_start = tok->buf + cur_multi_line_start;
|
tok->multi_line_start = tok->buf + cur_multi_line_start;
|
||||||
tok->line_start = tok->cur;
|
tok->line_start = tok->cur;
|
||||||
strcpy(tok->buf + oldlen, newtok);
|
strcpy(tok->buf + oldlen, newtok);
|
||||||
PyMem_FREE(newtok);
|
PyMem_Free(newtok);
|
||||||
tok->inp = tok->buf + newlen;
|
tok->inp = tok->buf + newlen;
|
||||||
tok->end = tok->inp + 1;
|
tok->end = tok->inp + 1;
|
||||||
tok->start = tok->buf + start;
|
tok->start = tok->buf + start;
|
||||||
|
@ -914,7 +914,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
else {
|
else {
|
||||||
tok->lineno++;
|
tok->lineno++;
|
||||||
if (tok->buf != NULL)
|
if (tok->buf != NULL)
|
||||||
PyMem_FREE(tok->buf);
|
PyMem_Free(tok->buf);
|
||||||
tok->buf = newtok;
|
tok->buf = newtok;
|
||||||
tok->cur = tok->buf;
|
tok->cur = tok->buf;
|
||||||
tok->line_start = tok->buf;
|
tok->line_start = tok->buf;
|
||||||
|
@ -929,7 +929,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
if (tok->start == NULL) {
|
if (tok->start == NULL) {
|
||||||
if (tok->buf == NULL) {
|
if (tok->buf == NULL) {
|
||||||
tok->buf = (char *)
|
tok->buf = (char *)
|
||||||
PyMem_MALLOC(BUFSIZ);
|
PyMem_Malloc(BUFSIZ);
|
||||||
if (tok->buf == NULL) {
|
if (tok->buf == NULL) {
|
||||||
tok->done = E_NOMEM;
|
tok->done = E_NOMEM;
|
||||||
return EOF;
|
return EOF;
|
||||||
|
@ -966,7 +966,7 @@ tok_nextc(struct tok_state *tok)
|
||||||
Py_ssize_t curvalid = tok->inp - tok->buf;
|
Py_ssize_t curvalid = tok->inp - tok->buf;
|
||||||
Py_ssize_t newsize = curvalid + BUFSIZ;
|
Py_ssize_t newsize = curvalid + BUFSIZ;
|
||||||
char *newbuf = tok->buf;
|
char *newbuf = tok->buf;
|
||||||
newbuf = (char *)PyMem_REALLOC(newbuf,
|
newbuf = (char *)PyMem_Realloc(newbuf,
|
||||||
newsize);
|
newsize);
|
||||||
if (newbuf == NULL) {
|
if (newbuf == NULL) {
|
||||||
tok->done = E_NOMEM;
|
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
|
encoding in the first or second line of the file (in which case the encoding
|
||||||
should be assumed to be UTF-8).
|
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. */
|
by the caller. */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -1894,7 +1894,7 @@ PyTokenizer_FindEncodingFilename(int fd, PyObject *filename)
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if (tok->encoding) {
|
if (tok->encoding) {
|
||||||
encoding = (char *)PyMem_MALLOC(strlen(tok->encoding) + 1);
|
encoding = (char *)PyMem_Malloc(strlen(tok->encoding) + 1);
|
||||||
if (encoding)
|
if (encoding)
|
||||||
strcpy(encoding, tok->encoding);
|
strcpy(encoding, tok->encoding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2089,7 +2089,7 @@ builtin_input_impl(PyObject *module, PyObject *prompt)
|
||||||
Py_DECREF(stdin_encoding);
|
Py_DECREF(stdin_encoding);
|
||||||
Py_DECREF(stdin_errors);
|
Py_DECREF(stdin_errors);
|
||||||
Py_XDECREF(po);
|
Py_XDECREF(po);
|
||||||
PyMem_FREE(s);
|
PyMem_Free(s);
|
||||||
|
|
||||||
if (result != NULL) {
|
if (result != NULL) {
|
||||||
if (PySys_Audit("builtins.input/result", "O", result) < 0) {
|
if (PySys_Audit("builtins.input/result", "O", result) < 0) {
|
||||||
|
|
|
@ -202,7 +202,7 @@ static int
|
||||||
cleanup_ptr(PyObject *self, void *ptr)
|
cleanup_ptr(PyObject *self, void *ptr)
|
||||||
{
|
{
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
PyMem_FREE(ptr);
|
PyMem_Free(ptr);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ cleanreturn(int retval, freelist_t *freelist)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (freelist->entries_malloced)
|
if (freelist->entries_malloced)
|
||||||
PyMem_FREE(freelist->entries);
|
PyMem_Free(freelist->entries);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -638,7 +638,7 @@ r_string(Py_ssize_t n, RFILE *p)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
if (p->buf == NULL) {
|
if (p->buf == NULL) {
|
||||||
p->buf = PyMem_MALLOC(n);
|
p->buf = PyMem_Malloc(n);
|
||||||
if (p->buf == NULL) {
|
if (p->buf == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -646,7 +646,7 @@ r_string(Py_ssize_t n, RFILE *p)
|
||||||
p->buf_size = n;
|
p->buf_size = n;
|
||||||
}
|
}
|
||||||
else if (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) {
|
if (tmp == NULL) {
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1453,7 +1453,7 @@ PyMarshal_ReadShortFromFile(FILE *fp)
|
||||||
rf.buf = NULL;
|
rf.buf = NULL;
|
||||||
res = r_short(&rf);
|
res = r_short(&rf);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1468,7 @@ PyMarshal_ReadLongFromFile(FILE *fp)
|
||||||
rf.buf = NULL;
|
rf.buf = NULL;
|
||||||
res = r_long(&rf);
|
res = r_long(&rf);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1501,11 +1501,11 @@ PyMarshal_ReadLastObjectFromFile(FILE *fp)
|
||||||
off_t filesize;
|
off_t filesize;
|
||||||
filesize = getfilesize(fp);
|
filesize = getfilesize(fp);
|
||||||
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
|
if (filesize > 0 && filesize <= REASONABLE_FILE_LIMIT) {
|
||||||
char* pBuf = (char *)PyMem_MALLOC(filesize);
|
char* pBuf = (char *)PyMem_Malloc(filesize);
|
||||||
if (pBuf != NULL) {
|
if (pBuf != NULL) {
|
||||||
size_t n = fread(pBuf, 1, (size_t)filesize, fp);
|
size_t n = fread(pBuf, 1, (size_t)filesize, fp);
|
||||||
PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n);
|
PyObject* v = PyMarshal_ReadObjectFromString(pBuf, n);
|
||||||
PyMem_FREE(pBuf);
|
PyMem_Free(pBuf);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1534,7 +1534,7 @@ PyMarshal_ReadObjectFromFile(FILE *fp)
|
||||||
result = r_object(&rf);
|
result = r_object(&rf);
|
||||||
Py_DECREF(rf.refs);
|
Py_DECREF(rf.refs);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1555,7 +1555,7 @@ PyMarshal_ReadObjectFromString(const char *str, Py_ssize_t len)
|
||||||
result = r_object(&rf);
|
result = r_object(&rf);
|
||||||
Py_DECREF(rf.refs);
|
Py_DECREF(rf.refs);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1684,7 +1684,7 @@ marshal_load(PyObject *module, PyObject *file)
|
||||||
result = read_object(&rf);
|
result = read_object(&rf);
|
||||||
Py_DECREF(rf.refs);
|
Py_DECREF(rf.refs);
|
||||||
if (rf.buf != NULL)
|
if (rf.buf != NULL)
|
||||||
PyMem_FREE(rf.buf);
|
PyMem_Free(rf.buf);
|
||||||
} else
|
} else
|
||||||
result = NULL;
|
result = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
|
||||||
char *copy, *c;
|
char *copy, *c;
|
||||||
/* Create a copy of the input, with the '.' converted to the
|
/* Create a copy of the input, with the '.' converted to the
|
||||||
locale-specific decimal point */
|
locale-specific decimal point */
|
||||||
copy = (char *)PyMem_MALLOC(end - digits_pos +
|
copy = (char *)PyMem_Malloc(end - digits_pos +
|
||||||
1 + decimal_point_len);
|
1 + decimal_point_len);
|
||||||
if (copy == NULL) {
|
if (copy == NULL) {
|
||||||
*endptr = (char *)nptr;
|
*endptr = (char *)nptr;
|
||||||
|
@ -286,7 +286,7 @@ _PyOS_ascii_strtod(const char *nptr, char **endptr)
|
||||||
(fail_pos - copy);
|
(fail_pos - copy);
|
||||||
}
|
}
|
||||||
|
|
||||||
PyMem_FREE(copy);
|
PyMem_Free(copy);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -128,7 +128,7 @@ ste_dealloc(PySTEntryObject *ste)
|
||||||
Py_XDECREF(ste->ste_varnames);
|
Py_XDECREF(ste->ste_varnames);
|
||||||
Py_XDECREF(ste->ste_children);
|
Py_XDECREF(ste->ste_children);
|
||||||
Py_XDECREF(ste->ste_directives);
|
Py_XDECREF(ste->ste_directives);
|
||||||
PyObject_Del(ste);
|
PyObject_Free(ste);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define OFF(x) offsetof(PySTEntryObject, x)
|
#define OFF(x) offsetof(PySTEntryObject, x)
|
||||||
|
|
|
@ -419,12 +419,12 @@ _Py_DisplaySourceLine(PyObject *f, PyObject *filename, int lineno, int indent)
|
||||||
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
|
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
|
||||||
Py_DECREF(io);
|
Py_DECREF(io);
|
||||||
Py_DECREF(binary);
|
Py_DECREF(binary);
|
||||||
PyMem_FREE(found_encoding);
|
PyMem_Free(found_encoding);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
|
fob = _PyObject_CallMethodId(io, &PyId_TextIOWrapper, "Os", binary, encoding);
|
||||||
Py_DECREF(io);
|
Py_DECREF(io);
|
||||||
PyMem_FREE(found_encoding);
|
PyMem_Free(found_encoding);
|
||||||
|
|
||||||
if (fob == NULL) {
|
if (fob == NULL) {
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
|
|
Loading…
Reference in New Issue