Commit Graph

4694 Commits

Author SHA1 Message Date
Kurt B. Kaiser 96d8842237 Implement idle command interface as suggested by GvR [idle-dev] 16 July
****************
PyShell: Added functionality:

usage: idle.py [-c command] [-d] [-i] [-r script] [-s] [-t title] [arg] ...

idle file(s)    (without options) edit the file(s)

-c cmd     run the command in a shell
-d         enable the debugger
-i         open an interactive shell
-i file(s) open a shell and also an editor window for each file
-r script  run a file as a script in a shell
-s         run $IDLESTARTUP or $PYTHONSTARTUP before anything else
-t title   set title of shell window

Remaining arguments are applied to the command (-c) or script (-r).

******************
idles: Removed the idles script, not needed

******************
idle:  Removed the IdleConf references, not required anymore
2001-07-17 04:59:01 +00:00
Fred Drake cf580c7ea1 Added tests for the new yield support in the parser module.
(Should be merged with descr branch.)
2001-07-17 03:01:29 +00:00
Tim Peters 861adac23e This has never worked on Windows. Now it does. If it breaks on Unix now,
great, it's your turn to watch it fail for months <0.9 wink>.
2001-07-16 20:49:49 +00:00
Barry Warsaw 06069330e3 test_basic(): Add a test for "person@dom.ain (User J. Person)" which
was already correctly parsed (contrary to a comment in Mailman).

test_rfc2822_phrases(): RFC 2822 now requires that we allow `.' in
phrases, which means we must accept dots in unquoted realname parts.
Add a test to check the change in rfc822.py 1.58.
2001-07-16 20:44:16 +00:00
Barry Warsaw b8a55c00d5 Stoopid change, just to mention that the last checkin resolves SF bug
#437395
2001-07-16 20:41:40 +00:00
Barry Warsaw 9ec58aaef2 Fix address parsing to be RFC 2822 conformant. Specifically, dots are
now allowed in unquoted RealName areas (technically, they are defined
as "obsolete syntax" we MUST accept in phrases, as part of the
obs-phrase production).  Thus, parsing

    To: User J. Person <person@dom.ain>

correctly returns "User J. Person" as the RealName.

AddrlistClass.__init__(): Add definition of self.phraseends which is
just self.atomends with `.' removed.

getatom(): Add an optional argument `atomends' which, if None (the
default) means use self.atomends.

getphraselist(): Pass self.phraseends to getatom() and break out of
the loop only when the current character is in phraseends instead of
atomends.  This allows dots to continue to serve as atom delimiters in
all contexts except phrases.

Also, loads of docstring updates to document RFC 2822 conformance
(sorry, this should have been two separate patches).
2001-07-16 20:40:35 +00:00
Fred Drake 19ff4ac7e9 Add a unit test for sgmllib (needs work, but has already caught problems).
Based on the test for the HTMLParser module.
2001-07-16 18:52:40 +00:00
Fred Drake 14f6c18b62 Give more useful information about a failing PyUnit-style test. 2001-07-16 18:51:32 +00:00
Fred Drake 50bc19fce5 Remove a duplicate test. 2001-07-16 18:50:29 +00:00
Tim Peters 03813399cc Document doctest's generator-future hack. 2001-07-16 18:39:58 +00:00
Fred Drake fb38c76e0f In CDATA mode, make sure entity-reference syntax is not interpreted;
entity references are not allowed in that mode.

Do a better job of scanning <!DOCTYPE ...> declarations; based on the
code in HTMLParser.py.
2001-07-16 18:30:35 +00:00
Guido van Rossum 63a47402b3 Fix a mismatched parenthesis in the last patch. 2001-07-16 14:46:13 +00:00
Andrew M. Kuchling 286b107bea [Bug #441527] Fixes for preprocessor support, contributed by Tarn
Weisner Burton
2001-07-16 14:19:20 +00:00
Kurt B. Kaiser d65ca7231a Added installation instructions.
Added a patch which modifies idlefork so that it can co-exist with
"official" IDLE in the site-packages directory. This patch is not
necessary if only idlefork IDLE is installed. See INSTALLATION for further
details.
2001-07-16 07:08:20 +00:00
Kurt B. Kaiser 91e476f297 Add a script "idles" which opens a Python Shell window.
The default behaviour of idlefork idle is to open an editor window instead
of a shell. Complex expressions may be run in a fresh environment by
selecting "run".  There are times, however, when a shell is desired.
Though one can be started by "idle -t 'foo'", this script is more
convenient.  In addition, a shell and an editor window can be started
in parallel by "idles -e foo.py".
2001-07-16 05:50:45 +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
Kurt B. Kaiser e75785a646 Call out IDLE Fork in startup message. 2001-07-16 05:25:12 +00:00
Kurt B. Kaiser 21ebb211df Add a script "idles" which opens a Python Shell window.
The default behaviour of idlefork idle is to open an editor window instead
of a shell. Complex expressions may be run in a fresh environment by
selecting "run".  There are times, however, when a shell is desired.
Though one can be started by "idle -t 'foo'", this script is more
convenient.  In addition, a shell and an editor window can be started
in parallel by "idles -e foo.py".
2001-07-16 04:00:10 +00:00
Tim Peters 5ba5866281 Part way to allowing "from __future__ import generators" to communicate
that info to code dynamically compiled *by* code compiled with generators
enabled.  Doesn't yet work because there's still no way to tell the parser
that "yield" is OK (unlike nested_scopes, the parser has its fingers in
this too).
Replaced PyEval_GetNestedScopes by a more-general
PyEval_MergeCompilerFlags.  Perhaps I should not have?  I doubted it was
*intended* to be part of the public API, so just did.
2001-07-16 02:29:45 +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
Kurt B. Kaiser 0765976cc4 tabnanny and pyclbr are now found in /Lib 2001-07-14 17:06:13 +00:00
Kurt B. Kaiser 03b75dc007 Remove, was retained for 1.5.2 support 2001-07-14 16:29:46 +00:00
Fred Drake 8600b47b61 Be more permissive in what is accepted as an attribute name; this makes
this module slightly more resiliant in the face of XHTML input, or just
colons in attribute names.
2001-07-14 05:50:33 +00:00
Kurt B. Kaiser 3eb78609c0 Installing Idle to site-packages via Distutils does not
copy the Idle help.txt file.

Ref SF Python Patch 422471
2001-07-14 05:48:44 +00:00
Kurt B. Kaiser b7651761bf py-cvs-2001_07_13 (Rev 1.3) merge
"Make copy, cut and paste events case insensitive.  Reported by Patrick
K. O'Brien on idle-dev. (Should other bindings follow suit?)" --GvR
2001-07-14 05:26:23 +00:00
Kurt B. Kaiser 7711b5f432 py-cvs-2001_07_13 (Rev 1.4) merge
"Move the action of loading the configuration to the IdleConf module
rather than the idle.py script.  This has advantages and
disadvantages; the biggest advantage being that we can more easily
have an alternative main program."  --GvR
2001-07-14 05:21:37 +00:00
Kurt B. Kaiser 40610547be py-cvs-2001_07_13 (Rev 1.4) merge
"Quick update to the extension mechanism (extend.py is gone, long live
config.txt)" --GvR
2001-07-14 05:18:59 +00:00
Kurt B. Kaiser a4c9be88c6 py-cvs-2001_07_13 (Rev 1.16) merge
"Refactored, with some future plans in mind. This now uses the new
gotofileline() method defined in FileList.py"  --GvR
2001-07-14 05:15:29 +00:00
Kurt B. Kaiser bb6b1e9b26 py-cvs-2001_07_13 (Rev 1.34) merge
"Amazing.  A very subtle change in policy in descr-branch actually
found a bug here.  Here's the deal: Class PyShell derives from class
OutputWindow.  Method PyShell.close()
wants to invoke its parent method, but because PyShell long ago was
inherited from class PyShellEditorWindow, it invokes
PyShelEditorWindow.close(self).  Now, class PyShellEditorWindow itself
derives from class OutputWindow, and inherits the close() method from
there without overriding it.  Under the old rules,
PyShellEditorWindow.close would return an unbound method restricted to
the class that defined the implementation of close(), which was
OutputWindow.close.  Under the new rules, the unbound method is
restricted to the class whose method was requested, that is
PyShellEditorWindow, and this was correctly trapped as an error." --GvR
2001-07-14 05:10:34 +00:00
Kurt B. Kaiser 752e4d5531 py-cvs-2001_07_13 (Rel 1.9) merge
"Taught IDLE's autoident parser that "yield" is a keyword that begins a
stmt.  Along w/ the preceding change to keyword.py, making all this
work w/ a future-stmt just looks harder and harder." --tim_one

(From Rel 1.8: "Hack to make this still work with Python 1.5.2.  ;-( "
--fdrake)
2001-07-14 04:59:24 +00:00
Kurt B. Kaiser 8bf5b2027a py-cvs-2001_07_13 (Rel 1.7) merge
"Move the action of loading the configuration to the IdleConf module
rather than the idle.py script.  This has advantages and
disadvantages; the biggest advantage being that we can more easily
have an alternative main program." --GvR
2001-07-14 04:51:06 +00:00
Kurt B. Kaiser df8a40fbf5 py-cvs-2000_07_13 (Rev 1.9) merge
"Delete goodname() method, which is unused. Add gotofileline(), a
convenience method which I intend to use in a
variant. Rename test() to _test()."  --GvR

This was an interesting merge. The join completely missed removing
goodname(), which was adjacent, but outside of, a small conflict.
I only caught it by comparing the 1.1.3.2/1.1.3.3 diff.  CVS ain't
infallible.
2001-07-14 04:45:32 +00:00
Kurt B. Kaiser fd182cd9d3 py-cvs-2000_07_13 (Rev 1.38) merge
"Remove legacy support for the BrowserControl module; the webbrowser
module has been included since Python 2.0, and that is the preferred
interface." --fdrake
2001-07-14 03:58:25 +00:00
Kurt B. Kaiser 4796c65952 py-cvs-rel2_1 (Rev 1.2) merge
Copied py-cvs rev 1.2 changed file to idlefork MAIN
2001-07-14 02:02:36 +00:00
Kurt B. Kaiser 1313833113 py-cvs-rel2_1 (Rev 1.2) merge
Copied py-cvs 1.2 changed file to idlefork MAIN
2001-07-14 01:58:10 +00:00
Kurt B. Kaiser bdaac36d00 py-cvs-rel2_1 (rev 1.5) merge - whitespace normalization 2001-07-14 01:23:30 +00:00
Kurt B. Kaiser f61eb42988 py-cvs-rel2_1 (Rev 1.3) merge - whitespace normalization 2001-07-14 01:20:05 +00:00
Kurt B. Kaiser fcd44ec5ea py-cvs-rel2_1 (Rev 1.15) merge - whitespace normalization 2001-07-14 01:16:56 +00:00
Kurt B. Kaiser d5338a8f99 py-cvs-rel2_1 (Rev 1.2) merge - whitespace normalization 2001-07-14 01:14:09 +00:00
Kurt B. Kaiser 94bd77415f cvs-py-rel2_1 (Rev 1.29 - 1.33) merge
Merged the following py-cvs revs without conflict:
1.29 Reduce copyright text output at startup
1.30 Delay setting sys.args until Tkinter is fully initialized
1.31 Whitespace normalization
1.32 Turn syntax warning into error when interactive
1.33 Fix warning initialization bug

Note that module is extensively modified wrt py-cvs
2001-07-14 00:13:28 +00:00
Kurt B. Kaiser 3269cc8bd1 py-cvs-rel2_1 (Rev 1.6 - 1.8) merge
Fix autoindent bug and deflect Unicode from text.get()
2001-07-13 20:33:46 +00:00
Kurt B. Kaiser 48b03144ec py-cvs-rel2_1 (Rev 1.3)
"move "from Tkinter import *" to module level" --jhylton
2001-07-13 20:00:15 +00:00
Kurt B. Kaiser bec5e5cb90 py-cvs-rel2_1 (Rev 1.6) merge - whitespace normalization 2001-07-13 19:57:00 +00:00
Kurt B. Kaiser 4d4d212325 cvs-py-rel2_1 (Rev 1.5) merge - whitespace normalization 2001-07-13 19:49:27 +00:00
Guido van Rossum 6e735c98dc Updated this file to match reality.
Thanks Shane for pointing this out!
2001-07-13 18:05:46 +00:00
Kurt B. Kaiser 6a945a5904 py-cvs-rel2_1 (Rev 1.3) merge
"Make the test program work outside IDLE."  -- GvR
2001-07-13 17:57:37 +00:00
Kurt B. Kaiser 8220fdda75 py-cvs-rel2_1 (Rev 1.2) merge - whitespace normalization 2001-07-13 17:52:08 +00:00
Kurt B. Kaiser 233bf2c563 py-cvs-rel2_1 (Rev 1.2) merge - whitespace normalization 2001-07-13 17:44:06 +00:00
Kurt B. Kaiser 4e32e7e567 py-cvs-rel2_1 (Rev 1.4) merge - whitespace normalization 2001-07-13 17:40:17 +00:00
Kurt B. Kaiser 7717ad6817 py-cvs-rel2_1 (Rev 1.6) merge - whitespace normalization 2001-07-13 17:38:08 +00:00
Guido van Rossum 0960015056 Should raise TestSkipped, not ImportError, when deciding to skip the
test.
2001-07-13 17:27:57 +00:00
Tim Peters 9a8c8e270b Having fun on my own time: quicker flat_conjoin; Knights Tour solver
simplified and generalized to rectangular boards.
2001-07-13 09:12:12 +00:00
Kurt B. Kaiser 7eea271464 py-cvs-rel2_1 (Rev 1.4) merge - move "import *" to module level 2001-07-13 04:18:32 +00:00
Kurt B. Kaiser 0e5fb0a618 py-cvs-rel2_1 (Rev 1.9) merge - whitespace normalization 2001-07-13 04:12:02 +00:00
Kurt B. Kaiser 6be679047b py-cvs-rel2_1 (Rev 1.8) merge - whitespace normalization 2001-07-13 04:07:47 +00:00
Kurt B. Kaiser afdf71b9ee py-cvs-rel2_1 (Rev 1.33 - 1.37) merge
VP IDLE version depended on VP's ExecBinding.py and spawn.py to get the
path to the Windows Doc directory (relative to python.exe). Removed this
conflicting code in favor of py-cvs updates which on Windows use a hard
coded path relative to the location of this module. py-cvs updates include
support for webbrowser.py.  Module still has BrowserControl.py for 1.5.2
support.

At this point, the differences wrt py-cvs relate to menu functionality.
2001-07-13 03:35:32 +00:00
Kurt B. Kaiser a3253d70bc py-cvs-rel2_1 merge - Remove, lives in /Lib 2001-07-13 01:30:07 +00:00
Kurt B. Kaiser 628b362886 py-cvs-rel2_1 (Rev 1.3) merge - whitespace normalization 2001-07-13 00:10:02 +00:00
Kurt B. Kaiser 5291d46755 py-cvs-rel2_1 (Rev 1.15) merge - whitespace normalization 2001-07-13 00:07:42 +00:00
Kurt B. Kaiser 6df4bf2864 py-cvs-rel2_1 (Rev 1.11 and 1.12) merge
Colorize "as" after "import" / use DEBUG instead of __debug__
2001-07-13 00:04:24 +00:00
Kurt B. Kaiser d6c4c9e846 py-cvs-rel2_1 (Rev 1.12) merge - whitespace normalization 2001-07-12 23:54:20 +00:00
Kurt B. Kaiser ae67647ab7 py-cvs-rel2_1 (Rev 1.8) merge - whitespace normalization 2001-07-12 23:10:35 +00:00
Tim Peters a1d545523d Remove the last remnants of the hacks to worm around leaks. 2001-07-12 22:55:42 +00:00
Tim Peters 3446365c37 Repair flawed example. 2001-07-12 22:43:41 +00:00
Tim Peters c4889c496a Remove now-unnecessary "from __future__ import nested_scopes" stmts. 2001-07-12 22:36:02 +00:00
Kurt B. Kaiser 9a1ae1a960 py-cvs-rel2_1 (Rev 1.3) merge - whitespace normalization 2001-07-12 22:26:44 +00:00
Kurt B. Kaiser 180b6be18c py-cvs-rel1_2 (Rev 1.4) merge,
"Add Alt-slash to Unix keydefs (I somehow need it on RH 6.2).
Get rid of assignment to unused self.text.wordlist."  --GvR
2001-07-12 22:13:51 +00:00
Fred Drake fd4ff52c22 Actually remove directories from sys.path if they do not exist; the intent
is to avoid as many stat() calls as we can.
2001-07-12 21:08:33 +00:00
Neil Schemenauer b20e9dbf89 Remove reference cycle breaking code. The GC now takes care of it. 2001-07-12 13:26:41 +00:00
Neil Schemenauer 88c761a117 Test GC of frame objects. 2001-07-12 13:25:53 +00:00
Guido van Rossum 28358fbed6 Make the test pass now that 10**-15 returns a float instead of raising
an exception.
2001-07-12 12:51:22 +00:00
Steven M. Gava e9880c81b9 py-cvs merge, python 1.5.2 compatability 2001-07-12 06:54:16 +00:00
Steven M. Gava 42f6c64816 py-cvs merge, better error dialog 2001-07-12 06:46:53 +00:00
Steven M. Gava 9713992bad py-cvs merge, additions 2001-07-12 06:38:24 +00:00
Steven M. Gava 817a76cfbb py-cvs merge, correct indentation 2001-07-12 05:35:17 +00:00
Steven M. Gava fc0386cc5a py-cvs merge, correct typo 2001-07-12 05:24:19 +00:00
Steven M. Gava 569b17f414 py-cvs merge, update colour changing info 2001-07-12 05:21:08 +00:00
Tim Peters 6a479f5488 PEP 250: Add lib/site-packages to sys.path on Windows; also sys.prefix
to sys.path if os.sep == ':' (Macs?).  See PEP 250.
2001-07-12 05:20:13 +00:00
Steven M. Gava 9fe8828cbf py-cvs merge, idle_dir loading changed 2001-07-12 04:51:11 +00:00
Steven M. Gava ba910c1e92 py-cvs merge, version update 2001-07-12 04:44:48 +00:00
Tim Peters 3230d5c961 SF patch #440170: Tests for fileinput module.
New test_fileinput.py from Nick Mathewson, fiddled to use TESTFN and sundry
style nits.
2001-07-11 22:21:17 +00:00
Tim Peters 48dacc69a2 SF patch #440144: Tests and minor bugfix for uu module.
New test_uu.py from Nick Mathewson, fiddled to work on Windows too.
Somebody should check that it still works on non-Windows boxes, though!
2001-07-11 21:43:42 +00:00
Fredrik Lundh b905633be0 xmlrpclib for python 2.2; initial checkin 2001-07-11 17:42:21 +00:00
Tim Peters 79c8671c7a SF patch #440144: Tests and minor bugfix for uu module
decode():  While writing tests for uu.py, Nick Mathewson discovered
that the 'Truncated input file' exception could never get raised,
because its "if not str:" test was actually testing the builtin
function "str", not the local string vrbl "s" as intended.

Bugfix candidate.
2001-07-11 04:08:49 +00:00
Kurt B. Kaiser 9178af1455 Initial revision 2001-07-11 02:53:57 +00:00
Guido van Rossum 05be1a0fd6 Ported to Windows:
- Set the host to "localhost" instead of "".

- Skip the AF_UNIX tests when socket.AF_UNIX is not defined.
2001-07-10 15:46:34 +00:00
Guido van Rossum 39f1b3656e A test suite for SocketServer.py that exposes the various bugs just
fixed.  Regrettably, this must be run manually -- somehow the I/O
redirection of the regression test breaks the test.  When run under
the regression test, this raises ImportError with a warning to that
effect.

Bugfix candidate!
2001-07-10 11:52:38 +00:00
Guido van Rossum 7de4d645a5 IMPORTANT FIX: This should definitely go into the 2.1.1 release!!!
Fix various serious problems:

- The ThreadingTCPServer class and its derived classes were completely
  broken because the main thread would close the request before the
  handler thread had time to look at it.  This was introduced by
  Ping's close_request() patch.  The fix moves the close_request()
  calls to after the handler has run to completion in the BaseServer
  class and the ForkingMixIn class; when using the ThreadingMixIn,
  closing the request is the handler's responsibility.

- The ForkingUDPServer class has always been been broken because the
  socket was closed in the child before calling the handler.  I fixed
  this by simply not calling server_close() in the child at all.

- I cannot get the UnixDatagramServer class to work at all.  The
  recvfrom() call doesn't return a meaningful client address.  I added
  a comment to this effect.  Maybe it works on other Unix versions.

- The __all__ variable was missing ThreadingMixIn and ForkingMixIn.

- Bumped __version__ to "0.4".

- Added a note about the test suite (to be checked in shortly).
2001-07-10 11:50:09 +00:00
Fredrik Lundh 2d96f11d07 map re.sub() to string.replace(), when possible 2001-07-08 13:26:57 +00:00
Fredrik Lundh e06cbb8c56 bug #436596
re.findall doesn't take a maxsplit argument
2001-07-06 20:56:10 +00:00
Fred Drake beb6713ea7 When reading a continuation line, make sure we still use the transformed
name when filling in the internal data structures, otherwise we incorrectly
raise a KeyError.

This fixes SF bug #432369.
2001-07-06 17:22:48 +00:00
Fred Drake dc19163b18 Allow underscores in tag names and quote characters in unquoted attribute
values.  The change for attribute values matches the way Mozilla and
Navigator view the world, at least.

This closes SF bug #436621.
2001-07-05 18:21:57 +00:00
Guido van Rossum c09cf33658 Rip out tests for xrange() features no longer supported. 2001-07-05 14:49:21 +00:00
unknown 31569561fd Added a non-recursive implementation of conjoin(), and a Knight's Tour
solver.  In conjunction, they easily found a tour of a 200x200 board:
that's 200**2 == 40,000 levels of backtracking.  Explicitly resumable
generators allow that to be coded as easily as a recursive solver (easier,
actually, because different levels can use level-customized algorithms
without pain), but without blowing the stack.  Indeed, I've never written
an exhaustive Tour solver in any language before that can handle boards so
large ("exhaustive" == guaranteed to find a solution if one exists, as
opposed to probabilistic heuristic approaches; of course, the age of the
universe may be a blip in the time needed!).
2001-07-04 22:11:22 +00:00
unknown a5aa0b5261 dummy checkin for testing, please ignore 2001-07-04 16:52:02 +00:00
unknown fee75ac4e5 Fix for SF bug #425868.
We should not depend on two spaces between words, so use the white
space after the to-be-encoded word only as lookahead and don't
actually consume it in the regular expression.
2001-07-04 10:15:58 +00:00
unknown 67bbd7a773 Clean up a bare except: clause. 2001-07-04 07:07:33 +00:00
unknown 3db163aa19 Clean up a bare except: clause. 2001-07-04 07:01:29 +00:00
Fred Drake fbe7b4fc8c Make the implementations of getElementsByTagName() and
getElementsByTagNameNS() consistent in form as well as functionality
(cosmetic).
2001-07-04 06:25:53 +00:00
Fred Drake ec3dfdee6a Only write out one blank line before the request data.
This closes SF patch #419459.
2001-07-04 05:18:29 +00:00
Fredrik Lundh df781e6a3f reapplied darryl gallion's minimizing repeat fix. I'm still not 100%
sure about this one, but test #133283 now works even with the fix in
place, and so does the test suite.  we'll see what comes up...
2001-07-02 19:54:28 +00:00
Fredrik Lundh 19af43d78a added martin's BIGCHARSET patch to SRE 2.1.1. martin reports 2x
speedups for certain unicode character ranges.
2001-07-02 16:58:38 +00:00
Fred Drake 1fb5ce0323 Avoid using os.path.normcase() on sys.path elements; doing so causes paths
to be presented in an unfamiliar case on case-preserving filesystems.

This closes SF patch #436173.
2001-07-02 16:55:42 +00:00
Tim Peters 683ecc7374 Nuke hard tabs. 2001-07-02 04:59:35 +00:00
Tim Peters d1c296537f Whitespace normalization; the plat-riscos file didn't even get by
tabnanny.py.
2001-07-02 04:57:30 +00:00
Tim Peters 353026663c A clever union-find implementation from c.l.py, due to David Eppstein.
This is another one that leaks memory without an explict clear!  Time to
bite this bullet.
2001-07-02 01:38:33 +00:00
Tim Peters c468fd28b6 Derive an industrial-strength conjoin() via cross-recursion loop unrolling,
and fiddle the conjoin tests to exercise all the new possible paths.
2001-06-30 07:29:44 +00:00
Tim Peters 4efb6e9643 Turns out Neil didn't intend for *all* of his gen-branch work to get
committed.

tokenize.py:  I like these changes, and have tested them extensively
without even realizing it, so I just updated the docstring and the docs.

tabnanny.py:  Also liked this, but did a little code fiddling.  I should
really rewrite this to *exploit* generators, but that's near the bottom
of my effort/benefit scale so doubt I'll get to it anytime soon (it
would be most useful as a non-trivial example of ideal use of generators;
but test_generators.py has already grown plenty of food-for-thought
examples).

inspect.py:  I'm sure Ping intended for this to continue running even
under 1.5.2, so I reverted this to the last pre-gen-branch version.  The
"bugfix" I checked in in-between was actually repairing a bug *introduced*
by the conversion to generators, so it's OK that the reverted version
doesn't reflect that checkin.
2001-06-29 23:51:08 +00:00
Guido van Rossum 52b8c29ca7 Solve SF bug #231249: cgi.py opens too many (temporary) files.
class FieldStorage: this patch changes read_lines() and co. to use a
StringIO() instead of a real file.  The write() calls are redirected
to a private method that replaces it with a real, external file only
when it gets too big (> 1000 bytes).

This avoids problems in forms using the multipart/form-data encoding
with many fields.  The original code created a temporary file for
*every* field (not just for file upload fields), thereby sometimes
exceeding the open file limit of some systems.

Note that the simpler solution "use a real file only for file uploads"
can't be used because the form field parser has no way to tell which
fields correspond to file uploads.

It's *possible* but extremely unlikely that this would break someone's
code; they would have to be stepping way outside the documented
interface for FieldStorage and use f.file.fileno(), or depend on
overriding make_file() to return a file-like object with additional
known properties.
2001-06-29 13:06:06 +00:00
Tim Peters be4f0a7748 Added a simple but general backtracking generator (conjoin), and a couple
examples of use.  These poke stuff not specifically targeted before, incl.
recursive local generators relying on nested scopes, ditto but also
inside class methods and rebinding instance vars, and anonymous
partially-evaluated generators (the N-Queens solver creates a different
column-generator for each row -- AFAIK this is my invention, and it's
really pretty <wink>).  No problems, not even a new leak.
2001-06-29 02:41:16 +00:00
Tim Peters 08a898f85d Another "if 0:" hack, this time to complain about otherwise invisible
"return expr" instances in generators (which latter may be generators
due to otherwise invisible "yield" stmts hiding in "if 0" blocks).
This was fun the first time, but this has gotten truly ugly now.
2001-06-28 01:52:22 +00:00
Tim Peters f6ed0740a8 This no longer leaks memory when run in an infinite loop. However,
that required explicitly calling LazyList.clear() in the two tests that
use LazyList (I added a LazyList Fibonacci generator too).

A real bitch:  the extremely inefficient first version of the 2-3-5 test
*looked* like a slow leak on Win98SE, but it wasn't "really":  it generated
so many results that the heap grew over 4Mb (tons of frames!  the number
of frames grows exponentially in that test).  Then Win98SE malloc() starts
fragmenting address space allocating more and more heaps, and the visible
memory use grew very slowly while the disk was thrashing like mad.
Printing fewer results (i.e., keeping the heap burden under 4Mb) made
that illusion vanish.

Looks like there's no hope for plugging the LazyList leaks automatically
short of adding frameobjects and genobjects to gc.  OTOH, they're very
easy to break by hand, and they're the only *kind* of plausibly realistic
leaks I've been able to provoke.

Dilemma.
2001-06-27 07:17:57 +00:00
Martin v. Löwis ce9b5a55e1 Encode surrogates in UTF-8 even for a wide Py_UNICODE.
Implement sys.maxunicode.
Explicitly wrap around upper/lower computations for wide Py_UNICODE.
When decoding large characters with UTF-8, represent expected test
results using the \U notation.
2001-06-27 06:28:56 +00:00
Tim Peters e77f2e2798 gen_getattr: make the gi_running and gi_frame members discoverable (but
not writable -- too dangerous!) from Python code.
2001-06-26 22:24:51 +00:00
Barry Warsaw 41775385df Add a bunch of tests for extended dict.update() where the argument is
a non-dictionary mapping object.  Include tests for several expected
failure modes.
2001-06-26 20:09:28 +00:00
Tim Peters b6c3ceae79 SF bug #436207: "if 0: yield x" is ignored.
Not anymore <wink>.  Pure hack.  Doesn't fix any other "if 0:" glitches.
2001-06-26 03:36:28 +00:00
Tim Peters 3e7b1a04a0 Teach the types module about generators. Thanks to James Althoff on the
Iterators list for bringing it up!
2001-06-25 19:46:25 +00:00
Just van Rossum ae1f65ff82 Return self.trace_dispatch from dispatch_return() to enable stepping through generators. (An alternative would be to create a new "yield" debugger event, but that involves many more changes, and might break Bdb subclasses.) 2001-06-25 18:01:24 +00:00
Steven M. Gava d7b6ed268e Initial revision 2001-06-25 07:23:57 +00:00
Tim Peters 2106ef0222 Repair indentation in comment.
Add a temporary driver to help track down remaining leak(s).
2001-06-25 01:30:12 +00:00
Tim Peters fee69d0313 Changed some comments. Removed the caution about clearing globs, since
clearing a shallow copy _run_examples() makes itself can't hurt anything.
2001-06-24 20:24:16 +00:00
Tim Peters d4ad59e1eb Clear the copy of the globs dict after running examples. This helps to
break cycles, which are a special problem when running generator tests
that provoke exceptions by invoking the .next() method of a named
generator-iterator:  then the iterator is named in globs, and the
iterator's frame gets a tracekback object pointing back to globs, and
gc doesn't chase these types so the cycle leaks.

Also changed _run_examples() to make a copy of globs itself, so its
callers (direct and indirect) don't have to (and changed the callers
to stop making their own copies); *that* much is a change I've been
meaning to make for a long time (it's more robust the new way).

Here's a way to provoke the symptom without doctest; it leaks at a
prodigious rate; if the last two "source" lines are replaced with
    g().next()
the iterator isn't named and then there's no leak:

source = """\
def g():
    yield 1/0

k = g()
k.next()
"""

code = compile(source, "<source>", "exec")

def f(globs):
    try:
        exec code in globs
    except ZeroDivisionError:
        pass

while 1:
    f(globals().copy())

After this change, running test_generators in an infinite loop still leaks,
but reduced from a flood to a trickle.
2001-06-24 20:02:47 +00:00
Tim Peters 77f2d504c3 doctest systematically leaked memory when handling an exception in an
example (an obvious trackback cycle).  Repaired.
Bugfix candidate.
2001-06-24 18:59:01 +00:00
Tim Peters b2bc6a93df Added a "generate k-combinations of a list" example posted to c.l.py. 2001-06-24 10:14:27 +00:00
Tim Peters ea2e97a08a New tests to provoke SyntaxErrors unique to generators. Minor fiddling
of other tests.
2001-06-24 07:10:02 +00:00
Tim Peters 08bba953ea doctest doesn't handle intentional SyntaxError exceptions gracefully,
because it picks up the first line of traceback.format_exception_only()
instead of the last line.  Pick up the last line instead!
2001-06-24 06:46:58 +00:00
Tim Peters ee30927b45 Another variant of the 2-3-5 test, mixing generators with a LazyList class.
Good news:  Some of this stuff is pretty sophisticated (read nuts), and
I haven't bumped into a bug yet.
Bad news:  If I run the doctest in an infinite loop, memory is clearly
leaking.
2001-06-24 05:47:06 +00:00
Tim Peters b9e9ff1288 More tests. 2001-06-24 03:44:52 +00:00
Tim Peters 0f9da0acde Add a recursive Sieve of Eratosthenes prime generator. Not practical,
but it's a heck of a good generator exerciser (think about it <wink>).
2001-06-23 21:01:47 +00:00
Tim Peters 6ba5f79674 Add all the examples from PEP 255, and a few email examples. 2001-06-23 20:45:43 +00:00
Tim Peters 1def351b45 New std test for generators, initially populated with doctests NeilS put
together.
2001-06-23 20:27:04 +00:00
Fred Drake a2d848e99c Add sha and _sre to the list of allowed built-in modules. 2001-06-22 18:19:16 +00:00
Tim Peters d6d010b874 Teach the UNPACK_SEQUENCE opcode how to tease an iterable object into
giving up the goods.
NEEDS DOC CHANGES
2001-06-21 02:49:55 +00:00
Barry Warsaw 7599a3fc5a Add a bunch of sample strings to test soft line breaks of varying end
cases.
2001-06-19 22:48:42 +00:00
Barry Warsaw dac67ac8bf encode(): Fixed the handling of soft line breaks for lines over 76
characters in length.  Remember that when calculating the soft breaks,
the trailing `=' sign counts against the max length!
2001-06-19 22:48:10 +00:00
Jack Jansen 9020bcebc8 - _filename_to_abs() didn't cater for .. components in the pathname. Fixed.
- compile() didn't return a (empty) list of objects. Fixed.
- the various _fix_xxx_args() methods weren't called (are they new or did I overlook them?). Fixed.
2001-06-19 21:23:11 +00:00
Jack Jansen 97df7b61f2 The test used int(time.time()) to get a random number, but this doesn't work on the mac (where times are bigger than ints). Changed to int(time.time()%1000000). 2001-06-19 20:20:05 +00:00
Jack Jansen 1bdcadd610 An import MacOS was missing after the code-rearranging. Added. 2001-06-19 20:11:36 +00:00
Marc-André Lemburg a37171dd86 Test by Martin v. Loewis for the new UTF-16 codec handling of BOM
marks.
2001-06-19 20:09:28 +00:00
Marc-André Lemburg 92b550cdd8 This patch by Martin v. Loewis changes the UTF-16 codec to only
write a BOM at the start of the stream and also to only read it as
BOM at the start of a stream.

Subsequent reading/writing of BOMs will read/write the BOM as ZWNBSP
character. This is in sync with the Unicode specifications.

Note that UTF-16 files will now *have* to start with a BOM mark
in order to be readable by the codec.
2001-06-19 20:07:51 +00:00
Just van Rossum 92c5bdbc19 Fixed -D emulation for symbols with a value, as specified with the define_macros Extension argument. 2001-06-19 19:44:02 +00:00
Barry Warsaw 7069763913 A unittest-based test for the quopri module. 2001-06-19 19:08:13 +00:00
Barry Warsaw 9b630a5020 Better support for RFC 1521 quoted-printable specification, along with
addition of interface for consistency with base64 module.  Namely,

encodestring(), decodestring(): New functions which accept a string
object and return a string object.  They just wrap the string in
StringIOs and pass them to the encode() and decode() methods
respectively.  encodestring() accepts a default argument of quotetabs,
defaulting to zero, which is passed on straight through to encode().

encode(): Fix the bug where an extra newline would always be added to
the output, which prevented an idempotent roundtrip through
encode->decode.  Now, if the source string doesn't end in a newline,
then the result string won't end in a newline.

Also, extend the quotetabs argument semantics to include quoting
embedded strings, which is also optional according to the RFC.

test() -> main()

"from quopri import *" also imports encodestring() and decodestring().
2001-06-19 19:07:46 +00:00
Tim Peters 463766816c Updated keyword.py for "yield". 2001-06-19 00:26:25 +00:00
Tim Peters ff0a2bb523 Somebody checked this in w/ an ambiguous tab/space mix (reported by
Mark Favas).
2001-06-18 23:56:36 +00:00
Tim Peters 3eec38af37 Added "i" and "l" to the list of std-mode struct codes that don't range-
check correctly on pack().  While these were checking OK on my 32-bit box,
Mark Favas reported failures on a 64-bit box (alas, easy to believe).
2001-06-18 22:27:39 +00:00
Tim Peters 5ca576ed0a Merging the gen-branch into the main line, at Guido's direction. Yay!
Bugfix candidate in inspect.py:  it was referencing "self" outside of
a method.
2001-06-18 22:08:13 +00:00
Tim Peters 1dad6a86de SF bug 434186: 0x80000000/2 != 0x80000000>>1
i_divmod:  New and simpler algorithm.  Old one returned gibberish on most
boxes when the numerator was -sys.maxint-1.  Oddly enough, it worked in the
release (not debug) build on Windows, because the compiler optimized away
some tricky sign manipulations that were incorrect in this case.
Makes you wonder <wink> ...
Bugfix candidate.
2001-06-18 19:21:11 +00:00
Guido van Rossum 183a2f2437 Fix SF bug #433904 (Alex Martelli) - all s_* methods return None only. 2001-06-18 12:33:36 +00:00
Martin v. Löwis f3b30747d6 Patch #413171: Implement get, setdefault, update in terms of
has_key, __getitem__, and __setitem__.
2001-06-18 01:09:41 +00:00