[Python-checkins] r63894 - in python/branches/tlee-ast-optimize: Doc/Makefile Doc/README.txt Doc/library/htmllib.rst Doc/library/msilib.rst Doc/library/sgmllib.rst Doc/library/sys.rst Doc/library/threading.rst Doc/tools/sphinxext/pyspecific.py Include/bytearrayobject.h Include/bytesobject.h Lib/htmllib.py Lib/pydoc.py Lib/pydoc_topics.py Lib/sgmllib.py Lib/test/test_datetime.py Lib/test/test_descrtut.py Lib/test/test_htmllib.py Lib/test/test_py3kwarn.py Lib/test/test_sgmllib.py Lib/test/test_sys.py Lib/test/test_threading.py Lib/threading.py Misc/NEWS Modules/datetimemodule.c Objects/bytesobject.c Objects/dictobject.c Objects/listobject.c Objects/longobject.c Objects/typeobject.c PC/_msi.c Python/sysmodule.c Tools/README Tools/bgen/README

thomas.lee python-checkins at python.org
Tue Jun 3 20:57:18 CEST 2008


Author: thomas.lee
Date: Mon Jun  2 15:14:06 2008
New Revision: 63894

Log:
Merged revisions 63854-63893 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r63856 | robert.schuppenies | 2008-06-02 02:16:17 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
........
  r63858 | georg.brandl | 2008-06-02 02:41:31 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Add plain text make target.
........
  r63859 | georg.brandl | 2008-06-02 02:42:16 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Some style nits. Also clarify in the docstrings what __sizeof__ does.
........
  r63860 | georg.brandl | 2008-06-02 03:05:56 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Fix test_descrtut.
........
  r63861 | robert.schuppenies | 2008-06-02 03:11:09 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Fix test_sys.
........
  r63863 | benjamin.peterson | 2008-06-02 05:01:25 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  add a warning about bgen being removed
........
  r63865 | georg.brandl | 2008-06-02 05:24:36 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Spaces vs. tabs.
........
  r63871 | georg.brandl | 2008-06-02 06:33:55 +1000 (Mon, 02 Jun 2008) | 3 lines
  
  Generate pydoc's topic help from the reST docs via Sphinx'
  new text writer.
........
  r63873 | georg.brandl | 2008-06-02 07:19:14 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Deprecate htmllib and sgmllib for 3.0.
........
  r63879 | gregory.p.smith | 2008-06-02 08:57:47 +1000 (Mon, 02 Jun 2008) | 3 lines
  
  Make the _H #define's match the header file names.  Fix comments to
  mention the correct type names.
........
  r63882 | gregory.p.smith | 2008-06-02 09:48:47 +1000 (Mon, 02 Jun 2008) | 3 lines
  
  Adds a Thread.getIdent() method to provide the _get_ident() value for
  any given threading.Thread object.  feature request issue 2871.
........
  r63887 | gregory.p.smith | 2008-06-02 14:05:52 +1000 (Mon, 02 Jun 2008) | 4 lines
  
  Fix issue 2782: be less strict about the format string type in strftime.
  Accept unicode and anything else ParseTuple "s#" can deal with.  This
  matches the time.strftime behavior.
........
  r63888 | martin.v.loewis | 2008-06-02 18:40:06 +1000 (Mon, 02 Jun 2008) | 2 lines
  
  Patch #2125: Add GetInteger and GetString methods for 
  msilib.Record objects.
........


Added:
   python/branches/tlee-ast-optimize/Lib/pydoc_topics.py
      - copied unchanged from r63888, /python/trunk/Lib/pydoc_topics.py
Modified:
   python/branches/tlee-ast-optimize/   (props changed)
   python/branches/tlee-ast-optimize/Doc/Makefile
   python/branches/tlee-ast-optimize/Doc/README.txt
   python/branches/tlee-ast-optimize/Doc/library/htmllib.rst
   python/branches/tlee-ast-optimize/Doc/library/msilib.rst
   python/branches/tlee-ast-optimize/Doc/library/sgmllib.rst
   python/branches/tlee-ast-optimize/Doc/library/sys.rst
   python/branches/tlee-ast-optimize/Doc/library/threading.rst
   python/branches/tlee-ast-optimize/Doc/tools/sphinxext/pyspecific.py
   python/branches/tlee-ast-optimize/Include/bytearrayobject.h
   python/branches/tlee-ast-optimize/Include/bytesobject.h
   python/branches/tlee-ast-optimize/Lib/htmllib.py
   python/branches/tlee-ast-optimize/Lib/pydoc.py
   python/branches/tlee-ast-optimize/Lib/sgmllib.py
   python/branches/tlee-ast-optimize/Lib/test/test_datetime.py
   python/branches/tlee-ast-optimize/Lib/test/test_descrtut.py
   python/branches/tlee-ast-optimize/Lib/test/test_htmllib.py
   python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py
   python/branches/tlee-ast-optimize/Lib/test/test_sgmllib.py
   python/branches/tlee-ast-optimize/Lib/test/test_sys.py
   python/branches/tlee-ast-optimize/Lib/test/test_threading.py
   python/branches/tlee-ast-optimize/Lib/threading.py
   python/branches/tlee-ast-optimize/Misc/NEWS
   python/branches/tlee-ast-optimize/Modules/datetimemodule.c
   python/branches/tlee-ast-optimize/Objects/bytesobject.c
   python/branches/tlee-ast-optimize/Objects/dictobject.c
   python/branches/tlee-ast-optimize/Objects/listobject.c
   python/branches/tlee-ast-optimize/Objects/longobject.c
   python/branches/tlee-ast-optimize/Objects/typeobject.c
   python/branches/tlee-ast-optimize/PC/_msi.c
   python/branches/tlee-ast-optimize/Python/sysmodule.c
   python/branches/tlee-ast-optimize/Tools/README
   python/branches/tlee-ast-optimize/Tools/bgen/README

Modified: python/branches/tlee-ast-optimize/Doc/Makefile
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/Makefile	(original)
+++ python/branches/tlee-ast-optimize/Doc/Makefile	Mon Jun  2 15:14:06 2008
@@ -21,6 +21,7 @@
 	@echo "  web       to make file usable by Sphinx.web"
 	@echo "  htmlhelp  to make HTML files and a HTML help project"
 	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  text      to make plain text files"
 	@echo "  changes   to make an overview over all changed/added/deprecated items"
 	@echo "  linkcheck to check all external links for integrity"
 	@echo "  coverage  to check documentation coverage for library and C API"
@@ -75,6 +76,10 @@
 	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
 	      "run these through (pdf)latex."
 
+text: BUILDER = text
+text: build
+	@echo "Build finished; the text files are in build/text."
+
 changes: BUILDER = changes
 changes: build
 	@echo "The overview file is in build/changes."
@@ -93,6 +98,11 @@
 	@echo "Testing of doctests in the sources finished, look at the " \
 	      "results in build/doctest/output.txt"
 
+pydoc-topics: BUILDER = pydoc-topics
+pydoc-topics: build
+	@echo "Building finished; now copy build/pydoc-topics/pydoc_topics.py " \
+	      "into the Lib/ directory"
+
 clean:
 	-rm -rf build/*
 	-rm -rf tools/sphinx

Modified: python/branches/tlee-ast-optimize/Doc/README.txt
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/README.txt	(original)
+++ python/branches/tlee-ast-optimize/Doc/README.txt	Mon Jun  2 15:14:06 2008
@@ -51,6 +51,8 @@
  * "latex", which builds LaTeX source files that can be run with "pdflatex"
    to produce PDF documents.
 
+ * "text", which builds a plain text file for each source file.
+
  * "linkcheck", which checks all external references to see whether they are
    broken, redirected or malformed, and outputs this information to stdout
    as well as a plain-text (.txt) file.
@@ -62,6 +64,11 @@
  * "coverage", which builds a coverage overview for standard library modules
    and C API.
 
+ * "pydoc-topics", which builds a Python module containing a dictionary
+   with plain text documentation for the labels defined in
+   `tools/sphinxext/pyspecific.py` -- pydoc needs these to show topic
+   and keyword help.
+
 A "make update" updates the Subversion checkouts in `tools/`.
 
 

Modified: python/branches/tlee-ast-optimize/Doc/library/htmllib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/htmllib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/htmllib.rst	Mon Jun  2 15:14:06 2008
@@ -1,9 +1,12 @@
-
 :mod:`htmllib` --- A parser for HTML documents
 ==============================================
 
 .. module:: htmllib
    :synopsis: A parser for HTML documents.
+   :deprecated:
+   
+.. deprecated:: 2.6
+    The :mod:`htmllib` module has been removed in Python 3.0.
 
 
 .. index::

Modified: python/branches/tlee-ast-optimize/Doc/library/msilib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/msilib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/msilib.rst	Mon Jun  2 15:14:06 2008
@@ -264,6 +264,18 @@
    :cfunc:`MsiRecordGetFieldCount`.
 
 
+.. method:: Record.GetInteger(field)
+
+   Return the value of *field* as an integer where possible.  *field* must
+   be an integer.
+
+
+.. method:: Record.GetString(field)
+
+   Return the value of *field* as a string where possible.  *field* must
+   be an integer.
+
+
 .. method:: Record.SetString(field, value)
 
    Set *field* to *value* through :cfunc:`MsiRecordSetString`. *field* must be an
@@ -543,3 +555,4 @@
    This module contains definitions for the UIText and ActionText tables, for the
    standard installer actions.
 
+

Modified: python/branches/tlee-ast-optimize/Doc/library/sgmllib.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/sgmllib.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/sgmllib.rst	Mon Jun  2 15:14:06 2008
@@ -1,10 +1,12 @@
-
 :mod:`sgmllib` --- Simple SGML parser
 =====================================
 
 .. module:: sgmllib
    :synopsis: Only as much of an SGML parser as needed to parse HTML.
-
+   :deprecated:
+   
+.. deprecated:: 2.6
+    The :mod:`sgmllib` module has been removed in Python 3.0.
 
 .. index:: single: SGML
 

Modified: python/branches/tlee-ast-optimize/Doc/library/sys.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/sys.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/sys.rst	Mon Jun  2 15:14:06 2008
@@ -409,6 +409,16 @@
    :func:`setrecursionlimit`.
 
 
+.. function:: getsizeof(object)
+
+   Return the size of an object in bytes. The object can be any type of
+   object. All built-in objects will return correct results, but this
+   does not have to hold true for third-party extensions as it is implementation 
+   specific.
+
+   .. versionadded:: 2.6
+
+
 .. function:: _getframe([depth])
 
    Return a frame object from the call stack.  If optional integer *depth* is

Modified: python/branches/tlee-ast-optimize/Doc/library/threading.rst
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/library/threading.rst	(original)
+++ python/branches/tlee-ast-optimize/Doc/library/threading.rst	Mon Jun  2 15:14:06 2008
@@ -651,6 +651,17 @@
    constructor.
 
 
+.. method:: Thread.getIdent()
+
+   Return the 'thread identifier' of this thread or None if the thread has not
+   been started.  This is a nonzero integer.  See the :mod:`thread` module's
+   :func:`get_ident()` function.  Thread identifiers may be recycled when a
+   thread exits and another thread is created.  The identifier is returned
+   even after the thread has exited.
+
+   .. versionadded:: 2.6
+
+
 .. method:: Thread.isAlive()
 
    Return whether the thread is alive.

Modified: python/branches/tlee-ast-optimize/Doc/tools/sphinxext/pyspecific.py
==============================================================================
--- python/branches/tlee-ast-optimize/Doc/tools/sphinxext/pyspecific.py	(original)
+++ python/branches/tlee-ast-optimize/Doc/tools/sphinxext/pyspecific.py	Mon Jun  2 15:14:06 2008
@@ -20,5 +20,71 @@
     return [refnode], []
 
 
+# Support for building "topic help" for pydoc
+
+pydoc_topic_labels = [
+    'assert', 'assignment', 'atom-identifiers', 'atom-literals',
+    'attribute-access', 'attribute-references', 'augassign', 'binary',
+    'bitwise', 'bltin-code-objects', 'bltin-ellipsis-object',
+    'bltin-file-objects', 'bltin-null-object', 'bltin-type-objects', 'booleans',
+    'break', 'callable-types', 'calls', 'class', 'coercion-rules',
+    'comparisons', 'compound', 'context-managers', 'continue', 'conversions',
+    'customization', 'debugger', 'del', 'dict', 'dynamic-features', 'else',
+    'exceptions', 'exec', 'execmodel', 'exprlists', 'floating', 'for',
+    'formatstrings', 'function', 'global', 'id-classes', 'identifiers', 'if',
+    'imaginary', 'import', 'in', 'integers', 'lambda', 'lists', 'naming',
+    'numbers', 'numeric-types', 'objects', 'operator-summary', 'pass', 'power',
+    'print', 'raise', 'return', 'sequence-methods', 'sequence-types',
+    'shifting', 'slicings', 'specialattrs', 'specialnames',
+    'string-conversions', 'string-methods', 'strings', 'subscriptions', 'truth',
+    'try', 'types', 'typesfunctions', 'typesmapping', 'typesmethods',
+    'typesmodules', 'typesseq', 'typesseq-mutable', 'unary', 'while', 'with',
+    'yield'
+]
+
+from os import path
+from time import asctime
+from pprint import pformat
+from docutils.io import StringOutput
+from docutils.utils import new_document
+from sphinx.builder import Builder
+from sphinx.textwriter import TextWriter
+
+class PydocTopicsBuilder(Builder):
+    name = 'pydoc-topics'
+
+    def init(self):
+        self.topics = {}
+
+    def get_outdated_docs(self):
+        return 'all pydoc topics'
+
+    def get_target_uri(self, docname, typ=None):
+        return ''  # no URIs
+
+    def write(self, *ignored):
+        writer = TextWriter(self)
+        for label in self.status_iterator(pydoc_topic_labels, 'building topics... '):
+            if label not in self.env.labels:
+                self.warn('label %r not in documentation' % label)
+                continue
+            docname, labelid, sectname = self.env.labels[label]
+            doctree = self.env.get_and_resolve_doctree(docname, self)
+            document = new_document('<section node>')
+            document.append(doctree.ids[labelid])
+            destination = StringOutput(encoding='utf-8')
+            writer.write(document, destination)
+            self.topics[label] = writer.output
+
+    def finish(self):
+        f = open(path.join(self.outdir, 'pydoc_topics.py'), 'w')
+        try:
+            f.write('# Autogenerated by Sphinx on %s\n' % asctime())
+            f.write('topics = ' + pformat(self.topics) + '\n')
+        finally:
+            f.close()
+
+
 def setup(app):
     app.add_role('issue', issue_role)
+    app.add_builder(PydocTopicsBuilder)

Modified: python/branches/tlee-ast-optimize/Include/bytearrayobject.h
==============================================================================
--- python/branches/tlee-ast-optimize/Include/bytearrayobject.h	(original)
+++ python/branches/tlee-ast-optimize/Include/bytearrayobject.h	Mon Jun  2 15:14:06 2008
@@ -1,7 +1,7 @@
-/* Bytes object interface */
+/* ByteArray object interface */
 
-#ifndef Py_BYTESOBJECT_H
-#define Py_BYTESOBJECT_H
+#ifndef Py_BYTEARRAYOBJECT_H
+#define Py_BYTEARRAYOBJECT_H
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -50,4 +50,4 @@
 #ifdef __cplusplus
 }
 #endif
-#endif /* !Py_BYTESOBJECT_H */
+#endif /* !Py_BYTEARRAYOBJECT_H */

Modified: python/branches/tlee-ast-optimize/Include/bytesobject.h
==============================================================================
--- python/branches/tlee-ast-optimize/Include/bytesobject.h	(original)
+++ python/branches/tlee-ast-optimize/Include/bytesobject.h	Mon Jun  2 15:14:06 2008
@@ -1,8 +1,8 @@
 
-/* String object interface */
+/* Bytes (String) object interface */
 
-#ifndef Py_STRINGOBJECT_H
-#define Py_STRINGOBJECT_H
+#ifndef Py_BYTESOBJECT_H
+#define Py_BYTESOBJECT_H
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -197,4 +197,4 @@
 #ifdef __cplusplus
 }
 #endif
-#endif /* !Py_STRINGOBJECT_H */
+#endif /* !Py_BYTESOBJECT_H */

Modified: python/branches/tlee-ast-optimize/Lib/htmllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/htmllib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/htmllib.py	Mon Jun  2 15:14:06 2008
@@ -4,6 +4,11 @@
 http://www.w3.org/hypertext/WWW/MarkUp/html-spec/html-spec_toc.html
 """
 
+from warnings import warnpy3k
+warnpy3k("the htmllib module has been removed in Python 3.0",
+         stacklevel=2)
+del warnpy3k
+
 import sgmllib
 
 from formatter import AS_IS

Modified: python/branches/tlee-ast-optimize/Lib/pydoc.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/pydoc.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/pydoc.py	Mon Jun  2 15:14:06 2008
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# -*- coding: Latin-1 -*-
+# -*- coding: latin-1 -*-
 """Generate Python documentation in HTML or text for interactive use.
 
 In the Python interpreter, do "from pydoc import help" to provide online
@@ -1523,142 +1523,149 @@
     return
 
 class Helper:
+
+    # These dictionaries map a topic name to either an alias, or a tuple
+    # (label, seealso-items).  The "label" is the label of the corresponding
+    # section in the .rst file under Doc/ and an index into the dictionary
+    # in pydoc_topics.py.
+    #
+    # CAUTION: if you change one of these dictionaries, be sure to adapt the
+    #          list of needed labels in Doc/tools/sphinxext/pyspecific.py and
+    #          regenerate the pydoc_topics.py file by running
+    #              make pydoc-topics
+    #          in Doc/ and copying the output file into the Lib/ directory.
+
     keywords = {
         'and': 'BOOLEAN',
         'as': 'with',
-        'assert': ('ref/assert', ''),
-        'break': ('ref/break', 'while for'),
-        'class': ('ref/class', 'CLASSES SPECIALMETHODS'),
-        'continue': ('ref/continue', 'while for'),
-        'def': ('ref/function', ''),
-        'del': ('ref/del', 'BASICMETHODS'),
+        'assert': ('assert', ''),
+        'break': ('break', 'while for'),
+        'class': ('class', 'CLASSES SPECIALMETHODS'),
+        'continue': ('continue', 'while for'),
+        'def': ('function', ''),
+        'del': ('del', 'BASICMETHODS'),
         'elif': 'if',
-        'else': ('ref/if', 'while for'),
-        'except': 'try',
-        'exec': ('ref/exec', ''),
-        'finally': 'try',
-        'for': ('ref/for', 'break continue while'),
-        'from': 'import',
-        'global': ('ref/global', 'NAMESPACES'),
-        'if': ('ref/if', 'TRUTHVALUE'),
-        'import': ('ref/import', 'MODULES'),
-        'in': ('ref/comparisons', 'SEQUENCEMETHODS2'),
+        'else': ('else', 'while for'),
+        'except': 'except',
+        'exec': ('exec', ''),
+        'finally': 'finally',
+        'for': ('for', 'break continue while'),
+        'from': 'from',
+        'global': ('global', 'NAMESPACES'),
+        'if': ('if', 'TRUTHVALUE'),
+        'import': ('import', 'MODULES'),
+        'in': ('in', 'SEQUENCEMETHODS2'),
         'is': 'COMPARISON',
-        'lambda': ('ref/lambdas', 'FUNCTIONS'),
+        'lambda': ('lambda', 'FUNCTIONS'),
         'not': 'BOOLEAN',
         'or': 'BOOLEAN',
-        'pass': ('ref/pass', ''),
-        'print': ('ref/print', ''),
-        'raise': ('ref/raise', 'EXCEPTIONS'),
-        'return': ('ref/return', 'FUNCTIONS'),
-        'try': ('ref/try', 'EXCEPTIONS'),
-        'while': ('ref/while', 'break continue if TRUTHVALUE'),
-        'with': ('ref/with', 'CONTEXTMANAGERS EXCEPTIONS yield'),
-        'yield': ('ref/yield', ''),
+        'pass': ('pass', ''),
+        'print': ('print', ''),
+        'raise': ('raise', 'EXCEPTIONS'),
+        'return': ('return', 'FUNCTIONS'),
+        'try': ('try', 'EXCEPTIONS'),
+        'while': ('while', 'break continue if TRUTHVALUE'),
+        'with': ('with', 'CONTEXTMANAGERS EXCEPTIONS yield'),
+        'yield': ('yield', ''),
     }
 
     topics = {
-        'TYPES': ('ref/types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS FUNCTIONS CLASSES MODULES FILES inspect'),
-        'STRINGS': ('ref/strings', 'str UNICODE SEQUENCES STRINGMETHODS FORMATTING TYPES'),
-        'STRINGMETHODS': ('lib/string-methods', 'STRINGS FORMATTING'),
-        'FORMATTING': ('lib/typesseq-strings', 'OPERATORS'),
-        'UNICODE': ('ref/strings', 'encodings unicode SEQUENCES STRINGMETHODS FORMATTING TYPES'),
-        'NUMBERS': ('ref/numbers', 'INTEGER FLOAT COMPLEX TYPES'),
-        'INTEGER': ('ref/integers', 'int range'),
-        'FLOAT': ('ref/floating', 'float math'),
-        'COMPLEX': ('ref/imaginary', 'complex cmath'),
-        'SEQUENCES': ('lib/typesseq', 'STRINGMETHODS FORMATTING xrange LISTS'),
+        'TYPES': ('types', 'STRINGS UNICODE NUMBERS SEQUENCES MAPPINGS '
+                  'FUNCTIONS CLASSES MODULES FILES inspect'),
+        'STRINGS': ('strings', 'str UNICODE SEQUENCES STRINGMETHODS FORMATTING '
+                    'TYPES'),
+        'STRINGMETHODS': ('string-methods', 'STRINGS FORMATTING'),
+        'FORMATTING': ('formatstrings', 'OPERATORS'),
+        'UNICODE': ('strings', 'encodings unicode SEQUENCES STRINGMETHODS '
+                    'FORMATTING TYPES'),
+        'NUMBERS': ('numbers', 'INTEGER FLOAT COMPLEX TYPES'),
+        'INTEGER': ('integers', 'int range'),
+        'FLOAT': ('floating', 'float math'),
+        'COMPLEX': ('imaginary', 'complex cmath'),
+        'SEQUENCES': ('typesseq', 'STRINGMETHODS FORMATTING xrange LISTS'),
         'MAPPINGS': 'DICTIONARIES',
-        'FUNCTIONS': ('lib/typesfunctions', 'def TYPES'),
-        'METHODS': ('lib/typesmethods', 'class def CLASSES TYPES'),
-        'CODEOBJECTS': ('lib/bltin-code-objects', 'compile FUNCTIONS TYPES'),
-        'TYPEOBJECTS': ('lib/bltin-type-objects', 'types TYPES'),
+        'FUNCTIONS': ('typesfunctions', 'def TYPES'),
+        'METHODS': ('typesmethods', 'class def CLASSES TYPES'),
+        'CODEOBJECTS': ('bltin-code-objects', 'compile FUNCTIONS TYPES'),
+        'TYPEOBJECTS': ('bltin-type-objects', 'types TYPES'),
         'FRAMEOBJECTS': 'TYPES',
         'TRACEBACKS': 'TYPES',
-        'NONE': ('lib/bltin-null-object', ''),
-        'ELLIPSIS': ('lib/bltin-ellipsis-object', 'SLICINGS'),
-        'FILES': ('lib/bltin-file-objects', ''),
-        'SPECIALATTRIBUTES': ('lib/specialattrs', ''),
-        'CLASSES': ('ref/types', 'class SPECIALMETHODS PRIVATENAMES'),
-        'MODULES': ('lib/typesmodules', 'import'),
+        'NONE': ('bltin-null-object', ''),
+        'ELLIPSIS': ('bltin-ellipsis-object', 'SLICINGS'),
+        'FILES': ('bltin-file-objects', ''),
+        'SPECIALATTRIBUTES': ('specialattrs', ''),
+        'CLASSES': ('types', 'class SPECIALMETHODS PRIVATENAMES'),
+        'MODULES': ('typesmodules', 'import'),
         'PACKAGES': 'import',
-        'EXPRESSIONS': ('ref/summary', 'lambda or and not in is BOOLEAN COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES LISTS DICTIONARIES BACKQUOTES'),
+        'EXPRESSIONS': ('operator-summary', 'lambda or and not in is BOOLEAN '
+                        'COMPARISON BITWISE SHIFTING BINARY FORMATTING POWER '
+                        'UNARY ATTRIBUTES SUBSCRIPTS SLICINGS CALLS TUPLES '
+                        'LISTS DICTIONARIES BACKQUOTES'),
         'OPERATORS': 'EXPRESSIONS',
         'PRECEDENCE': 'EXPRESSIONS',
-        'OBJECTS': ('ref/objects', 'TYPES'),
-        'SPECIALMETHODS': ('ref/specialnames', 'BASICMETHODS ATTRIBUTEMETHODS CALLABLEMETHODS SEQUENCEMETHODS1 MAPPINGMETHODS SEQUENCEMETHODS2 NUMBERMETHODS CLASSES'),
-        'BASICMETHODS': ('ref/customization', 'cmp hash repr str SPECIALMETHODS'),
-        'ATTRIBUTEMETHODS': ('ref/attribute-access', 'ATTRIBUTES SPECIALMETHODS'),
-        'CALLABLEMETHODS': ('ref/callable-types', 'CALLS SPECIALMETHODS'),
-        'SEQUENCEMETHODS1': ('ref/sequence-types', 'SEQUENCES SEQUENCEMETHODS2 SPECIALMETHODS'),
-        'SEQUENCEMETHODS2': ('ref/sequence-methods', 'SEQUENCES SEQUENCEMETHODS1 SPECIALMETHODS'),
-        'MAPPINGMETHODS': ('ref/sequence-types', 'MAPPINGS SPECIALMETHODS'),
-        'NUMBERMETHODS': ('ref/numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT SPECIALMETHODS'),
-        'EXECUTION': ('ref/execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
-        'NAMESPACES': ('ref/naming', 'global ASSIGNMENT DELETION DYNAMICFEATURES'),
-        'DYNAMICFEATURES': ('ref/dynamic-features', ''),
+        'OBJECTS': ('objects', 'TYPES'),
+        'SPECIALMETHODS': ('specialnames', 'BASICMETHODS ATTRIBUTEMETHODS '
+                           'CALLABLEMETHODS SEQUENCEMETHODS1 MAPPINGMETHODS '
+                           'SEQUENCEMETHODS2 NUMBERMETHODS CLASSES'),
+        'BASICMETHODS': ('customization', 'cmp hash repr str SPECIALMETHODS'),
+        'ATTRIBUTEMETHODS': ('attribute-access', 'ATTRIBUTES SPECIALMETHODS'),
+        'CALLABLEMETHODS': ('callable-types', 'CALLS SPECIALMETHODS'),
+        'SEQUENCEMETHODS1': ('sequence-types', 'SEQUENCES SEQUENCEMETHODS2 '
+                             'SPECIALMETHODS'),
+        'SEQUENCEMETHODS2': ('sequence-methods', 'SEQUENCES SEQUENCEMETHODS1 '
+                             'SPECIALMETHODS'),
+        'MAPPINGMETHODS': ('sequence-types', 'MAPPINGS SPECIALMETHODS'),
+        'NUMBERMETHODS': ('numeric-types', 'NUMBERS AUGMENTEDASSIGNMENT '
+                          'SPECIALMETHODS'),
+        'EXECUTION': ('execmodel', 'NAMESPACES DYNAMICFEATURES EXCEPTIONS'),
+        'NAMESPACES': ('naming', 'global ASSIGNMENT DELETION DYNAMICFEATURES'),
+        'DYNAMICFEATURES': ('dynamic-features', ''),
         'SCOPING': 'NAMESPACES',
         'FRAMES': 'NAMESPACES',
-        'EXCEPTIONS': ('ref/exceptions', 'try except finally raise'),
-        'COERCIONS': ('ref/coercion-rules','CONVERSIONS'),
-        'CONVERSIONS': ('ref/conversions', 'COERCIONS'),
-        'IDENTIFIERS': ('ref/identifiers', 'keywords SPECIALIDENTIFIERS'),
-        'SPECIALIDENTIFIERS': ('ref/id-classes', ''),
-        'PRIVATENAMES': ('ref/atom-identifiers', ''),
-        'LITERALS': ('ref/atom-literals', 'STRINGS BACKQUOTES NUMBERS TUPLELITERALS LISTLITERALS DICTIONARYLITERALS'),
+        'EXCEPTIONS': ('exceptions', 'try except finally raise'),
+        'COERCIONS': ('coercion-rules','CONVERSIONS'),
+        'CONVERSIONS': ('conversions', 'COERCIONS'),
+        'IDENTIFIERS': ('identifiers', 'keywords SPECIALIDENTIFIERS'),
+        'SPECIALIDENTIFIERS': ('id-classes', ''),
+        'PRIVATENAMES': ('atom-identifiers', ''),
+        'LITERALS': ('atom-literals', 'STRINGS BACKQUOTES NUMBERS '
+                     'TUPLELITERALS LISTLITERALS DICTIONARYLITERALS'),
         'TUPLES': 'SEQUENCES',
-        'TUPLELITERALS': ('ref/exprlists', 'TUPLES LITERALS'),
-        'LISTS': ('lib/typesseq-mutable', 'LISTLITERALS'),
-        'LISTLITERALS': ('ref/lists', 'LISTS LITERALS'),
-        'DICTIONARIES': ('lib/typesmapping', 'DICTIONARYLITERALS'),
-        'DICTIONARYLITERALS': ('ref/dict', 'DICTIONARIES LITERALS'),
-        'BACKQUOTES': ('ref/string-conversions', 'repr str STRINGS LITERALS'),
-        'ATTRIBUTES': ('ref/attribute-references', 'getattr hasattr setattr ATTRIBUTEMETHODS'),
-        'SUBSCRIPTS': ('ref/subscriptions', 'SEQUENCEMETHODS1'),
-        'SLICINGS': ('ref/slicings', 'SEQUENCEMETHODS2'),
-        'CALLS': ('ref/calls', 'EXPRESSIONS'),
-        'POWER': ('ref/power', 'EXPRESSIONS'),
-        'UNARY': ('ref/unary', 'EXPRESSIONS'),
-        'BINARY': ('ref/binary', 'EXPRESSIONS'),
-        'SHIFTING': ('ref/shifting', 'EXPRESSIONS'),
-        'BITWISE': ('ref/bitwise', 'EXPRESSIONS'),
-        'COMPARISON': ('ref/comparisons', 'EXPRESSIONS BASICMETHODS'),
-        'BOOLEAN': ('ref/Booleans', 'EXPRESSIONS TRUTHVALUE'),
+        'TUPLELITERALS': ('exprlists', 'TUPLES LITERALS'),
+        'LISTS': ('typesseq-mutable', 'LISTLITERALS'),
+        'LISTLITERALS': ('lists', 'LISTS LITERALS'),
+        'DICTIONARIES': ('typesmapping', 'DICTIONARYLITERALS'),
+        'DICTIONARYLITERALS': ('dict', 'DICTIONARIES LITERALS'),
+        'BACKQUOTES': ('string-conversions', 'repr str STRINGS LITERALS'),
+        'ATTRIBUTES': ('attribute-references', 'getattr hasattr setattr '
+                       'ATTRIBUTEMETHODS'),
+        'SUBSCRIPTS': ('subscriptions', 'SEQUENCEMETHODS1'),
+        'SLICINGS': ('slicings', 'SEQUENCEMETHODS2'),
+        'CALLS': ('calls', 'EXPRESSIONS'),
+        'POWER': ('power', 'EXPRESSIONS'),
+        'UNARY': ('unary', 'EXPRESSIONS'),
+        'BINARY': ('binary', 'EXPRESSIONS'),
+        'SHIFTING': ('shifting', 'EXPRESSIONS'),
+        'BITWISE': ('bitwise', 'EXPRESSIONS'),
+        'COMPARISON': ('comparisons', 'EXPRESSIONS BASICMETHODS'),
+        'BOOLEAN': ('booleans', 'EXPRESSIONS TRUTHVALUE'),
         'ASSERTION': 'assert',
-        'ASSIGNMENT': ('ref/assignment', 'AUGMENTEDASSIGNMENT'),
-        'AUGMENTEDASSIGNMENT': ('ref/augassign', 'NUMBERMETHODS'),
+        'ASSIGNMENT': ('assignment', 'AUGMENTEDASSIGNMENT'),
+        'AUGMENTEDASSIGNMENT': ('augassign', 'NUMBERMETHODS'),
         'DELETION': 'del',
         'PRINTING': 'print',
         'RETURNING': 'return',
         'IMPORTING': 'import',
         'CONDITIONAL': 'if',
-        'LOOPING': ('ref/compound', 'for while break continue'),
-        'TRUTHVALUE': ('lib/truth', 'if while and or not BASICMETHODS'),
-        'DEBUGGING': ('lib/module-pdb', 'pdb'),
-        'CONTEXTMANAGERS': ('ref/context-managers', 'with'),
+        'LOOPING': ('compound', 'for while break continue'),
+        'TRUTHVALUE': ('truth', 'if while and or not BASICMETHODS'),
+        'DEBUGGING': ('debugger', 'pdb'),
+        'CONTEXTMANAGERS': ('context-managers', 'with'),
     }
 
     def __init__(self, input, output):
         self.input = input
         self.output = output
-        self.docdir = None
-        execdir = os.path.dirname(sys.executable)
-        homedir = os.environ.get('PYTHONHOME')
-        join = os.path.join
-        for dir in [os.environ.get('PYTHONDOCS'),
-                    homedir and os.path.join(homedir, 'doc'),
-                    join(execdir, 'doc'), # for Windows
-                    join(sys.prefix, 'doc/python-docs-' + split(sys.version)[0]),
-                    join(sys.prefix, 'doc/python-' + split(sys.version)[0]),
-                    join(sys.prefix, 'doc/python-docs-' + sys.version[:3]),
-                    join(sys.prefix, 'doc/python-' + sys.version[:3]),
-                    join(sys.prefix, 'Resources/English.lproj/Documentation')]:
-            if dir and os.path.isdir(join(dir, 'lib')):
-                self.docdir = dir
-                break
-            if dir and os.path.isdir(join(dir, 'html', 'lib')):
-                self.docdir = join(dir, 'html')
-                break
 
     def __repr__(self):
         if inspect.stack()[1][3] == '?':
@@ -1761,14 +1768,12 @@
         self.list(self.topics.keys())
 
     def showtopic(self, topic):
-        if not self.docdir:
+        try:
+            import pydoc_topics
+        except ImportError:
             self.output.write('''
-Sorry, topic and keyword documentation is not available because the Python
-HTML documentation files could not be found.  If you have installed them,
-please set the environment variable PYTHONDOCS to indicate their location.
-
-On the Microsoft Windows operating system, the files can be built by
-running "hh -decompile . PythonNN.chm" in the C:\PythonNN\Doc> directory.
+Sorry, topic and keyword documentation is not available because the
+module "pydoc_topics" could not be found.
 ''')
             return
         target = self.topics.get(topic, self.keywords.get(topic))
@@ -1778,31 +1783,15 @@
         if type(target) is type(''):
             return self.showtopic(target)
 
-        filename, xrefs = target
-        filename = self.docdir + '/' + filename + '.html'
+        label, xrefs = target
         try:
-            file = open(filename)
-        except:
-            self.output.write('could not read docs from %s\n' % filename)
+            doc = pydoc_topics.topics[label]
+        except KeyError:
+            self.output.write('no documentation found for %s\n' % repr(topic))
             return
-
-        divpat = re.compile('<div[^>]*navigat.*?</div.*?>', re.I | re.S)
-        addrpat = re.compile('<address.*?>.*?</address.*?>', re.I | re.S)
-        document = re.sub(addrpat, '', re.sub(divpat, '', file.read()))
-        file.close()
-
-        import htmllib, formatter, StringIO
-        buffer = StringIO.StringIO()
-        parser = htmllib.HTMLParser(
-            formatter.AbstractFormatter(formatter.DumbWriter(buffer)))
-        parser.start_table = parser.do_p
-        parser.end_table = lambda parser=parser: parser.do_p({})
-        parser.start_tr = parser.do_br
-        parser.start_td = parser.start_th = lambda a, b=buffer: b.write('\t')
-        parser.feed(document)
-        buffer = replace(buffer.getvalue(), '\xa0', ' ', '\n', '\n  ')
-        pager('  ' + strip(buffer) + '\n')
+        pager(strip(doc) + '\n')
         if xrefs:
+            import StringIO, formatter
             buffer = StringIO.StringIO()
             formatter.DumbWriter(buffer).send_flowing_data(
                 'Related help topics: ' + join(split(xrefs), ', ') + '\n')

Modified: python/branches/tlee-ast-optimize/Lib/sgmllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/sgmllib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/sgmllib.py	Mon Jun  2 15:14:06 2008
@@ -9,6 +9,11 @@
 # not supported at all.
 
 
+from warnings import warnpy3k
+warnpy3k("the sgmllib module has been removed in Python 3.0",
+         stacklevel=2)
+del warnpy3k
+
 import markupbase
 import re
 

Modified: python/branches/tlee-ast-optimize/Lib/test/test_datetime.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_datetime.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_datetime.py	Mon Jun  2 15:14:06 2008
@@ -850,9 +850,13 @@
         self.assertRaises(TypeError, t.strftime, "one", "two") # too many args
         self.assertRaises(TypeError, t.strftime, 42) # arg wrong type
 
+        # test that unicode input is allowed (issue 2782)
+        self.assertEqual(t.strftime(u"%m"), "03")
+
         # A naive object replaces %z and %Z w/ empty strings.
         self.assertEqual(t.strftime("'%z' '%Z'"), "'' ''")
 
+
     def test_format(self):
         dt = self.theclass(2007, 9, 10)
         self.assertEqual(dt.__format__(''), str(dt))

Modified: python/branches/tlee-ast-optimize/Lib/test/test_descrtut.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_descrtut.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_descrtut.py	Mon Jun  2 15:14:06 2008
@@ -208,6 +208,7 @@
      '__setattr__',
      '__setitem__',
      '__setslice__',
+     '__sizeof__',
      '__str__',
      '__subclasshook__',
      'append',

Modified: python/branches/tlee-ast-optimize/Lib/test/test_htmllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_htmllib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_htmllib.py	Mon Jun  2 15:14:06 2008
@@ -1,8 +1,8 @@
 import formatter
-import htmllib
 import unittest
 
 from test import test_support
+htmllib = test_support.import_module('htmllib', deprecated=True)
 
 
 class AnchorCollector(htmllib.HTMLParser):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_py3kwarn.py	Mon Jun  2 15:14:06 2008
@@ -137,7 +137,7 @@
     # import side-effect.
     all_platforms = ('audiodev', 'imputil', 'mutex', 'user', 'new', 'rexec',
                         'Bastion', 'compiler', 'dircache', 'fpformat',
-                        'ihooks', 'mhlib', 'statvfs')
+                        'ihooks', 'mhlib', 'statvfs', 'htmllib', 'sgmllib')
     inclusive_platforms = {'irix' : ('pure', 'AL', 'al', 'CD', 'cd', 'cddb',
                                      'cdplayer', 'CL', 'cl', 'DEVICE', 'GL',
                                      'gl', 'ERRNO', 'FILE', 'FL', 'flp', 'fl',

Modified: python/branches/tlee-ast-optimize/Lib/test/test_sgmllib.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_sgmllib.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_sgmllib.py	Mon Jun  2 15:14:06 2008
@@ -1,8 +1,8 @@
 import pprint
 import re
-import sgmllib
 import unittest
 from test import test_support
+sgmllib = test_support.import_module('sgmllib', deprecated=True)
 
 
 class EventCollector(sgmllib.SGMLParser):

Modified: python/branches/tlee-ast-optimize/Lib/test/test_sys.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_sys.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_sys.py	Mon Jun  2 15:14:06 2008
@@ -1,6 +1,6 @@
 # -*- coding: iso-8859-1 -*-
 import unittest, test.test_support
-import sys, cStringIO
+import sys, cStringIO, os
 
 class SysModuleTest(unittest.TestCase):
 
@@ -405,8 +405,153 @@
         self.assertEqual(out, '?')
 
 
+class SizeofTest(unittest.TestCase):
+
+    def setUp(self):
+        import struct
+        self.i = len(struct.pack('i', 0))
+        self.l = len(struct.pack('l', 0))
+        self.p = len(struct.pack('P', 0))
+        self.headersize = self.l + self.p
+        if hasattr(sys, "gettotalrefcount"):
+            self.headersize += 2 * self.p
+        self.file = open(test.test_support.TESTFN, 'wb')
+
+    def tearDown(self):
+        self.file.close()
+        test.test_support.unlink(test.test_support.TESTFN)
+
+    def check_sizeof(self, o, size):
+        result = sys.getsizeof(o)
+        msg = 'wrong size for %s: got %d, expected %d' \
+            % (type(o), result, size)
+        self.assertEqual(result, size, msg)
+
+    def align(self, value):
+        mod = value % self.p
+        if mod != 0:
+            return value - mod + self.p
+        else:
+            return value
+
+    def test_align(self):
+        self.assertEqual(self.align(0) % self.p, 0)
+        self.assertEqual(self.align(1) % self.p, 0)
+        self.assertEqual(self.align(3) % self.p, 0)
+        self.assertEqual(self.align(4) % self.p, 0)
+        self.assertEqual(self.align(7) % self.p, 0)
+        self.assertEqual(self.align(8) % self.p, 0)
+        self.assertEqual(self.align(9) % self.p, 0)
+
+    def test_standardtypes(self):
+        i = self.i
+        l = self.l
+        p = self.p
+        h = self.headersize
+        # bool
+        self.check_sizeof(True, h + l)
+        # buffer
+        self.check_sizeof(buffer(''), h + 2*p + 2*l + self.align(i) +l)
+        # cell
+        def get_cell():
+            x = 42
+            def inner():
+                return x
+            return inner
+        self.check_sizeof(get_cell().func_closure[0], h + p)
+        # old-style class
+        class class_oldstyle():
+            def method():
+                pass
+        self.check_sizeof(class_oldstyle, h + 6*p)
+        # instance
+        self.check_sizeof(class_oldstyle(), h + 3*p)
+        # method
+        self.check_sizeof(class_oldstyle().method, h + 4*p)
+        # code
+        self.check_sizeof(get_cell().func_code, h + self.align(4*i) + 8*p +\
+                            self.align(i) + 2*p)
+        # complex
+        self.check_sizeof(complex(0,1), h + 2*8)
+        # enumerate
+        self.check_sizeof(enumerate([]), h + l + 3*p)
+        # reverse
+        self.check_sizeof(reversed(''), h + l + p )
+        # file
+        self.check_sizeof(self.file, h + 4*p + self.align(2*i) + 4*p +\
+                            self.align(3*i) + 3*p + self.align(i))
+        # float
+        self.check_sizeof(float(0), h + 8)
+        # function
+        def func(): pass
+        self.check_sizeof(func, h + 9 * l)
+        class c():
+            @staticmethod
+            def foo():
+                pass
+            @classmethod
+            def bar(cls):
+                pass
+            # staticmethod
+            self.check_sizeof(foo, h + l)
+            # classmethod
+            self.check_sizeof(bar, h + l)
+        # generator
+        def get_gen(): yield 1
+        self.check_sizeof(get_gen(), h + p + self.align(i) + 2*p)
+        # integer
+        self.check_sizeof(1, h + l)
+        # builtin_function_or_method
+        self.check_sizeof(abs, h + 3*p)
+        # module
+        self.check_sizeof(unittest, h + p)
+        # xrange
+        self.check_sizeof(xrange(1), h + 3*p)
+        # slice
+        self.check_sizeof(slice(0), h + 3*p)
+
+        h += l
+        # new-style class
+        class class_newstyle(object):
+            def method():
+                pass
+        # type (PyTypeObject + PyNumberMethods +  PyMappingMethods +
+        #       PySequenceMethods +  PyBufferProcs)
+        len_typeobject = p + 2*l + 15*p + l + 4*p + l + 9*p + l + 11*p
+        self.check_sizeof(class_newstyle,
+                          h + len_typeobject + 42*p + 10*p + 3*p + 6*p)
+
+
+    def test_specialtypes(self):
+        i = self.i
+        l = self.l
+        p = self.p
+        h = self.headersize
+        # dict
+        self.check_sizeof({}, h + 3*l + 3*p + 8*(l + 2*p))
+        longdict = {1:1, 2:2, 3:3, 4:4, 5:5, 6:6, 7:7, 8:8}
+        self.check_sizeof(longdict, h + 3*l + 3*p + 8*(l + 2*p) + 16*(l + 2*p))
+        # list
+        self.check_sizeof([], h + l + p + l)
+        self.check_sizeof([1, 2, 3], h + l + p + l + 3*l)
+
+        h += l
+        # long
+        self.check_sizeof(0L, h + self.align(2))
+        self.check_sizeof(1L, h + self.align(2))
+        self.check_sizeof(-1L, h + self.align(2))
+        self.check_sizeof(32768L, h + self.align(2) + 2)
+        self.check_sizeof(32768L*32768L-1, h + self.align(2) + 2)
+        self.check_sizeof(32768L*32768L, h + self.align(2) + 4)
+        # string
+        self.check_sizeof('', h + l + self.align(i + 1))
+        self.check_sizeof('abc', h + l + self.align(i + 1) + 3)
+
+
 def test_main():
-    test.test_support.run_unittest(SysModuleTest)
+    test_classes = (SysModuleTest, SizeofTest)
+
+    test.test_support.run_unittest(*test_classes)
 
 if __name__ == "__main__":
     test_main()

Modified: python/branches/tlee-ast-optimize/Lib/test/test_threading.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/test/test_threading.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/test/test_threading.py	Mon Jun  2 15:14:06 2008
@@ -3,6 +3,7 @@
 import test.test_support
 from test.test_support import verbose
 import random
+import re
 import sys
 import threading
 import thread
@@ -72,6 +73,8 @@
         for i in range(NUMTASKS):
             t = TestThread("<thread %d>"%i, self, sema, mutex, numrunning)
             threads.append(t)
+            self.failUnlessEqual(t.getIdent(), None)
+            self.assert_(re.match('<TestThread\(.*, initial\)>', repr(t)))
             t.start()
 
         if verbose:
@@ -79,6 +82,8 @@
         for t in threads:
             t.join(NUMTASKS)
             self.assert_(not t.isAlive())
+            self.failIfEqual(t.getIdent(), 0)
+            self.assert_(re.match('<TestThread\(.*, \w+ -?\d+\)>', repr(t)))
         if verbose:
             print 'all tasks done'
         self.assertEqual(numrunning.get(), 0)

Modified: python/branches/tlee-ast-optimize/Lib/threading.py
==============================================================================
--- python/branches/tlee-ast-optimize/Lib/threading.py	(original)
+++ python/branches/tlee-ast-optimize/Lib/threading.py	Mon Jun  2 15:14:06 2008
@@ -414,6 +414,7 @@
         self.__args = args
         self.__kwargs = kwargs
         self.__daemonic = self._set_daemon()
+        self.__ident = None
         self.__started = Event()
         self.__stopped = False
         self.__block = Condition(Lock())
@@ -434,7 +435,9 @@
         if self.__stopped:
             status = "stopped"
         if self.__daemonic:
-            status = status + " daemon"
+            status += " daemon"
+        if self.__ident is not None:
+            status += " %s" % self.__ident
         return "<%s(%s, %s)>" % (self.__class__.__name__, self.__name, status)
 
     def start(self):
@@ -481,9 +484,10 @@
 
     def __bootstrap_inner(self):
         try:
+            self.__ident = _get_ident()
             self.__started.set()
             _active_limbo_lock.acquire()
-            _active[_get_ident()] = self
+            _active[self.__ident] = self
             del _limbo[self]
             _active_limbo_lock.release()
             if __debug__:
@@ -635,6 +639,10 @@
         assert self.__initialized, "Thread.__init__() not called"
         self.__name = str(name)
 
+    def getIdent(self):
+        assert self.__initialized, "Thread.__init__() not called"
+        return self.__ident
+
     def isAlive(self):
         assert self.__initialized, "Thread.__init__() not called"
         return self.__started.isSet() and not self.__stopped

Modified: python/branches/tlee-ast-optimize/Misc/NEWS
==============================================================================
--- python/branches/tlee-ast-optimize/Misc/NEWS	(original)
+++ python/branches/tlee-ast-optimize/Misc/NEWS	Mon Jun  2 15:14:06 2008
@@ -12,6 +12,8 @@
 Core and Builtins
 -----------------
 
+- Issue #2898: Added sys.getsizeof() to retrieve size of objects in bytes.
+
 - New environment variable PYTHONIOENCODING.
 
 - Patch #2488: Add sys.maxsize.
@@ -65,11 +67,22 @@
 
 - Issue #2870: cmathmodule.c compile error.
 
+- Added a threading.Thread.getIdent() method.
+
 Library
 -------
 
-- Issue #3011: locale module alias table was updated to the latest version
-  from the X.org locale.alias file
+- Patch #2125: Add GetInteger and GetString methods for 
+  msilib.Record objects.
+
+- Issue #2782: The datetime module's strftime methods now accept
+  unicode format strings just as time.strftime always has.
+
+- The sgmllib and htmllib modules have been deprecated for removal
+  in Python 3.0.
+
+- Issue #3011: locale module alias table was updated to the latest
+  version from the X.org locale.alias file.
 
 - Issue #1797 (partial fix): ctypes NULL function pointers have a
   False boolean value now.

Modified: python/branches/tlee-ast-optimize/Modules/datetimemodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Modules/datetimemodule.c	(original)
+++ python/branches/tlee-ast-optimize/Modules/datetimemodule.c	Mon Jun  2 15:14:06 2008
@@ -2,6 +2,8 @@
  *  http://www.zope.org/Members/fdrake/DateTimeWiki/FrontPage
  */
 
+#define PY_SSIZE_T_CLEAN
+
 #include "Python.h"
 #include "modsupport.h"
 #include "structmember.h"
@@ -1152,8 +1154,8 @@
  * needed.
  */
 static PyObject *
-wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
-	      PyObject *tzinfoarg)
+wrap_strftime(PyObject *object, const char *format, size_t format_len,
+		PyObject *timetuple, PyObject *tzinfoarg)
 {
 	PyObject *result = NULL;	/* guilty until proved innocent */
 
@@ -1161,20 +1163,19 @@
 	PyObject *Zreplacement = NULL;	/* py string, replacement for %Z */
 	PyObject *freplacement = NULL;	/* py string, replacement for %f */
 
-	char *pin;	/* pointer to next char in input format */
-	char ch;	/* next char in input format */
+	const char *pin;	/* pointer to next char in input format */
+	char ch;		/* next char in input format */
 
 	PyObject *newfmt = NULL;	/* py string, the output format */
 	char *pnew;	/* pointer to available byte in output format */
-	int totalnew;	/* number bytes total in output format buffer,
-			   exclusive of trailing \0 */
-	int usednew;	/* number bytes used so far in output format buffer */
+	size_t totalnew;	/* number bytes total in output format buffer,
+				   exclusive of trailing \0 */
+	size_t usednew;	/* number bytes used so far in output format buffer */
 
-	char *ptoappend; /* pointer to string to append to output buffer */
-	int ntoappend;	/* # of bytes to append to output buffer */
+	const char *ptoappend;	/* ptr to string to append to output buffer */
+	size_t ntoappend;	/* # of bytes to append to output buffer */
 
 	assert(object && format && timetuple);
-	assert(PyBytes_Check(format));
 
 	/* Give up if the year is before 1900.
 	 * Python strftime() plays games with the year, and different
@@ -1205,13 +1206,13 @@
 	 * a new format.  Since computing the replacements for those codes
 	 * is expensive, don't unless they're actually used.
 	 */
-	totalnew = PyBytes_Size(format) + 1;	/* realistic if no %z/%Z/%f */
+	totalnew = format_len + 1;	/* realistic if no %z/%Z/%f */
 	newfmt = PyBytes_FromStringAndSize(NULL, totalnew);
 	if (newfmt == NULL) goto Done;
 	pnew = PyBytes_AsString(newfmt);
 	usednew = 0;
 
-	pin = PyBytes_AsString(format);
+	pin = format;
 	while ((ch = *pin++) != '\0') {
 		if (ch != '%') {
 			ptoappend = pin - 1;
@@ -1313,7 +1314,7 @@
  		if (ntoappend == 0)
  			continue;
  		while (usednew + ntoappend > totalnew) {
- 			int bigger = totalnew << 1;
+ 			size_t bigger = totalnew << 1;
  			if ((bigger >> 1) != totalnew) { /* overflow */
  				PyErr_NoMemory();
  				goto Done;
@@ -2480,18 +2481,19 @@
 	 * timetuple() method appropriate to self's class.
 	 */
 	PyObject *result;
-	PyObject *format;
 	PyObject *tuple;
+	const char *format;
+	Py_ssize_t format_len;
 	static char *keywords[] = {"format", NULL};
 
-	if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords,
-					  &PyBytes_Type, &format))
+	if (! PyArg_ParseTupleAndKeywords(args, kw, "s#:strftime", keywords,
+					  &format, &format_len))
 		return NULL;
 
 	tuple = PyObject_CallMethod((PyObject *)self, "timetuple", "()");
 	if (tuple == NULL)
 		return NULL;
-	result = wrap_strftime((PyObject *)self, format, tuple,
+	result = wrap_strftime((PyObject *)self, format, format_len, tuple,
 			       (PyObject *)self);
 	Py_DECREF(tuple);
 	return result;
@@ -3256,12 +3258,13 @@
 time_strftime(PyDateTime_Time *self, PyObject *args, PyObject *kw)
 {
 	PyObject *result;
-	PyObject *format;
 	PyObject *tuple;
+	const char *format;
+	Py_ssize_t format_len;
 	static char *keywords[] = {"format", NULL};
 
-	if (! PyArg_ParseTupleAndKeywords(args, kw, "O!:strftime", keywords,
-					  &PyBytes_Type, &format))
+	if (! PyArg_ParseTupleAndKeywords(args, kw, "s#:strftime", keywords,
+					  &format, &format_len))
 		return NULL;
 
 	/* Python's strftime does insane things with the year part of the
@@ -3277,7 +3280,8 @@
 	if (tuple == NULL)
 		return NULL;
 	assert(PyTuple_Size(tuple) == 9);
-	result = wrap_strftime((PyObject *)self, format, tuple, Py_None);
+	result = wrap_strftime((PyObject *)self, format, format_len, tuple,
+			       Py_None);
 	Py_DECREF(tuple);
 	return result;
 }

Modified: python/branches/tlee-ast-optimize/Objects/bytesobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/bytesobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/bytesobject.c	Mon Jun  2 15:14:06 2008
@@ -3917,6 +3917,17 @@
     return NULL;
 }
 
+PyDoc_STRVAR(sizeof__doc__,
+"S.__sizeof__() -> size of S in memory, in bytes");
+
+static PyObject *
+string_sizeof(PyBytesObject *v)
+{
+	Py_ssize_t res;
+	res = sizeof(PyBytesObject) + v->ob_size * v->ob_type->tp_itemsize;
+	return PyInt_FromSsize_t(res);
+}
+
 #undef SPLIT_APPEND
 #undef SPLIT_ADD
 #undef MAX_PREALLOC
@@ -4024,6 +4035,8 @@
 	 expandtabs__doc__},
 	{"splitlines", (PyCFunction)string_splitlines, METH_VARARGS,
 	 splitlines__doc__},
+	{"__sizeof__", (PyCFunction)string_sizeof, METH_NOARGS,
+	 sizeof__doc__},
 	{"__getnewargs__",	(PyCFunction)string_getnewargs,	METH_NOARGS},
 	{NULL,     NULL}		     /* sentinel */
 };

Modified: python/branches/tlee-ast-optimize/Objects/dictobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/dictobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/dictobject.c	Mon Jun  2 15:14:06 2008
@@ -2032,6 +2032,16 @@
 	return dictiter_new(dict, &PyDictIterItem_Type);
 }
 
+static PyObject *
+dict_sizeof(PyDictObject *mp)
+{
+	Py_ssize_t res;
+
+	res = sizeof(PyDictObject) + sizeof(mp->ma_table);
+	if (mp->ma_table != mp->ma_smalltable)
+		res = res + (mp->ma_mask + 1) * sizeof(PyDictEntry);
+	return PyInt_FromSsize_t(res);
+}
 
 PyDoc_STRVAR(has_key__doc__,
 "D.has_key(k) -> True if D has a key k, else False");
@@ -2041,6 +2051,9 @@
 
 PyDoc_STRVAR(getitem__doc__, "x.__getitem__(y) <==> x[y]");
 
+PyDoc_STRVAR(sizeof__doc__,
+"D.__sizeof__() -> size of D in memory, in bytes");
+
 PyDoc_STRVAR(get__doc__,
 "D.get(k[,d]) -> D[k] if k in D, else d.  d defaults to None.");
 
@@ -2092,6 +2105,8 @@
 	 contains__doc__},
 	{"__getitem__", (PyCFunction)dict_subscript,	METH_O | METH_COEXIST,
 	 getitem__doc__},
+	{"__sizeof__",	(PyCFunction)dict_sizeof,	METH_NOARGS,
+	 sizeof__doc__},
 	{"has_key",	(PyCFunction)dict_has_key,      METH_O,
 	 has_key__doc__},
 	{"get",         (PyCFunction)dict_get,          METH_VARARGS,

Modified: python/branches/tlee-ast-optimize/Objects/listobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/listobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/listobject.c	Mon Jun  2 15:14:06 2008
@@ -2420,6 +2420,15 @@
 	return 0;
 }
 
+static PyObject *
+list_sizeof(PyListObject *self)
+{
+	Py_ssize_t res;
+
+	res = sizeof(PyListObject) + self->allocated * sizeof(void*);
+	return PyInt_FromSsize_t(res);
+}
+
 static PyObject *list_iter(PyObject *seq);
 static PyObject *list_reversed(PyListObject* seq, PyObject* unused);
 
@@ -2427,6 +2436,8 @@
 "x.__getitem__(y) <==> x[y]");
 PyDoc_STRVAR(reversed_doc,
 "L.__reversed__() -- return a reverse iterator over the list");
+PyDoc_STRVAR(sizeof_doc,
+"L.__sizeof__() -- size of L in memory, in bytes");
 PyDoc_STRVAR(append_doc,
 "L.append(object) -- append object to end");
 PyDoc_STRVAR(extend_doc,
@@ -2452,6 +2463,7 @@
 static PyMethodDef list_methods[] = {
 	{"__getitem__", (PyCFunction)list_subscript, METH_O|METH_COEXIST, getitem_doc},
 	{"__reversed__",(PyCFunction)list_reversed, METH_NOARGS, reversed_doc},
+	{"__sizeof__",  (PyCFunction)list_sizeof, METH_NOARGS, sizeof_doc},
 	{"append",	(PyCFunction)listappend,  METH_O, append_doc},
 	{"insert",	(PyCFunction)listinsert,  METH_VARARGS, insert_doc},
 	{"extend",      (PyCFunction)listextend,  METH_O, extend_doc},

Modified: python/branches/tlee-ast-optimize/Objects/longobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/longobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/longobject.c	Mon Jun  2 15:14:06 2008
@@ -3436,6 +3436,17 @@
 	return NULL;
 }
 
+static PyObject *
+long_sizeof(PyLongObject *v)
+{
+	Py_ssize_t res;
+
+	res = sizeof(PyLongObject) + abs(v->ob_size) * sizeof(digit);
+        if (v->ob_size != 0)
+		res -=  sizeof(digit);
+	return PyInt_FromSsize_t(res);
+}
+
 #if 0
 static PyObject *
 long_is_finite(PyObject *v)
@@ -3455,6 +3466,8 @@
          "Truncating an Integral returns itself."},
 	{"__getnewargs__",	(PyCFunction)long_getnewargs,	METH_NOARGS},
         {"__format__", (PyCFunction)long__format__, METH_VARARGS},
+	{"__sizeof__",	(PyCFunction)long_sizeof, METH_NOARGS,
+	 "Returns size in memory, in bytes"},
 	{NULL,		NULL}		/* sentinel */
 };
 

Modified: python/branches/tlee-ast-optimize/Objects/typeobject.c
==============================================================================
--- python/branches/tlee-ast-optimize/Objects/typeobject.c	(original)
+++ python/branches/tlee-ast-optimize/Objects/typeobject.c	Mon Jun  2 15:14:06 2008
@@ -3397,6 +3397,20 @@
         return result;
 }
 
+static PyObject *
+object_sizeof(PyObject *self, PyObject *args)
+{
+	Py_ssize_t res, isize;
+
+	res = 0;
+	isize = self->ob_type->tp_itemsize;
+	if (isize > 0)
+		res = self->ob_type->ob_size * isize;
+	res += self->ob_type->tp_basicsize;
+
+	return PyInt_FromSsize_t(res);	 
+}
+
 static PyMethodDef object_methods[] = {
 	{"__reduce_ex__", object_reduce_ex, METH_VARARGS,
 	 PyDoc_STR("helper for pickle")},
@@ -3406,6 +3420,8 @@
 	 object_subclasshook_doc},
         {"__format__", object_format, METH_VARARGS,
          PyDoc_STR("default object formatter")},
+        {"__sizeof__", object_sizeof, METH_NOARGS,
+         PyDoc_STR("__sizeof__() -> size of object in memory, in bytes")},
 	{0}
 };
 

Modified: python/branches/tlee-ast-optimize/PC/_msi.c
==============================================================================
--- python/branches/tlee-ast-optimize/PC/_msi.c	(original)
+++ python/branches/tlee-ast-optimize/PC/_msi.c	Mon Jun  2 15:14:06 2008
@@ -339,6 +339,49 @@
 }
 
 static PyObject*
+record_getinteger(msiobj* record, PyObject* args)
+{
+    unsigned int field;
+    int status;
+    
+    if (!PyArg_ParseTuple(args, "I:GetInteger", &field))
+        return NULL;
+    status = MsiRecordGetInteger(record->h, field);
+    if (status == MSI_NULL_INTEGER){
+        PyErr_SetString(MSIError, "could not convert record field to integer");
+        return NULL;
+    }
+    return PyInt_FromLong((long) status);
+}
+
+static PyObject*
+record_getstring(msiobj* record, PyObject* args)
+{
+    unsigned int field;
+    unsigned int status;
+    char buf[2000];
+    char *res = buf;
+    DWORD size = sizeof(buf);
+    PyObject* string;
+    
+    if (!PyArg_ParseTuple(args, "I:GetString", &field))
+        return NULL;
+    status = MsiRecordGetString(record->h, field, res, &size);
+    if (status == ERROR_MORE_DATA) {
+        res = (char*) malloc(size + 1);
+        if (res == NULL)
+            return PyErr_NoMemory();
+        status = MsiRecordGetString(record->h, field, res, &size);
+    }
+    if (status != ERROR_SUCCESS)
+        return msierror((int) status);
+    string = PyString_FromString(res);
+    if (buf != res)
+        free(res);
+    return string;
+}
+
+static PyObject*
 record_cleardata(msiobj* record, PyObject *args)
 {
     int status = MsiRecordClearData(record->h);
@@ -405,6 +448,10 @@
 static PyMethodDef record_methods[] = {
     { "GetFieldCount", (PyCFunction)record_getfieldcount, METH_NOARGS, 
 	PyDoc_STR("GetFieldCount() -> int\nWraps MsiRecordGetFieldCount")},
+    { "GetInteger", (PyCFunction)record_getinteger, METH_VARARGS,
+    PyDoc_STR("GetInteger(field) -> int\nWraps MsiRecordGetInteger")},
+    { "GetString", (PyCFunction)record_getstring, METH_VARARGS,
+    PyDoc_STR("GetString(field) -> string\nWraps MsiRecordGetString")},
     { "SetString", (PyCFunction)record_setstring, METH_VARARGS, 
 	PyDoc_STR("SetString(field,str) -> None\nWraps MsiRecordSetString")},
     { "SetStream", (PyCFunction)record_setstream, METH_VARARGS, 

Modified: python/branches/tlee-ast-optimize/Python/sysmodule.c
==============================================================================
--- python/branches/tlee-ast-optimize/Python/sysmodule.c	(original)
+++ python/branches/tlee-ast-optimize/Python/sysmodule.c	Mon Jun  2 15:14:06 2008
@@ -640,6 +640,45 @@
 #endif /* USE_MALLOPT */
 
 static PyObject *
+sys_getsizeof(PyObject *self, PyObject *args)
+{
+	static PyObject * str__sizeof__ = NULL;
+
+	/* Initialize static variable needed by _PyType_Lookup */
+	if (str__sizeof__ == NULL) {
+		str__sizeof__ = PyString_InternFromString("__sizeof__");
+		if (str__sizeof__ == NULL)
+			return NULL;
+	}
+
+	/* Type objects */
+	if (PyType_Check(args)){
+		PyObject *method = _PyType_Lookup(Py_TYPE(args),
+						  str__sizeof__);
+		if (method == NULL) {
+			PyErr_Format(PyExc_TypeError,
+				     "Type %.100s doesn't define __sizeof__",
+				     Py_TYPE(args)->tp_name);
+			return NULL;
+		}
+		return PyObject_CallFunctionObjArgs(method, args, NULL);
+	} 
+	/* Instance of old-style classes */
+	else if (PyInstance_Check(args))
+		return PyInt_FromSsize_t(PyInstance_Type.tp_basicsize);
+	/* Old-style classes */
+	else if (PyClass_Check(args))
+		return PyInt_FromSsize_t(PyClass_Type.tp_basicsize);
+	else
+		return PyObject_CallMethod(args, "__sizeof__", NULL);
+}
+
+PyDoc_STRVAR(getsizeof_doc,
+"getsizeof(object) -> int\n\
+\n\
+Return the size of object in bytes.");
+
+static PyObject *
 sys_getrefcount(PyObject *self, PyObject *arg)
 {
 	return PyInt_FromSsize_t(arg->ob_refcnt);
@@ -850,6 +889,7 @@
 	{"getrefcount",	(PyCFunction)sys_getrefcount, METH_O, getrefcount_doc},
 	{"getrecursionlimit", (PyCFunction)sys_getrecursionlimit, METH_NOARGS,
 	 getrecursionlimit_doc},
+ 	{"getsizeof",	sys_getsizeof,  METH_O, getsizeof_doc},
 	{"_getframe", sys_getframe, METH_VARARGS, getframe_doc},
 #ifdef MS_WINDOWS
 	{"getwindowsversion", (PyCFunction)sys_getwindowsversion, METH_NOARGS,
@@ -1031,6 +1071,7 @@
 getprofile() -- get the global profiling function\n\
 getrefcount() -- return the reference count for an object (plus one :-)\n\
 getrecursionlimit() -- return the max recursion depth for the interpreter\n\
+getsizeof() -- return the size of an object in bytes\n\
 gettrace() -- get the global debug tracing function\n\
 setcheckinterval() -- control how often the interpreter checks for events\n\
 setdlopenflags() -- set the flags to be used for dlopen() calls\n\

Modified: python/branches/tlee-ast-optimize/Tools/README
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/README	(original)
+++ python/branches/tlee-ast-optimize/Tools/README	Mon Jun  2 15:14:06 2008
@@ -9,6 +9,7 @@
 
 bgen		Generate complete extension modules from a
 		description.  Still under development!
+		WARNING: bgen has been removed in 3.0.
 
 compiler	Tools used to maintain the compiler package in the
 		standard library.

Modified: python/branches/tlee-ast-optimize/Tools/bgen/README
==============================================================================
--- python/branches/tlee-ast-optimize/Tools/bgen/README	(original)
+++ python/branches/tlee-ast-optimize/Tools/bgen/README	Mon Jun  2 15:14:06 2008
@@ -5,3 +5,5 @@
 complete source code for Python extension module.  For examples of its
 use, see the Mac Python source distribution (available separately
 from the Python ftp archives).  Note that BGEN is not Mac specific!
+
+WARNING: bgen has been removed in 3.0.


More information about the Python-checkins mailing list