Commit Graph

253 Commits

Author SHA1 Message Date
Thomas Wouters afea529088 SF patch #1630975: Fix crash when replacing sys.stdout in sitecustomize
When running the interpreter in an environment that would cause it to set
stdout/stderr/stdin's encoding, having a sitecustomize that would replace
them with something other than PyFile objects would crash the interpreter.
Fix it by simply ignoring the encoding-setting for non-files.

This could do with a test, but I can think of no maintainable and portable
way to test this bug, short of adding a sitecustomize.py to the buildsystem
and have it always run with it (hmmm....)
2007-01-23 13:42:00 +00:00
Neal Norwitz ca460d9722 with and as are now keywords. There are some generated files I can't recreate. 2006-09-06 06:28:06 +00:00
Neal Norwitz 0c6ae5bad4 Handle a few more error conditions.
Klocwork 301 and 302.  Will backport.
2006-08-21 20:16:24 +00:00
Neal Norwitz 0f7dbf731a PyModule_GetDict() can fail, produce fatal errors if this happens on startup.
Klocwork #298-299.
2006-08-12 03:17:41 +00:00
Neal Norwitz 421c1319ad Whoops, how did that get in there. :-) Revert all the parts of 51227 that were not supposed to go it. Only Modules/_ctypes/cfields.c was supposed to be changed 2006-08-12 02:12:30 +00:00
Neal Norwitz 6b4953fd3d Check returned pointer is valid.
Klocwork #233
2006-08-12 02:06:34 +00:00
Neal Norwitz b59d08c2fb Fix more memory allocation issues found with failmalloc. 2006-07-22 16:20:49 +00:00
Neal Norwitz d12bd012a6 Handle more memory allocation failures without crashing. 2006-07-21 07:59:47 +00:00
Neal Norwitz a5e4f22bfb Reported by Klocwork #151.
v2 can be NULL if exception2 is NULL.  I don't think that condition can happen,
but I'm not sure it can't either.  Now the code will protect against either
being NULL.
2006-07-17 00:59:04 +00:00
Martin v. Löwis 0e8bd7e1cc Patch #1495999: Part two of Windows CE changes.
- update header checks, using autoconf
- provide dummies for getenv, environ, and GetVersion
- adjust MSC_VER check in socketmodule.c
2006-06-10 12:23:46 +00:00
Tim Peters 5e9d6cfbda PyErr_Display(), PyErr_WriteUnraisable(): Coverity found a cut-and-paste
bug in both:  `className` was referenced before being checked for NULL.
2006-05-28 10:41:29 +00:00
Richard Jones 7b9558d37d Conversion of exceptions over from faked-up classes to new-style C types. 2006-05-27 12:29:24 +00:00
Thomas Heller 1b04664eab Change those parts of the Python-api that were functions in 2.4, and
are now macros to exported functions again.

Fixes [ 1465834 ] bdist_wininst preinstall script support is broken in 2.5a1.
2006-04-18 18:51:06 +00:00
Martin v. Löwis 45294a9562 Remove types from type_list if they have no objects
and unlist_types_without_objects is set.
Give dump_counts a FILE* argument.
2006-04-18 06:24:08 +00:00
Anthony Baxter ac6bd46d5c spread the extern "C" { } magic pixie dust around. Python itself builds now
using a C++ compiler. Still lots and lots of errors in the modules built by
setup.py, and a bunch of warnings from g++ in the core.
2006-04-13 02:06:09 +00:00
Armin Rigo e170937af6 Ignore the references to the dummy objects used as deleted keys
in dicts and sets when computing the total number of references.
2006-04-12 17:06:05 +00:00
Martin v. Löwis ea62d2535f Bug #1421664: Set sys.stderr.encoding 2006-04-03 10:56:49 +00:00
Tim Peters 62e97f023b In format strings slinging Py_ssize_t, unconditionally
interpolate PY_FORMAT_SIZE_T instead of #if'ing on
MS_WIN64.
2006-03-28 21:44:32 +00:00
Tim Peters c9d78aa470 Years in the making.
objimpl.h, pymem.h:  Stop mapping PyMem_{Del, DEL} and PyMem_{Free, FREE}
to PyObject_{Free, FREE} in a release build.  They're aliases for the
system free() now.

_subprocess.c/sp_handle_dealloc():  Since the memory was originally
obtained via PyObject_NEW, it must be released via PyObject_FREE (or
_DEL).

pythonrun.c, tokenizer.c, parsermodule.c:  I lost count of the number of
PyObject vs PyMem mismatches in these -- it's like the specific
function called at each site was picked at random, sometimes even with
memory obtained via PyMem getting released via PyObject.  Changed most
to use PyObject uniformly, since the blobs allocated are predictably
small in most cases, and obmalloc is generally faster than system
mallocs then.

If extension modules in real life prove as sloppy as Python's front
end, we'll have to revert the objimpl.h + pymem.h part of this patch.
Note that no problems will show up in a debug build (all calls still go
thru obmalloc then). Problems will show up only in a release build, most
likely segfaults.
2006-03-26 23:27:58 +00:00
Guido van Rossum 9d7855076a Address an coverity issue. Coverity was complaining about a line that's fine,
but an earlier line checked for v != NULL unnecessarily.
2006-03-07 18:31:44 +00:00
Neal Norwitz f2e0c45492 Fix warnings on x86 (32-bit). 2006-03-06 23:31:27 +00:00
Martin v. Löwis 99b93c2824 Use %Id for size_t-ish things on Win64. 2006-03-05 05:33:54 +00:00
Neal Norwitz 4281cef205 Use Py_ssize_t for _Py_RefTotal.
I tried to handle Win64 properly, but please review.
2006-03-04 19:58:13 +00:00
Neal Norwitz 9589ee276a Tabify 2006-03-04 19:01:22 +00:00
Neal Norwitz e92fba0a12 Get rid of run_err_mod(). It was only used in two places.
One place it wasn't necessary since mod was already checked.
Inline the check that mod != NULL for the other use.
2006-03-04 18:52:26 +00:00
Brett Cannon 2e63b73a2c Fix refleak in PyErr_Display(). 2006-03-02 18:34:57 +00:00
Martin v. Löwis 056a69cba6 Reconst parameters that lost their const in the AST merge. 2006-03-01 16:55:42 +00:00
Brett Cannon bf36409e2a PEP 352 implementation. Creates a new base class, BaseException, which has an
added message attribute compared to the previous version of Exception.  It is
also a new-style class, making all exceptions now new-style.  KeyboardInterrupt
and SystemExit inherit from BaseException directly.  String exceptions now
raise DeprecationWarning.

Applies patch 1104669, and closes bugs 1012952 and 518846.
2006-03-01 04:25:17 +00:00
Thomas Wouters 34aa7ba114 from __future__ import with_statement addon for 'with', mostly written by
Neal.
2006-02-28 19:02:24 +00:00
Martin v. Löwis 2b366e41c3 Check whether there are flags. 2006-02-26 22:12:35 +00:00
Martin v. Löwis bd260da900 Generate code to recursively copy an AST into
a tree of Python objects. Expose this through compile().
2006-02-26 19:42:26 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Neal Norwitz db83eb3170 Fix Bug #1378022, UTF-8 files with a leading BOM crashed the interpreter.
Needs backport.
2005-12-18 05:29:30 +00:00
Neal Norwitz adb69fcdff Merge from ast-arena. This reduces the code in Python/ast.c by ~300 lines,
simplifies a lot of error handling code, and fixes many memory leaks.
2005-12-17 20:54:49 +00:00
Martin v. Löwis b45b315855 Patch #1350409: Port signal handling to VS 2005. 2005-11-28 17:34:23 +00:00
Jeremy Hylton 3e0055f8c6 Merge ast-branch to head
This change implements a new bytecode compiler, based on a
transformation of the parse tree to an abstract syntax defined in
Parser/Python.asdl.

The compiler implementation is not complete, but it is in stable
enough shape to run the entire test suite excepting two disabled
tests.
2005-10-20 19:59:25 +00:00
Neal Norwitz 40d3781416 - Fix segfault with invalid coding.
- SF Bug #772896, unknown encoding results in MemoryError, which is not helpful

I will only backport the segfault fix.  I'll let Anthony decide if he wants
the other changes backported.  I will do the backport if asked.
2005-10-02 01:48:49 +00:00
Martin v. Löwis d35edda682 Forward UnicodeDecodeError into SyntaxError for source encoding errors.
Will backport to 2.4.
2005-08-24 08:39:24 +00:00
Raymond Hettinger d794666048 * Improve code for the empty frozenset singleton:
- Handle both frozenset() and frozenset([]).
  - Do not use singleton for frozenset subclasses.
  - Finalize the singleton.
  - Add test cases.
* Factor-out set_update_internal() from set_update().  Simplifies the
  code for several internal callers.
* Factor constant expressions out of loop in set_merge_internal().
* Minor comment touch-ups.
2005-08-01 21:39:29 +00:00
Michael W. Hudson ba283e2b7f This is my patch:
[ 1181301 ] make float packing copy bytes when they can

which hasn't been reviewed, despite numerous threats to check it in
anyway if noone reviews it.  Please read the diff on the checkin list,
at least!

The basic idea is to examine the bytes of some 'probe values' to see if
the current platform is a IEEE 754-ish platform, and if so
_PyFloat_{Pack,Unpack}{4,8} just copy bytes around.

The rest is hair for testing, and tests.
2005-05-27 15:23:20 +00:00
Anthony Baxter 12b6f6cac7 Move exception finalisation later in the shutdown process - this
fixes the crash seen in bug #1165761
2005-03-29 13:36:16 +00:00
Martin v. Löwis 4bf108d74f Patch #802188: better parser error message for non-EOL following line cont. 2005-03-03 11:45:45 +00:00
Anthony Baxter 9ceaa72ebe Patch #975056 - fixes for restartable signals on *BSD. In addition,
a few remaining calls to signal() were converted to PyOS_setsig().
2004-10-13 14:48:50 +00:00
Tim Peters 7f468f29f4 SF patch 1044089: New C API function PyEval_ThreadsInitialized(), by Nick
Coghlan, for determining whether PyEval_InitThreads() has been called.
Also purged the undocumented+unused _PyThread_Started int.
2004-10-11 02:40:51 +00:00
Raymond Hettinger fb09f0e85c Finalize the freelist of list objects. 2004-10-07 03:58:07 +00:00
Martin v. Löwis 336e85f56a Patch #900727: Add Py_InitializeEx to allow embedding without signals. 2004-08-19 11:31:58 +00:00
Martin v. Löwis c2632a5c34 Patch #984714: Properly diagnose E_DECODE errors.
Backported to 2.3.
2004-07-21 05:35:02 +00:00
Michael W. Hudson 30ea2f223f This closes patch:
[ 960406 ] unblock signals in threads

although the changes do not correspond exactly to any patch attached to
that report.

Non-main threads no longer have all signals masked.

A different interface to readline is used.

The handling of signals inside calls to PyOS_Readline is now rather
different.

These changes are all a bit scary!  Review and cross-platform testing
much appreciated.
2004-07-07 17:44:12 +00:00
Nicholas Bastin e5662aedef Changed random calls to PyThreadState_Get() to use the macro 2004-03-24 22:22:12 +00:00
Armin Rigo 5d2c68359b Lost reference. 2004-03-22 20:16:58 +00:00