Ka-Ping Yee [Fri, 2 Mar 2001 05:50:34 +0000 (05:50 +0000)]
Make getsourcefile() succeed even if the filename doesn't end in '.py' --
as long as the filename also doesn't end in a suffix that indicates
a binary file (according to the flags in imp.get_suffixes()).
Shrink try...except clauses and replace some of them with explicit checks.
Believe it or not, but "more" on Windows requires "more <file" rather
than "more file". Since tempfilepager() is only used on Windows, it
seems, do this unconditionally -- on Unix, it always invokes something
else.
Made sure that the warnings issued by symtable_check_unoptimized()
(about import * and exec) contain the proper filename and line number,
and are transformed into SyntaxError exceptions with -Werror.
Jeremy Hylton [Thu, 1 Mar 2001 22:59:14 +0000 (22:59 +0000)]
Useful future statement support for the interactive interpreter
(Also remove warning about module-level global decl, because we can't
distinguish from code passed to exec.)
Define PyCompilerFlags type contains a single element,
cf_nested_scopes, that is true if a nested scopes future statement has
been entered at the interactive prompt.
New API functions:
PyNode_CompileFlags()
PyRun_InteractiveOneFlags()
-- same as their non Flags counterparts except that the take an
optional PyCompilerFlags pointer
compile.c: In jcompile() use PyCompilerFlags argument. If
cf_nested_scopes is true, compile code with nested scopes. If it
is false, but the code has a valid future nested scopes statement,
set it to true.
pythonrun.c: Create a new PyCompilerFlags object in
PyRun_InteractiveLoop() and thread it through to
PyRun_InteractiveOneFlags().
Fred Drake [Thu, 1 Mar 2001 21:54:49 +0000 (21:54 +0000)]
Solaris defines VSWTCH instead of VSWTC; carefully make sure both are
defined and export both names.
Solaris also does not define CBAUDEX; it is not clear that CBAUDEXT
(which is defined there) is the same thing, so we only protect against
the lack of CBAUDEX.
Fred Drake [Thu, 1 Mar 2001 18:37:52 +0000 (18:37 +0000)]
Comment out section titles for sections that have not been written yet;
there is no need to clutter a reader's life with those useless things.
Suppress the "Contents" page for HTML; it is not needed for small documents
in the online environment since LaTeX2HTML generates lots of tables of links
anyway.
Fred Drake [Thu, 1 Mar 2001 18:35:43 +0000 (18:35 +0000)]
Comment out section titles for sections that have not been written yet;
there is no need to clutter a reader's life with those useless things.
Make the snippets of Python code conform to the standard style.
Suppress the "Contents" page for HTML; it is not needed for small documents
in the online environment since LaTeX2HTML generates lots of tables of links
anyway.
- In _portable_ftell(), try fgetpos() before ftello() and ftell64().
I ran into a situation on a 64-bit capable Linux where the C
library's ftello() and ftell64() returned negative numbers despite
fpos_t and off_t both being 64-bit types; fgetpos() did the right
thing.
- Define a new typedef, Py_off_t, which is either fpos_t or off_t,
depending on which one is 64 bits. This removes the need for a lot
of #ifdefs later on. (XXX Should this be moved to pyport.h? That
file currently seems oblivious to large fille support, so for now
I'll leave it here where it's needed.)
Tim Peters [Thu, 1 Mar 2001 18:12:00 +0000 (18:12 +0000)]
More MacOSX fiddling. As noted in a comment, I believe all variations
of these "search the directory" schemes (including this one) are still prone
to making mistakes.
Ka-Ping Yee [Thu, 1 Mar 2001 13:55:20 +0000 (13:55 +0000)]
Docstring improvements.
Add checks for .pyo and .pyd.
Collapse docfunction, docmethod, docbuiltin into the one method docroutine.
Small formatting fixes.
Link the segments of a package path in the title.
Link to the source file only if it exists.
Allow modules (e.g. repr.py) to take precedence over built-ins (e.g. repr()).
Add interruptible synopsis scanner (so we can do searches in the background).
Make HTTP server quit.
Add small GUI for controlling the server and launching searches (like -k).
(Tested on Win2k, Win98, and Linux.)
Moshe Zadka [Thu, 1 Mar 2001 08:40:42 +0000 (08:40 +0000)]
Checking in patch 404826 -- urllib2 enhancements and documentations.
(please not that the library reference does *not* include the
urllib2 documnetation -- that will wiat for Fred)
Fred Drake [Thu, 1 Mar 2001 06:33:32 +0000 (06:33 +0000)]
Suppress a compiler warning under OpenVMS; time_t is unsigned on (at least)
the more recent versions of that platform, so we use the value (time_t)(-1)
as the error value. This is the type used in the OpenVMS documentation:
Tim Peters [Thu, 1 Mar 2001 01:30:56 +0000 (01:30 +0000)]
In Steven's apparent absence, check in *something* with a non-zero chance
of making new-fangled Mac imports work again. May not work, and may not
even compile on his boxes, but should be at worst very close on both.
to remove all .py[co] files before testing, rather than just those in
the Lib/test directory. "find" is used all over the Makefile so I
suppose it's safe; how about xargs?
Ka-Ping Yee [Thu, 1 Mar 2001 00:24:32 +0000 (00:24 +0000)]
Normalize case of paths in sys.path to avoid duplicates on Windows.
Handle <... at 001B6378> like <... at 0x120f80> (%p is platform-dependent).
Fix RCS version tag handling.
Move __main__ behaviour into a function, pydoc.cli().
Jeremy Hylton [Wed, 28 Feb 2001 22:54:51 +0000 (22:54 +0000)]
Add warning/error handlin for problematic nested scopes cases as
described in PEP 227.
symtable_check_unoptimized() warns about import * and exec with "in"
when it is used in a function that contains a nested function with
free variables. Warnings are issued unless nested scopes are in
effect, in which case these are SyntaxErrors.
symtable_check_shadow() warns about assignments in a function scope
that shadow free variables defined in a nested scope. This will
always generate a warning -- and will behave differently with nested
scopes than without.
Restore full checking for free vars in children, even when nested
scopes are not enabled. This is needed to support warnings for
shadowing.
Change symtable_warn() to return an int-- the return value of
PyErr_WarnExplicit.
Sundry cleanup: Remove commented out code. Break long lines.
Guido van Rossum [Wed, 28 Feb 2001 21:55:38 +0000 (21:55 +0000)]
Use the new PyErr_WarnExplicit() API to issue better warnings for
global after assign / use.
Note: I'm not updating the PyErr_Warn() call for import * / exec
combined with a function, because I can't trigger it with an example.
Jeremy, just follow the example of the call to PyErr_WarnExplicit()
that I *did* include.
Fred Drake [Wed, 28 Feb 2001 21:52:10 +0000 (21:52 +0000)]
SyntaxError__init__(): Be a little more robust when picking apart the
location information for the SyntaxError -- do not do more than we
need to, stopping as soon as an exception has been raised.
Fred Drake [Wed, 28 Feb 2001 21:46:37 +0000 (21:46 +0000)]
Move some constant initialization from FTP.__init__() and FTP.connect()
to the class namespace.
Allow FTP.close() to be called more than once without tossing cookies.
(This seems to be a fairly common idiom for .close() methods, so let's
try to be consistent.)
Fred Drake [Wed, 28 Feb 2001 20:58:04 +0000 (20:58 +0000)]
Now that Jeremy is asking about this code, it looks really bogus to me,
so let's rip it out. The constructor for SyntaxError does the right
thing, so we do not need to do it again.
Add script form of pydoc so that it's present in beta1. Currently
this just copies the __name__=='__main__' logic from pydoc.py.
?!ng can decide whether he wants to create a main() in pydoc, or rip
it out of pydoc.py completely.
Fred Drake [Wed, 28 Feb 2001 17:56:26 +0000 (17:56 +0000)]
Define lots of constants for indexes into the structures for the file
header and central directory structures, and use them as appropriate.
The point being to make it easier to tell what is getting pulled out
where; magic numbers are evil!
Change the computation of the ZipInfo.file_offset field to use the
length of the relevant "extra" field -- there are two different ones,
and the wrong one had been used. ;-(
This closes SF tracker patch #403276, but more verbosely than the
proposed patch.