Commit Graph

1072 Commits

Author SHA1 Message Date
Tim Peters 8315ea5790 Included assert.h in Python.h -- it's absurd that this basic tool of
good C practice hasn't been available to everything all along.
Added Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) macro to pyport.h; this
just casts VALUE from type WIDE to type NARROW, but assert-fails if
Py_DEBUG is defined and info is lost due to casting.
Replaced a line in Fredrik's fix to marshal.c to use the new macro.
2000-07-23 19:28:35 +00:00
Fredrik Lundh 115343849c -- changed w_more to take an integer instead of a char
(this is what the callers expect).
2000-07-23 18:24:06 +00:00
Thomas Wouters 2f2370bfc9 Oops. One of last nights ANSIfication patches accidentily upped the bytecode
MAGIC number. When updating it next time, be sure it's higher than 50715 *
constants. (Shouldn't be a problem if everyone keeps to the proper
algorithm.)
2000-07-23 09:20:08 +00:00
Thomas Wouters b4bd21cf79 ANSIfy as many declarations as possible. 2000-07-22 23:38:01 +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 0452d1f316 Fix two instances of empty argument lists, and fix style
('PyObject** x' -> 'PyObject **x')
2000-07-22 18:45:06 +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
Peter Schneider-Kamp 9a5086c598 just fixing the indentation 2000-07-13 06:24:29 +00:00
Peter Schneider-Kamp 11384c60f6 raise error on duplicate function arguments
example:

>>> def f(a,a):print a
...
SyntaxError: duplicate argument in function definition
2000-07-13 06:15:04 +00:00
Skip Montanaro 6980dff3db delete obsolete SYMANTEC__CFM68K__ #ifdefs 2000-07-12 17:21:42 +00:00
Jeremy Hylton 03657cfdb0 replace PyXXX_Length calls with PyXXX_Size calls 2000-07-12 13:05:33 +00:00
Tim Peters bf26e07049 Worm around MSVC6 error on single string literal > 2Kb. 2000-07-12 04:02:10 +00:00
Jack Jansen cbf630f0a9 Include macglue.h for some function prototypes, and renamed a few
mac-specific functions to have a PyMac_ name.
2000-07-11 21:59:16 +00:00
Fred Drake 85f363990c Create two new exceptions: IndentationError and TabError. These are
used for indentation related errors.  This patch includes Ping's
improvements for indentation-related error messages.

Closes SourceForge patches #100734 and #100856.
2000-07-11 17:53:00 +00:00
Barry Warsaw b78165566e Exception__str__(): In case 1, be sure to decref the tmp local
variable.  This crushes another memory leak.  Slight rewrite
included.
2000-07-09 22:27:10 +00:00
Barry Warsaw 7dfeb42939 EnvironmentError__init__(): The two case clauses were missing
`break's.  This first missing break caused a memory leak when case 3
fell through case 2 in the following example:

import os
os.chmod('/missing', 0600)
2000-07-09 04:56:25 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Tim Peters 4be47c0f76 Get rid of unused vars in builtin_unicode (they were causing
legit warnings).
2000-07-09 02:11:18 +00:00
Marc-André Lemburg 1b1bcc9935 Fixed unicode() to use the new API PyUnicode_FromEncodedObject().
This adds support for instance to the constructor (instances
have to define __str__ and can return Unicode objects via that
hook; string return values are decoded into Unicode using the
current default encoding).
2000-07-07 13:48:25 +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
Jack Jansen 41aa8e523d Include limits.h if we have it. 2000-07-03 21:39:47 +00:00
Barry Warsaw 8fcaa92c5f init_exceptions(): Decref `doc' so it doesn't leak. 2000-07-01 04:45:52 +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 f12d7a02a0 Jack Jansen, Mac patch:
If we have stat.h include it if we don't have sys/stat.h
2000-07-01 01:08:11 +00:00
Guido van Rossum 63e97ad4ea Jack Jansen, Mac patch:
Include stat.h if needed; different Mac filename compare
2000-07-01 01:06:56 +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
Fred Drake 615ae55eca Trent Mick <trentm@activestate.com>:
The common technique for printing out a pointer has been to cast to a long
and use the "%lx" printf modifier. This is incorrect on Win64 where casting
to a long truncates the pointer. The "%p" formatter should be used instead.

The problem as stated by Tim:
> Unfortunately, the C committee refused to define what %p conversion "looks
> like" -- they explicitly allowed it to be implementation-defined. Older
> versions of Microsoft C even stuck a colon in the middle of the address (in
> the days of segment+offset addressing)!

The result is that the hex value of a pointer will maybe/maybe not have a 0x
prepended to it.


Notes on the patch:

There are two main classes of changes:
- in the various repr() functions that print out pointers
- debugging printf's in the various thread_*.h files (these are why the
patch is large)


Closes SourceForge patch #100505.
2000-06-30 16:20:13 +00:00
Fred Drake 4c82b2366f Trent Mick <trentm@activestate.com>:
This patch fixes possible overflow in the use of
PyOS_GetLastModificationTime in getmtime.c and Python/import.c.

Currently PyOS_GetLastModificationTime returns a C long. This can
overflow on Win64 where sizeof(time_t) > sizeof(long). Besides it
should logically return a time_t anyway (this patch changes this).

As well, import.c uses PyOS_GetLastModificationTime for .pyc
timestamping.  There has been recent discussion about the .pyc header
format on python-dev.  This patch adds oveflow checking to import.c so
that an exception will be raised if the modification time
overflows. There are a few other minor 64-bit readiness changes made
to the module as well:

- size_t instead of int or long for function-local buffer and string
length variables

- one buffer overflow check was added (raises an exception on possible
overflow, this overflow chance exists on 32-bit platforms as well), no
other possible buffer overflows existed (from my analysis anyway)

Closes SourceForge patch #100509.
2000-06-30 16:18:57 +00:00
Fred Drake a44d353e2b Trent Mick <trentm@activestate.com>:
The common technique for printing out a pointer has been to cast to a long
and use the "%lx" printf modifier. This is incorrect on Win64 where casting
to a long truncates the pointer. The "%p" formatter should be used instead.

The problem as stated by Tim:
> Unfortunately, the C committee refused to define what %p conversion "looks
> like" -- they explicitly allowed it to be implementation-defined. Older
> versions of Microsoft C even stuck a colon in the middle of the address (in
> the days of segment+offset addressing)!

The result is that the hex value of a pointer will maybe/maybe not have a 0x
prepended to it.


Notes on the patch:

There are two main classes of changes:
- in the various repr() functions that print out pointers
- debugging printf's in the various thread_*.h files (these are why the
patch is large)


Closes SourceForge patch #100505.
2000-06-30 15:01:00 +00:00
Jeremy Hylton 4e542a3d99 replace constant 1 with symbolic constant METH_VARARGS
another typo caught by Rob Hooft
2000-06-30 04:59:59 +00:00
Jeremy Hylton 9262b8ab1f another typo caught by Rob Hooft 2000-06-30 04:59:17 +00:00
Fredrik Lundh 34a96371c3 - workaround to make 1.6 build under MSVC 5.0. hopefully,
trent (who broke it in the first place ;-) will come up
  with a cleaner solution.
2000-06-29 17:25:30 +00:00
Guido van Rossum 338311378e Change the loop index in normalizestring() to size_t too, to avoid a
warning on Windows.
2000-06-29 14:50:15 +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
Guido van Rossum 98626cd7ac Urmpf. Quality control on this patch lapsed a bit. :-(
The depth field was never decremented inside w_object(), and it was
never initialized in PyMarshal_WriteObjectToFile().

This caused imports from .pyc files to fil mysteriously when the .pyc
file was written by the broken code -- w_object() would bail out
early, but PyMarshal_WriteObjectToFile() doesn't check the error or
return an error code, and apparently the marshalling code doesn't call
PyErr_Check() either.  (That's a separate patch if I feel like it.)
2000-06-28 23:24:19 +00:00
Guido van Rossum 582acece2e Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
2000-06-28 22:07:35 +00:00
Guido van Rossum 106f2dae86 Trent Mick:
Various small fixes to the builtin module to ensure no buffer
overflows.

- chunk #1:
Proper casting to ensure no truncation, and hence no surprises, in the
comparison.

- chunk #2:
The id() function guarantees a unique return value for different
objects.  It does this by returning the pointer to the object. By
returning a PyInt, on Win64 (sizeof(long) < sizeof(void*)) the pointer
is truncated and the guarantee may be proven false. The appropriate
return function is PyLong_FromVoidPtr, this returns a PyLong if that
is necessary to return the pointer without truncation.

[GvR: note that this means that id() can now return a long on Win32
platforms.  This *might* break some code...]

- chunk #3:
Ensure no overflow in raw_input(). Granted the user would have to pass
in >2GB of data but it *is* a possible buffer overflow condition.
2000-06-28 21:12:25 +00:00
Fred Drake 6da0b9148c Michael Hudson <mwh21@cam.ac.uk>:
As I really do not have anything better to do at the moment, I have written
a patch to Python/marshal.c that prevents Python dumping core when trying
to marshal stack bustingly deep (or recursive) data structure.

It just throws an exception; even slightly clever handling of recursive
data is what pickle is for...

[Fred Drake:]  Moved magic constant 5000 to a #define.

This closes SourceForge patch #100645.
2000-06-28 18:47:56 +00:00
Jeremy Hylton 94988067b9 Add new parser error code, E_OVERFLOW. This error is returned when
the number of children of a node exceeds the max possible value for
the short that is used to count them.  The Python runtime converts
this parser error into the SyntaxError "expression too long."
2000-06-20 19:10:44 +00:00
Jeremy Hylton 2d15d9d869 mark SyntaxError__str__ as METH_VARARGS 2000-06-20 18:36:26 +00:00
Mark Hammond 440d898230 Added a new debug method sys.gettotalrefcount(), which returns the total number of references on all Python objects. This is only enabled when Py_TRACE_REFS is defined (which includes default debug builds under Windows).
Also removed a redundant cast from sys.getrefcount(), as discussed on the patches list.
2000-06-20 08:12:48 +00:00
Fred Drake 5550de3084 Christopher Fandrich <cfandrich@8cs.com>:
Fix memory leak in initializing __debug__.
2000-06-20 04:54:19 +00:00
Marc-André Lemburg 99964b86b2 Marc-Andre Lemburg <mal@lemburg.com>:
Changed the API names for setting the default encoding.
These are now in line with the other hooks API names
(no underscores).
2000-06-07 09:13:41 +00:00
Barry Warsaw 675ac285ae The standard exception classes. Moved here from ../Modules/_exceptions.c 2000-05-26 19:05:16 +00:00
Barry Warsaw f17861badc Added exceptions.o to the list of object to build in this subdir. 2000-05-26 19:04:27 +00:00
Barry Warsaw 78e6c671db All the exception building related stuff has been moved out of this
module and into _exceptions.c.  This includes all the PyExc_* globals,
the bltin_exc table, init_class_exc(), fini_instances(),
finierrors().

Renamed _PyBuiltin_Init_1() to _PyBuiltin_Init() since the two phase
initializations are necessary any more.

Removed as obsolete _PyBuiltin_Init_2(), _PyBuiltin_Fini_1() and
_PyBuiltin_Fini_2().
2000-05-25 23:15:05 +00:00
Barry Warsaw f242aa0d1e Py_Initialize(): Now that standard exceptions are builtin, we don't
need two phase init or fini of the builtin module.  Change the call of
_PyBuiltin_Init_1() to _PyBuiltin_Init().  Add a call to
init_exceptions().

Py_Finalize(): Don't call _PyBuiltin_Fini_1().  Instead call
fini_exceptions() but move this to before the thread state is
cleared.
2000-05-25 23:09:49 +00:00
Barry Warsaw 1226588e57 bltin_exc: Removed the leaf_exc flag in the structure, which was only
used to build the fallback string-based exception.
2000-05-25 03:18:53 +00:00
Guido van Rossum ede8c6eea1 Bill Tutt:
Calling Sleep(0) for a spinlock can cause a priority inversion, adding
comments to explain what's going on.
2000-05-11 12:53:51 +00:00
Guido van Rossum cf3ba65749 At Bob Kahn's request, add CNRI to the copyright string (but not to
the notice yet).
2000-05-10 20:06:00 +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
Fred Drake 8b4d01d9f9 M.-A. Lemburg <mal@lemburg.com>:
Added APIs to allow setting and querying the system's
current string encoding: sys.set_string_encoding()
and sys.get_string_encoding().
2000-05-09 19:57:01 +00:00
Fred Drake 766de83ab1 M.-A. Lemburg <mal@lemburg.com>:
Moved some docs to the include file.

Added a NULL check to _PyCodec_Lookup() to make it
core dump safe.
2000-05-09 19:55:59 +00:00
Fred Drake c640b18d96 M.-A. Lemburg <mal@lemburg.com>:
Fixed docs according to the new behaviour (the Unicode
encoding is no longer fixed to UTF-8).
2000-05-09 19:55:16 +00:00
Guido van Rossum 20c6add7ff Trent Mick:
Change static slice_index() to extern _PyEval_SliceIndex() (with
different return value interpretation: 0 for failure, 1 for success).
2000-05-08 14:06:50 +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
Guido van Rossum 07bd90e92d Andy Dustman: add GNU pth user-space thread support. 2000-05-08 13:41:38 +00:00
Guido van Rossum 4cea605e75 Quick fix by Mark Hammond -- Yakov changed a dprintf call but it was
referencing an undefined variable, so we better change it back.
2000-05-05 14:29:59 +00:00
Guido van Rossum 706262bde0 Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru,
who wrote:

Here's the new version of thread_nt.h.  More particular, there is a
new version of thread lock that uses kernel object (e.g. semaphore)
only in case of contention; in other case it simply uses interlocked
functions, which are faster by the order of magnitude.  It doesn't
make much difference without threads present, but as soon as thread
machinery initialised and (mostly) the interpreter global lock is on,
difference becomes tremendous.  I've included a small script, which
initialises threads and launches pystone.  With original thread_nt.h,
Pystone results with initialised threads are twofold worse then w/o
threads.  With the new version, only 10% worse.  I have used this
patch for about 6 months (with threaded and non-threaded
applications).  It works remarkably well (though I'd desperately
prefer Python was free-threaded; I hope, it will soon).
2000-05-04 18:47:15 +00:00
Guido van Rossum cc229ea76f Add useless 'return 1' to prtrace() to shut up VC++. 2000-05-04 00:55:17 +00:00
Guido van Rossum b18618dab7 Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives.
For documentation read the comments in mymalloc.h and objimpl.h.

(This is not exactly what Vladimir posted to the patches list; I've
made a few changes, and Vladimir sent me a fix in private email for a
problem that only occurs in debug mode.  I'm also holding back on his
change to main.c, which seems unnecessary to me.)
2000-05-03 23:44:39 +00:00
Guido van Rossum a7cfca23e1 A bit of cleanup:
- When 'import exceptions' fails, don't suggest to use -v to print the traceback;
  this doesn't actually work.
- Remove comment about fallback to string exceptions.
- Remove a PyErr_Occurred() check after all is said and done that can
  never trigger.
- Remove static function newstdexception() which is no longer called.
2000-05-03 22:03:46 +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
Barry Warsaw fa5c315afa PyErr_GivenExceptionMatches(): Check for err==NULL and exc==NULL and
return 0 (exceptions don't match).  This means that if an ImportError
is raised because exceptions.py can't be imported, the interpreter
will exit "cleanly" with an error message instead of just core
dumping.

PyErr_SetFromErrnoWithFilename(), PyErr_SetFromWindowsErrWithFilename():
Don't test on Py_UseClassExceptionsFlag.
2000-05-02 19:27:51 +00:00
Barry Warsaw 48719d3d1f _PyBuiltin_Init_2(): Remove the misleading comment. 2000-05-02 19:24:39 +00:00
Barry Warsaw 47eeb9bdad initerrors(): Remove this function. String-based standard exceptions
are no longer supported (i.e. -X option is removed).

_PyBuiltin_Init_1(): Don't call initerrors().  This does mean that it
is possible to raise an ImportError before that exception has been
initialized, say because exceptions.py can't be found, or contains
bogosity.  See changes to errors.c for how this is handled.

_PyBuiltin_Init_2(): Don't test Py_UseClassExceptionsFlag, just go
ahead and initialize the class-based standard exceptions.  If this
fails, we throw a Py_FatalError.
2000-05-02 19:24:06 +00:00
Barry Warsaw 3ce096459e Py_UseClassExceptionsFlag is deprecated. We keep the C variable for C
API consistency, but nothing sets it or checks it now.
2000-05-02 19:18:59 +00:00
Barry Warsaw ee98e4e75d Ignore a bunch of generated files. 2000-05-02 18:34:30 +00:00
Guido van Rossum 96774c1347 Marc-Andre Lemburg:
Changed all references to the MAGIC constant to use a global
pyc_magic instead. This global is initially set to MAGIC, but can be
changed by the _PyImport_Init() function to provide for
special features implemented in the compiler which are settable
using command line switches and affect the way PYC files are
generated.

Currently this change is only done for the -U flag.
2000-05-01 20:19:08 +00:00
Guido van Rossum b16d197d66 Marc-Andre Lemburg:
Added Py_UnicodeFlag for use by the -U command line option.
2000-05-01 17:55:15 +00:00
Guido van Rossum fdc8bdb67b Marc-Andre Lemburg:
Support for the new -U command line option option:
with the option enabled the Python compiler
interprets all "..." strings as u"..." (same with r"..." and
ur"...").
2000-05-01 17:54:56 +00:00
Guido van Rossum 22b65a8edc Robin Becker: The following patch seems to fix a module case bug in
1.6a2 caused by wrong return values in routine allcaps83.  [GvR: I
also changed the case for end-s>8 to return 0.]
2000-05-01 17:36:58 +00:00
Guido van Rossum 1cb6cd0ec5 As Marc-Andre Lemburg points out, the magic number needs to change
because we've added Unicode marshalling to the repertoire.
2000-04-28 19:03:54 +00:00
Guido van Rossum a2ace6ae25 Charles G Waldman:
Follow a suggestion in an /*XXX*/ comment [in com_add()] to speed up
compilation by using supplemental dictionaries to keep track of names
and constants, eliminating quadratic behavior.  With this patch in
place, the time to import a 5000-line file with lots of constants [at
the global level] is reduced from 20 seconds to under 3 on my system.
2000-04-28 16:42:25 +00:00
Fred Drake 25d34473c3 Brian Hooper <brian_takashi@hotmail.com>:
Here's a patch which changes modsupport to add 'u' and 'u#',
to support building Unicode objects from a null-terminated
Py_UNICODE *, and a Py_UNICODE * with length, respectively.

[Conversion from 'U' to 'u' by Fred, based on python-dev comments.]

Note that the use of None for NULL values of the Py_UNICODE* value is
still in; I'm not sure of the conclusion on that issue.
2000-04-28 14:42:37 +00:00
Guido van Rossum eca4784781 Mark Hammond: For Windows debug builds, we now only offer to dump
remaining object references if the environment variable PYTHONDUMPREFS
exists.  The default behaviour caused problems for background or
otherwise invisible processes that use the debug build of Python.
2000-04-27 23:44:15 +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 b33aa1a51e Jack Jansen: The new version of the GUSI i/o library on the Macintosh
has a few slightly different calls from the old one.
2000-04-24 15:08:18 +00:00
Guido van Rossum 095249fc8c Jack Jansen: Posix threads are now supported on the Macintosh too. 2000-04-24 15:06:51 +00:00
Guido van Rossum 25826c93c4 Charles Waldman writes:
"""
Running "test_extcall" repeatedly results in memory leaks.

One of these can't be fixed (at least not easily!), it happens since
this code:

def saboteur(**kw):
    kw['x'] = locals()
d = {}
saboteur(a=1, **d)

creates a circular reference - d['x']['d']==d

The others are due to some missing decrefs in ceval.c, fixed by the
patch attached below.

Note:  I originally wrote this without the "goto", just adding the
missing decref's where needed.  But I think the goto is justified in
keeping the executable code size of ceval as small as possible.
"""

[I think the circular reference is more like kw['x']['kw'] == kw. --GvR]
2000-04-21 21:17:39 +00:00
Jeremy Hylton 4a3dd2dcc2 Fix PR#7 comparisons of recursive objects
Note that comparisons of deeply nested objects can still dump core in
extreme cases.
2000-04-14 19:13:24 +00:00
Fred Drake 6d27c1eb32 Simplify creation of the version_info value for clarity, per
suggestion from Greg Stein.
2000-04-13 20:03:20 +00:00
Fred Drake 93a20bf87c Capitulate, changing version_info to a 5-tuple:
major, minor, micro, level, serial

Values are now monotonically increasing with each new release.
2000-04-13 17:44:51 +00:00
Fred Drake 801c08d700 Define version_info to be a tuple (major, minor, micro, level); level
is a string "a2", "b1", "c1", or '' for a final release.

Added version_info and hexversion to the module docstring.
2000-04-13 15:29:10 +00:00
Fred Drake 4e998bc658 M.-A. Lemburg <mal@lemburg.com>:
Fixed problem with Unicode string concatenation:
u = (u"abc" u"abc") previously dumped core.
2000-04-13 14:10:44 +00:00
Fred Drake 078b24f000 When refering to Unicode characters in exception messages and
docstrings, the documentation guidelines call for "Unicode", not
"unicode".  Comply.
2000-04-13 02:42:50 +00:00
Jeremy Hylton 394b54d01a ord: provide better error messages 2000-04-12 21:19:47 +00:00
Guido van Rossum 3afba7644b Marc-Andre Lemburg:
Added special case to unicode(): when being passed a
Unicode object as first argument, return the object as-is.
Raises an exception when given a Unicode object *and* an
encoding name.
2000-04-11 15:38:23 +00:00
Guido van Rossum 44679590e0 Patch by Vladimir Marangozov to include the function name when
comparing code objects.  This give sless surprising results in
-Optimized code.  It also sorts code objects by name, now.

[I changed the patch to hash() slightly to touch fewer lines.]
2000-04-10 16:20:31 +00:00
Guido van Rossum 5db862dd0c Skip Montanaro: add string precisions to calls to PyErr_Format
to prevent possible buffer overruns.
2000-04-10 12:46:51 +00:00
Guido van Rossum a396a883af Vladimir Marangozov: This fixes the line number in the string
representation of code objects when optimization is on (python -O). It
was always reported as -1 instead of the real lineno.
2000-04-07 01:21:36 +00:00
Guido van Rossum 9e896b37c7 Marc-Andre's third try at this bulk patch seems to work (except that
his copy of test_contains.py seems to be broken -- the lines he
deleted were already absent).  Checkin messages:


New Unicode support for int(), float(), complex() and long().

- new APIs PyInt_FromUnicode() and PyLong_FromUnicode()
- added support for Unicode to PyFloat_FromString()
- new encoding API PyUnicode_EncodeDecimal() which converts
  Unicode to a decimal char* string (used in the above new
  APIs)
- shortcuts for calls like int(<int object>) and float(<float obj>)
- tests for all of the above

Unicode compares and contains checks:
- comparing Unicode and non-string types now works; TypeErrors
  are masked, all other errors such as ValueError during
  Unicode coercion are passed through (note that PyUnicode_Compare
  does not implement the masking -- PyObject_Compare does this)
- contains now works for non-string types too; TypeErrors are
  masked and 0 returned; all other errors are passed through

Better testing support for the standard codecs.

Misc minor enhancements, such as an alias dbcs for the mbcs codec.

Changes:
- PyLong_FromString() now applies the same error checks as
  does PyInt_FromString(): trailing garbage is reported
  as error and not longer silently ignored. The only characters
  which may be trailing the digits are 'L' and 'l' -- these
  are still silently ignored.
- string.ato?() now directly interface to int(), long() and
  float(). The error strings are now a little different, but
  the type still remains the same. These functions are now
  ready to get declared obsolete ;-)
- PyNumber_Int() now also does a check for embedded NULL chars
  in the input string; PyNumber_Long() already did this (and
  still does)

Followed by:

Looks like I've gone a step too far there... (and test_contains.py
seem to have a bug too).

I've changed back to reporting all errors in PyUnicode_Contains()
and added a few more test cases to test_contains.py (plus corrected
the join() NameError).
2000-04-05 20:11:21 +00:00
Guido van Rossum b95de4f847 Marc-Andre Lemburg: Error reporting in the codec registry and lookup
mechanism is enhanced to be more informative.
2000-03-31 17:25:23 +00:00
Guido van Rossum 7a5b796322 Thomas Heller fixes a typo in an error message. 2000-03-31 13:52:29 +00:00
Jeremy Hylton 387b1011a1 rename args variable in CALL_FUNCTION to callargs (avoids name
override)

add missing DECREFs in error handling code of CALL_FUNCTION
2000-03-31 01:22:54 +00:00
Guido van Rossum 6d10887cdc Change traceback error message to "most recent call last" from
"innermost last".  The latter was mysterious to newbies.
2000-03-31 00:39:23 +00:00
Guido van Rossum ffc0f4fb36 Use modern PyArg_ParseTuple style, with function names.
(Mostly.)
2000-03-31 00:38:29 +00:00
Guido van Rossum 2efa369861 Use modern PyArg_ParseTuple style, with function names. 2000-03-31 00:37:41 +00:00
Jeremy Hylton 074c3e62d1 Two fixes for extended call syntax:
If a non-tuple sequence is passed as the *arg, convert it to a tuple
before checking its length.
If named keyword arguments are used in combination with **kwargs, make
a copy of kwargs before inserting the new keys.
2000-03-30 23:55:31 +00:00