Commit Graph

145 Commits

Author SHA1 Message Date
Antoine Pitrou f95a1b3c53 Recorded merge of revisions 81029 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines

  Untabify C files. Will watch buildbots.
........
2010-05-09 15:52:27 +00:00
Gregory P. Smith fb94c5f1e5 * Replaces the internals of the subprocess module from fork through exec on
POSIX systems with a C extension module.  This is required in order for
  the subprocess module to be made thread safe.

  The pure python implementation is retained so that it can continue to be
  used if for some reason the _posixsubprocess extension module is not
  available.

  The unittest executes tests on both code paths to guarantee compatibility.

* Moves PyLong_FromPid and PyLong_AsPid from posixmodule.c into longobject.h.

Code reviewed by jeffrey.yasskin at http://codereview.appspot.com/223077/show
2010-03-14 06:49:55 +00:00
Benjamin Peterson e39d5d5f81 Merged revisions 73782-73784 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r73782 | benjamin.peterson | 2009-07-02 16:44:01 -0500 (Thu, 02 Jul 2009) | 1 line

  the old CO_FUTURE flags can't be commented out
................
  r73783 | benjamin.peterson | 2009-07-02 16:54:36 -0500 (Thu, 02 Jul 2009) | 1 line

  a little more fiddling to make flags like 2.x
................
  r73784 | benjamin.peterson | 2009-07-02 16:55:39 -0500 (Thu, 02 Jul 2009) | 9 lines

  Merged revisions 73781 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r73781 | benjamin.peterson | 2009-07-02 16:38:36 -0500 (Thu, 02 Jul 2009) | 1 line

    test that compile() accepts the future flag
  ........
................
2009-07-02 22:02:15 +00:00
Benjamin Peterson ffeaa88525 a little more fiddling to make flags like 2.x 2009-07-02 21:54:36 +00:00
Benjamin Peterson 466a7822c1 the old CO_FUTURE flags can't be commented out 2009-07-02 21:44:01 +00:00
Brett Cannon e3944a5e1e The BDFL has retired! Long live the FLUFL (Friendly Language Uncle For Life)! 2009-04-01 05:08:41 +00:00
Benjamin Peterson f5b52246ed ignore the coding cookie in compile(), exec(), and eval() if the source is a string #4626 2009-03-02 23:31:26 +00:00
Amaury Forgeot d'Arc 3d17a5c5ae Merged revisions 64214 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r64214 | amaury.forgeotdarc | 2008-06-13 02:42:22 +0200 (ven., 13 juin 2008) | 6 lines

  Restore support for Microsoft VC6 compiler.
  Some functions in the msvcrt module are skipped,
  and socket.ioctl is enabled only when using a more recent Platform SDK.

  (and yes, there are still companies that use a 10-years old compiler)
........
2008-06-13 01:09:34 +00:00
Christian Heimes 72b710a596 Renamed PyString to PyBytes 2008-05-26 13:28:38 +00:00
Christian Heimes 9c4756ea26 Renamed PyBytes to PyByteArray 2008-05-26 13:22:05 +00:00
Martin v. Löwis 790465fd90 Change command line processing API to use wchar_t.
Fixes #2128.
2008-04-05 20:41:37 +00:00
Christian Heimes 77c02ebf38 Merged revisions 60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,60505-60506,60508-60509,60523-60524,60532,60543,60545,60547-60548,60552,60554,60556-60559,60561-60562,60569,60571-60572,60574,60576-60583,60585-60586,60589,60591,60594-60595,60597-60598,60600-60601,60606-60612,60615,60617-60678 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r60618 | walter.doerwald | 2008-02-06 15:31:55 +0100 (Wed, 06 Feb 2008) | 6 lines

  Remove month parameter from Calendar.yeardatescalendar(),
  Calendar.yeardays2calendar() and Calendar.yeardayscalendar() as the methods
  don't have such a parameter. Fixes issue #2017.

  Rewrap content to 80 chars.
........
  r60622 | facundo.batista | 2008-02-06 20:28:49 +0100 (Wed, 06 Feb 2008) | 4 lines


  Fixes issue 1959. Converted tests to unittest.
  Thanks Giampaolo Rodola.
........
  r60626 | thomas.heller | 2008-02-06 21:29:17 +0100 (Wed, 06 Feb 2008) | 3 lines

  Fixed refcounts and error handling.

  Should not be merged to py3k branch.
........
  r60630 | mark.dickinson | 2008-02-06 23:10:50 +0100 (Wed, 06 Feb 2008) | 4 lines

  Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN
  raise InvalidOperation (and return False if InvalidOperation is trapped).
........
  r60632 | mark.dickinson | 2008-02-06 23:25:16 +0100 (Wed, 06 Feb 2008) | 2 lines

  Remove incorrect usage of :const: in documentation.
........
  r60634 | georg.brandl | 2008-02-07 00:45:51 +0100 (Thu, 07 Feb 2008) | 2 lines

  Revert accidental changes to test_queue in r60605.
........
  r60636 | raymond.hettinger | 2008-02-07 01:54:20 +0100 (Thu, 07 Feb 2008) | 1 line

  Issue 2025:  Add tuple.count() and tuple.index() to follow the ABC in collections.Sequence.
........
  r60637 | mark.dickinson | 2008-02-07 02:14:23 +0100 (Thu, 07 Feb 2008) | 2 lines

  Fix broken link in decimal documentation.
........
  r60638 | mark.dickinson | 2008-02-07 02:42:06 +0100 (Thu, 07 Feb 2008) | 3 lines

  IEEE 754 should be IEEE 854;  give precise reference for
  comparisons involving NaNs.
........
  r60639 | raymond.hettinger | 2008-02-07 03:12:52 +0100 (Thu, 07 Feb 2008) | 1 line

  Return ints instead of longs for tuple.count() and tuple.index().
........
  r60640 | raymond.hettinger | 2008-02-07 04:10:33 +0100 (Thu, 07 Feb 2008) | 1 line

  Merge 60627.
........
  r60641 | raymond.hettinger | 2008-02-07 04:25:46 +0100 (Thu, 07 Feb 2008) | 1 line

  Merge r60628, r60631, and r60633.  Register UserList and UserString will the appropriate ABCs.
........
  r60642 | brett.cannon | 2008-02-07 08:47:31 +0100 (Thu, 07 Feb 2008) | 3 lines

  Cast a struct to a void pointer so as to do a type-safe pointer comparison
  (mistmatch found by clang).
........
  r60643 | brett.cannon | 2008-02-07 09:04:07 +0100 (Thu, 07 Feb 2008) | 2 lines

  Remove unnecessary curly braces around an int literal.
........
  r60644 | andrew.kuchling | 2008-02-07 12:43:47 +0100 (Thu, 07 Feb 2008) | 1 line

  Update URL
........
  r60645 | facundo.batista | 2008-02-07 17:16:29 +0100 (Thu, 07 Feb 2008) | 4 lines


  Fixes issue 2026.  Tests converted to unittest.  Thanks
  Giampaolo Rodola.
........
  r60646 | christian.heimes | 2008-02-07 18:15:30 +0100 (Thu, 07 Feb 2008) | 1 line

  Added some statistics code to dict and list object code. I wanted to test how a larger freelist affects the reusage of freed objects. Contrary to my gut feelings 80 objects is more than fine for small apps. I haven't profiled a large app yet.
........
  r60648 | facundo.batista | 2008-02-07 20:06:52 +0100 (Thu, 07 Feb 2008) | 6 lines


  Fixes Issue 1401. When redirected, a possible POST get converted
  to GET, so it loses its payload. So, it also must lose the
  headers related to the payload (if it has no content any more,
  it shouldn't indicate content length and type).
........
  r60649 | walter.doerwald | 2008-02-07 20:30:22 +0100 (Thu, 07 Feb 2008) | 3 lines

  Clarify that the output of TextCalendar.formatmonth() and
  TextCalendar.formatyear() for custom instances won't be influenced by calls
  to the module global setfirstweekday() function. Fixes #2018.
........
  r60651 | walter.doerwald | 2008-02-07 20:48:34 +0100 (Thu, 07 Feb 2008) | 3 lines

  Fix documentation for Calendar.iterweekdays(): firstweekday is a property.
  Fixes second part of #2018.
........
  r60653 | walter.doerwald | 2008-02-07 20:57:32 +0100 (Thu, 07 Feb 2008) | 2 lines

  Fix typo in docstring for Calendar.itermonthdays().
........
  r60655 | raymond.hettinger | 2008-02-07 21:04:37 +0100 (Thu, 07 Feb 2008) | 1 line

  The float conversion recipe is simpler in Py2.6
........
  r60657 | raymond.hettinger | 2008-02-07 21:10:49 +0100 (Thu, 07 Feb 2008) | 1 line

  Fix typo
........
  r60660 | brett.cannon | 2008-02-07 23:27:10 +0100 (Thu, 07 Feb 2008) | 3 lines

  Make sure a switch statement does not have repetitive case statements.
  Error found through LLVM post-2.1 svn.
........
  r60661 | christian.heimes | 2008-02-08 01:11:31 +0100 (Fri, 08 Feb 2008) | 1 line

  Deallocate content of the dict free list on interpreter shutdown
........
  r60662 | christian.heimes | 2008-02-08 01:14:34 +0100 (Fri, 08 Feb 2008) | 1 line

  Use prefix decrement
........
  r60663 | amaury.forgeotdarc | 2008-02-08 01:56:02 +0100 (Fri, 08 Feb 2008) | 5 lines

  issue 2045: Infinite recursion when printing a subclass of defaultdict,
  if default_factory is set to a bound method.

  Will backport.
........
  r60667 | jeffrey.yasskin | 2008-02-08 07:45:40 +0100 (Fri, 08 Feb 2008) | 2 lines

  Oops! 2.6's Rational.__ne__ didn't work.
........
  r60671 | hyeshik.chang | 2008-02-08 18:10:20 +0100 (Fri, 08 Feb 2008) | 2 lines

  Update big5hkscs codec to conform to the HKSCS:2004 revision.
........
  r60673 | raymond.hettinger | 2008-02-08 23:30:04 +0100 (Fri, 08 Feb 2008) | 4 lines

  Remove unnecessary modulo division.
  The preceding test guarantees that 0 <= i < len.
........
  r60674 | raymond.hettinger | 2008-02-09 00:02:27 +0100 (Sat, 09 Feb 2008) | 1 line

  Speed-up __iter__() mixin method.
........
  r60675 | raymond.hettinger | 2008-02-09 00:34:21 +0100 (Sat, 09 Feb 2008) | 1 line

  Fill-in missing Set comparisons
........
  r60677 | raymond.hettinger | 2008-02-09 00:57:06 +0100 (Sat, 09 Feb 2008) | 1 line

  Add advice on choosing between DictMixin and MutableMapping
........
2008-02-09 02:18:51 +00:00
Christian Heimes 217cfd1c86 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h 2007-12-02 14:31:20 +00:00
Martin v. Löwis 85bcc66bb4 Convert code from sys.stdin.encoding to UTF-8 in
interactive mode. Fixes #1100.
2007-09-04 09:18:06 +00:00
Collin Winter 670e692134 Patch #1680961: remove sys.exitfunc and replace it with a private C API. Also, reimplement atexit in C so it can take advantage of this private API. 2007-03-21 02:57:17 +00:00
Neal Norwitz 6968b056ef SF patch #1669633, add methods for bytes from Pete Shinners. 2007-02-27 19:02:19 +00:00
Guido van Rossum 45aecf451a Checkpoint. 218 tests are okay; 53 are failing. Done so far:
- all classes are new-style (but ripping out classobject.[ch] isn't done)
- int/int -> float
- all exceptions must derive from BaseException
- absolute import
- 'as' and 'with' are keywords
2006-03-15 04:58:47 +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
Thomas Wouters 34aa7ba114 from __future__ import with_statement addon for 'with', mostly written by
Neal.
2006-02-28 19:02:24 +00:00
Thomas Wouters f7f438ba3b SF patch #1438387, PEP 328: relative and absolute imports.
- IMPORT_NAME takes an extra argument from the stack: the relativeness of
   the import. Only passed to __import__ when it's not -1.

 - __import__() takes an optional 5th argument for the same thing; it
   __defaults to -1 (old semantics: try relative, then absolute)

 - 'from . import name' imports name (be it module or regular attribute)
   from the current module's *package*. Likewise, 'from .module import name'
   will import name from a sibling to the current module.

 - Importing from outside a package is not allowed; 'from . import sys' in a
   toplevel module will not work, nor will 'from .. import sys' in a
   (single-level) package.

 - 'from __future__ import absolute_import' will turn on the new semantics
   for import and from-import: imports will be absolute, except for
   from-import with dots.

Includes tests for regular imports and importhooks, parser changes and a
NEWS item, but no compiler-package changes or documentation changes.
2006-02-28 16:09:29 +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
Neal Norwitz ab51f5f24d Per discussion on python-dev, remove CO_GENERATOR_ALLOWED. Leave comment about not removing yet. 2006-02-25 15:43:10 +00:00
Martin v. Löwis 43b57805fb Drop sys.build_number. Add sys.subversion. 2006-01-05 23:38:54 +00:00
Barry Warsaw 2a38a86c1c Expose Subversion revision number (calculated via "svnversion .") to Python.
Add C API function Py_GetBuildNumber(), add it to the interactive prompt
banner (i.e. Py_GetBuildInfo()), and add it as the sys.build_number
attribute.  The build number is a string instead of an int because it may
contain a trailing 'M' if there are local modifications.
2005-12-18 01:27:35 +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
Mark Hammond f3ddaee9a0 Correct error to PyRun_SimpleString macro introduced in AST merge. 2005-10-23 10:53:06 +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
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
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
Jason Tishler 0d2a75c7b8 Patch #1006003: Cygwin standard module build problems
Add missing PyAPI_FUNC/PyAPI_DATA macros.
2004-08-09 15:02:30 +00:00
Guido van Rossum 4b499dd3fb - Finally fixed the bug in compile() and exec where a string ending
with an indented code block but no newline would raise SyntaxError.
  This would have been a four-line change in parsetok.c...  Except
  codeop.py depends on this behavior, so a compilation flag had to be
  invented that causes the tokenizer to revert to the old behavior;
  this required extra changes to 2 .h files, 2 .c files, and 2 .py
  files.  (Fixes SF bug #501622.)
2003-02-13 22:07:59 +00:00
Just van Rossum 3aaf42c613 patch #683515: "Add unicode support to compile(), eval() and exec"
Incorporated nnorwitz's comment re. Py__USING_UNICODE.
2003-02-10 08:21:10 +00:00
Neal Norwitz dc392e3143 Move _PyInt_Init() into pythonrun.h, since all the other _Init()
functions are here.  Suggested by Skip.
2003-01-01 15:18:32 +00:00
Neal Norwitz b2501f4cd1 Since the *_Init() are private, prefix with _, suggested by Skip 2002-12-31 03:42:13 +00:00
Neal Norwitz c91ed400e0 SF #561244, Micro optimizations
Initialize the small integers and __builtins__ in startup.
This removes some if conditions.
Change XDECREF to DECREF for values which shouldn't be NULL.
2002-12-30 22:29:22 +00:00
Just van Rossum 52e14d640b PEP 302 + zipimport:
- new import hooks in import.c, exposed in the sys module
- new module called 'zipimport'
- various changes to allow bootstrapping from zip files

I hope I didn't break the Windows build (or anything else for that
matter), but then again, it's been sitting on sf long enough...

Regarding the latest discussions on python-dev: zipimport sets
pkg.__path__ as specified in PEP 273, and likewise, sys.path item such as
/path/to/Archive.zip/subdir/ are supported again.
2002-12-30 22:08:05 +00:00
Martin v. Löwis 95292d6caa Constify filenames and scripts. Fixes #651362. 2002-12-11 14:04:59 +00:00
Martin v. Löwis 566f6afe9a Patch #512981: Update readline input stream on sys.stdin/out change. 2002-10-26 14:39:10 +00:00
Mark Hammond 5d546674d1 Correct PyAPI_FUNC to PyAPI_DATA - sorry Jack. 2002-08-12 13:06:35 +00:00
Mark Hammond 91a681debf Excise DL_EXPORT from Include.
Thanks to Skip Montanaro and Kalle Svensson for the patches.
2002-08-12 07:21:58 +00:00
Mark Hammond fe51c6d66e Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
for Py_Main().

Thanks to Kalle Svensson and Skip Montanaro for the patches.
2002-08-02 02:27:13 +00:00
Mark Hammond a290527376 Excise DL_IMPORT/EXPORT from object.h, and related files. This patch
also adds 'extern' to PyAPI_DATA rather than at each declaration, as
discussed with Tim and Guido.
2002-07-29 13:42:14 +00:00
Thomas Heller 6b17abf6c0 Fix SF Bug 564931: compile() traceback must include filename. 2002-07-09 09:23:27 +00:00
Tim Peters 2bbdba3c00 Removed more hair in support of future-generator stmts. 2002-04-12 01:20:10 +00:00
Guido van Rossum 393661d15f Add warning mode for classic division, almost exactly as specified in
PEP 238.  Changes:

- add a new flag variable Py_DivisionWarningFlag, declared in
  pydebug.h, defined in object.c, set in main.c, and used in
  {int,long,float,complex}object.c.  When this flag is set, the
  classic division operator issues a DeprecationWarning message.

- add a new API PyRun_SimpleStringFlags() to match
  PyRun_SimpleString().  The main() function calls this so that
  commands run with -c can also benefit from -Dnew.

- While I was at it, I changed the usage message in main() somewhat:
  alphabetized the options, split it in *four* parts to fit in under
  512 bytes (not that I still believe this is necessary -- doc strings
  elsewhere are much longer), and perhaps most visibly, don't display
  the full list of options on each command line error.  Instead, the
  full list is only displayed when -h is used, and otherwise a brief
  reminder of -h is displayed.  When -h is used, write to stdout so
  that you can do `python -h | more'.

Notes:

- I don't want to use the -W option to control whether the classic
  division warning is issued or not, because the machinery to decide
  whether to display the warning or not is very expensive (it involves
  calling into the warnings.py module).  You can use -Werror to turn
  the warnings into exceptions though.

- The -Dnew option doesn't select future division for all of the
  program -- only for the __main__ module.  I don't know if I'll ever
  change this -- it would require changes to the .pyc file magic
  number to do it right, and a more global notion of compiler flags.

- You can usefully combine -Dwarn and -Dnew: this gives the __main__
  module new division, and warns about classic division everywhere
  else.
2001-08-31 17:40:15 +00:00
Tim Peters e2c18e90da ceval, PyEval_MergeCompilerFlags: wasn't merging in the
CO_FUTURE_DIVISION flag.  Redid this to use Jeremy's PyCF_MASK #define
instead, so we dont have to remember to fiddle individual feature names
here again.

pythonrun.h:  Also #define a PyCF_MASK_OBSOLETE mask.  This isn't used
yet, but will be as part of the PEP 264 implementation (compile() mustn't
raise an error just because old code uses a flag name that's become
obsolete; a warning may be appropriate, but not an error; so compile() has
to know about obsolete flags too, but nobody is going to remember to
update compile() with individual obsolete flag names across releases either
-- i.e., this is the flip side of PyEval_MergeCompilerFlags's oversight).
2001-08-17 20:47:47 +00:00
Jeremy Hylton fdd12f66bb Refactor future feature handling
Replace individual slots in PyFutureFeatures with a single bitmask
with one field per feature.  The flags for this bitmask are the same
as the flags used in the co_flags slot of a code object.

    XXX This means we waste several bits, because they are used
    for co_flags but have no meaning for future statements.  Don't
    think this is an issue.

Remove the NESTED_SCOPES_DEFAULT define and others.  Not sure what
they were for anyway.

Remove all the PyCF_xxx flags, but define PyCF_MASK in terms of the
CO_xxx flags that are relevant for this release.

Change definition of PyCompilerFlags so that cf_flags matches
co_flags.
2001-08-10 21:38:04 +00:00
Guido van Rossum 4668b000a1 Implement PEP 238 in its (almost) full glory.
This introduces:

- A new operator // that means floor division (the kind of division
  where 1/2 is 0).

- The "future division" statement ("from __future__ import division)
  which changes the meaning of the / operator to implement "true
  division" (where 1/2 is 0.5).

- New overloadable operators __truediv__ and __floordiv__.

- New slots in the PyNumberMethods struct for true and floor division,
  new abstract APIs for them, new opcodes, and so on.

I emphasize that without the future division statement, the semantics
of / will remain unchanged until Python 3.0.

Not yet implemented are warnings (default off) when / is used with int
or long arguments.

This has been on display since 7/31 as SF patch #443474.

Flames to /dev/null.
2001-08-08 05:00:18 +00:00
Tim Peters 6d6c1a35e0 Merge of descr-branch back into trunk. 2001-08-02 04:15:00 +00:00
Tim Peters fe2127d3cb Ugly. A pile of new xxxFlags() functions, to communicate to the parser
that 'yield' is a keyword.  This doesn't help test_generators at all!  I
don't know why not.  These things do work now (and didn't before this
patch):

1. "from __future__ import generators" now works in a native shell.

2. Similarly "python -i xxx.py" now has generators enabled in the
   shell if xxx.py had them enabled.

3. This program (which was my doctest proxy) works fine:

from __future__ import generators

source = """\
def f():
    yield 1
"""

exec compile(source, "", "single") in globals()
print type(f())
2001-07-16 05:37:24 +00:00
Tim Peters 5ba5866281 Part way to allowing "from __future__ import generators" to communicate
that info to code dynamically compiled *by* code compiled with generators
enabled.  Doesn't yet work because there's still no way to tell the parser
that "yield" is OK (unlike nested_scopes, the parser has its fingers in
this too).
Replaced PyEval_GetNestedScopes by a more-general
PyEval_MergeCompilerFlags.  Perhaps I should not have?  I doubted it was
*intended* to be part of the public API, so just did.
2001-07-16 02:29:45 +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
Jeremy Hylton bc32024769 Extend support for from __future__ import nested_scopes
If a module has a future statement enabling nested scopes, they are
also enable for the exec statement and the functions compile() and
execfile() if they occur in the module.

If Python is run with the -i option, which enters interactive mode
after executing a script, and the script it runs enables nested
scopes, they are also enabled in interactive mode.

XXX The use of -i with -c "from __future__ import nested_scopes" is
not supported.  What's the point?

To support these changes, many function variants have been added to
pythonrun.c.  All the variants names end with Flags and they take an
extra PyCompilerFlags * argument.  It is possible that this complexity
will be eliminated in a future version of the interpreter in which
nested scopes are not optional.
2001-03-22 02:47:58 +00:00
Jeremy Hylton 9f324e964e Useful future statement support for the interactive interpreter
(Also remove warning about module-level global decl, because we can't
distinguish from code passed to exec.)

Define PyCompilerFlags type contains a single element,
cf_nested_scopes, that is true if a nested scopes future statement has
been entered at the interactive prompt.

New API functions:
    PyNode_CompileFlags()
    PyRun_InteractiveOneFlags()
    -- same as their non Flags counterparts except that the take an
       optional PyCompilerFlags pointer

compile.c: In jcompile() use PyCompilerFlags argument.  If
    cf_nested_scopes is true, compile code with nested scopes.  If it
    is false, but the code has a valid future nested scopes statement,
    set it to true.

pythonrun.c: Create a new PyCompilerFlags object in
    PyRun_InteractiveLoop() and thread it through to
    PyRun_InteractiveOneFlags().
2001-03-01 22:59:14 +00:00
Jeremy Hylton 4b38da664c Move a bunch of definitions that were internal to compile.c to
symtable.h, so that they can be used by external module.

Improve error handling in symtable_enter_scope(), which return an
error code that went unchecked by most callers. XXX The error handling
in symtable code is sloppy in general.

Modify symtable to record the line number that begins each scope.
This can help to identify which code block is being referred to when
multiple blocks are bound to the same name.

Add st_scopes dict that is used to preserve scope info when
PyNode_CompileSymtable() is called.  Otherwise, this information is
tossed as soon as it is no longer needed.

Add Py_SymtableString() to pythonrun; analogous to Py_CompileString().
2001-02-02 18:19:15 +00:00
Trent Mick 0a7af4058f Use suggested workaround for PyOS_CheckStack causing failure of test_[s]re.py
on Win64.

This closes bug http://sourceforge.net/bugs/?func=detailbug&group_id=5470&bug_id=116516
2000-10-11 17:18:11 +00:00
Guido van Rossum c7247ce269 Add typedef PyOS_sighandler_t and prototypes for PyOS_getsig() and
PyOS_setsig().
2000-09-16 16:31:31 +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
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
Jack Jansen 275abb3f1b Added a prototype for PyOS_CheckStack (within #ifdef USE_STACKCHECK). 2000-08-07 21:00:42 +00:00
Fred Drake 3cf4d2b3ea ANSI-fication and Py_PROTO extermination. 2000-07-09 00:55:06 +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 5e3c632a90 Fredrik Lundh: get rid of warning in pythonrun.c 2000-06-26 14:37:53 +00:00
Barry Warsaw c094ac856f Now that standard exceptions are builtin, we don't need two phase init
or fini of the builtin module.

_PyBuiltin_Init_1 => _PyBuiltin_Init
_PyBuiltin_Init_2 removed
_PyBuiltin_Fini_1 removed
_PyBuiltin_Fini_2 removed

These functions are used to initialize the _exceptions module.

init_exceptions added
fini_exceptions added
2000-05-25 23:05:36 +00:00
Guido van Rossum 43466ec7b0 Add DL_IMPORT(returntype) for all officially exported functions. 1998-12-04 18:48:25 +00:00
Guido van Rossum 66d4b90791 - Add Py_GetPythonHome() and Py_SetPythonHome(), intended to allow
embedders to force a different PYTHONHOME.

- Add new interface PyErr_PrintEx(flag); same as PyErr_Print() but
flag determines whether sys.last_* are set or not.  PyErr_Print()
now simply calls PyErr_PrintEx(1).
1998-02-06 22:28:05 +00:00
Barry Warsaw 0596c2ac28 Declarations for two phase initialization and finalization functions
for the built-in module.
1997-08-29 21:57:07 +00:00
Guido van Rossum e3c0d5eb34 Added new Py_IsInitalized() API function to test the 'initialized' flag. 1997-08-22 04:20:13 +00:00
Guido van Rossum 3fb1aea0ae Added decls for stuff from myreadline. 1997-08-12 15:14:22 +00:00
Guido van Rossum 8e5e4461a8 Added prototype for various finalizers. 1997-08-12 14:57:21 +00:00
Guido van Rossum 29e46a9a12 Mass checkin (more to follow for other directories).
Introduce truly separate (sub)interpreter objects.  For now, these
must be used by separate threads, created from C.  See Demo/pysvr for
an example of how to use this.  This also rationalizes Python's
initialization and finalization behavior:

Py_Initialize() -- initialize the whole interpreter
Py_Finalize() -- finalize the whole interpreter

tstate = Py_NewInterpreter() -- create a new (sub)interpreter
Py_EndInterpreter(tstate) -- delete a new (sub)interpreter

There are also new interfaces relating to threads and the interpreter
lock, which can be used to create new threads, and sometimes have to
be used to manipulate the interpreter lock when creating or deleting
sub-interpreters.  These are only defined when WITH_THREAD is defined:

PyEval_AcquireLock() -- acquire the interpreter lock
PyEval_ReleaseLock() -- release the interpreter lock

PyEval_AcquireThread(tstate) -- acquire the lock and make the thread current
PyEval_ReleaseThread(tstate) -- release the lock and make NULL current

Other administrative changes:

- The header file bltinmodule.h is deleted.

- The init functions for Import, Sys and Builtin are now internal and
  declared in pythonrun.h.

- Py_Setup() and Py_Cleanup() are no longer declared.

- The interpreter state and thread state structures are now linked
  together in a chain (the chain of interpreters is a static variable
  in pythonrun.c).

- Some members of the interpreter and thread structures have new,
  shorter, more consistent, names.

- Added declarations for _PyImport_{Find,Fixup}Extension() to import.h.
1997-08-02 02:56:48 +00:00
Guido van Rossum 57d8e3f1c7 Added declarations for Py_{Set,Get}ProgramName() and a bunch of other
Py_Get*() functions.
1997-07-19 19:50:52 +00:00
Guido van Rossum 5c4998b236 Added decl for Py_FdIsInteractive. 1997-02-14 19:51:34 +00:00
Guido van Rossum d266eb460e New permission notice, includes CNRI. 1996-10-25 14:44:06 +00:00
Guido van Rossum b9d876020d Don't declare Py_FatalError.
Add Py_mport_Init and PyBuiltin_Init.
1996-05-22 17:30:12 +00:00
Guido van Rossum fe299f9408 add Py_FatalError 1995-02-17 15:01:39 +00:00
Guido van Rossum 9e89f0a5b3 added callable, removed run_pyc_file 1995-02-07 15:26:59 +00:00
Guido van Rossum 938178283c new names for lots of new functions 1995-01-17 16:01:01 +00:00
Guido van Rossum caa6380886 The great renaming, phase two: all header files have been updated to
use the new names exclusively, and the linker will see the new names.
Files that import "Python.h" also only see the new names.  Files that
import "allobjects.h" will continue to be able to use the old names,
due to the inclusion (in allobjects.h) of "rename2.h".
1995-01-12 11:45:45 +00:00
Guido van Rossum 5799b52008 Added 1995 copyright.
object.h: made sizes and refcnts signed ints.
stringobject.h: make getstrsize() signed int.
methodobject.h: add METH_VARARGS and METH_FREENAME flag bit definitions.
1995-01-04 19:06:22 +00:00
Guido van Rossum 956640880d pythonrun.h: added run_pyc_file
ceval.h: added Py_AddPendingCall
rest: modules using the new naming scheme must now include Python.h
1994-09-14 13:23:36 +00:00
Guido van Rossum c6cf1dd317 pythgonrun.h: added Py_AtExit().
rename1.h: add PyArg_GetInt.
1994-09-07 14:35:10 +00:00
Guido van Rossum b6775db241 Merge alpha100 branch back to main trunk 1994-08-01 11:34:53 +00:00
Guido van Rossum b73cc04e62 * ceval.c, longobject.c, methodobject.c, listnode.c, arraymodule.c,
pythonrun.c: added static forward declarations
* pythonrun.h, ceval.h, longobject.h, node.h: removed declarations of
  static routines
1993-11-01 16:28:59 +00:00
Guido van Rossum a3309960a5 * Added support for X11 modules.
* Makefile: change location of FORMS library.
* posixmodule.c: turn #if 0 into #ifdef MSDOS (stuff in unistd.h or not)
* Almost all .h files: added CPP magic to avoid duplicate inclusions and
  to support inclusion from C++.
1993-07-28 09:05:47 +00:00
Guido van Rossum 234f942aef * Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Added $(SYSDEF) to its build rule in Makefile.
* cgensupport.[ch], modsupport.[ch]: removed some old stuff.  Also
  changed files that still used it...  And made several things static
  that weren't but should have been...  And other minor cleanups...
* listobject.[ch]: add external interfaces {set,get}listslice
* socketmodule.c: fix bugs in new send() argument parsing.
* sunaudiodevmodule.c: added flush() and close().
1993-06-17 12:35:49 +00:00
Guido van Rossum 5b7221849e * Fixed some subtleties with fastlocals. You can no longer access
f_fastlocals in a traceback object (this is a core dump hazard
  if there are <nil> entries), but instead eval_code() merges the fast
  locals back into the locals dictionary if it looks like the local
  variables will be retained.  Also, the merge routines save
  exceptions since this is sometimes needed (alas!).

* Added id() to bltinmodule.c, which returns an object's address
  (identity).  Useful to walk arbitrary data structures containing
  cycles.

* Added compile() to bltinmodule.c and compile_string() to
  pythonrun.[ch]: support to exec/eval arbitrary code objects.  The
  code that defaults globals and locals is moved from run_node in
  pythonrun.c (which is now identical to eval_node) to eval_code in
  ceval.c.  [XXX For elegance a clean-up session is necessary.]
1993-03-30 17:46:03 +00:00
Guido van Rossum 9bfef44d97 * Changed all copyright messages to include 1993.
* Stubs for faster implementation of local variables (not yet finished)
* Added function name to code object.  Print it for code and function
  objects.  THIS MAKES THE .PYC FILE FORMAT INCOMPATIBLE (the version
  number has changed accordingly)
* Print address of self for built-in methods
* New internal functions getattro and setattro (getattr/setattr with
  string object arg)
* Replaced "dictobject" with more powerful "mappingobject"
* New per-type functio tp_hash to implement arbitrary object hashing,
  and hashobject() to interface to it
* Added built-in functions hash(v) and hasattr(v, 'name')
* classobject: made some functions static that accidentally weren't;
  added __hash__ special instance method to implement hash()
* Added proper comparison for built-in methods and functions
1993-03-29 10:43:31 +00:00
Guido van Rossum 5113f5fd34 Copyright for 1992 added 1992-04-05 14:20:22 +00:00
Guido van Rossum f70e43a073 Added copyright notice. 1991-02-19 12:39:46 +00:00
Guido van Rossum 3f5da24ea3 "Compiling" version 1990-12-20 15:06:42 +00:00