Commit Graph

1122 Commits

Author SHA1 Message Date
Fred Drake e693df94ed Avoid a couple of "value computed is not used" warnings from gcc -Wall;
these computations are required for their side effects in traversing the
variable arguments list.

Reported by Marc-Andre Lemburg <mal@lemburg.com>.
2000-10-10 21:10:35 +00:00
Fred Drake a6c2eb5e1e Donn Cave <donn@u.washington.edu>:
Do not assume that all platforms using a MetroWorks compiler can use
POSIX threads; the assumption breaks on BeOS.  This fix only helps
for BeOS.

This closes SourceForge patch #101772.
2000-10-06 15:48:38 +00:00
Tim Peters 98dc065c1b SF "bug" 115973: patches from Norman Vine so that shared libraries and
Tkinter work under Cygwin.  Accepted on faith & reasonableness.
2000-10-05 19:24:26 +00:00
Mark Hammond 1f7838bcc0 Detect conflicting Python DLL on module import under Windows - as per [ Patch #101676 ] 2000-10-05 10:54:45 +00:00
Barry Warsaw 84294487df _PyImport_Fini(): Closed small memory leak when an embedded app calls
Py_Initialize()/Py_Finalize() in a loop.  _PyImport_Filetab needed to
be deallocated.  Partial closure of SF #110681, Jitterbug PR#398.
2000-10-03 16:02:05 +00:00
Tim Peters 42c83afd14 The 2.0b2 change to write .pyc files in exclusive mode (if possible)
unintentionally caused them to get written in text mode under Windows.
As a result, when .pyc files were later read-- in binary mode --the
magic number was always wrong (note that .pyc magic numbers deliberately
include \r and \n characters, so this was "good" breakage, 100% across
all .pyc files, not random corruption in a subset).  Fixed that.
2000-09-29 04:03:10 +00:00
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
Fred Drake 9e2851566c Andrew Kuchling <akuchlin@mems-exchange.org>:
Add three new convenience functions to the PyModule_*() family:
PyModule_AddObject(), PyModule_AddIntConstant(), PyModule_AddStringConstant().

This closes SourceForge patch #101233.
2000-09-23 03:24:27 +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
Guido van Rossum 55a8338d7f On Unix, use O_EXCL when creating the .pyc/.pyo files, to avoid a race condition 2000-09-20 20:31:38 +00:00
Marc-André Lemburg d1ba443206 This patch adds a new Python C API called PyString_AsStringAndSize()
which implements the automatic conversion from Unicode to a string
object using the default encoding.

The new API is then put to use to have eval() and exec accept
Unicode objects as code parameter. This closes bugs #110924
and #113890.

As side-effect, the traditional C APIs PyString_Size() and
PyString_AsString() will also accept Unicode objects as
parameters.
2000-09-19 21:04:18 +00:00
Tim Peters e84b74039b Obscure marshal fixes:
When reading a short, sign-extend on platforms where shorts are
    bigger than 16 bits.
    When reading a long, repair the unportable sign extension that was
    being done for 64-bit machines (it assumed that signed right shift
    sign-extends).
2000-09-19 08:54:13 +00:00
Guido van Rossum 9e8181b809 Make better use of GNU Pth -- patch by Andy Dustman.
I can't test this, so I'm just checking it in with blind faith in Andy.
I've tested that it doesn't broeak a non-Pth build on Linux.

Changes include:

- There's a --with-pth configure option.

- Instead of _GNU_PTH, we test for HAVE_PTH.

- Better signal handling.

- (The config.h.in file is regenerated in a slightly different order.)
2000-09-19 00:46:46 +00:00
Marc-André Lemburg 691270feee Deferred the attribute name object type checking to the underlying
PyObject_Set/GetAttr() calls.

This patch fixes bug #113829.
2000-09-18 16:22:27 +00:00
Guido van Rossum 6f25618be5 Add PyOS_getsig() and PyOS_setsig() -- wrappers around signal() or
sigaction() (if HAVE_SIGACTION is defined).
2000-09-16 16:32:19 +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
Jack Jansen b763b9d9d5 Cast UCHAR_MAX to int before doing the comparison for overflow of the
B format char.
2000-09-15 12:51:01 +00:00
Fred Drake fd1f1be98d com_continue_stmt(): Improve error message when continue is found
in a try statement in a loop.

This is related to SourceForge bug #110830.
2000-09-08 16:31:24 +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 f26cda62b6 The GCC version is loooooooooong; put it on a new line. 2000-09-05 04:40:39 +00:00
Guido van Rossum f4d189f70b All right. More uniformity, and extra blank lines. 2000-09-04 01:27:04 +00:00
Guido van Rossum 7ca7b5ac93 Use periods, not semicolons between Copyright and All Rights Reserved. 2000-09-04 01:22:12 +00:00
Vladimir Marangozov 547936c86f Fix the char* vs. const char* mismatch for the argument of aix_loaderror() 2000-09-04 00:54:56 +00:00
Guido van Rossum 76ad68ae6e Change the copyright notice according to CNRI's wishes, with
BeOpen.com added to the front.

(Even if maybe we won't print this long banner at startup, the string
must still be defined for sys.copyright.)
2000-09-03 03:35:50 +00:00
Fredrik Lundh 1fa0b895ec changed \x to consume exactly two hex digits. implements PEP-223
for 8-bit strings.
2000-09-02 20:11:27 +00:00
Tim Peters 412f246024 PyInterpreterState_New is not thread-safe, and the recent fix to _PyPclose
can cause it to get called by multiple threads simultaneously.

Ditto for PyInterpreterState_Delete.

Of the former, the docs say "The interpreter lock need not be held, but may
be held if it is necessary to serialize calls to this function".  This
kinda implies it both is and isn't thread-safe.

Of the latter, the docs merely say "The interpreter lock need not be
held.", and the clause about serializing is absent.

I expect it was *believed* these are both thread-safe, and the bit about
serializing via the global lock was meant as a permission rather than a
caution.

I also expect we've never seen a problem here because the Python core
(prior to the _PyPclose fix) only calls these functions once per run.
The Py_NewInterpreter subsystem exposed by the C API (but not used by
Python itself) also calls them, but that subsystem appears to be very
rarely used.

Whatever, they're both thread-safe now.
2000-09-02 09:16:15 +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
Vladimir Marangozov 7bd25be508 Cosmetics on Py_Get/SetRecursionLimit (for the style guide) 2000-09-01 11:07:19 +00:00
Jeremy Hylton b69a27e5b2 code part of patch #100895 by Fredrik Lundh
PyErr_Format computes size of buffer needed rather than relying on
static buffer.
2000-09-01 03:49:47 +00:00
Tim Peters d320c348f8 Revert removal of void from function definition. Guido sez I can take it
out again after we complete switching to C++ <wink>.  Thanks to Greg Stein
for hitting me.
2000-09-01 03:34:26 +00:00
Jeremy Hylton b709df3810 refactor __del__ exception handler into PyErr_WriteUnraisable
add sanity check to gc: if an exception occurs during GC, call
PyErr_WriteUnraisable and then call Py_FatalEror.
2000-09-01 02:47:25 +00:00
Guido van Rossum 349ff6f7e2 Set the recursion limit to 1000 -- 2500 was not enough, let's be
conservative.
2000-09-01 01:52:08 +00:00
Tim Peters 51de6906be Supply missing prototypes for new Py_{Get,Set}RecursionLimit; fixes compiler wngs;
un-analize Get's definition ("void" is needed only in declarations, not defns, &
is generally considered bad style in the latter).
2000-09-01 00:01:58 +00:00
Jeremy Hylton ee5adfbae6 add user-modifiable recursion_limit
ceval.c:
    define recurion_limit (static), default value is 2500
    define Py_GetRecursionLimit and Py_SetRecursionLimit
    raise RuntimeError if limit is exceeded
PC/config.h:
    remove plat-specific definition
sysmodule.c:
    add sys.(get|set)recursionlimit
2000-08-31 19:23:01 +00:00
Fred Drake 592f2d6c85 _PySys_Init(): When setting up sys.version_info, use #if/#elif.../#endif
instead of four #if/#endif blocks.  This shortens the
                code and improves readability.
2000-08-31 15:21:11 +00:00
Fred Drake 399739f79f PyOS_CheckStack(): Better ANSI'fy this while we're at it. 2000-08-31 05:52:44 +00:00
Fred Drake e8de31cbd0 Add a comment explaining the return value of PyOS_CheckStack(). 2000-08-31 05:38:39 +00:00
Paul Prescod e68140dd3c Better error message with UnboundLocalError 2000-08-30 20:25:01 +00:00
Barry Warsaw 093abe005d eval_code2(): Guido provides this patch for his suggested elaboration
of extended print.  If the file object being printed to is None, then
sys.stdout is used.
2000-08-29 04:56:13 +00:00
Thomas Wouters dd13e4f91f Replace the run-time 'future-bytecode-stream-inspection' hack to find out
how 'import' was called with a compiletime mechanism: create either a tuple
of the import arguments, or None (in the case of a normal import), add it to
the code-block constants, and load it onto the stack before calling
IMPORT_NAME.
2000-08-27 20:31:27 +00:00
Tim Peters e868211e10 Hard to believe Guido compiled this! Function lacked a return stmt. 2000-08-27 20:18:17 +00:00
Thomas Wouters e753ef8d1b Re-allow 'import mod.submod as s', and change its meaning to what it should
mean; the same as 'from mod import submod as s'.
2000-08-27 20:16:32 +00:00
Guido van Rossum 0df002c45b Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),
PyRun_FileEx().  These are the same as their non-Ex counterparts but
have an extra argument, a flag telling them to close the file when
done.

Then this is used by Py_Main() and execfile() to close the file after
it is parsed but before it is executed.

Adding APIs seems strange given the feature freeze but it's the only
way I see to close the bug report without incompatible changes.

[ Bug #110616 ] source file stays open after parsing is done (PR#209)
2000-08-27 19:21:52 +00:00
Fredrik Lundh 2f15b25da2 implements PyOS_CheckStack for Windows and MSVC. this fixes a
couple of potential stack overflows, including bug #110615.

closes patch #101238
2000-08-27 19:15:31 +00:00
Thomas Wouters 0ae722e0a2 Oops, one pop too many. 2000-08-27 19:01:33 +00:00
Guido van Rossum fee3a2dd8c Charles Waldman's patch to reinitialize the interpreter lock after a
fork.  This solves the test_fork1 problem.  (ceval.c, signalmodule.c,
intrcheck.c)

SourceForge: [ Patch #101226 ] make threading fork-safe
2000-08-27 17:34:07 +00:00
Marc-André Lemburg dc3d606bd9 Fix to [ Bug #111165 ] doc-string removal masked by PYTHONOPTIMIZE 2000-08-25 21:00:46 +00:00
Thomas Wouters b59290f5b2 Fix allowable node-types for assignment, need to add 'listmaker'.
(This fix is a bit broken, just as the test already was: the test for
testlist and listmaker are done always, whereas the test for exprlist and
the actual abort() are only done if Py_DEBUG is defined. Suggestions
welcome, I guess ;)
2000-08-25 05:41:11 +00:00
Fred Drake 6d63adfbb7 Improve the exceptions raised by PyErr_BadInternalCall(); adding the
filename and line number of the call site to allow esier debugging.

This closes SourceForge patch #101214.
2000-08-24 22:38:39 +00:00
Thomas Wouters 434d0828d8 Support for three-token characters (**=, >>=, <<=) which was written by
Michael Hudson, and support in general for the augmented assignment syntax.
The graminit.c patch is large!
2000-08-24 20:11:32 +00:00