embedded code objects (e.g. functions) rather than the generated code
object. This change means that the compiler generates code for
everything at the end, rather then generating code for each function
as it finds it. Implementation note: _convert_LOAD_CONST in
pyassem.py must be change to call getCode().
Other changes follow. Several changes creates extra edges between
basic blocks to reflect control flow for loops and exceptions. These
missing edges had gone unnoticed because they do not affect the
current compilation process.
pyassem.py:
Add _enable_debug() and _disable_debug() methods that print
instructions and blocks to stdout as they are generated.
Add edges between blocks for instructions like SETUP_LOOP,
FOR_LOOP, etc.
Add pruneNext to get rid of bogus edges remaining after
unconditional transfer ops (e.g. JUMP_FORWARD)
Change repr of Block to omit block length.
pycodegen.py:
Make sure a new block is started after FOR_LOOP, etc.
Change assert implementation to use RAISE_VARARGS 1 when there is
no user-specified failure output.
misc.py:
Implement __contains__ and copy for Set.
Reformatting -- long lines, "[ ]" -> "[]", a few indentation nits.
Replace calls to Node function (which constructed ast nodes) with
calls to actual constructors imported from ast module.
Optimize com_node (most frequently used method) for the common case --
the appropriate method is found in _dispatch.
Fix com_augassign to use class object's rather than node names
(rendered invalid by recent changes to ast)
Remove expensive tests for sequence-ness in com_stmt and
com_append_stmt. These tests should never fail; if they do, something
is really broken and exception will be raised elsewhere.
Fix com_stmt and com_append_stmt to use isinstance rather than
testing's type slot of ast node (this slot disappeared with recent
changes to ast).
1.5.2. The compiler generates code for the version of the interpreter
it is run under.
ast.py:
Print and Printnl add dest attr for extended print
new node AugAssign for augmented assignments
new nodes ListComp, ListCompFor, and ListCompIf for list
comprehensions
pyassem.py:
add work around for string-Unicode comparison raising UnicodeError
on comparison of two objects in code object's const table
pycodegen.py:
define VERSION, the Python major version number
get magic number using imp.get_magic() instead of hard coding
implement list comprehensions, extended print, and augmented
assignment; augmented assignment uses Delegator classes (see
doc string)
fix import and tuple unpacking for 1.5.2
transformer.py:
various changes to support new 2.0 grammar and old 1.5 grammar
add debug_tree helper than converts and symbol and token numbers
to their names
parsing functions in support of auto-indent weren't expecting Unicode
strings, but text.get() can now return them (although it remains muddy as
to exactly when or why that can happen). Fixed that with a Big Hammer.
- use unidb compression for the unicodectype module. smaller,
faster, and slightly more portable...
- also mention the unicode directory in Tools/README
- fixed attributions
- moved decomposition data to a separate table, in preparation
for step 3 (which won't happen before 2.0 final, promise!)
- use relative paths in the generator script
I have a lot more stuff in the works for 2.1, but let's leave
that for another day...
a bit, sped it a lot primarily by removing the unused assumption that None was
a legit bin entry (the function doesn't really need to assume that there's
anything special about 0), added an optional "trace" argument, and in __debug__
mode added exhaustive verification that the decomposition is both correct and
doesn't overstep any array bounds (which wasn't obvious to me from staring at the
generated C code -- now I feel safe!). Did not commit a new unicodedata_db.h, as
the one produced by this version is identical to the one already checked in.
subset of Win32 ShellExecute's functionality. Guido wants this because
IDLE's Help -> Docs function currently crashes his machine because of a
conflict between his version of Norton AntiVirus (6.10.20) and MS's
_popen. Docs for startfile are being mailed to Fred (or just read the
docstring -- it tells the whole story).
Changed webbrowser.py to use os.startfile instead of os.popen on Windows.
Changed IDLE's EditorWindow.py to pass an absolute path for the docs
(hardcoding ShellExecute's "directory" arg to "." as used to be done let
IDLE work, but made the startfile command exceedingly obscure for other
uses -- the MS docs are terrible, of course, & still not sure I
understand it).
Note that Windows Python must link with shell32.lib now! That's where
ShellExecute lives.
The cause was that the replace code necessarily used a PCRE internal
function to to template expansion.
The fix changes the code to use an SRE internal if SRE is used, and a
PCRE internal if SRE is used; in a way that should work with 1.5.2.
The solution can be sped up tremendously under the assumption that the
choice between sre and pre is not changed during the execution of the
program; especially replace-all will be slow.
But I'll leave that to someone else.
created. This allows the application-specific Tkinter
initialization to be executed if present. Also pass an explicit
className parameter to the Tk() constructor.
This closes SourceForge bug #110618.
Fix import support to work with import as variant of Python 2.0. The
grammar for import changed, requiring changes in transformer and code
generator, even to handle compilation of imports with as.
by Martin v. Loewis, proofed by Barry Warsaw for coding standards,
typos, and to make command line options compatible with GNU msgfmt
where they overlap.
Closes patch #101295.
- fix tab space issues (SF patch #101167 by Neil Schemenauer)
- fix co_flags for classes to include CO_NEWLOCALS (SF patch #101145 by Neil)
- fix for merger of UNPACK_LIST and UNPACK_TUPLE into UNPACK_SEQUENCE,
(SF patch #101168 by, well, Neil :)
- Adjust bytecode MAGIC to current bytecode.
TODO: teach compile.py about list comprehensions.
originally submitted by Bill Tutt
Note: This code is actually going to be replaced in 2.0 by /F's new
database. Until then, this patch keeps the test suite working.
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 ;)
mislabeled.
(Using -c and then -e rearranges some comments, so I won't check that
in -- but it's a good test anyway.
Note that pindent is not perfect -- e.g. it doesn't know about
triple-quoted strings!)
Problem:
A Python program can be completed and reformatted using
Tools/scripts/pindent.py. Unfortunately there is no option for removal
of the generated "# end"-tags. Although a few Python commands or a
"grep -v '# end '" can do wonders here, there are two drawbacks:
- not everyone has grep/time to write a Python script
- it is not checked whether the "# end"-tags were used validly
Solution:
add extra option "-e" (eliminate) to pindent.py
Perfect hash table generator. Outputs a Python extension module
which provides access to the hash table (which is stored in static
C data) using custom code.
This module can currently only generates code for the ucnhash
module, but can easily be adapted to produce perfect hash tables
for other tasks where fast lookup in large tables is needed.
By Bill Tutt.
Instead of using Netscape through os.system(), use the new
browser.open() function to load the documentation on the
default browser. On Windows, this will use the installed
documentation if it exists, instead of hitting python.org.
Attached is a set of diffs for the .py compiler that adds support
for the new extended call syntax.
compiler/ast.py:
CallFunc node gets 2 new children to support extended call syntax -
"star_args" (for "*args") and "dstar_args" (for "**args")
compiler/pyassem.py
It appear that self.lnotab is supposed to be responsible for
tracking line numbers, but self.firstlineno was still hanging
around. Removed self.firstlineno completely. NOTE - I didnt
actually test that the generated code has the correct line numbers!!
Stack depth tracking appeared a little broken - the checks never
made it beyond the "self.patterns" check - thus, the custom methods
were never called! Fixed this.
(XXX Jeremy notes: I think this code is still broken because it
doesn't track stack effects across block bounaries.)
Added support for the new extended call syntax opcodes for depth
calculations.
compiler/pycodegen.py
Added support for the new extended call syntax opcodes.
compiler/transformer.py
Added support for the new extended call syntax.
can't remember who. :-) Changes:
- Owner name+email made generic instead of GvR
- Support for Windows NT (running from a .bat file)
- DOcument <HTML>...</HTML> tags
The robotparser.py module currently lives in Tools/webchecker. In
preparation for its migration to Lib, I made the following changes:
* renamed the test() function _test
* corrected the URLs in _test() so they refer to actual documents
* added an "if __name__ == '__main__'" catcher to invoke _test()
when run as a main program
* added doc strings for the two main methods, parse and can_fetch
* replaced usage of regsub and regex with corresponding re code
code generator uses flowgraph as intermediate representation. the old
rep uses a list with explicit "StackRefs" to indicate the target
of jumps.
pyassem converts flowgraph to bytecode, breaks up individual steps of
generating bytecode
Fix bad auto-indent I recently introduced when replacing the regexp that
could cause re to blow up:
if or_any_other_block_opener:
# one indenting comment line
^ cursor ended up at the caret (the bug)
^ but belongs here (the post-patch behavior)
(inspired by Detlef Lannert). Specifically,
-k/--keyword no longer takes an optional argument to clear the
default keywords. Instead, use -K/--no-default-keywords to clear
them.
-n/--add-location also no longer takes an optional argument to set
the comment style. Instead, use -S/--style to set the comment
style to GNU or Solaris.
-o/--output can take `-' as the filename, meaning write to
standard output.
The inputfile name can also be `-' meaning read from standard in.
A few other changes include
Kludge to mark the file docstring as translatable. Since the
marking is to place _() around the docstring, and because we
actually have to define the _() function before we use it, this
means that we have to manually assign to __doc__ the output of
_(). This doesn't seem too bad because you'll only use this idiom
when translating a script's docstring (you really don't need to
translate most module docstrings).
Convert everything to string methods and do not import the string
module.
Bump the version number to 1.1
and output windows) so that it if it doesn't succeed with the line
at the cursor, it tries the line before that. This is handy with
tracebacks, where my natural tendency is to click in the displayed
source line rather than in the file/line indicator just above it.
Now I can indulge this tendency.
I factored out a helper and changed the error handling so that a
non-existing file is treated as if the line didn't match -- this is
handy because some function calls (e.g. "foo.bar(1)") match the grep
pattern.
cursor, erase that whitespace first. This avoids a particularly
confusing case where hitting Return at the end of the command didn't
do what it was expected to do -- because it wasn't considered to be at
the end of the command. Now it is.
fix imports
remove parse functions and visitor code
track name change: Classdef to Class
add some comments and tweak order of visitXXX methods
get rid of if __name__ == "__main__ section
idle.py:
Load the config files before anything else happens
XXX Need to define standard way to get files relative to the
IDLE install dir
PyShell.py:
ColorDelegator.py:
Get color defns out of IdleConf instead of IdlePrefs
EditorWindow.py:
Replace hard-coded font & window size with config options
Get extension names via IdleConf.getextensions
extend.py:
Obsolete. Extensions defined in config file.
ParenMatch.py:
Use config file for extension options.
Revise comment about parser requirements.
Simplify logic on find returning None.
Changes the one regexp in PyParse capable of making the re module blow the C
stack when passed unreasonable <0.9 wink> program text. Jeremy Hylton
provoked this with a program of the form:
x = (1,
2,
... # 9997 lines deleted here
10000,
)
Programs "like this" will no longer (no matter how many lines they contain)
trigger re death. OTOH, you can now make another class of unreasonable
program that will take much longer to parse.
This will fold all ISO 8859 chars from the upper half of the
charset into the lower half, which is ...ummm.... unintened.
The second is a typo in the reference to options.escape in main().
make pygettext more compatible with GNU xgettext, specifically:
Added -E/--escape for allowing pass-thru of iso8859-1 characters above
7 bits.
Added -o/--output option for renaming the output file from
messages.pot (there's overlap with -d/--default-domain, but GNU
xgettext has them both).
Added -p/--output-dir for specifying the output directory for
messages.pot.
Added -V/--version for printing the version number.
Added -w/--width for specifying the output page width (this is because
now pygettext, like GNU xgettext will put several locations on the
same line to cut down on vertical space).
Added -x/--exclude-file for specifying a list of strings that are not
to be extracted from the input files.
Bumped version number to 1.0
Try to import fintl and use fintl.gettext as _ if available. Fall
back is to use identity definition of _().
Moved the escape creation to a function make_escapes() so that its
behavior can be controlled by the -E option.
__openseen(): Support the -x option.
write(): Support -w option and vertical space preserving feature.
main(): Support new options.
standard library. Added some comments:
# XXX Note: this is now a standard library module.
# XXX The API needs to undergo changes however; the current code is too
# XXX script-like. This will be addressed later.
of the current module. It also runs the tabnanny to catch any
inconsistent tabs.
Also did a little bit of refactoring: added an errorbox() method to
simplify the display of error dialogs.
- removed now (happily) unused second arg
- need to verify results of [].index are correct; for building consts,
need to have same value and same type, e.g. 2 not the same as 2L
(big surprise). new solution is a little less hackish.
Code gen adds a TupleArg instance in the argument slot. The tuple arg
includes a copy of the names that it is responsble for binding. The
PyAssembler uses this information to calculate the correct argcount.
all fix this wacky case: del (a, ((b,), c)), d
which is the same as: del a, b, c, d
(Can't wait for Guido to tell me why.)
solution uses findOp which walks a tree to find out whether it
contains OP_ASSIGN or OP_DELETE or ...