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.
Jack Jansen [Wed, 28 Feb 2001 11:23:04 +0000 (11:23 +0000)]
If we can't find our splash dialog (i.e. we're probably running from source) go into interactive mode: print what we're doing and ask about carbon/classic configure.
Jeremy Hylton [Wed, 28 Feb 2001 07:07:43 +0000 (07:07 +0000)]
Print the offending line of code in the traceback for SyntaxErrors
raised by the compiler.
XXX For now, text entered into the interactive intepreter is not
printed in the traceback.
Inspired by a patch from Roman Sulzhyk
compile.c:
Add helper fetch_program_text() that opens a file and reads until it
finds the specified line number. The code is a near duplicate of
similar code in traceback.c.
Modify com_error() to pass two arguments to SyntaxError constructor,
where the second argument contains the offending text when possible.
Modify set_error_location(), now used only by the symtable pass, to
set the text attribute on existing exceptions.
pythonrun.c:
Change parse_syntax_error() to continue of the offset attribute of a
SyntaxError is None. In this case, it sets offset to -1.
Move code from PyErr_PrintEx() into helper function
print_error_text(). In the helper, only print the caret for a
SyntaxError if offset > 0.
Tim Peters [Wed, 28 Feb 2001 05:34:27 +0000 (05:34 +0000)]
Implement PEP 235: Import on Case-Insensitive Platforms.
http://python.sourceforge.net/peps/pep-0235.html
Renamed check_case to case_ok. Substantial code rearrangement to get
this stuff in one place in the file. Innermost loop of find_module()
now much simpler and #ifdef-free, and I want to keep it that way (it's
bad enough that the innermost loop is itself still in an #ifdef!).
Windows semantics tested and are fine.
Jason, Cygwin *should* be fine if and only if what you did before "worked"
for case_ok.
Jack, the semantics on your flavor of Mac have definitely changed (see
the PEP), and need to be tested. The intent is that your flavor of Mac
now work the same as everything else in the "lower left" box, including
respecting PYTHONCASEOK.
Steven, sorry, you did the most work here so far but you got screwed the
worst. Happy to work with you on repairing it, but I don't understand
anything about all your Mac variants. We need to add another branch (or
two, three, ...?) inside case_ok. But we should not need to change
anything else.