Import Upstream version 2.7.18
This commit is contained in:
43
Misc/BeOS-NOTES
Normal file
43
Misc/BeOS-NOTES
Normal file
@@ -0,0 +1,43 @@
|
||||
Python for BeOS R5
|
||||
|
||||
In Python-2.1, the standard version of the new setup.py program
|
||||
will not build the full complement of modules on BeOS. Instead,
|
||||
please replace it with the special BeOS version in Misc/BeOS-setup.py.
|
||||
|
||||
To build,
|
||||
|
||||
1) cp Misc/BeOS-setup.py setup.py
|
||||
2) ./configure --prefix=/boot/home/config
|
||||
3) make
|
||||
|
||||
The modules will all build, except termios which assumes some flags
|
||||
we don't have. Put a libreadline.a in /boot/home/config/lib to get
|
||||
a readline.so for your interactive editing convenience; NB, not
|
||||
libreadline.so, you want to link a static readline library into the
|
||||
dynamically loaded Python module.
|
||||
|
||||
Test:
|
||||
|
||||
make test
|
||||
|
||||
The BeOS is Not UNIX category:
|
||||
- test_select crashed -- select.error : (-2147459072, 'Bad file descriptor')
|
||||
- test_socket crashed -- exceptions.AttributeError : SOCK_RAW
|
||||
- test_fcntl crashed -- exceptions.IOError: [Errno -2147483643] Invalid argument
|
||||
|
||||
This one is funny! BeOS does support large files, and that's why
|
||||
we get this error: the file is too big for my filesystem!
|
||||
- test_largefile crashed -- exceptions.IOError: [Errno -2147459065]
|
||||
No space left on device
|
||||
|
||||
- test_pickle crashed. This is apparently a serious problem, "complex"
|
||||
number objects reconstructed from a pickle don't compare equal to
|
||||
their ancestors. But it happens on BeOS PPC only, not Intel.
|
||||
|
||||
Install:
|
||||
|
||||
make install
|
||||
|
||||
|
||||
Maintainer: None (please volunteer if you would like to see this port continue
|
||||
to exist!)
|
||||
574
Misc/BeOS-setup.py
Normal file
574
Misc/BeOS-setup.py
Normal file
@@ -0,0 +1,574 @@
|
||||
# Autodetecting setup.py script for building the Python extensions
|
||||
#
|
||||
# Modified for BeOS build. Donn Cave, March 27 2001.
|
||||
|
||||
__version__ = "special BeOS after 1.37"
|
||||
|
||||
import sys, os
|
||||
from distutils import sysconfig
|
||||
from distutils import text_file
|
||||
from distutils.errors import *
|
||||
from distutils.core import Extension, setup
|
||||
from distutils.command.build_ext import build_ext
|
||||
|
||||
# This global variable is used to hold the list of modules to be disabled.
|
||||
disabled_module_list = ['dbm', 'mmap', 'resource', 'nis']
|
||||
|
||||
def find_file(filename, std_dirs, paths):
|
||||
"""Searches for the directory where a given file is located,
|
||||
and returns a possibly-empty list of additional directories, or None
|
||||
if the file couldn't be found at all.
|
||||
|
||||
'filename' is the name of a file, such as readline.h or libcrypto.a.
|
||||
'std_dirs' is the list of standard system directories; if the
|
||||
file is found in one of them, no additional directives are needed.
|
||||
'paths' is a list of additional locations to check; if the file is
|
||||
found in one of them, the resulting list will contain the directory.
|
||||
"""
|
||||
|
||||
# Check the standard locations
|
||||
for dir in std_dirs:
|
||||
f = os.path.join(dir, filename)
|
||||
if os.path.exists(f): return []
|
||||
|
||||
# Check the additional directories
|
||||
for dir in paths:
|
||||
f = os.path.join(dir, filename)
|
||||
if os.path.exists(f):
|
||||
return [dir]
|
||||
|
||||
# Not found anywhere
|
||||
return None
|
||||
|
||||
def find_library_file(compiler, libname, std_dirs, paths):
|
||||
filename = compiler.library_filename(libname, lib_type='shared')
|
||||
result = find_file(filename, std_dirs, paths)
|
||||
if result is not None: return result
|
||||
|
||||
filename = compiler.library_filename(libname, lib_type='static')
|
||||
result = find_file(filename, std_dirs, paths)
|
||||
return result
|
||||
|
||||
def module_enabled(extlist, modname):
|
||||
"""Returns whether the module 'modname' is present in the list
|
||||
of extensions 'extlist'."""
|
||||
extlist = [ext for ext in extlist if ext.name == modname]
|
||||
return len(extlist)
|
||||
|
||||
class PyBuildExt(build_ext):
|
||||
|
||||
def build_extensions(self):
|
||||
|
||||
# Detect which modules should be compiled
|
||||
self.detect_modules()
|
||||
|
||||
# Remove modules that are present on the disabled list
|
||||
self.extensions = [ext for ext in self.extensions
|
||||
if ext.name not in disabled_module_list]
|
||||
|
||||
# Fix up the autodetected modules, prefixing all the source files
|
||||
# with Modules/ and adding Python's include directory to the path.
|
||||
(srcdir,) = sysconfig.get_config_vars('srcdir')
|
||||
|
||||
# Figure out the location of the source code for extension modules
|
||||
moddir = os.path.join(os.getcwd(), srcdir, 'Modules')
|
||||
moddir = os.path.normpath(moddir)
|
||||
srcdir, tail = os.path.split(moddir)
|
||||
srcdir = os.path.normpath(srcdir)
|
||||
moddir = os.path.normpath(moddir)
|
||||
|
||||
# Fix up the paths for scripts, too
|
||||
self.distribution.scripts = [os.path.join(srcdir, filename)
|
||||
for filename in self.distribution.scripts]
|
||||
|
||||
for ext in self.extensions[:]:
|
||||
ext.sources = [ os.path.join(moddir, filename)
|
||||
for filename in ext.sources ]
|
||||
ext.include_dirs.append( '.' ) # to get config.h
|
||||
ext.include_dirs.append( os.path.join(srcdir, './Include') )
|
||||
|
||||
# If a module has already been built statically,
|
||||
# don't build it here
|
||||
if ext.name in sys.builtin_module_names:
|
||||
self.extensions.remove(ext)
|
||||
|
||||
# Parse Modules/Setup to figure out which modules are turned
|
||||
# on in the file.
|
||||
input = text_file.TextFile('Modules/Setup', join_lines=1)
|
||||
remove_modules = []
|
||||
while 1:
|
||||
line = input.readline()
|
||||
if not line: break
|
||||
line = line.split()
|
||||
remove_modules.append( line[0] )
|
||||
input.close()
|
||||
|
||||
for ext in self.extensions[:]:
|
||||
if ext.name in remove_modules:
|
||||
self.extensions.remove(ext)
|
||||
|
||||
# When you run "make CC=altcc" or something similar, you really want
|
||||
# those environment variables passed into the setup.py phase. Here's
|
||||
# a small set of useful ones.
|
||||
compiler = os.environ.get('CC')
|
||||
linker_so = os.environ.get('LDSHARED')
|
||||
args = {}
|
||||
# unfortunately, distutils doesn't let us provide separate C and C++
|
||||
# compilers
|
||||
if compiler is not None:
|
||||
args['compiler_so'] = compiler
|
||||
if linker_so is not None:
|
||||
args['linker_so'] = linker_so + ' -shared'
|
||||
self.compiler.set_executables(**args)
|
||||
|
||||
build_ext.build_extensions(self)
|
||||
|
||||
def build_extension(self, ext):
|
||||
|
||||
try:
|
||||
build_ext.build_extension(self, ext)
|
||||
except (CCompilerError, DistutilsError), why:
|
||||
self.announce('WARNING: building of extension "%s" failed: %s' %
|
||||
(ext.name, sys.exc_info()[1]))
|
||||
|
||||
def get_platform (self):
|
||||
# Get value of sys.platform
|
||||
platform = sys.platform
|
||||
if platform[:6] =='cygwin':
|
||||
platform = 'cygwin'
|
||||
elif platform[:4] =='beos':
|
||||
platform = 'beos'
|
||||
|
||||
return platform
|
||||
|
||||
def detect_modules(self):
|
||||
try:
|
||||
belibs = os.environ['BELIBRARIES'].split(';')
|
||||
except KeyError:
|
||||
belibs = ['/boot/beos/system/lib']
|
||||
belibs.append('/boot/home/config/lib')
|
||||
self.compiler.library_dirs.append('/boot/home/config/lib')
|
||||
try:
|
||||
beincl = os.environ['BEINCLUDES'].split(';')
|
||||
except KeyError:
|
||||
beincl = []
|
||||
beincl.append('/boot/home/config/include')
|
||||
self.compiler.include_dirs.append('/boot/home/config/include')
|
||||
# lib_dirs and inc_dirs are used to search for files;
|
||||
# if a file is found in one of those directories, it can
|
||||
# be assumed that no additional -I,-L directives are needed.
|
||||
lib_dirs = belibs
|
||||
inc_dirs = beincl
|
||||
exts = []
|
||||
|
||||
platform = self.get_platform()
|
||||
|
||||
# Check for MacOS X, which doesn't need libm.a at all
|
||||
math_libs = ['m']
|
||||
if platform in ['Darwin1.2', 'beos']:
|
||||
math_libs = []
|
||||
|
||||
# XXX Omitted modules: gl, pure, dl, SGI-specific modules
|
||||
|
||||
#
|
||||
# The following modules are all pretty straightforward, and compile
|
||||
# on pretty much any POSIXish platform.
|
||||
#
|
||||
|
||||
# Some modules that are normally always on:
|
||||
exts.append( Extension('_weakref', ['_weakref.c']) )
|
||||
exts.append( Extension('_symtable', ['symtablemodule.c']) )
|
||||
|
||||
# array objects
|
||||
exts.append( Extension('array', ['arraymodule.c']) )
|
||||
# complex math library functions
|
||||
exts.append( Extension('cmath', ['cmathmodule.c'],
|
||||
libraries=math_libs) )
|
||||
|
||||
# math library functions, e.g. sin()
|
||||
exts.append( Extension('math', ['mathmodule.c'],
|
||||
libraries=math_libs) )
|
||||
# fast string operations implemented in C
|
||||
exts.append( Extension('strop', ['stropmodule.c']) )
|
||||
# time operations and variables
|
||||
exts.append( Extension('time', ['timemodule.c'],
|
||||
libraries=math_libs) )
|
||||
# operator.add() and similar goodies
|
||||
exts.append( Extension('operator', ['operator.c']) )
|
||||
# access to the built-in codecs and codec registry
|
||||
exts.append( Extension('_codecs', ['_codecsmodule.c']) )
|
||||
# Python C API test module
|
||||
exts.append( Extension('_testcapi', ['_testcapimodule.c']) )
|
||||
# static Unicode character database
|
||||
exts.append( Extension('unicodedata', ['unicodedata.c']) )
|
||||
# access to ISO C locale support
|
||||
exts.append( Extension('_locale', ['_localemodule.c']) )
|
||||
|
||||
# Modules with some UNIX dependencies -- on by default:
|
||||
# (If you have a really backward UNIX, select and socket may not be
|
||||
# supported...)
|
||||
|
||||
# fcntl(2) and ioctl(2)
|
||||
exts.append( Extension('fcntl', ['fcntlmodule.c']) )
|
||||
# pwd(3)
|
||||
exts.append( Extension('pwd', ['pwdmodule.c']) )
|
||||
# grp(3)
|
||||
exts.append( Extension('grp', ['grpmodule.c']) )
|
||||
# posix (UNIX) errno values
|
||||
exts.append( Extension('errno', ['errnomodule.c']) )
|
||||
# select(2); not on ancient System V
|
||||
exts.append( Extension('select', ['selectmodule.c']) )
|
||||
|
||||
# The md5 module implements the RSA Data Security, Inc. MD5
|
||||
# Message-Digest Algorithm, described in RFC 1321. The necessary files
|
||||
# md5c.c and md5.h are included here.
|
||||
exts.append( Extension('md5', ['md5module.c', 'md5c.c']) )
|
||||
|
||||
# The sha module implements the SHA checksum algorithm.
|
||||
# (NIST's Secure Hash Algorithm.)
|
||||
exts.append( Extension('sha', ['shamodule.c']) )
|
||||
|
||||
# Helper module for various ascii-encoders
|
||||
exts.append( Extension('binascii', ['binascii.c']) )
|
||||
|
||||
# Fred Drake's interface to the Python parser
|
||||
exts.append( Extension('parser', ['parsermodule.c']) )
|
||||
|
||||
# cStringIO and cPickle
|
||||
exts.append( Extension('cStringIO', ['cStringIO.c']) )
|
||||
exts.append( Extension('cPickle', ['cPickle.c']) )
|
||||
|
||||
# Memory-mapped files (also works on Win32).
|
||||
exts.append( Extension('mmap', ['mmapmodule.c']) )
|
||||
|
||||
# Lance Ellinghaus's syslog daemon interface
|
||||
exts.append( Extension('syslog', ['syslogmodule.c']) )
|
||||
|
||||
# George Neville-Neil's timing module:
|
||||
exts.append( Extension('timing', ['timingmodule.c']) )
|
||||
|
||||
#
|
||||
# Here ends the simple stuff. From here on, modules need certain
|
||||
# libraries, are platform-specific, or present other surprises.
|
||||
#
|
||||
|
||||
# Multimedia modules
|
||||
# These don't work for 64-bit platforms!!!
|
||||
# These represent audio samples or images as strings:
|
||||
|
||||
# Disabled on 64-bit platforms
|
||||
if sys.maxint != 9223372036854775807L:
|
||||
# Operations on audio samples
|
||||
exts.append( Extension('audioop', ['audioop.c']) )
|
||||
# Operations on images
|
||||
exts.append( Extension('imageop', ['imageop.c']) )
|
||||
# Read SGI RGB image files (but coded portably)
|
||||
exts.append( Extension('rgbimg', ['rgbimgmodule.c']) )
|
||||
|
||||
# readline
|
||||
if self.compiler.find_library_file(lib_dirs, 'readline'):
|
||||
readline_libs = ['readline']
|
||||
if self.compiler.find_library_file(lib_dirs +
|
||||
['/usr/lib/termcap'],
|
||||
'termcap'):
|
||||
readline_libs.append('termcap')
|
||||
exts.append( Extension('readline', ['readline.c'],
|
||||
library_dirs=['/usr/lib/termcap'],
|
||||
libraries=readline_libs) )
|
||||
|
||||
# The crypt module is now disabled by default because it breaks builds
|
||||
# on many systems (where -lcrypt is needed), e.g. Linux (I believe).
|
||||
|
||||
if self.compiler.find_library_file(lib_dirs, 'crypt'):
|
||||
libs = ['crypt']
|
||||
else:
|
||||
libs = []
|
||||
exts.append( Extension('crypt', ['cryptmodule.c'], libraries=libs) )
|
||||
|
||||
# socket(2)
|
||||
# Detect SSL support for the socket module
|
||||
ssl_incs = find_file('openssl/ssl.h', inc_dirs,
|
||||
['/usr/local/ssl/include',
|
||||
'/usr/contrib/ssl/include/'
|
||||
]
|
||||
)
|
||||
ssl_libs = find_library_file(self.compiler, 'ssl',lib_dirs,
|
||||
['/usr/local/ssl/lib',
|
||||
'/usr/contrib/ssl/lib/'
|
||||
] )
|
||||
|
||||
if (ssl_incs is not None and
|
||||
ssl_libs is not None):
|
||||
exts.append( Extension('_socket', ['socketmodule.c'],
|
||||
include_dirs = ssl_incs,
|
||||
library_dirs = ssl_libs,
|
||||
libraries = ['ssl', 'crypto'],
|
||||
define_macros = [('USE_SSL',1)] ) )
|
||||
else:
|
||||
exts.append( Extension('_socket', ['socketmodule.c']) )
|
||||
|
||||
# Modules that provide persistent dictionary-like semantics. You will
|
||||
# probably want to arrange for at least one of them to be available on
|
||||
# your machine, though none are defined by default because of library
|
||||
# dependencies. The Python module anydbm.py provides an
|
||||
# implementation independent wrapper for these; dumbdbm.py provides
|
||||
# similar functionality (but slower of course) implemented in Python.
|
||||
|
||||
# The standard Unix dbm module:
|
||||
if platform not in ['cygwin']:
|
||||
if (self.compiler.find_library_file(lib_dirs, 'ndbm')):
|
||||
exts.append( Extension('dbm', ['dbmmodule.c'],
|
||||
libraries = ['ndbm'] ) )
|
||||
else:
|
||||
exts.append( Extension('dbm', ['dbmmodule.c']) )
|
||||
|
||||
# Anthony Baxter's gdbm module. GNU dbm(3) will require -lgdbm:
|
||||
if (self.compiler.find_library_file(lib_dirs, 'gdbm')):
|
||||
exts.append( Extension('gdbm', ['gdbmmodule.c'],
|
||||
libraries = ['gdbm'] ) )
|
||||
|
||||
# Berkeley DB interface.
|
||||
#
|
||||
# This requires the Berkeley DB code, see
|
||||
# ftp://ftp.cs.berkeley.edu/pub/4bsd/db.1.85.tar.gz
|
||||
#
|
||||
# Edit the variables DB and DBPORT to point to the db top directory
|
||||
# and the subdirectory of PORT where you built it.
|
||||
#
|
||||
# (See http://electricrain.com/greg/python/bsddb3/ for an interface to
|
||||
# BSD DB 3.x.)
|
||||
|
||||
dblib = []
|
||||
if self.compiler.find_library_file(lib_dirs, 'db'):
|
||||
dblib = ['db']
|
||||
|
||||
db185_incs = find_file('db_185.h', inc_dirs,
|
||||
['/usr/include/db3', '/usr/include/db2'])
|
||||
db_inc = find_file('db.h', inc_dirs, ['/usr/include/db1'])
|
||||
if db185_incs is not None:
|
||||
exts.append( Extension('bsddb', ['bsddbmodule.c'],
|
||||
include_dirs = db185_incs,
|
||||
define_macros=[('HAVE_DB_185_H',1)],
|
||||
libraries = dblib ) )
|
||||
elif db_inc is not None:
|
||||
exts.append( Extension('bsddb', ['bsddbmodule.c'],
|
||||
include_dirs = db_inc,
|
||||
libraries = dblib) )
|
||||
|
||||
# Unix-only modules
|
||||
if platform == 'win32':
|
||||
# Steen Lumholt's termios module
|
||||
exts.append( Extension('termios', ['termios.c']) )
|
||||
# Jeremy Hylton's rlimit interface
|
||||
if platform not in ['cygwin']:
|
||||
exts.append( Extension('resource', ['resource.c']) )
|
||||
|
||||
# Generic dynamic loading module
|
||||
#exts.append( Extension('dl', ['dlmodule.c']) )
|
||||
|
||||
# Sun yellow pages. Some systems have the functions in libc.
|
||||
if platform not in ['cygwin']:
|
||||
if (self.compiler.find_library_file(lib_dirs, 'nsl')):
|
||||
libs = ['nsl']
|
||||
else:
|
||||
libs = []
|
||||
exts.append( Extension('nis', ['nismodule.c'],
|
||||
libraries = libs) )
|
||||
|
||||
# Curses support, requring the System V version of curses, often
|
||||
# provided by the ncurses library.
|
||||
if (self.compiler.find_library_file(lib_dirs, 'ncurses')):
|
||||
curses_libs = ['ncurses']
|
||||
exts.append( Extension('_curses', ['_cursesmodule.c'],
|
||||
libraries = curses_libs) )
|
||||
elif (self.compiler.find_library_file(lib_dirs, 'curses')):
|
||||
if (self.compiler.find_library_file(lib_dirs, 'terminfo')):
|
||||
curses_libs = ['curses', 'terminfo']
|
||||
else:
|
||||
curses_libs = ['curses', 'termcap']
|
||||
|
||||
exts.append( Extension('_curses', ['_cursesmodule.c'],
|
||||
libraries = curses_libs) )
|
||||
|
||||
# If the curses module is enabled, check for the panel module
|
||||
if (os.path.exists('Modules/_curses_panel.c') and
|
||||
module_enabled(exts, '_curses') and
|
||||
self.compiler.find_library_file(lib_dirs, 'panel')):
|
||||
exts.append( Extension('_curses_panel', ['_curses_panel.c'],
|
||||
libraries = ['panel'] + curses_libs) )
|
||||
|
||||
|
||||
|
||||
# Lee Busby's SIGFPE modules.
|
||||
# The library to link fpectl with is platform specific.
|
||||
# Choose *one* of the options below for fpectl:
|
||||
|
||||
if platform == 'irix5':
|
||||
# For SGI IRIX (tested on 5.3):
|
||||
exts.append( Extension('fpectl', ['fpectlmodule.c'],
|
||||
libraries=['fpe']) )
|
||||
elif 0: # XXX how to detect SunPro?
|
||||
# For Solaris with SunPro compiler (tested on Solaris 2.5 with SunPro C 4.2):
|
||||
# (Without the compiler you don't have -lsunmath.)
|
||||
#fpectl fpectlmodule.c -R/opt/SUNWspro/lib -lsunmath -lm
|
||||
pass
|
||||
else:
|
||||
# For other systems: see instructions in fpectlmodule.c.
|
||||
#fpectl fpectlmodule.c ...
|
||||
exts.append( Extension('fpectl', ['fpectlmodule.c']) )
|
||||
|
||||
|
||||
# Andrew Kuchling's zlib module.
|
||||
# This require zlib 1.1.3 (or later).
|
||||
# See http://www.gzip.org/zlib/
|
||||
if (self.compiler.find_library_file(lib_dirs, 'z')):
|
||||
exts.append( Extension('zlib', ['zlibmodule.c'],
|
||||
libraries = ['z']) )
|
||||
|
||||
# Interface to the Expat XML parser
|
||||
#
|
||||
# Expat is written by James Clark and must be downloaded separately
|
||||
# (see below). The pyexpat module was written by Paul Prescod after a
|
||||
# prototype by Jack Jansen.
|
||||
#
|
||||
# The Expat dist includes Windows .lib and .dll files. Home page is
|
||||
# at http://www.jclark.com/xml/expat.html, the current production
|
||||
# release is always ftp://ftp.jclark.com/pub/xml/expat.zip.
|
||||
#
|
||||
# EXPAT_DIR, below, should point to the expat/ directory created by
|
||||
# unpacking the Expat source distribution.
|
||||
#
|
||||
# Note: the expat build process doesn't yet build a libexpat.a; you
|
||||
# can do this manually while we try convince the author to add it. To
|
||||
# do so, cd to EXPAT_DIR, run "make" if you have not done so, then
|
||||
# run:
|
||||
#
|
||||
# ar cr libexpat.a xmltok/*.o xmlparse/*.o
|
||||
#
|
||||
expat_defs = []
|
||||
expat_incs = find_file('expat.h', inc_dirs, [])
|
||||
if expat_incs is not None:
|
||||
# expat.h was found
|
||||
expat_defs = [('HAVE_EXPAT_H', 1)]
|
||||
else:
|
||||
expat_incs = find_file('xmlparse.h', inc_dirs, [])
|
||||
|
||||
if (expat_incs is not None and
|
||||
self.compiler.find_library_file(lib_dirs, 'expat')):
|
||||
exts.append( Extension('pyexpat', ['pyexpat.c'],
|
||||
define_macros = expat_defs,
|
||||
libraries = ['expat']) )
|
||||
|
||||
# Platform-specific libraries
|
||||
if platform == 'linux2':
|
||||
# Linux-specific modules
|
||||
exts.append( Extension('linuxaudiodev', ['linuxaudiodev.c']) )
|
||||
|
||||
if platform == 'sunos5':
|
||||
# SunOS specific modules
|
||||
exts.append( Extension('sunaudiodev', ['sunaudiodev.c']) )
|
||||
|
||||
self.extensions.extend(exts)
|
||||
|
||||
# Call the method for detecting whether _tkinter can be compiled
|
||||
self.detect_tkinter(inc_dirs, lib_dirs)
|
||||
|
||||
|
||||
def detect_tkinter(self, inc_dirs, lib_dirs):
|
||||
# The _tkinter module.
|
||||
|
||||
# Assume we haven't found any of the libraries or include files
|
||||
tcllib = tklib = tcl_includes = tk_includes = None
|
||||
for version in ['8.4', '8.3', '8.2', '8.1', '8.0']:
|
||||
tklib = self.compiler.find_library_file(lib_dirs,
|
||||
'tk' + version )
|
||||
tcllib = self.compiler.find_library_file(lib_dirs,
|
||||
'tcl' + version )
|
||||
if tklib and tcllib:
|
||||
# Exit the loop when we've found the Tcl/Tk libraries
|
||||
break
|
||||
|
||||
# Now check for the header files
|
||||
if tklib and tcllib:
|
||||
# Check for the include files on Debian, where
|
||||
# they're put in /usr/include/{tcl,tk}X.Y
|
||||
debian_tcl_include = [ '/usr/include/tcl' + version ]
|
||||
debian_tk_include = [ '/usr/include/tk' + version ] + debian_tcl_include
|
||||
tcl_includes = find_file('tcl.h', inc_dirs, debian_tcl_include)
|
||||
tk_includes = find_file('tk.h', inc_dirs, debian_tk_include)
|
||||
|
||||
if (tcllib is None or tklib is None and
|
||||
tcl_includes is None or tk_includes is None):
|
||||
# Something's missing, so give up
|
||||
return
|
||||
|
||||
# OK... everything seems to be present for Tcl/Tk.
|
||||
|
||||
include_dirs = [] ; libs = [] ; defs = [] ; added_lib_dirs = []
|
||||
for dir in tcl_includes + tk_includes:
|
||||
if dir not in include_dirs:
|
||||
include_dirs.append(dir)
|
||||
|
||||
# Check for various platform-specific directories
|
||||
platform = self.get_platform()
|
||||
if platform == 'sunos5':
|
||||
include_dirs.append('/usr/openwin/include')
|
||||
added_lib_dirs.append('/usr/openwin/lib')
|
||||
elif os.path.exists('/usr/X11R6/include'):
|
||||
include_dirs.append('/usr/X11R6/include')
|
||||
added_lib_dirs.append('/usr/X11R6/lib')
|
||||
elif os.path.exists('/usr/X11R5/include'):
|
||||
include_dirs.append('/usr/X11R5/include')
|
||||
added_lib_dirs.append('/usr/X11R5/lib')
|
||||
else:
|
||||
# Assume default location for X11
|
||||
include_dirs.append('/usr/X11/include')
|
||||
added_lib_dirs.append('/usr/X11/lib')
|
||||
|
||||
# Check for BLT extension
|
||||
if self.compiler.find_library_file(lib_dirs + added_lib_dirs, 'BLT8.0'):
|
||||
defs.append( ('WITH_BLT', 1) )
|
||||
libs.append('BLT8.0')
|
||||
|
||||
# Add the Tcl/Tk libraries
|
||||
libs.append('tk'+version)
|
||||
libs.append('tcl'+version)
|
||||
|
||||
if platform in ['aix3', 'aix4']:
|
||||
libs.append('ld')
|
||||
|
||||
# Finally, link with the X11 libraries
|
||||
libs.append('X11')
|
||||
|
||||
ext = Extension('_tkinter', ['_tkinter.c', 'tkappinit.c'],
|
||||
define_macros=[('WITH_APPINIT', 1)] + defs,
|
||||
include_dirs = include_dirs,
|
||||
libraries = libs,
|
||||
library_dirs = added_lib_dirs,
|
||||
)
|
||||
self.extensions.append(ext)
|
||||
|
||||
# XXX handle these, but how to detect?
|
||||
# *** Uncomment and edit for PIL (TkImaging) extension only:
|
||||
# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
|
||||
# *** Uncomment and edit for TOGL extension only:
|
||||
# -DWITH_TOGL togl.c \
|
||||
# *** Uncomment these for TOGL extension only:
|
||||
# -lGL -lGLU -lXext -lXmu \
|
||||
|
||||
def main():
|
||||
setup(name = 'Python standard library',
|
||||
version = '%d.%d' % sys.version_info[:2],
|
||||
cmdclass = {'build_ext':PyBuildExt},
|
||||
# The struct module is defined here, because build_ext won't be
|
||||
# called unless there's at least one extension module defined.
|
||||
ext_modules=[Extension('struct', ['structmodule.c'])],
|
||||
|
||||
# Scripts to install
|
||||
scripts = ['Tools/scripts/pydoc']
|
||||
)
|
||||
|
||||
# --install-platlib
|
||||
if __name__ == '__main__':
|
||||
sysconfig.set_python_build()
|
||||
main()
|
||||
17442
Misc/HISTORY
Normal file
17442
Misc/HISTORY
Normal file
File diff suppressed because it is too large
Load Diff
41
Misc/Porting
Normal file
41
Misc/Porting
Normal file
@@ -0,0 +1,41 @@
|
||||
Q. I want to port Python to a new platform. How do I begin?
|
||||
|
||||
A. I guess the two things to start with is to familiarize yourself
|
||||
with are the development system for your target platform and the
|
||||
generic build process for Python. Make sure you can compile and run a
|
||||
simple hello-world program on your target platform. Make sure you can
|
||||
compile and run the Python interpreter on a platform to which it has
|
||||
already been ported (preferably Unix, but Mac or Windows will do,
|
||||
too).
|
||||
|
||||
I also would never start something like this without at least
|
||||
medium-level understanding of your target platform (i.e. how it is
|
||||
generally used, how to write platform specific apps etc.) and Python
|
||||
(or else you'll never know how to test the results).
|
||||
|
||||
The build process for Python, in particular the Makefiles in the
|
||||
source distribution, will give you a hint on which files to compile
|
||||
for Python. Not all source files are relevant -- some are platform
|
||||
specific, others are only used in emergencies (e.g. getopt.c). The
|
||||
Makefiles tell the story.
|
||||
|
||||
You'll also need a pyconfig.h file tailored for your platform. You can
|
||||
start with pyconfig.h.in, read the comments and turn on definitions that
|
||||
apply to your platform.
|
||||
|
||||
And you'll need a config.c file, which lists the built-in modules you
|
||||
support. Start with Modules/config.c.in.
|
||||
|
||||
Finally, you'll run into some things that aren't supported on your
|
||||
target platform. Forget about the posix module for now -- simply take
|
||||
it out of the config.c file.
|
||||
|
||||
Bang on it until you get a >>> prompt. (You may have to disable the
|
||||
importing of "site.py" by passing the -S option.)
|
||||
|
||||
Then bang on it until it executes very simple Python statements.
|
||||
|
||||
Now bang on it some more. At some point you'll want to use the os
|
||||
module; this is the time to start thinking about what to do with the
|
||||
posix module. It's okay to simply #ifdef out those functions that
|
||||
cause problems; the remaining ones will be quite useful.
|
||||
42
Misc/README
Normal file
42
Misc/README
Normal file
@@ -0,0 +1,42 @@
|
||||
Python Misc subdirectory
|
||||
========================
|
||||
|
||||
This directory contains files that wouldn't fit in elsewhere. Some
|
||||
documents are only of historic importance.
|
||||
|
||||
Files found here
|
||||
----------------
|
||||
|
||||
ACKS Acknowledgements
|
||||
AIX-NOTES Notes for building Python on AIX
|
||||
BeOS-NOTES Notes for building on BeOS
|
||||
BeOS-setup.py setup.py replacement for BeOS, see BeOS-NOTES
|
||||
build.sh Script to build and test latest Python from the repository
|
||||
cheatsheet Quick summary of Python by Ken Manheimer
|
||||
developers.txt A history of who got developer permissions, and why
|
||||
gdbinit Handy stuff to put in your .gdbinit file, if you use gdb
|
||||
HISTORY News from previous releases -- oldest last
|
||||
indent.pro GNU indent profile approximating my C style
|
||||
maintainers.rst A list of maintainers for library modules
|
||||
NEWS News for this release (for some meaning of "this")
|
||||
NEWS.help How to edit NEWS
|
||||
Porting Mini-FAQ on porting to new platforms
|
||||
PURIFY.README Information for Purify users
|
||||
pymemcompat.h Memory interface compatibility file.
|
||||
python-config.in Python script template for python-config
|
||||
python.man UNIX man page for the python interpreter
|
||||
python-mode.el Emacs mode for editing Python programs
|
||||
python.pc.in Package configuration info template for pkg-config
|
||||
python-wing.wpr Wing IDE project file
|
||||
README The file you're reading now
|
||||
README.coverity Information about running Coverity's Prevent on Python
|
||||
README.klocwork Information about running Klocwork's K7 on Python
|
||||
README.OpenBSD Help for building problems on OpenBSD
|
||||
README.valgrind Information for Valgrind users, see valgrind-python.supp
|
||||
RFD Request For Discussion about a Python newsgroup
|
||||
setuid-prog.c C helper program for set-uid Python scripts
|
||||
SpecialBuilds.txt Describes extra symbols you can set for debug builds
|
||||
TextMate A TextMate bundle for Python development
|
||||
valgrind-python.supp Valgrind suppression file, see README.valgrind
|
||||
vgrindefs Python configuration for vgrind (a generic pretty printer)
|
||||
Vim Python development utilities for the Vim editor
|
||||
137
Misc/README.AIX
Normal file
137
Misc/README.AIX
Normal file
@@ -0,0 +1,137 @@
|
||||
|
||||
This documentation tries to help people who intend to use Python on
|
||||
AIX.
|
||||
|
||||
There used to be many issues with Python on AIX, but the major ones
|
||||
have been corrected for version 3.2, so that Python should now work
|
||||
rather well on this platform. The remaining known issues are listed in
|
||||
this document.
|
||||
|
||||
|
||||
======================================================================
|
||||
Compiling Python
|
||||
----------------------------------------------------------------------
|
||||
|
||||
You can compile Python with gcc or the native AIX compiler. The native
|
||||
compiler used to give better performances on this system with older
|
||||
versions of Python. With Python 3.2 it may not be the case anymore,
|
||||
as this compiler does not allow compiling Python with computed gotos.
|
||||
Some benchmarks need to be done.
|
||||
|
||||
Compiling with gcc:
|
||||
|
||||
cd Python-3.2
|
||||
CC=gcc OPT="-O2" ./configure --enable-shared
|
||||
make
|
||||
|
||||
There are various aliases for the native compiler. The recommended
|
||||
alias for compiling Python is 'xlc_r', which provides a better level of
|
||||
compatibility and handles thread initialization properly.
|
||||
|
||||
It is a good idea to add the '-qmaxmem=70000' option, otherwise the
|
||||
compiler considers various files too complex to optimize.
|
||||
|
||||
Compiling with xlc:
|
||||
|
||||
cd Python-3.2
|
||||
CC=xlc_r OPT="-O2 -qmaxmem=70000" ./configure --without-computed-gotos --enable-shared
|
||||
make
|
||||
|
||||
Note:
|
||||
On AIX 5.3 and earlier, you will also need to specify the
|
||||
"--disable-ipv6" flag to configure. This has been corrected in AIX
|
||||
6.1.
|
||||
|
||||
|
||||
======================================================================
|
||||
Memory Limitations
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Note: this section may not apply when compiling Python as a 64 bit
|
||||
application.
|
||||
|
||||
By default on AIX each program gets one segment register for its data
|
||||
segment. As each segment register covers 256 MB, a Python program that
|
||||
would use more than 256MB will raise a MemoryError. The standard
|
||||
Python test suite is one such application.
|
||||
|
||||
To allocate more segment registers to Python, you must use the linker
|
||||
option -bmaxdata or the ldedit tool to specify the number of bytes you
|
||||
need in the data segment.
|
||||
|
||||
For example, if you want to allow 512MB of memory for Python (this is
|
||||
enough for the test suite to run without MemoryErrors), you should run
|
||||
the following command at the end of compilation:
|
||||
|
||||
ldedit -b maxdata:0x20000000 ./python
|
||||
|
||||
You can allow up to 2GB of memory for Python by using the value
|
||||
0x80000000 for maxdata.
|
||||
|
||||
It is also possible to go beyond 2GB of memory by activating Large
|
||||
Page Use. You should consult the IBM documentation if you need to use
|
||||
this option. You can also follow the discussion of this problem
|
||||
in issue 11212 at bugs.python.org.
|
||||
|
||||
http://publib.boulder.ibm.com/infocenter/aix/v6r1/index.jsp?topic=/com.ibm.aix.cmds/doc/aixcmds3/ldedit.htm
|
||||
|
||||
|
||||
======================================================================
|
||||
Known issues
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Those issues are currently affecting Python on AIX:
|
||||
|
||||
* Python has not been fully tested on AIX when compiled as a 64 bit
|
||||
application.
|
||||
|
||||
* issue 3526: the memory used by a Python process will never be
|
||||
released to the system. If you have a Python application on AIX that
|
||||
uses a lot of memory, you should read this issue and you may
|
||||
consider using the provided patch that implements a custom malloc
|
||||
implementation
|
||||
|
||||
* issue 11184: support for large files is currently broken
|
||||
|
||||
* issue 11185: os.wait4 does not behave correctly with option WNOHANG
|
||||
|
||||
* issue 1745108: there may be some problems with curses.panel
|
||||
|
||||
* issue 11192: test_socket fails
|
||||
|
||||
* issue 11190: test_locale fails
|
||||
|
||||
* issue 11193: test_subprocess fails
|
||||
|
||||
* issue 9920: minor arithmetic issues in cmath
|
||||
|
||||
* issue 11215: test_fileio fails
|
||||
|
||||
* issue 11188: test_time fails
|
||||
|
||||
|
||||
======================================================================
|
||||
Implementation details for developers
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Python and python modules can now be built as shared libraries on AIX
|
||||
as usual.
|
||||
|
||||
AIX shared libraries require that an "export" and "import" file be
|
||||
provided at compile time to list all extern symbols which may be
|
||||
shared between modules. The "export" file (named python.exp) for the
|
||||
modules and the libraries that belong to the Python core is created by
|
||||
the "makexp_aix" script before performing the link of the python
|
||||
binary. It lists all global symbols (exported during the link) of the
|
||||
modules and the libraries that make up the python executable.
|
||||
|
||||
When shared library modules (.so files) are made, a second shell
|
||||
script is invoked. This script is named "ld_so_aix" and is also
|
||||
provided with the distribution in the Modules subdirectory. This
|
||||
script acts as an "ld" wrapper which hides the explicit management of
|
||||
"export" and "import" files; it adds the appropriate arguments (in the
|
||||
appropriate order) to the link command that creates the shared module.
|
||||
Among other things, it specifies that the "python.exp" file is an
|
||||
"import" file for the shared module.
|
||||
|
||||
This mechanism should be transparent.
|
||||
32
Misc/README.Emacs
Normal file
32
Misc/README.Emacs
Normal file
@@ -0,0 +1,32 @@
|
||||
=============
|
||||
Emacs support
|
||||
=============
|
||||
|
||||
If you want to edit Python code in Emacs, you should download python-mode.el
|
||||
and install it somewhere on your load-path. See the project page to download:
|
||||
|
||||
https://launchpad.net/python-mode
|
||||
|
||||
While Emacs comes with a python.el file, it is not recommended.
|
||||
python-mode.el is maintained by core Python developers and is generally
|
||||
considered more Python programmer friendly. For example, python-mode.el
|
||||
includes a killer feature called `pdbtrack` which allows you to set a pdb
|
||||
breakpoint in your code, run your program in an Emacs shell buffer, and do gud
|
||||
style debugging when the breakpoint is hit.
|
||||
|
||||
python-mode.el is compatible with both GNU Emacs from the FSF, and XEmacs.
|
||||
|
||||
For more information and bug reporting, see the above project page. For help,
|
||||
development, or discussions, see the python-mode mailing list:
|
||||
|
||||
http://mail.python.org/mailman/listinfo/python-mode
|
||||
|
||||
|
||||
..
|
||||
Local Variables:
|
||||
mode: indented-text
|
||||
indent-tabs-mode: nil
|
||||
sentence-end-double-space: t
|
||||
fill-column: 78
|
||||
coding: utf-8
|
||||
End:
|
||||
38
Misc/README.OpenBSD
Normal file
38
Misc/README.OpenBSD
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
2005-01-08
|
||||
|
||||
If you are have a problem building on OpenBSD and see output like this
|
||||
while running configure:
|
||||
|
||||
checking curses.h presence... yes
|
||||
configure: WARNING: curses.h: present but cannot be compiled
|
||||
configure: WARNING: curses.h: check for missing prerequisite headers?
|
||||
configure: WARNING: curses.h: see the Autoconf documentation
|
||||
configure: WARNING: curses.h: section "Present But Cannot Be Compiled"
|
||||
configure: WARNING: curses.h: proceeding with the preprocessor's result
|
||||
configure: WARNING: curses.h: in the future, the compiler will take precedence
|
||||
|
||||
there is likely a problem that will prevent building python.
|
||||
If you see the messages above and are able to completely build python,
|
||||
please tell python-dev@python.org indicating your version of OpenBSD
|
||||
and any other relevant system configuration.
|
||||
|
||||
The build error that occurs while making may look something like this:
|
||||
|
||||
/usr/include/sys/event.h:53: error: syntax error before "u_int"
|
||||
/usr/include/sys/event.h:55: error: syntax error before "u_short"
|
||||
|
||||
To fix this problem, you will probably need update Python's configure
|
||||
script to disable certain options. Search for a line that looks like:
|
||||
|
||||
OpenBSD/2.* | OpenBSD/3.@<:@012345678@:>@)
|
||||
|
||||
If your version is not in that list, e.g., 3.9, add the version
|
||||
number. In this case, you would just need to add a 9 after the 8.
|
||||
If you modify configure.ac, you will need to regenerate configure
|
||||
with autoconf.
|
||||
|
||||
If your version is already in the list, this is not a known problem.
|
||||
Please submit a bug report here:
|
||||
|
||||
http://sourceforge.net/tracker/?group_id=5470&atid=105470
|
||||
22
Misc/README.coverity
Normal file
22
Misc/README.coverity
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
Coverity has a static analysis tool (Prevent) which is similar to Klocwork.
|
||||
They run their tool on the Python source code (SVN head) on a daily basis.
|
||||
The results are available at:
|
||||
|
||||
http://scan.coverity.com/
|
||||
|
||||
About 20 people have access to the analysis reports. Other
|
||||
people can be added by request.
|
||||
|
||||
Prevent was first run on the Python 2.5 source code in March 2006.
|
||||
There were originally about 100 defects reported. Some of these
|
||||
were false positives. Over 70 issues were uncovered.
|
||||
|
||||
Each warning has a unique id and comments that can be made on it.
|
||||
When checking in changes due to a warning, the unique id
|
||||
as reported by the tool was added to the SVN commit message.
|
||||
|
||||
False positives were annotated so that the comments can
|
||||
be reviewed and reversed if the analysis was incorrect.
|
||||
|
||||
Contact python-dev@python.org for more information.
|
||||
30
Misc/README.klocwork
Normal file
30
Misc/README.klocwork
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
Klocwork has a static analysis tool (K7) which is similar to Coverity.
|
||||
They will run their tool on the Python source code on demand.
|
||||
The results are available at:
|
||||
|
||||
https://opensource.klocwork.com/
|
||||
|
||||
Currently, only Neal Norwitz has access to the analysis reports. Other
|
||||
people can be added by request.
|
||||
|
||||
K7 was first run on the Python 2.5 source code in mid-July 2006.
|
||||
This is after Coverity had been making their results available.
|
||||
There were originally 175 defects reported. Most of these
|
||||
were false positives. However, there were numerous real issues
|
||||
also uncovered.
|
||||
|
||||
Each warning has a unique id and comments that can be made on it.
|
||||
When checking in changes due to a K7 report, the unique id
|
||||
as reported by the tool was added to the SVN commit message.
|
||||
A comment was added to the K7 warning indicating the SVN revision
|
||||
in addition to any analysis.
|
||||
|
||||
False positives were also annotated so that the comments can
|
||||
be reviewed and reversed if the analysis was incorrect.
|
||||
|
||||
A second run was performed on 10-Aug-2006. The tool was tuned to remove
|
||||
some false positives and perform some additional checks. ~150 new
|
||||
warnings were produced, primarily related to dereferencing NULL pointers.
|
||||
|
||||
Contact python-dev@python.org for more information.
|
||||
97
Misc/README.valgrind
Normal file
97
Misc/README.valgrind
Normal file
@@ -0,0 +1,97 @@
|
||||
This document describes some caveats about the use of Valgrind with
|
||||
Python. Valgrind is used periodically by Python developers to try
|
||||
to ensure there are no memory leaks or invalid memory reads/writes.
|
||||
|
||||
If you don't want to read about the details of using Valgrind, there
|
||||
are still two things you must do to suppress the warnings. First,
|
||||
you must use a suppressions file. One is supplied in
|
||||
Misc/valgrind-python.supp. Second, you must do one of the following:
|
||||
|
||||
* Uncomment Py_USING_MEMORY_DEBUGGER in Objects/obmalloc.c,
|
||||
then rebuild Python
|
||||
* Uncomment the lines in Misc/valgrind-python.supp that
|
||||
suppress the warnings for PyObject_Free and PyObject_Realloc
|
||||
|
||||
If you want to use Valgrind more effectively and catch even more
|
||||
memory leaks, you will need to configure python --without-pymalloc.
|
||||
PyMalloc allocates a few blocks in big chunks and most object
|
||||
allocations don't call malloc, they use chunks doled about by PyMalloc
|
||||
from the big blocks. This means Valgrind can't detect
|
||||
many allocations (and frees), except for those that are forwarded
|
||||
to the system malloc. Note: configuring python --without-pymalloc
|
||||
makes Python run much slower, especially when running under Valgrind.
|
||||
You may need to run the tests in batches under Valgrind to keep
|
||||
the memory usage down to allow the tests to complete. It seems to take
|
||||
about 5 times longer to run --without-pymalloc.
|
||||
|
||||
Apr 15, 2006:
|
||||
test_ctypes causes Valgrind 3.1.1 to fail (crash).
|
||||
test_socket_ssl should be skipped when running valgrind.
|
||||
The reason is that it purposely uses uninitialized memory.
|
||||
This causes many spurious warnings, so it's easier to just skip it.
|
||||
|
||||
|
||||
Details:
|
||||
--------
|
||||
Python uses its own small-object allocation scheme on top of malloc,
|
||||
called PyMalloc.
|
||||
|
||||
Valgrind may show some unexpected results when PyMalloc is used.
|
||||
Starting with Python 2.3, PyMalloc is used by default. You can disable
|
||||
PyMalloc when configuring python by adding the --without-pymalloc option.
|
||||
If you disable PyMalloc, most of the information in this document and
|
||||
the supplied suppressions file will not be useful. As discussed above,
|
||||
disabling PyMalloc can catch more problems.
|
||||
|
||||
If you use valgrind on a default build of Python, you will see
|
||||
many errors like:
|
||||
|
||||
==6399== Use of uninitialised value of size 4
|
||||
==6399== at 0x4A9BDE7E: PyObject_Free (obmalloc.c:711)
|
||||
==6399== by 0x4A9B8198: dictresize (dictobject.c:477)
|
||||
|
||||
These are expected and not a problem. Tim Peters explains
|
||||
the situation:
|
||||
|
||||
PyMalloc needs to know whether an arbitrary address is one
|
||||
that's managed by it, or is managed by the system malloc.
|
||||
The current scheme allows this to be determined in constant
|
||||
time, regardless of how many memory areas are under pymalloc's
|
||||
control.
|
||||
|
||||
The memory pymalloc manages itself is in one or more "arenas",
|
||||
each a large contiguous memory area obtained from malloc.
|
||||
The base address of each arena is saved by pymalloc
|
||||
in a vector. Each arena is carved into "pools", and a field at
|
||||
the start of each pool contains the index of that pool's arena's
|
||||
base address in that vector.
|
||||
|
||||
Given an arbitrary address, pymalloc computes the pool base
|
||||
address corresponding to it, then looks at "the index" stored
|
||||
near there. If the index read up is out of bounds for the
|
||||
vector of arena base addresses pymalloc maintains, then
|
||||
pymalloc knows for certain that this address is not under
|
||||
pymalloc's control. Otherwise the index is in bounds, and
|
||||
pymalloc compares
|
||||
|
||||
the arena base address stored at that index in the vector
|
||||
|
||||
to
|
||||
|
||||
the arbitrary address pymalloc is investigating
|
||||
|
||||
pymalloc controls this arbitrary address if and only if it lies
|
||||
in the arena the address's pool's index claims it lies in.
|
||||
|
||||
It doesn't matter whether the memory pymalloc reads up ("the
|
||||
index") is initialized. If it's not initialized, then
|
||||
whatever trash gets read up will lead pymalloc to conclude
|
||||
(correctly) that the address isn't controlled by it, either
|
||||
because the index is out of bounds, or the index is in bounds
|
||||
but the arena it represents doesn't contain the address.
|
||||
|
||||
This determination has to be made on every call to one of
|
||||
pymalloc's free/realloc entry points, so its speed is critical
|
||||
(Python allocates and frees dynamic memory at a ferocious rate
|
||||
-- everything in Python, from integers to "stack frames",
|
||||
lives in the heap).
|
||||
114
Misc/RFD
Normal file
114
Misc/RFD
Normal file
@@ -0,0 +1,114 @@
|
||||
To: python-list
|
||||
Subject: comp.lang.python RFD again
|
||||
From: Guido.van.Rossum@cwi.nl
|
||||
|
||||
I've followed the recent discussion and trimmed the blurb RFD down a bit
|
||||
(and added the word "object-oriented" to the blurb).
|
||||
|
||||
I don't think it's too early to *try* to create the newsgroup --
|
||||
whether we will succeed may depend on how many Python supporters there
|
||||
are outside the mailing list.
|
||||
|
||||
I'm personally not worried about moderation, and anyway I haven't
|
||||
heard from any volunteers for moderation (and I won't volunteer
|
||||
myself) so I suggest that we'll continue to ask for one unmoderated
|
||||
newsgroup.
|
||||
|
||||
My next action will be to post an updated FAQ (which will hint at the
|
||||
upcoming RFD) to comp.lang.misc; then finalize the 1.0.0 release and
|
||||
put it on the ftp site. I'll also try to get it into
|
||||
comp.sources.unix or .misc. And all this before the end of January!
|
||||
|
||||
--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
|
||||
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>
|
||||
|
||||
======================================================================
|
||||
|
||||
These are the steps required (in case you don't know about the
|
||||
newsgroup creation process):
|
||||
|
||||
First, we need to draw up an RFD (Request For Discussion). This is a
|
||||
document that tells what the purpose of the group is, and gives a case
|
||||
for its creation. We post this to relevant groups (comp.lang.misc,
|
||||
the mailing list, news.groups, etc.) Discussion is held on
|
||||
news.groups.
|
||||
|
||||
Then, after a few weeks, we run the official CFV (Call For Votes).
|
||||
The votes are then collected over a period of weeks. We need 100 more
|
||||
yes votes than no votes, and a 2/3 majority, to get the group.
|
||||
|
||||
There are some restrictions on the vote taker: [s]he cannot actively
|
||||
campaign for/against the group during the vote process. So the main
|
||||
benefit to Steve instead of me running the vote is that I will be free
|
||||
to campaign for its creation!
|
||||
|
||||
The following is our current draft for the RFD.
|
||||
|
||||
======================================================================
|
||||
|
||||
Request For Discussion: comp.lang.python
|
||||
|
||||
|
||||
Purpose
|
||||
-------
|
||||
|
||||
The newsgroup will be for discussion on the Python computer language.
|
||||
Possible topics include requests for information, general programming,
|
||||
development, and bug reports. The group will be unmoderated.
|
||||
|
||||
|
||||
What is Python?
|
||||
---------------
|
||||
|
||||
Python is a relatively new very-high-level language developed in
|
||||
Amsterdam. Python is a simple, object-oriented procedural language,
|
||||
with features taken from ABC, Icon, Modula-3, and C/C++.
|
||||
|
||||
Its central goal is to provide the best of both worlds: the dynamic
|
||||
nature of scripting languages like Perl/TCL/REXX, but also support for
|
||||
general programming found in the more traditional languages like Icon,
|
||||
C, Modula,...
|
||||
|
||||
Python may be FTP'd from the following sites:
|
||||
|
||||
ftp.cwi.nl in directory /pub/python (its "home site", also has a FAQ)
|
||||
ftp.uu.net in directory /languages/python
|
||||
gatekeeper.dec.com in directory /pub/plan/python/cwi
|
||||
|
||||
|
||||
Rationale
|
||||
---------
|
||||
|
||||
Currently there is a mailing list with over 130 subscribers.
|
||||
The activity of this list is high, and to make handling the
|
||||
traffic more reasonable, a newsgroup is being proposed. We
|
||||
also feel that comp.lang.misc would not be a suitable forum
|
||||
for this volume of discussion on a particular language.
|
||||
|
||||
|
||||
Charter
|
||||
-------
|
||||
|
||||
Comp.lang.python is an unmoderated newsgroup which will serve
|
||||
as a forum for discussing the Python computer language. The
|
||||
group will serve both those who just program in Python and
|
||||
those who work on developing the language. Topics that
|
||||
may be discussed include:
|
||||
|
||||
- announcements of new versions of the language and
|
||||
applications written in Python.
|
||||
|
||||
- discussion on the internals of the Python language.
|
||||
|
||||
- general information about the language.
|
||||
|
||||
- discussion on programming in Python.
|
||||
|
||||
|
||||
Discussion
|
||||
----------
|
||||
|
||||
Any objections to this RFD will be considered and, if determined
|
||||
to be appropriate, will be incorporated. The discussion period
|
||||
will be for a period of 21 days after which the first CFV will be
|
||||
issued.
|
||||
258
Misc/SpecialBuilds.txt
Normal file
258
Misc/SpecialBuilds.txt
Normal file
@@ -0,0 +1,258 @@
|
||||
This file describes some special Python build types enabled via compile-time
|
||||
preprocessor defines.
|
||||
|
||||
IMPORTANT: if you want to build a debug-enabled Python, it is recommended that
|
||||
you use ``./configure --with-pydebug``, rather than the options listed here.
|
||||
|
||||
However, if you wish to define some of these options individually, it is best
|
||||
to define them in the EXTRA_CFLAGS make variable;
|
||||
``make EXTRA_CFLAGS="-DPy_REF_DEBUG"``.
|
||||
|
||||
|
||||
Py_REF_DEBUG
|
||||
------------
|
||||
|
||||
Turn on aggregate reference counting. This arranges that extern _Py_RefTotal
|
||||
hold a count of all references, the sum of ob_refcnt across all objects. In a
|
||||
debug-mode build, this is where the "8288" comes from in
|
||||
|
||||
>>> 23
|
||||
23
|
||||
[8288 refs]
|
||||
>>>
|
||||
|
||||
Note that if this count increases when you're not storing away new objects,
|
||||
there's probably a leak. Remember, though, that in interactive mode the special
|
||||
name "_" holds a reference to the last result displayed!
|
||||
|
||||
Py_REF_DEBUG also checks after every decref to verify that the refcount hasn't
|
||||
gone negative, and causes an immediate fatal error if it has.
|
||||
|
||||
Special gimmicks:
|
||||
|
||||
sys.gettotalrefcount()
|
||||
Return current total of all refcounts.
|
||||
|
||||
|
||||
Py_TRACE_REFS
|
||||
-------------
|
||||
|
||||
Turn on heavy reference debugging. This is major surgery. Every PyObject grows
|
||||
two more pointers, to maintain a doubly-linked list of all live heap-allocated
|
||||
objects. Most built-in type objects are not in this list, as they're statically
|
||||
allocated. Starting in Python 2.3, if COUNT_ALLOCS (see below) is also defined,
|
||||
a static type object T does appear in this list if at least one object of type T
|
||||
has been created.
|
||||
|
||||
Note that because the fundamental PyObject layout changes, Python modules
|
||||
compiled with Py_TRACE_REFS are incompatible with modules compiled without it.
|
||||
|
||||
Py_TRACE_REFS implies Py_REF_DEBUG.
|
||||
|
||||
Special gimmicks:
|
||||
|
||||
sys.getobjects(max[, type])
|
||||
Return list of the (no more than) max most-recently allocated objects, most
|
||||
recently allocated first in the list, least-recently allocated last in the
|
||||
list. max=0 means no limit on list length. If an optional type object is
|
||||
passed, the list is also restricted to objects of that type. The return
|
||||
list itself, and some temp objects created just to call sys.getobjects(),
|
||||
are excluded from the return list. Note that the list returned is just
|
||||
another object, though, so may appear in the return list the next time you
|
||||
call getobjects(); note that every object in the list is kept alive too,
|
||||
simply by virtue of being in the list.
|
||||
|
||||
envvar PYTHONDUMPREFS
|
||||
If this envvar exists, Py_Finalize() arranges to print a list of all
|
||||
still-live heap objects. This is printed twice, in different formats,
|
||||
before and after Py_Finalize has cleaned up everything it can clean up. The
|
||||
first output block produces the repr() of each object so is more
|
||||
informative; however, a lot of stuff destined to die is still alive then.
|
||||
The second output block is much harder to work with (repr() can't be invoked
|
||||
anymore -- the interpreter has been torn down too far), but doesn't list any
|
||||
objects that will die. The tool script combinerefs.py can be run over this
|
||||
to combine the info from both output blocks. The second output block, and
|
||||
combinerefs.py, were new in Python 2.3b1.
|
||||
|
||||
|
||||
PYMALLOC_DEBUG
|
||||
--------------
|
||||
|
||||
When pymalloc is enabled (WITH_PYMALLOC is defined), calls to the PyObject_
|
||||
memory routines are handled by Python's own small-object allocator, while calls
|
||||
to the PyMem_ memory routines are directed to the system malloc/ realloc/free.
|
||||
If PYMALLOC_DEBUG is also defined, calls to both PyObject_ and PyMem_ memory
|
||||
routines are directed to a special debugging mode of Python's small-object
|
||||
allocator.
|
||||
|
||||
This mode fills dynamically allocated memory blocks with special, recognizable
|
||||
bit patterns, and adds debugging info on each end of dynamically allocated
|
||||
memory blocks. The special bit patterns are:
|
||||
|
||||
#define CLEANBYTE 0xCB /* clean (newly allocated) memory */
|
||||
#define DEADBYTE 0xDB /* dead (newly freed) memory */
|
||||
#define FORBIDDENBYTE 0xFB /* forbidden -- untouchable bytes */
|
||||
|
||||
Strings of these bytes are unlikely to be valid addresses, floats, or 7-bit
|
||||
ASCII strings.
|
||||
|
||||
Let S = sizeof(size_t). 2*S bytes are added at each end of each block of N bytes
|
||||
requested. The memory layout is like so, where p represents the address
|
||||
returned by a malloc-like or realloc-like function (p[i:j] means the slice of
|
||||
bytes from *(p+i) inclusive up to *(p+j) exclusive; note that the treatment of
|
||||
negative indices differs from a Python slice):
|
||||
|
||||
p[-2*S:-S]
|
||||
Number of bytes originally asked for. This is a size_t, big-endian (easier
|
||||
to read in a memory dump).
|
||||
p[-S:0]
|
||||
Copies of FORBIDDENBYTE. Used to catch under- writes and reads.
|
||||
p[0:N]
|
||||
The requested memory, filled with copies of CLEANBYTE, used to catch
|
||||
reference to uninitialized memory. When a realloc-like function is called
|
||||
requesting a larger memory block, the new excess bytes are also filled with
|
||||
CLEANBYTE. When a free-like function is called, these are overwritten with
|
||||
DEADBYTE, to catch reference to freed memory. When a realloc- like function
|
||||
is called requesting a smaller memory block, the excess old bytes are also
|
||||
filled with DEADBYTE.
|
||||
p[N:N+S]
|
||||
Copies of FORBIDDENBYTE. Used to catch over- writes and reads.
|
||||
p[N+S:N+2*S]
|
||||
A serial number, incremented by 1 on each call to a malloc-like or
|
||||
realloc-like function. Big-endian size_t. If "bad memory" is detected
|
||||
later, the serial number gives an excellent way to set a breakpoint on the
|
||||
next run, to capture the instant at which this block was passed out. The
|
||||
static function bumpserialno() in obmalloc.c is the only place the serial
|
||||
number is incremented, and exists so you can set such a breakpoint easily.
|
||||
|
||||
A realloc-like or free-like function first checks that the FORBIDDENBYTEs at
|
||||
each end are intact. If they've been altered, diagnostic output is written to
|
||||
stderr, and the program is aborted via Py_FatalError(). The other main failure
|
||||
mode is provoking a memory error when a program reads up one of the special bit
|
||||
patterns and tries to use it as an address. If you get in a debugger then and
|
||||
look at the object, you're likely to see that it's entirely filled with 0xDB
|
||||
(meaning freed memory is getting used) or 0xCB (meaning uninitialized memory is
|
||||
getting used).
|
||||
|
||||
Note that PYMALLOC_DEBUG requires WITH_PYMALLOC.
|
||||
|
||||
Special gimmicks:
|
||||
|
||||
envvar PYTHONMALLOCSTATS
|
||||
If this envvar exists, a report of pymalloc summary statistics is printed to
|
||||
stderr whenever a new arena is allocated, and also by Py_Finalize().
|
||||
|
||||
Changed in 2.5: The number of extra bytes allocated is 4*sizeof(size_t).
|
||||
Before it was 16 on all boxes, reflecting that Python couldn't make use of
|
||||
allocations >= 2**32 bytes even on 64-bit boxes before 2.5.
|
||||
|
||||
|
||||
Py_DEBUG
|
||||
--------
|
||||
|
||||
This is what is generally meant by "a debug build" of Python.
|
||||
|
||||
Py_DEBUG implies LLTRACE, Py_REF_DEBUG, Py_TRACE_REFS, and PYMALLOC_DEBUG (if
|
||||
WITH_PYMALLOC is enabled). In addition, C assert()s are enabled (via the C way:
|
||||
by not defining NDEBUG), and some routines do additional sanity checks inside
|
||||
"#ifdef Py_DEBUG" blocks.
|
||||
|
||||
|
||||
COUNT_ALLOCS
|
||||
------------
|
||||
|
||||
Each type object grows three new members:
|
||||
|
||||
/* Number of times an object of this type was allocated. */
|
||||
int tp_allocs;
|
||||
|
||||
/* Number of times an object of this type was deallocated. */
|
||||
int tp_frees;
|
||||
|
||||
/* Highwater mark: the maximum value of tp_allocs - tp_frees so
|
||||
* far; or, IOW, the largest number of objects of this type alive at
|
||||
* the same time.
|
||||
*/
|
||||
int tp_maxalloc;
|
||||
|
||||
Allocation and deallocation code keeps these counts up to date. Py_Finalize()
|
||||
displays a summary of the info returned by sys.getcounts() (see below), along
|
||||
with assorted other special allocation counts (like the number of tuple
|
||||
allocations satisfied by a tuple free-list, the number of 1-character strings
|
||||
allocated, etc).
|
||||
|
||||
Before Python 2.2, type objects were immortal, and the COUNT_ALLOCS
|
||||
implementation relies on that. As of Python 2.2, heap-allocated type/ class
|
||||
objects can go away. COUNT_ALLOCS can blow up in 2.2 and 2.2.1 because of this;
|
||||
this was fixed in 2.2.2. Use of COUNT_ALLOCS makes all heap-allocated type
|
||||
objects immortal, except for those for which no object of that type is ever
|
||||
allocated.
|
||||
|
||||
Starting with Python 2.3, If Py_TRACE_REFS is also defined, COUNT_ALLOCS
|
||||
arranges to ensure that the type object for each allocated object appears in the
|
||||
doubly-linked list of all objects maintained by Py_TRACE_REFS.
|
||||
|
||||
Special gimmicks:
|
||||
|
||||
sys.getcounts()
|
||||
Return a list of 4-tuples, one entry for each type object for which at least
|
||||
one object of that type was allocated. Each tuple is of the form:
|
||||
|
||||
(tp_name, tp_allocs, tp_frees, tp_maxalloc)
|
||||
|
||||
Each distinct type object gets a distinct entry in this list, even if two or
|
||||
more type objects have the same tp_name (in which case there's no way to
|
||||
distinguish them by looking at this list). The list is ordered by time of
|
||||
first object allocation: the type object for which the first allocation of
|
||||
an object of that type occurred most recently is at the front of the list.
|
||||
|
||||
|
||||
LLTRACE
|
||||
-------
|
||||
|
||||
Compile in support for Low Level TRACE-ing of the main interpreter loop.
|
||||
|
||||
When this preprocessor symbol is defined, before PyEval_EvalFrame executes a
|
||||
frame's code it checks the frame's global namespace for a variable
|
||||
"__lltrace__". If such a variable is found, mounds of information about what
|
||||
the interpreter is doing are sprayed to stdout, such as every opcode and opcode
|
||||
argument and values pushed onto and popped off the value stack.
|
||||
|
||||
Not useful very often, but very useful when needed.
|
||||
|
||||
|
||||
CALL_PROFILE
|
||||
------------
|
||||
|
||||
Count the number of function calls executed.
|
||||
|
||||
When this symbol is defined, the ceval mainloop and helper functions count the
|
||||
number of function calls made. It keeps detailed statistics about what kind of
|
||||
object was called and whether the call hit any of the special fast paths in the
|
||||
code.
|
||||
|
||||
|
||||
WITH_TSC
|
||||
--------
|
||||
|
||||
Super-lowlevel profiling of the interpreter. When enabled, the sys module grows
|
||||
a new function:
|
||||
|
||||
settscdump(bool)
|
||||
If true, tell the Python interpreter to dump VM measurements to stderr. If
|
||||
false, turn off dump. The measurements are based on the processor's
|
||||
time-stamp counter.
|
||||
|
||||
This build option requires a small amount of platform specific code. Currently
|
||||
this code is present for linux/x86 and any PowerPC platform that uses GCC
|
||||
(i.e. OS X and linux/ppc).
|
||||
|
||||
On the PowerPC the rate at which the time base register is incremented is not
|
||||
defined by the architecture specification, so you'll need to find the manual for
|
||||
your specific processor. For the 750CX, 750CXe and 750FX (all sold as the G3)
|
||||
we find:
|
||||
|
||||
The time base counter is clocked at a frequency that is one-fourth that of
|
||||
the bus clock.
|
||||
|
||||
This build is enabled by the --with-tsc flag to configure.
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string>#!/usr/bin/python
|
||||
"""Generate code to warn about a module's removal in Python 3.0.
|
||||
|
||||
XXX Not supported:
|
||||
- Module's in a package do not have their full name generated.
|
||||
- Package's __init__ module; should detect and use the package's name instead.
|
||||
|
||||
"""
|
||||
py_template = """from warnings import warnpy3k
|
||||
warnpy3k("the ${1:%s} module has been removed in Python 3.0", stacklevel=2)
|
||||
del warnpy3k$0"""
|
||||
|
||||
c_template = """
|
||||
if (PyErr_WarnPy3k("the ${1:%s} module has been removed in "
|
||||
"Python 3.0", 2) < 0)
|
||||
return;$0"""
|
||||
|
||||
|
||||
import imp
|
||||
import os
|
||||
|
||||
file_name = os.path.split(os.environ['TM_FILEPATH'])[1]
|
||||
|
||||
py_suffixes = reversed(sorted((suffix[0] for suffix in imp.get_suffixes() if suffix[2] == imp.PY_SOURCE), key=len))
|
||||
c_suffixes = reversed(sorted((os.path.splitext(suffix[0])[0] + '.c'
|
||||
for suffix in imp.get_suffixes() if suffix[2] == imp.C_EXTENSION), key=len))
|
||||
|
||||
pairings = ((py_suffixes, py_template), (c_suffixes, c_template))
|
||||
|
||||
def create_template(suffixes, template):
|
||||
for suffix in suffixes:
|
||||
if not file_name.endswith(suffix):
|
||||
continue
|
||||
module_name = file_name[:-len(suffix)]
|
||||
return template % module_name
|
||||
else:
|
||||
return None
|
||||
|
||||
for template in (create_template(*pair) for pair in pairings):
|
||||
if not template:
|
||||
continue
|
||||
print template,
|
||||
break
|
||||
else:
|
||||
print 'XXX Could not generate code.'</string>
|
||||
<key>input</key>
|
||||
<string>none</string>
|
||||
<key>name</key>
|
||||
<string>2 to 3 - Module Deletion</string>
|
||||
<key>output</key>
|
||||
<string>insertAsSnippet</string>
|
||||
<key>tabTrigger</key>
|
||||
<string>2to3moddel</string>
|
||||
<key>uuid</key>
|
||||
<string>9519C22B-6AB8-41A1-94F6-079E0B45C147</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string># XXX Leopard-specific unless have easy way to specific alternative Python executable.
|
||||
|
||||
cd $TM_PROJECT_DIRECTORY/Doc
|
||||
make html 2>&1 | pre
|
||||
|
||||
rescan_project</string>
|
||||
<key>input</key>
|
||||
<string>none</string>
|
||||
<key>name</key>
|
||||
<string>Build Docs</string>
|
||||
<key>output</key>
|
||||
<string>showAsHTML</string>
|
||||
<key>uuid</key>
|
||||
<string>6EF151E5-7149-4F82-8796-0CC40FE589FA</string>
|
||||
</dict>
|
||||
</plist>
|
||||
25
Misc/TextMate/Python-Dev.tmbundle/Commands/Build.tmCommand
Normal file
25
Misc/TextMate/Python-Dev.tmbundle/Commands/Build.tmCommand
Normal file
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string># XXX TODO
|
||||
# - Highlight any compiler warnings for Python code.
|
||||
# - Point out if compile failed.
|
||||
|
||||
cd $TM_PROJECT_DIRECTORY
|
||||
make -s -j2 2>&1 | pre
|
||||
|
||||
rescan_project</string>
|
||||
<key>input</key>
|
||||
<string>none</string>
|
||||
<key>name</key>
|
||||
<string>Build Python</string>
|
||||
<key>output</key>
|
||||
<string>showAsHTML</string>
|
||||
<key>uuid</key>
|
||||
<string>B545BB1B-A8E1-426C-B50A-426E78B96D38</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string>open "http://bugs.python.org/issue$(cat)"</string>
|
||||
<key>fallbackInput</key>
|
||||
<string>word</string>
|
||||
<key>input</key>
|
||||
<string>selection</string>
|
||||
<key>name</key>
|
||||
<string>Go to Issue</string>
|
||||
<key>output</key>
|
||||
<string>discard</string>
|
||||
<key>uuid</key>
|
||||
<string>FD25A8DC-22DC-4ED4-B222-B943C8A9117D</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string># Search order:
|
||||
# - Current project.
|
||||
# - TM_PYTHONDEV_DOCS.
|
||||
# - Online docs in development.
|
||||
|
||||
html_index=$TM_PROJECT_DIRECTORY/Doc/build/html/index.html
|
||||
if [[ -f $html_index ]]; then
|
||||
open $html_index
|
||||
elif [[ $TM_PYTHONDEV_DOCS ]]; then
|
||||
open $TM_PYTHONDEV_DOCS
|
||||
else
|
||||
open http://docs.python.org/dev/
|
||||
fi</string>
|
||||
<key>input</key>
|
||||
<string>none</string>
|
||||
<key>keyEquivalent</key>
|
||||
<string>@H</string>
|
||||
<key>name</key>
|
||||
<string>Open Docs</string>
|
||||
<key>output</key>
|
||||
<string>discard</string>
|
||||
<key>uuid</key>
|
||||
<string>BF336FFF-E14D-4BF1-A156-71CF768AC034</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>beforeRunningCommand</key>
|
||||
<string>nop</string>
|
||||
<key>command</key>
|
||||
<string># XXX Worth supporting using a local copy?
|
||||
|
||||
# Dumb luck that an unrecognized number leads to a 0 being used.
|
||||
open `printf "http://www.python.org/dev/peps/pep-%04d" $(cat)`</string>
|
||||
<key>fallbackInput</key>
|
||||
<string>word</string>
|
||||
<key>input</key>
|
||||
<string>selection</string>
|
||||
<key>name</key>
|
||||
<string>Open PEP</string>
|
||||
<key>output</key>
|
||||
<string>discard</string>
|
||||
<key>uuid</key>
|
||||
<string>EDBB037F-AAE3-4512-863F-D9AA82C9E51E</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>content</key>
|
||||
<string>.. deprecated:: 2.6
|
||||
The :mod:\`${1}\` module has been deprecated for removal in Python 3.0.
|
||||
${0}</string>
|
||||
<key>name</key>
|
||||
<string>2 to 3 - Module Deletion (docs)</string>
|
||||
<key>tabTrigger</key>
|
||||
<string>2to3docdel</string>
|
||||
<key>uuid</key>
|
||||
<string>0568410D-EAF1-4AF3-B6DE-8AF133A91821</string>
|
||||
</dict>
|
||||
</plist>
|
||||
37
Misc/TextMate/Python-Dev.tmbundle/info.plist
Normal file
37
Misc/TextMate/Python-Dev.tmbundle/info.plist
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>mainMenu</key>
|
||||
<dict>
|
||||
<key>items</key>
|
||||
<array>
|
||||
<string>9519C22B-6AB8-41A1-94F6-079E0B45C147</string>
|
||||
<string>0568410D-EAF1-4AF3-B6DE-8AF133A91821</string>
|
||||
<string>------------------------------------</string>
|
||||
<string>B545BB1B-A8E1-426C-B50A-426E78B96D38</string>
|
||||
<string>6EF151E5-7149-4F82-8796-0CC40FE589FA</string>
|
||||
<string>------------------------------------</string>
|
||||
<string>BF336FFF-E14D-4BF1-A156-71CF768AC034</string>
|
||||
<string>FD25A8DC-22DC-4ED4-B222-B943C8A9117D</string>
|
||||
<string>EDBB037F-AAE3-4512-863F-D9AA82C9E51E</string>
|
||||
</array>
|
||||
<key>submenus</key>
|
||||
<dict/>
|
||||
</dict>
|
||||
<key>name</key>
|
||||
<string>Python-Dev</string>
|
||||
<key>ordering</key>
|
||||
<array>
|
||||
<string>9519C22B-6AB8-41A1-94F6-079E0B45C147</string>
|
||||
<string>0568410D-EAF1-4AF3-B6DE-8AF133A91821</string>
|
||||
<string>B545BB1B-A8E1-426C-B50A-426E78B96D38</string>
|
||||
<string>6EF151E5-7149-4F82-8796-0CC40FE589FA</string>
|
||||
<string>FD25A8DC-22DC-4ED4-B222-B943C8A9117D</string>
|
||||
<string>BF336FFF-E14D-4BF1-A156-71CF768AC034</string>
|
||||
<string>EDBB037F-AAE3-4512-863F-D9AA82C9E51E</string>
|
||||
</array>
|
||||
<key>uuid</key>
|
||||
<string>A932ECD1-D43A-4F57-B7FB-A1CEC3B65D20</string>
|
||||
</dict>
|
||||
</plist>
|
||||
149
Misc/Vim/python.vim
Normal file
149
Misc/Vim/python.vim
Normal file
@@ -0,0 +1,149 @@
|
||||
" Auto-generated Vim syntax file for Python (trunk: r80490).
|
||||
"
|
||||
" To use: copy or symlink to ~/.vim/syntax/python.vim
|
||||
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
if exists("python_highlight_all")
|
||||
let python_highlight_numbers = 1
|
||||
let python_highlight_builtins = 1
|
||||
let python_highlight_exceptions = 1
|
||||
let python_highlight_space_errors = 1
|
||||
endif
|
||||
|
||||
syn keyword pythonStatement as assert break continue del except exec finally
|
||||
syn keyword pythonStatement global lambda pass print raise return try with
|
||||
syn keyword pythonStatement yield
|
||||
|
||||
syn keyword pythonStatement def class nextgroup=pythonFunction skipwhite
|
||||
|
||||
syn match pythonFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
|
||||
|
||||
syn keyword pythonRepeat for while
|
||||
|
||||
syn keyword pythonConditional if elif else
|
||||
|
||||
syn keyword pythonOperator and in is not or
|
||||
|
||||
syn keyword pythonPreCondit import from
|
||||
|
||||
syn match pythonComment "#.*$" contains=pythonTodo
|
||||
|
||||
syn keyword pythonTodo TODO FIXME XXX contained
|
||||
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\='+ end=+'+ skip=+\\\\\|\\'+ contains=pythonEscape
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=pythonEscape
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\="""+ end=+"""+ contains=pythonEscape
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\='''+ end=+'''+ contains=pythonEscape
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\=[rR]'+ end=+'+ skip=+\\\\\|\\'+
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+
|
||||
syn region pythonString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+
|
||||
|
||||
syn match pythonEscape +\\[abfnrtv\'"\\]+ contained
|
||||
syn match pythonEscape "\\\o\{1,3}" contained
|
||||
syn match pythonEscape "\\x\x\{2}" contained
|
||||
syn match pythonEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
|
||||
|
||||
syn match pythonEscape "\\$"
|
||||
|
||||
|
||||
if exists("python_highlight_numbers")
|
||||
syn match pythonNumber "\<0x\x\+[Ll]\=\>"
|
||||
syn match pythonNumber "\<\d\+[LljJ]\=\>"
|
||||
syn match pythonNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
|
||||
syn match pythonNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
|
||||
syn match pythonNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
|
||||
|
||||
endif
|
||||
|
||||
|
||||
if exists("python_highlight_builtins")
|
||||
syn keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__
|
||||
syn keyword pythonBuiltin __import__ abs all any apply basestring bin bool
|
||||
syn keyword pythonBuiltin buffer bytearray bytes callable chr classmethod
|
||||
syn keyword pythonBuiltin cmp coerce compile complex copyright credits
|
||||
syn keyword pythonBuiltin delattr dict dir divmod enumerate eval execfile
|
||||
syn keyword pythonBuiltin exit file filter float format frozenset getattr
|
||||
syn keyword pythonBuiltin globals hasattr hash help hex id input int intern
|
||||
syn keyword pythonBuiltin isinstance issubclass iter len license list
|
||||
syn keyword pythonBuiltin locals long map max memoryview min next object
|
||||
syn keyword pythonBuiltin oct open ord pow print property quit range
|
||||
syn keyword pythonBuiltin raw_input reduce reload repr reversed round set
|
||||
syn keyword pythonBuiltin setattr slice sorted staticmethod str sum super
|
||||
syn keyword pythonBuiltin tuple type unichr unicode vars xrange zip
|
||||
|
||||
endif
|
||||
|
||||
|
||||
if exists("python_highlight_exceptions")
|
||||
syn keyword pythonException ArithmeticError AssertionError AttributeError
|
||||
syn keyword pythonException BaseException BufferError BytesWarning
|
||||
syn keyword pythonException DeprecationWarning EOFError EnvironmentError
|
||||
syn keyword pythonException Exception FloatingPointError FutureWarning
|
||||
syn keyword pythonException GeneratorExit IOError ImportError ImportWarning
|
||||
syn keyword pythonException IndentationError IndexError KeyError
|
||||
syn keyword pythonException KeyboardInterrupt LookupError MemoryError
|
||||
syn keyword pythonException NameError NotImplementedError OSError
|
||||
syn keyword pythonException OverflowError PendingDeprecationWarning
|
||||
syn keyword pythonException ReferenceError RuntimeError RuntimeWarning
|
||||
syn keyword pythonException StandardError StopIteration SyntaxError
|
||||
syn keyword pythonException SyntaxWarning SystemError SystemExit TabError
|
||||
syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError
|
||||
syn keyword pythonException UnicodeEncodeError UnicodeError
|
||||
syn keyword pythonException UnicodeTranslateError UnicodeWarning
|
||||
syn keyword pythonException UserWarning ValueError Warning
|
||||
syn keyword pythonException ZeroDivisionError
|
||||
|
||||
endif
|
||||
|
||||
|
||||
if exists("python_highlight_space_errors")
|
||||
syn match pythonSpaceError display excludenl "\S\s\+$"ms=s+1
|
||||
syn match pythonSpaceError display " \+\t"
|
||||
syn match pythonSpaceError display "\t\+ "
|
||||
|
||||
endif
|
||||
|
||||
|
||||
hi def link pythonStatement Statement
|
||||
hi def link pythonStatement Statement
|
||||
hi def link pythonFunction Function
|
||||
hi def link pythonRepeat Repeat
|
||||
hi def link pythonConditional Conditional
|
||||
hi def link pythonOperator Operator
|
||||
hi def link pythonPreCondit PreCondit
|
||||
hi def link pythonComment Comment
|
||||
hi def link pythonTodo Todo
|
||||
hi def link pythonString String
|
||||
hi def link pythonEscape Special
|
||||
hi def link pythonEscape Special
|
||||
|
||||
if exists("python_highlight_numbers")
|
||||
hi def link pythonNumber Number
|
||||
endif
|
||||
|
||||
if exists("python_highlight_builtins")
|
||||
hi def link pythonBuiltin Function
|
||||
endif
|
||||
|
||||
if exists("python_highlight_exceptions")
|
||||
hi def link pythonException Exception
|
||||
endif
|
||||
|
||||
if exists("python_highlight_space_errors")
|
||||
hi def link pythonSpaceError Error
|
||||
endif
|
||||
|
||||
|
||||
" Uncomment the 'minlines' statement line and comment out the 'maxlines'
|
||||
" statement line; changes behaviour to look at least 2000 lines previously for
|
||||
" syntax matches instead of at most 200 lines
|
||||
syn sync match pythonSync grouphere NONE "):$"
|
||||
syn sync maxlines=200
|
||||
"syn sync minlines=2000
|
||||
|
||||
let b:current_syntax = "python"
|
||||
62
Misc/Vim/syntax_test.py
Normal file
62
Misc/Vim/syntax_test.py
Normal file
@@ -0,0 +1,62 @@
|
||||
"""Test file for syntax highlighting of editors.
|
||||
|
||||
Meant to cover a wide range of different types of statements and expressions.
|
||||
Not necessarily sensical or comprehensive (assume that if one exception is
|
||||
highlighted that all are, for instance).
|
||||
|
||||
Extraneous trailing whitespace can't be tested because of svn pre-commit hook
|
||||
checks for such things.
|
||||
|
||||
"""
|
||||
# Comment
|
||||
# OPTIONAL: XXX catch your attention
|
||||
|
||||
# Statements
|
||||
from __future__ import with_statement # Import
|
||||
from sys import path as thing
|
||||
assert True # keyword
|
||||
def foo(): # function definition
|
||||
return []
|
||||
class Bar(object): # Class definition
|
||||
def __enter__(self):
|
||||
pass
|
||||
def __exit__(self, *args):
|
||||
pass
|
||||
foo() # UNCOLOURED: function call
|
||||
while False: # 'while'
|
||||
continue
|
||||
for x in foo(): # 'for'
|
||||
break
|
||||
with Bar() as stuff:
|
||||
pass
|
||||
if False: pass # 'if'
|
||||
elif False: pass
|
||||
else: pass
|
||||
|
||||
# Constants
|
||||
'single-quote', u'unicode' # Strings of all kinds; prefixes not highlighted
|
||||
"double-quote"
|
||||
"""triple double-quote"""
|
||||
'''triple single-quote'''
|
||||
r'raw'
|
||||
ur'unicode raw'
|
||||
'escape\n'
|
||||
'\04' # octal
|
||||
'\xFF' # hex
|
||||
'\u1111' # unicode character
|
||||
1 # Integral
|
||||
1L
|
||||
1.0 # Float
|
||||
.1
|
||||
1+2j # Complex
|
||||
|
||||
# Expressions
|
||||
1 and 2 or 3 # Boolean operators
|
||||
2 < 3 # UNCOLOURED: comparison operators
|
||||
spam = 42 # UNCOLOURED: assignment
|
||||
2 + 3 # UNCOLOURED: number operators
|
||||
[] # UNCOLOURED: list
|
||||
{} # UNCOLOURED: dict
|
||||
(1,) # UNCOLOURED: tuple
|
||||
all # Built-in functions
|
||||
GeneratorExit # Exceptions
|
||||
227
Misc/Vim/vim_syntax.py
Normal file
227
Misc/Vim/vim_syntax.py
Normal file
@@ -0,0 +1,227 @@
|
||||
from __future__ import with_statement
|
||||
|
||||
import keyword
|
||||
import exceptions
|
||||
import __builtin__
|
||||
from string import Template
|
||||
from sys import subversion
|
||||
|
||||
comment_header = '''" Auto-generated Vim syntax file for Python (%s: r%s).
|
||||
"
|
||||
" To use: copy or symlink to ~/.vim/syntax/python.vim'''
|
||||
|
||||
statement_header = """
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif"""
|
||||
|
||||
statement_footer = '''
|
||||
" Uncomment the 'minlines' statement line and comment out the 'maxlines'
|
||||
" statement line; changes behaviour to look at least 2000 lines previously for
|
||||
" syntax matches instead of at most 200 lines
|
||||
syn sync match pythonSync grouphere NONE "):$"
|
||||
syn sync maxlines=200
|
||||
"syn sync minlines=2000
|
||||
|
||||
let b:current_syntax = "python"'''
|
||||
|
||||
looping = ('for', 'while')
|
||||
conditionals = ('if', 'elif', 'else')
|
||||
boolean_ops = ('and', 'in', 'is', 'not', 'or')
|
||||
import_stmts = ('import', 'from')
|
||||
object_defs = ('def', 'class')
|
||||
|
||||
exception_names = sorted(exc for exc in dir(exceptions)
|
||||
if not exc.startswith('__'))
|
||||
|
||||
# Need to include functions that start with '__' (e.g., __import__), but
|
||||
# nothing that comes with modules (e.g., __name__), so just exclude anything in
|
||||
# the 'exceptions' module since we want to ignore exceptions *and* what any
|
||||
# module would have
|
||||
builtin_names = sorted(builtin for builtin in dir(__builtin__)
|
||||
if builtin not in dir(exceptions))
|
||||
|
||||
escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"',
|
||||
r'"\(\\u\x\{4}\|\\U\x\{8}\)"', r'"\\$"')
|
||||
|
||||
todos = ("TODO", "FIXME", "XXX")
|
||||
|
||||
# XXX codify?
|
||||
numbers = (r'"\<0x\x\+[Ll]\=\>"', r'"\<\d\+[LljJ]\=\>"',
|
||||
'"\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"',
|
||||
'"\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"',
|
||||
'"\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"')
|
||||
|
||||
contained = lambda x: "%s contained" % x
|
||||
|
||||
def str_regexes():
|
||||
"""Generator to yield various combinations of strings regexes"""
|
||||
regex_template = Template('matchgroup=Normal ' +
|
||||
'start=+[uU]\=${raw}${sep}+ ' +
|
||||
'end=+${sep}+ ' +
|
||||
'${skip} ' +
|
||||
'${contains}')
|
||||
skip_regex = Template(r'skip=+\\\\\|\\${sep}+')
|
||||
for raw in ('', '[rR]'):
|
||||
for separator in ("'", '"', '"""', "'''"):
|
||||
if len(separator) == 1:
|
||||
skip = skip_regex.substitute(sep=separator)
|
||||
else:
|
||||
skip = ''
|
||||
contains = 'contains=pythonEscape' if not raw else ''
|
||||
yield regex_template.substitute(raw=raw, sep=separator, skip=skip,
|
||||
contains = contains)
|
||||
|
||||
space_errors = (r'excludenl "\S\s\+$"ms=s+1', r'" \+\t"', r'"\t\+ "')
|
||||
|
||||
statements = (
|
||||
('',
|
||||
# XXX Might need to change pythonStatement since have
|
||||
# specific Repeat, Conditional, Operator, etc. for 'while',
|
||||
# etc.
|
||||
[("Statement", "pythonStatement", "keyword",
|
||||
(kw for kw in keyword.kwlist
|
||||
if kw not in (looping + conditionals + boolean_ops +
|
||||
import_stmts + object_defs))
|
||||
),
|
||||
("Statement", "pythonStatement", "keyword",
|
||||
(' '.join(object_defs) +
|
||||
' nextgroup=pythonFunction skipwhite')),
|
||||
("Function","pythonFunction", "match",
|
||||
contained('"[a-zA-Z_][a-zA-Z0-9_]*"')),
|
||||
("Repeat", "pythonRepeat", "keyword", looping),
|
||||
("Conditional", "pythonConditional", "keyword",
|
||||
conditionals),
|
||||
("Operator", "pythonOperator", "keyword", boolean_ops),
|
||||
("PreCondit", "pythonPreCondit", "keyword", import_stmts),
|
||||
("Comment", "pythonComment", "match",
|
||||
'"#.*$" contains=pythonTodo'),
|
||||
("Todo", "pythonTodo", "keyword",
|
||||
contained(' '.join(todos))),
|
||||
("String", "pythonString", "region", str_regexes()),
|
||||
("Special", "pythonEscape", "match",
|
||||
(contained(esc) for esc in escapes
|
||||
if not '$' in esc)),
|
||||
("Special", "pythonEscape", "match", r'"\\$"'),
|
||||
]
|
||||
),
|
||||
("python_highlight_numbers",
|
||||
[("Number", "pythonNumber", "match", numbers)]
|
||||
),
|
||||
("python_highlight_builtins",
|
||||
[("Function", "pythonBuiltin", "keyword", builtin_names)]
|
||||
),
|
||||
("python_highlight_exceptions",
|
||||
[("Exception", "pythonException", "keyword",
|
||||
exception_names)]
|
||||
),
|
||||
("python_highlight_space_errors",
|
||||
[("Error", "pythonSpaceError", "match",
|
||||
("display " + err for err in space_errors))]
|
||||
)
|
||||
)
|
||||
|
||||
def syn_prefix(type_, kind):
|
||||
return 'syn %s %s ' % (type_, kind)
|
||||
|
||||
def fill_stmt(iterable, fill_len):
|
||||
"""Yield a string that fills at most fill_len characters with strings
|
||||
returned by 'iterable' and separated by a space"""
|
||||
# Deal with trailing char to handle ' '.join() calculation
|
||||
fill_len += 1
|
||||
overflow = None
|
||||
it = iter(iterable)
|
||||
while True:
|
||||
buffer_ = []
|
||||
total_len = 0
|
||||
if overflow:
|
||||
buffer_.append(overflow)
|
||||
total_len += len(overflow) + 1
|
||||
overflow = None
|
||||
while total_len < fill_len:
|
||||
try:
|
||||
new_item = it.next()
|
||||
buffer_.append(new_item)
|
||||
total_len += len(new_item) + 1
|
||||
except StopIteration:
|
||||
if buffer_:
|
||||
break
|
||||
if overflow:
|
||||
yield overflow
|
||||
return
|
||||
if total_len > fill_len:
|
||||
overflow = buffer_.pop()
|
||||
total_len -= len(overflow) - 1
|
||||
ret = ' '.join(buffer_)
|
||||
assert len(ret) <= fill_len
|
||||
yield ret
|
||||
|
||||
FILL = 80
|
||||
|
||||
def main(file_path):
|
||||
with open(file_path, 'w') as FILE:
|
||||
# Comment for file
|
||||
print>>FILE, comment_header % subversion[1:]
|
||||
print>>FILE, ''
|
||||
# Statements at start of file
|
||||
print>>FILE, statement_header
|
||||
print>>FILE, ''
|
||||
# Generate case for python_highlight_all
|
||||
print>>FILE, 'if exists("python_highlight_all")'
|
||||
for statement_var, statement_parts in statements:
|
||||
if statement_var:
|
||||
print>>FILE, ' let %s = 1' % statement_var
|
||||
else:
|
||||
print>>FILE, 'endif'
|
||||
print>>FILE, ''
|
||||
# Generate Python groups
|
||||
for statement_var, statement_parts in statements:
|
||||
if statement_var:
|
||||
print>>FILE, 'if exists("%s")' % statement_var
|
||||
indent = ' '
|
||||
else:
|
||||
indent = ''
|
||||
for colour_group, group, type_, arguments in statement_parts:
|
||||
if not isinstance(arguments, basestring):
|
||||
prefix = syn_prefix(type_, group)
|
||||
if type_ == 'keyword':
|
||||
stmt_iter = fill_stmt(arguments,
|
||||
FILL - len(prefix) - len(indent))
|
||||
try:
|
||||
while True:
|
||||
print>>FILE, indent + prefix + stmt_iter.next()
|
||||
except StopIteration:
|
||||
print>>FILE, ''
|
||||
else:
|
||||
for argument in arguments:
|
||||
print>>FILE, indent + prefix + argument
|
||||
else:
|
||||
print>>FILE, ''
|
||||
|
||||
else:
|
||||
print>>FILE, indent + syn_prefix(type_, group) + arguments
|
||||
print>>FILE, ''
|
||||
else:
|
||||
if statement_var:
|
||||
print>>FILE, 'endif'
|
||||
print>>FILE, ''
|
||||
print>>FILE, ''
|
||||
# Associating Python group with Vim colour group
|
||||
for statement_var, statement_parts in statements:
|
||||
if statement_var:
|
||||
print>>FILE, ' if exists("%s")' % statement_var
|
||||
indent = ' '
|
||||
else:
|
||||
indent = ' '
|
||||
for colour_group, group, type_, arguments in statement_parts:
|
||||
print>>FILE, (indent + "hi def link %s %s" %
|
||||
(group, colour_group))
|
||||
else:
|
||||
if statement_var:
|
||||
print>>FILE, ' endif'
|
||||
print>>FILE, ''
|
||||
# Statements at the end of the file
|
||||
print>>FILE, statement_footer
|
||||
|
||||
if __name__ == '__main__':
|
||||
main("python.vim")
|
||||
87
Misc/Vim/vimrc
Normal file
87
Misc/Vim/vimrc
Normal file
@@ -0,0 +1,87 @@
|
||||
" vimrc file for following the coding standards specified in PEP 7 & 8.
|
||||
"
|
||||
" To use this file, source it in your own personal .vimrc file (``source
|
||||
" <filename>``) or, if you don't have a .vimrc file, you can just symlink to it
|
||||
" (``ln -s <this file> ~/.vimrc``). All options are protected by autocmds
|
||||
" (read below for an explanation of the command) so blind sourcing of this file
|
||||
" is safe and will not affect your settings for non-Python or non-C files.
|
||||
"
|
||||
"
|
||||
" All setting are protected by 'au' ('autocmd') statements. Only files ending
|
||||
" in .py or .pyw will trigger the Python settings while files ending in *.c or
|
||||
" *.h will trigger the C settings. This makes the file "safe" in terms of only
|
||||
" adjusting settings for Python and C files.
|
||||
"
|
||||
" Only basic settings needed to enforce the style guidelines are set.
|
||||
" Some suggested options are listed but commented out at the end of this file.
|
||||
|
||||
" Number of spaces that a pre-existing tab is equal to.
|
||||
" For the amount of space used for a new tab use shiftwidth.
|
||||
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=8
|
||||
|
||||
" What to use for an indent.
|
||||
" This will affect Ctrl-T and 'autoindent'.
|
||||
" Python: 4 spaces
|
||||
" C: tabs (pre-existing files) or 4 spaces (new files)
|
||||
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
|
||||
au BufRead,BufNewFile *.py,*.pyw set expandtab
|
||||
fu Select_c_style()
|
||||
if search('^\t', 'n', 150)
|
||||
set shiftwidth=8
|
||||
set noexpandtab
|
||||
el
|
||||
set shiftwidth=4
|
||||
set expandtab
|
||||
en
|
||||
endf
|
||||
au BufRead,BufNewFile *.c,*.h call Select_c_style()
|
||||
au BufRead,BufNewFile Makefile* set noexpandtab
|
||||
|
||||
" Use the below highlight group when displaying bad whitespace is desired.
|
||||
highlight BadWhitespace ctermbg=red guibg=red
|
||||
|
||||
" Display tabs at the beginning of a line in Python mode as bad.
|
||||
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
|
||||
" Make trailing whitespace be flagged as bad.
|
||||
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
|
||||
|
||||
" Wrap text after a certain number of characters
|
||||
" Python: 79
|
||||
" C: 79
|
||||
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set textwidth=79
|
||||
|
||||
" Turn off settings in 'formatoptions' relating to comment formatting.
|
||||
" - c : do not automatically insert the comment leader when wrapping based on
|
||||
" 'textwidth'
|
||||
" - o : do not insert the comment leader when using 'o' or 'O' from command mode
|
||||
" - r : do not insert the comment leader when hitting <Enter> in insert mode
|
||||
" Python: not needed
|
||||
" C: prevents insertion of '*' at the beginning of every line in a comment
|
||||
au BufRead,BufNewFile *.c,*.h set formatoptions-=c formatoptions-=o formatoptions-=r
|
||||
|
||||
" Use UNIX (\n) line endings.
|
||||
" Only used for new files so as to not force existing files to change their
|
||||
" line endings.
|
||||
" Python: yes
|
||||
" C: yes
|
||||
au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
|
||||
|
||||
|
||||
" ----------------------------------------------------------------------------
|
||||
" The following section contains suggested settings. While in no way required
|
||||
" to meet coding standards, they are helpful.
|
||||
|
||||
" Set the default file encoding to UTF-8: ``set encoding=utf-8``
|
||||
|
||||
" Puts a marker at the beginning of the file to differentiate between UTF and
|
||||
" UCS encoding (WARNING: can trick shells into thinking a text file is actually
|
||||
" a binary file when executing the text file): ``set bomb``
|
||||
|
||||
" For full syntax highlighting:
|
||||
"``let python_highlight_all=1``
|
||||
"``syntax on``
|
||||
|
||||
" Automatically indent based on file type: ``filetype indent on``
|
||||
" Keep indentation level from previous line: ``set autoindent``
|
||||
|
||||
" Folding based on indentation: ``set foldmethod=indent``
|
||||
2273
Misc/cheatsheet
Normal file
2273
Misc/cheatsheet
Normal file
File diff suppressed because it is too large
Load Diff
346
Misc/developers.txt
Normal file
346
Misc/developers.txt
Normal file
@@ -0,0 +1,346 @@
|
||||
Developer Log
|
||||
=============
|
||||
|
||||
This file is a running log of developers given permissions on SourceForge.
|
||||
|
||||
The purpose is to provide some institutional memory of who was given access
|
||||
and why.
|
||||
|
||||
The first entry starts in April 2005. In keeping with the style of
|
||||
Misc/NEWS, newer entries should be added to the top. Any markup should
|
||||
be in the form of ReST. Entries should include the initials of the
|
||||
project admin who made the change or granted access. Feel free to revise
|
||||
the format to accommodate documentation needs as they arise.
|
||||
|
||||
Note, when giving new commit permissions, be sure to get a contributor
|
||||
agreement from the committer. See http://www.python.org/psf/contrib/
|
||||
for details. When the agreement is signed, please note it in this log.
|
||||
|
||||
This file is encoded in UTF-8. If the usual form for a name is not in
|
||||
a Latin or extended Latin alphabet, make sure to include an ASCII
|
||||
transliteration too.
|
||||
|
||||
Permissions History
|
||||
-------------------
|
||||
|
||||
- David Malcolm was given commit access on Oct 27 2010 by GFB,
|
||||
at recommendation by Antoine Pitrou and Raymond Hettinger.
|
||||
|
||||
- Tal Einat was given commit access on Oct 4 2010 by MvL,
|
||||
for improving IDLE.
|
||||
|
||||
- Łukasz Langa was given commit access on Sep 08 2010 by GFB,
|
||||
at suggestion of Antoine Pitrou, for general bug fixing.
|
||||
|
||||
- Daniel Stutzbach was given commit access on Aug 22 2010 by MvL,
|
||||
for general bug fixing.
|
||||
|
||||
- Ask Solem was given commit access on Aug 17 2010 by MvL,
|
||||
on recommendation by Jesse Noller, for work on the multiprocessing
|
||||
library.
|
||||
|
||||
- George Boutsioukis was given commit access on Aug 10 2010
|
||||
by MvL, for work on 2to3.
|
||||
|
||||
- Éric Araujo was given commit access on Aug 10 2010 by BAC,
|
||||
at suggestion of Tarek Ziadé.
|
||||
|
||||
- Terry Reedy was given commit access on Aug 04 2010 by MvL,
|
||||
at suggestion of Nick Coghlan.
|
||||
|
||||
- Brian Quinlan was given commit access on Jul 26 2010 by GFB,
|
||||
for work related to PEP 3148.
|
||||
|
||||
- Reid Kleckner was given commit access on Jul 11 2010 by GFB,
|
||||
for work on the py3k-jit branch, at suggestion of the Unladen
|
||||
Swallow team.
|
||||
|
||||
- Alexander Belopolsky was given commit access on May 25 2010
|
||||
by MvL at suggestion of Mark Dickinson.
|
||||
|
||||
- Tim Golden was given commit access on April 21 2010 by MvL,
|
||||
at suggestion of Michael Foord.
|
||||
|
||||
- Giampaolo Rodolà was given commit access on April 17 2010 by
|
||||
MvL, at suggestion of R. David Murray.
|
||||
|
||||
- Jean-Paul Calderone was given commit access on April 6 2010 by
|
||||
GFB, at suggestion of Michael Foord and others.
|
||||
|
||||
- Brian Curtin was given commit access on March 24 2010 by MvL.
|
||||
|
||||
- Florent Xicluna was given commit access on February 25 2010 by
|
||||
MvL, based on Antoine Pitrou's recommendation.
|
||||
|
||||
- Dino Viehland was given SVN access on February 23 2010 by Brett
|
||||
Cannon, for backporting tests from IronPython.
|
||||
|
||||
- Larry Hastings was given SVN access on February 22 2010 by
|
||||
Andrew Kuchling, based on Brett Cannon's recommendation.
|
||||
|
||||
- Victor Stinner was given SVN access on January 30 2010 by MvL,
|
||||
at recommendation by Mark Dickinson and Amaury Forgeot d'Arc.
|
||||
|
||||
- Stefan Krah was given SVN access on January 5 2010 by GFB, at
|
||||
suggestion of Mark Dickinson, for work on the decimal module.
|
||||
|
||||
- Doug Hellmann was given SVN access on September 19 2009 by GFB, at
|
||||
suggestion of Jesse Noller, for documentation work.
|
||||
|
||||
- Ezio Melotti was given SVN access on June 7 2009 by GFB, for work on and
|
||||
fixes to the documentation.
|
||||
|
||||
- Paul Kippes was given commit privileges at PyCon 2009 by BAC to work on 3to2.
|
||||
|
||||
- Ron DuPlain was given commit privileges at PyCon 2009 by BAC to work on 3to2.
|
||||
|
||||
- Several developers of alternative Python implementations where
|
||||
given access for test suite and library adaptions by MvL:
|
||||
Allison Randal (Parrot), Michael Foord (IronPython),
|
||||
Jim Baker, Philip Jenvey, and Frank Wierzbicki (all Jython).
|
||||
|
||||
- R. David Murray was given SVN access on March 30 2009 by MvL, after
|
||||
recommendation by BAC.
|
||||
|
||||
- Chris Withers was given SVN access on March 8 2009 by MvL,
|
||||
after recommendation by GvR.
|
||||
|
||||
- Tarek Ziadé was given SVN access on December 21 2008 by NCN,
|
||||
for maintenance of distutils.
|
||||
|
||||
- Hirokazu Yamamoto was given SVN access on August 12 2008 by MvL,
|
||||
for contributions to the Windows build.
|
||||
|
||||
- Antoine Pitrou was given SVN access on July 16 2008, by recommendation
|
||||
from GvR, for general contributions to Python.
|
||||
|
||||
- Jesse Noller was given SVN access on 16 June 2008 by GFB,
|
||||
for work on the multiprocessing module.
|
||||
|
||||
- Gregor Lingl was given SVN access on 10 June 2008 by MvL,
|
||||
for work on the turtle module.
|
||||
|
||||
- Robert Schuppenies was given SVN access on 21 May 2008 by MvL,
|
||||
for GSoC contributions.
|
||||
|
||||
- Rodrigo Bernardo Pimentel was given SVN access on 29 April 2008 by MvL,
|
||||
for GSoC contributions.
|
||||
|
||||
- Heiko Weinen was given SVN access on 29 April 2008 by MvL,
|
||||
for GSoC contributions.
|
||||
|
||||
- Jesus Cea was given SVN access on 24 April 2008 by MvL,
|
||||
for maintenance of bsddb.
|
||||
|
||||
- Guilherme Polo was given SVN access on 24 April 2008 by MvL,
|
||||
for GSoC contributions.
|
||||
|
||||
- Thomas Lee was given SVN access on 21 April 2008 by NCN,
|
||||
for work on branches (ast/optimizer related).
|
||||
|
||||
- Jeroen Ruigrok van der Werven was given SVN access on 12 April 2008
|
||||
by GFB, for documentation work.
|
||||
|
||||
- Josiah Carlson was given SVN access on 26 March 2008 by GFB,
|
||||
for work on asyncore/asynchat.
|
||||
|
||||
- Benjamin Peterson was given SVN access on 25 March 2008 by GFB,
|
||||
for bug triage work.
|
||||
|
||||
- Jerry Seutter was given SVN access on 20 March 2008 by BAC, for
|
||||
general contributions to Python.
|
||||
|
||||
- Jeff Rush was given SVN access on 18 March 2008 by AMK, for Distutils work.
|
||||
|
||||
- David Wolever was given SVN access on 17 March 2008 by MvL,
|
||||
for 2to3 work.
|
||||
|
||||
- Trent Nelson was given SVN access on 17 March 2008 by MvL,
|
||||
for general contributions to Python.
|
||||
|
||||
- Mark Dickinson was given SVN access on 6 January 2008 by Facundo
|
||||
Batista for his work on mathematics and number related issues.
|
||||
|
||||
- Amaury Forgeot d'Arc was given SVN access on 9 November 2007 by MvL,
|
||||
for general contributions to Python.
|
||||
|
||||
- Christian Heimes was given SVN access on 31 October 2007 by MvL,
|
||||
for general contributions to Python.
|
||||
|
||||
- Chris Monson was given SVN access on 20 October 2007 by NCN,
|
||||
for his work on editing PEPs.
|
||||
|
||||
- Bill Janssen was given SVN access on 28 August 2007 by NCN,
|
||||
for his work on the SSL module and other things related to (SSL) sockets.
|
||||
|
||||
- Jeffrey Yasskin was given SVN access on 9 August 2007 by NCN,
|
||||
for his work on PEPs and other general patches.
|
||||
|
||||
- Mark Summerfield was given SVN access on 1 August 2007 by GFB,
|
||||
for work on documentation.
|
||||
|
||||
- Armin Ronacher was given SVN access on 23 July 2007 by GFB,
|
||||
for work on the documentation toolset. He now maintains the
|
||||
ast module.
|
||||
|
||||
- Senthil Kumaran was given SVN access on 16 June 2007 by MvL,
|
||||
for his Summer-of-Code project, mentored by Skip Montanaro.
|
||||
|
||||
- Alexandre Vassalotti was given SVN access on 21 May 2007 by MvL,
|
||||
for his Summer-of-Code project, mentored by Brett Cannon.
|
||||
|
||||
- Travis Oliphant was given SVN access on 17 Apr 2007 by MvL,
|
||||
for implementing the extended buffer protocol.
|
||||
|
||||
- Ziga Seilnacht was given SVN access on 09 Mar 2007 by MvL,
|
||||
for general maintenance.
|
||||
|
||||
- Pete Shinners was given SVN access on 04 Mar 2007 by NCN,
|
||||
for PEP 3101 work in the sandbox.
|
||||
|
||||
- Pat Maupin and Eric V. Smith were given SVN access on 28 Feb 2007 by NCN,
|
||||
for PEP 3101 work in the sandbox.
|
||||
|
||||
- Steven Bethard (SF name "bediviere") added to the SourceForge Python
|
||||
project 26 Feb 2007, by NCN, as a tracker tech.
|
||||
|
||||
- Josiah Carlson (SF name "josiahcarlson") added to the SourceForge Python
|
||||
project 06 Jan 2007, by NCN, as a tracker tech. He will maintain asyncore.
|
||||
|
||||
- Collin Winter was given SVN access on 05 Jan 2007 by NCN, for PEP
|
||||
update access.
|
||||
|
||||
- Lars Gustaebel was given SVN access on 20 Dec 2006 by NCN, for tarfile.py
|
||||
related work.
|
||||
|
||||
- 2006 Summer of Code entries: SoC developers are expected to work
|
||||
primarily in nondist/sandbox or on a branch of their own, and will
|
||||
have their work reviewed before changes are accepted into the trunk.
|
||||
|
||||
- Matt Fleming was added on 25 May 2006 by AMK; he'll be working on
|
||||
enhancing the Python debugger.
|
||||
|
||||
- Jackilyn Hoxworth was added on 25 May 2006 by AMK; she'll be adding logging
|
||||
to the standard library.
|
||||
|
||||
- Mateusz Rukowicz was added on 30 May 2006 by AMK; he'll be
|
||||
translating the decimal module into C.
|
||||
|
||||
- SVN access granted to the "Need for Speed" Iceland sprint attendees,
|
||||
between May 17 and 21, 2006, by Tim Peters. All work is to be done
|
||||
in new sandbox projects or on new branches, with merging to the
|
||||
trunk as approved:
|
||||
|
||||
Andrew Dalke
|
||||
Christian Tismer
|
||||
Jack Diederich
|
||||
John Benediktsson
|
||||
Kristján V. Jónsson
|
||||
Martin Blais
|
||||
Richard Emslie
|
||||
Richard Jones
|
||||
Runar Petursson
|
||||
Steve Holden
|
||||
Richard M. Tew
|
||||
|
||||
- Steven Bethard was given SVN access on 27 Apr 2006 by DJG, for PEP
|
||||
update access.
|
||||
|
||||
- Talin was given SVN access on 27 Apr 2006 by DJG, for PEP update
|
||||
access.
|
||||
|
||||
- George Yoshida (SF name "quiver") added to the SourceForge Python
|
||||
project 14 Apr 2006, by Tim Peters, as a tracker admin. See
|
||||
contemporaneous python-checkins thread with the unlikely Subject:
|
||||
|
||||
r45329 - python/trunk/Doc/whatsnew/whatsnew25.tex
|
||||
|
||||
- Ronald Oussoren was given SVN access on 3 Mar 2006 by NCN, for Mac
|
||||
related work.
|
||||
|
||||
- Bob Ippolito was given SVN access on 2 Mar 2006 by NCN, for Mac
|
||||
related work.
|
||||
|
||||
- Nick Coghlan requested CVS access so he could update his PEP directly.
|
||||
Granted by GvR on 16 Oct 2005.
|
||||
|
||||
- Added two new developers for the Summer of Code project. 8 July 2005
|
||||
by RDH. Andrew Kuchling will be mentoring Gregory K Johnson for a
|
||||
project to enhance mailbox. Brett Cannon requested access for Flovis
|
||||
Bruynooghe (sirolf) to work on pstats, profile, and hotshot. Both users
|
||||
are expected to work primarily in nondist/sandbox and have their work
|
||||
reviewed before making updates to active code.
|
||||
|
||||
- Georg Brandl was given SF tracker permissions on 28 May 2005
|
||||
by RDH. Since the beginning of 2005, he has been active in discussions
|
||||
on python-dev and has submitted a dozen patch reviews. The permissions
|
||||
add the ability to change tracker status and to attach patches. On
|
||||
3 June 2005, this was expanded by RDH to include checkin permissions.
|
||||
|
||||
- Terry Reedy was given SF tracker permissions on 7 Apr 2005 by RDH.
|
||||
|
||||
- Nick Coghlan was given SF tracker permissions on 5 Apr 2005 by RDH.
|
||||
For several months, he has been active in reviewing and contributing
|
||||
patches. The added permissions give him greater flexibility in
|
||||
working with the tracker.
|
||||
|
||||
- Eric Price was made a developer on 2 May 2003 by TGP. This was
|
||||
specifically to work on the new ``decimal`` package, which lived in
|
||||
``nondist/sandbox/decimal/`` at the time.
|
||||
|
||||
- Eric S. Raymond was made a developer on 2 Jul 2000 by TGP, for general
|
||||
library work. His request is archived here:
|
||||
|
||||
http://mail.python.org/pipermail/python-dev/2000-July/005314.html
|
||||
|
||||
|
||||
Permissions Dropped on Request
|
||||
------------------------------
|
||||
|
||||
- Roy Smith, Matt Fleming and Richard Emslie sent drop requests.
|
||||
4 Aug 2008 GFB
|
||||
|
||||
- Per note from Andrew Kuchling, the permissions for Gregory K Johnson
|
||||
and the Summer Of Code project are no longer needed. 4 Aug 2008 GFB
|
||||
|
||||
- Per note from Andrew Kuchling, the permissions for Gregory K Johnson
|
||||
and the Summer Of Code project are no longer needed. AMK will make
|
||||
any future checkins directly. 16 Oct 2005 RDH
|
||||
|
||||
- Johannes Gijsbers sent a drop request. 27 July 2005 RDH
|
||||
|
||||
- Flovis Bruynooghe sent a drop request. 14 July 2005 RDH
|
||||
|
||||
- Paul Prescod sent a drop request. 30 Apr 2005 RDH
|
||||
|
||||
- Finn Bock sent a drop request. 13 Apr 2005 RDH
|
||||
|
||||
- Eric Price sent a drop request. 10 Apr 2005 RDH
|
||||
|
||||
- Irmen de Jong requested dropping CVS access while keeping tracker
|
||||
access. 10 Apr 2005 RDH
|
||||
|
||||
- Moshe Zadka and Ken Manheimer sent drop requests. 8 Apr 2005 by RDH
|
||||
|
||||
- Steve Holden, Gerhard Haring, and David Cole sent email stating that
|
||||
they no longer use their access. 7 Apr 2005 RDH
|
||||
|
||||
|
||||
Permissions Dropped after Loss of Contact
|
||||
-----------------------------------------
|
||||
|
||||
- Several unsuccessful efforts were made to contact Charles G Waldman.
|
||||
Removed on 8 Apr 2005 by RDH.
|
||||
|
||||
|
||||
Initials of Project Admins
|
||||
--------------------------
|
||||
|
||||
TGP: Tim Peters
|
||||
GFB: Georg Brandl
|
||||
BAC: Brett Cannon
|
||||
NCN: Neal Norwitz
|
||||
DJG: David Goodger
|
||||
MvL: Martin v. Loewis
|
||||
GvR: Guido van Rossum
|
||||
RDH: Raymond Hettinger
|
||||
162
Misc/gdbinit
Normal file
162
Misc/gdbinit
Normal file
@@ -0,0 +1,162 @@
|
||||
# If you use the GNU debugger gdb to debug the Python C runtime, you
|
||||
# might find some of the following commands useful. Copy this to your
|
||||
# ~/.gdbinit file and it'll get loaded into gdb automatically when you
|
||||
# start it up. Then, at the gdb prompt you can do things like:
|
||||
#
|
||||
# (gdb) pyo apyobjectptr
|
||||
# <module 'foobar' (built-in)>
|
||||
# refcounts: 1
|
||||
# address : 84a7a2c
|
||||
# $1 = void
|
||||
# (gdb)
|
||||
#
|
||||
# NOTE: If you have gdb 7 or later, it supports debugging of Python directly
|
||||
# with embedded macros that you may find superior to what is in here.
|
||||
# See Tools/gdb/libpython.py and http://bugs.python.org/issue8032.
|
||||
|
||||
# Prints a representation of the object to stderr, along with the
|
||||
# number of reference counts it current has and the hex address the
|
||||
# object is allocated at. The argument must be a PyObject*
|
||||
define pyo
|
||||
# side effect of calling _PyObject_Dump is to dump the object's
|
||||
# info - assigning just prevents gdb from printing the
|
||||
# NULL return value
|
||||
set $_unused_void = _PyObject_Dump($arg0)
|
||||
end
|
||||
|
||||
# Prints a representation of the object to stderr, along with the
|
||||
# number of reference counts it current has and the hex address the
|
||||
# object is allocated at. The argument must be a PyGC_Head*
|
||||
define pyg
|
||||
print _PyGC_Dump($arg0)
|
||||
end
|
||||
|
||||
# print the local variables of the current frame
|
||||
define pylocals
|
||||
set $_i = 0
|
||||
while $_i < f->f_code->co_nlocals
|
||||
if f->f_localsplus + $_i != 0
|
||||
set $_names = co->co_varnames
|
||||
set $_name = PyString_AsString(PyTuple_GetItem($_names, $_i))
|
||||
printf "%s:\n", $_name
|
||||
pyo f->f_localsplus[$_i]
|
||||
end
|
||||
set $_i = $_i + 1
|
||||
end
|
||||
end
|
||||
|
||||
# A rewrite of the Python interpreter's line number calculator in GDB's
|
||||
# command language
|
||||
define lineno
|
||||
set $__continue = 1
|
||||
set $__co = f->f_code
|
||||
set $__lasti = f->f_lasti
|
||||
set $__sz = ((PyStringObject *)$__co->co_lnotab)->ob_size/2
|
||||
set $__p = (unsigned char *)((PyStringObject *)$__co->co_lnotab)->ob_sval
|
||||
set $__li = $__co->co_firstlineno
|
||||
set $__ad = 0
|
||||
while ($__sz-1 >= 0 && $__continue)
|
||||
set $__sz = $__sz - 1
|
||||
set $__ad = $__ad + *$__p
|
||||
set $__p = $__p + 1
|
||||
if ($__ad > $__lasti)
|
||||
set $__continue = 0
|
||||
else
|
||||
set $__li = $__li + *$__p
|
||||
set $__p = $__p + 1
|
||||
end
|
||||
end
|
||||
printf "%d", $__li
|
||||
end
|
||||
|
||||
# print the current frame - verbose
|
||||
define pyframev
|
||||
pyframe
|
||||
pylocals
|
||||
end
|
||||
|
||||
define pyframe
|
||||
set $__fn = (char *)((PyStringObject *)co->co_filename)->ob_sval
|
||||
set $__n = (char *)((PyStringObject *)co->co_name)->ob_sval
|
||||
printf "%s (", $__fn
|
||||
lineno
|
||||
printf "): %s\n", $__n
|
||||
### Uncomment these lines when using from within Emacs/XEmacs so it will
|
||||
### automatically track/display the current Python source line
|
||||
# printf "%c%c%s:", 032, 032, $__fn
|
||||
# lineno
|
||||
# printf ":1\n"
|
||||
end
|
||||
|
||||
### Use these at your own risk. It appears that a bug in gdb causes it
|
||||
### to crash in certain circumstances.
|
||||
|
||||
#define up
|
||||
# up-silently 1
|
||||
# printframe
|
||||
#end
|
||||
|
||||
#define down
|
||||
# down-silently 1
|
||||
# printframe
|
||||
#end
|
||||
|
||||
define printframe
|
||||
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
|
||||
pyframe
|
||||
else
|
||||
frame
|
||||
end
|
||||
end
|
||||
|
||||
# Here's a somewhat fragile way to print the entire Python stack from gdb.
|
||||
# It's fragile because the tests for the value of $pc depend on the layout
|
||||
# of specific functions in the C source code.
|
||||
|
||||
# Explanation of while and if tests: We want to pop up the stack until we
|
||||
# land in Py_Main (this is probably an incorrect assumption in an embedded
|
||||
# interpreter, but the test can be extended by an interested party). If
|
||||
# Py_Main <= $pc <= Py_GetArgcArv is true, $pc is in Py_Main(), so the while
|
||||
# tests succeeds as long as it's not true. In a similar fashion the if
|
||||
# statement tests to see if we are in PyEval_EvalFrameEx().
|
||||
|
||||
# Note: The name of the main interpreter function and the function which
|
||||
# follow it has changed over time. This version of pystack works with this
|
||||
# version of Python. If you try using it with older or newer versions of
|
||||
# the interpreter you may will have to change the functions you compare with
|
||||
# $pc.
|
||||
|
||||
# print the entire Python call stack
|
||||
define pystack
|
||||
while $pc < Py_Main || $pc > Py_GetArgcArgv
|
||||
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
|
||||
pyframe
|
||||
end
|
||||
up-silently 1
|
||||
end
|
||||
select-frame 0
|
||||
end
|
||||
|
||||
# print the entire Python call stack - verbose mode
|
||||
define pystackv
|
||||
while $pc < Py_Main || $pc > Py_GetArgcArgv
|
||||
if $pc > PyEval_EvalFrameEx && $pc < PyEval_EvalCodeEx
|
||||
pyframev
|
||||
end
|
||||
up-silently 1
|
||||
end
|
||||
select-frame 0
|
||||
end
|
||||
|
||||
# generally useful macro to print a Unicode string
|
||||
def pu
|
||||
set $uni = $arg0
|
||||
set $i = 0
|
||||
while (*$uni && $i++<100)
|
||||
if (*$uni < 0x80)
|
||||
print *(char*)$uni++
|
||||
else
|
||||
print /x *(short*)$uni++
|
||||
end
|
||||
end
|
||||
end
|
||||
24
Misc/indent.pro
Normal file
24
Misc/indent.pro
Normal file
@@ -0,0 +1,24 @@
|
||||
--blank-lines-after-declarations
|
||||
--blank-lines-after-procedures
|
||||
--braces-after-func-def-line
|
||||
--braces-on-if-line
|
||||
--braces-on-struct-decl-line
|
||||
--break-after-boolean-operator
|
||||
--comment-indentation25
|
||||
--comment-line-length79
|
||||
--continue-at-parentheses
|
||||
--dont-cuddle-do-while
|
||||
--dont-cuddle-else
|
||||
--indent-level4
|
||||
--line-length79
|
||||
--no-space-after-casts
|
||||
--no-space-after-function-call-names
|
||||
--no-space-after-parentheses
|
||||
--no-tabs
|
||||
--procnames-start-lines
|
||||
--space-after-for
|
||||
--space-after-if
|
||||
--space-after-while
|
||||
--swallow-optional-blank-lines
|
||||
-T PyCFunction
|
||||
-T PyObject
|
||||
319
Misc/maintainers.rst
Normal file
319
Misc/maintainers.rst
Normal file
@@ -0,0 +1,319 @@
|
||||
Maintainers Index
|
||||
=================
|
||||
|
||||
.. warning::
|
||||
|
||||
This document is out of date and replaced by another version in the
|
||||
developer's guide at http://docs.python.org/devguide/experts
|
||||
|
||||
This document has tables that list Python Modules, Tools, Platforms and
|
||||
Interest Areas and names for each item that indicate a maintainer or an
|
||||
expert in the field. This list is intended to be used by issue submitters,
|
||||
issue triage people, and other issue participants to find people to add to
|
||||
the nosy list or to contact directly by email for help and decisions on
|
||||
feature requests and bug fixes. People on this list may be asked to render
|
||||
final judgement on a feature or bug. If no active maintainer is listed for
|
||||
a given module, then questionable changes should go to python-dev, while
|
||||
any other issues can and should be decided by any committer.
|
||||
|
||||
Unless a name is followed by a '*', you should never assign an issue to
|
||||
that person, only make them nosy. Names followed by a '*' may be assigned
|
||||
issues involving the module or topic.
|
||||
|
||||
The Platform and Interest Area tables list broader fields in which various
|
||||
people have expertise. These people can also be contacted for help,
|
||||
opinions, and decisions when issues involve their areas.
|
||||
|
||||
If a listed maintainer does not respond to requests for comment for an
|
||||
extended period (three weeks or more), they should be marked as inactive
|
||||
in this list by placing the word 'inactive' in parenthesis behind their
|
||||
tracker id. They are of course free to remove that inactive mark at
|
||||
any time.
|
||||
|
||||
Committers should update these tables as their areas of expertise widen.
|
||||
New topics may be added to the Interest Area table at will.
|
||||
|
||||
The existence of this list is not meant to indicate that these people
|
||||
*must* be contacted for decisions; it is, rather, a resource to be used
|
||||
by non-committers to find responsible parties, and by committers who do
|
||||
not feel qualified to make a decision in a particular context.
|
||||
|
||||
See also `PEP 291`_ and `PEP 360`_ for information about certain modules
|
||||
with special rules.
|
||||
|
||||
.. _`PEP 291`: http://www.python.org/dev/peps/pep-0291/
|
||||
.. _`PEP 360`: http://www.python.org/dev/peps/pep-0360/
|
||||
|
||||
|
||||
================== ===========
|
||||
Module Maintainers
|
||||
================== ===========
|
||||
__builtin__
|
||||
__future__
|
||||
__main__ gvanrossum
|
||||
_dummy_thread brett.cannon
|
||||
_thread pitrou
|
||||
_winreg brian.curtin*, stutzbach
|
||||
abc
|
||||
aifc r.david.murray
|
||||
argparse bethard
|
||||
array
|
||||
ast
|
||||
asynchat josiahcarlson, giampaolo.rodola, stutzbach
|
||||
asyncore josiahcarlson, giampaolo.rodola, stutzbach
|
||||
atexit
|
||||
audioop
|
||||
base64
|
||||
BaseHTTPServer
|
||||
bdb
|
||||
binascii
|
||||
binhex
|
||||
bisect rhettinger
|
||||
bz2
|
||||
calendar rhettinger
|
||||
cgi
|
||||
CGIHTTPServer
|
||||
cgitb
|
||||
chunk
|
||||
cmath mark.dickinson
|
||||
cmd
|
||||
code
|
||||
codecs lemburg, doerwalter
|
||||
codeop
|
||||
collections rhettinger
|
||||
collections._abcoll rhettinger, stutzbach
|
||||
colorsys
|
||||
compileall
|
||||
ConfigParser lukasz.langa
|
||||
contextlib ncoghlan
|
||||
copy alexandre.vassalotti
|
||||
copy_reg alexandre.vassalotti
|
||||
cProfile
|
||||
crypt jafo*
|
||||
csv skip.montanaro
|
||||
ctypes theller
|
||||
curses
|
||||
datetime belopolsky
|
||||
dbm
|
||||
decimal facundobatista, rhettinger, mark.dickinson
|
||||
difflib tim_one (inactive)
|
||||
dis
|
||||
distutils tarek*, eric.araujo*
|
||||
doctest tim_one (inactive)
|
||||
dummy_threading brett.cannon
|
||||
email barry, r.david.murray*
|
||||
encodings lemburg, loewis
|
||||
errno
|
||||
exceptions
|
||||
fcntl
|
||||
filecmp
|
||||
fileinput
|
||||
fnmatch
|
||||
formatter
|
||||
fpectl
|
||||
fractions mark.dickinson, rhettinger
|
||||
ftplib giampaolo.rodola
|
||||
functools ncoghlan, rhettinger
|
||||
gc pitrou
|
||||
getopt
|
||||
getpass
|
||||
gettext loewis
|
||||
glob
|
||||
grp
|
||||
gzip
|
||||
hashlib
|
||||
heapq rhettinger, stutzbach
|
||||
hmac
|
||||
htmlentitydefs
|
||||
htmllib
|
||||
HTMLParser
|
||||
httplib
|
||||
idlelib kbk
|
||||
imaplib
|
||||
imghdr
|
||||
imp
|
||||
importlib brett.cannon
|
||||
inspect
|
||||
io pitrou, benjamin.peterson, stutzbach
|
||||
itertools rhettinger
|
||||
json bob.ippolito (inactive), rhettinger
|
||||
keyword
|
||||
lib2to3 benjamin.peterson
|
||||
linecache
|
||||
locale loewis, lemburg
|
||||
logging vinay.sajip
|
||||
macpath
|
||||
mailbox
|
||||
mailcap
|
||||
marshal
|
||||
math mark.dickinson, rhettinger, stutzbach
|
||||
mimetypes
|
||||
mmap
|
||||
modulefinder theller, jvr
|
||||
msilib loewis
|
||||
msvcrt
|
||||
multiprocessing jnoller
|
||||
netrc
|
||||
nis
|
||||
nntplib pitrou
|
||||
numbers
|
||||
operator
|
||||
optparse aronacher
|
||||
os loewis
|
||||
ossaudiodev
|
||||
parser
|
||||
pdb georg.brandl*
|
||||
pickle alexandre.vassalotti, pitrou
|
||||
pickletools alexandre.vassalotti
|
||||
pipes
|
||||
pkgutil
|
||||
platform lemburg
|
||||
plistlib
|
||||
poplib
|
||||
posix
|
||||
pprint fdrake
|
||||
profile georg.brandl
|
||||
pstats georg.brandl
|
||||
pty
|
||||
pwd
|
||||
py_compile
|
||||
pybench lemburg, pitrou
|
||||
pyclbr
|
||||
pydoc
|
||||
Queue rhettinger
|
||||
quopri
|
||||
random rhettinger
|
||||
re effbot (inactive), pitrou, ezio.melotti
|
||||
readline
|
||||
reprlib
|
||||
resource
|
||||
rlcompleter
|
||||
runpy ncoghlan
|
||||
sched
|
||||
select
|
||||
shelve
|
||||
shlex
|
||||
shutil tarek
|
||||
signal
|
||||
SimpleHTTPServer
|
||||
site
|
||||
smtpd
|
||||
smtplib
|
||||
sndhdr
|
||||
socket
|
||||
SocketServer
|
||||
spwd
|
||||
sqlite3 ghaering
|
||||
ssl janssen, pitrou, giampaolo.rodola
|
||||
stat
|
||||
string georg.brandl*
|
||||
stringprep
|
||||
struct mark.dickinson
|
||||
subprocess astrand (inactive)
|
||||
sunau
|
||||
symbol
|
||||
symtable benjamin.peterson
|
||||
sys
|
||||
sysconfig tarek
|
||||
syslog jafo*
|
||||
tabnanny tim_one (inactive)
|
||||
tarfile lars.gustaebel
|
||||
telnetlib
|
||||
tempfile georg.brandl
|
||||
termios
|
||||
test
|
||||
textwrap georg.brandl
|
||||
threading pitrou
|
||||
time belopolsky
|
||||
timeit georg.brandl
|
||||
Tkinter gpolo
|
||||
token georg.brandl
|
||||
tokenize
|
||||
trace belopolsky
|
||||
traceback georg.brandl*
|
||||
tty
|
||||
turtle gregorlingl
|
||||
types
|
||||
unicodedata loewis, lemburg, ezio.melotti
|
||||
unittest michael.foord, ezio.melotti
|
||||
urllib orsenthil
|
||||
uu
|
||||
uuid
|
||||
warnings brett.cannon
|
||||
wave
|
||||
weakref fdrake, pitrou
|
||||
webbrowser georg.brandl
|
||||
winsound effbot (inactive)
|
||||
wsgiref pje
|
||||
xdrlib
|
||||
xml.dom
|
||||
xml.dom.minidom
|
||||
xml.dom.pulldom
|
||||
xml.etree effbot (inactive)
|
||||
xml.parsers.expat
|
||||
xml.sax
|
||||
xml.sax.handler
|
||||
xml.sax.saxutils
|
||||
xml.sax.xmlreader
|
||||
xmlrpc loewis
|
||||
zipfile alanmcintyre
|
||||
zipimport
|
||||
zlib
|
||||
================== ===========
|
||||
|
||||
|
||||
================== ===========
|
||||
Tool Maintainers
|
||||
------------------ -----------
|
||||
pybench lemburg
|
||||
================== ===========
|
||||
|
||||
|
||||
================== ===========
|
||||
Platform Maintainers
|
||||
------------------ -----------
|
||||
AIX
|
||||
Cygwin jlt63, stutzbach
|
||||
FreeBSD
|
||||
HP-UX
|
||||
Linux
|
||||
Mac ronaldoussoren, ned.deily
|
||||
NetBSD1
|
||||
OS2/EMX aimacintyre
|
||||
Solaris
|
||||
Windows tim.golden, brian.curtin
|
||||
================== ===========
|
||||
|
||||
|
||||
================== ===========
|
||||
Interest Area Maintainers
|
||||
------------------ -----------
|
||||
algorithms
|
||||
ast/compiler ncoghlan, benjamin.peterson, brett.cannon, georg.brandl
|
||||
autoconf/makefiles
|
||||
bsd
|
||||
bug tracker ezio.melotti
|
||||
buildbots
|
||||
bytecode pitrou
|
||||
data formats mark.dickinson, georg.brandl
|
||||
database lemburg
|
||||
documentation georg.brandl, ezio.melotti
|
||||
GUI
|
||||
i18n lemburg
|
||||
import machinery brett.cannon, ncoghlan
|
||||
io pitrou, benjamin.peterson, stutzbach
|
||||
locale lemburg, loewis
|
||||
mathematics mark.dickinson, eric.smith, lemburg, stutzbach
|
||||
memory management tim_one, lemburg
|
||||
networking giampaolo.rodola
|
||||
packaging tarek, lemburg
|
||||
py3 transition benjamin.peterson
|
||||
release management tarek, lemburg, benjamin.peterson, barry, loewis,
|
||||
gvanrossum, anthonybaxter
|
||||
str.format eric.smith
|
||||
testing michael.foord, pitrou, giampaolo.rodola, ezio.melotti
|
||||
threads pitrou
|
||||
time and dates lemburg, belopolsky
|
||||
unicode lemburg, ezio.melotti, haypo
|
||||
version control
|
||||
================== ===========
|
||||
85
Misc/pymemcompat.h
Normal file
85
Misc/pymemcompat.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* The idea of this file is that you bundle it with your extension,
|
||||
#include it, program to Python 2.3's memory API and have your
|
||||
extension build with any version of Python from 1.5.2 through to
|
||||
2.3 (and hopefully beyond). */
|
||||
|
||||
#ifndef Py_PYMEMCOMPAT_H
|
||||
#define Py_PYMEMCOMPAT_H
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
/* There are three "families" of memory API: the "raw memory", "object
|
||||
memory" and "object" families. (This is ignoring the matter of the
|
||||
cycle collector, about which more is said below).
|
||||
|
||||
Raw Memory:
|
||||
|
||||
PyMem_Malloc, PyMem_Realloc, PyMem_Free
|
||||
|
||||
Object Memory:
|
||||
|
||||
PyObject_Malloc, PyObject_Realloc, PyObject_Free
|
||||
|
||||
Object:
|
||||
|
||||
PyObject_New, PyObject_NewVar, PyObject_Del
|
||||
|
||||
The raw memory and object memory allocators both mimic the
|
||||
malloc/realloc/free interface from ANSI C, but the object memory
|
||||
allocator can (and, since 2.3, does by default) use a different
|
||||
allocation strategy biased towards lots of "small" allocations.
|
||||
|
||||
The object family is used for allocating Python objects, and the
|
||||
initializers take care of some basic initialization (setting the
|
||||
refcount to 1 and filling out the ob_type field) as well as having
|
||||
a somewhat different interface.
|
||||
|
||||
Do not mix the families! E.g. do not allocate memory with
|
||||
PyMem_Malloc and free it with PyObject_Free. You may get away with
|
||||
it quite a lot of the time, but there *are* scenarios where this
|
||||
will break. You Have Been Warned.
|
||||
|
||||
Also, in many versions of Python there are an insane amount of
|
||||
memory interfaces to choose from. Use the ones described above. */
|
||||
|
||||
#if PY_VERSION_HEX < 0x01060000
|
||||
/* raw memory interface already present */
|
||||
|
||||
/* there is no object memory interface in 1.5.2 */
|
||||
#define PyObject_Malloc PyMem_Malloc
|
||||
#define PyObject_Realloc PyMem_Realloc
|
||||
#define PyObject_Free PyMem_Free
|
||||
|
||||
/* the object interface is there, but the names have changed */
|
||||
#define PyObject_New PyObject_NEW
|
||||
#define PyObject_NewVar PyObject_NEW_VAR
|
||||
#define PyObject_Del PyMem_Free
|
||||
#endif
|
||||
|
||||
/* If your object is a container you probably want to support the
|
||||
cycle collector, which was new in Python 2.0.
|
||||
|
||||
Unfortunately, the interface to the collector that was present in
|
||||
Python 2.0 and 2.1 proved to be tricky to use, and so changed in
|
||||
2.2 -- in a way that can't easily be papered over with macros.
|
||||
|
||||
This file contains macros that let you program to the 2.2 GC API.
|
||||
Your module will compile against any Python since version 1.5.2,
|
||||
but the type will only participate in the GC in versions 2.2 and
|
||||
up. Some work is still necessary on your part to only fill out the
|
||||
tp_traverse and tp_clear fields when they exist and set tp_flags
|
||||
appropriately.
|
||||
|
||||
It is possible to support both the 2.0 and 2.2 GC APIs, but it's
|
||||
not pretty and this comment block is too narrow to contain a
|
||||
description of what's required... */
|
||||
|
||||
#if PY_VERSION_HEX < 0x020200B1
|
||||
#define PyObject_GC_New PyObject_New
|
||||
#define PyObject_GC_NewVar PyObject_NewVar
|
||||
#define PyObject_GC_Del PyObject_Del
|
||||
#define PyObject_GC_Track(op)
|
||||
#define PyObject_GC_UnTrack(op)
|
||||
#endif
|
||||
|
||||
#endif /* !Py_PYMEMCOMPAT_H */
|
||||
58
Misc/python-config.in
Normal file
58
Misc/python-config.in
Normal file
@@ -0,0 +1,58 @@
|
||||
#!@EXENAME@
|
||||
|
||||
import sys
|
||||
import os
|
||||
import getopt
|
||||
from distutils import sysconfig
|
||||
|
||||
valid_opts = ['prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
|
||||
'ldflags', 'help']
|
||||
|
||||
def exit_with_usage(code=1):
|
||||
print >>sys.stderr, "Usage: %s [%s]" % (sys.argv[0],
|
||||
'|'.join('--'+opt for opt in valid_opts))
|
||||
sys.exit(code)
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
|
||||
except getopt.error:
|
||||
exit_with_usage()
|
||||
|
||||
if not opts:
|
||||
exit_with_usage()
|
||||
|
||||
pyver = sysconfig.get_config_var('VERSION')
|
||||
getvar = sysconfig.get_config_var
|
||||
|
||||
opt_flags = [flag for (flag, val) in opts]
|
||||
|
||||
if '--help' in opt_flags:
|
||||
exit_with_usage(code=0)
|
||||
|
||||
for opt in opt_flags:
|
||||
if opt == '--prefix':
|
||||
print sysconfig.PREFIX
|
||||
|
||||
elif opt == '--exec-prefix':
|
||||
print sysconfig.EXEC_PREFIX
|
||||
|
||||
elif opt in ('--includes', '--cflags'):
|
||||
flags = ['-I' + sysconfig.get_python_inc(),
|
||||
'-I' + sysconfig.get_python_inc(plat_specific=True)]
|
||||
if opt == '--cflags':
|
||||
flags.extend(getvar('CFLAGS').split())
|
||||
print ' '.join(flags)
|
||||
|
||||
elif opt in ('--libs', '--ldflags'):
|
||||
libs = ['-lpython' + pyver]
|
||||
libs += getvar('LIBS').split()
|
||||
libs += getvar('SYSLIBS').split()
|
||||
# add the prefix/lib/pythonX.Y/config dir, but only if there is no
|
||||
# shared library in prefix/lib/.
|
||||
if opt == '--ldflags':
|
||||
if not getvar('Py_ENABLE_SHARED'):
|
||||
libs.insert(0, '-L' + getvar('LIBPL'))
|
||||
if not getvar('PYTHONFRAMEWORK'):
|
||||
libs.extend(getvar('LINKFORSHARED').split())
|
||||
print ' '.join(libs)
|
||||
|
||||
13
Misc/python-wing3.wpr
Normal file
13
Misc/python-wing3.wpr
Normal file
@@ -0,0 +1,13 @@
|
||||
#!wing
|
||||
#!version=3.0
|
||||
##################################################################
|
||||
# Wing IDE project file #
|
||||
##################################################################
|
||||
[project attributes]
|
||||
proj.directory-list = [{'dirloc': loc('..'),
|
||||
'excludes': (),
|
||||
'filter': '*',
|
||||
'include_hidden': False,
|
||||
'recursive': True,
|
||||
'watch_for_changes': True}]
|
||||
proj.file-type = 'shared'
|
||||
16
Misc/python-wing4.wpr
Normal file
16
Misc/python-wing4.wpr
Normal file
@@ -0,0 +1,16 @@
|
||||
#!wing
|
||||
#!version=4.0
|
||||
##################################################################
|
||||
# Wing IDE project file #
|
||||
##################################################################
|
||||
[project attributes]
|
||||
proj.directory-list = [{'dirloc': loc('..'),
|
||||
'excludes': [u'.hg',
|
||||
u'Lib/__pycache__',
|
||||
u'Doc/build',
|
||||
u'build'],
|
||||
'filter': '*',
|
||||
'include_hidden': False,
|
||||
'recursive': True,
|
||||
'watch_for_changes': True}]
|
||||
proj.file-type = 'shared'
|
||||
472
Misc/python.man
Normal file
472
Misc/python.man
Normal file
@@ -0,0 +1,472 @@
|
||||
.TH PYTHON "1"
|
||||
|
||||
.\" To view this file while editing, run it through groff:
|
||||
.\" groff -Tascii -man python.man | less
|
||||
|
||||
.SH NAME
|
||||
python \- an interpreted, interactive, object-oriented programming language
|
||||
.SH SYNOPSIS
|
||||
.B python
|
||||
[
|
||||
.B \-B
|
||||
]
|
||||
[
|
||||
.B \-d
|
||||
]
|
||||
[
|
||||
.B \-E
|
||||
]
|
||||
[
|
||||
.B \-h
|
||||
]
|
||||
[
|
||||
.B \-i
|
||||
]
|
||||
[
|
||||
.B \-m
|
||||
.I module-name
|
||||
]
|
||||
.br
|
||||
[
|
||||
.B \-O
|
||||
]
|
||||
[
|
||||
.B \-OO
|
||||
]
|
||||
[
|
||||
.B \-R
|
||||
]
|
||||
[
|
||||
.B -Q
|
||||
.I argument
|
||||
]
|
||||
[
|
||||
.B \-s
|
||||
]
|
||||
[
|
||||
.B \-S
|
||||
]
|
||||
[
|
||||
.B \-t
|
||||
]
|
||||
[
|
||||
.B \-u
|
||||
]
|
||||
.br
|
||||
[
|
||||
.B \-v
|
||||
]
|
||||
[
|
||||
.B \-V
|
||||
]
|
||||
[
|
||||
.B \-W
|
||||
.I argument
|
||||
]
|
||||
[
|
||||
.B \-x
|
||||
]
|
||||
[
|
||||
.B \-3
|
||||
]
|
||||
[
|
||||
.B \-?
|
||||
]
|
||||
.br
|
||||
[
|
||||
.B \-c
|
||||
.I command
|
||||
|
|
||||
.I script
|
||||
|
|
||||
\-
|
||||
]
|
||||
[
|
||||
.I arguments
|
||||
]
|
||||
.SH DESCRIPTION
|
||||
Python is an interpreted, interactive, object-oriented programming
|
||||
language that combines remarkable power with very clear syntax.
|
||||
For an introduction to programming in Python, see the Python Tutorial.
|
||||
The Python Library Reference documents built-in and standard types,
|
||||
constants, functions and modules.
|
||||
Finally, the Python Reference Manual describes the syntax and
|
||||
semantics of the core language in (perhaps too) much detail.
|
||||
(These documents may be located via the
|
||||
.B "INTERNET RESOURCES"
|
||||
below; they may be installed on your system as well.)
|
||||
.PP
|
||||
Python's basic power can be extended with your own modules written in
|
||||
C or C++.
|
||||
On most systems such modules may be dynamically loaded.
|
||||
Python is also adaptable as an extension language for existing
|
||||
applications.
|
||||
See the internal documentation for hints.
|
||||
.PP
|
||||
Documentation for installed Python modules and packages can be
|
||||
viewed by running the
|
||||
.B pydoc
|
||||
program.
|
||||
.SH COMMAND LINE OPTIONS
|
||||
.TP
|
||||
.B \-B
|
||||
Don't write
|
||||
.I .py[co]
|
||||
files on import. See also PYTHONDONTWRITEBYTECODE.
|
||||
.TP
|
||||
.BI "\-c " command
|
||||
Specify the command to execute (see next section).
|
||||
This terminates the option list (following options are passed as
|
||||
arguments to the command).
|
||||
.TP
|
||||
.B \-d
|
||||
Turn on parser debugging output (for wizards only, depending on
|
||||
compilation options).
|
||||
.TP
|
||||
.B \-E
|
||||
Ignore environment variables like PYTHONPATH and PYTHONHOME that modify
|
||||
the behavior of the interpreter.
|
||||
.TP
|
||||
.B \-h ", " \-? ", "\-\-help
|
||||
Prints the usage for the interpreter executable and exits.
|
||||
.TP
|
||||
.B \-i
|
||||
When a script is passed as first argument or the \fB\-c\fP option is
|
||||
used, enter interactive mode after executing the script or the
|
||||
command. It does not read the $PYTHONSTARTUP file. This can be
|
||||
useful to inspect global variables or a stack trace when a script
|
||||
raises an exception.
|
||||
.TP
|
||||
.BI "\-m " module-name
|
||||
Searches
|
||||
.I sys.path
|
||||
for the named module and runs the corresponding
|
||||
.I .py
|
||||
file as a script.
|
||||
.TP
|
||||
.B \-O
|
||||
Turn on basic optimizations. This changes the filename extension for
|
||||
compiled (bytecode) files from
|
||||
.I .pyc
|
||||
to \fI.pyo\fP. Given twice, causes docstrings to be discarded.
|
||||
.TP
|
||||
.B \-OO
|
||||
Discard docstrings in addition to the \fB-O\fP optimizations.
|
||||
.TP
|
||||
.B \-R
|
||||
Turn on "hash randomization", so that the hash() values of str, bytes and
|
||||
datetime objects are "salted" with an unpredictable pseudo-random value.
|
||||
Although they remain constant within an individual Python process, they are
|
||||
not predictable between repeated invocations of Python.
|
||||
.IP
|
||||
This is intended to provide protection against a denial of service
|
||||
caused by carefully-chosen inputs that exploit the worst case performance
|
||||
of a dict construction, O(n^2) complexity. See
|
||||
http://www.ocert.org/advisories/ocert-2011-003.html
|
||||
for details.
|
||||
.TP
|
||||
.BI "\-Q " argument
|
||||
Division control; see PEP 238. The argument must be one of "old" (the
|
||||
default, int/int and long/long return an int or long), "new" (new
|
||||
division semantics, i.e. int/int and long/long returns a float),
|
||||
"warn" (old division semantics with a warning for int/int and
|
||||
long/long), or "warnall" (old division semantics with a warning for
|
||||
all use of the division operator). For a use of "warnall", see the
|
||||
Tools/scripts/fixdiv.py script.
|
||||
.TP
|
||||
.B \-s
|
||||
Don't add user site directory to sys.path.
|
||||
.TP
|
||||
.B \-S
|
||||
Disable the import of the module
|
||||
.I site
|
||||
and the site-dependent manipulations of
|
||||
.I sys.path
|
||||
that it entails.
|
||||
.TP
|
||||
.B \-t
|
||||
Issue a warning when a source file mixes tabs and spaces for
|
||||
indentation in a way that makes it depend on the worth of a tab
|
||||
expressed in spaces. Issue an error when the option is given twice.
|
||||
.TP
|
||||
.B \-u
|
||||
Force stdin, stdout and stderr to be totally unbuffered. On systems
|
||||
where it matters, also put stdin, stdout and stderr in binary mode.
|
||||
Note that there is internal buffering in xreadlines(), readlines() and
|
||||
file-object iterators ("for line in sys.stdin") which is not
|
||||
influenced by this option. To work around this, you will want to use
|
||||
"sys.stdin.readline()" inside a "while 1:" loop.
|
||||
.TP
|
||||
.B \-v
|
||||
Print a message each time a module is initialized, showing the place
|
||||
(filename or built-in module) from which it is loaded. When given
|
||||
twice, print a message for each file that is checked for when
|
||||
searching for a module. Also provides information on module cleanup
|
||||
at exit.
|
||||
.TP
|
||||
.B \-V ", " \-\-version
|
||||
Prints the Python version number of the executable and exits.
|
||||
.TP
|
||||
.BI "\-W " argument
|
||||
Warning control. Python sometimes prints warning message to
|
||||
.IR sys.stderr .
|
||||
A typical warning message has the following form:
|
||||
.IB file ":" line ": " category ": " message.
|
||||
By default, each warning is printed once for each source line where it
|
||||
occurs. This option controls how often warnings are printed.
|
||||
Multiple
|
||||
.B \-W
|
||||
options may be given; when a warning matches more than one
|
||||
option, the action for the last matching option is performed.
|
||||
Invalid
|
||||
.B \-W
|
||||
options are ignored (a warning message is printed about invalid
|
||||
options when the first warning is issued). Warnings can also be
|
||||
controlled from within a Python program using the
|
||||
.I warnings
|
||||
module.
|
||||
|
||||
The simplest form of
|
||||
.I argument
|
||||
is one of the following
|
||||
.I action
|
||||
strings (or a unique abbreviation):
|
||||
.B ignore
|
||||
to ignore all warnings;
|
||||
.B default
|
||||
to explicitly request the default behavior (printing each warning once
|
||||
per source line);
|
||||
.B all
|
||||
to print a warning each time it occurs (this may generate many
|
||||
messages if a warning is triggered repeatedly for the same source
|
||||
line, such as inside a loop);
|
||||
.B module
|
||||
to print each warning only the first time it occurs in each
|
||||
module;
|
||||
.B once
|
||||
to print each warning only the first time it occurs in the program; or
|
||||
.B error
|
||||
to raise an exception instead of printing a warning message.
|
||||
|
||||
The full form of
|
||||
.I argument
|
||||
is
|
||||
.IB action : message : category : module : line.
|
||||
Here,
|
||||
.I action
|
||||
is as explained above but only applies to messages that match the
|
||||
remaining fields. Empty fields match all values; trailing empty
|
||||
fields may be omitted. The
|
||||
.I message
|
||||
field matches the start of the warning message printed; this match is
|
||||
case-insensitive. The
|
||||
.I category
|
||||
field matches the warning category. This must be a class name; the
|
||||
match test whether the actual warning category of the message is a
|
||||
subclass of the specified warning category. The full class name must
|
||||
be given. The
|
||||
.I module
|
||||
field matches the (fully-qualified) module name; this match is
|
||||
case-sensitive. The
|
||||
.I line
|
||||
field matches the line number, where zero matches all line numbers and
|
||||
is thus equivalent to an omitted line number.
|
||||
.TP
|
||||
.B \-x
|
||||
Skip the first line of the source. This is intended for a DOS
|
||||
specific hack only. Warning: the line numbers in error messages will
|
||||
be off by one!
|
||||
.TP
|
||||
.B \-3
|
||||
Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix.
|
||||
.SH INTERPRETER INTERFACE
|
||||
The interpreter interface resembles that of the UNIX shell: when
|
||||
called with standard input connected to a tty device, it prompts for
|
||||
commands and executes them until an EOF is read; when called with a
|
||||
file name argument or with a file as standard input, it reads and
|
||||
executes a
|
||||
.I script
|
||||
from that file;
|
||||
when called with
|
||||
.B \-c
|
||||
.IR command ,
|
||||
it executes the Python statement(s) given as
|
||||
.IR command .
|
||||
Here
|
||||
.I command
|
||||
may contain multiple statements separated by newlines.
|
||||
Leading whitespace is significant in Python statements!
|
||||
In non-interactive mode, the entire input is parsed before it is
|
||||
executed.
|
||||
.PP
|
||||
If available, the script name and additional arguments thereafter are
|
||||
passed to the script in the Python variable
|
||||
.IR sys.argv ,
|
||||
which is a list of strings (you must first
|
||||
.I import sys
|
||||
to be able to access it).
|
||||
If no script name is given,
|
||||
.I sys.argv[0]
|
||||
is an empty string; if
|
||||
.B \-c
|
||||
is used,
|
||||
.I sys.argv[0]
|
||||
contains the string
|
||||
.I '-c'.
|
||||
Note that options interpreted by the Python interpreter itself
|
||||
are not placed in
|
||||
.IR sys.argv .
|
||||
.PP
|
||||
In interactive mode, the primary prompt is `>>>'; the second prompt
|
||||
(which appears when a command is not complete) is `...'.
|
||||
The prompts can be changed by assignment to
|
||||
.I sys.ps1
|
||||
or
|
||||
.IR sys.ps2 .
|
||||
The interpreter quits when it reads an EOF at a prompt.
|
||||
When an unhandled exception occurs, a stack trace is printed and
|
||||
control returns to the primary prompt; in non-interactive mode, the
|
||||
interpreter exits after printing the stack trace.
|
||||
The interrupt signal raises the
|
||||
.I Keyboard\%Interrupt
|
||||
exception; other UNIX signals are not caught (except that SIGPIPE is
|
||||
sometimes ignored, in favor of the
|
||||
.I IOError
|
||||
exception). Error messages are written to stderr.
|
||||
.SH FILES AND DIRECTORIES
|
||||
These are subject to difference depending on local installation
|
||||
conventions; ${prefix} and ${exec_prefix} are installation-dependent
|
||||
and should be interpreted as for GNU software; they may be the same.
|
||||
The default for both is \fI/usr/local\fP.
|
||||
.IP \fI${exec_prefix}/bin/python\fP
|
||||
Recommended location of the interpreter.
|
||||
.PP
|
||||
.I ${prefix}/lib/python<version>
|
||||
.br
|
||||
.I ${exec_prefix}/lib/python<version>
|
||||
.RS
|
||||
Recommended locations of the directories containing the standard
|
||||
modules.
|
||||
.RE
|
||||
.PP
|
||||
.I ${prefix}/include/python<version>
|
||||
.br
|
||||
.I ${exec_prefix}/include/python<version>
|
||||
.RS
|
||||
Recommended locations of the directories containing the include files
|
||||
needed for developing Python extensions and embedding the
|
||||
interpreter.
|
||||
.RE
|
||||
.IP \fI~/.pythonrc.py\fP
|
||||
User-specific initialization file loaded by the \fIuser\fP module;
|
||||
not used by default or by most applications.
|
||||
.SH ENVIRONMENT VARIABLES
|
||||
.IP PYTHONHOME
|
||||
Change the location of the standard Python libraries. By default, the
|
||||
libraries are searched in ${prefix}/lib/python<version> and
|
||||
${exec_prefix}/lib/python<version>, where ${prefix} and ${exec_prefix}
|
||||
are installation-dependent directories, both defaulting to
|
||||
\fI/usr/local\fP. When $PYTHONHOME is set to a single directory, its value
|
||||
replaces both ${prefix} and ${exec_prefix}. To specify different values
|
||||
for these, set $PYTHONHOME to ${prefix}:${exec_prefix}.
|
||||
.IP PYTHONPATH
|
||||
Augments the default search path for module files.
|
||||
The format is the same as the shell's $PATH: one or more directory
|
||||
pathnames separated by colons.
|
||||
Non-existent directories are silently ignored.
|
||||
The default search path is installation dependent, but generally
|
||||
begins with ${prefix}/lib/python<version> (see PYTHONHOME above).
|
||||
The default search path is always appended to $PYTHONPATH.
|
||||
If a script argument is given, the directory containing the script is
|
||||
inserted in the path in front of $PYTHONPATH.
|
||||
The search path can be manipulated from within a Python program as the
|
||||
variable
|
||||
.IR sys.path .
|
||||
.IP PYTHONSTARTUP
|
||||
If this is the name of a readable file, the Python commands in that
|
||||
file are executed before the first prompt is displayed in interactive
|
||||
mode.
|
||||
The file is executed in the same name space where interactive commands
|
||||
are executed so that objects defined or imported in it can be used
|
||||
without qualification in the interactive session.
|
||||
You can also change the prompts
|
||||
.I sys.ps1
|
||||
and
|
||||
.I sys.ps2
|
||||
in this file.
|
||||
.IP PYTHONY2K
|
||||
Set this to a non-empty string to cause the \fItime\fP module to
|
||||
require dates specified as strings to include 4-digit years, otherwise
|
||||
2-digit years are converted based on rules described in the \fItime\fP
|
||||
module documentation.
|
||||
.IP PYTHONOPTIMIZE
|
||||
If this is set to a non-empty string it is equivalent to specifying
|
||||
the \fB\-O\fP option. If set to an integer, it is equivalent to
|
||||
specifying \fB\-O\fP multiple times.
|
||||
.IP PYTHONDEBUG
|
||||
If this is set to a non-empty string it is equivalent to specifying
|
||||
the \fB\-d\fP option. If set to an integer, it is equivalent to
|
||||
specifying \fB\-d\fP multiple times.
|
||||
.IP PYTHONDONTWRITEBYTECODE
|
||||
If this is set to a non-empty string it is equivalent to specifying
|
||||
the \fB\-B\fP option (don't try to write
|
||||
.I .py[co]
|
||||
files).
|
||||
.IP PYTHONINSPECT
|
||||
If this is set to a non-empty string it is equivalent to specifying
|
||||
the \fB\-i\fP option.
|
||||
.IP PYTHONIOENCODING
|
||||
If this is set before running the interpreter, it overrides the encoding used
|
||||
for stdin/stdout/stderr, in the syntax
|
||||
.IB encodingname ":" errorhandler
|
||||
The
|
||||
.IB errorhandler
|
||||
part is optional and has the same meaning as in str.encode. For stderr, the
|
||||
.IB errorhandler
|
||||
part is ignored; the handler will always be \'backslashreplace\'.
|
||||
.IP PYTHONNOUSERSITE
|
||||
If this is set to a non-empty string it is equivalent to specifying the
|
||||
\fB\-s\fP option (Don't add the user site directory to sys.path).
|
||||
.IP PYTHONUNBUFFERED
|
||||
If this is set to a non-empty string it is equivalent to specifying
|
||||
the \fB\-u\fP option.
|
||||
.IP PYTHONVERBOSE
|
||||
If this is set to a non-empty string it is equivalent to specifying
|
||||
the \fB\-v\fP option. If set to an integer, it is equivalent to
|
||||
specifying \fB\-v\fP multiple times.
|
||||
.IP PYTHONWARNINGS
|
||||
If this is set to a comma-separated string it is equivalent to
|
||||
specifying the \fB\-W\fP option for each separate value.
|
||||
.IP PYTHONHASHSEED
|
||||
If this variable is set to "random", the effect is the same as specifying
|
||||
the \fB-R\fP option: a random value is used to seed the hashes of str,
|
||||
bytes and datetime objects.
|
||||
|
||||
If PYTHONHASHSEED is set to an integer value, it is used as a fixed seed for
|
||||
generating the hash() of the types covered by the hash randomization. Its
|
||||
purpose is to allow repeatable hashing, such as for selftests for the
|
||||
interpreter itself, or to allow a cluster of python processes to share hash
|
||||
values.
|
||||
|
||||
The integer must be a decimal number in the range [0,4294967295]. Specifying
|
||||
the value 0 will lead to the same hash values as when hash randomization is
|
||||
disabled.
|
||||
.SH AUTHOR
|
||||
The Python Software Foundation: https://www.python.org/psf/
|
||||
.SH INTERNET RESOURCES
|
||||
Main website: https://www.python.org/
|
||||
.br
|
||||
Documentation: https://docs.python.org/2/
|
||||
.br
|
||||
Developer resources: https://docs.python.org/devguide/
|
||||
.br
|
||||
Downloads: https://www.python.org/downloads/
|
||||
.br
|
||||
Module repository: https://pypi.python.org/
|
||||
.br
|
||||
Newsgroups: comp.lang.python, comp.lang.python.announce
|
||||
.SH LICENSING
|
||||
Python is distributed under an Open Source license. See the file
|
||||
"LICENSE" in the Python source distribution for information on terms &
|
||||
conditions for accessing and otherwise using Python and for a
|
||||
DISCLAIMER OF ALL WARRANTIES.
|
||||
13
Misc/python.pc.in
Normal file
13
Misc/python.pc.in
Normal file
@@ -0,0 +1,13 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: Python
|
||||
Description: Python library
|
||||
Requires:
|
||||
Version: @VERSION@
|
||||
Libs.private: @LIBS@
|
||||
Libs: -L${libdir} -lpython@VERSION@
|
||||
Cflags: -I${includedir}/python@VERSION@
|
||||
|
||||
176
Misc/setuid-prog.c
Normal file
176
Misc/setuid-prog.c
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
Template for a setuid program that calls a script.
|
||||
|
||||
The script should be in an unwritable directory and should itself
|
||||
be unwritable. In fact all parent directories up to the root
|
||||
should be unwritable. The script must not be setuid, that's what
|
||||
this program is for.
|
||||
|
||||
This is a template program. You need to fill in the name of the
|
||||
script that must be executed. This is done by changing the
|
||||
definition of FULL_PATH below.
|
||||
|
||||
There are also some rules that should be adhered to when writing
|
||||
the script itself.
|
||||
|
||||
The first and most important rule is to never, ever trust that the
|
||||
user of the program will behave properly. Program defensively.
|
||||
Check your arguments for reasonableness. If the user is allowed to
|
||||
create files, check the names of the files. If the program depends
|
||||
on argv[0] for the action it should perform, check it.
|
||||
|
||||
Assuming the script is a Bourne shell script, the first line of the
|
||||
script should be
|
||||
#!/bin/sh -
|
||||
The - is important, don't omit it. If you're using esh, the first
|
||||
line should be
|
||||
#!/usr/local/bin/esh -f
|
||||
and for ksh, the first line should be
|
||||
#!/usr/local/bin/ksh -p
|
||||
The script should then set the variable IFS to the string
|
||||
consisting of <space>, <tab>, and <newline>. After this (*not*
|
||||
before!), the PATH variable should be set to a reasonable value and
|
||||
exported. Do not expect the PATH to have a reasonable value, so do
|
||||
not trust the old value of PATH. You should then set the umask of
|
||||
the program by calling
|
||||
umask 077 # or 022 if you want the files to be readable
|
||||
If you plan to change directories, you should either unset CDPATH
|
||||
or set it to a good value. Setting CDPATH to just ``.'' (dot) is a
|
||||
good idea.
|
||||
If, for some reason, you want to use csh, the first line should be
|
||||
#!/bin/csh -fb
|
||||
You should then set the path variable to something reasonable,
|
||||
without trusting the inherited path. Here too, you should set the
|
||||
umask using the command
|
||||
umask 077 # or 022 if you want the files to be readable
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <string.h>
|
||||
|
||||
/* CONFIGURATION SECTION */
|
||||
|
||||
#ifndef FULL_PATH /* so that this can be specified from the Makefile */
|
||||
/* Uncomment the following line:
|
||||
#define FULL_PATH "/full/path/of/script"
|
||||
* Then comment out the #error line. */
|
||||
#error "You must define FULL_PATH somewhere"
|
||||
#endif
|
||||
#ifndef UMASK
|
||||
#define UMASK 077
|
||||
#endif
|
||||
|
||||
/* END OF CONFIGURATION SECTION */
|
||||
|
||||
#if defined(__STDC__) && defined(__sgi)
|
||||
#define environ _environ
|
||||
#endif
|
||||
|
||||
/* don't change def_IFS */
|
||||
char def_IFS[] = "IFS= \t\n";
|
||||
/* you may want to change def_PATH, but you should really change it in */
|
||||
/* your script */
|
||||
#ifdef __sgi
|
||||
char def_PATH[] = "PATH=/usr/bsd:/usr/bin:/bin:/usr/local/bin:/usr/sbin";
|
||||
#else
|
||||
char def_PATH[] = "PATH=/usr/ucb:/usr/bin:/bin:/usr/local/bin";
|
||||
#endif
|
||||
/* don't change def_CDPATH */
|
||||
char def_CDPATH[] = "CDPATH=.";
|
||||
/* don't change def_ENV */
|
||||
char def_ENV[] = "ENV=:";
|
||||
|
||||
/*
|
||||
This function changes all environment variables that start with LD_
|
||||
into variables that start with XD_. This is important since we
|
||||
don't want the script that is executed to use any funny shared
|
||||
libraries.
|
||||
|
||||
The other changes to the environment are, strictly speaking, not
|
||||
needed here. They can safely be done in the script. They are done
|
||||
here because we don't trust the script writer (just like the script
|
||||
writer shouldn't trust the user of the script).
|
||||
If IFS is set in the environment, set it to space,tab,newline.
|
||||
If CDPATH is set in the environment, set it to ``.''.
|
||||
Set PATH to a reasonable default.
|
||||
*/
|
||||
void
|
||||
clean_environ(void)
|
||||
{
|
||||
char **p;
|
||||
extern char **environ;
|
||||
|
||||
for (p = environ; *p; p++) {
|
||||
if (strncmp(*p, "LD_", 3) == 0)
|
||||
**p = 'X';
|
||||
else if (strncmp(*p, "_RLD", 4) == 0)
|
||||
**p = 'X';
|
||||
else if (strncmp(*p, "PYTHON", 6) == 0)
|
||||
**p = 'X';
|
||||
else if (strncmp(*p, "IFS=", 4) == 0)
|
||||
*p = def_IFS;
|
||||
else if (strncmp(*p, "CDPATH=", 7) == 0)
|
||||
*p = def_CDPATH;
|
||||
else if (strncmp(*p, "ENV=", 4) == 0)
|
||||
*p = def_ENV;
|
||||
}
|
||||
putenv(def_PATH);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct stat statb;
|
||||
gid_t egid = getegid();
|
||||
uid_t euid = geteuid();
|
||||
|
||||
/*
|
||||
Sanity check #1.
|
||||
This check should be made compile-time, but that's not possible.
|
||||
If you're sure that you specified a full path name for FULL_PATH,
|
||||
you can omit this check.
|
||||
*/
|
||||
if (FULL_PATH[0] != '/') {
|
||||
fprintf(stderr, "%s: %s is not a full path name\n", argv[0],
|
||||
FULL_PATH);
|
||||
fprintf(stderr, "You can only use this wrapper if you\n");
|
||||
fprintf(stderr, "compile it with an absolute path.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
Sanity check #2.
|
||||
Check that the owner of the script is equal to either the
|
||||
effective uid or the super user.
|
||||
*/
|
||||
if (stat(FULL_PATH, &statb) < 0) {
|
||||
perror("stat");
|
||||
exit(1);
|
||||
}
|
||||
if (statb.st_uid != 0 && statb.st_uid != euid) {
|
||||
fprintf(stderr, "%s: %s has the wrong owner\n", argv[0],
|
||||
FULL_PATH);
|
||||
fprintf(stderr, "The script should be owned by root,\n");
|
||||
fprintf(stderr, "and shouldn't be writeable by anyone.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (setregid(egid, egid) < 0)
|
||||
perror("setregid");
|
||||
if (setreuid(euid, euid) < 0)
|
||||
perror("setreuid");
|
||||
|
||||
clean_environ();
|
||||
|
||||
umask(UMASK);
|
||||
|
||||
while (**argv == '-') /* don't let argv[0] start with '-' */
|
||||
(*argv)++;
|
||||
execv(FULL_PATH, argv);
|
||||
fprintf(stderr, "%s: could not execute the script\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
423
Misc/valgrind-python.supp
Normal file
423
Misc/valgrind-python.supp
Normal file
@@ -0,0 +1,423 @@
|
||||
#
|
||||
# This is a valgrind suppression file that should be used when using valgrind.
|
||||
#
|
||||
# Here's an example of running valgrind:
|
||||
#
|
||||
# cd python/dist/src
|
||||
# valgrind --tool=memcheck --suppressions=Misc/valgrind-python.supp \
|
||||
# ./python -E -tt ./Lib/test/regrtest.py -u bsddb,network
|
||||
#
|
||||
# You must edit Objects/obmalloc.c and uncomment Py_USING_MEMORY_DEBUGGER
|
||||
# to use the preferred suppressions with Py_ADDRESS_IN_RANGE.
|
||||
#
|
||||
# If you do not want to recompile Python, you can uncomment
|
||||
# suppressions for PyObject_Free and PyObject_Realloc.
|
||||
#
|
||||
# See Misc/README.valgrind for more information.
|
||||
|
||||
# all tool names: Addrcheck,Memcheck,cachegrind,helgrind,massif
|
||||
{
|
||||
ADDRESS_IN_RANGE/Invalid read of size 4
|
||||
Memcheck:Addr4
|
||||
fun:Py_ADDRESS_IN_RANGE
|
||||
}
|
||||
|
||||
{
|
||||
ADDRESS_IN_RANGE/Invalid read of size 4
|
||||
Memcheck:Value4
|
||||
fun:Py_ADDRESS_IN_RANGE
|
||||
}
|
||||
|
||||
{
|
||||
ADDRESS_IN_RANGE/Invalid read of size 8 (x86_64 aka amd64)
|
||||
Memcheck:Value8
|
||||
fun:Py_ADDRESS_IN_RANGE
|
||||
}
|
||||
|
||||
{
|
||||
ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
|
||||
Memcheck:Cond
|
||||
fun:Py_ADDRESS_IN_RANGE
|
||||
}
|
||||
|
||||
#
|
||||
# Leaks (including possible leaks)
|
||||
# Hmmm, I wonder if this masks some real leaks. I think it does.
|
||||
# Will need to fix that.
|
||||
#
|
||||
|
||||
{
|
||||
Suppress leaking the GIL. Happens once per process, see comment in ceval.c.
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:PyThread_allocate_lock
|
||||
fun:PyEval_InitThreads
|
||||
}
|
||||
|
||||
{
|
||||
Suppress leaking the GIL after a fork.
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:PyThread_allocate_lock
|
||||
fun:PyEval_ReInitThreads
|
||||
}
|
||||
|
||||
{
|
||||
Suppress leaking the autoTLSkey. This looks like it shouldn't leak though.
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:PyThread_create_key
|
||||
fun:_PyGILState_Init
|
||||
fun:Py_InitializeEx
|
||||
fun:Py_Main
|
||||
}
|
||||
|
||||
{
|
||||
Hmmm, is this a real leak or like the GIL?
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:PyThread_ReInitTLS
|
||||
}
|
||||
|
||||
{
|
||||
Handle PyMalloc confusing valgrind (possibly leaked)
|
||||
Memcheck:Leak
|
||||
fun:realloc
|
||||
fun:_PyObject_GC_Resize
|
||||
fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
|
||||
}
|
||||
|
||||
{
|
||||
Handle PyMalloc confusing valgrind (possibly leaked)
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_PyObject_GC_New
|
||||
fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
|
||||
}
|
||||
|
||||
{
|
||||
Handle PyMalloc confusing valgrind (possibly leaked)
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:_PyObject_GC_NewVar
|
||||
fun:COMMENT_THIS_LINE_TO_DISABLE_LEAK_WARNING
|
||||
}
|
||||
|
||||
{
|
||||
bpo-37329: _PyWarnings_Init allocates memory at startup, but doesn't release it at exit
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
...
|
||||
fun:_PyWarnings_Init
|
||||
}
|
||||
|
||||
#
|
||||
# Non-python specific leaks
|
||||
#
|
||||
|
||||
{
|
||||
Handle pthread issue (possibly leaked)
|
||||
Memcheck:Leak
|
||||
fun:calloc
|
||||
fun:allocate_dtv
|
||||
fun:_dl_allocate_tls_storage
|
||||
fun:_dl_allocate_tls
|
||||
}
|
||||
|
||||
{
|
||||
Handle pthread issue (possibly leaked)
|
||||
Memcheck:Leak
|
||||
fun:memalign
|
||||
fun:_dl_allocate_tls_storage
|
||||
fun:_dl_allocate_tls
|
||||
}
|
||||
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Invalid read of size 4
|
||||
### Memcheck:Addr4
|
||||
### fun:PyObject_Free
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Invalid read of size 4
|
||||
### Memcheck:Value4
|
||||
### fun:PyObject_Free
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Use of uninitialised value of size 8
|
||||
### Memcheck:Addr8
|
||||
### fun:PyObject_Free
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Use of uninitialised value of size 8
|
||||
### Memcheck:Value8
|
||||
### fun:PyObject_Free
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
|
||||
### Memcheck:Cond
|
||||
### fun:PyObject_Free
|
||||
###}
|
||||
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Invalid read of size 4
|
||||
### Memcheck:Addr4
|
||||
### fun:PyObject_Realloc
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Invalid read of size 4
|
||||
### Memcheck:Value4
|
||||
### fun:PyObject_Realloc
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Use of uninitialised value of size 8
|
||||
### Memcheck:Addr8
|
||||
### fun:PyObject_Realloc
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Use of uninitialised value of size 8
|
||||
### Memcheck:Value8
|
||||
### fun:PyObject_Realloc
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### ADDRESS_IN_RANGE/Conditional jump or move depends on uninitialised value
|
||||
### Memcheck:Cond
|
||||
### fun:PyObject_Realloc
|
||||
###}
|
||||
|
||||
###
|
||||
### All the suppressions below are for errors that occur within libraries
|
||||
### that Python uses. The problems to not appear to be related to Python's
|
||||
### use of the libraries.
|
||||
###
|
||||
|
||||
{
|
||||
Generic ubuntu ld problems
|
||||
Memcheck:Addr8
|
||||
obj:/lib/ld-2.4.so
|
||||
obj:/lib/ld-2.4.so
|
||||
obj:/lib/ld-2.4.so
|
||||
obj:/lib/ld-2.4.so
|
||||
}
|
||||
|
||||
{
|
||||
Generic gentoo ld problems
|
||||
Memcheck:Cond
|
||||
obj:/lib/ld-2.3.4.so
|
||||
obj:/lib/ld-2.3.4.so
|
||||
obj:/lib/ld-2.3.4.so
|
||||
obj:/lib/ld-2.3.4.so
|
||||
}
|
||||
|
||||
{
|
||||
DBM problems, see test_dbm
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
fun:write
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
fun:dbm_close
|
||||
}
|
||||
|
||||
{
|
||||
DBM problems, see test_dbm
|
||||
Memcheck:Value8
|
||||
fun:memmove
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
fun:dbm_store
|
||||
fun:dbm_ass_sub
|
||||
}
|
||||
|
||||
{
|
||||
DBM problems, see test_dbm
|
||||
Memcheck:Cond
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
fun:dbm_store
|
||||
fun:dbm_ass_sub
|
||||
}
|
||||
|
||||
{
|
||||
DBM problems, see test_dbm
|
||||
Memcheck:Cond
|
||||
fun:memmove
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
obj:/usr/lib/libdb1.so.2
|
||||
fun:dbm_store
|
||||
fun:dbm_ass_sub
|
||||
}
|
||||
|
||||
{
|
||||
GDBM problems, see test_gdbm
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
fun:write
|
||||
fun:gdbm_open
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
ZLIB problems, see test_gzip
|
||||
Memcheck:Cond
|
||||
obj:/lib/libz.so.1.2.3
|
||||
obj:/lib/libz.so.1.2.3
|
||||
fun:deflate
|
||||
}
|
||||
|
||||
{
|
||||
Avoid problems w/readline doing a putenv and leaking on exit
|
||||
Memcheck:Leak
|
||||
fun:malloc
|
||||
fun:xmalloc
|
||||
fun:sh_set_lines_and_columns
|
||||
fun:_rl_get_screen_size
|
||||
fun:_rl_init_terminal_io
|
||||
obj:/lib/libreadline.so.4.3
|
||||
fun:rl_initialize
|
||||
}
|
||||
|
||||
###
|
||||
### These occur from somewhere within the SSL, when running
|
||||
### test_socket_sll. They are too general to leave on by default.
|
||||
###
|
||||
###{
|
||||
### somewhere in SSL stuff
|
||||
### Memcheck:Cond
|
||||
### fun:memset
|
||||
###}
|
||||
###{
|
||||
### somewhere in SSL stuff
|
||||
### Memcheck:Value4
|
||||
### fun:memset
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### somewhere in SSL stuff
|
||||
### Memcheck:Cond
|
||||
### fun:MD5_Update
|
||||
###}
|
||||
###
|
||||
###{
|
||||
### somewhere in SSL stuff
|
||||
### Memcheck:Value4
|
||||
### fun:MD5_Update
|
||||
###}
|
||||
|
||||
#
|
||||
# All of these problems come from using test_socket_ssl
|
||||
#
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:BN_bin2bn
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:BN_num_bits_word
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Value4
|
||||
fun:BN_num_bits_word
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:BN_mod_exp_mont_word
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:BN_mod_exp_mont
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Param
|
||||
write(buf)
|
||||
fun:write
|
||||
obj:/usr/lib/libcrypto.so.0.9.7
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:RSA_verify
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Value4
|
||||
fun:RSA_verify
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Value4
|
||||
fun:DES_set_key_unchecked
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Value4
|
||||
fun:DES_encrypt2
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
obj:/usr/lib/libssl.so.0.9.7
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Value4
|
||||
obj:/usr/lib/libssl.so.0.9.7
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:BUF_MEM_grow_clean
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:memcpy
|
||||
fun:ssl3_read_bytes
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Cond
|
||||
fun:SHA1_Update
|
||||
}
|
||||
|
||||
{
|
||||
from test_socket_ssl
|
||||
Memcheck:Value4
|
||||
fun:SHA1_Update
|
||||
}
|
||||
|
||||
|
||||
10
Misc/vgrindefs
Normal file
10
Misc/vgrindefs
Normal file
@@ -0,0 +1,10 @@
|
||||
# vgrind is a pretty-printer that takes source code and outputs
|
||||
# eye-pleasing postscript. The entry below should be added to your
|
||||
# local vgrindefs file. Contributed by Neale Pickett <neale@lanl.gov>.
|
||||
|
||||
python|Python|py:\
|
||||
:pb=^\d?(def|class)\d\p(\d|\\|\(|\:):\
|
||||
:cb=#:ce=$:sb=":se=\e":lb=':le=\e':\
|
||||
:kw=assert and break class continue def del elif else except\
|
||||
exec finally for from global if import in is lambda not or\
|
||||
pass print raise return try while yield:
|
||||
Reference in New Issue
Block a user