Commit Graph

49 Commits

Author SHA1 Message Date
Fred Drake d5fadf75e4 Rationalize use of limits.h, moving the inclusion to Python.h.
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-26 05:46:01 +00:00
Marc-André Lemburg 0afff388ce Special case the "s#" PyArg_Parse() token for Unicode objects:
"s#" will now return a pointer to the default encoded string data
of the Unicode object instead of a pointer to the raw UTF-16
data.

The latter is still available via PyObject_AsReadBuffer().

The patch also adds an optimization for string objects which is
based on the fact that string objects return the raw character data
for getreadbuffer access and are always single-segment.
2000-09-21 21:08:30 +00:00
Jack Jansen a454ebd924 Added B format char to Py_BuildValue (same as b,h,i, but makes
bgen-generated code work).
2000-09-15 12:52:19 +00:00
Marc-André Lemburg bbcf2a7c81 This patch hopefully fixes the problem with "es#" and "es" in
PyArg_ParseTupleAndKeywords() and closes bug #113807.
2000-09-08 11:49:37 +00:00
Guido van Rossum 8586991099 REMOVED all CWI, CNRI and BeOpen copyright markings.
This should match the situation in the 1.6b1 tree.
2000-09-01 23:29:29 +00:00
Jack Jansen cc22fbe3db Changed H specifier to mean "bitfield", i.e. any value from
-32768..65535 is acceptable. Added B specifier (with values from
-128..255). No L added (which would have completed the set) because l
already accepts any value (and the letter L is taken for quadwords).
2000-08-05 21:29:58 +00:00
Marc-André Lemburg bff879cabb This patch finalizes the move from UTF-8 to a default encoding in
the Python Unicode implementation.

The internal buffer used for implementing the buffer protocol
is renamed to defenc to make this change visible. It now holds the
default encoded version of the Unicode object and is calculated
on demand (NULL otherwise).

Since the default encoding defaults to ASCII, this will mean that
Unicode objects which hold non-ASCII characters will no longer
work on C APIs using the "s" or "t" parser markers. C APIs must now
explicitly provide Unicode support via the "u", "U" or "es"/"es#"
parser markers in order to work with non-ASCII Unicode strings.

(Note: this patch will also have to be applied to the 1.6 branch
 of the CVS tree.)
2000-08-03 18:46:08 +00:00
Thomas Wouters f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Jeremy Hylton 03657cfdb0 replace PyXXX_Length calls with PyXXX_Size calls 2000-07-12 13:05:33 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Jack Jansen d50338fbd9 Added support for H (unsigned short) specifier in PyArg_ParseTuple and
Py_BuildValue.
2000-07-06 12:22:00 +00:00
Guido van Rossum db67739d4f Jack Jansen, Mac patch:
Include limits.h if we have it.
2000-07-01 01:09:43 +00:00
Guido van Rossum ffcc3813d8 Change copyright notice - 2nd try. 2000-06-30 23:58:06 +00:00
Guido van Rossum fd71b9e9d4 Change copyright notice. 2000-06-30 23:50:40 +00:00
Guido van Rossum 5e08cb8e50 Vladimir Marangozov:
This patch fixes a problem on AIX with the signed int case code in
getargs.c, after Trent Mick's intervention about MIN/MAX overflow
checks. The AIX compiler/optimizer generates bogus code with the
default flags "-g -O" causing test_builtin to fail: int("10", 16) <>
16L. Swapping the two checks in the signed int code makes the problem
go away.

Also, make the error messages fit in 80 char lines in the
source.
2000-06-28 23:53:56 +00:00
Fred Drake 230cae7474 Trent Mick <trentm@activestate.com>:
Limit the 'b' formatter of PyArg_ParseTuple to valid values of an unsigned
char, i.e. [0,UCHAR_MAX]. It is expected that this is the common usage of 'b'.
An OverflowError is raised if the parsed value is outside this range.
2000-05-09 21:50:00 +00:00
Guido van Rossum 80dc16baaa Trent Mick:
Changes the 'b', 'h', and 'i' formatters in PyArg_ParseTuple to raise an
Overflow exception if they overflow (previously they just silently
overflowed).

Changes by Guido: always accept values [0..255] (in addition to
[CHAR_MIN..CHAR_MAX]) for 'b' format; changed some spaces into tabs in
other code.
2000-05-08 14:02:41 +00:00
Fred Drake 25871c001f Brian Hooper <brian_takashi@hotmail.com>:
Added 'u' and 'u#' tags for PyArg_ParseTuple - these turn a
PyUnicodeObject argument into a Py_UNICODE * buffer, or a Py_UNICODE *
buffer plus a length with the '#'.  Also added an analog to 'U'
for Py_BuildValue.
2000-05-03 15:17:02 +00:00
Guido van Rossum 700c6ff1fb Marc-Andre Lemburg:
Fixed a memory leak found by Fredrik Lundh.  Instead of
PyUnicode_AsUTF8String() we now use _PyUnicode_AsUTF8String() which
returns the string object without incremented refcount (and assures
that the so obtained object remains alive until the Unicode object is
garbage collected).
2000-04-27 20:13:18 +00:00
Guido van Rossum 24bdb0474f Marc-Andre Lemburg:
The attached patch set includes a workaround to get Python with
Unicode compile on BSDI 4.x (courtesy Thomas Wouters; the cause
is a bug in the BSDI wchar.h header file) and Python interfaces
for the MBCS codec donated by Mark Hammond.

Also included are some minor corrections w/r to the docs of
the new "es" and "es#" parser markers (use PyMem_Free() instead
of free(); thanks to Mark Hammond for finding these).

The unicodedata tests are now in a separate file
(test_unicodedata.py) to avoid problems if the module cannot
be found.
2000-03-28 20:29:59 +00:00
Guido van Rossum 50fbb15b16 Typo fixed by Mark Hammond. 2000-03-28 02:00:29 +00:00
Guido van Rossum d8855fde88 Marc-Andre Lemburg:
Attached you find the latest update of the Unicode implementation.
The patch is against the current CVS version.

It includes the fix I posted yesterday for the core dump problem
in codecs.c (was introduced by my previous patch set -- sorry),
adds more tests for the codecs and two new parser markers
"es" and "es#".
2000-03-24 22:14:19 +00:00
Guido van Rossum e826ef0a89 Marc-Andre Lemburg: support for Unicode strings; 'U' expects a Unicode
object.
2000-03-10 23:02:17 +00:00
Guido van Rossum 66368ccc55 Patch by Tommy Burnette to accept an arbitrary sequence when "(...)"
is used in the format string, instead of requiring a tuple.  This is
in line with the general trend towards accepting arbitrary sequences.
1999-02-17 23:16:43 +00:00
Guido van Rossum 3dbba6ec3a Change rare occurrences of #if HAVE_LONG_LONG to #ifdef. 1999-01-25 21:48:56 +00:00
Guido van Rossum b317f8aa0d Implement new format character 't#'. This is like s#, accepting an
object that implements the buffer interface, but requires a buffer
that contains 8-bit character data.  Greg Stein.
1998-10-08 02:21:21 +00:00
Guido van Rossum 3293b07df5 Patch by Mark Hammond to support 64-bit ints on MS platforms.
The MS compiler doesn't call it 'long long', it uses __int64,
so a new #define, LONG_LONG, has been added and all occurrences
of 'long long' are replaced with it.
1998-08-25 16:07:15 +00:00
Guido van Rossum 1a8791e0b8 Changes for BeOS, QNX and long long, by Chris Herborth. 1998-08-04 22:46:29 +00:00
Guido van Rossum fccfe89753 Another veeeeeery old patch...
Date:    Thu, 14 Sep 1995 12:18:20 -0400
From:    Alan Morse <alan@dvcorp.com>
To:      python-list@cwi.nl
Subject: getargs bug in 1.2 and 1.3 BETA

We have found a bug in the part of the getargs code that we added
and submitted, and which was incorporated into 1.1.

The parsing of "O?" format specifiers is not handled correctly;
there is no "else" for the "if" and therefore it can never fail.
What's worse, the advancing of the varargs pointer is not
handled properly, so from then on it is out of sync, wreaking
all sorts of havoc. (If it had failed properly, then the out-of-sync
varargs would not have been an issue.)

Below is the context diff for the change.

Note that I have made a few stylistic changes beyond adding the
else case, namely:

1) Making the "O" case follow the convention established by the other
format specifiers of getting all their vararg arguments before
performing the test, rather than getting some before and some after
the test passes.

2) Making the logic of the tests parallel, so the "if" part indicates
that the format is accepted and the "else" part indicates that the
format has failed. They were inconsistent with each other and with the
the other format specifiers.

-Alan Morse (amorse@dvcorp.com)
1998-05-15 22:04:07 +00:00
Guido van Rossum 730806d3d9 Make new gcc -Wall happy 1998-04-10 22:27:42 +00:00
Guido van Rossum 0d6b49eff2 Protect PyErr_Format format string argument from overflow (ironically,
the error was about a bad format string :-).
1998-01-19 22:22:44 +00:00
Guido van Rossum 7d4f68c15f Oops -- '(' is also a legal start character of a new format... 1997-12-19 04:25:23 +00:00
Guido van Rossum 231a41e708 Add explicit check for correct next character in format at end of
format.  This will complain about illegal formats like "O#" instead of
ignoring the '#'.
1997-12-09 20:36:39 +00:00
Guido van Rossum fdf95dd525 Checkin of Jack's buffer mods.
Not really checked, but didn't fail any tests either...
1997-05-05 22:15:02 +00:00
Guido van Rossum 13454c3f9c Fix old typo PyArgs_VaParse -> PyArg_VaParse.
(Redoing the checking without merging in Jack's buffer mods.)
1997-05-05 21:57:29 +00:00
Guido van Rossum 79f25d9a7b Quickly renamed the remaining files -- this directory is done. 1997-04-29 20:08:16 +00:00
Guido van Rossum 6bf62dad9e Keep gcc -Wall and Microsoft VC happy. 1997-04-11 20:37:35 +00:00
Guido van Rossum 80bb9655f0 Keep gcc -Wall happy. 1996-12-05 23:27:02 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum c1d5053882 Add needed #include <ctype.h> 1996-08-21 23:38:24 +00:00
Guido van Rossum aa35465ccf Support for keyword arguments (PyArg_ParseTupleAndKeywords) donated by
Geoff Philbrick <philbric@delphi.hks.com> (slightly changed by me).

Also a little change to make the file acceptable to K&R C compilers
(HPUX, SunOS 4.x).
1996-08-19 19:32:04 +00:00
Guido van Rossum 530956d247 Py_complex; and WITHOUT_COMPLEX added to getargs.c 1996-07-21 02:27:43 +00:00
Guido van Rossum 8a5c5d277e changes for complex numbers 1996-01-12 01:09:56 +00:00
Guido van Rossum 64fc649095 don't overwrite error already set (e.g. from O&) 1995-01-21 14:09:37 +00:00
Guido van Rossum 6d023c98b0 Added 1995 to copyright message.
bltinmodule.c: fixed coerce() nightmare in ternary pow().
modsupport.c (initmodule2): pass METH_FREENAME flag to newmethodobject().
pythonrun.c: move flushline() into and around print_error().
1995-01-04 19:12:13 +00:00
Guido van Rossum 1ae940a587 Lots of changes, most minor (fatal() instead of abort(), use of
err_fetch/err_restore and so on).  But...
NOTE: import.c has been rewritten and all the DL stuff is now in the
new file importdl.c.
1995-01-02 19:04:15 +00:00
Guido van Rossum 13d0ed13c3 prevent core dump for old getargs() with NULL arg 1994-11-10 22:35:48 +00:00
Guido van Rossum fe3f1a256b * Python/{modsupport.c,getargs.c,Makefile.in},
Include/modsupport.h: moved getargs() to its own file and
	re-implemented it entirely to support optional arguments, multiple
	arguments without surrounding parentheses
	(when called as newgetargs()), and better error messages
1994-09-29 09:42:55 +00:00