Commit Graph

2797 Commits

Author SHA1 Message Date
Nick Coghlan ef01d822aa Implement PEP 366 2007-12-03 12:55:17 +00:00
Christian Heimes dfdfaab1c5 Feature #1534
Added PyFloat_GetMax(), PyFloat_GetMin() and PyFloat_GetInfo() to the float API.
Added a dictionary sys.float_info with information about the internal floating point type to the sys module.
2007-12-01 11:20:10 +00:00
Amaury Forgeot d'Arc dafd32b730 Issue #1521: on 64bit platforms, str.decode fails on very long strings.
The t# and w# formats were not correctly handled.

Will backport.
2007-11-30 20:51:40 +00:00
Amaury Forgeot d'Arc 025c347d61 Issue #1402: PyInterpreterState_Clear() may still invoke user code
(in deallocation of running threads, for example), so the PyGILState_Release()
function must still be functional.
On the other hand, _PyGILState_Fini() only frees memory, and can be called later.

Backport candidate, but only after some experts comment on it.
2007-11-29 23:35:25 +00:00
Christian Heimes 28104c58d2 Expose Py_Py3kWarningFlag as sys.py3kwarning as discussed in #1504
Also added a warning.warnpy3k() as convenient method for Python 3.x related deprecation warnings.
2007-11-27 23:16:44 +00:00
Christian Heimes ffcd1e10b6 Added filename to compiling struct based on Martin's suggestion.
I'm wonder why I was trying to add the filename to the node all the time. The compiling struct is more obvious.
2007-11-24 01:36:02 +00:00
Christian Heimes 6d8fb1a444 And yet another fix for the patch. Paul Moore has send me a note that I've missed a declaration. The additional code has moved the declaration in the middle of the block. 2007-11-23 13:25:31 +00:00
Christian Heimes e36fe53d68 How did the comment get there? 2007-11-23 12:16:35 +00:00
Christian Heimes 02c9ab568d Fixed problems in the last commit. Filenames and line numbers weren't reported correctly.
Backquotes still don't report the correct file. The AST nodes only contain the line number but not the file name.
2007-11-23 12:12:02 +00:00
Christian Heimes 729ab15370 Applied patch #1754273 and #1754271 from Thomas Glee
The patches are adding deprecation warnings for back ticks and <>
2007-11-23 09:10:36 +00:00
Christian Heimes e8954f8ce7 Backport of the PCbuild9 directory from the py3k branch.
I've finished the last task for the PCbuild9 directory today. I don't think there is much left to do. Now you can all play around with the shiny new VS 2008 and try the PGO builds. I was able to get a speed improvement of about 10% on py3k.
Have fun! :)
2007-11-22 11:21:16 +00:00
Nick Coghlan 327a39b047 Patch #1739468: Directories and zipfiles containing __main__.py are now executable 2007-11-18 11:56:28 +00:00
Amaury Forgeot d'Arc 0d75f09177 Merge from py3k branch:
Correction for issue1265 (pdb bug with "with" statement).

When an unfinished generator-iterator is garbage collected, PyEval_EvalFrameEx
is called with a GeneratorExit exception set.  This leads to funny results
if the sys.settrace function itself makes use of generators.
A visible effect is that the settrace function is reset to None.
Another is that the eventual "finally" block of the generator is not called.

It is necessary to save/restore the exception around the call to the trace
function.

This happens a lot with py3k: isinstance() of an ABCMeta instance runs
    def __instancecheck__(cls, instance):
        """Override for isinstance(instance, cls)."""
        return any(cls.__subclasscheck__(c)
                   for c in {instance.__class__, type(instance)})
which lets an opened generator expression each time it returns True.

Backport candidate, even if the case is less frequent in 2.5.
2007-11-13 21:54:28 +00:00
Martin v. Löwis 63bf149a26 Patch #1418: Make the AC_REPLACE_FUNCS object files actually work. 2007-11-12 05:14:05 +00:00
Christian Heimes 004c1c1562 Backport of Guido's review of my patch. 2007-11-07 18:30:22 +00:00
Christian Heimes cea681be19 Backported fix for bug #1392 from py3k branch r58903. 2007-11-07 17:50:54 +00:00
Raymond Hettinger dc1d1ba9cf Add build option for faster loop execution. 2007-11-07 02:45:46 +00:00
Raymond Hettinger 12e94200c0 Fix marshal's incorrect handling of subclasses of builtin types (backport candidate). 2007-11-07 01:13:09 +00:00
Raymond Hettinger a45c4873fc Missing DECREFs 2007-10-25 02:26:58 +00:00
Raymond Hettinger 3a8daf5b56 Fixup error return and add support for intermixed ints and floats/ 2007-10-24 02:05:51 +00:00
Raymond Hettinger 3f8caa3ba7 Optimize sum() for integer and float inputs. 2007-10-24 01:28:33 +00:00
Neal Norwitz 15f2661758 Fix Coverity 185-186: If the passed in FILE is NULL, uninitialized memory
would be accessed.

Will backport.
2007-10-12 03:05:19 +00:00
Neal Norwitz 3adac21762 Fix Coverity #158: Check the correct variable. 2007-10-05 03:41:19 +00:00
Thomas Wouters e2176020f9 Try harder to stay within the 79-column limit. There's still two places that go (way) over, but those are harder to fix without suffering in readability. 2007-09-20 17:35:10 +00:00
Thomas Wouters ae406c6018 Whitespace cleanup. 2007-09-19 17:27:43 +00:00
Georg Brandl 5a5bc7b10d Fix #1169: remove docstrings in functions for -OO. 2007-09-19 06:37:19 +00:00
Brett Cannon 1e534b5425 Fix a crasher where Python code managed to infinitely recurse in C code without
ever going back out to Python code in PyObject_Call().  Required introducing a
static RuntimeError instance so that normalizing an exception there is no
reliance on a recursive call that would put the exception system over the
recursion check itself.
2007-09-07 04:18:30 +00:00
Nick Coghlan b90f52e932 Revert compile.c changes that shouldn't have been included in previous checkin 2007-08-25 04:35:54 +00:00
Nick Coghlan 3af0e785e7 Revert misguided attempt at fixing incompatibility between -m and -i switches (better fix coming soon) 2007-08-25 04:32:07 +00:00
Georg Brandl add36e5fdf Second half of #1752175: #ifdef out references to PyImport_DynLoadFiletab if HAVE_DYNAMIC_LOADING is not defined. 2007-08-23 18:08:06 +00:00
Alex Martelli d8672aa8a4 Fix compile.c so that it records 0.0 and -0.0 as separate constants in a code
object's co_consts tuple; add a test to show that the previous behavior (where
these two constants were "collapsed" into one) causes serious malfunctioning.
2007-08-22 21:14:17 +00:00
Georg Brandl d7e9f608c3 Revert accidental checkins from last commit. 2007-08-21 06:03:43 +00:00
Georg Brandl fdca6d8599 Demand version 2.5.1 since 2.5 has a bug with codecs.open context managers. 2007-08-21 06:01:18 +00:00
Georg Brandl 69ff5acc8b Place #ifdef Py_USING_UNICODE around decode_unicode(). 2007-08-06 07:37:58 +00:00
Neal Norwitz 2ef7582b52 Handle errors when generating a warning.
The value is always written to the returned pointer if getting it was
successful, even if a warning causes an error. (This probably doesn't matter
as the caller will probably discard the value.)

Will backport.
2007-08-05 03:23:31 +00:00
Martin v. Löwis 6819210b9e PEP 3123: Provide forward compatibility with Python 3.0, while keeping
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and
PyVarObject_HEAD_INIT.
2007-07-21 06:55:02 +00:00
Guido van Rossum b6ac23cd07 SF patch# 1755885 by Kurt Kaiser: show location of Unicode escape errors.
(Slightly tweaked for style and refcounts.)
2007-07-18 17:19:14 +00:00
Walter Dörwald 84a3efec37 Add T_PYSSIZET in structmember.h: This can be used for
Py_ssize_t members.

Simplify the implementation of UnicodeError objects:
start and end attributes are now stored directly as
Py_ssize_t members, which simplifies various get and
set functions.
2007-06-13 16:57:12 +00:00
Martin v. Löwis 6371cd8177 Patch #1733960: Allow T_LONGLONG to accept ints.
Will backport to 2.5.
2007-06-09 07:42:52 +00:00
Neal Norwitz 080b598990 Use macro version of GET_SIZE to avoid Coverity warning (#150) about a possible error. 2007-06-09 04:48:22 +00:00
Georg Brandl e06cf4534f Disallow function calls like foo(None=1).
Backport from py3k rev. 55708 by Guido.
2007-06-07 13:23:24 +00:00
Georg Brandl a5ea68905a Bug #1722484: remove docstrings again when running with -OO. 2007-06-01 11:33:33 +00:00
Neal Norwitz 2fca81cc4c Fix indentation (whitespace only). 2007-05-30 04:53:41 +00:00
Kristján Valur Jónsson 629ec26f63 Include <windows.h> after python.h, so that WINNT is properly set before windows.h is included. Fixes warnings in PC builds. 2007-05-26 19:31:39 +00:00
Neal Norwitz df25efeae9 Add a bunch more deprecation warnings for builtins that are going away in 3.0 2007-05-23 06:58:36 +00:00
Neal Norwitz 8b2bfbc198 Add -3 option to the interpreter to warn about features that are
deprecated and will be changed/removed in Python 3.0.

This patch is mostly from Anthony.  I tweaked some format and added
a little doc.
2007-05-23 06:35:32 +00:00
Georg Brandl 2134e754f2 Patch #1686487: you can now pass any mapping after '**' in function calls. 2007-05-21 20:34:16 +00:00
Collin Winter 6290305e67 Backport PEP 3110's new 'except' syntax to 2.6. 2007-05-18 23:11:24 +00:00
Neal Norwitz f6b0e4dca8 Last try for tweaking the max stack depth. 5000 was the original value,
4000 didn't work either.  1000 does work on Windows.  If 2000 works,
that will hopefully be a reasonable balance.
2007-05-17 07:04:46 +00:00
Neal Norwitz 4f82bc3183 Set the depth to something very small to try to determine if the
crashes on Windows are really due to the stack size or possibly
some other problem.
2007-05-17 06:23:50 +00:00
Neal Norwitz 117ef0863b Reduce the max stack depth to see if this fixes the segfaults on
Windows and some other boxes.  If this is successful, this rev should
be backported.  I'm not sure how close to the limit we should push this.
2007-05-17 06:11:36 +00:00
Neal Norwitz b1a9b37aa8 Fix bug in marshal where bad data would cause a segfault due to
lack of an infinite recursion check.

Contributed by Damien Miller at Google.
2007-05-16 20:05:11 +00:00
Georg Brandl bc1b5f1669 Remove an XXX that is unnecessary. 2007-05-11 09:41:37 +00:00
Kristján Valur Jónsson f030394de3 Fix problems in x64 build that were discovered by the testsuite:
- Reenable modules on x64 that had been disabled aeons ago for Itanium.
- Cleared up confusion about compilers for 64 bit windows.  There is only Itanium and x64.  Added macros MS_WINI64 and MS_WINX64 for those rare cases where it matters, such as the disabling of modules above.
- Set target platform (_WIN32_WINNT and WINVER) to 0x0501 (XP) for x64, and 0x0400 (NT 4.0) otherwise, which are the targeted minimum platforms.
- Fixed thread_nt.h.  The emulated InterlockedCompareExchange function didn´t work on x64, probaby due to the lack of a "volatile" specifier.  Anyway, win95 is no longer a target platform.
- Itertools module used wrong constant to check for overflow in count()
- PyInt_AsSsize_t couldn't deal with attribute error when accessing the __long__ member.
- PyLong_FromSsize_t() incorrectly specified that the operand were unsigned.

With these changes, the x64 passes the testsuite, for those modules present.
2007-05-03 20:27:03 +00:00
Neal Norwitz dc9b32e1ab Handle a couple of uncaught errors. This should be backported 2007-05-03 06:47:18 +00:00
Georg Brandl b8ae3d0138 Actually raise an exception before calling ast_error_finish.
Triggers an assertion otherwise.
2007-05-02 20:02:29 +00:00
Kristján Valur Jónsson f371cb1694 Remove obsolete comment. Importing of .dll files has been discontinued, only .pyd files supported on windows now. 2007-04-25 00:19:26 +00:00
Kristján Valur Jónsson 67387fb4aa Make pythoncore compile cleanly with VisualStudio 2005. Used an explicit typecast to get a 64 bit integer, and undefined the Yield macro that conflicts with winbase.h 2007-04-25 00:17:39 +00:00
Kristján Valur Jónsson 17b8e97e2e Merge change 54909 from release25-maint: Fix several minor issues discovered using code analysis in VisualStudio 2005 Team Edition 2007-04-25 00:10:50 +00:00
Neal Norwitz 68cdf8a6da SF #1701207, Fix bogus assertion (and test it!) 2007-04-16 07:37:55 +00:00
Kristján Valur Jónsson 2f2f57916c Fix a bug when using the __lltrace__ opcode tracer, and a problem sith signed chars in frameobject.c which can occur with opcodes > 127 2007-04-13 22:07:33 +00:00
Georg Brandl 5cb76c19ba Patch #1682205: a TypeError while unpacking an iterable is no longer
masked by a generic one with the message "unpack non-sequence".
2007-03-21 09:00:39 +00:00
Neal Norwitz aa754b70b0 Remove unused file spotted by Paul Hankin 2007-03-21 06:39:48 +00:00
Jeremy Hylton dd2cf1cb84 Clean up formatting of this file.
The file should now follow PEP 7, except that it uses 4 space indents
(in the style of Py3k).  This particular code would be really hard to
read with the regular tab idents.

Other changes:
 - reflow long lines
 - change multi-line conditionals to have test at end of line
2007-03-16 15:59:47 +00:00
Collin Winter 77c67bd585 Patch #1642547: Fix an error/crash when encountering syntax errors in complex if statements.
Will backport.
2007-03-16 04:11:30 +00:00
Collin Winter 47c52a8b60 Inline PyImport_GetModulesReloading(). 2007-03-13 23:02:15 +00:00
Georg Brandl 5240d7416c Patch #1444529: the builtin compile() now accepts keyword arguments.
(backport)
2007-03-13 20:46:32 +00:00
Georg Brandl 3bb156722e Typo and grammar fixes. 2007-03-13 07:23:16 +00:00
Neal Norwitz 75c7c80ee5 Fix some style nits:
* lines too long
  * wrong indentation
  * space after a function name
  * wrong function name in error string
  * simplifying some logic

Also add an error check to PyDict_SetItemString.
2007-03-13 05:31:38 +00:00
Collin Winter 276887b16d Bug #742342: make Python stop segfaulting on infinitely-recursive reload()s. Fixed by patch #922167.
Will backport.
2007-03-12 16:11:39 +00:00
Georg Brandl 7b9c555520 Bug #1678647: write a newline after printing an exception in any
case, even when converting the value to a string failed.
2007-03-12 14:30:05 +00:00
Georg Brandl 871f1bc601 Backport from Py3k branch:
Patch #1591665: implement the __dir__() special function lookup in PyObject_Dir.

Had to change a few bits of the patch because classobjs and __methods__ are still
in Py2.6.
2007-03-12 13:17:36 +00:00
Georg Brandl 7478096148 Typos. 2007-03-10 07:38:14 +00:00
Georg Brandl aa2321b0f8 Patch #703779: unset __file__ in __main__ after running a file. This
makes the filenames the warning module prints much more sensible when
a PYTHONSTARTUP file is used.
2007-03-07 00:40:28 +00:00
Georg Brandl 49aafc9f2c Variant of patch #697613: don't exit the interpreter on a SystemExit
exception if the -i command line option or PYTHONINSPECT environment
variable is given, but break into the interactive interpreter just like
on other exceptions or normal program exit.
 (backport)
2007-03-07 00:34:46 +00:00
Georg Brandl 098cd69ff9 Bug #1674503: close the file opened by execfile() in an error condition. 2007-03-06 12:17:50 +00:00
Georg Brandl 0fca97a5fb Patch #1674228: when assigning a slice (old-style), check for the
sq_ass_slice instead of the sq_slice slot.
2007-03-05 22:28:08 +00:00
Raymond Hettinger 20e1199fbe Fix embarrassing typo and fix constantification of None 2007-03-02 19:20:46 +00:00
Jeremy Hylton 819de6ce20 tabify
Note that ast.c still has a mix of tabs and spaces, because it
attempts to use four-space indents for more of the new code.
2007-02-27 16:13:23 +00:00
Jeremy Hylton 37075c5ace Fix long-standing bug in name mangling for package imports
Reported by Mike Verdone.
2007-02-27 01:01:59 +00:00
Neal Norwitz f83b751f4b SF #1669182, 2.5 was already fixed. Just assert in 2.6 since string exceptions
are gone.
2007-02-26 23:48:27 +00:00
Neal Norwitz 88516a6039 When printing an unraisable error, don't print exceptions. before the name.
This duplicates the behavior whening normally printing exceptions.
2007-02-26 22:41:45 +00:00
Neal Norwitz 7b7d1c8282 Fix a couple of problems in generating the AST code:
* use %r instead of backticks since backticks are going away in Py3k
 * PyArena_Malloc() already sets PyErr_NoMemory so we don't need to do it again
 * the signature for ast2obj_int incorrectly used a bool, rather than a long
2007-02-26 18:10:47 +00:00
Jeremy Hylton 7c1e347f73 Reformat long lines. 2007-02-26 16:14:51 +00:00
Jeremy Hylton 714b112ae5 Put declarations before code. 2007-02-25 16:01:58 +00:00
Jeremy Hylton c5ceb251b3 Fix crash in exec when unicode filename can't be decoded.
I can't think of an easy way to test this behavior.  It only occurs
when the file system default encoding and the interpreter default
encoding are different, such that you can open the file but not decode
its name.
2007-02-25 15:57:45 +00:00
Brett Cannon 0db62aaf09 Modify Parser/asdl_c.py so that the __version__ number for Python/Python-ast.c
is specified at the top of the file.  Also add a note that Python/Python-ast.c
needs to be committed separately after a change to the AST grammar to capture
the revision number of the change (which is what __version__ is set to).
2007-02-12 03:51:02 +00:00
Brett Cannon d080d4b047 Check in changed Python-ast.c from a cosmetic change to Python.asdl (in
r53731).
2007-02-11 19:44:41 +00:00
Brett Cannon 129bd52146 No more raising of string exceptions!
The next step of PEP 352 (for 2.6) causes raising a string exception to trigger
a TypeError.  Trying to catch a string exception raises a DeprecationWarning.
References to string exceptions has been removed from the docs since they are
now just an error.
2007-01-30 21:34:36 +00:00
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
Neal Norwitz 9a70f95ee8 There were really two issues 2006-08-04 05:12:19 +00:00
Neal Norwitz 0cbd805a10 Bug #1333982: string/number constants were inappropriately stored
in the byte code and co_consts even if they were not used, ie
immediately popped off the stack.
2006-08-04 05:09:28 +00:00
Neal Norwitz 4ffedadb10 Bug #1191458: tracing over for loops now produces a line event
on each iteration.  I'm not positive this is the best way to handle
this.  I'm also not sure that there aren't other cases where
the lnotab is generated incorrectly.  It would be great if people
that use pdb or tracing could test heavily.

Also:
 * Remove dead/duplicated code that wasn't used/necessary
   because we already handled the docstring prior to entering the loop.
 * add some debugging code into the compiler (#if 0'd out).
2006-08-04 04:58:47 +00:00
Neal Norwitz c173b488dc Add some asserts and update comments 2006-07-30 19:18:13 +00:00
Neal Norwitz 07aadb14f3 Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().
This provides the proper warning for struct.pack().
PyErr_Warn() is now deprecated in favor of PyErr_WarnEx().
As mentioned by Tim Peters on python-dev.
2006-07-30 06:55:48 +00:00
Neal Norwitz 0d62a06206 Patch #1531113: Fix augmented assignment with yield expressions.
Also fix a SystemError when trying to assign to yield expressions.
2006-07-30 06:53:31 +00:00
Phillip J. Eby f7575d0cb7 Bug #1529871: The speed enhancement patch #921466 broke Python's compliance
with PEP 302.  This was fixed by adding an ``imp.NullImporter`` type that is
used in ``sys.path_importer_cache`` to cache non-directory paths and avoid
excessive filesystem operations during imports.
2006-07-28 21:12:07 +00:00
Tim Peters bc24eee333 Bug #1521947: possible bug in mystrtol.c with recent gcc.
In general, C doesn't define anything about what happens when
an operation on a signed integral type overflows, and PyOS_strtol()
did several formally undefined things of that nature on signed
longs.  Some version of gcc apparently tries to exploit that now,
and PyOS_strtol() could fail to detect overflow then.

Tried to repair all that, although it seems at least as likely to me
that we'll get screwed by bad platform definitions for LONG_MIN
and/or LONG_MAX now.  For that reason, I don't recommend backporting
this.

Note that I have no box on which this makes a lick of difference --
can't really test it, except to note that it didn't break anything
on my boxes.

Silent change:  PyOS_strtol() used to return the hard-coded 0x7fffffff
in case of overflow.  Now it returns LONG_MAX.  They're the same only on
32-bit boxes (although C doesn't guarantee that either ...).
2006-07-27 01:14:53 +00:00
Georg Brandl 5f135787ec Part of bug #1523610: fix miscalculation of buffer length.
Also add a guard against NULL in converttuple and add a test case
(that previously would have crashed).
2006-07-26 08:03:10 +00:00
Andrew MacIntyre 82247cb7d1 bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
will backport.
2006-07-23 13:00:04 +00:00
Neal Norwitz f71847e645 If the for loop isn't entered, entryblock will be NULL. If passed
to stackdepth_walk it will be dereffed.

Not sure if I found with failmalloc or Klockwork #55.
2006-07-23 07:51:58 +00:00
Neal Norwitz 18b6adf9b2 Handle more mem alloc issues found with failmalloc 2006-07-23 07:50:36 +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 33722aec57 Speel initialise write. Tanks Anthony. 2006-07-21 07:59:02 +00:00
Neal Norwitz e1fdb32ff2 Handle allocation failures gracefully. Found with failmalloc.
Many (all?) of these could be backported.
2006-07-21 05:32:28 +00:00
Tim Peters 112aad3630 SF bug 1524317: configure --without-threads fails to build
Moved the code for _PyThread_CurrentFrames() up, so it's no longer
in a huge "#ifdef WITH_THREAD" block (I didn't realize it /was/ in
one).

Changed test_sys's test_current_frames() so it passes with or without
thread supported compiled in.

Note that test_sys fails when Python is compiled without threads,
but for an unrelated reason (the old test_exit() fails with an
indirect ImportError on the `thread` module).  There are also
other unrelated compilation failures without threads, in extension
modules (like ctypes); at least the core compiles again.

Do we really support --without-threads?  If so, there are several
problems remaining.
2006-07-19 00:03:19 +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
Neal Norwitz c0cde4da2a Fix memory leak under some conditions.
Reported by Klocwork, #98.
2006-07-16 02:17:36 +00:00
Neal Norwitz 84be93b2db Bug #1512814, Fix incorrect lineno's when code within a function
had more than 255 blank lines.  Byte codes need to go first, line #s second.
2006-07-16 01:50:38 +00:00
Georg Brandl 9dceedbb97 Accept long options "--help" and "--version". 2006-07-12 15:31:17 +00:00
Neal Norwitz a1f1090109 Actually change the MAGIC #. Create a new section for 2.5c1 and mention the impact of changing the MAGIC #. 2006-07-12 07:28:29 +00:00
Neal Norwitz edef2be4af Bug #1520864: unpacking singleton tuples in for loop (for x, in) work again. 2006-07-12 05:26:17 +00:00
Thomas Heller 249f6b1bf4 Add missing Py_DECREFs. 2006-07-11 16:44:25 +00:00
Tim Peters 32a8361f2d After approval from Anthony, merge the tim-current_frames
branch into the trunk.  This adds a new sys._current_frames()
function, which returns a dict mapping thread id to topmost
thread stack frame.
2006-07-10 21:08:24 +00:00
Neal Norwitz ed65755608 Bug #1512814, Fix incorrect lineno's when code at module scope
started after line 256.
2006-07-10 00:04:44 +00:00
Neal Norwitz 28746aba9b On 64 bit systems, int literals that use less than 64 bits are now ints
rather than longs.  This also fixes the test for eval(-sys.maxint - 1).
2006-07-09 22:14:42 +00:00
Neil Schemenauer 6ec6ab02c3 Fix SF bug 1441486: bad unary minus folding in compiler. 2006-07-09 21:19:29 +00:00
Neil Schemenauer 0e07b60a4e Fix AST compiler bug #1501934: incorrect LOAD/STORE_GLOBAL generation. 2006-07-09 16:16:34 +00:00
Neal Norwitz fb48afa708 Fix SF bug #1519018: 'as' is now validated properly in import statements 2006-07-08 05:31:37 +00:00
Neal Norwitz a4df11d9c3 Fix refleaks reported by Shane Hathaway in SF patch #1515361. This change
contains only the changes related to leaking the copy variable.
2006-07-06 04:28:59 +00:00
Martin v. Löwis fcfff0a7fa Bug #1417699: Reject locale-specific decimal point in float()
and atof().
2006-07-03 12:19:50 +00:00
Hye-Shik Chang e6a1cb9700 Bug #1511381: codec_getstreamcodec() in codec.c is corrected to
omit a default "error" argument for NULL pointer.  This allows
the parser to take a codec from cjkcodecs again.
(Reported by Taewook Kang and reviewed by Walter Doerwald)
2006-06-23 21:16:18 +00:00
Andrew MacIntyre 9291332de1 Patch #1454481: Make thread stack size runtime tunable.
Heavily revised, comprising revisions:
46640 - original trunk revision (backed out in r46655)
46647 - markup fix (backed out in r46655)
46692:46918 merged from branch aimacintyre-sf1454481

branch tested on buildbots (Windows buildbots had problems
not related to these changes).
2006-06-13 15:04:24 +00:00
Neal Norwitz 245ce8db46 i and j are initialized below when used. No need to do it twice 2006-06-12 02:16:10 +00:00
Neal Norwitz b9845e72f9 Get rid of f_restricted too. Doc the other 4 ints that were already removed
at the NeedForSpeed sprint.
2006-06-12 02:11:18 +00:00
Neal Norwitz 2585ad58e6 Fix indentation of case and a Py_ssize_t issue. 2006-06-12 02:09:34 +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
Georg Brandl 98251f8a2f Argh. "integer" is a very confusing word ;)
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
2006-06-08 13:31:07 +00:00
Georg Brandl 22ccbbc4ec Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking. 2006-06-08 12:45:01 +00:00
Tim Peters 02f1d0dc78 _PySys_Init(): It's rarely a good idea to size a buffer to the
exact maximum size someone guesses is needed.  In this case, if
we're really worried about extreme integers, then "cp%d" can
actually need 14 bytes (2 for "cp" + 1 for \0 at the end +
11 for -(2**31-1)).  So reserve 128 bytes instead -- nothing is
actually saved by making a stack-local buffer tiny.
2006-06-06 00:25:07 +00:00
Brett Cannon 4f7a7220c1 Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int.
Closes bug #1501223.
2006-06-05 23:51:55 +00:00
Tim Peters 28eeefe566 Revert revisions:
46640 Patch #1454481:  Make thread stack size runtime tunable.
46647 Markup fix

The first is causing many buildbots to fail test runs, and there
are multiple causes with seemingly no immediate prospects for
repairing them.  See python-dev discussion.

Note that a branch can (and should) be created for resolving these
problems, like

svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH

followed by merging rev 46647 to the new branch.
2006-06-04 23:52:47 +00:00
Georg Brandl ddbaa660d3 Patch #1346214: correctly optimize away "if 0"-style stmts
(thanks to Neal for review)
2006-06-04 21:56:52 +00:00
Andrew MacIntyre 63f0db682e clean up function declarations to conform to PEP-7 style. 2006-06-04 12:59:59 +00:00
Andrew MacIntyre 6539d2d3c7 Patch #1454481: Make thread stack size runtime tunable. 2006-06-04 12:31:09 +00:00
Armin Rigo 35f6d36951 [ 1497053 ] Let dicts propagate the exceptions in user __eq__().
[ 1456209 ] dictresize() vulnerability ( <- backport candidate ).
2006-06-01 13:19:12 +00:00
Georg Brandl bf92f46572 Convert more modules to METH_VARARGS. 2006-05-29 21:58:42 +00:00
Georg Brandl 96a8c3954c Make use of METH_O and METH_NOARGS where possible.
Use Py_UnpackTuple instead of PyArg_ParseTuple where possible.
2006-05-29 21:04:52 +00:00
Georg Brandl 80181e2b78 Fix compiler warning. 2006-05-29 14:33:55 +00:00
Georg Brandl b569ee4863 Handle PyMem_Malloc failure in pystrtod.c. Closes #1494671. 2006-05-29 14:28:05 +00:00
Georg Brandl a1121fa935 Fix #1494605. 2006-05-29 14:13:21 +00:00
Georg Brandl 5f6861df93 Correct None refcount issue in Mac modules. (Are they
still used?)
2006-05-28 21:57:35 +00:00
Georg Brandl 0fd1291c38 The empty string is a valid import path.
(fixes #1496539)
2006-05-28 20:11:45 +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
Fredrik Lundh 7a83089c06 needforspeed: backed out the Py_LOCAL-isation of ceval; the massive in-
lining killed performance on certain Intel boxes, and the "aggressive"
macro itself gives most of the benefits on others.
2006-05-27 10:39:48 +00:00
Tim Peters 7df5e7f4b2 Patch 1145039.
set_exc_info(), reset_exc_info():  By exploiting the
likely (who knows?) invariant that when an exception's
`type` is NULL, its `value` and `traceback` are also NULL,
save some cycles in heavily-executed code.

This is a "a kronar saved is a kronar earned" patch:  the
speedup isn't reliably measurable, but it obviously does
reduce the operation count in the normal (no exception
raised) path through PyEval_EvalFrameEx().

The tim-exc_sanity branch tries to push this harder, but
is still blowing up (at least in part due to pre-existing
subtle bugs that appear to have no other visible
consequences!).

Not a bugfix candidate.
2006-05-26 23:14:37 +00:00
Georg Brandl 7784f12d74 Replace Py_BuildValue("OO") by PyTuple_Pack. 2006-05-26 20:04:44 +00:00
Georg Brandl f4ef11659c Need for speed: Patch #921466 : sys.path_importer_cache is now used to cache valid and
invalid file paths for the built-in import machinery which leads to
  fewer open calls on startup.

  Also fix issue with PEP 302 style import hooks which lead to more open()
  calls than necessary.
2006-05-26 18:03:31 +00:00
Fredrik Lundh 1b94940165 Py_LOCAL shouldn't be used for data; it works for some .NET 2003 compilers,
but Trent's copy thinks that it's an anachronism...
2006-05-26 12:01:49 +00:00
Fredrik Lundh 57640f5c57 needforspeed: added PY_LOCAL_AGGRESSIVE macro to enable "aggressive"
LOCAL inlining; also added some missing whitespace
2006-05-26 11:54:04 +00:00
Fredrik Lundh b8b3c8e276 needforspeed: added Py_LOCAL macro, based on the LOCAL macro used
for SRE and others.  applied Py_LOCAL to relevant portion of ceval,
which gives a 1-2% speedup on my machine.  ymmv.
2006-05-26 11:29:39 +00:00
Brett Cannon 0ed05875b2 Swap out bare malloc()/free() use for PyMem_MALLOC()/PyMem_FREE() . 2006-05-25 20:44:08 +00:00
Georg Brandl 684fd0c8ec Replace PyObject_CallFunction calls with only object args
with PyObject_CallFunctionObjArgs, which is 30% faster.
2006-05-25 19:15:31 +00:00
Tim Peters da53afa1b0 A new table to help string->integer conversion was added yesterday to
both mystrtoul.c and longobject.c.  Share the table instead.  Also
cut its size by 64 entries (they had been used for an inscrutable
trick originally, but the code no longer tries to use that trick).
2006-05-25 17:34:03 +00:00
Thomas Wouters 143bdfcee6 Update graminit.c for the fix for #1488915, Multiple dots in relative import
statement raise SyntaxError, and add testcase.
2006-05-25 11:26:25 +00:00
Walter Dörwald c611f17418 Replace tab inside comment with space. 2006-05-25 08:53:28 +00:00
Tim Peters b713ec2531 Bug #1334662 / patch #1335972: int(string, base) wrong answers.
In rare cases of strings specifying true values near sys.maxint,
and oddball bases (not decimal or a power of 2), int(string, base)
could deliver insane answers.  This repairs all such problems, and
also speeds string->int significantly.  On my box, here are %
speedups for decimal strings of various lengths:

length speedup
------ -------
 1       12.4%
 2       15.7%
 3       20.6%
 4       28.1%
 5       33.2%
 6       37.5%
 7       41.9%
 8       46.3%
 9       51.2%
10       19.5%
11       19.9%
12       23.9%
13       23.7%
14       23.3%
15       24.9%
16       25.3%
17       28.3%
18       27.9%
19       35.7%

Note that the difference between 9 and 10 is the difference between
short and long Python ints on a 32-bit box.  The patch doesn't
actually do anything to speed conversion to long:  the speedup is
due to detecting "unsigned long" overflow more quickly.

This is a bugfix candidate, but it's a non-trivial patch and it
would be painful to separate the "bug fix" from the "speed up" parts.
2006-05-23 18:45:30 +00:00
Richard Jones cebbefc98d Applied patch 1337051 by Neal Norwitz, saving 4 ints on frame objects. 2006-05-23 18:28:17 +00:00
Georg Brandl 658d513328 PyErr_NewException now accepts a tuple of base classes as its
"base" parameter.
2006-05-23 11:17:21 +00:00
Martin v. Löwis a43190bc78 Patch #1492356: Port to Windows CE (patch set 1). 2006-05-22 09:15:18 +00:00
Neal Norwitz 4eafe9ee4f Oops, I forgot to include this file in the last commit (46046):
Bug/Patch #1481770: Use .so extension for shared libraries on HP-UX for ia64.

I suppose this could be backported if anyone cares.
2006-05-19 07:05:01 +00:00
Neal Norwitz 5ef922447c Fix #1474677, non-keyword argument following keyword. 2006-05-19 06:43:50 +00:00
Neal Norwitz 02104df4c8 Fix #132 from Coverity, retval could have been derefed
if a continue inside a try failed.
2006-05-19 06:31:23 +00:00
Martin v. Löwis 2a0ad4db3a Remove bogus DECREF of self.
Change __str__() functions to METH_O.
Change WindowsError__str__ to use PyTuple_Pack.
2006-05-15 09:22:27 +00:00
Neal Norwitz 373f0a718c - Bug #1487966: Fix SystemError with conditional expression in assignment
Most of the test_syntax changes are just updating the numbers.
2006-05-15 07:04:36 +00:00
Martin v. Löwis 879768dd97 Change WindowsError to carry the Win32 error code in winerror,
and the DOS error code in errno. Revert changes where
WindowsError catch blocks unnecessarily special-case OSError.
2006-05-11 13:28:43 +00:00
Neal Norwitz b255069d43 Micro optimization. In the first case, we know that frame->f_exc_type
is NULL, so there's no reason to do anything with it.  In the second case,
we know frame->f_exc_type is not NULL, so we can just do an INCREF.
2006-05-09 05:38:56 +00:00
Guido van Rossum da5b701aee Get rid of __context__, per the latest changes to PEP 343 and python-dev
discussion.
There are two places of documentation that still mention __context__:
Doc/lib/libstdtypes.tex -- I wasn't quite sure how to rewrite that without
spending a whole lot of time thinking about it; and whatsnew, which Andrew
usually likes to change himself.
2006-05-02 19:47:52 +00:00
Neal Norwitz c4edb0ec81 SF #1479181: split open() and file() from being aliases for each other. 2006-05-02 04:43:14 +00:00
Neal Norwitz abab1d44bb Fix a warning on ppc (debian) 2006-04-28 05:28:54 +00:00
Neal Norwitz 237bf40746 Fix a warning on alpha 2006-04-28 05:28:30 +00:00
Thomas Wouters 9df4e6f673 - Add new Warning class, ImportWarning
- Warn-raise ImportWarning when importing would have picked up a directory
   as package, if only it'd had an __init__.py. This swaps two tests (for
   case-ness and __init__-ness), but case-test is not really more expensive,
   and it's not in a speed-critical section.

 - Test for the new warning by importing a common non-package directory on
   sys.path: site-packages

 - In regrtest.py, silence warnings generated by the build-environment
   because Modules/ (which is added to sys.path for Setup-created modules)
   has 'zlib' and '_ctypes' directories without __init__.py's.
2006-04-27 23:13:20 +00:00
Thomas Wouters 1ddba60e3d Define MAXPATHLEN to be at least PATH_MAX, if that's defined. Python uses
MAXPATHLEN-sized buffers for various output-buffers (like to realpath()),
and that's correct on BSD platforms, but not Linux (which uses PATH_MAX, and
does not define MAXPATHLEN.) Cursory googling suggests Linux is following a
newer standard than BSD, but in cases like this, who knows. Using the
greater of PATH_MAX and 1024 as a fallback for MAXPATHLEN seems to be the
most portable solution.
2006-04-25 15:29:46 +00:00
Martin v. Löwis 6685128b97 Fix more ssize_t issues. 2006-04-22 11:40:03 +00:00
Thomas Wouters 79cdce35de Teach Python/ceval.c's inlining of 'str += str' about Py_ssize_t sizes; this
was having funny effects when called on >2Gb strings ;P
2006-04-19 15:09:44 +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
Jeremy Hylton a4ebc135ac Refactor: Move code that uses co_lnotab from ceval to codeobject 2006-04-18 14:47:00 +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
Skip Montanaro b507972cdd C++ compiler cleanup: cast... 2006-04-18 00:57:15 +00:00
Skip Montanaro 53a6d1de83 C++ compiler cleanup: extern "C" a couple declarations, cast int to size_t 2006-04-18 00:55:46 +00:00
Skip Montanaro 7ff54e7706 C++ compiler cleanup: migrate to modsupport.h 2006-04-18 00:53:48 +00:00
Ronald Oussoren 6c1074888e This patches fixes a number of byteorder problems in MacOSX specific code. 2006-04-17 13:40:08 +00:00
Neal Norwitz 1a26920506 moduleName can be NULL 2006-04-17 00:33:23 +00:00
Thomas Wouters b8f81d4863 Add missing DECREF to PyErr_WriteUnraisable(). That function reports
exceptions that can't be raised any further, because (for instance) they
occur in __del__ methods. The coroutine tests in test_generators was
triggering this leak. Remove the leakers' testcase, and add a simpler
testcase that explicitly tests this leak to test_generators.

test_generators now no longer leaks at all, on my machine. This fix may also
solve other leaks, but my full refleakhunting run is still busy, so who
knows?
2006-04-15 23:27:28 +00:00
Thomas Wouters c6e55068ca Use Py_VISIT in all tp_traverse methods, instead of traversing manually or
using a custom, nearly-identical macro. This probably changes how some of
these functions are compiled, which may result in fractionally slower (or
faster) execution. Considering the nature of traversal, visiting much of the
address space in unpredictable patterns, I'd argue the code readability and
maintainability is well worth it ;P
2006-04-15 21:47:09 +00:00
Martin v. Löwis ab0e284a24 Zap ZAP. 2006-04-15 18:14:21 +00:00
Thomas Wouters edf17d8798 Use Py_CLEAR instead of in-place DECREF/XDECREF or custom macros, for
tp_clear methods.
2006-04-15 17:28:34 +00:00
Martin v. Löwis 841747cb56 Fix sys.getobjects(0): we get a reference to the
arena's "private" list of objects, so there might
be two references to that list.
2006-04-15 12:46:09 +00:00
Martin v. Löwis 5cb6936672 Make Py_BuildValue, PyObject_CallFunction and
PyObject_CallMethod aware of PY_SSIZE_T_CLEAN.
2006-04-14 09:08:42 +00:00
Neal Norwitz 615461603c SF Bug #1454485, array.array('u') could crash the interpreter when
passing a string.  Martin already fixed the actual crash by ensuring
Py_UNICODE is unsigned.  As discussed on python-dev, this fix
removes the possibility of creating a unicode string from a raw buffer.

There is an outstanding question of how to fix the crash in 2.4.
2006-04-14 05:20:28 +00:00
Neal Norwitz 8c0dc84398 ALIGNMENT_SHIFT is not used 2006-04-14 03:53:34 +00:00
Martin v. Löwis da69041123 Force 8-alignment of memory blocks, as needed on
64-bit machines that require pointers to be aligned (e.g. IA64)
2006-04-13 19:16:13 +00:00
Martin v. Löwis f33dea2961 Fix type errors. 2006-04-13 13:08:58 +00:00
Martin v. Löwis 0cc56e5c59 Introduce asdl_int_seq, to hold cmpop_ty. 2006-04-13 12:29:43 +00:00
Skip Montanaro 869bacd465 revert - breaks build of Python/ast.c w/ gcc 2006-04-13 09:48:28 +00:00
Skip Montanaro b940671186 Use union to discriminate pointer types from enum/int types. 2006-04-13 09:37:01 +00:00
Georg Brandl 7f573f7319 Add a test for Py_ssize_t. Correct typo in getargs.c. 2006-04-13 07:59:30 +00:00
Martin v. Löwis b1ed7fac12 Replace INT_MAX with PY_SSIZE_T_MAX. 2006-04-13 07:52:27 +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