Commit Graph

1105 Commits

Author SHA1 Message Date
Barry Warsaw 77c9f50422 SyntaxError__str__(): Fix two memory problems discovered by Insure.
First, the allocated buffer was never freed after using it to create
the PyString object.  Second, it was possible that have_filename would
be false (meaning that filename was not a PyString object), but that
the code would still try to PyString_GET_SIZE() it.
2000-08-16 19:43:17 +00:00
Tim Peters b59ab42487 Fix new compiler warnings. Unused var in compile.c. Argsize mismatches
in binascii.c (only on platforms with signed chars -- although Py_CHARMASK
is documented as returning an int, it only does so on platforms with
signed chars).
2000-08-15 16:41:26 +00:00
Fred Drake 185a29b08f my_basename(): Removes the leading path components from a path name,
returning a pointer to the start of the file's "base" name;
	similar to os.path.basename().

SyntaxError__str__():  Use my_basename() to keep the length of the
	file name included in the exception message short.
2000-08-15 16:20:36 +00:00
Fred Drake a811a5b13a Remove the osdefs.h #include; it was not needed in the final version of
my last set of changes.
2000-08-15 16:13:37 +00:00
Fred Drake dcf08e0dfe When raising a SyntaxError, make a best-effort attempt to set the
filename and lineno attributes, but do not mask the SyntaxError if we
fail.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).

Wrap a long line to fit in under 80 columns.
2000-08-15 15:49:44 +00:00
Fred Drake 83cb797380 When raising a SyntaxError, make a best-effort attempt to set the
filename and lineno attributes, but do not mask the SyntaxError if we
fail.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).
2000-08-15 15:49:03 +00:00
Fred Drake 1aba577093 SyntaxError__str__(): Do more formatting of the exception here, rather
than depending on the site that raises the exception.  If the
	filename and lineno attributes are set on the exception object,
	use them to augment the message displayed.

This is part of what is needed to close SoruceForge bug #110628
(Jitterbug PR#278).
2000-08-15 15:46:16 +00:00
Fred Drake a2b6ad6e27 Guido pointed out that all names in the sys module have no underscore, 2000-08-15 04:24:43 +00:00
Mark Hammond 557a044f74 Fix the parent of WindowsError - both the comments in this source file, and the previous exceptions.py have WindowsError as a sub-class of OSError. 2000-08-15 00:37:32 +00:00
Fred Drake ccede59889 The attempt to protect against MS_WIN16 compilers that do not support long
string literals has not been tested on an MS_WIN16 platform; the trailing
";" was inside the #ifndef MS_WIN16, which should cause an error (missing
semi-colon) when compiled with that symbol #defined.
2000-08-14 20:59:57 +00:00
Fred Drake 099325e01b Add a byte_order value to the sys module. The value is "big" for
big-endian machines and "little" for little-endian machines.
2000-08-14 15:47:03 +00:00
Thomas Wouters 87df80d542 The list comp patch checked for the second child node of the 'listmaker'
node, without checking if the node actually had more than one child. It can
have only one node, though: '[' test ']'. This fixes it.
2000-08-13 17:05:17 +00:00
Thomas Wouters 361852f80e The list comprehensions patch partly reversed the removal of UNPACK_LIST,
re-introducing com_assign_list, now unused. Removed it.
2000-08-12 22:03:16 +00:00
Trent Mick 29b83810bd Clean up a couple of warnings on Win64. The downcast of the strlen size_t
return value to int is safe here because in each case it previouls checked that
there will be no overflow.
2000-08-12 21:35:36 +00:00
Skip Montanaro 803d6e5451 list comprehensions. see
http://sourceforge.net/patch/?func=detailpatch&patch_id=100654&group_id=5470

for details.
2000-08-12 18:09:51 +00:00
Thomas Wouters 0be5aab04d Merge UNPACK_LIST and UNPACK_TUPLE into a single UNPACK_SEQUENCE, since they
did the same anyway.

I'm not sure what to do with Tools/compiler/compiler/* -- that isn't part of
distutils, is it ? Should it try to be compatible with old bytecode version ?
2000-08-11 22:15:52 +00:00
Fredrik Lundh 6947d0b65e -- from Trent Mick: [Patch #101010] replace use of INT_PTR
with uintptr_t (fix MSVC 5.0 build)
2000-08-07 20:16:28 +00:00
Guido van Rossum 6c2f0c73a1 When returning an error from jcompile() (which is passed through by
PyNode_Compile()), make sure that an exception is actually set --
otherwise someone stomped on our error.  [2.0 checkin of this fix.]
2000-08-07 19:22:43 +00:00
Guido van Rossum ed473a46fc Avoid dumping core when PyErr_NormalizeException() is called without
an exception set.  This shouldn't happen, but we see it at times...
2000-08-07 19:18:27 +00:00
Moshe Zadka aa39a7edf7 Initialized opcode and oparg to silence a gcc -Wall warning. 2000-08-07 06:34:45 +00:00
Thomas Wouters e8643c465d Fix some strange indentation and grammar that have been bugging me for
weeks.
2000-08-05 21:37:50 +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
Moshe Zadka 9fb6af9640 Removing warnings by gcc -Wall -- cast ugly || to void. 2000-08-04 21:27:47 +00:00
Guido van Rossum 413407f103 Add a test that Py_IsInitialized() in Py_InitModule4(). See
python-dev discussion.

This should catch future version incompatibilities on Windows.  Alas,
this doesn't help for 1.5 vs. 1.6; but it will help for 1.6 vs. 2.0.
2000-08-04 14:00:14 +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
Guido van Rossum 16b1ad9c7d Changing the CNRI copyright notice according to CNRI's instructions.
This is a notice without a date, which apparently is not a claim to
copyright but only advice to the reader.  IANAL. :-)
2000-08-03 16:24:25 +00:00
Barry Warsaw bd599b5928 Both PEP 201 Lockstep Iteration and SF patch #101030 have been
accepted by the BDFL.

builtin_zip(): New function to implement the zip() function described
in the above proposal.

zip_doc[]: Docstring for zip().

builtin_methods[]: added entry for zip()
2000-08-03 15:45:29 +00:00
Fred Drake 19c6afb42b Include the dependence of sysmodule on the patchlevel.h include, so
that sys.version_info will be built properly.
2000-08-01 17:46:22 +00:00
Peter Schneider-Kamp 7e01890986 merge Include/my*.h into Include/pyport.h
marked my*.h as obsolete
2000-07-31 15:28:04 +00:00
Thomas Wouters 334fb8985b Use 'void' directly instead of the ANY #define, now that all code is ANSI C.
Leave the actual #define in for API compatibility.
2000-07-25 12:56:38 +00:00
Thomas Wouters 1e0c2f4bee Create a new section of pyport.h to hold all external function declarations
for systems that are missing those declarations from system include files.
Start by moving a pointy-haired ones from their previous locations to the
new section.

(The gethostname() one, for instance, breaks on several systems, because
some define it as (char *, size_t) and some as (char *, int).)

I purposely decided not to include the summary of used #defines like Tim did
in the first section of pyport.h. In my opinion, the number of #defines
likedly to be used by this section would make such an overview unwieldy. I
would suggest documenting the non-obvious ones, though.
2000-07-24 16:06:23 +00:00
Thomas Wouters 8ec68fded2 Prototype yet another forward declaration. 2000-07-24 14:39:50 +00:00
Thomas Wouters e28c296f0f Another missed ansification. 2000-07-23 22:21:32 +00:00
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