Commit Graph

106 Commits

Author SHA1 Message Date
Neal Norwitz 0c766a0bb6 Change sys_exit to use METH_VARARGS.
sys.exit() now requires 0-1 arguments.  Previously 2+ arguments were allowed.
2002-03-27 13:03:09 +00:00
Neil Schemenauer 0f2103fb16 Fix wording of sys.exit docstring. Close SF bug 534113. 2002-03-23 20:46:35 +00:00
Neal Norwitz 290d31e2fc SF #506611, fix sys.setprofile(), sys.settrace() core dumps
when no arguments are passed
2002-03-03 15:12:58 +00:00
Neal Norwitz 2a47c0fa23 Fix spelling mistakes. Bugfix candidates. 2002-01-29 00:53:41 +00:00
Martin v. Löwis cdc4451222 Include <unistd.h> in Python.h. Fixes #500924. 2002-01-12 11:05:12 +00:00
Tim Peters faad5ad590 mysnprintf.c: Massive rewrite of PyOS_snprintf and PyOS_vsnprintf, to
use wrappers on all platforms, to make this as consistent as possible x-
platform (in particular, make sure there's at least one \0 byte in
the output buffer).  Also document more of the truth about what these do.

getargs.c, seterror():  Three computations of remaining buffer size were
backwards, thus telling PyOS_snprintf the buffer is larger than it
actually is.  This matters a lot now that PyOS_snprintf ensures there's a
trailing \0 byte (because it didn't get the truth about the buffer size,
it was storing \0 beyond the true end of the buffer).

sysmodule.c, mywrite():  Simplify, now that PyOS_vsnprintf guarantees to
produce a \0 byte.
2001-12-03 00:43:33 +00:00
Tim Peters 080d5b3f0b mywrite(): The test for trouble in PyOS_vsnprintf was wrong on both
ends.  Also, when there is trouble, ensure the buffer has a traiing
0 byte.
2001-12-02 08:29:16 +00:00
Jeremy Hylton 5d3d134d56 Use PyOS_vsnprintf() and check its return value.
If it returns -1 (which indicates overflow on old Linux platforms and
perhaps on Windows) or size greater than buffer, write a message
indicating that the previous message was truncated.
2001-11-28 21:44:53 +00:00
Martin v. Löwis 107b7daf5a Include sys_getdefaultencoding in #ifdef Py_USING_UNICODE. Fixes #479571. 2001-11-09 20:59:39 +00:00
Fred Drake a768882b00 Convert getrefcount() to METH_O, and sys_excepthook() to use
PyArg_UnpackTuple().
2001-10-24 20:47:48 +00:00
Fred Drake 8f51f54319 Rationalize the events passed to the profiler (no changes for the tracer).
The profiler does not need to know anything about the exception state,
so we no longer call it when an exception is raised.  We do, however,
make sure we *always* call the profiler when we exit a frame.  This
ensures that timing events are more easily isolated by a profiler and
finally clauses that do a lot of work don't have their time
mis-allocated.

When an exception is propogated out of the frame, the C callback for
the profiler now receives a PyTrace_RETURN event with an arg of NULL;
the Python-level profile hook function will see a 'return' event with
an arg of None.  This means that from Python it is impossible for the
profiler to determine if the frame exited with an exception or if it
returned None, but this doesn't matter for profiling.  A C-based
profiler could tell the difference, but this doesn't seem important.

ceval.c:eval_frame():  Simplify the code in two places so that the
                       profiler is called for every exit from a frame
                       and not for exceptions.

sysmodule.c:profile_trampoline():  Make sure we don't expose Python
                                   code to NULL; use None instead.
2001-10-04 14:48:42 +00:00
Martin v. Löwis 339d0f720e Patch #445762: Support --disable-unicode
- Do not compile unicodeobject, unicodectype, and unicodedata if Unicode is disabled
- check for Py_USING_UNICODE in all places that use Unicode functions
- disables unicode literals, and the builtin functions
- add the types.StringTypes list
- remove Unicode literals from most tests.
2001-08-17 18:39:25 +00:00
Martin v. Löwis e3eb1f2b23 Patch #427190: Implement and use METH_NOARGS and METH_O. 2001-08-16 13:15:00 +00:00
Moshe Zadka 03897ea1f7 Patch number #422106 by Greg Ball, to fix segmentation
fault in sys.displayhook.

Please check this in on the 2.2a1 branch (or whatever is necessary
to get it working next release)
2001-07-23 13:32:43 +00:00
Martin v. Löwis f0473d511b Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags.
Add dlopenflags to PyInterpreterState, and use it in dlopen calls.
2001-07-18 16:17:16 +00:00
Fred Drake 5755ce693d Revise the interface to the profiling and tracing support for the
Python interpreter.

This change adds two new C-level APIs:  PyEval_SetProfile() and
PyEval_SetTrace().  These can be used to install profile and trace
functions implemented in C, which can operate at much higher speeds
than Python-based functions.  The overhead for calling a C-based
profile function is a very small fraction of a percent of the overhead
involved in calling a Python-based function.

The machinery required to call a Python-based profile or trace
function been moved to sysmodule.c, where sys.setprofile() and
sys.setprofile() simply become users of the new interface.

As a side effect, SF bug #436058 is fixed; there is no longer a
_PyTrace_Init() function to declare.
2001-06-27 19:19:46 +00:00
Martin v. Löwis ce9b5a55e1 Encode surrogates in UTF-8 even for a wide Py_UNICODE.
Implement sys.maxunicode.
Explicitly wrap around upper/lower computations for wide Py_UNICODE.
When decoding large characters with UTF-8, represent expected test
results using the \U notation.
2001-06-27 06:28:56 +00:00
Fred Drake d083839fb4 Instead of initializing & interning the strings passed to the profile
and trace functions lazily, which incurs extra argument pushing and checks
in the C overhead for profiling/tracing, create the strings semi-lazily
when the Python code first registers a profile or trace function.  This
simplifies the trampoline into the profile/trace functions.
2001-06-16 21:02:31 +00:00
Guido van Rossum bceccf5f43 Updated version of RISCOS support. SF patch 411213 by Dietmar Schwertberger 2001-04-10 22:07:43 +00:00
Ka-Ping Yee b5c5132d1a Add sys.excepthook.
Update docstring and library reference section on 'sys' module.
New API PyErr_Display, just for displaying errors, called by excepthook.
Uncaught exceptions now call sys.excepthook; if that fails, we fall back
    to calling PyErr_Display directly.
Also comes with sys.__excepthook__ and sys.__displayhook__.
2001-03-23 02:46:52 +00:00
Guido van Rossum 03df3b3bc1 Neil discovered a bad DECREF on warnoptions, that caused repeated
re-initializing Python (Py_Finalize() followed by Py_Initialize()) to
blow up quickly.  With the DECREF removed I can't get it to fail any
more.  (Except it still leaks, but that's probably a separate issue.)
2001-01-13 22:06:05 +00:00
Greg Stein ceb9b7c700 stdout is sometimes a macro; use "outf" instead.
Submitted by: Mark Favas <m.favas@per.dem.csiro.au>
2001-01-11 09:27:34 +00:00
Moshe Zadka f68f2fec7d Implementation of PEP-0217.
This closes the PEP, and patch 103170
2001-01-11 05:41:27 +00:00
Guido van Rossum 23fff911a2 Add definitions for PySys_ResetWarnOptions() and
PySys_AddWarnOption().
2000-12-15 22:02:05 +00:00
Barry Warsaw b6a54d2a2c _getframe(): New sys module function for getting at the stack frame.
Implements and closes SF patch #102106, with Guido's suggested
documentation changes.
2000-12-06 21:47:46 +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
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
Barry Warsaw f2581c97f2 _PySys_Init(): Fix another Insure discovered memory leak; the PyString
created from the "big"/"little" constant needs to be decref'd.
2000-08-16 23:03:57 +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
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 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 f70ef4f860 Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
2000-07-22 18:47:25 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +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 582acece2e Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
tests.
2000-06-28 22:07:35 +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
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
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 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
Guido van Rossum ffc0f4fb36 Use modern PyArg_ParseTuple style, with function names.
(Mostly.)
2000-03-31 00:38:29 +00:00
Guido van Rossum 43713e5a28 Massive patch by Skip Montanaro to add ":name" to as many
PyArg_ParseTuple() format string arguments as possible.
2000-02-29 13:59:29 +00:00
Guido van Rossum be2033697f In PySys_GetObject(), it's possible that tstate->interp->sysdict is
NULL.  In that case, return NULL rather than dumping core.

This fixes PR#91, submitted by Lele Gaifax.
1999-10-05 22:17:41 +00:00
Barry Warsaw 54892c4b2c _PySys_Init(): Nailed small memory leak. The stringobject created for
sys.version was missing a Py_XDECREF().
1999-01-27 16:33:19 +00:00
Guido van Rossum a71b5f4e1d Jim Ahlstrom patch: the module doc string is too long for 16-bit VC
1.5.  Omit the second part.
1999-01-14 19:07:00 +00:00
Guido van Rossum e0d7dae3b8 Add sys.hexversion, which is an integer encoding the version in hexadecimal.
In other words, hex(sys.hexversion) == 0x010502b2 for Python 1.5.2b2.
This is derived from the new variable PY_VERSION_HEX defined in patchlevel.h.
(Cute, eh?)
1999-01-03 12:55:39 +00:00