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
sure it's imported! ;)
Re-wrap the docstrings on get_python_inc() and get_python_lib() to be
closer to the "normal" Python style. See GvR's "style guide" on the
essays page (http://www.python.org/doc/essays/).
There should never be a space between a function name and the '(' that
opens the argument list (see the style guide again).
the platform-neutral include dir by default and with Mac support.
Added 'get_python_lib()', inspired by 'get_python_inc()'.
Rewrote 'get_config_h_filename()' and 'get_makefile_filename()'
in terms of 'get_python_inc()' and 'get_python_lib()'.
Changed '_init_nt()' and '_init_mac()' to use 'get_python_inc()' and
'get_python_lib()' for directory names.
When you set a breakpoint on a function with a multi-line argument
list, the breakpoint is actually set on the second line of the
arguments instead of the first line of the body. This patch fixes
that.
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
implement it (so far):
* moved filename generation methods into CCompiler base class,
driven by data supplied by implementation classes
* moved a bunch of common code from UnixCCompiler to convenience
methods in CCompiler
* overhauled MSVCCompiler's compile/link methods to look and act
as much as possible like UnixCCompiler's, in order to regularize
both interface and behaviour (especially by using those new
convenience methods)
* replaced build_lib.py with build_clib.py
* renamed the class in build_clib.py
* changed all references to 'build_lib' command in other command classes
when building extensions (uses build_lib's 'get_library_names()' method).
Ensure that the relative structure of source filenames is preserved in
the temporary build tree, eg. foo/bar.c compiles to
build/temp.<plat>/foo/bar.o.
Added 'build_clib' and 'build_temp' options (where to put C libraries
and where to put temporary compiler by-products, ie. object files).
Moved the call to 'check_library_list()' from 'run()' to 'finalize_options()'
-- that way, if we're going to crash we do so earlier, and we guarantee
that the library list is valid before we do anything (not just run).
Disallow directory separators in library names -- the compiled library
always goes right in 'build_clib'.
Added 'get_library_names()', so the "build_ext" command knows what
libraries to link every extension with.
filenames when constructing object filenames, even if output_dir given --
eg. "foo/bar.c" will compile to "foo/bar.o" without an output_dir, and to
"temp/foo/bar.o" if output_dir is "temp".
* 'build_dir' -> 'build_lib', which by default takes its value
straight from 'build_lib' in the 'build' command
* added 'build_temp' and 'inplace' options
* change 'build_extensions()' to put object files (compiler turds) in
'build_temp' dir
* complicated the name-of-extension-file shenanigans in
'build_extensions()' to support "in-place" extension building, i.e.
put the extension right into the source tree (handy for developers)
* added 'get_ext_fullname()', renamed 'extension_filename()' to
'get_ext_filename()', and tweaked the latter a bit -- all to support
the new filename shenanigans
This patch is re: Lucas.Dejonge@awtpl.com.au: [Python-bugs-list] imaplib -
not complying with RFC (PR#218)
Lucas de Jonge reported that the code in imaplib that detects a read-write
to read-only change doesn't comply with RFC 2060.
discussed on c.l.py last January. Specifically:
- more characters allowed in section & option names
- if '=' is used to separate the option & value, the value can be
followed by a comment of the form '\s;'
OptionMenu is modified. Somewhat rewritten and elaborated by myself.
class _setit: The constructor now takes an optional argument
`callback' and stashes this in a private variable. If set, the
__call__() method will invoke this callback after the variable's value
has changed. It will pass the callback the value, followed by any
args passed to __call__().
class OptionMenu: The constructor now takes keyword arguments, the
only one that's legally recognized is `command', which can be set to a
callback. This callback is invoked when the OptionMenu value is set.
Any other keyword argument throws a TclError.
A change in my last patch could, under certain circumstances,
cause a loop if the connection to the server dropped while
waiting for a command completion. I've changed the code to
re-raise the error after possible debugging output.
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.
add clsFilesystemImporter class attribute, alter handling of suffix list
convert suffix importers to funcs rather than instances
remove backwards compat code: Importer.install and 2-tuple get_code()
result values
switch to isinstance() rather than direct type comparisons
removing chaining concept
update ImportManager.install() to take an optional namespace to install
itself in. this will be useful for setting up rexec environments.
minor comment nits
old 'dist' command, but the code for dealing with manifests is completely
redone -- and renaming the command to 'sdist' is more symmetric with the
soon-to-exist 'bdist' command.
- 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 ...
Reasons for patches:
1st patch (15,21):
version change
2nd patch (66,72):
This is a patch I found in a Zope product release (quite by accident!).
It relaxes the conditions for matching a literal. I've looked over the
logic, and tested it, and it seems sensible.
3rd patch (117,123):
It appears the quoting matcher was too general, and that the IMAP4
protocol requires characters like ':' in commands to be unquoted.
(This is the patch already sent to Guido.)
4th patch (699,705):
Spelling correction in comment.
5th patch (753,761):
Another patch from the Zope product. It seems that some IMAP4 servers
produce unexpected responses in the middle of valid command/response
sequences. This patch ignores the unexpected responses in this
situation. (How I wish users would send me bug reports with examples!).
last 2 patches: (1015,1028) (1038,1044):
Minor improvements to test code.
- added a number of support methods to generate code just before the
body
- hack protocol for communicating number of args to PyAssembler
fix TryExcept generation for case where exception handler has no body
fix visitAssAttr
add comment about incomplete visitAssName
stop using the ExampleASTVisitor
change script invocation to accept a list of .py files (e.g. Lib/*.py)
named OPTIMIZED, which matches compile.c and makes more sense for
classes
revamp call signature for PythonVMCode.__init__; doesn't really matter
'cuz this code is going to be refactored out of existence
add generateClassCode and modify Func & Lambda generation
add support for nodes Classdef, Keyword,
fix CallFunc to generate right op arg when calling w/ keywords
add ugly hack to properly compute offsets when the same stack ref is
used multiple times
change resolution of local name ops (LOAD_FAST). i think it makes
sense now. if it is an argument or a local var name that it used, it
must be in varnames. if it is a local var name that is used, it must
also be in names
'get_msvc_paths()'.
Renamed '_do_SET()' to 'set_path_env_var()', tweaked docstring, and
cosmetically tweaked code.
Stylistic changes to MSVCCompiler constructor (variable renaming
and type consistency).
* tweak my docstrings
* fix None returns to empty list
* reshuffle responsibilities between '_find_exe()', '_find_SET()', and
the MSVCCompiler constructor -- now the constructor worries about
fetching the version list and determining the most recent one
* added "/W3" compile option
Also, I added/tweaked some docstrings.
NNTPError - derived from Exception, it's the base class for all
other exceptions in this module
NNTPReplyError - what used to be error_reply
NNTPTemporaryError - what used to be error_temp
NNTPPermanentError - what used to be error_perm
NNTPProtocolError - what used to be error_proto
NNTPDataError - what used to be error_data
All the old names are retained for backwards compatibility; they point
to the class that replaces them. Also, any code in this module that
raises an exception, now does so with the exception class.
NNTP.__init__(): Added a new optional argument `readermode', which is
a flag that defaults to false. When set to true, the "mode reader"
command is sent to the NNTP server before user authentication. Reader
mode is sometimes necessary if you are connecting to an NNTP server on
the local machine and intend to call reader-specific comamnds, such as
`group'. If you get unexpected NNTPPermanentErrors, you might need to
set readermode. Patch provided by Thomas Wouters (who include the
standard disclaimer on is patches@python.org submission), and inspired
by Jim Tittsler.
FUNCTION_NAMESPACE. initialize in __init__ and reset in
generateFunctionCode.
replace direct issue of STORE_FAST, STORE_GLOBAL, etc. with call to
storeName; same for loadName and deleteName
the new {store,load,delete}Name methods use the namespace attr and the
local variable stack to determine the correct bytecode to issue
* don't need to mention python<ver>.lib -- it's done by a pragma
* add debug flags for compile and link, and use them
* fix 'link_shared_library()' to pass everything to 'link_shared_object()'
* change filename when shared object with debug info (ugh)
* prints out examples of nodes that are handled by visitor. simply a
development convenience
remove NestedCodeGenerator -- it was bogus after all
replace with generateFunctionCode, a method to call to generate code
for a function instead of a top-level module
fix impl of visitDiscard (most pop stack)
emit lineno for pass
handle the following new node types: Import, From, Getattr, Subscript,
Slice, AssAttr, AssTuple, Mod, Not, And, Or, List
LocalNameFinder: remove names declared as globals for locals
PythonVMCode: pass arg names to constructor, force varnames to contain
them all (even if they aren't referenced)
add -q option on command line to disable stdout
someone who knows Windows/MSVC++ to come along and add the right flags.
Comment noting that 'link_static_lib()' signature is inconsistent with
the other compiler classes (uh-oh!)
VERBOSE setting for the ASTVisitor
add getopt handling for one or more -v args
rename ForwardRef to StackRef, because it isn't necessarily directional
CodeGenerator:
* add assertStackEmpty method. prints warning if stack is not empty
when it should be
* define methods for AssName, UNARY_*, For
PythonVMCode:
* fix mix up between hasjrel and hasjabs for address calculation
language.
CodeGenerator:
* modify to track stack depth
* add emit method that call's PythonVMCode's makeCodeObject
* thread filenames through in hackish way
* set flags for code objects for modules and functions
XXX the docs for the flags seem out of date and/or incomplete
PythonVMCode:
* add doc string describing the elements of a real code object
LineAddrTable:
* creates an lnotab (no quite correctly though)
handle most of the language syntax yet)
create NestedCodeGenerator used to generator the separate code object
that needs to be passed as an argument to MAKE_FUNCTION when a def
stmt is found (probably useful for class too)
change CodeGenerator.visitFunction to use the NestedCG
add CompiledModule class to handle creation of .pyc (pretty minimal
for now)
add makeCodeObject method to PythonVMCode that replaces symbolic names
with indexes into slots of the code code. the design of this
class will probably need to be revised.
*this* set of patches is Ka-Ping's final sweep:
The attached patches update the standard library so that all modules
have docstrings beginning with one-line summaries.
A new docstring was added to formatter. The docstring for os.py
was updated to mention nt, os2, ce in addition to posix, dos, mac.
The attached patches update the standard library so that all modules
have docstrings beginning with one-line summaries.
A new docstring was added to formatter. The docstring for os.py
was updated to mention nt, os2, ce in addition to posix, dos, mac.
who writes:
Here is batch 2, as a big collection of CVS context diffs.
Along with moving comments into docstrings, i've added a
couple of missing docstrings and attempted to make sure more
module docstrings begin with a one-line summary.
I did not add docstrings to the methods in profile.py for
fear of upsetting any careful optimizations there, though
i did move class documentation into class docstrings.
The convention i'm using is to leave credits/version/copyright
type of stuff in # comments, and move the rest of the descriptive
stuff about module usage into module docstrings. Hope this is
okay.
compile.py: ASTVisitor framework plus bits of a code generator that
should be bug-for-buf compatible with compile.c
misc.py: Set and Stack helpers
test.py: a bit of simple sample code that compile.py will work on
# combo of old cmp, cmpcache and dircmp with redundancies removed
#
# bugs fixed:
# dircmp.dircmp was not ignoring IGNORES
# old stuff could falsely report files as "identical" when contents actually differed
#
# enhancements:
# dircmp has a more straightforward interface
#cmp enhanced by Moshe Zadca
#dircmp enhanced byGordon McMillan
[some layout changes by GvR]
1. Comments at the beginning of the module, before
functions, and before classes have been turned
into docstrings.
2. Tabs are normalized to four spaces.
Also, removed the "remove" function from dircmp.py, which reimplements
list.remove() (it must have been very old).
Fixed a TypeError: not enough arguments; expected 4, got 3.
When authentication is needed, the default http_error_401 method calls
retry_http_basic_auth. The default version of that method expected a
data argument which wasn't provided, so now we provide the argument if
it was given and we also made the data argument optional.
Also changed other calls where data was optional to not pass data if
it was not passed to the calling method (in line with other similar
occurances).
'--help-commands' option).
Shuffled imports around in a few command modules to avoid expensive
up-front import of sysconfig (and resulting delays in generating list
of all commands).
* "--help" can now come either before or after particular commands
to get help on and can give help on multiple commands, eg.
"--help install dist" gives help on those two commands
* added "--help-commands" option, implemented by the 'print_commands()'
and 'print_command_list()' methods
Added 'link_static_lib()' method, and 'archiver' and 'archiver_options'
class attributes to support it.
Added 'link_executable()' method, and 'ld_exec' instance attribute
to support it.
'newer_group()' is now able to handle missing files, so we don't have
to kludge it by catching OSError when calling it.
'object_filenames()' and 'shared_object_filename()' now take 'keep_dir'
flag parameters.
'library_filename()' and 'shared_library_filename()' now respect
a directory component in the library name.
Various comment updates/deletions.
This patch changes the string-based exceptions to class-based
exceptions, so that you can fetch the unknown option as an
attribute. As far as I know, it is backward compatible.
[The new exception class is called GetoptError; the name error is an
alias for compatibility.]
I've changed the login command to force proper
quoting of the password argument. I've also added
some extra debugging code, which is removed when
__debug__ is false.