Commit Graph

91 Commits

Author SHA1 Message Date
Martin v. Löwis ad0a4629be Use Py_ssize_t for counts and sizes. 2006-02-16 14:30:23 +00:00
Martin v. Löwis 18e165558b Merge ssize_t branch. 2006-02-15 17:27:45 +00:00
Neal Norwitz 1ac754fa10 Check return result from Py_InitModule*(). This API can fail.
Probably should be backported.
2006-01-19 06:09:39 +00:00
Jeremy Hylton af68c874a6 Add const to several API functions that take char *.
In C++, it's an error to pass a string literal to a char* function
without a const_cast().  Rather than require every C++ extension
module to put a cast around string literals, fix the API to state the
const-ness.

I focused on parts of the API where people usually pass literals:
PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type
slots, etc.  Predictably, there were a large set of functions that
needed to be fixed as a result of these changes.  The most pervasive
change was to make the keyword args list passed to
PyArg_ParseTupleAndKewords() to be a const char *kwlist[].

One cast was required as a result of the changes:  A type object
mallocs the memory for its tp_doc slot and later frees it.
PyTypeObject says that tp_doc is const char *; but if the type was
created by type_new(), we know it is safe to cast to char *.
2005-12-10 18:50:16 +00:00
Phillip J. Eby 0d6615fd29 PEP 342 implementation. Per Guido's comments, the generator throw()
method still needs to support string exceptions, and allow None for the
third argument.  Documentation updates are needed, too.
2005-08-02 00:46:46 +00:00
Brett Cannon f4189916e3 Flush out support for ``class B(): pass`` syntax by adding support to the
'parser' module and 'compiler' package.

Closes patch #1176012.  Thanks logistix.
2005-04-09 02:30:16 +00:00
Anthony Baxter 1a4ddaecc7 SF patch #1007189, multi-line imports, for instance:
"from blah import (foo, bar
baz, bongo)"
2004-08-31 10:07:13 +00:00
Michael W. Hudson 0ccff074cd This is Mark Russell's patch:
[ 1009560 ] Fix @decorator evaluation order

From the description:

Changes in this patch:

- Change Grammar/Grammar to require
newlines between adjacent decorators.

- Fix order of evaluation of decorators
in the C (compile.c) and python
(Lib/compiler/pycodegen.py) compilers

- Add better order of evaluation check
to test_decorators.py (test_eval_order)

- Update the decorator documentation in
the reference manual (improve description
of evaluation order and update syntax
description)

and the comment:

Used Brett's evaluation order (see
http://mail.python.org/pipermail/python-dev/2004-August/047835.html)

(I'm checking this in for Anthony who was having problems getting SF to
talk to him)
2004-08-17 17:29:16 +00:00
Anthony Baxter c2a5a63654 PEP-0318, @decorator-style. In Guido's words:
"@ seems the syntax that everybody can hate equally"
Implementation by Mark Russell, from SF #979728.
2004-08-02 06:10:11 +00:00
Raymond Hettinger 354433a59d SF patch #872326: Generator expression implementation
(Code contributed by Jiwon Seo.)

The documentation portion of the patch is being re-worked and will be
checked-in soon.  Likewise, PEP 289 will be updated to reflect Guido's
rationale for the design decisions on binding behavior (as described in
in his patch comments and in discussions on python-dev).

The test file, test_genexps.py, is written in doctest format and is
meant to exercise all aspects of the the patch.  Further additions are
welcome from everyone.  Please stress test this new feature as much as
possible before the alpha release.
2004-05-19 08:20:33 +00:00
Jack Jansen eddc1449ba Getting rid of all the code inside #ifdef macintosh too. 2003-11-20 01:44:59 +00:00
Tim Peters 6a627250d2 Merge 23c1-branch back into the head. Barry will send email about the
New Plan (releases to be made off the head, ongoing random 2.4 stuff
to be done on a short-lived branch, provided anyone is motivated enough
to create one).
2003-07-21 14:25:23 +00:00
Guido van Rossum fc29646a2e Don't use (PyObject *)PyObject_Type(x). It is a leaky and verbose way
of saying x->ob_type.
2003-04-09 17:53:22 +00:00
Neal Norwitz e4b5500e54 Remove duplicate code introduced by fixing bug #678518 2003-02-10 01:08:50 +00:00
Guido van Rossum d58f3fce3d Remove unused variable. 2003-02-09 17:19:18 +00:00
Michael W. Hudson df1252dec9 Apply logistix's patch from
[ 678518 ] Another parsermodule validation error
2003-02-08 18:05:10 +00:00
Michael W. Hudson 5e83b7a9cc Teach the parsermodule about floor division. Fixes
[ 676521 ] parser module validation failure

bugfix candidate.
2003-01-29 14:20:23 +00:00
Jeremy Hylton accb62b28e SF patch [ 597919 ] compiler package and SET_LINENO
A variety of changes from Michael Hudson to get the compiler working
with 2.3.  The primary change is the handling of SET_LINENO:

# The set_lineno() function and the explicit emit() calls for
# SET_LINENO below are only used to generate the line number table.
# As of Python 2.3, the interpreter does not have a SET_LINENO
# instruction.  pyassem treats SET_LINENO opcodes as a special case.

A few other small changes:
 - Remove unused code from pycodegen and pyassem.
 - Fix error handling in parsermodule.  When PyParser_SimplerParseString()
   fails, it sets an exception with detailed info.  The parsermodule
   was clobbering that exception and replacing it was a generic
   "could not parse string" exception.  Keep the original exception.
2002-12-31 18:17:44 +00:00
Neal Norwitz 200788ce45 Allow more docstrings to be removed during compilation in some modules 2002-08-13 22:20:41 +00:00
Mark Hammond 62b1ab1b31 Replace DL_IMPORT with PyMODINIT_FUNC and remove "/export:init..." link
command line for Windows builds.  This should allow MSVC to import and
build the Python MSVC6 project files without error.
2002-07-23 06:31:15 +00:00
Jeremy Hylton 938ace69a0 staticforward bites the dust.
The staticforward define was needed to support certain broken C
compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the
static keyword when it was used with a forward declaration of a static
initialized structure.  Standard C allows the forward declaration with
static, and we've decided to stop catering to broken C compilers.  (In
fact, we expect that the compilers are all fixed eight years later.)

I'm leaving staticforward and statichere defined in object.h as
static.  This is only for backwards compatibility with C extensions
that might still use it.

XXX I haven't updated the documentation.
2002-07-17 16:30:39 +00:00
Martin v. Löwis 14f8b4cfcb Patch #568124: Add doc string macros. 2002-06-13 20:33:02 +00:00
Guido van Rossum 2d3b986480 Disambiguate the grammar for backtick.
The old syntax suggested that a trailing comma was OK inside backticks,
but in fact (due to ideosyncrasies of pgen) it was not.  Fix the grammar
to avoid the ambiguity.  Fred: you may want to update the refman.
2002-05-24 15:47:06 +00:00
Guido van Rossum 146483964e Patch supplied by Burton Radons for his own SF bug #487390: Modifying
type.__module__ behavior.

This adds the module name and a dot in front of the type name in every
type object initializer, except for built-in types (and those that
already had this).  Note that it touches lots of Mac modules -- I have
no way to test these but the changes look right.  Apologies if they're
not.  This also touches the weakref docs, which contains a sample type
object initializer.  It also touches the mmap test output, because the
mmap type's repr is included in that output.  It touches object.h to
put the correct description in a comment.
2001-12-08 18:02:58 +00:00
Fred Drake 8b55b2d9aa Fix memory leak in the parser module: There were two leaks in
parser_tuple2st() and a failure to propogate an error in
build_node_children() (masking yet another leak, of course!).
This closes SF bug #485133 (confirmed by Insure++).
2001-12-05 22:10:44 +00:00
Guido van Rossum 1c917072ca Very subtle syntax change: in a list comprehension, the testlist in
"for <var> in <testlist> may no longer be a single test followed by
a comma.  This solves SF bug #431886.  Note that if the testlist
contains more than one test, a trailing comma is still allowed, for
maximum backward compatibility; but this example is not:

    [(x, y) for x in range(10), for y in range(10)]
                              ^

The fix involved creating a new nonterminal 'testlist_safe' whose
definition doesn't allow the trailing comma if there's only one test:

    testlist_safe: test [(',' test)+ [',']]
2001-10-15 15:44:05 +00:00
Fred Drake 13130bc5b1 Use the abstract object interfaces when digging around in module objects
instead of directly manipulating the underlying dictionary.
2001-08-15 16:44:56 +00:00
Fred Drake 78bdb9bc46 Elaborate a comment. 2001-07-19 20:17:15 +00:00
Fred Drake c2683ddb29 The syntax trees handled by this module are not "abstract," so take the
"A" out of the internal abbreviations.  For published functions with
"ast" in their names, make alternate offerings using just "st".
2001-07-17 19:32:05 +00:00
Fred Drake 02126f20b6 Add support for yield statements.
(Should be merged with descr branch.)
2001-07-17 02:59:15 +00:00
Martin v. Löwis b28f6e7c7b Properly use &&. Closes bug #434989. 2001-06-23 19:55:38 +00:00
Fred Drake 711370831a Fix problems with validation of import statement parse trees.
This closes SF bug #127271.
2001-01-07 05:59:59 +00:00
Fred Drake b6429a2020 validate_varargslist(): Fix two bugs in this function, one that affected
it when *args and/or **kw are used, and one when
                         they are not.

This closes bug #125375: "parser.tuple2ast() failure on valid parse tree".
2000-12-11 22:08:27 +00:00
Fred Drake 661ea26b3d Ka-Ping Yee <ping@lfw.org>:
Changes to error messages to increase consistency & clarity.

This (mostly) closes SourceForge patch #101839.
2000-10-24 19:57:45 +00:00
Fred Drake 0ac9b07963 Simplify some of the code. Use PyErr_Format() instead of sprintf(), etc.
Reduces lines of code and compiled object size.
2000-09-12 21:58:06 +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
Barry Warsaw 9bfd2bf5ed Do the absolute minimal amount of modifications to eradicate
Py_FatalError() from module initialization functions.  The importing
mechanism already checks for PyErr_Occurred() after module importation
and it Does The Right Thing.

Unfortunately, the following either were not compiled or tested by the
regression suite, due to issues with my development platform:

	almodule.c
	cdmodule.c
	mpzmodule.c
	puremodule.c
	timingmodule.c
2000-09-01 09:01:32 +00:00
Tim Peters 6d7c442e03 Try to supply a prototype for the module init function but avoid
Windows "inconsistent linkage" warnings at the same time.  I agree
with Mark Hammond that the whole DL_IMPORT/DL_EXPORT macro system
needs an overhaul; this is just an expedient hack until then.
2000-08-26 07:38:06 +00:00
Fred Drake 28f739aad4 Update the parser module to support augmented assignment.
Add some test cases.
2000-08-25 22:42:40 +00:00
Fred Drake 85bf3bb44a validate_listmaker(): Revise to match Skip's latest changes to the
Grammar file.  This makes the test suite pass once again.
2000-08-23 15:35:26 +00:00
Tim Peters 72b93ec1c3 Nuked unused variable. 2000-08-22 01:44:16 +00:00
Fred Drake cff283c7b3 Update to reflect recent grammar changes (list comprehensions, extended
print statement), and fix up the extended call syntax support.

Minor stylistic cleanups.
2000-08-21 22:24:43 +00:00
Thomas Wouters 5c669860e6 ANSIfy a bit more. 2000-07-24 15:49:08 +00:00
Thomas Wouters bd4bc4e9e9 Even more ANSIfication: fix as many function pointers and declarations as
possible.
2000-07-22 23:57:55 +00:00
Thomas Wouters 7e47402264 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
comments, docstrings or error messages. I fixed two minor things in
test_winreg.py ("didn't" -> "Didn't" and "Didnt" -> "Didn't").

There is a minor style issue involved: Guido seems to have preferred English
grammar (behaviour, honour) in a couple places. This patch changes that to
American, which is the more prominent style in the source. I prefer English
myself, so if English is preferred, I'd be happy to supply a patch myself ;)
2000-07-16 12:04:32 +00:00
Jeremy Hylton 03657cfdb0 replace PyXXX_Length calls with PyXXX_Size calls 2000-07-12 13:05:33 +00:00
Peter Schneider-Kamp 286da3b46a ANSI-fying
added excplicit node * parameter to termvalid argument in
validate_two_chain_ops of parsermodule.c (as proposed by fred)
2000-07-10 12:43:58 +00:00
Fred Drake 3cd2ee4037 Remove use of HAVE_OLD_CPP to support non-ANSI preprocessors. 2000-07-09 14:36:13 +00:00
Fred Drake 7797d3692b Remove warning about local variable possibly being using uninitialized;
noted by Marc-Andre Lemburg <mal@lemburg.com>.
2000-07-04 18:48:46 +00:00
Fred Drake 22269b5976 Andrew Kuchling <akuchlin@mems-exchange.org>:
Typo in string literal: execpt --> except
2000-07-03 18:07:43 +00:00