summaryrefslogtreecommitdiff
path: root/Modules/structmodule.c
AgeCommit message (Collapse)AuthorLines
2003-03-29Rename LONG_LONG to PY_LONG_LONG. Fixes #710285.Martin v. Löwis-14/+14
2003-03-20New private API functions _PyFloat_{Pack,Unpack}(4,8}. This is aTim Peters-292/+18
refactoring to get all the duplicates of this delicate code out of the cPickle and struct modules.
2003-03-20SF bug 705836: struct.pack of floats in non-native endian orderTim Peters-12/+37
pack_float, pack_double, save_float: All the routines for creating IEEE-format packed representations of floats and doubles simply ignored that rounding can (in rare cases) propagate out of a long string of 1 bits. At worst, the end-off carry can (by mistake) interfere with the exponent value, and then unpacking yields a result wrong by a factor of 2. In less severe cases, it can end up losing more low-order bits than intended, or fail to catch overflow *caused* by rounding. Bugfix candidate, but I already backported this to 2.2. In 2.3, this code remains in severe need of refactoring.
2002-09-03(Most of) SF patch 601369 (Christos Georgiou): obmalloc,structmodule:Guido van Rossum-27/+54
64bit, big endian (issue 2 only). This adds a bunch of memcpy calls via a temporary variable to avoid alignment errors. That's needed for some platforms.
2002-08-02Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototypeMark Hammond-1/+1
for Py_Main(). Thanks to Kalle Svensson and Skip Montanaro for the patches.
2002-06-13Patch #568124: Add doc string macros.Martin v. Löwis-16/+15
2002-04-02Get rid of more PyArg_Parse & METH_OLDARGS.Neal Norwitz-1/+2
PyArg_Parse( "s" ) -> PyString_AsString PyArg_Parse( "t#" ) -> PyString_AsStringAndSize
2002-02-14Fix typo.Fred Drake-1/+1
2002-02-14Use PyModule_AddObject() instead of accessing the module dict directly.Fred Drake-6/+8
2001-10-24SF patch #474590 -- RISC OS supportGuido van Rossum-12/+12
2001-09-15The 'p' (Pascal string) pack code acts unreasonably when the string sizeTim Peters-0/+2
and count exceed 255. Changed to preserve as much of the string as possible (instead of count%256 characters).
2001-07-18SF bug #442520: test_struct fails on SPARC.Tim Peters-4/+10
The ob_sval member of a string object isn't necessarily aligned to better than a native long, so the new "q" and "Q" struct codes can't get away w/ casting tricks on platforms where LONG_LONG requires stricter-than-long alignment. After I thought of a few elaborate workarounds, Guido bashed me over the head with the obvious memcpy approach, herewith implemented.
2001-06-13The new {b,l}p_{u,}longlong() didn't check get_pylong()'s return for NULL.Tim Peters-0/+8
Repaired that, and added appropriate tests for it to test_struct.py.
2001-06-12Added q/Q standard (x-platform 8-byte ints) mode in struct module.Tim Peters-55/+137
This completes the q/Q project. longobject.c _PyLong_AsByteArray: The original code had a gross bug: the most-significant Python digit doesn't necessarily have SHIFT significant bits, and you really need to count how many copies of the sign bit it has else spurious overflow errors result. test_struct.py: This now does exhaustive std q/Q testing at, and on both sides of, all relevant power-of-2 boundaries, both positive and negative. NEWS: Added brief dict news while I was at it.
2001-06-11Trimmed trailing whitespace.Tim Peters-3/+3
2001-06-11Simplify some convolution by simply not recognizing 'q' and 'Q' at allTim Peters-33/+0
in native mode on platforms that don't HAVE_LONG_LONG.
2001-06-11Make clear in the docstring that "std" applies to both size and alignment,Tim Peters-6/+6
not just to alignment. Spotted by Guido. Bugfix candidate.
2001-06-10Initial support for 'q' and 'Q' struct format codes: for now, only inTim Peters-1/+186
native mode, and only when config #defines HAVE_LONG_LONG. Standard mode will eventually treat them as 8-byte ints across all platforms, but that likely requires a new set of routines in longobject.c first (while sizeof(long) >= 4 is guaranteed by C, there's nothing in C we can rely on x-platform to hold 8 bytes of int, so we'll have to roll our own; I'm thinking of a simple pair of conversion functions, Python long to/from sized vector of unsigned bytes; that may be useful for GMP conversions too; std q/Q would call them with size fixed at 8). test_struct.py: In addition to adding some native-mode 'q' and 'Q' tests, got rid of unused code, and repaired a non-portable assumption about native sizeof(short) (it isn't 2 on some Cray boxes). libstruct.tex: In addition to adding a bit of 'q'/'Q' docs (more needed later), removed an erroneous footnote about 'I' behavior.
2001-04-08Repair portability of sign extension when reading signed ints on boxesTim Peters-10/+6
where sizeof(long)==8. This *was* broken on boxes where signed right shifts didn't sign-extend, but not elsewhere. Unfortunately, apart from the Cray T3E I don't know of such a box, and Guido has so far refused to buy me any Cray machines for home Python testing <wink>. More immediately interesting would be if someone could please test this on *any* sizeof(long)==8 box, to make sure I didn't break it.
2000-09-26Rationalize use of limits.h, moving the inclusion to Python.h.Fred Drake-1/+0
Add definitions of INT_MAX and LONG_MAX to pyport.h. Remove includes of limits.h and conditional definitions of INT_MAX and LONG_MAX elsewhere. This closes SourceForge patch #101659 and bug #115323.
2000-09-15Use symbolic constants for allowable short ranges.Martin v. Löwis-4/+7
2000-09-15Check range for bytes and shorts. Closes bug #110845.Martin v. Löwis-2/+42
2000-09-01REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum-9/+0
This should match the situation in the 1.6b1 tree.
2000-07-31merge Include/my*.h into Include/pyport.hPeter Schneider-Kamp-1/+0
marked my*.h as obsolete
2000-07-21Bunch of minor ANSIfications: 'void initfunc()' -> 'void initfunc(void)',Thomas Wouters-1/+1
and a couple of functions that were missed in the previous batches. Not terribly tested, but very carefully scrutinized, three times. All these were found by the little findkrc.py that I posted to python-dev, which means there might be more lurking. Cases such as this: long func(a, b) long a; long b; /* flagword */ { and other cases where the last ; in the argument list isn't followed by a newline and an opening curly bracket. Regexps to catch all are welcome, of course ;)
2000-07-10ANSI-ficationPeter Schneider-Kamp-173/+57
2000-07-09Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.Tim Peters-5/+4
2000-06-30Change copyright notice - 2nd try.Guido van Rossum-6/+0
2000-06-30Change copyright notice.Guido van Rossum-21/+6
2000-06-01Michael Hudson <mwh21@cam.ac.uk>:Fred Drake-1/+2
Removed PyErr_BadArgument() calls and replaced them with more useful error messages.
2000-02-29Massive patch by Skip Montanaro to add ":name" to as manyGuido van Rossum-2/+2
PyArg_ParseTuple() format string arguments as possible.
1998-12-04Add DL_EXPORT() to all modules that could possibly be usedGuido van Rossum-1/+1
on BeOS or Windows.
1998-09-18Patches from Greg Stein to support 'P' format in struct module'sGuido van Rossum-0/+31
native format, as void* (translated to Python int or long). Also adds PyLong_FromVoidPtr and PyLong_AsVoidPtr to longobject.c.
1998-06-29Unsigned 1 and 2 byte sized formats shouldn't result in long integer values!Guido van Rossum-2/+8
1998-05-28get_long(): Use PyErr_ExceptionMatches(...) instead of PyErr_Occurred(...).Fred Drake-1/+1
1998-04-10Make new gcc -Wall happyGuido van Rossum-3/+3
1997-12-21Oops, left in a non-standard multi-line doc string that GCC finds okayGuido van Rossum-4/+4
but other compilers don't like.
1997-12-19Added doc strings, suggested by Charles G. Waldman (but massaged quite a bit).Guido van Rossum-7/+41
1997-11-04Fix due to Bill Noon for problem discovered by Ken Manheimer: packingGuido van Rossum-2/+2
0.0 as float or double would yield the representation for 1.0!
1997-10-01Apply two changes, systematically:Guido van Rossum-5/+3
(1) Use PyErr_NewException("module.class", NULL, NULL) to create the exception object. (2) Remove all calls to Py_FatalError(); instead, return or ignore the errors -- the import code now checks PyErr_Occurred() after calling a module's init function, so it's no longer a fatal error for the initialization to fail. Also did some small cleanups, e.g. removed unnecessary test for "already initialized" from initfpectl(), and unified initposix()/initnt(). I haven't checked this very thoroughly, so while the changes are pretty trivial -- beware of untested code!
1997-09-05Contribution by Hannu Krosing (with some changes).Guido van Rossum-0/+38
Added 'p' format character for Pascal string (i.e. leading length byte). This uses the count prefix line 's' does, except that the count includes the length byte; i.e. '10p' takes 10 bytes packed but has space for a length byte and 9 data bytes.
1997-08-26Ignore whitespace between formats (not internal to a count+format).Guido van Rossum-0/+7
1997-04-11Keep Microsoft VC happy.Guido van Rossum-8/+8
1997-01-03Changed the ``add/sub_offset'' hacks for dealing with C's unsignedGuido van Rossum-112/+14
int/long types, and use the new PyLong_FromUnsignedLong() and PyLong_AsUnsignedLong() interfaces instead. Semantic change: the 'I' format will now always return a long int.
1997-01-03Fill pad bytes with zeros (fixing a bug dating from the very first version!).Guido van Rossum-2/+5
1997-01-03Scratch the ears of gcc -Wall.Barry Warsaw-1/+1
1997-01-02Ok, ok, I've fixed gradual underflow on packing too.Guido van Rossum-45/+47
Still don't know what to do with Inf/NaN, so I raise an exception on pack(), and something random decided by ldexp() will happen on unpack().
1997-01-02Oops -- unpack float/double didn't do the right thing if e==0.Guido van Rossum-4/+14
1997-01-02Support float and double in non-native formats.Guido van Rossum-2/+365
These use the ANSI/IEEE standard, which is also used by XDR; so the _xdr module may become obsolete.
1996-12-31Added better handling of unsigned longs -- a Python long returned byGuido van Rossum-27/+163
unpack('L', ...) is now acceptable to pack('L', ...).