Commit Graph

2508 Commits

Author SHA1 Message Date
Martin v. Löwis 6c5c502b91 Make PyTraceBack_Here use the current thread, not the
frame's thread state. Fixes #1579370.
Will backport.
2007-01-23 21:11:47 +00:00
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
Anthony Baxter 83955ef639 update to (c) years to include 2007 2007-01-06 04:45:54 +00:00
Raymond Hettinger 4bd97d4549 SF# 1409443: Expand comment to cover the interaction between f->f_lasti and the PREDICT macros. 2007-01-06 01:14:41 +00:00
Neal Norwitz 72cd02c041 Prevent crash on shutdown which can occur if we are finalizing
and the module dict has been cleared already and some object
raises a warning (like in a __del__).

Will backport.
2007-01-05 05:25:22 +00:00
Armin Rigo 7037085959 Forgot a case where the locals can now be a general mapping
instead of just a dictionary.  (backporting...)
2006-11-29 21:59:22 +00:00
Neal Norwitz 85dbec6da7 Bug #1588287: fix invalid assertion for `1,2` in debug builds.
Will backport
2006-11-04 19:25:22 +00:00
Neal Norwitz f733a013b2 Update comments, remove commented out code.
Move assembler structure next to assembler code to make it easier to
move it to a separate file.
2006-10-29 18:30:10 +00:00
Georg Brandl 2c4fb8d601 Clean up a leftover from old listcomp generation code. 2006-10-29 08:47:08 +00:00
Neal Norwitz 21997afb0c Fix bug #1565514, SystemError not raised on too many nested blocks.
It seems like this should be a different error than SystemError, but
I don't have any great ideas and SystemError was raised in 2.4 and earlier.

Will backport.
2006-10-28 21:19:07 +00:00
Neal Norwitz 837ce9389e Add some asserts. In sysmodule, I think these were to try to silence
some warnings from Klokwork.  They verify the assumptions of the format
of svn version output.

The assert in the thread module helped debug a problem on HP-UX.
2006-10-28 21:15:30 +00:00
Andrew M. Kuchling 1f3ebe0b10 [Bug #1542016] Report PCALL_POP value. This makes the return value of sys.callstats() match its docstring.
Backport candidate.  Though it's an API change, this is a pretty obscure
portion of the API.
2006-10-27 13:22:46 +00:00
Martin v. Löwis b5bc537c5e Patch #1549049: Rewrite type conversion in structmember.
Fixes #1545696 and #1566140. Will backport to 2.5.
2006-10-27 06:16:31 +00:00
Neal Norwitz cbeb687c68 Update the peephole optimizer to remove more dead code (jumps after returns)
and inline jumps to returns.
2006-10-14 21:33:38 +00:00
Georg Brandl 8134d06e08 Bug #1283491: follow docstring convention wrt. keyword-able args in sum(). 2006-10-12 12:33:07 +00:00
Armin Rigo 7ccbca93a2 Forward-port of r52136,52138: a review of overflow-detecting code.
* unified the way intobject, longobject and mystrtoul handle
  values around -sys.maxint-1.

* in general, trying to entierely avoid overflows in any computation
  involving signed ints or longs is extremely involved.  Fixed a few
  simple cases where a compiler might be too clever (but that's all
  guesswork).

* more overflow checks against bad data in marshal.c.

* 2.5 specific: fixed a number of places that were still confusing int
  and Py_ssize_t.  Some of them could potentially have caused
  "real-world" breakage.

* list.pop(x): fixing overflow issues on x was messy.  I just reverted
  to PyArg_ParseTuple("n"), which does the right thing.  (An obscure
  test was trying to give a Decimal to list.pop()... doesn't make
  sense any more IMHO)

* trying to write a few tests...
2006-10-04 12:17:45 +00:00
Jeremy Hylton 82271f13e7 Fix for SF bug 1569998: break permitted inside try.
The compiler was checking that there was something on the fblock
stack, but not that there was a loop on the stack.  Fixed that and
added a test for the specific syntax error.

Bug fix candidate.
2006-10-04 02:24:52 +00:00
Brett Cannon 5a9aa4f31c Fix minor typo in a comment. 2006-10-03 21:58:55 +00:00
Brett Cannon 94b69f6ba3 Very minor grammatical fix in a comment. 2006-09-28 22:10:14 +00:00
Neal Norwitz d3f91908dd Remove extra semi-colons reported by Johnny Lee on python-dev. Backport if anyone cares. 2006-09-23 04:11:38 +00:00
Neal Norwitz 3a23017bb2 Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)).
These tests should be improved.  Hopefully this fixes variations when
flipping back and forth between fpdef and fplist.

Backport candidate.
2006-09-22 08:18:10 +00:00
Walter Dörwald d14bf61d05 Fix typo. 2006-09-21 15:09:55 +00:00
Georg Brandl ec6c2dfb63 Forward-port of rev. 51857:
Building with HP's cc on HP-UX turned up a couple of problems.
_PyGILState_NoteThreadState was declared as static inconsistently.
Make it static as it's not necessary outside of this module.

Some tests failed because errno was reset to 0. (I think the tests
that failed were at least: test_fcntl and test_mailbox).
Ensure that errno doesn't change after a call to Py_END_ALLOW_THREADS.
This only affected debug builds.
2006-09-11 09:38:35 +00:00
Neal Norwitz 2a399b0f11 Properly handle a NULL returned from PyArena_New().
(Also fix some whitespace)

Klocwork #364.
2006-09-11 04:28:16 +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
Georg Brandl 98775dfebc Bug #1550983: emit better error messages for erroneous relative
imports (if not in package and if beyond toplevel package).
2006-09-06 06:09:31 +00:00
Neal Norwitz d042132268 M-x untabify 2006-09-05 04:00:12 +00:00
Neal Norwitz e4d4f00aee Add a comment about some refactoring. (There's probably more that should be done.) I will reformat this file in the next checkin due to the inconsistent tabs/spaces. 2006-09-05 03:58:26 +00:00
Neal Norwitz dac090d3e6 Bug #1520864 (again): unpacking singleton tuples in list comprehensions and
generator expressions (x for x, in ... ) works again.

Sigh, I only fixed for loops the first time, not list comps and genexprs too.
I couldn't find any more unpacking cases where there is a similar bug lurking.

This code should be refactored to eliminate the duplication.  I'm sure
the listcomp/genexpr code can be refactored.  I'm not sure if the for loop
can re-use any of the same code though.

Will backport to 2.5 (the only place it matters).
2006-09-05 03:53:08 +00:00
Neal Norwitz 477ca1c953 Fix SF #1552093, eval docstring typo (3 ps in mapping) 2006-09-05 02:25:41 +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 4f096d9487 Patch #1542451: disallow continue anywhere under a finally
I'm undecided if this should be backported to 2.5 or 2.5.1.
Armin suggested to wait (I'm of the same opinion).  Thomas W thinks
it's fine to go in 2.5.
2006-08-21 19:47:08 +00:00
Neal Norwitz 87557cd72a Add assert to make Klocwork happy (#276) 2006-08-21 18:01:30 +00:00
Jeremy Hylton 644dddcc3f Move peephole optimizer to separate file. 2006-08-21 16:19:37 +00:00
Neal Norwitz 7605936dee Handle PyString_FromInternedString() failing (unlikely, but possible).
Klocwork #325

(I'm not backporting this, but if someone wants to, feel free.)
2006-08-19 04:52:03 +00:00
Neal Norwitz 3cb31ac704 cpathname could be NULL if it was longer than MAXPATHLEN. Don't try
to write the .pyc to NULL.

Check results of PyList_GetItem() and PyModule_GetDict() are not NULL.

Klocwork 282, 283, 285
2006-08-13 18:10:47 +00:00
Neal Norwitz df6a6494cb Move/copy assert for tstate != NULL before first use.
Verify that PyEval_Get{Globals,Locals} returned valid pointers.

Klocwork 231-232
2006-08-13 18:10:10 +00:00
Neal Norwitz 8a87f5d37e Patch #1538606, Patch to fix __index__() clipping.
I modified this patch some by fixing style, some error checking, and adding
XXX comments.  This patch requires review and some changes are to be expected.
I'm checking in now to get the greatest possible review and establish a
baseline for moving forward.  I don't want this to hold up release if possible.
2006-08-12 17:03:09 +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 edb2168079 This code is actually not used unless WITHOUT_COMPLEX is defined.
However, there was no error checking that PyFloat_FromDouble returned
a valid pointer.  I believe this change is correct as it seemed
to follow other code in the area.

Klocwork # 292.
2006-08-12 01:47:59 +00:00
Neal Norwitz 43bd4db933 It's highly unlikely, though possible for PyEval_Get*() to return NULLs.
So be safe and do an XINCREF.

Klocwork # 221-222.
2006-08-12 01:46:42 +00:00
Neal Norwitz 84167d09cd Even though _Py_Mangle() isn't truly public anyone can call it and
there was no verification that privateobj was a PyString.  If it wasn't
a string, this could have allowed a NULL pointer to creep in below and crash.

I wonder if this should be PyString_CheckExact?  Must identifiers be strings
or can they be subclasses?

Klocwork #275
2006-08-12 01:45:47 +00:00
Neal Norwitz 6f5ff3f3eb Klocwork made another run and found a bunch more problems.
This is the first batch of fixes that should be easy to verify based on context.

This fixes problem numbers: 220 (ast), 323-324 (symtable),
321-322 (structseq), 215 (array), 210 (hotshot), 182 (codecs), 209 (etree).
2006-08-12 01:43:40 +00:00
Tim Peters 4643c2fda1 Followup to bug #1069160.
PyThreadState_SetAsyncExc():  internal correctness changes wrt
refcount safety and deadlock avoidance.  Also added a basic test
case (relying on ctypes) and repaired the docs.
2006-08-10 22:45:34 +00:00
Armin Rigo 97ff04789d Concatenation on a long string breaks (SF #1526585). 2006-08-09 15:37:26 +00:00
Georg Brandl 209307eb3b Introduce an upper bound on tuple nesting depth in
C argument format strings; fixes rest of #1523610.
2006-08-09 07:03:22 +00:00
Georg Brandl 7e3ba2a699 Bug #1535165: fixed a segfault in input() and raw_input() when
sys.stdin is closed.
2006-08-06 08:23:54 +00:00
Thomas Heller 74d36f0d95 On Windows, make PyErr_Warn an exported function again. 2006-08-04 18:17:40 +00:00