Commit Graph

1064 Commits

Author SHA1 Message Date
Jeremy Hylton e7f710cc06 add -d option that dumps entire AST before compiling 2000-10-13 21:59:32 +00:00
Jeremy Hylton 9c048f9f65 Now supports entire Python 2.0 language and still supports Python
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
2000-10-13 21:58:13 +00:00
Jeremy Hylton 4e1be72e6b Fix SF bug #116263: support for from .. import *
transformer.py: return '*', None from com_import_as_name
pycodegen.py: special case for name == '*'
pyassem.py: fix stack counting for IMPORT_ opcodes
2000-10-12 20:23:23 +00:00
Jeremy Hylton b769e80056 read in a .pyc file and disassemble the code objects 2000-10-09 14:35:24 +00:00
Tim Peters f2fba87dcc Fix for next iteration of SF bug 115690 (Unicode headaches in IDLE). The
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.
2000-10-06 23:09:00 +00:00
Guido van Rossum 70280b859e I'm moving redemo.py here from Demo/tkinter/guido, since it is
somewhat useful to learn regular expressions, and this way it'll be
installed on Windows.

This closes bug report 115609.
2000-10-06 17:37:12 +00:00
Tim Peters ad14720262 New tool for normalizing indentation of .py files. 2000-10-05 03:48:38 +00:00
Fredrik Lundh 375732cd41 - don't set the titlecase flag for uppercase letters (sorry, tim) 2000-09-25 23:03:34 +00:00
Fredrik Lundh 0f8fad4969 unicode database compression, step 3:
- added decimal digit and digit properties to the unidb tables
2000-09-25 21:01:56 +00:00
Fredrik Lundh e9133f7e2e unicode database compression, step 3:
- use unidb compression for the unicodectype module.  smaller,
  faster, and slightly more portable...

- also mention the unicode directory in Tools/README
2000-09-25 17:59:57 +00:00
Fredrik Lundh cfcea49218 unicode database compression, step 2:
- 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...
2000-09-25 08:07:06 +00:00
Tim Peters 2101348830 Fiddled w/ /F's cool new splitbins function: documented it, generalized it
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.
2000-09-25 07:13:41 +00:00
Fredrik Lundh f367cacb98 unicode database compression, step 1:
- use unidb compression for the unicodedata module.  on Windows,
  the new unidatabase module is 120k, down from nearly 600k.
2000-09-24 23:18:31 +00:00
Tim Peters f58a7aafea Implemented new os.startfile function, unique to Windows, exposing a
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.
2000-09-22 10:05:54 +00:00
Jeremy Hylton 572bdce4b3 change 2-space indent to 4-space indent 2000-09-20 02:47:28 +00:00
Jeremy Hylton 9c36a41694 distutils setup script 2000-09-20 02:35:19 +00:00
Guido van Rossum bdd901714d Fix typo (newtabwith). 2000-09-20 00:17:39 +00:00
Guido van Rossum f8d071332a Temporary fix for Bug #114821.
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.
2000-09-19 20:51:17 +00:00
Jeremy Hylton 0b7b4b8a22 satisfy the tabnanny 2000-09-18 01:46:01 +00:00
Barry Warsaw 64850efa39 Allow this script to act like a module by only calling main() if
__name__ == '__main__'.  Closes SF bug #110844.
2000-09-16 22:09:51 +00:00
Guido van Rossum 8999053326 Fix for bug #113693: with the changes to the IMPORT_FROM opcodes, this
crashed on an assert.
2000-09-15 16:37:42 +00:00
Guido van Rossum 3634112b40 Include the filename in the errror message for F5 without saving.
This closes bug #110660.
2000-09-15 15:45:57 +00:00
Fred Drake 10515b6483 main(): Move hackery of sys.argv until after the Tk instance has been
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.
2000-09-15 04:32:56 +00:00
Guido van Rossum fa6013cff0 Don't emit 8 lines of (c) information at startup -- use the same text
as main.c.
2000-09-05 13:51:14 +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
Jeremy Hylton 92f3972090 patch by Neil Schemenauer to improve (fix?) line number generation 2000-09-01 20:47:37 +00:00
Jeremy Hylton 2051608616 Update magic number.
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.
2000-09-01 20:33:26 +00:00
Guido van Rossum 1688f378cb Rob Hooft, Moshe Zadka: converted to 4 space indents and re instead of regex. 2000-09-01 13:41:37 +00:00
Barry Warsaw 72dacb8026 Tool to generate binary GNU .mo file from .po template files. Written
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.
2000-09-01 08:10:08 +00:00
Thomas Wouters 46cc7c0f7b Bring Tools/compiler almost up to date. Specifically:
- 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.
2000-08-12 20:32:46 +00:00
Jeremy Hylton 20b2ca9d19 add note about compiler directory
(is bgen still "still under development"?)
2000-08-04 17:03:58 +00:00
Jeremy Hylton 7daf04d9e0 replace most calls to emit 'SET_LINENO' will call to method set_lineno
based on bug report by Neil Schemenauer
2000-08-04 16:56:51 +00:00
Jeremy Hylton 8612f1c152 update my email address
fix com_call_function to cope with trailing comma in "f(a, b,)"
2000-08-04 16:54:54 +00:00
Jeremy Hylton da1ec468b1 Python code coverage tool by Skip Montanaro and Andrew Dalke 2000-08-03 19:26:21 +00:00
Greg Stein fd342bf453 add a bit more legal junk
(too lazy to paste in the whole BSD license tho; included by ref)
2000-08-03 17:39:13 +00:00
Andrew M. Kuchling 7e11170e85 Removed Tools/perfecthash, per python-dev discussion 2000-07-29 13:24:39 +00:00
Guido van Rossum efdf107fb7 Add the exceptions module to the 'never' list -- it is built in. 2000-07-28 10:34:48 +00:00
Jeremy Hylton 4d6381dfee Fix UCNs machine with >= 32bit longs
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.
2000-07-26 03:56:06 +00:00
Jeremy Hylton ffe968b8fe This script demonstrates use of the visitor interface of the compiler
package.
2000-07-25 16:43:23 +00:00
Peter Schneider-Kamp 332c59c4ef change some occurence of python15.dll to python20.dll
closes patch #100956
2000-07-24 16:02:00 +00:00
Thomas Wouters 7889010731 Miscelaneous ANSIfications. I'm assuming here 'main' should take (int,
char**) and return an int even on PC platforms. If not, please fix
PC/utils/makesrc.c ;-P
2000-07-22 19:25:51 +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
Jack Jansen c8081e9bfa Modified the standard mac preamble so we include pymactoolbox.h in
stead of defining lots of function prototypes in each module.
2000-07-15 22:29:30 +00:00
Jack Jansen 629eee0636 ScannerPREUH3.initpatterns() should call Scanner.initpatterns() so the
new comment patterns get included.
2000-07-15 22:27:47 +00:00
Guido van Rossum f67c2383da Patch by Toby Dickenson, mentored by Mark Hammond, to support
automatically finding (most of) the standard PYD extensions, and to
remove the hardcoded Python version.
2000-07-13 15:45:17 +00:00
Peter Schneider-Kamp 7f589fddad add expandtabs command (-e)
change eliminate to delete (-d)
2000-07-11 16:43:16 +00:00
Fred Drake 3637799afe Update to use the new standard webbrowser module if available, otherwise
uses the BrowserControl module.

BrowserControl is not removed to allow IDLE to be distributed separately
and still be used with Python 1.5.2.
2000-07-09 19:10:19 +00:00
Tim Peters dbd9ba6a6c Nuke all remaining occurrences of Py_PROTO and Py_FPROTO. 2000-07-09 03:09:57 +00:00
Marc-André Lemburg bc30b11764 Fix to use Py_UCS4. By Bill Tutt. 2000-07-07 17:53:54 +00:00
Jack Jansen e3889da076 Make a distinction between shorts and unsigned shorts. 2000-07-06 15:17:52 +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
Marc-André Lemburg a4657f736c Marc-Andre Lemburg <mal@lemburg.com>:
Fixed a quote bug. Thanks to Fredrik Lundh.
2000-06-30 10:30:35 +00:00
Marc-André Lemburg e3f257e681 Marc-Andre Lemburg <mal@lemburg.com>:
Include <> -> "". Removed some left over code at the end of the file.
Patch by Bill Tutt.
2000-06-30 09:56:00 +00:00
Marc-André Lemburg 90321ec314 Marc-Andre Lemburg <mal@lemburg.com>:
Include <> -> "". Patch by Bill Tutt.
2000-06-30 09:53:22 +00:00
Guido van Rossum a04ff0fb53 Running the program through itself reveals that one end tag was
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!)
2000-06-28 22:55:20 +00:00
Guido van Rossum 59811b189d Peter Schneider-Kamp:
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
2000-06-28 22:47:22 +00:00
Guido van Rossum b7c298f806 Jack Jansen: Support for conditional inclusion of methods and functions 2000-06-28 20:53:33 +00:00
Marc-André Lemburg 4e5302a27e Marc-Andre Lemburg <mal@lemburg.com>:
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.
2000-06-28 16:53:16 +00:00
Marc-André Lemburg c5bb9c21fe Marc-Andre Lemburg <mal@lemburg.com>:
Generator for the new ucnhash module (ucnhash.h|c). Uses perfect_hash.py
to create the ucnhash module.
2000-06-28 16:49:29 +00:00
Marc-André Lemburg 93c409a590 Marc-Andre Lemburg <mal@lemburg.com>:
Utility extension module needed by perfect_hash.py

By Bill Tutt.
2000-06-28 16:48:05 +00:00
Fred Drake 6cd948ebd8 Rename the "browser" module to "BrowserControl", since Guido did not
like the short, ambiguous name.
2000-05-10 17:28:42 +00:00
Fred Drake 8638ace511 EditorWindow.python_docs():
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.
2000-05-10 16:50:07 +00:00
Fred Drake 95a40001e6 Collection of classes and convenience functions to control external
Web browsers.
2000-05-10 16:47:27 +00:00
Fred Drake bd7b8b3310 Minor edit of leading comments: 'the the' --> 'the', quoted 'enable'
option name for clarity.
2000-05-09 14:28:03 +00:00
Guido van Rossum 4b1235cdac Toby Dickenson:
Fix for problem with freeze when both "-m" and "-s service" options
are used.

(Blessed by MarkH)
2000-05-06 03:18:08 +00:00
Jeremy Hylton be317e615e patches from Mark Hammond
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.
2000-05-02 22:32:59 +00:00
Jeremy Hylton 0a4f1ff64e patches from Mark Hammond
compile.py:
On Windows, use 'nul' instead of '/dev/null'.

test.py:
Use double-quotes for the command-line, as Windows doesnt recognise
singles.
2000-05-02 22:29:46 +00:00
Barry Warsaw 75a6e67e69 Added an unused Unicode string for testing. 2000-05-02 19:28:30 +00:00
Guido van Rossum ce33eb3ee8 Sjoerd Mullender:
Bad % formatting.
2000-05-02 13:49:13 +00:00
Guido van Rossum 6664bb87dc Sjoerd Mullender: cmp.py is obsolete... 2000-04-28 13:31:52 +00:00
Guido van Rossum f3335e193b Patch inspired by Just van Rossum: on the Mac, in savefilename(), make
the path to save a relative path by prefixing it with os.sep (':').
Also fix an indent inconsistency in the same function.
2000-04-25 21:13:24 +00:00
Guido van Rossum e56b4cf804 Jack Jansen: A few new types needed by new API calls. 2000-04-24 14:56:00 +00:00
Guido van Rossum e39a88fd58 Two more items. 2000-04-11 15:30:19 +00:00
Fred Drake d6904ea5a0 Use a better approach to locating IDLE's default configuration,
allowing it to be run from anywhere, including through a symlink to
the actual idle.py script.
2000-04-10 16:27:47 +00:00
Guido van Rossum fa9ef1864f Just in case someone wants to use this, let's fix the pathname. 2000-04-06 20:09:17 +00:00
Guido van Rossum 2b6004a07f New version 1.0.4. I'm sure someone mailed me these patches but I
can't remember who. :-)  Changes:

- Support for Windows NT (different locking behavior)
- Added a logging mechanism
2000-03-31 00:58:00 +00:00
Guido van Rossum 8daef3791e New version 1.0.4. I'm sure someone mailed me these patches but I
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
2000-03-31 00:55:54 +00:00
Guido van Rossum e0dd3010ce Removed two files that were added temporarily. 2000-03-30 20:34:56 +00:00
Guido van Rossum b8f512bfa4 Bump version to 0.6 for the event of the Python 1.6 alpha 1 release. 2000-03-30 20:30:34 +00:00
Barry Warsaw bc9476ebe5 __pushtodev(): Ignore transient sunaudiodev.errors when setting the
device info.  I don't know why these occur, but they seem to be
shortlived and harmless.
2000-03-29 21:05:53 +00:00
Guido van Rossum 918429b3b2 Moved robotparser.py to the Lib directory.
If you do a "cvs update" in the Lib directory, it will pop up there.
2000-03-29 16:02:45 +00:00
Guido van Rossum 84306246f1 Fix suggested by Magnus Kessler: in class Page, it is possible for
self.parser to be None; in that case don't dereference it in
getnames().
2000-03-28 20:10:39 +00:00
Guido van Rossum dc8b7980e0 Skip Montanaro:
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
2000-03-27 19:29:31 +00:00
Fred Drake 70b5d47f71 From Sjoerd Mullender <sjoerd@oratrix.nl>:
cmp is not used in freeze, but is imported anyway.  What's worse, cmp
is no longer in the library, so freeze won't work like this.
2000-03-23 18:13:10 +00:00
Fred Drake bae57a88a6 Of course, I forget how to type long ago...
Typo noted by /F.
2000-03-17 16:56:23 +00:00
Fred Drake 1966004986 "write marshalled" --> "writes marshalled" (in docstring); noted by
Detlef Lannert <lannert@lannert.rz.uni-duesseldorf.de>.
2000-03-17 15:43:37 +00:00
Jeremy Hylton 36cc6a2197 complete rewrite
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
2000-03-16 20:06:59 +00:00
Jeremy Hylton f635abee3a simplify visitor walker class
- remove postorder
- remove protocol for automatically walking children based on visitor
  method return value; now only walks if there is no method
2000-03-16 20:04:16 +00:00
Jeremy Hylton b631b8ede5 fix list.append problems 2000-03-16 20:03:04 +00:00
Jeremy Hylton e4d6293383 change name of Set method: items -> elements (avoids confusion with
dict)
2000-03-16 20:02:38 +00:00
Guido van Rossum 7f1cd296c6 Tim Peters writes:
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)
2000-03-13 14:50:24 +00:00
Guido van Rossum 34a79115c5 Marc-Andre Lemburg: added
gencodec.py - Create Python codecs from Unicode mapping files
2000-03-10 22:36:57 +00:00
Jeremy Hylton 329e4be05a a simple client-server framework for executing code in a different
process

not yet connected with IDLE
2000-03-09 19:56:50 +00:00
Barry Warsaw a17e0f1b61 A bunch of changes, primarily to command line argument parsing
(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
2000-03-08 15:18:35 +00:00
Guido van Rossum 9de988315a Override the Undo delegator to forbid any changes before the I/O mark.
It beeps if you try to insert or delete before the "iomark" mark.
This makes the shell less confusing for newbies.
2000-03-07 18:51:49 +00:00
Jeremy Hylton 6fbd1f85d9 replace : with = 2000-03-07 17:56:47 +00:00
Jeremy Hylton ae1f3bd7bd rename the global IdleConfParser object from IdleConf to idleconf
standard usage is now from IdleConf import idleconf
2000-03-07 17:56:27 +00:00
Jeremy Hylton 6b3edf0510 rename the global IdleConfParser object from IdleConf to idleconf
standard usage is now from IdleConf import idleconf

replace : with = in config.txt
2000-03-07 17:55:32 +00:00
Guido van Rossum ba23bed340 Tweak the goto file/line command (in the right button menu in PyShell
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.
2000-03-07 16:25:11 +00:00