Jeremy Hylton
9ebfbf0a43
Simplify ast_for_trailer() in anticipation of more changes.
2006-02-27 16:50:35 +00:00
Thomas Wouters
aa8b6c5855
Fix old not-reading-pep-308-right artifact.
2006-02-27 16:46:22 +00:00
Martin v. Löwis
15e62742fa
Revert backwards-incompatible const changes.
2006-02-27 16:46:16 +00:00
Thomas Wouters
fa443cda87
Fix assertion errors in debug build, brought on by PEP 308 patch.
2006-02-27 15:43:57 +00:00
Martin v. Löwis
577b5b960d
Create _ast module.
...
Cleanup Python-ast.c generation.
2006-02-27 15:23:19 +00:00
Thomas Wouters
dca3b9c797
PEP 308 implementation, including minor refdocs and some testcases. It
...
breaks the parser module, because it adds the if/else construct as well as
two new grammar rules for backward compatibility. If no one else fixes
parsermodule, I guess I'll go ahead and fix it later this week.
The TeX code was checked with texcheck.py, but not rendered. There is
actually a slight incompatibility:
>>> (x for x in lambda:0)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: iteration over non-sequence
changes into
>>> (x for x in lambda: 0)
File "<stdin>", line 1
(x for x in lambda: 0)
^
SyntaxError: invalid syntax
Since there's no way the former version can be useful, it's probably a
bugfix ;)
2006-02-27 00:24:13 +00:00
Martin v. Löwis
d3a5f53a27
Avoid reinitializing the types twice.
2006-02-27 00:09:50 +00:00
Martin v. Löwis
8d0701daf1
Stop generating empty arrays.
2006-02-26 23:40:20 +00:00
Neal Norwitz
59090a7334
Oops, I forgot to check this in with the change to Grammar/Grammar.
...
Implement change suggested by Jiwon Seo on python-dev.
['(' gen_for ')'] is redundant with test, so remove it.
2006-02-26 22:29:38 +00:00
Martin v. Löwis
2b366e41c3
Check whether there are flags.
2006-02-26 22:12:35 +00:00
Martin v. Löwis
ce1d5d2527
Fix iterating over cmpop_ty lists.
2006-02-26 20:51:25 +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
9a27617239
Based on discussion with Martin and Thomas on python-checkins
...
add a Py_SAFE_DOWNCAST() to make the code correct.
2006-02-20 18:57:39 +00:00
Neal Norwitz
20dd93f427
Fix compiler warning on amd64. We can't use zd here since this is
...
ultimately going to snprintf() not the python string formatter. Right?
2006-02-19 19:34:15 +00:00
Neal Norwitz
a361bd8dce
Fix compiler warning (int vs Py_ssize_t mismatch
2006-02-19 19:31:50 +00:00
Georg Brandl
1dc5a84aee
Bug #801349 : document that start/stop/step slice arguments can be None
2006-02-19 00:12:42 +00:00
Martin v. Löwis
dde99d2633
Remove size constraints in SLICE opcodes.
2006-02-17 15:57:41 +00:00
Martin v. Löwis
67baee6287
Move cast to suppress warning.
2006-02-16 14:37:48 +00:00
Martin v. Löwis
d96ee90993
Use Py_ssize_t to count the
2006-02-16 14:37:16 +00:00
Martin v. Löwis
720ddb625b
Use PyString_FromFormat for formatting error messages.
2006-02-16 07:11:33 +00:00
Martin v. Löwis
18e165558b
Merge ssize_t branch.
2006-02-15 17:27:45 +00:00
Armin Rigo
f5b3e36493
Renamed _length_cue() to __length_hint__(). See:
...
http://mail.python.org/pipermail/python-dev/2006-February/060524.html
2006-02-11 21:32:43 +00:00
Georg Brandl
b69406dc09
Update general copyright years to 2006.
2006-02-11 15:30:36 +00:00
Thomas Wouters
03ca23d892
Explain the clearing of the stack in a comment in Python/ceval.c's
...
call_function(), rather than commenting on the lack of an explanation in a
comment.
2006-02-10 22:51:45 +00:00
Brett Cannon
82a9394237
Add doc discussing how AST compiler is structured and designed.
...
It is out of date, though, thanks to lacking info on the arena API. It also
should eventually be removed in favor of updating PEP 339.
2006-02-09 02:43:14 +00:00
Neal Norwitz
96e48d4698
Use C-style comment
2006-02-05 02:07:19 +00:00
Jeremy Hylton
c960f26044
Improved handling of syntax errors.
...
Expand set of errors caught in set_context(). Some new errors, some
old error messages changed for consistency.
Fixed error checking in generator expression code. The first set of
tests were impossible condition given the grammar. In general, the
ast code uses REQ() for those sanity checks.
Fix some error handling for augmented assignments. As comments in the
code explain, set_context() ought to work here, but I got unexpected
crashes when I tried it. Should come back to this.
Add note to Grammar that yield expression is a special case.
Add doctest cases for SyntaxErrors raised by ast.c.
2006-01-27 15:18:39 +00:00
Georg Brandl
d704817b66
typo
2006-01-20 17:53:27 +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
Tim Peters
e93e64fb1a
Repair bizarre indentation created by VC 7.1.
2006-01-08 02:28:41 +00:00
Tim Peters
5db42c4c50
alias_for_import_name(): Dueling compiler warnings ;-)
...
Squash new warnings from VC 7.1 about mixing signed and
unsigned types in comparisons. I can see why `len` was
changed to size_t here, but don't see why `i` was also
changed. Change `i` back to int.
2006-01-08 02:25:34 +00:00
Tim Peters
d8fe7ab711
analyze_cells(): This no longer compiled under VC 7.1.
...
Move declaration of local `flags` to top of block.
2006-01-08 02:19:07 +00:00
Neal Norwitz
46b7bda9bc
Fix icc warnings: conversion from "long" to "int" may lose significant bits
2006-01-08 01:06:06 +00:00
Neal Norwitz
d39d861a36
Fix icc warnings: strlen() returns size_t
2006-01-08 01:03:36 +00:00
Neal Norwitz
daf595f8a9
Fix icc warnings: shadowing local variable (i) and complex is set but not used, so remove
2006-01-07 21:24:54 +00:00
Neal Norwitz
08b401f67a
Fix icc warnings: single bit fields should be unsigned, shadowing local variables
2006-01-07 21:24:09 +00:00
Neal Norwitz
406c640344
Fix icc warnings: shadowing local variables
2006-01-07 21:23:26 +00:00
Tim Peters
e86e7a5b62
svnversion_init(): Use standard layout for function defn.
2006-01-06 02:42:46 +00:00
Tim Peters
216b78bdaa
Trimmed trailing whitespace.
2006-01-06 02:40:53 +00:00
Martin v. Löwis
43b57805fb
Drop sys.build_number. Add sys.subversion.
2006-01-05 23:38:54 +00:00
Hye-Shik Chang
23f391c6a1
Fix a warning from gcc by adding a missed const qualifier.
2006-01-04 01:30:17 +00:00
Martin v. Löwis
5b43126e03
Regenerate.
2006-01-02 21:18:55 +00:00
Martin v. Löwis
94962615b7
Adjust usage of compiler_use_new_block to its return type.
2006-01-02 21:15:05 +00:00
Fredrik Lundh
24f0fa97c5
SF#1391872
...
Floating point literals don't work in non-US locale in 2.5. Patch and
new locale tests by Hye-Shik Chang.
2005-12-29 20:35:52 +00:00
Tim Peters
35c3f4f249
do_mkvalue(), 'I' and 'k' cases: squash legitimate
...
compiler warnings about mixing signed and unsigned types
in comparisons.
2005-12-24 06:23:41 +00:00
Tim Peters
c3d12ac88c
const poisoning, spreading to fix new const warnings
...
in _winreg.c.
2005-12-24 06:03:06 +00:00
Neal Norwitz
4ac13dfc3a
Remove extra parens
2005-12-19 06:10:07 +00:00
Neal Norwitz
30b5c5d011
Fix SF bug #1072182 , problems with signed characters.
...
Most of these can be backported.
2005-12-19 06:05:18 +00:00
Neal Norwitz
5d0ad50f5a
Bug #889500 , fix line number on SyntaxWarning for global declarations.
2005-12-19 04:27:42 +00:00
Fredrik Lundh
93d69a7948
fixed compilation with an ordinary C89 compiler
2005-12-18 15:44:21 +00:00
Neal Norwitz
51abbc7b4a
Fix Armin's bug 1333982. He found it, he didn't created it :-)
...
This code generated a C assertion:
assert 1, ([s for s in x] +
[s for s in x])
pass
assert was completely broken, it needed to use the proper block.
compiler_use_block() is now no longer used, so remove it.
2005-12-18 07:06:23 +00:00
Neal Norwitz
0e7a0ed335
Fix compiler warnings
2005-12-18 05:37:36 +00:00
Neal Norwitz
4e6bf49a5e
Handle more error conditions with SystemError
2005-12-18 05:32:41 +00:00
Neal Norwitz
db83eb3170
Fix Bug #1378022 , UTF-8 files with a leading BOM crashed the interpreter.
...
Needs backport.
2005-12-18 05:29:30 +00:00
Neal Norwitz
e7214a130b
Get float() to be more portable across platforms. Disable hex strings.
2005-12-18 05:03:17 +00:00
Neal Norwitz
87b801cc2d
Set MemoryError when alloc fails
2005-12-18 04:42:47 +00:00
Neal Norwitz
3c52c5a888
Wrap long lines in the grammar
2005-12-18 04:12:30 +00:00
Neal Norwitz
84456bdab3
Cleanup a bit and make things more consistent.
...
Don't double check for NULLs and don't initialize if not necessary.
No functional changes.
2005-12-18 03:16:20 +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
f599f424a2
SF patch #1355913 , PEP 341 - Unification of try/except and try/finally
...
Modified since ast-arenas was implemented.
2005-12-17 21:33:47 +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
Neal Norwitz
6f0d479c78
Fix an int/long mismatch identified here:
...
http://www.tortall.net/mu/blog/2005/12/01
Pointed out from SF #1365916 .
Backport candidate.
2005-12-15 06:40:36 +00:00
Neal Norwitz
897ff817d5
SF #1373150 , diffs in working copy after a build
...
Strip off leading dots and slash so the generated files are the same regardless
of whether you configure in the checkout directory or build.
If anyone configures in a different directory, we might want a cleaner
approach using os.path.*(). Hopefully this is good enough.
2005-12-11 21:18:22 +00:00
Neal Norwitz
f8d403dd97
SF #1377897 , Bus error in ast
...
If a line had multiple semi-colons and ended with a semi-colon, we would
loop too many times and access a NULL node. Exit the loop early if
there are no more children.
2005-12-11 20:12:40 +00:00
Neal Norwitz
8ad64aaacc
SF #1370197 , memory leak - ast_error_finish (in error conditions).
2005-12-11 20:08:33 +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
Neal Norwitz
28b32ac6bc
Simplify logic for handling import *
2005-12-06 07:41:30 +00:00
Neal Norwitz
b15ec09343
Reduce scope of feature
2005-12-06 07:26:02 +00:00
Neal Norwitz
c1f213ebdc
Remove unused macro, check is done elsewhere
2005-12-06 06:36:36 +00:00
Neal Norwitz
e536892541
Remove unnecessary extern variable
2005-12-05 07:16:38 +00:00
Martin v. Löwis
b45b315855
Patch #1350409 : Port signal handling to VS 2005.
2005-11-28 17:34:23 +00:00
Neal Norwitz
3a9a3e7864
Fix memory leaks
2005-11-27 20:38:31 +00:00
Neal Norwitz
3715c3e576
Fix a few more ref leaks. Backport candidate
2005-11-24 22:09:18 +00:00
Georg Brandl
f06e30af4a
bug #1281408 : make Py_BuildValue work with unsigned longs and long longs
2005-11-24 15:37:42 +00:00
Neal Norwitz
7bcabc60a3
Fix a few more memory leaks
...
Document more info about the benefits of configuring without
pymalloc when running valgrind
2005-11-20 23:58:38 +00:00
Neal Norwitz
4737b2348b
Last batch of ref leaks in new AST code.
...
Also converted a bunch of assert(0) to SystemError's.
There are still printfs, etc that need to be cleaned up.
2005-11-19 23:58:29 +00:00
Nick Coghlan
944d3eb154
Correctly handle identifiers for anonymous scopes and align genexpr name with symtable.c
2005-11-16 12:46:55 +00:00
Nick Coghlan
99b2533539
Bring handling of genexpr in line with other anonymous scope names
2005-11-16 12:45:24 +00:00
Neal Norwitz
a3fd07d524
add more doc
2005-11-16 05:49:04 +00:00
Neal Norwitz
ef78529e86
version was not initialized properly
2005-11-16 05:04:51 +00:00
Neal Norwitz
6b34789046
Fix another memory leak or two (one real, one potential)
2005-11-15 07:17:53 +00:00
Neal Norwitz
af8f974967
Add a note about how to do the memory deallocation a bit.
...
This needs a lot of work.
2005-11-15 05:09:44 +00:00
Neal Norwitz
e76adcd78a
Fix a whole bunch of potential memory leaks (and some real ones too)
...
in error conditions.
2005-11-15 05:04:31 +00:00
Neal Norwitz
79792651c4
Convert all internal errors from Exception to SystemError
...
Remove an abort() and let a SystemError be raised.
2005-11-14 04:25:03 +00:00
Neal Norwitz
daae6161b5
Use convenience function
2005-11-14 00:47:57 +00:00
Neal Norwitz
e8c0536d57
Fix memory leak with bad generator expression
2005-11-14 00:18:03 +00:00
Neal Norwitz
7b3d5e1779
remove useless debug print helper. fix a couple of exceptions
2005-11-13 21:17:28 +00:00
Neal Norwitz
7b5a604d24
Whoops, checkin consistent versions of *all* files to stop polluting
...
a bunch of names
2005-11-13 19:14:20 +00:00
Neal Norwitz
b6fc9df8fc
Fix a lot of memory and ref leaks in error paths.
...
(Call symtable_exit_block or compiler_exit_scope as appropriate)
Use PyMem_Free on c_future since it was allocated with PyMem_Malloc
2005-11-13 18:50:34 +00:00
Neal Norwitz
6576bd844f
Prevent name pollution by making lots of internal functions static.
2005-11-13 18:41:28 +00:00
Neal Norwitz
2744c6cc35
make internal method static
2005-11-13 01:08:38 +00:00
Neal Norwitz
67715f0420
- SF Bug #1350188 , "setdlopenflags" leads to crash upon "import"
...
It was possible dlerror() returns a NULL pointer, use a default error
message in this case.
2005-11-09 06:59:35 +00:00
Martin v. Löwis
ab0f947a21
Remove .cvsignore files, as they live in svn:ignore
...
properties now.
2005-10-30 22:01:41 +00:00
Neil Schemenauer
982e8d671c
Refactor code for translating "power" nodes.
2005-10-25 09:16:05 +00:00
Neil Schemenauer
c5dd10aa1d
Write a separate ast_for_testlist_gexp() function instead of overloading
...
ast_for_testlist(). Also, write a ast_for_class_bases() function and in
the process fix a memory leak. Add some assertions.
2005-10-25 07:54:54 +00:00
Neil Schemenauer
c396d9edd6
Ensure that compiler_exit_scope() is called as necessary to free memory
...
allocated by compiler_enter_scope(). Change return type for
compiler_exit_scope() to be void.
2005-10-25 06:30:14 +00:00
Neal Norwitz
62c2fac9a0
Do not pollute name block_ty, prefix with _Py_
2005-10-24 00:30:44 +00:00
Neal Norwitz
f1d50684c6
Fix problem handling EXTENDED_ARGs from SF bug # 1333982
2005-10-23 23:00:41 +00:00
Neal Norwitz
7d37f2ff40
cleanup a bit and reuse instrsize (instruction size). working towards fixing problems with EXTENDED_ARG
2005-10-23 22:40:47 +00:00
Neal Norwitz
12ebfd79f8
Use PyErr_NoMemory() instead of rolling our own.
...
Get rid of "int i" unused warnings from Python-ast.c which we are generating.
2005-10-23 19:22:48 +00:00