summaryrefslogtreecommitdiff
path: root/Modules/_struct.c
AgeCommit message (Collapse)AuthorLines
2020-05-26[3.8] bpo-35714: Reject null characters in struct format strings (GH-16928) ↵Miss Islington (bot)-0/+4
(GH-20419) struct.error is now raised if there is a null character in a struct format string. (cherry picked from commit 3f59b55316f4c6ab451997902579aa69020b537c) (cherry picked from commit 5ff5edfef63b3dbc1abb004b3fa4b3db87e79ff9) Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2020-03-31bpo-39689: Do not use native packing for format "?" with standard size ↵Miss Islington (bot)-0/+3
(GH-18969) (cherry picked from commit 472fc843ca816d65c12f9508ac762ca492165c45) Co-authored-by: Stefan Krah <skrah@bytereef.org>
2017-12-15bpo-32240: Add the const qualifier to declarations of PyObject* array ↵Serhiy Storchaka-5/+5
arguments. (#4746)
2017-09-14bpo-30246: fix several error messages which only mention bytes in struct (#1421)Xiang Zhang-4/+5
2017-08-24bpo-31095: fix potential crash during GC (GH-2974)INADA Naoki-0/+2
2017-07-03bpo-29464: Rename METH_FASTCALL to METH_FASTCALL|METH_KEYWORDS and make (#1955)Serhiy Storchaka-20/+6
the bare METH_FASTCALL be used for functions with positional-only parameters.
2017-06-23bpo-21071: struct.Struct.format type is now str (#845)Victor Stinner-2/+2
2017-06-15bpo-20627: Fix error message when keyword arguments are used (#2115)Sylvain-6/+14
2017-06-02bpo-30245: Fix possible overflow when organize struct.pack_into error ↵Johan Liu-2/+5
message (#1682)
2017-05-15bpo-30242: resolve some undefined behaviours in struct (#1418)Xiang Zhang-5/+9
2017-05-15bpo-30224: remove outdated checks in struct (#1374)Xiang Zhang-47/+15
2017-04-20bpo-29802: Fix reference counting in module-level struct functions (#1213)Serhiy Storchaka-0/+1
when pass arguments of wrong type.
2017-04-04bpo-29649: Improve struct.pack_into() boundary error messages (#424)Andrew Nester-4/+30
2017-02-04Issue #29300: Use Argument Clinic for getting struct object from the format.Serhiy Storchaka-65/+52
2017-02-02Rename struct.unpack() 2nd parameter to "buffer"Victor Stinner-4/+4
Issue #29300: Rename struct.unpack() second parameter from "inputstr" to "buffer", and use the Py_buffer type. Fix also unit tests on struct.unpack() which passed a Unicode string instead of a bytes string as struct.unpack() second parameter. The purpose of test_trailing_counter() is to test invalid format strings, not to test the buffer parameter.
2017-02-02Issue #29300: Convert _struct module to Argument ClinicVictor Stinner-226/+246
* The struct module now requires contiguous buffers. * Convert most functions and methods of the _struct module to Argument Clinic * Use "Py_buffer" type for the "buffer" argument. Argument Clinic is responsible to create and release the Py_buffer object. * Use "PyStructObject *" type for self to avoid explicit conversions. * Add an unit test on the _struct.Struct.unpack_from() method to test passing arguments as keywords. * Rephrase docstrings. * Rename "fmt" argument to "format" in docstrings and the documentation. As a side effect, functions and methods which used METH_VARARGS calling convention like struct.pack() now use the METH_FASTCALL calling convention which avoids the creation of temporary tuple to pass positional arguments and so is faster. For example, struct.pack("i", 1) becomes 1.56x faster (-36%):: $ ./python -m perf timeit \ -s 'import struct; pack=struct.pack' 'pack("i", 1)' \ --compare-to=../default-ref/python Median +- std dev: 119 ns +- 1 ns -> 76.8 ns +- 0.4 ns: 1.56x faster (-36%) Significant (t=295.91) Patch co-written with Serhiy Storchaka.
2016-12-16Issue #28959: Added private macro PyDict_GET_SIZE for retrieving the size of ↵Serhiy Storchaka-1/+1
dict.
2016-12-04Backed out changeset b9c9691c72c5Victor Stinner-1/+1
Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
2016-12-01Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner-1/+1
* PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
2016-10-04Closes #21124, #28337: Call PyType_Ready on unpackiter_type.Zachary Ware-0/+3
Patch by Masayuki Yamamoto.
2016-10-02Issue #21124: Fix building _struct on Cygwin.Zachary Ware-1/+1
Patch by Masayuki Yamamoto.
2016-09-19merge 3.5 (#28184)Benjamin Peterson-1/+1
2016-09-07require C99 boolBenjamin Peterson-12/+5
2016-09-06replace PY_LONG_LONG with long longBenjamin Peterson-26/+26
2016-09-05require a long long data type (closes #27961)Benjamin Peterson-43/+0
2016-09-03Issue #11734: Add support for IEEE 754 half-precision floats to the struct ↵Mark Dickinson-1/+75
module. Original patch by Eli Stevens.
2016-04-15merge headsGregory P. Smith-8/+8
2016-04-15Issue #26535: Correct docs regarding the struct buffer sizeMartin Panter-8/+8
2016-04-06Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka-1/+1
2016-04-06Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka-1/+1
2015-12-27Issue #20440: Applied yet one patch for using Py_SETREF.Serhiy Storchaka-2/+1
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-27Issue #20440: Applied yet one patch for using Py_SETREF.Serhiy Storchaka-2/+1
The patch is automatically generated, it replaces the code that uses Py_CLEAR.
2015-12-25Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka-3/+3
private functions.
2015-12-25Issue #25923: Added the const qualifier to static constant arrays.Serhiy Storchaka-2/+2
2015-12-19Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.Serhiy Storchaka-1/+1
This allows sys.getsize() to work correctly with their subclasses with __slots__ defined.
2015-02-03Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()Serhiy Storchaka-10/+13
and PyObject_AsWriteBuffer().
2015-02-03Issue #22896: Avoid to use PyObject_AsCharBuffer(), PyObject_AsReadBuffer()Serhiy Storchaka-10/+13
and PyObject_AsWriteBuffer().
2014-08-16Issue #22156: Fix some "comparison between signed and unsigned integers"Victor Stinner-2/+3
compiler warnings in the Modules/ subdirectory.
2014-05-14Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()Victor Stinner-5/+4
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between pyconfig.h and pymacros.h.
2013-11-23 - Modules/_struct.c (unpackiter_type): Define static.doko@ubuntu.com-1/+1
2013-08-27Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka-1/+1
error messages and comments.
2013-08-27Issue #18783: Removed existing mentions of Python long type in docstrings,Serhiy Storchaka-1/+1
error messages and comments.
2013-05-17Issue #14596: The struct.Struct() objects now use more compact implementation.Serhiy Storchaka-79/+94
2013-04-27Issue #17804: New function ``struct.iter_unpack`` allows for streaming ↵Antoine Pitrou-0/+165
struct unpacking.
2013-02-09Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou-2/+2
in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou-2/+2
in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag), mpdecimal (needs to build without Python.h).
2013-02-09Issue #17173: Remove uses of locale-dependent C functions (isalpha() etc.) ↵Antoine Pitrou-2/+2
in the interpreter. I've left a couple of them in: zlib (third-party lib), getaddrinfo.c (doesn't include Python.h, and probably obsolete), _sre.c (legitimate use for the re.LOCALE flag).
2012-10-29#14897: Enhance error messages of struct.pack and struct.pack_intoPetri Lehtinen-4/+14
Patch by Matti Mäki.
2012-10-29#14897: Enhance error messages of struct.pack and struct.pack_intoPetri Lehtinen-4/+14
Patch by Matti Mäki.
2012-10-29#14897: Enhance error messages of struct.pack and struct.pack_intoPetri Lehtinen-4/+14
Patch by Matti Mäki.