Commit Graph

197 Commits

Author SHA1 Message Date
Tim Peters 17db21ffd0 Removed reliance on gcc/C99 extension. 2002-09-03 15:39:58 +00:00
Martin v. Löwis f62a89b1e0 Ignore encoding declarations inside strings. Fixes #603509. 2002-09-03 11:52:44 +00:00
Guido van Rossum 84b2bed435 Squash a few calls to the hideously expensive PyObject_CallObject(o,a)
-- replace then with slightly faster PyObject_Call(o,a,NULL).  (The
difference is that the latter requires a to be a tuple; the former
allows other values and wraps them in a tuple if necessary; it
involves two more levels of C function calls to accomplish all that.)
2002-08-16 17:01:09 +00:00
Skip Montanaro 118ec70ea2 provide less mysterious error messages when seeing end-of-line in
single-quoted strings or end-of-file in triple-quoted strings.
closes patch 586561.
2002-08-15 01:20:16 +00:00
Martin v. Löwis 2863c10a86 Use Py_FatalError instead of abort. 2002-08-07 15:18:57 +00:00
Martin v. Löwis 019934b3cc Fix PEP 263 code --without-unicode. Fixes #591943. 2002-08-07 12:33:18 +00:00
Jack Jansen cf0a2cfdb2 Added a cast to shut up a compiler warning. 2002-08-05 14:14:05 +00:00
Martin v. Löwis 725bb233b9 Add 1 to lineno in deprecation warning. Fixes #590888. 2002-08-05 01:49:16 +00:00
Martin v. Löwis 1ee99d31d9 Make pgen compile with pydebug. Duplicate normalized names, as it may
be longer than the old string.
2002-08-04 20:10:29 +00:00
Martin v. Löwis cd280fb59c Group statements properly. 2002-08-04 18:28:44 +00:00
Tim Peters 2c3f9c6f04 Repaired a fatal compiler error in the debug build: it's not clear what
this was trying to assert, but the name it referenced didn't exist.
2002-08-04 17:58:34 +00:00
Tim Peters 919603b27a Squash compiler wng about signed-vs-unsigned mismatch. 2002-08-04 17:56:42 +00:00
Martin v. Löwis 00f1e3f5a5 Patch #534304: Implement phase 1 of PEP 263. 2002-08-04 17:29:52 +00:00
Andrew MacIntyre 80d4e2acf5 SF patch #578297:
Change the parser and compiler to use PyMalloc.

Only the files implementing processes that will request memory
allocations small enough for PyMalloc to be a win have been
changed, which are:-
 - Python/compile.c
 - Parser/acceler.c
 - Parser/node.c
 - Parser/parsetok.c

This augments the aggressive overallocation strategy implemented by
Tim Peters in PyNode_AddChild() [Parser/node.c], in reducing the
impact of platform malloc()/realloc()/free() corner case behaviour.
Such corner cases are known to be triggered by test_longexp and
test_import.

Jeremy Hylton, in accepting this patch, recommended this as a
bugfix candidate for 2.2.  While the changes to Python/compile.c
and Parser/node.c backport easily (and could go in), the changes
to Parser/acceler.c and Parser/parsetok.c require other not
insignificant changes as a result of the differences in the memory
APIs between 2.3 and 2.2, which I'm not in a position to work
through at the moment.  This is a pity, as the Parser/parsetok.c
changes are the most important after the Parser/node.c changes, due
to the size of the memory requests involved and their frequency.
2002-08-04 06:28:21 +00:00
Tim Peters e561dc231e XXXROUNDUP(): Turns out this fixed Andrew MacIntyre's memory-mgmt
disaster too, so this change is here to stay.  Beefed up the comments
and added some stats Andrew reported.  Also a small change to the
macro body, to make it obvious how XXXROUNDUP(0) ends up returning 0.
See SF patch 578297 for context.

Not a bugfix candidate, as the functional changes here have already
been backported to the 2.2 line (this patch just improves clarity).
2002-07-15 17:58:03 +00:00
Mark Hammond 2f10cb8fa5 Fix bug 439992 - [win32] KeyboardInterrupt Not Caught.
This gets us closer to consistent Ctrl+C behaviour on NT and Win9x.  NT now reliably generates KeyboardInterrupt exceptions for NT when a file IO operation was aborted.  Bugfix candidate
2002-07-14 23:12:29 +00:00
Jeremy Hylton 7b4c8e485c I trust the parser accelators are getting added :-). 2002-07-11 15:43:37 +00:00
Thomas Heller 6b17abf6c0 Fix SF Bug 564931: compile() traceback must include filename. 2002-07-09 09:23:27 +00:00
Tim Peters 7c321a80f9 The Py_REF_DEBUG/COUNT_ALLOCS/Py_TRACE_REFS macro minefield: added
more trivial lexical helper macros so that uses of these guys expand
to nothing at all when they're not enabled.  This should help sub-
standard compilers that can't do a good job of optimizing away the
previous "(void)0" expressions.

Py_DECREF:  There's only one definition of this now.  Yay!  That
was that last one in the family defined multiple times in an #ifdef
maze.

Py_FatalError():  Changed the char* signature to const char*.

_Py_NegativeRefcount():  New helper function for the Py_REF_DEBUG
expansion of Py_DECREF.  Calling an external function cuts down on
the volume of generated code.  The previous inline expansion of abort()
didn't work as intended on Windows (the program often kept going, and
the error msg scrolled off the screen unseen).  _Py_NegativeRefcount
calls Py_FatalError instead, which captures our best knowledge of
how to abort effectively across platforms.
2002-07-09 02:57:01 +00:00
Tim Peters 623fdb9884 PyNode_AddChild() and fancy_roundup(): Be paranoid about int overflow. 2002-07-08 19:11:07 +00:00
Tim Peters 755ebea23b PyNode_AddChild(): Do aggressive over-allocation when the number of
children gets large, to avoid severe platform realloc() degeneration
in extreme cases (like test_longexp).

Bugfix candidate.

This was doing extremely timid over-allocation, just rounding up to the
nearest multiple of 3.  Now so long as the number of children is <= 128,
it rounds up to a multiple of 4 but via a much faster method.  When the
number of children exceeds 128, though, and more space is needed, it
doubles the capacity.  This is aggressive over-allocation.

SF patch <http://www.python.org/sf/578297> has Andrew MacIntyre using
PyMalloc in the parser to overcome platform malloc problems in
test_longexp on OS/2 EMX.  Jack Jansen notes there that it didn't help
him on the Mac, because the Mac has problems with frequent ever-growing
reallocs, not just with gazillions of teensy mallocs.  Win98 has no
visible problems with test_longexp, but I tried boosting the test-case
size and soon got "senseless" MemoryErrors out of it, and soon after
crashed the OS:  as I've seen in many other contexts before, while the
Win98 realloc remains zippy in bad cases, it leads to extreme
fragmentation of user address space, to the point that the OS barfs.

I don't yet know whether this fixes Jack's Mac problems, but it does cure
Win98's problems when boosting the test case size.  It also speeds
test_longexp in its unaltered state.
2002-07-08 06:32:09 +00:00
Guido van Rossum 79e39bd4d0 Add definition of Py_IgnoreEnvironmentFlag (needed at least in debug
mode).
2002-05-31 14:32:07 +00:00
Neal Norwitz 5352d8c0c6 Py_IgnoreEnvironmentFlag should be extern, since it is declared in pythonrun.c 2002-05-31 13:11:40 +00:00
Tim Peters 1ccb3eeb7b Link with the right C library! This has always been wrong (& my fault). 2002-05-23 19:25:59 +00:00
Neil Schemenauer 44c4c6dbd6 Py_GETENV is used by obmalloc and needs Py_IgnoreEnvironmentFlag. Provide it. 2002-04-22 03:29:32 +00:00
Tim Peters 1c6192662d Update the Windows makefile for 2.3. 2002-04-22 00:39:44 +00:00
Jack Jansen 7b8c7546eb Mass checkin of universal newline support.
Highlights: import and friends will understand any of \r, \n and \r\n
as end of line. Python file input will do the same if you use mode 'U'.
Everything can be disabled by configuring with --without-universal-newlines.

See PEP278 for details.
2002-04-14 20:12:41 +00:00
Neil Schemenauer c24ea08644 Disable the parser hacks that enabled the "yield" keyword using a future
statement.
2002-03-22 23:53:36 +00:00
Neil Schemenauer c155dd4ca9 Disable the parser hacks that allowed the "yield" keyword to be enabled
by a future statement.
2002-03-22 23:38:11 +00:00
Martin v. Löwis cdc4451222 Include <unistd.h> in Python.h. Fixes #500924. 2002-01-12 11:05:12 +00:00
Martin v. Löwis 16eff6f77b Initialize err_ret with filename if available. Fixes #498828. 2002-01-05 21:40:08 +00:00
Tim Peters 88e138c842 PyGrammar_LabelRepr(): sprintf -> PyOS_snprintf. 2001-12-04 03:36:01 +00:00
Tim Peters 1ca1296157 The parser doesn't need its own implementation of assert, and having its
own interfered with including Python.h.  Remove Python's assert.h.
2001-12-04 03:18:48 +00:00
Barry Warsaw 5947af5ac3 Reverting last change so we don't have to think about the assert macro
redefinition problem.
2001-11-28 21:34:34 +00:00
Barry Warsaw b97c969fee PyGrammar_LabelRepr(): Conversion of sprintf() to PyOS_snprintf() for
buffer overrun avoidance.
2001-11-28 21:04:25 +00:00
Guido van Rossum 0c156a5130 Patch from SF bug #472956: UMR when there is a syntax error (Neal Norwitz)
perrdetail.token is unitialized when there is a syntax
    error in a file.
2001-10-20 14:27:56 +00:00
Tim Peters eba84cdacb An MSVC makefile to rebuild the grammar files (graminit.[ch]) manually.
Ugly, but it works.
2001-10-13 20:16:17 +00:00
Guido van Rossum 25dfe2c095 Silence parser generator output. 2001-09-11 16:43:16 +00:00
Tim Peters d507dab91f SF patch #455966: Allow leading 0 in float/imag literals.
Consequences for Jython still unknown (but raised on Jython-Dev).
2001-08-30 20:51:59 +00:00
Tim Peters 9aa70d93aa SF bug [#455775] float parsing discrepancy.
PyTokenizer_Get:  error if exponent contains no digits (3e, 2.0e+, ...).
2001-08-27 19:19:28 +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
Guido van Rossum 3c033230ec Fis SF bug #442647: not all forms of legal future statements were
parsed correctly.  Now they are.
2001-07-19 15:27:45 +00:00
Guido van Rossum da62ecc9aa Add a really stupid warning about 'yield' used as an identifier.
This is really stupid because it cannot be suppressed or altered using
the warning framework; that's because the warning framework is built
on Python interpreter internals, and the parser generator doesn't have
access to any of those (you cannot use anything of type PyObject * in
the parser).

But it's better than nothing, and implementing a proper check for this
appears to require modifying compile.c in a dozen places, for which I
don't have the stamina today.  I promise we'll do better in 2.2a2.

At least it tells you the filename and line number (unlike the first
hack I considered :-).
2001-07-17 16:53:11 +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
Guido van Rossum b09f7ed623 Preliminary support for "from __future__ import generators" to enable
the yield statement.  I figure we have to have this in before I can
release 2.2a1 on Wednesday.

Note: test_generators is currently broken, I'm counting on Tim to fix
this.
2001-07-15 21:08:29 +00:00
Tim Peters cf96de052f SF but #417587: compiler warnings compiling 2.1.
Repaired *some* of the SGI compiler warnings Sjoerd Mullender reported.
2001-04-21 02:46:11 +00:00
Guido van Rossum 48a680c097 RISCOS changes by dschwertberger. 2001-03-02 06:34:14 +00:00
Neil Schemenauer 84521c078e Take output filenames as arguments instead of hard-coding them. 2001-02-16 03:57:53 +00:00
Neil Schemenauer 693291ba23 Superseded by $(srcdir)/Makefile.pre.in. 2001-02-03 17:18:21 +00:00
Guido van Rossum e3c3b27d33 Fix a bug in stack overflow error handling. This fixes half of Bug
#115555.

The error from s_push() on stack overflow was -1, which was passed
through unchanged by push(), but not tested for by push()'s caller --
which only expected positive error codes.  Fixed by changing s_push()
to return E_NOMEM on stack overflow.  (Not quite the proper error code
either, but I can't be bothered adding a new E_STACKOVERFLOW error
code in all the right places.)
2000-10-02 10:21:59 +00:00