From python-3000-checkins at python.org Sat Dec 1 00:30:41 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Sat, 1 Dec 2007 00:30:41 +0100 (CET) Subject: [Python-3000-checkins] r59250 - python/branches/py3k/Objects/descrobject.c Message-ID: <20071130233041.1E8621E4022@bag.python.org> Author: guido.van.rossum Date: Sat Dec 1 00:30:40 2007 New Revision: 59250 Modified: python/branches/py3k/Objects/descrobject.c Log: Rename the internal name of dictproxy -> dict_proxy, in analogy with dict_keys etc. Modified: python/branches/py3k/Objects/descrobject.c ============================================================================== --- python/branches/py3k/Objects/descrobject.c (original) +++ python/branches/py3k/Objects/descrobject.c Sat Dec 1 00:30:40 2007 @@ -788,7 +788,7 @@ PyTypeObject PyDictProxy_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) - "dictproxy", /* tp_name */ + "dict_proxy", /* tp_name */ sizeof(proxyobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ From python-3000-checkins at python.org Sat Dec 1 00:34:21 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 1 Dec 2007 00:34:21 +0100 (CET) Subject: [Python-3000-checkins] r59251 - python/branches/py3k/Modules/socketmodule.h Message-ID: <20071130233421.E99E31E4021@bag.python.org> Author: christian.heimes Date: Sat Dec 1 00:34:21 2007 New Revision: 59251 Modified: python/branches/py3k/Modules/socketmodule.h Log: Marc-Andre Lemburg has found the culprit of the problem in r57142. Modified: python/branches/py3k/Modules/socketmodule.h ============================================================================== --- python/branches/py3k/Modules/socketmodule.h (original) +++ python/branches/py3k/Modules/socketmodule.h Sat Dec 1 00:34:21 2007 @@ -8,7 +8,7 @@ # include # endif # include -# if defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP)) +# if !(defined(__CYGWIN__) || (defined(PYOS_OS2) && defined(PYCC_VACPP))) # include # endif From python-3000-checkins at python.org Sat Dec 1 00:45:17 2007 From: python-3000-checkins at python.org (amaury.forgeotdarc) Date: Sat, 1 Dec 2007 00:45:17 +0100 (CET) Subject: [Python-3000-checkins] r59252 - python/branches/py3k/Lib/test/test_bigmem.py Message-ID: <20071130234517.5F0991E4021@bag.python.org> Author: amaury.forgeotdarc Date: Sat Dec 1 00:45:17 2007 New Revision: 59252 Modified: python/branches/py3k/Lib/test/test_bigmem.py Log: Correct a failing test after merge from trunk. Modified: python/branches/py3k/Lib/test/test_bigmem.py ============================================================================== --- python/branches/py3k/Lib/test/test_bigmem.py (original) +++ python/branches/py3k/Lib/test/test_bigmem.py Sat Dec 1 00:45:17 2007 @@ -66,12 +66,12 @@ @bigmemtest(minsize=_2G + 2, memuse=3) def test_decode(self, size): - s = '.' * size + s = b'.' * size self.assertEquals(len(s.decode('utf-8')), size) @bigmemtest(minsize=_2G + 2, memuse=3) def test_encode(self, size): - s = u'.' * size + s = '.' * size self.assertEquals(len(s.encode('utf-8')), size) @bigmemtest(minsize=_2G, memuse=2) From python-3000-checkins at python.org Sat Dec 1 13:22:32 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 1 Dec 2007 13:22:32 +0100 (CET) Subject: [Python-3000-checkins] r59255 - in python/branches/py3k: Doc/c-api/concrete.rst Doc/library/os.rst Doc/library/sys.rst Include/floatobject.h Lib/test/regrtest.py Lib/test/test_sys.py Objects/floatobject.c PC/pyconfig.h PCbuild9/pythoncore.vcproj Python/sysmodule.c Message-ID: <20071201122232.AD4E41E4003@bag.python.org> Author: christian.heimes Date: Sat Dec 1 13:22:32 2007 New Revision: 59255 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/concrete.rst python/branches/py3k/Doc/library/os.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Include/floatobject.h python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/test_sys.py python/branches/py3k/Objects/floatobject.c python/branches/py3k/PC/pyconfig.h python/branches/py3k/PCbuild9/pythoncore.vcproj python/branches/py3k/Python/sysmodule.c Log: Merged revisions 59245-59254 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59245 | georg.brandl | 2007-11-30 23:04:45 +0100 (Fri, 30 Nov 2007) | 2 lines Move lchmod() docs to correct place, and add versionadded tags. ........ r59249 | christian.heimes | 2007-11-30 23:36:10 +0100 (Fri, 30 Nov 2007) | 2 lines Backport of -r59242:59246 from py3k Fixed problem with regrtest caused by the additional of objects to _abcoll. ........ r59253 | christian.heimes | 2007-12-01 02:03:20 +0100 (Sat, 01 Dec 2007) | 1 line Although pyconfig.h claims that WIN32 is obsolete it is still required for the locale module. locale.getdefaultlocale() fails silently w/o the WIN32 macro. ........ r59254 | christian.heimes | 2007-12-01 12:20:10 +0100 (Sat, 01 Dec 2007) | 3 lines Feature #1534 Added PyFloat_GetMax(), PyFloat_GetMin() and PyFloat_GetInfo() to the float API. Added a dictionary sys.float_info with information about the internal floating point type to the sys module. ........ Modified: python/branches/py3k/Doc/c-api/concrete.rst ============================================================================== --- python/branches/py3k/Doc/c-api/concrete.rst (original) +++ python/branches/py3k/Doc/c-api/concrete.rst Sat Dec 1 13:22:32 2007 @@ -499,6 +499,23 @@ without error checking. +.. cfunction:: PyObject* PyFloat_GetInfo(void) + + Return a :ctype:`PyDictObject` object which contains information about the + precision, minimum and maximum values of a float. It's a thin wrapper + around the header file :file:`float.h`. + + +.. cfunction:: double PyFloat_GetMax(void) + + Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`. + + +.. cfunction:: double PyFloat_GetMin(void) + + Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`. + + .. _complexobjects: Complex Number Objects Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Sat Dec 1 13:22:32 2007 @@ -422,6 +422,8 @@ Change the mode of the file given by *fd* to the numeric *mode*. See the docs for :func:`chmod` for possible values of *mode*. Availability: Unix. + .. versionadded:: 2.6 + .. function:: fchown(fd, uid, gid) @@ -429,6 +431,8 @@ and *gid*. To leave one of the ids unchanged, set it to -1. Availability: Unix. + .. versionadded:: 2.6 + .. function:: fdatasync(fd) @@ -488,13 +492,6 @@ tty(-like) device, else ``False``. Availability: Macintosh, Unix. -.. function:: lchmod(path, mode) - - Change the mode of *path* to the numeric *mode*. If path is a symlink, this - affects the symlink rather than the target. See the docs for :func:`chmod` - for possible values of *mode*. Availability: Unix. - - .. function:: lseek(fd, pos, how) Set the current position of file descriptor *fd* to position *pos*, modified by @@ -800,6 +797,15 @@ follow symbolic links. Availability: Unix. +.. function:: lchmod(path, mode) + + Change the mode of *path* to the numeric *mode*. If path is a symlink, this + affects the symlink rather than the target. See the docs for :func:`chmod` + for possible values of *mode*. Availability: Unix. + + .. versionadded:: 2.6 + + .. function:: lchown(path, uid, gid) Change the owner and group id of *path* to the numeric *uid* and gid. This Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Sat Dec 1 13:22:32 2007 @@ -184,6 +184,48 @@ error occurs. +.. data:: float_info + + A dict holding information about the float type. It contains low level + information about the precision and internal representation. Please study + your system's :file:`float.h` for more information. + + +---------------------+--------------------------------------------------+ + | key | explanation | + +=====================+==================================================+ + | :const:`epsilon` | Difference between 1 and the next representable | + | | floating point number | + +---------------------+--------------------------------------------------+ + | :const:`dig` | digits (see :file:`float.h`) | + +---------------------+--------------------------------------------------+ + | :const:`mant_dig` | mantissa digits (see :file:`float.h`) | + +---------------------+--------------------------------------------------+ + | :const:`max` | maximum representable finite float | + +---------------------+--------------------------------------------------+ + | :const:`max_exp` | maximum int e such that radix**(e-1) is in the | + | | range of finite representable floats | + +---------------------+--------------------------------------------------+ + | :const:`max_10_exp` | maximum int e such that 10**e is in the | + | | range of finite representable floats | + +---------------------+--------------------------------------------------+ + | :const:`min` | Minimum positive normalizer float | + +---------------------+--------------------------------------------------+ + | :const:`min_exp` | minimum int e such that radix**(e-1) is a | + | | normalized float | + +---------------------+--------------------------------------------------+ + | :const:`min_10_exp` | minimum int e such that 10**e is a normalized | + | | float | + +---------------------+--------------------------------------------------+ + | :const:`radix` | radix of exponent | + +---------------------+--------------------------------------------------+ + | :const:`rounds` | addition rounds (see :file:`float.h`) | + +---------------------+--------------------------------------------------+ + + .. note:: + + The information in the table is simplified. + + .. function:: getcheckinterval() Return the interpreter's "check interval"; see :func:`setcheckinterval`. Modified: python/branches/py3k/Include/floatobject.h ============================================================================== --- python/branches/py3k/Include/floatobject.h (original) +++ python/branches/py3k/Include/floatobject.h Sat Dec 1 13:22:32 2007 @@ -21,6 +21,10 @@ #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) #define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type) +PyAPI_FUNC(double) PyFloat_GetMax(void); +PyAPI_FUNC(double) PyFloat_GetMin(void); +PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); + /* Return Python float from string PyObject. */ PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*); Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Sat Dec 1 13:22:32 2007 @@ -699,10 +699,12 @@ fs = warnings.filters[:] ps = copy_reg.dispatch_table.copy() pic = sys.path_importer_cache.copy() - abcs = {obj: obj._abc_registry.copy() - for abc in [getattr(_abcoll, a) for a in _abcoll.__all__ - if issubclass(getattr(_abcoll, a), _Abstract)] - for obj in abc.__subclasses__() + [abc]} + abcs = {} + for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: + if not isinstance(abc, _Abstract): + continue + for obj in abc.__subclasses__() + [abc]: + abcs[obj] = obj._abc_registry.copy() if indirect_test: def run_the_test(): Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Sat Dec 1 13:22:32 2007 @@ -279,6 +279,8 @@ self.assert_(isinstance(sys.copyright, str)) self.assert_(isinstance(sys.exec_prefix, str)) self.assert_(isinstance(sys.executable, str)) + self.assert_(isinstance(sys.float_info, dict)) + self.assertEqual(len(sys.float_info), 11) self.assert_(isinstance(sys.hexversion, int)) self.assert_(isinstance(sys.maxint, int)) self.assert_(isinstance(sys.maxunicode, int)) Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Sat Dec 1 13:22:32 2007 @@ -9,6 +9,7 @@ #include "formatter_unicode.h" #include +#include #if !defined(__STDC__) extern double fmod(double, double); @@ -48,6 +49,52 @@ return p + N_FLOATOBJECTS - 1; } +double +PyFloat_GetMax(void) +{ + return DBL_MAX; +} + +double +PyFloat_GetMin(void) +{ + return DBL_MIN; +} + +PyObject * +PyFloat_GetInfo(void) +{ + PyObject *d, *tmp; + +#define SET_FLOAT_CONST(d, key, const) \ + tmp = PyFloat_FromDouble(const); \ + if (tmp == NULL) return NULL; \ + if (PyDict_SetItemString(d, key, tmp)) return NULL; \ + Py_DECREF(tmp) +#define SET_INT_CONST(d, key, const) \ + tmp = PyInt_FromLong(const); \ + if (tmp == NULL) return NULL; \ + if (PyDict_SetItemString(d, key, tmp)) return NULL; \ + Py_DECREF(tmp) + + d = PyDict_New(); + + SET_FLOAT_CONST(d, "max", DBL_MAX); + SET_INT_CONST(d, "max_exp", DBL_MAX_EXP); + SET_INT_CONST(d, "max_10_exp", DBL_MAX_10_EXP); + SET_FLOAT_CONST(d, "min", DBL_MIN); + SET_INT_CONST(d, "min_exp", DBL_MIN_EXP); + SET_INT_CONST(d, "min_10_exp", DBL_MIN_10_EXP); + SET_INT_CONST(d, "dig", DBL_DIG); + SET_INT_CONST(d, "mant_dig", DBL_MANT_DIG); + SET_FLOAT_CONST(d, "epsilon", DBL_EPSILON); + SET_INT_CONST(d, "radix", FLT_RADIX); + SET_INT_CONST(d, "rounds", FLT_ROUNDS); + + return d; +} + + PyObject * PyFloat_FromDouble(double fval) { Modified: python/branches/py3k/PC/pyconfig.h ============================================================================== --- python/branches/py3k/PC/pyconfig.h (original) +++ python/branches/py3k/PC/pyconfig.h Sat Dec 1 13:22:32 2007 @@ -23,9 +23,11 @@ NOTE: The following symbols are deprecated: -NT, WIN32, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT +NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT MS_CORE_DLL. +WIN32 is still required for the locale module. + */ #ifdef _WIN32_WCE Modified: python/branches/py3k/PCbuild9/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/pythoncore.vcproj (original) +++ python/branches/py3k/PCbuild9/pythoncore.vcproj Sat Dec 1 13:22:32 2007 @@ -44,7 +44,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/Zm200 " AdditionalIncludeDirectories="..\Python;..\Modules\zlib" - PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED" + PreprocessorDefinitions="_USRDLL;Py_BUILD_CORE;Py_ENABLE_SHARED;WIN32" RuntimeLibrary="2" /> Author: georg.brandl Date: Sat Dec 1 14:31:39 2007 New Revision: 59257 Modified: python/branches/py3k/Doc/library/os.rst Log: Remove merged versionadded tags from os docs. Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Sat Dec 1 14:31:39 2007 @@ -114,10 +114,6 @@ automatically when an item is deleted from ``os.environ``, and when one of the :meth:`pop` or :meth:`clear` methods is called. - .. versionchanged:: 2.6 - Also unset environment variables when calling :meth:`os.environ.clear` - and :meth:`os.environ.pop`. - .. function:: chdir(path) fchdir(fd) @@ -422,8 +418,6 @@ Change the mode of the file given by *fd* to the numeric *mode*. See the docs for :func:`chmod` for possible values of *mode*. Availability: Unix. - .. versionadded:: 2.6 - .. function:: fchown(fd, uid, gid) @@ -431,8 +425,6 @@ and *gid*. To leave one of the ids unchanged, set it to -1. Availability: Unix. - .. versionadded:: 2.6 - .. function:: fdatasync(fd) @@ -803,8 +795,6 @@ affects the symlink rather than the target. See the docs for :func:`chmod` for possible values of *mode*. Availability: Unix. - .. versionadded:: 2.6 - .. function:: lchown(path, uid, gid) From python-3000-checkins at python.org Sat Dec 1 16:42:08 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 1 Dec 2007 16:42:08 +0100 (CET) Subject: [Python-3000-checkins] r59259 - python/branches/py3k Message-ID: <20071201154208.D455D1E4003@bag.python.org> Author: christian.heimes Date: Sat Dec 1 16:42:08 2007 New Revision: 59259 Modified: python/branches/py3k/ (props changed) Log: Empty svnmerge from trunk to skip the versionadded tags. From python-3000-checkins at python.org Sun Dec 2 10:40:09 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Sun, 2 Dec 2007 10:40:09 +0100 (CET) Subject: [Python-3000-checkins] r59268 - in python/branches/py3k: Demo/classes/Range.py Demo/imputil/knee.py Demo/pdist/client.py Doc/c-api/init.rst Doc/c-api/intro.rst Doc/glossary.rst Doc/library/__builtin__.rst Doc/library/builtins.rst Doc/library/functions.rst Doc/library/imputil.rst Doc/library/python.rst Doc/library/rlcompleter.rst Doc/library/runpy.rst Doc/library/sys.rst Doc/reference/executionmodel.rst Doc/reference/lexical_analysis.rst Doc/reference/toplevel_components.rst Doc/tutorial/classes.rst Doc/tutorial/modules.rst Include/object.h Lib/aifc.py Lib/codecs.py Lib/dumbdbm.py Lib/gettext.py Lib/gzip.py Lib/idlelib/ColorDelegator.py Lib/idlelib/RemoteDebugger.py Lib/ihooks.py Lib/imputil.py Lib/inspect.py Lib/io.py Lib/locale.py Lib/optparse.py Lib/pickletools.py Lib/plat-mac/icopen.py Lib/py_compile.py Lib/pydoc.py Lib/repr.py Lib/rlcompleter.py Lib/site.py Lib/sunau.py Lib/tarfile.py Lib/test/pickletester.py Lib/test/test_compile.py Lib/test/test_exceptions.py Lib/test/test_gettext.py Lib/test/test_inspect.py Lib/test/test_iterlen.py Lib/test/test_pep352.py Lib/test/test_site.py Lib/test/test_sys.py Lib/test/test_traceback.py Lib/traceback.py Lib/wave.py Misc/Vim/vim_syntax.py Modules/_bsddb.c Modules/_lsprof.c Modules/config.c.in Objects/exceptions.c Objects/listobject.c Objects/typeobject.c PC/bdist_wininst/install.c PC/config.c PC/os2emx/config.c PC/os2vacpp/config.c Python/bltinmodule.c Python/errors.c Python/import.c Python/pythonrun.c Python/sysmodule.c Tools/freeze/makeconfig.py Message-ID: <20071202094009.18F3E1E4020@bag.python.org> Author: georg.brandl Date: Sun Dec 2 10:40:06 2007 New Revision: 59268 Added: python/branches/py3k/Doc/library/builtins.rst Removed: python/branches/py3k/Doc/library/__builtin__.rst Modified: python/branches/py3k/Demo/classes/Range.py python/branches/py3k/Demo/imputil/knee.py python/branches/py3k/Demo/pdist/client.py python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Doc/c-api/intro.rst python/branches/py3k/Doc/glossary.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/imputil.rst python/branches/py3k/Doc/library/python.rst python/branches/py3k/Doc/library/rlcompleter.rst python/branches/py3k/Doc/library/runpy.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Doc/reference/executionmodel.rst python/branches/py3k/Doc/reference/lexical_analysis.rst python/branches/py3k/Doc/reference/toplevel_components.rst python/branches/py3k/Doc/tutorial/classes.rst python/branches/py3k/Doc/tutorial/modules.rst python/branches/py3k/Include/object.h python/branches/py3k/Lib/aifc.py python/branches/py3k/Lib/codecs.py python/branches/py3k/Lib/dumbdbm.py python/branches/py3k/Lib/gettext.py python/branches/py3k/Lib/gzip.py python/branches/py3k/Lib/idlelib/ColorDelegator.py python/branches/py3k/Lib/idlelib/RemoteDebugger.py python/branches/py3k/Lib/ihooks.py python/branches/py3k/Lib/imputil.py python/branches/py3k/Lib/inspect.py python/branches/py3k/Lib/io.py python/branches/py3k/Lib/locale.py python/branches/py3k/Lib/optparse.py python/branches/py3k/Lib/pickletools.py python/branches/py3k/Lib/plat-mac/icopen.py python/branches/py3k/Lib/py_compile.py python/branches/py3k/Lib/pydoc.py python/branches/py3k/Lib/repr.py python/branches/py3k/Lib/rlcompleter.py python/branches/py3k/Lib/site.py python/branches/py3k/Lib/sunau.py python/branches/py3k/Lib/tarfile.py python/branches/py3k/Lib/test/pickletester.py python/branches/py3k/Lib/test/test_compile.py python/branches/py3k/Lib/test/test_exceptions.py python/branches/py3k/Lib/test/test_gettext.py python/branches/py3k/Lib/test/test_inspect.py python/branches/py3k/Lib/test/test_iterlen.py python/branches/py3k/Lib/test/test_pep352.py python/branches/py3k/Lib/test/test_site.py python/branches/py3k/Lib/test/test_sys.py python/branches/py3k/Lib/test/test_traceback.py python/branches/py3k/Lib/traceback.py python/branches/py3k/Lib/wave.py python/branches/py3k/Misc/Vim/vim_syntax.py python/branches/py3k/Modules/_bsddb.c python/branches/py3k/Modules/_lsprof.c python/branches/py3k/Modules/config.c.in python/branches/py3k/Objects/exceptions.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Objects/typeobject.c python/branches/py3k/PC/bdist_wininst/install.c python/branches/py3k/PC/config.c python/branches/py3k/PC/os2emx/config.c python/branches/py3k/PC/os2vacpp/config.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/errors.c python/branches/py3k/Python/import.c python/branches/py3k/Python/pythonrun.c python/branches/py3k/Python/sysmodule.c python/branches/py3k/Tools/freeze/makeconfig.py Log: #1535: rename __builtin__ module to builtins. Modified: python/branches/py3k/Demo/classes/Range.py ============================================================================== --- python/branches/py3k/Demo/classes/Range.py (original) +++ python/branches/py3k/Demo/classes/Range.py Sun Dec 2 10:40:06 2007 @@ -64,9 +64,9 @@ def test(): - import time, __builtin__ + import time, builtins #Just a quick sanity check - correct_result = __builtin__.range(5, 100, 3) + correct_result = builtins.range(5, 100, 3) oldrange_result = list(oldrange(5, 100, 3)) genrange_result = list(genrange(5, 100, 3)) if genrange_result != correct_result or oldrange_result != correct_result: @@ -81,7 +81,7 @@ for i in genrange(1000): pass t3 = time.time() - for i in __builtin__.range(1000): + for i in builtins.range(1000): pass t4 = time.time() print(t2-t1, 'sec (old-style class)') Modified: python/branches/py3k/Demo/imputil/knee.py ============================================================================== --- python/branches/py3k/Demo/imputil/knee.py (original) +++ python/branches/py3k/Demo/imputil/knee.py Sun Dec 2 10:40:06 2007 @@ -7,7 +7,7 @@ """ -import sys, imp, __builtin__ +import sys, imp, builtins # Replacement for __import__() @@ -117,7 +117,7 @@ # Save the original hooks -original_import = __builtin__.__import__ +original_import = builtins.__import__ # Now install our hooks -__builtin__.__import__ = import_hook +builtins.__import__ = import_hook Modified: python/branches/py3k/Demo/pdist/client.py ============================================================================== --- python/branches/py3k/Demo/pdist/client.py (original) +++ python/branches/py3k/Demo/pdist/client.py Sun Dec 2 10:40:06 2007 @@ -3,7 +3,7 @@ import sys import socket import pickle -import __builtin__ +import builtins import os @@ -90,8 +90,8 @@ if exception is None: return value x = exception - if hasattr(__builtin__, exception): - x = getattr(__builtin__, exception) + if hasattr(builtins, exception): + x = getattr(builtins, exception) elif exception in ('posix.error', 'mac.error'): x = os.error if x == exception: Modified: python/branches/py3k/Doc/c-api/init.rst ============================================================================== --- python/branches/py3k/Doc/c-api/init.rst (original) +++ python/branches/py3k/Doc/c-api/init.rst Sun Dec 2 10:40:06 2007 @@ -17,7 +17,7 @@ single: PyEval_AcquireLock() single: modules (in module sys) single: path (in module sys) - module: __builtin__ + module: builtins module: __main__ module: sys triple: module; search; path @@ -29,7 +29,7 @@ exception of :cfunc:`Py_SetProgramName`, :cfunc:`PyEval_InitThreads`, :cfunc:`PyEval_ReleaseLock`, and :cfunc:`PyEval_AcquireLock`. This initializes the table of loaded modules (``sys.modules``), and creates the fundamental - modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`. It also initializes + modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. It also initializes the module search path (``sys.path``). It does not set ``sys.argv``; use :cfunc:`PySys_SetArgv` for that. This is a no-op when called for a second time (without calling :cfunc:`Py_Finalize` first). There is no return value; it is a @@ -83,7 +83,7 @@ .. cfunction:: PyThreadState* Py_NewInterpreter() .. index:: - module: __builtin__ + module: builtins module: __main__ module: sys single: stdout (in module sys) @@ -93,7 +93,7 @@ Create a new sub-interpreter. This is an (almost) totally separate environment for the execution of Python code. In particular, the new interpreter has separate, independent versions of all imported modules, including the - fundamental modules :mod:`__builtin__`, :mod:`__main__` and :mod:`sys`. The + fundamental modules :mod:`builtins`, :mod:`__main__` and :mod:`sys`. The table of loaded modules (``sys.modules``) and the module search path (``sys.path``) are also separate. The new environment has no ``sys.argv`` variable. It has new standard I/O stream file objects ``sys.stdin``, Modified: python/branches/py3k/Doc/c-api/intro.rst ============================================================================== --- python/branches/py3k/Doc/c-api/intro.rst (original) +++ python/branches/py3k/Doc/c-api/intro.rst Sun Dec 2 10:40:06 2007 @@ -507,7 +507,7 @@ .. index:: single: Py_Initialize() - module: __builtin__ + module: builtins module: __main__ module: sys module: exceptions @@ -516,7 +516,7 @@ The basic initialization function is :cfunc:`Py_Initialize`. This initializes the table of loaded modules, and creates the fundamental modules -:mod:`__builtin__`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also +:mod:`builtins`, :mod:`__main__`, :mod:`sys`, and :mod:`exceptions`. It also initializes the module search path (``sys.path``). .. index:: single: PySys_SetArgv() Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Sun Dec 2 10:40:06 2007 @@ -268,7 +268,7 @@ dictionaries. There are the local, global and builtin namespaces as well as nested namespaces in objects (in methods). Namespaces support modularity by preventing naming conflicts. For instance, the functions - :func:`__builtin__.open` and :func:`os.open` are distinguished by their + :func:`builtins.open` and :func:`os.open` are distinguished by their namespaces. Namespaces also aid readability and maintainability by making it clear which module implements a function. For instance, writing :func:`random.seed` or :func:`itertools.izip` makes it clear that those Deleted: /python/branches/py3k/Doc/library/__builtin__.rst ============================================================================== --- /python/branches/py3k/Doc/library/__builtin__.rst Sun Dec 2 10:40:06 2007 +++ (empty file) @@ -1,41 +0,0 @@ - -:mod:`__builtin__` --- Built-in objects -======================================= - -.. module:: __builtin__ - :synopsis: The module that provides the built-in namespace. - - -This module provides direct access to all 'built-in' identifiers of Python; for -example, ``__builtin__.open`` is the full name for the built-in function -:func:`open`. See chapter :ref:`builtin`. - -This module is not normally accessed explicitly by most applications, but can be -useful in modules that provide objects with the same name as a built-in value, -but in which the built-in of that name is also needed. For example, in a module -that wants to implement an :func:`open` function that wraps the built-in -:func:`open`, this module can be used directly:: - - import __builtin__ - - def open(path): - f = __builtin__.open(path, 'r') - return UpperCaser(f) - - class UpperCaser: - '''Wrapper around a file that converts output to upper-case.''' - - def __init__(self, f): - self._f = f - - def read(self, count=-1): - return self._f.read(count).upper() - - # ... - -As an implementation detail, most modules have the name ``__builtins__`` (note -the ``'s'``) made available as part of their globals. The value of -``__builtins__`` is normally either this module or the value of this modules's -:attr:`__dict__` attribute. Since this is an implementation detail, it may not -be used by alternate implementations of Python. - Added: python/branches/py3k/Doc/library/builtins.rst ============================================================================== --- (empty file) +++ python/branches/py3k/Doc/library/builtins.rst Sun Dec 2 10:40:06 2007 @@ -0,0 +1,41 @@ + +:mod:`builtins` --- Built-in objects +==================================== + +.. module:: builtins + :synopsis: The module that provides the built-in namespace. + + +This module provides direct access to all 'built-in' identifiers of Python; for +example, ``builtins.open`` is the full name for the built-in function +:func:`open`. See chapter :ref:`builtin`. + +This module is not normally accessed explicitly by most applications, but can be +useful in modules that provide objects with the same name as a built-in value, +but in which the built-in of that name is also needed. For example, in a module +that wants to implement an :func:`open` function that wraps the built-in +:func:`open`, this module can be used directly:: + + import builtins + + def open(path): + f = builtins.open(path, 'r') + return UpperCaser(f) + + class UpperCaser: + '''Wrapper around a file that converts output to upper-case.''' + + def __init__(self, f): + self._f = f + + def read(self, count=-1): + return self._f.read(count).upper() + + # ... + +As an implementation detail, most modules have the name ``__builtins__`` (note +the ``'s'``) made available as part of their globals. The value of +``__builtins__`` is normally either this module or the value of this modules's +:attr:`__dict__` attribute. Since this is an implementation detail, it may not +be used by alternate implementations of Python. + Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Sun Dec 2 10:40:06 2007 @@ -356,7 +356,7 @@ dictionaries as global and local namespace. If the *globals* dictionary is present and lacks '__builtins__', the current globals are copied into *globals* before *expression* is parsed. This means that *expression* normally has full - access to the standard :mod:`__builtin__` module and restricted environments are + access to the standard :mod:`builtins` module and restricted environments are propagated. If the *locals* dictionary is omitted it defaults to the *globals* dictionary. If both dictionaries are omitted, the expression is executed in the environment where :keyword:`eval` is called. The return value is the result of @@ -398,7 +398,7 @@ If the *globals* dictionary does not contain a value for the key ``__builtins__``, a reference to the dictionary of the built-in module - :mod:`__builtin__` is inserted under that key. That way you can control what + :mod:`builtins` is inserted under that key. That way you can control what builtins are available to the executed code by inserting your own ``__builtins__`` dictionary into *globals* before passing it to :func:`exec`. Modified: python/branches/py3k/Doc/library/imputil.rst ============================================================================== --- python/branches/py3k/Doc/library/imputil.rst (original) +++ python/branches/py3k/Doc/library/imputil.rst Sun Dec 2 10:40:06 2007 @@ -108,7 +108,7 @@ :: - import sys, imp, __builtin__ + import sys, imp, builtins # Replacement for __import__() def import_hook(name, globals=None, locals=None, fromlist=None): @@ -218,12 +218,12 @@ # Save the original hooks - original_import = __builtin__.__import__ - original_reload = __builtin__.reload + original_import = builtins.__import__ + original_reload = builtins.reload # Now install our hooks - __builtin__.__import__ = import_hook - __builtin__.reload = reload_hook + builtins.__import__ = import_hook + builtins.reload = reload_hook .. index:: module: knee Modified: python/branches/py3k/Doc/library/python.rst ============================================================================== --- python/branches/py3k/Doc/library/python.rst (original) +++ python/branches/py3k/Doc/library/python.rst Sun Dec 2 10:40:06 2007 @@ -13,7 +13,7 @@ .. toctree:: sys.rst - __builtin__.rst + builtins.rst __main__.rst warnings.rst contextlib.rst Modified: python/branches/py3k/Doc/library/rlcompleter.rst ============================================================================== --- python/branches/py3k/Doc/library/rlcompleter.rst (original) +++ python/branches/py3k/Doc/library/rlcompleter.rst Sun Dec 2 10:40:06 2007 @@ -55,7 +55,7 @@ Return the *state*th completion for *text*. If called for *text* that doesn't include a period character (``'.'``), it will - complete from names currently defined in :mod:`__main__`, :mod:`__builtin__` and + complete from names currently defined in :mod:`__main__`, :mod:`builtins` and keywords (as defined by the :mod:`keyword` module). If called for a dotted name, it will try to evaluate anything without obvious Modified: python/branches/py3k/Doc/library/runpy.rst ============================================================================== --- python/branches/py3k/Doc/library/runpy.rst (original) +++ python/branches/py3k/Doc/library/runpy.rst Sun Dec 2 10:40:06 2007 @@ -46,7 +46,7 @@ does not make filename information available, this variable is set to ``None``. ``__builtins__`` is automatically initialised with a reference to the top level - namespace of the :mod:`__builtin__` module. + namespace of the :mod:`builtins` module. If the argument *alter_sys* is supplied and evaluates to ``True``, then ``sys.argv[0]`` is updated with the value of ``__file__`` and Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Sun Dec 2 10:40:06 2007 @@ -78,7 +78,7 @@ .. function:: displayhook(value) If *value* is not ``None``, this function prints it to ``sys.stdout``, and saves - it in ``__builtin__._``. + it in ``builtins._``. ``sys.displayhook`` is called on the result of evaluating an expression entered in an interactive Python session. The display of these values can be customized Modified: python/branches/py3k/Doc/reference/executionmodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/executionmodel.rst (original) +++ python/branches/py3k/Doc/reference/executionmodel.rst Sun Dec 2 10:40:06 2007 @@ -105,7 +105,7 @@ specified in the statement refer to the binding of that name in the top-level namespace. Names are resolved in the top-level namespace by searching the global namespace, i.e. the namespace of the module containing the code block, -and the builtin namespace, the namespace of the module :mod:`__builtin__`. The +and the builtin namespace, the namespace of the module :mod:`builtins`. The global namespace is searched first. If the name is not found there, the builtin namespace is searched. The global statement must precede all uses of the name. @@ -117,8 +117,8 @@ found by looking up the name ``__builtins__`` in its global namespace; this should be a dictionary or a module (in the latter case the module's dictionary is used). By default, when in the :mod:`__main__` module, ``__builtins__`` is -the built-in module :mod:`__builtin__` (note: no 's'); when in any other module, -``__builtins__`` is an alias for the dictionary of the :mod:`__builtin__` module +the built-in module :mod:`builtins`; when in any other module, +``__builtins__`` is an alias for the dictionary of the :mod:`builtins` module itself. ``__builtins__`` can be set to a user-created dictionary to create a weak form of restricted execution. @@ -126,7 +126,7 @@ Users should not touch ``__builtins__``; it is strictly an implementation detail. Users wanting to override values in the built-in namespace should - :keyword:`import` the :mod:`__builtin__` (no 's') module and modify its + :keyword:`import` the :mod:`builtins` module and modify its attributes appropriately. .. index:: module: __main__ Modified: python/branches/py3k/Doc/reference/lexical_analysis.rst ============================================================================== --- python/branches/py3k/Doc/reference/lexical_analysis.rst (original) +++ python/branches/py3k/Doc/reference/lexical_analysis.rst Sun Dec 2 10:40:06 2007 @@ -344,7 +344,7 @@ ``_*`` Not imported by ``from module import *``. The special identifier ``_`` is used in the interactive interpreter to store the result of the last evaluation; it is - stored in the :mod:`__builtin__` module. When not in interactive mode, ``_`` + stored in the :mod:`builtins` module. When not in interactive mode, ``_`` has no special meaning and is not defined. See section :ref:`import`. .. note:: Modified: python/branches/py3k/Doc/reference/toplevel_components.rst ============================================================================== --- python/branches/py3k/Doc/reference/toplevel_components.rst (original) +++ python/branches/py3k/Doc/reference/toplevel_components.rst Sun Dec 2 10:40:06 2007 @@ -23,13 +23,13 @@ .. index:: module: sys module: __main__ - module: __builtin__ + module: builtins While a language specification need not prescribe how the language interpreter is invoked, it is useful to have a notion of a complete Python program. A complete Python program is executed in a minimally initialized environment: all built-in and standard modules are available, but none have been initialized, -except for :mod:`sys` (various system services), :mod:`__builtin__` (built-in +except for :mod:`sys` (various system services), :mod:`builtins` (built-in functions, exceptions and ``None``) and :mod:`__main__`. The latter is used to provide the local and global namespace for execution of the complete program. Modified: python/branches/py3k/Doc/tutorial/classes.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/classes.rst (original) +++ python/branches/py3k/Doc/tutorial/classes.rst Sun Dec 2 10:40:06 2007 @@ -98,7 +98,7 @@ invocation of the interpreter, either read from a script file or interactively, are considered part of a module called :mod:`__main__`, so they have their own global namespace. (The built-in names actually also live in a module; this is -called :mod:`__builtin__`.) +called :mod:`builtins`.) The local namespace for a function is created when the function is called, and deleted when the function returns or raises an exception that is not handled Modified: python/branches/py3k/Doc/tutorial/modules.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/modules.rst (original) +++ python/branches/py3k/Doc/tutorial/modules.rst Sun Dec 2 10:40:06 2007 @@ -308,14 +308,14 @@ Note that it lists all types of names: variables, modules, functions, etc. -.. index:: module: __builtin__ +.. index:: module: builtins :func:`dir` does not list the names of built-in functions and variables. If you want a list of those, they are defined in the standard module -:mod:`__builtin__`:: +:mod:`builtins`:: - >>> import __builtin__ - >>> dir(__builtin__) + >>> import builtins + >>> dir(builtins) ['ArithmeticError', 'AssertionError', 'AttributeError', 'BaseException', 'Buffer Error', 'DeprecationWarning', 'EOFError', 'Ellipsis', 'EnvironmentError', 'Excep Modified: python/branches/py3k/Include/object.h ============================================================================== --- python/branches/py3k/Include/object.h (original) +++ python/branches/py3k/Include/object.h Sun Dec 2 10:40:06 2007 @@ -458,8 +458,8 @@ extern int _PyObject_SlotCompare(PyObject *, PyObject *); -/* PyObject_Dir(obj) acts like Python __builtin__.dir(obj), returning a - list of strings. PyObject_Dir(NULL) is like __builtin__.dir(), +/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a + list of strings. PyObject_Dir(NULL) is like builtins.dir(), returning the names of the current locals. In this case, if there are no current locals, NULL is returned, and PyErr_Occurred() is false. */ Modified: python/branches/py3k/Lib/aifc.py ============================================================================== --- python/branches/py3k/Lib/aifc.py (original) +++ python/branches/py3k/Lib/aifc.py Sun Dec 2 10:40:06 2007 @@ -135,7 +135,7 @@ """ import struct -import __builtin__ +import builtins __all__ = ["Error","open","openfp"] @@ -336,7 +336,7 @@ def __init__(self, f): if type(f) == type(''): - f = __builtin__.open(f, 'rb') + f = builtins.open(f, 'rb') # else, assume it is an open file object already self.initfp(f) @@ -557,7 +557,7 @@ def __init__(self, f): if type(f) == type(''): filename = f - f = __builtin__.open(f, 'wb') + f = builtins.open(f, 'wb') else: # else, assume it is an open file object already filename = '???' Modified: python/branches/py3k/Lib/codecs.py ============================================================================== --- python/branches/py3k/Lib/codecs.py (original) +++ python/branches/py3k/Lib/codecs.py Sun Dec 2 10:40:06 2007 @@ -7,7 +7,7 @@ """#" -import __builtin__, sys +import builtins, sys ### Registry and builtin stateless codec functions @@ -858,7 +858,7 @@ 'b' not in mode: # Force opening of the file in binary mode mode = mode + 'b' - file = __builtin__.open(filename, mode, buffering) + file = builtins.open(filename, mode, buffering) if encoding is None: return file info = lookup(encoding) Modified: python/branches/py3k/Lib/dumbdbm.py ============================================================================== --- python/branches/py3k/Lib/dumbdbm.py (original) +++ python/branches/py3k/Lib/dumbdbm.py Sun Dec 2 10:40:06 2007 @@ -23,7 +23,6 @@ import io as _io import os as _os -import __builtin__ import UserDict _BLOCKSIZE = 512 Modified: python/branches/py3k/Lib/gettext.py ============================================================================== --- python/branches/py3k/Lib/gettext.py (original) +++ python/branches/py3k/Lib/gettext.py Sun Dec 2 10:40:06 2007 @@ -236,18 +236,18 @@ self._output_charset = charset def install(self, str=False, names=None): - import __builtin__ - __builtin__.__dict__['_'] = str and self.ugettext or self.gettext + import builtins + builtins.__dict__['_'] = str and self.ugettext or self.gettext if hasattr(names, "__contains__"): if "gettext" in names: - __builtin__.__dict__['gettext'] = __builtin__.__dict__['_'] + builtins.__dict__['gettext'] = builtins.__dict__['_'] if "ngettext" in names: - __builtin__.__dict__['ngettext'] = (str and self.ungettext + builtins.__dict__['ngettext'] = (str and self.ungettext or self.ngettext) if "lgettext" in names: - __builtin__.__dict__['lgettext'] = self.lgettext + builtins.__dict__['lgettext'] = self.lgettext if "lngettext" in names: - __builtin__.__dict__['lngettext'] = self.lngettext + builtins.__dict__['lngettext'] = self.lngettext class GNUTranslations(NullTranslations): Modified: python/branches/py3k/Lib/gzip.py ============================================================================== --- python/branches/py3k/Lib/gzip.py (original) +++ python/branches/py3k/Lib/gzip.py Sun Dec 2 10:40:06 2007 @@ -7,7 +7,7 @@ import struct, sys, time import zlib -import __builtin__ +import builtins __all__ = ["GzipFile","open"] @@ -92,7 +92,7 @@ if mode and 'b' not in mode: mode += 'b' if fileobj is None: - fileobj = self.myfileobj = __builtin__.open(filename, mode or 'rb') + fileobj = self.myfileobj = builtins.open(filename, mode or 'rb') if filename is None: if hasattr(fileobj, 'name'): filename = fileobj.name else: filename = '' @@ -487,13 +487,13 @@ print("filename doesn't end in .gz:", repr(arg)) continue f = open(arg, "rb") - g = __builtin__.open(arg[:-3], "wb") + g = builtins.open(arg[:-3], "wb") else: if arg == "-": f = sys.stdin g = GzipFile(filename="", mode="wb", fileobj=sys.stdout) else: - f = __builtin__.open(arg, "rb") + f = builtins.open(arg, "rb") g = open(arg + ".gz", "wb") while True: chunk = f.read(1024) Modified: python/branches/py3k/Lib/idlelib/ColorDelegator.py ============================================================================== --- python/branches/py3k/Lib/idlelib/ColorDelegator.py (original) +++ python/branches/py3k/Lib/idlelib/ColorDelegator.py Sun Dec 2 10:40:06 2007 @@ -1,7 +1,7 @@ import time import re import keyword -import __builtin__ +import builtins from Tkinter import * from idlelib.Delegator import Delegator from idlelib.configHandler import idleConf @@ -14,7 +14,7 @@ def make_pat(): kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b" - builtinlist = [str(name) for name in dir(__builtin__) + builtinlist = [str(name) for name in dir(builtins) if not name.startswith('_')] # self.file = open("file") : # 1st 'file' colorized normal, 2nd as builtin, 3rd as string Modified: python/branches/py3k/Lib/idlelib/RemoteDebugger.py ============================================================================== --- python/branches/py3k/Lib/idlelib/RemoteDebugger.py (original) +++ python/branches/py3k/Lib/idlelib/RemoteDebugger.py Sun Dec 2 10:40:06 2007 @@ -172,7 +172,7 @@ def dict_item(self, did, key): dict = dicttable[did] value = dict[key] - value = repr(value) ### can't pickle module '__builtin__' + value = repr(value) ### can't pickle module 'builtins' return value #----------end class IdbAdapter---------- Modified: python/branches/py3k/Lib/ihooks.py ============================================================================== --- python/branches/py3k/Lib/ihooks.py (original) +++ python/branches/py3k/Lib/ihooks.py Sun Dec 2 10:40:06 2007 @@ -49,7 +49,7 @@ """ -import __builtin__ +import builtins import imp import os import sys @@ -375,18 +375,18 @@ # XXX Should this try to clear the module's namespace? def install(self): - self.save_import_module = __builtin__.__import__ - if not hasattr(__builtin__, 'unload'): - __builtin__.unload = None - self.save_unload = __builtin__.unload - __builtin__.__import__ = self.import_module - __builtin__.unload = self.unload + self.save_import_module = builtins.__import__ + if not hasattr(builtins, 'unload'): + builtins.unload = None + self.save_unload = builtins.unload + builtins.__import__ = self.import_module + builtins.unload = self.unload def uninstall(self): - __builtin__.__import__ = self.save_import_module - __builtin__.unload = self.save_unload - if not __builtin__.unload: - del __builtin__.unload + builtins.__import__ = self.save_import_module + builtins.unload = self.save_unload + if not builtins.unload: + del builtins.unload class ModuleImporter(BasicModuleImporter): Modified: python/branches/py3k/Lib/imputil.py ============================================================================== --- python/branches/py3k/Lib/imputil.py (original) +++ python/branches/py3k/Lib/imputil.py Sun Dec 2 10:40:06 2007 @@ -13,7 +13,7 @@ # note: avoid importing non-builtin modules import imp ### not available in JPython? import sys -import __builtin__ +import builtins # for the DirectoryImporter import struct @@ -26,7 +26,7 @@ class ImportManager: "Manage the import process." - def install(self, namespace=vars(__builtin__)): + def install(self, namespace=vars(builtins)): "Install this ImportManager into the specified namespace." if isinstance(namespace, _ModuleType): @@ -404,7 +404,7 @@ codestring = open(pathname, 'rU').read() if codestring and codestring[-1] != '\n': codestring = codestring + '\n' - code = __builtin__.compile(codestring, pathname, 'exec') + code = builtins.compile(codestring, pathname, 'exec') # try to cache the compiled code try: Modified: python/branches/py3k/Lib/inspect.py ============================================================================== --- python/branches/py3k/Lib/inspect.py (original) +++ python/branches/py3k/Lib/inspect.py Sun Dec 2 10:40:06 2007 @@ -444,7 +444,7 @@ if mainobject is object: return main # Check builtins - builtin = sys.modules['__builtin__'] + builtin = sys.modules['builtins'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) if builtinobject is object: @@ -775,7 +775,7 @@ def formatannotation(annotation, base_module=None): if isinstance(annotation, type): - if annotation.__module__ in ('__builtin__', base_module): + if annotation.__module__ in ('builtins', base_module): return annotation.__name__ return annotation.__module__+'.'+annotation.__name__ return repr(annotation) Modified: python/branches/py3k/Lib/io.py ============================================================================== --- python/branches/py3k/Lib/io.py (original) +++ python/branches/py3k/Lib/io.py Sun Dec 2 10:40:06 2007 @@ -184,7 +184,7 @@ class OpenWrapper: - """Wrapper for __builtin__.open + """Wrapper for builtins.open Trick so that open won't become a bound method when stored as a class variable (as dumbdbm does). Modified: python/branches/py3k/Lib/locale.py ============================================================================== --- python/branches/py3k/Lib/locale.py (original) +++ python/branches/py3k/Lib/locale.py Sun Dec 2 10:40:06 2007 @@ -12,7 +12,7 @@ """ import sys, encodings, encodings.aliases -from __builtin__ import str as _builtin_str +from builtins import str as _builtin_str # Try importing the _locale module. # Modified: python/branches/py3k/Lib/optparse.py ============================================================================== --- python/branches/py3k/Lib/optparse.py (original) +++ python/branches/py3k/Lib/optparse.py Sun Dec 2 10:40:06 2007 @@ -636,13 +636,13 @@ else: # Allow type objects or builtin type conversion functions # (int, str, etc.) as an alternative to their names. (The - # complicated check of __builtin__ is only necessary for + # complicated check of builtins is only necessary for # Python 2.1 and earlier, and is short-circuited by the # first check on modern Pythons.) - import __builtin__ + import builtins if ( isinstance(self.type, type) or (hasattr(self.type, "__name__") and - getattr(__builtin__, self.type.__name__, None) is self.type) ): + getattr(builtins, self.type.__name__, None) is self.type) ): self.type = self.type.__name__ if self.type == "str": Modified: python/branches/py3k/Lib/pickletools.py ============================================================================== --- python/branches/py3k/Lib/pickletools.py (original) +++ python/branches/py3k/Lib/pickletools.py Sun Dec 2 10:40:06 2007 @@ -2054,25 +2054,25 @@ 33: ( MARK 34: c GLOBAL 'pickletools _Example' 56: p PUT 2 - 59: c GLOBAL '__builtin__ object' - 79: p PUT 3 - 82: N NONE - 83: t TUPLE (MARK at 33) - 84: p PUT 4 - 87: R REDUCE - 88: p PUT 5 - 91: ( MARK - 92: d DICT (MARK at 91) - 93: p PUT 6 - 96: V UNICODE 'value' - 103: p PUT 7 - 106: L LONG 42 - 110: s SETITEM - 111: b BUILD - 112: a APPEND - 113: g GET 5 - 116: a APPEND - 117: . STOP + 59: c GLOBAL 'builtins object' + 76: p PUT 3 + 79: N NONE + 80: t TUPLE (MARK at 33) + 81: p PUT 4 + 84: R REDUCE + 85: p PUT 5 + 88: ( MARK + 89: d DICT (MARK at 88) + 90: p PUT 6 + 93: V UNICODE 'value' + 100: p PUT 7 + 103: L LONG 42 + 107: s SETITEM + 108: b BUILD + 109: a APPEND + 110: g GET 5 + 113: a APPEND + 114: . STOP highest protocol among opcodes = 0 >>> dis(pickle.dumps(x, 1)) @@ -2084,23 +2084,23 @@ 31: ( MARK 32: c GLOBAL 'pickletools _Example' 54: q BINPUT 2 - 56: c GLOBAL '__builtin__ object' - 76: q BINPUT 3 - 78: N NONE - 79: t TUPLE (MARK at 31) - 80: q BINPUT 4 - 82: R REDUCE - 83: q BINPUT 5 - 85: } EMPTY_DICT - 86: q BINPUT 6 - 88: X BINUNICODE 'value' - 98: q BINPUT 7 - 100: K BININT1 42 - 102: s SETITEM - 103: b BUILD - 104: h BINGET 5 - 106: e APPENDS (MARK at 3) - 107: . STOP + 56: c GLOBAL 'builtins object' + 73: q BINPUT 3 + 75: N NONE + 76: t TUPLE (MARK at 31) + 77: q BINPUT 4 + 79: R REDUCE + 80: q BINPUT 5 + 82: } EMPTY_DICT + 83: q BINPUT 6 + 85: X BINUNICODE 'value' + 95: q BINPUT 7 + 97: K BININT1 42 + 99: s SETITEM + 100: b BUILD + 101: h BINGET 5 + 103: e APPENDS (MARK at 3) + 104: . STOP highest protocol among opcodes = 1 Try "the canonical" recursive-object test. Modified: python/branches/py3k/Lib/plat-mac/icopen.py ============================================================================== --- python/branches/py3k/Lib/plat-mac/icopen.py (original) +++ python/branches/py3k/Lib/plat-mac/icopen.py Sun Dec 2 10:40:06 2007 @@ -37,9 +37,9 @@ effect. """ -import __builtin__ +import builtins -_builtin_open = globals().get('_builtin_open', __builtin__.open) +_builtin_open = globals().get('_builtin_open', builtins.open) def _open_with_typer(*args): file = _builtin_open(*args) @@ -55,7 +55,7 @@ pass return file -__builtin__.open = _open_with_typer +builtins.open = _open_with_typer """ open('test.py') Modified: python/branches/py3k/Lib/py_compile.py ============================================================================== --- python/branches/py3k/Lib/py_compile.py (original) +++ python/branches/py3k/Lib/py_compile.py Sun Dec 2 10:40:06 2007 @@ -3,7 +3,7 @@ This module has intimate knowledge of the format of .pyc files. """ -import __builtin__ +import builtins import imp import marshal import os @@ -139,7 +139,7 @@ if codestring and codestring[-1] != '\n': codestring = codestring + '\n' try: - codeobject = __builtin__.compile(codestring, dfile or file,'exec') + codeobject = builtins.compile(codestring, dfile or file,'exec') except Exception as err: py_exc = PyCompileError(err.__class__, err, dfile or file) if doraise: Modified: python/branches/py3k/Lib/pydoc.py ============================================================================== --- python/branches/py3k/Lib/pydoc.py (original) +++ python/branches/py3k/Lib/pydoc.py Sun Dec 2 10:40:06 2007 @@ -52,7 +52,7 @@ # the current directory is changed with os.chdir(), an incorrect # path will be displayed. -import sys, imp, os, re, inspect, __builtin__, pkgutil +import sys, imp, os, re, inspect, builtins, pkgutil from repr import Repr try: from collections import deque @@ -787,7 +787,7 @@ thisclass = attrs[0][2] attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass) - if thisclass is __builtin__.object: + if thisclass is builtins.object: attrs = inherited continue elif thisclass is object: @@ -1184,7 +1184,7 @@ thisclass = attrs[0][2] attrs, inherited = _split_list(attrs, lambda t: t[2] is thisclass) - if thisclass is __builtin__.object: + if thisclass is builtins.object: attrs = inherited continue elif thisclass is object: @@ -1450,8 +1450,8 @@ except AttributeError: return None return object else: - if hasattr(__builtin__, path): - return getattr(__builtin__, path) + if hasattr(builtins, path): + return getattr(builtins, path) # --------------------------------------- interactive interpreter interface Modified: python/branches/py3k/Lib/repr.py ============================================================================== --- python/branches/py3k/Lib/repr.py (original) +++ python/branches/py3k/Lib/repr.py Sun Dec 2 10:40:06 2007 @@ -2,7 +2,7 @@ __all__ = ["Repr","repr"] -import __builtin__ +import builtins from itertools import islice class Repr: @@ -84,16 +84,16 @@ return '{%s}' % (s,) def repr_str(self, x, level): - s = __builtin__.repr(x[:self.maxstring]) + s = builtins.repr(x[:self.maxstring]) if len(s) > self.maxstring: i = max(0, (self.maxstring-3)//2) j = max(0, self.maxstring-3-i) - s = __builtin__.repr(x[:i] + x[len(x)-j:]) + s = builtins.repr(x[:i] + x[len(x)-j:]) s = s[:i] + '...' + s[len(s)-j:] return s def repr_int(self, x, level): - s = __builtin__.repr(x) # XXX Hope this isn't too slow... + s = builtins.repr(x) # XXX Hope this isn't too slow... if len(s) > self.maxlong: i = max(0, (self.maxlong-3)//2) j = max(0, self.maxlong-3-i) @@ -102,7 +102,7 @@ def repr_instance(self, x, level): try: - s = __builtin__.repr(x) + s = builtins.repr(x) # Bugs in x.__repr__() can cause arbitrary # exceptions -- then make up something except Exception: Modified: python/branches/py3k/Lib/rlcompleter.py ============================================================================== --- python/branches/py3k/Lib/rlcompleter.py (original) +++ python/branches/py3k/Lib/rlcompleter.py Sun Dec 2 10:40:06 2007 @@ -33,7 +33,7 @@ """ -import __builtin__ +import builtins import __main__ __all__ = ["Completer"] @@ -97,7 +97,7 @@ matches = [] n = len(text) for list in [keyword.kwlist, - __builtin__.__dict__, + builtins.__dict__, self.namespace]: for word in list: if word[:n] == text and word != "__builtins__": Modified: python/branches/py3k/Lib/site.py ============================================================================== --- python/branches/py3k/Lib/site.py (original) +++ python/branches/py3k/Lib/site.py Sun Dec 2 10:40:06 2007 @@ -60,7 +60,7 @@ import sys import os -import __builtin__ +import builtins def makepath(*paths): @@ -251,8 +251,8 @@ except: pass raise SystemExit(code) - __builtin__.quit = Quitter('quit') - __builtin__.exit = Quitter('exit') + builtins.quit = Quitter('quit') + builtins.exit = Quitter('exit') class _Printer(object): @@ -319,18 +319,18 @@ break def setcopyright(): - """Set 'copyright' and 'credits' in __builtin__""" - __builtin__.copyright = _Printer("copyright", sys.copyright) + """Set 'copyright' and 'credits' in builtins""" + builtins.copyright = _Printer("copyright", sys.copyright) if sys.platform[:4] == 'java': - __builtin__.credits = _Printer( + builtins.credits = _Printer( "credits", "Jython is maintained by the Jython developers (www.jython.org).") else: - __builtin__.credits = _Printer("credits", """\ + builtins.credits = _Printer("credits", """\ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.""") here = os.path.dirname(os.__file__) - __builtin__.license = _Printer( + builtins.license = _Printer( "license", "See http://www.python.org/%.3s/license.html" % sys.version, ["LICENSE.txt", "LICENSE"], [os.path.join(here, os.pardir), here, os.curdir]) @@ -350,7 +350,7 @@ return pydoc.help(*args, **kwds) def sethelper(): - __builtin__.help = _Helper() + builtins.help = _Helper() def aliasmbcs(): """On Windows, some default encodings are not provided by Python, Modified: python/branches/py3k/Lib/sunau.py ============================================================================== --- python/branches/py3k/Lib/sunau.py (original) +++ python/branches/py3k/Lib/sunau.py Sun Dec 2 10:40:06 2007 @@ -153,8 +153,8 @@ def __init__(self, f): if type(f) == type(''): - import __builtin__ - f = __builtin__.open(f, 'rb') + import builtins + f = builtins.open(f, 'rb') self.initfp(f) def __del__(self): @@ -282,8 +282,8 @@ def __init__(self, f): if type(f) == type(''): - import __builtin__ - f = __builtin__.open(f, 'wb') + import builtins + f = builtins.open(f, 'wb') self.initfp(f) def __del__(self): Modified: python/branches/py3k/Lib/tarfile.py ============================================================================== --- python/branches/py3k/Lib/tarfile.py (original) +++ python/branches/py3k/Lib/tarfile.py Sun Dec 2 10:40:06 2007 @@ -65,7 +65,7 @@ # from tarfile import * __all__ = ["TarFile", "TarInfo", "is_tarfile", "TarError"] -from __builtin__ import open as _open # Since 'open' is TarFile.open +from builtins import open as _open # Since 'open' is TarFile.open #--------------------------------------------------------- # tar constants Modified: python/branches/py3k/Lib/test/pickletester.py ============================================================================== --- python/branches/py3k/Lib/test/pickletester.py (original) +++ python/branches/py3k/Lib/test/pickletester.py Sun Dec 2 10:40:06 2007 @@ -91,7 +91,7 @@ DATA0 = ( b'(lp0\nL0\naL1\naF2.0\nac' - b'__builtin__\ncomplex\n' + b'builtins\ncomplex\n' b'p1\n(F3.0\nF0.0\ntp2\nRp' b'3\naL1\naL-1\naL255\naL-' b'255\naL-256\naL65535\na' @@ -100,8 +100,8 @@ b'647\naL-2147483648\na(' b'Vabc\np4\ng4\nccopy_reg' b'\n_reconstructor\np5\n(' - b'c__main__\nC\np6\nc__bu' - b'iltin__\nobject\np7\nNt' + b'c__main__\nC\np6\ncbu' + b'iltins\nobject\np7\nNt' b'p8\nRp9\n(dp10\nVfoo\np1' b'1\nL1\nsVbar\np12\nL2\nsb' b'g9\ntp13\nag13\naL5\na.' @@ -118,7 +118,7 @@ 12: a APPEND 13: F FLOAT 2.0 18: a APPEND - 19: c GLOBAL '__builtin__ complex' + 19: c GLOBAL 'builtins complex' 40: p PUT 1 43: ( MARK 44: F FLOAT 3.0 @@ -159,7 +159,7 @@ 199: ( MARK 200: c GLOBAL '__main__ C' 212: p PUT 6 - 215: c GLOBAL '__builtin__ object' + 215: c GLOBAL 'builtins object' 235: p PUT 7 238: N NONE 239: t TUPLE (MARK at 199) @@ -191,15 +191,15 @@ """ DATA1 = ( - b']q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c__' - b'builtin__\ncomplex\nq\x01' + b']q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c' + b'builtins\ncomplex\nq\x01' b'(G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00t' b'q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xffJ' b'\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff\xff' b'\xff\x7fJ\x01\x00\x00\x80J\x00\x00\x00\x80(X\x03\x00\x00\x00ab' b'cq\x04h\x04ccopy_reg\n_reco' b'nstructor\nq\x05(c__main' - b'__\nC\nq\x06c__builtin__\n' + b'__\nC\nq\x06cbuiltins\n' b'object\nq\x07Ntq\x08Rq\t}q\n(' b'X\x03\x00\x00\x00fooq\x0bK\x01X\x03\x00\x00\x00bar' b'q\x0cK\x02ubh\ttq\rh\rK\x05e.' @@ -213,7 +213,7 @@ 4: K BININT1 0 6: K BININT1 1 8: G BINFLOAT 2.0 - 17: c GLOBAL '__builtin__ complex' + 17: c GLOBAL 'builtins complex' 38: q BINPUT 1 40: ( MARK 41: G BINFLOAT 3.0 @@ -242,7 +242,7 @@ 152: ( MARK 153: c GLOBAL '__main__ C' 165: q BINPUT 6 - 167: c GLOBAL '__builtin__ object' + 167: c GLOBAL 'builtins object' 187: q BINPUT 7 189: N NONE 190: t TUPLE (MARK at 152) @@ -272,7 +272,7 @@ DATA2 = ( b'\x80\x02]q\x00(K\x00K\x01G@\x00\x00\x00\x00\x00\x00\x00c' - b'__builtin__\ncomplex\n' + b'builtins\ncomplex\n' b'q\x01G@\x08\x00\x00\x00\x00\x00\x00G\x00\x00\x00\x00\x00\x00\x00\x00' b'\x86q\x02Rq\x03K\x01J\xff\xff\xff\xffK\xffJ\x01\xff\xff\xff' b'J\x00\xff\xff\xffM\xff\xffJ\x01\x00\xff\xffJ\x00\x00\xff\xffJ\xff' @@ -292,7 +292,7 @@ 6: K BININT1 0 8: K BININT1 1 10: G BINFLOAT 2.0 - 19: c GLOBAL '__builtin__ complex' + 19: c GLOBAL 'builtins complex' 40: q BINPUT 1 42: G BINFLOAT 3.0 51: G BINFLOAT 0.0 Modified: python/branches/py3k/Lib/test/test_compile.py ============================================================================== --- python/branches/py3k/Lib/test/test_compile.py (original) +++ python/branches/py3k/Lib/test/test_compile.py Sun Dec 2 10:40:06 2007 @@ -7,10 +7,10 @@ def test_debug_assignment(self): # catch assignments to __debug__ self.assertRaises(SyntaxError, compile, '__debug__ = 1', '?', 'single') - import __builtin__ - prev = __builtin__.__debug__ - setattr(__builtin__, '__debug__', 'sure') - setattr(__builtin__, '__debug__', prev) + import builtins + prev = builtins.__debug__ + setattr(builtins, '__debug__', 'sure') + setattr(builtins, '__debug__', prev) def test_argument_handling(self): # detect duplicate positional and keyword arguments Modified: python/branches/py3k/Lib/test/test_exceptions.py ============================================================================== --- python/branches/py3k/Lib/test/test_exceptions.py (original) +++ python/branches/py3k/Lib/test/test_exceptions.py Sun Dec 2 10:40:06 2007 @@ -288,7 +288,7 @@ raise else: # Verify module name - self.assertEquals(type(e).__module__, '__builtin__') + self.assertEquals(type(e).__module__, 'builtins') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: Modified: python/branches/py3k/Lib/test/test_gettext.py ============================================================================== --- python/branches/py3k/Lib/test/test_gettext.py (original) +++ python/branches/py3k/Lib/test/test_gettext.py Sun Dec 2 10:40:06 2007 @@ -146,13 +146,13 @@ t.install(str=True) eq(_('mullusk'), 'bacon') # Test installation of other methods - import __builtin__ + import builtins t.install(str=True, names=["gettext", "lgettext"]) eq(_, t.ugettext) - eq(__builtin__.gettext, t.ugettext) + eq(builtins.gettext, t.ugettext) eq(lgettext, t.lgettext) - del __builtin__.gettext - del __builtin__.lgettext + del builtins.gettext + del builtins.lgettext class GettextTestCase2(GettextBaseTest): Modified: python/branches/py3k/Lib/test/test_inspect.py ============================================================================== --- python/branches/py3k/Lib/test/test_inspect.py (original) +++ python/branches/py3k/Lib/test/test_inspect.py Sun Dec 2 10:40:06 2007 @@ -29,7 +29,7 @@ def revise(filename, *args): return (normcase(filename),) + args -import __builtin__ +import builtins try: 1/0 @@ -197,7 +197,7 @@ # Do it again (check the caching isn't broken) self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) # Check a builtin - self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) + self.assertEqual(inspect.getmodule(str), sys.modules["builtins"]) # Check filename override self.assertEqual(inspect.getmodule(None, modfile), mod) Modified: python/branches/py3k/Lib/test/test_iterlen.py ============================================================================== --- python/branches/py3k/Lib/test/test_iterlen.py (original) +++ python/branches/py3k/Lib/test/test_iterlen.py Sun Dec 2 10:40:06 2007 @@ -46,7 +46,7 @@ from itertools import repeat from collections import deque from UserList import UserList -from __builtin__ import len as _len +from builtins import len as _len n = 10 Modified: python/branches/py3k/Lib/test/test_pep352.py ============================================================================== --- python/branches/py3k/Lib/test/test_pep352.py (original) +++ python/branches/py3k/Lib/test/test_pep352.py Sun Dec 2 10:40:06 2007 @@ -1,5 +1,5 @@ import unittest -import __builtin__ +import builtins import warnings from test.test_support import run_unittest import os @@ -23,7 +23,7 @@ def test_inheritance(self): # Make sure the inheritance hierarchy matches the documentation exc_set = set() - for object_ in __builtin__.__dict__.values(): + for object_ in builtins.__dict__.values(): try: if issubclass(object_, BaseException): exc_set.add(object_.__name__) @@ -35,7 +35,7 @@ try: superclass_name = inheritance_tree.readline().rstrip() try: - last_exc = getattr(__builtin__, superclass_name) + last_exc = getattr(builtins, superclass_name) except AttributeError: self.fail("base class %s not a built-in" % superclass_name) self.failUnless(superclass_name in exc_set, @@ -58,7 +58,7 @@ left_bracket = exc_name.index('[') exc_name = exc_name[:left_bracket-1] # cover space try: - exc = getattr(__builtin__, exc_name) + exc = getattr(builtins, exc_name) except AttributeError: self.fail("%s not a built-in exception" % exc_name) if last_depth < depth: Modified: python/branches/py3k/Lib/test/test_site.py ============================================================================== --- python/branches/py3k/Lib/test/test_site.py (original) +++ python/branches/py3k/Lib/test/test_site.py Sun Dec 2 10:40:06 2007 @@ -6,7 +6,7 @@ """ import unittest from test.test_support import TestSkipped, TestFailed, run_unittest, TESTFN -import __builtin__ +import builtins import os import sys import encodings @@ -162,7 +162,7 @@ # as an absolute path. # Handled by abs__file__() site.abs__file__() - for module in (sys, os, __builtin__): + for module in (sys, os, builtins): try: self.failUnless(os.path.isabs(module.__file__), repr(module)) except AttributeError: @@ -187,18 +187,18 @@ pass def test_setting_quit(self): - # 'quit' and 'exit' should be injected into __builtin__ - self.failUnless(hasattr(__builtin__, "quit")) - self.failUnless(hasattr(__builtin__, "exit")) + # 'quit' and 'exit' should be injected into builtins + self.failUnless(hasattr(builtins, "quit")) + self.failUnless(hasattr(builtins, "exit")) def test_setting_copyright(self): - # 'copyright' and 'credits' should be in __builtin__ - self.failUnless(hasattr(__builtin__, "copyright")) - self.failUnless(hasattr(__builtin__, "credits")) + # 'copyright' and 'credits' should be in builtins + self.failUnless(hasattr(builtins, "copyright")) + self.failUnless(hasattr(builtins, "credits")) def test_setting_help(self): - # 'help' should be set in __builtin__ - self.failUnless(hasattr(__builtin__, "help")) + # 'help' should be set in builtins + self.failUnless(hasattr(builtins, "help")) def test_aliasing_mbcs(self): if sys.platform == "win32": Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Sun Dec 2 10:40:06 2007 @@ -15,22 +15,22 @@ sys.displayhook = self.orig_displayhook def test_original_displayhook(self): - import __builtin__ + import builtins out = io.StringIO() sys.stdout = out dh = sys.__displayhook__ self.assertRaises(TypeError, dh) - if hasattr(__builtin__, "_"): - del __builtin__._ + if hasattr(builtins, "_"): + del builtins._ dh(None) self.assertEqual(out.getvalue(), "") - self.assert_(not hasattr(__builtin__, "_")) + self.assert_(not hasattr(builtins, "_")) dh(42) self.assertEqual(out.getvalue(), "42\n") - self.assertEqual(__builtin__._, 42) + self.assertEqual(builtins._, 42) del sys.stdout self.assertRaises(RuntimeError, dh, 42) Modified: python/branches/py3k/Lib/test/test_traceback.py ============================================================================== --- python/branches/py3k/Lib/test/test_traceback.py (original) +++ python/branches/py3k/Lib/test/test_traceback.py Sun Dec 2 10:40:06 2007 @@ -65,7 +65,7 @@ err = traceback.format_exception_only(X, X()) self.assertEqual(len(err), 1) str_value = '' % X.__name__ - if X.__module__ in ('__main__', '__builtin__'): + if X.__module__ in ('__main__', 'builtins'): str_name = X.__name__ else: str_name = '.'.join([X.__module__, X.__name__]) Modified: python/branches/py3k/Lib/traceback.py ============================================================================== --- python/branches/py3k/Lib/traceback.py (original) +++ python/branches/py3k/Lib/traceback.py Sun Dec 2 10:40:06 2007 @@ -168,7 +168,7 @@ stype = etype.__name__ smod = etype.__module__ - if smod not in ("__main__", "__builtin__"): + if smod not in ("__main__", "builtins"): stype = smod + '.' + stype if not issubclass(etype, SyntaxError): Modified: python/branches/py3k/Lib/wave.py ============================================================================== --- python/branches/py3k/Lib/wave.py (original) +++ python/branches/py3k/Lib/wave.py Sun Dec 2 10:40:06 2007 @@ -71,7 +71,7 @@ is destroyed. """ -import __builtin__ +import builtins __all__ = ["open", "openfp", "Error"] @@ -156,7 +156,7 @@ def __init__(self, f): self._i_opened_the_file = None if isinstance(f, str): - f = __builtin__.open(f, 'rb') + f = builtins.open(f, 'rb') self._i_opened_the_file = f # else, assume it is an open file object already try: @@ -300,7 +300,7 @@ def __init__(self, f): self._i_opened_the_file = None if isinstance(f, str): - f = __builtin__.open(f, 'wb') + f = builtins.open(f, 'wb') self._i_opened_the_file = f try: self.initfp(f) Modified: python/branches/py3k/Misc/Vim/vim_syntax.py ============================================================================== --- python/branches/py3k/Misc/Vim/vim_syntax.py (original) +++ python/branches/py3k/Misc/Vim/vim_syntax.py Sun Dec 2 10:40:06 2007 @@ -4,7 +4,7 @@ import keyword import exceptions -import __builtin__ +import builtins from string import Template comment_header = '''" Auto-generated Vim syntax file for Python. @@ -39,7 +39,7 @@ # 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__) +builtin_names = sorted(builtin for builtin in dir(builtins) if builtin not in dir(exceptions)) escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"', Modified: python/branches/py3k/Modules/_bsddb.c ============================================================================== --- python/branches/py3k/Modules/_bsddb.c (original) +++ python/branches/py3k/Modules/_bsddb.c Sun Dec 2 10:40:06 2007 @@ -6002,7 +6002,7 @@ * using one base class. */ PyDict_SetItemString(d, "KeyError", PyExc_KeyError); { - PyObject *builtin_mod = PyImport_ImportModule("__builtin__"); + PyObject *builtin_mod = PyImport_ImportModule("builtins"); PyDict_SetItemString(d, "__builtins__", builtin_mod); } PyRun_String("class DBNotFoundError(DBError, KeyError): pass\n" Modified: python/branches/py3k/Modules/_lsprof.c ============================================================================== --- python/branches/py3k/Modules/_lsprof.c (original) +++ python/branches/py3k/Modules/_lsprof.c Sun Dec 2 10:40:06 2007 @@ -186,13 +186,13 @@ modname = PyModule_GetName(mod); if (modname == NULL) { PyErr_Clear(); - modname = "__builtin__"; + modname = "builtins"; } } else { - modname = "__builtin__"; + modname = "builtins"; } - if (strcmp(modname, "__builtin__") != 0) + if (strcmp(modname, "builtins") != 0) return PyUnicode_FromFormat("<%s.%s>", modname, fn->m_ml->ml_name); Modified: python/branches/py3k/Modules/config.c.in ============================================================================== --- python/branches/py3k/Modules/config.c.in (original) +++ python/branches/py3k/Modules/config.c.in Sun Dec 2 10:40:06 2007 @@ -48,7 +48,7 @@ /* These entries are here for sys.builtin_module_names */ {"__main__", NULL}, - {"__builtin__", NULL}, + {"builtins", NULL}, {"sys", NULL}, /* This lives in gcmodule.c */ Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Sun Dec 2 10:40:06 2007 @@ -1849,7 +1849,7 @@ PRE_INIT(UnicodeWarning) PRE_INIT(BytesWarning) - bltinmod = PyImport_ImportModule("__builtin__"); + bltinmod = PyImport_ImportModule("builtins"); if (bltinmod == NULL) Py_FatalError("exceptions bootstrapping error."); bdict = PyModule_GetDict(bltinmod); Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Sun Dec 2 10:40:06 2007 @@ -1961,7 +1961,7 @@ module = PyUnicode_AsString(f->m_module); if (module == NULL) return 0; - if (strcmp(module, "__builtin__") != 0) + if (strcmp(module, "builtins") != 0) return 0; if (strcmp(f->m_ml->ml_name, "cmp") != 0) return 0; Modified: python/branches/py3k/Objects/typeobject.c ============================================================================== --- python/branches/py3k/Objects/typeobject.c (original) +++ python/branches/py3k/Objects/typeobject.c Sun Dec 2 10:40:06 2007 @@ -112,7 +112,7 @@ if (s != NULL) return PyUnicode_FromStringAndSize( type->tp_name, (Py_ssize_t)(s - type->tp_name)); - return PyUnicode_FromString("__builtin__"); + return PyUnicode_FromString("builtins"); } } @@ -397,7 +397,7 @@ else kind = "type"; - if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "__builtin__")) + if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) rtn = PyUnicode_FromFormat("<%s '%U.%U'>", kind, mod, name); else rtn = PyUnicode_FromFormat("<%s '%s'>", kind, type->tp_name); @@ -2455,7 +2455,7 @@ name = type_name(type, NULL); if (name == NULL) return NULL; - if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "__builtin__")) + if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self); else rtn = PyUnicode_FromFormat("<%s object at %p>", Modified: python/branches/py3k/PC/bdist_wininst/install.c ============================================================================== --- python/branches/py3k/PC/bdist_wininst/install.c (original) +++ python/branches/py3k/PC/bdist_wininst/install.c Sun Dec 2 10:40:06 2007 @@ -654,7 +654,7 @@ if (!Py_BuildValue || !PyArg_ParseTuple || !PyErr_Format) return 1; - mod = PyImport_ImportModule("__builtin__"); + mod = PyImport_ImportModule("builtins"); if (mod) { int i; g_PyExc_ValueError = PyObject_GetAttrString(mod, "ValueError"); Modified: python/branches/py3k/PC/config.c ============================================================================== --- python/branches/py3k/PC/config.c (original) +++ python/branches/py3k/PC/config.c Sun Dec 2 10:40:06 2007 @@ -143,7 +143,7 @@ /* These entries are here for sys.builtin_module_names */ {"__main__", NULL}, - {"__builtin__", NULL}, + {"builtins", NULL}, {"sys", NULL}, {"_types", init_types}, Modified: python/branches/py3k/PC/os2emx/config.c ============================================================================== --- python/branches/py3k/PC/os2emx/config.c (original) +++ python/branches/py3k/PC/os2emx/config.c Sun Dec 2 10:40:06 2007 @@ -156,7 +156,7 @@ /* These entries are here for sys.builtin_module_names */ {"__main__", NULL}, - {"__builtin__", NULL}, + {"builtins", NULL}, {"sys", NULL}, /* This lives in gcmodule.c */ Modified: python/branches/py3k/PC/os2vacpp/config.c ============================================================================== --- python/branches/py3k/PC/os2vacpp/config.c (original) +++ python/branches/py3k/PC/os2vacpp/config.c Sun Dec 2 10:40:06 2007 @@ -94,7 +94,7 @@ /* These entries are here for sys.builtin_module_names */ {"__main__", NULL}, - {"__builtin__", NULL}, + {"builtins", NULL}, {"sys", NULL}, /* Sentinel */ Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Sun Dec 2 10:40:06 2007 @@ -1851,7 +1851,7 @@ _PyBuiltin_Init(void) { PyObject *mod, *dict, *debug; - mod = Py_InitModule4("__builtin__", builtin_methods, + mod = Py_InitModule4("builtins", builtin_methods, builtin_doc, (PyObject *)NULL, PYTHON_API_VERSION); if (mod == NULL) @@ -1859,7 +1859,7 @@ dict = PyModule_GetDict(mod); #ifdef Py_TRACE_REFS - /* __builtin__ exposes a number of statically allocated objects + /* "builtins" exposes a number of statically allocated objects * that, before this code was added in 2.3, never showed up in * the list of "all objects" maintained by Py_TRACE_REFS. As a * result, programs leaking references to None and False (etc) Modified: python/branches/py3k/Python/errors.c ============================================================================== --- python/branches/py3k/Python/errors.c (original) +++ python/branches/py3k/Python/errors.c Sun Dec 2 10:40:06 2007 @@ -645,7 +645,7 @@ else { char* modstr = PyUnicode_AsString(moduleName); if (modstr && - strcmp(modstr, "__builtin__") != 0) + strcmp(modstr, "builtins") != 0) { PyFile_WriteString(modstr, f); PyFile_WriteString(".", f); Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Sun Dec 2 10:40:06 2007 @@ -400,11 +400,11 @@ deleted *last* of all, they would come too late in the normal destruction order. Sigh. */ - value = PyDict_GetItemString(modules, "__builtin__"); + value = PyDict_GetItemString(modules, "builtins"); if (value != NULL && PyModule_Check(value)) { dict = PyModule_GetDict(value); if (Py_VerboseFlag) - PySys_WriteStderr("# clear __builtin__._\n"); + PySys_WriteStderr("# clear builtins._\n"); PyDict_SetItemString(dict, "_", Py_None); } value = PyDict_GetItemString(modules, "sys"); @@ -436,11 +436,11 @@ PyDict_SetItemString(modules, "__main__", Py_None); } - /* The special treatment of __builtin__ here is because even + /* The special treatment of "builtins" here is because even when it's not referenced as a module, its dictionary is referenced by almost every module's __builtins__. Since deleting a module clears its dictionary (even if there are - references left to it), we need to delete the __builtin__ + references left to it), we need to delete the "builtins" module last. Likewise, we don't delete sys until the very end because it is implicitly referenced (e.g. by print). @@ -451,7 +451,7 @@ re-imported. */ /* Next, repeatedly delete modules with a reference count of - one (skipping __builtin__ and sys) and delete them */ + one (skipping builtins and sys) and delete them */ do { ndone = 0; pos = 0; @@ -460,7 +460,7 @@ continue; if (PyUnicode_Check(key) && PyModule_Check(value)) { name = PyUnicode_AsString(key); - if (strcmp(name, "__builtin__") == 0) + if (strcmp(name, "builtins") == 0) continue; if (strcmp(name, "sys") == 0) continue; @@ -474,12 +474,12 @@ } } while (ndone > 0); - /* Next, delete all modules (still skipping __builtin__ and sys) */ + /* Next, delete all modules (still skipping builtins and sys) */ pos = 0; while (PyDict_Next(modules, &pos, &key, &value)) { if (PyUnicode_Check(key) && PyModule_Check(value)) { name = PyUnicode_AsString(key); - if (strcmp(name, "__builtin__") == 0) + if (strcmp(name, "builtins") == 0) continue; if (strcmp(name, "sys") == 0) continue; @@ -490,7 +490,7 @@ } } - /* Next, delete sys and __builtin__ (in that order) */ + /* Next, delete sys and builtins (in that order) */ value = PyDict_GetItemString(modules, "sys"); if (value != NULL && PyModule_Check(value)) { if (Py_VerboseFlag) @@ -498,12 +498,12 @@ _PyModule_Clear(value); PyDict_SetItemString(modules, "sys", Py_None); } - value = PyDict_GetItemString(modules, "__builtin__"); + value = PyDict_GetItemString(modules, "builtins"); if (value != NULL && PyModule_Check(value)) { if (Py_VerboseFlag) - PySys_WriteStderr("# cleanup __builtin__\n"); + PySys_WriteStderr("# cleanup builtins\n"); _PyModule_Clear(value); - PyDict_SetItemString(modules, "__builtin__", Py_None); + PyDict_SetItemString(modules, "builtins", Py_None); } /* Finally, clear and delete the modules directory */ @@ -2491,7 +2491,7 @@ /* No globals -- use standard builtins, and fake globals */ PyErr_Clear(); - builtins = PyImport_ImportModuleLevel("__builtin__", + builtins = PyImport_ImportModuleLevel("builtins", NULL, NULL, NULL, 0); if (builtins == NULL) return NULL; Modified: python/branches/py3k/Python/pythonrun.c ============================================================================== --- python/branches/py3k/Python/pythonrun.c (original) +++ python/branches/py3k/Python/pythonrun.c Sun Dec 2 10:40:06 2007 @@ -211,7 +211,7 @@ bimod = _PyBuiltin_Init(); if (bimod == NULL) - Py_FatalError("Py_Initialize: can't initialize __builtin__"); + Py_FatalError("Py_Initialize: can't initialize builtins modules"); interp->builtins = PyModule_GetDict(bimod); if (interp->builtins == NULL) Py_FatalError("Py_Initialize: can't initialize builtins dict"); @@ -243,7 +243,7 @@ _PyImport_Init(); /* phase 2 of builtins */ - _PyImport_FixupExtension("__builtin__", "__builtin__"); + _PyImport_FixupExtension("builtins", "builtins"); _PyImportHooks_Init(); @@ -572,7 +572,7 @@ interp->modules = PyDict_New(); interp->modules_reloading = PyDict_New(); - bimod = _PyImport_FindExtension("__builtin__", "__builtin__"); + bimod = _PyImport_FindExtension("builtins", "builtins"); if (bimod != NULL) { interp->builtins = PyModule_GetDict(bimod); if (interp->builtins == NULL) @@ -682,7 +682,7 @@ Py_FatalError("can't create __main__ module"); d = PyModule_GetDict(m); if (PyDict_GetItemString(d, "__builtins__") == NULL) { - PyObject *bimod = PyImport_ImportModule("__builtin__"); + PyObject *bimod = PyImport_ImportModule("builtins"); if (bimod == NULL || PyDict_SetItemString(d, "__builtins__", bimod) != 0) Py_FatalError("can't add __builtins__ to __main__"); @@ -717,7 +717,7 @@ } } -/* Initialize sys.stdin, stdout, stderr and __builtin__.open */ +/* Initialize sys.stdin, stdout, stderr and builtins.open */ static int initstdio(void) { @@ -739,7 +739,7 @@ } Py_DECREF(m); - if (!(bimod = PyImport_ImportModule("__builtin__"))) { + if (!(bimod = PyImport_ImportModule("builtins"))) { goto error; } @@ -750,7 +750,7 @@ goto error; } - /* Set __builtin__.open */ + /* Set builtins.open */ if (PyObject_SetAttrString(bimod, "open", wrapper) == -1) { goto error; } @@ -1362,7 +1362,7 @@ } else { char* modstr = PyUnicode_AsString(moduleName); - if (modstr && strcmp(modstr, "__builtin__")) + if (modstr && strcmp(modstr, "builtins")) { err = PyFile_WriteString(modstr, f); err += PyFile_WriteString(".", f); Modified: python/branches/py3k/Python/sysmodule.c ============================================================================== --- python/branches/py3k/Python/sysmodule.c (original) +++ python/branches/py3k/Python/sysmodule.c Sun Dec 2 10:40:06 2007 @@ -72,10 +72,10 @@ PyObject *outf; PyInterpreterState *interp = PyThreadState_GET()->interp; PyObject *modules = interp->modules; - PyObject *builtins = PyDict_GetItemString(modules, "__builtin__"); + PyObject *builtins = PyDict_GetItemString(modules, "builtins"); if (builtins == NULL) { - PyErr_SetString(PyExc_RuntimeError, "lost __builtin__"); + PyErr_SetString(PyExc_RuntimeError, "lost builtins module"); return NULL; } @@ -106,7 +106,7 @@ PyDoc_STRVAR(displayhook_doc, "displayhook(object) -> None\n" "\n" -"Print an object to sys.stdout and also save it in __builtin__.\n" +"Print an object to sys.stdout and also save it in builtins.\n" ); static PyObject * @@ -896,7 +896,7 @@ \n\ Functions:\n\ \n\ -displayhook() -- print an object to the screen, and save it in __builtin__._\n\ +displayhook() -- print an object to the screen, and save it in builtins._\n\ excepthook() -- print an exception and its traceback to sys.stderr\n\ exc_info() -- return thread-safe information about the current exception\n\ exit() -- exit the interpreter by raising SystemExit\n\ Modified: python/branches/py3k/Tools/freeze/makeconfig.py ============================================================================== --- python/branches/py3k/Tools/freeze/makeconfig.py (original) +++ python/branches/py3k/Tools/freeze/makeconfig.py Sun Dec 2 10:40:06 2007 @@ -3,7 +3,7 @@ # Write the config.c file -never = ['marshal', '__main__', '__builtin__', 'sys', 'exceptions'] +never = ['marshal', '__main__', 'builtins', 'sys', 'exceptions'] def makeconfig(infp, outfp, modules, with_ifdef=0): m1 = re.compile('-- ADDMODULE MARKER 1 --') From python-3000-checkins at python.org Sun Dec 2 15:31:25 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 15:31:25 +0100 (CET) Subject: [Python-3000-checkins] r59270 - in python/branches/py3k: Demo/embed/demo.c Doc/includes/run-func.c Doc/includes/shoddy.c Include/intobject.h Include/longobject.h Include/py_curses.h Include/pythonrun.h Mac/Modules/MacOS.c Mac/Modules/carbonevt/_CarbonEvtmodule.c Mac/Modules/cf/pycfbridge.c Mac/Modules/ctl/_Ctlmodule.c Mac/Modules/dlg/_Dlgmodule.c Mac/Modules/gestaltmodule.c Mac/Modules/qd/_Qdmodule.c Mac/Modules/res/_Resmodule.c Mac/Modules/snd/_Sndihooks.c Mac/Modules/win/_Winmodule.c Modules/_bisectmodule.c Modules/_bsddb.c Modules/_collectionsmodule.c Modules/_csv.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/stgdict.c Modules/_cursesmodule.c Modules/_elementtree.c Modules/_fileio.c Modules/_hashopenssl.c Modules/_localemodule.c Modules/_randommodule.c Modules/_sqlite/connection.c Modules/_sqlite/cursor.c Modules/_sqlite/module.c Modules/_sre.c Modules/_ssl.c Modules/_struct.c Modules/_testcapimodule.c Modules/_tkinter.c Modules/_weakref.c Modules/arraymodule.c Modules/audioop.c Modules/binascii.c Modules/bz2module.c Modules/cStringIO.c Modules/cjkcodecs/multibytecodec.c Modules/datetimemodule.c Modules/dlmodule.c Modules/errnomodule.c Modules/fcntlmodule.c Modules/gcmodule.c Modules/grpmodule.c Modules/itertoolsmodule.c Modules/md5module.c Modules/mmapmodule.c Modules/operator.c Modules/ossaudiodev.c Modules/parsermodule.c Modules/posixmodule.c Modules/pwdmodule.c Modules/pyexpat.c Modules/readline.c Modules/resource.c Modules/selectmodule.c Modules/sha1module.c Modules/sha256module.c Modules/sha512module.c Modules/signalmodule.c Modules/socketmodule.c Modules/spwdmodule.c Modules/syslogmodule.c Modules/termios.c Modules/threadmodule.c Modules/timemodule.c Modules/unicodedata.c Modules/xxmodule.c Modules/xxsubtype.c Modules/zipimport.c Modules/zlibmodule.c Objects/abstract.c Objects/bytesobject.c Objects/dictobject.c Objects/enumobject.c Objects/exceptions.c Objects/fileobject.c Objects/floatobject.c Objects/frameobject.c Objects/iterobject.c Objects/listobject.c Objects/longobject.c Objects/memoryobject.c Objects/rangeobject.c Objects/setobject.c Objects/sliceobject.c Objects/stringlib/formatter.h Objects/stringlib/string_format.h Objects/stringobject.c Objects/structseq.c Objects/tupleobject.c Objects/typeobject.c Objects/unicodeobject.c PC/_msi.c PC/_subprocess.c PC/_winreg.c PC/msvcrtmodule.c Python/Python-ast.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/compile.c Python/errors.c Python/getargs.c Python/import.c Python/mactoolboxglue.c Python/marshal.c Python/modsupport.c Python/pystate.c Python/pythonrun.c Python/structmember.c Python/symtable.c Python/sysmodule.c Python/traceback.c Message-ID: <20071202143125.0E7F61E4020@bag.python.org> Author: christian.heimes Date: Sun Dec 2 15:31:20 2007 New Revision: 59270 Modified: python/branches/py3k/Demo/embed/demo.c python/branches/py3k/Doc/includes/run-func.c python/branches/py3k/Doc/includes/shoddy.c python/branches/py3k/Include/intobject.h python/branches/py3k/Include/longobject.h python/branches/py3k/Include/py_curses.h python/branches/py3k/Include/pythonrun.h python/branches/py3k/Mac/Modules/MacOS.c python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c python/branches/py3k/Mac/Modules/cf/pycfbridge.c python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c python/branches/py3k/Mac/Modules/gestaltmodule.c python/branches/py3k/Mac/Modules/qd/_Qdmodule.c python/branches/py3k/Mac/Modules/res/_Resmodule.c python/branches/py3k/Mac/Modules/snd/_Sndihooks.c python/branches/py3k/Mac/Modules/win/_Winmodule.c python/branches/py3k/Modules/_bisectmodule.c python/branches/py3k/Modules/_bsddb.c python/branches/py3k/Modules/_collectionsmodule.c python/branches/py3k/Modules/_csv.c python/branches/py3k/Modules/_ctypes/_ctypes.c python/branches/py3k/Modules/_ctypes/callbacks.c python/branches/py3k/Modules/_ctypes/callproc.c python/branches/py3k/Modules/_ctypes/cfield.c python/branches/py3k/Modules/_ctypes/stgdict.c python/branches/py3k/Modules/_cursesmodule.c python/branches/py3k/Modules/_elementtree.c python/branches/py3k/Modules/_fileio.c python/branches/py3k/Modules/_hashopenssl.c python/branches/py3k/Modules/_localemodule.c python/branches/py3k/Modules/_randommodule.c python/branches/py3k/Modules/_sqlite/connection.c python/branches/py3k/Modules/_sqlite/cursor.c python/branches/py3k/Modules/_sqlite/module.c python/branches/py3k/Modules/_sre.c python/branches/py3k/Modules/_ssl.c python/branches/py3k/Modules/_struct.c python/branches/py3k/Modules/_testcapimodule.c python/branches/py3k/Modules/_tkinter.c python/branches/py3k/Modules/_weakref.c python/branches/py3k/Modules/arraymodule.c python/branches/py3k/Modules/audioop.c python/branches/py3k/Modules/binascii.c python/branches/py3k/Modules/bz2module.c python/branches/py3k/Modules/cStringIO.c python/branches/py3k/Modules/cjkcodecs/multibytecodec.c python/branches/py3k/Modules/datetimemodule.c python/branches/py3k/Modules/dlmodule.c python/branches/py3k/Modules/errnomodule.c python/branches/py3k/Modules/fcntlmodule.c python/branches/py3k/Modules/gcmodule.c python/branches/py3k/Modules/grpmodule.c python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Modules/md5module.c python/branches/py3k/Modules/mmapmodule.c python/branches/py3k/Modules/operator.c python/branches/py3k/Modules/ossaudiodev.c python/branches/py3k/Modules/parsermodule.c python/branches/py3k/Modules/posixmodule.c python/branches/py3k/Modules/pwdmodule.c python/branches/py3k/Modules/pyexpat.c python/branches/py3k/Modules/readline.c python/branches/py3k/Modules/resource.c python/branches/py3k/Modules/selectmodule.c python/branches/py3k/Modules/sha1module.c python/branches/py3k/Modules/sha256module.c python/branches/py3k/Modules/sha512module.c python/branches/py3k/Modules/signalmodule.c python/branches/py3k/Modules/socketmodule.c python/branches/py3k/Modules/spwdmodule.c python/branches/py3k/Modules/syslogmodule.c python/branches/py3k/Modules/termios.c python/branches/py3k/Modules/threadmodule.c python/branches/py3k/Modules/timemodule.c python/branches/py3k/Modules/unicodedata.c python/branches/py3k/Modules/xxmodule.c python/branches/py3k/Modules/xxsubtype.c python/branches/py3k/Modules/zipimport.c python/branches/py3k/Modules/zlibmodule.c python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/bytesobject.c python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/enumobject.c python/branches/py3k/Objects/exceptions.c python/branches/py3k/Objects/fileobject.c python/branches/py3k/Objects/floatobject.c python/branches/py3k/Objects/frameobject.c python/branches/py3k/Objects/iterobject.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Objects/longobject.c python/branches/py3k/Objects/memoryobject.c python/branches/py3k/Objects/rangeobject.c python/branches/py3k/Objects/setobject.c python/branches/py3k/Objects/sliceobject.c python/branches/py3k/Objects/stringlib/formatter.h python/branches/py3k/Objects/stringlib/string_format.h python/branches/py3k/Objects/stringobject.c python/branches/py3k/Objects/structseq.c python/branches/py3k/Objects/tupleobject.c python/branches/py3k/Objects/typeobject.c python/branches/py3k/Objects/unicodeobject.c python/branches/py3k/PC/_msi.c python/branches/py3k/PC/_subprocess.c python/branches/py3k/PC/_winreg.c python/branches/py3k/PC/msvcrtmodule.c python/branches/py3k/Python/Python-ast.c python/branches/py3k/Python/ast.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/ceval.c python/branches/py3k/Python/compile.c python/branches/py3k/Python/errors.c python/branches/py3k/Python/getargs.c python/branches/py3k/Python/import.c python/branches/py3k/Python/mactoolboxglue.c python/branches/py3k/Python/marshal.c python/branches/py3k/Python/modsupport.c python/branches/py3k/Python/pystate.c python/branches/py3k/Python/pythonrun.c python/branches/py3k/Python/structmember.c python/branches/py3k/Python/symtable.c python/branches/py3k/Python/sysmodule.c python/branches/py3k/Python/traceback.c Log: Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h Modified: python/branches/py3k/Demo/embed/demo.c ============================================================================== --- python/branches/py3k/Demo/embed/demo.c (original) +++ python/branches/py3k/Demo/embed/demo.c Sun Dec 2 15:31:20 2007 @@ -48,7 +48,7 @@ static PyObject * xyzzy_foo(PyObject *self, PyObject* args) { - return PyInt_FromLong(42L); + return PyLong_FromLong(42L); } static PyMethodDef xyzzy_methods[] = { Modified: python/branches/py3k/Doc/includes/run-func.c ============================================================================== --- python/branches/py3k/Doc/includes/run-func.c (original) +++ python/branches/py3k/Doc/includes/run-func.c Sun Dec 2 15:31:20 2007 @@ -26,7 +26,7 @@ if (pFunc && PyCallable_Check(pFunc)) { pArgs = PyTuple_New(argc - 3); for (i = 0; i < argc - 3; ++i) { - pValue = PyInt_FromLong(atoi(argv[i + 3])); + pValue = PyLong_FromLong(atoi(argv[i + 3])); if (!pValue) { Py_DECREF(pArgs); Py_DECREF(pModule); @@ -39,7 +39,7 @@ pValue = PyObject_CallObject(pFunc, pArgs); Py_DECREF(pArgs); if (pValue != NULL) { - printf("Result of call: %ld\n", PyInt_AsLong(pValue)); + printf("Result of call: %ld\n", PyLong_AsLong(pValue)); Py_DECREF(pValue); } else { Modified: python/branches/py3k/Doc/includes/shoddy.c ============================================================================== --- python/branches/py3k/Doc/includes/shoddy.c (original) +++ python/branches/py3k/Doc/includes/shoddy.c Sun Dec 2 15:31:20 2007 @@ -10,7 +10,7 @@ Shoddy_increment(Shoddy *self, PyObject *unused) { self->state++; - return PyInt_FromLong(self->state); + return PyLong_FromLong(self->state); } Modified: python/branches/py3k/Include/intobject.h ============================================================================== --- python/branches/py3k/Include/intobject.h (original) +++ python/branches/py3k/Include/intobject.h Sun Dec 2 15:31:20 2007 @@ -29,23 +29,24 @@ PyAPI_DATA(PyTypeObject) PyInt_Type; */ -#define PyInt_Check(op) PyLong_Check(op) #define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op)) -#define PyInt_FromString PyLong_FromString -#define PyInt_FromUnicode PyLong_FromUnicode -#define PyInt_FromLong PyLong_FromLong -#define PyInt_FromSize_t PyLong_FromSize_t -#define PyInt_FromSsize_t PyLong_FromSsize_t -#define PyInt_AsLong PyLong_AsLong -#define PyInt_AsSsize_t PyLong_AsSsize_t -#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask -#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#ifdef 0 +# define PyInt_Check(op) PyLong_Check(op) +# define PyInt_FromString PyLong_FromString +# define PyInt_FromUnicode PyLong_FromUnicode +# define PyInt_FromLong PyLong_FromLong +# define PyInt_FromSize_t PyLong_FromSize_t +# define PyInt_FromSsize_t PyLong_FromSsize_t +# define PyInt_AsLong PyLong_AsLong +# define PyInt_AsSsize_t PyLong_AsSsize_t +# define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask +# define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +# define PyInt_AS_LONG PyLong_AS_LONG +#endif PyAPI_FUNC(long) PyInt_GetMax(void); -#define PyInt_AS_LONG(op) PyLong_AsLong(op) - /* These aren't really part of the Int object, but they're handy; the protos * are necessary for systems that need the magic of PyAPI_FUNC. */ Modified: python/branches/py3k/Include/longobject.h ============================================================================== --- python/branches/py3k/Include/longobject.h (original) +++ python/branches/py3k/Include/longobject.h Sun Dec 2 15:31:20 2007 @@ -26,6 +26,10 @@ PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +/* It may be useful in the future. I've added it in the PyInt -> PyLong + cleanup to keep the extra information. [CH] */ +#define PyLong_AS_LONG(op) PyLong_AsLong(op) + /* Used by socketmodule.c */ #if SIZEOF_SOCKET_T <= SIZEOF_LONG #define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd)) Modified: python/branches/py3k/Include/py_curses.h ============================================================================== --- python/branches/py3k/Include/py_curses.h (original) +++ python/branches/py3k/Include/py_curses.h Sun Dec 2 15:31:20 2007 @@ -139,7 +139,7 @@ static PyObject *PyCurses_ ## X (PyObject *self) \ { \ PyCursesInitialised \ - return PyInt_FromLong((long) X()); } + return PyLong_FromLong((long) X()); } #define NoArgReturnStringFunction(X) \ Modified: python/branches/py3k/Include/pythonrun.h ============================================================================== --- python/branches/py3k/Include/pythonrun.h (original) +++ python/branches/py3k/Include/pythonrun.h Sun Dec 2 15:31:20 2007 @@ -125,7 +125,6 @@ PyAPI_FUNC(void) _PyExc_Init(void); PyAPI_FUNC(void) _PyImportHooks_Init(void); PyAPI_FUNC(int) _PyFrame_Init(void); -PyAPI_FUNC(int) _PyInt_Init(void); PyAPI_FUNC(void) _PyFloat_Init(void); PyAPI_FUNC(int) PyBytes_Init(void); @@ -140,7 +139,6 @@ PyAPI_FUNC(void) PySet_Fini(void); PyAPI_FUNC(void) PyString_Fini(void); PyAPI_FUNC(void) PyBytes_Fini(void); -PyAPI_FUNC(void) PyInt_Fini(void); PyAPI_FUNC(void) PyFloat_Fini(void); PyAPI_FUNC(void) PyOS_FiniInterrupts(void); Modified: python/branches/py3k/Mac/Modules/MacOS.c ============================================================================== --- python/branches/py3k/Mac/Modules/MacOS.c (original) +++ python/branches/py3k/Mac/Modules/MacOS.c Sun Dec 2 15:31:20 2007 @@ -195,7 +195,7 @@ PyMac_Error(err); return NULL; } - return PyInt_FromLong(where); + return PyLong_FromLong(where); } static char rf_close__doc__[] = Modified: python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c (original) +++ python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c Sun Dec 2 15:31:20 2007 @@ -102,8 +102,8 @@ } else { if (retValue == Py_None) status = noErr; - else if (PyInt_Check(retValue)) { - status = PyInt_AsLong(retValue); + else if (PyLong_Check(retValue)) { + status = PyLong_AsLong(retValue); } else status = noErr; /* wrong object type, complain? */ Py_DECREF(retValue); Modified: python/branches/py3k/Mac/Modules/cf/pycfbridge.c ============================================================================== --- python/branches/py3k/Mac/Modules/cf/pycfbridge.c (original) +++ python/branches/py3k/Mac/Modules/cf/pycfbridge.c Sun Dec 2 15:31:20 2007 @@ -114,7 +114,7 @@ long l; if (!CFNumberGetValue(src, kCFNumberLongType, &l)) /* XXXX Out of range! */; - return PyInt_FromLong(l); + return PyLong_FromLong(l); } } /* XXXX Should return as CFTypeRef, really... */ @@ -258,8 +258,8 @@ *dst = kCFBooleanFalse; return 1; } - if (PyInt_Check(src)) { - long v = PyInt_AsLong(src); + if (PyLong_Check(src)) { + long v = PyLong_AsLong(src); *dst = CFNumberCreate(NULL, kCFNumberLongType, &v); return 1; } Modified: python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c (original) +++ python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c Sun Dec 2 15:31:20 2007 @@ -3250,7 +3250,7 @@ PyMac_GetPoint, &startPoint, &callback)) return NULL; if (callback && callback != Py_None) { - if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) + if (PyLong_Check(callback) && PyLong_AS_LONG(callback) == -1) upp = (ControlActionUPP)-1; else { settrackfunc(callback); @@ -3283,7 +3283,7 @@ &callback)) return NULL; if (callback && callback != Py_None) { - if (PyInt_Check(callback) && PyInt_AS_LONG(callback) == -1) + if (PyLong_Check(callback) && PyLong_AS_LONG(callback) == -1) upp = (ControlActionUPP)-1; else { settrackfunc(callback); Modified: python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c (original) +++ python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c Sun Dec 2 15:31:20 2007 @@ -55,8 +55,8 @@ } else { Dlg_FilterProc_callback = callback; - if (PyInt_Check(res)) { - *itemHit = PyInt_AsLong(res); + if (PyLong_Check(res)) { + *itemHit = PyLong_AsLong(res); rv = 1; } else @@ -150,7 +150,7 @@ int DlgObj_Convert(PyObject *v, DialogPtr *p_itself) { if (v == Py_None) { *p_itself = NULL; return 1; } - if (PyInt_Check(v)) { *p_itself = (DialogPtr)PyInt_AsLong(v); + if (PyLong_Check(v)) { *p_itself = (DialogPtr)PyLong_AsLong(v); return 1; } if (!DlgObj_Check(v)) { Modified: python/branches/py3k/Mac/Modules/gestaltmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/gestaltmodule.c (original) +++ python/branches/py3k/Mac/Modules/gestaltmodule.c Sun Dec 2 15:31:20 2007 @@ -40,7 +40,7 @@ iErr = Gestalt ( selector, &response ); if (iErr != 0) return PyMac_Error(iErr); - return PyInt_FromLong(response); + return PyLong_FromLong(response); } static struct PyMethodDef gestalt_methods[] = { Modified: python/branches/py3k/Mac/Modules/qd/_Qdmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/qd/_Qdmodule.c (original) +++ python/branches/py3k/Mac/Modules/qd/_Qdmodule.c Sun Dec 2 15:31:20 2007 @@ -1488,14 +1488,14 @@ static PyObject *BMObj_get_baseAddr(BitMapObject *self, void *closure) { - return PyInt_FromLong((long)self->ob_itself->baseAddr); + return PyLong_FromLong((long)self->ob_itself->baseAddr); } #define BMObj_set_baseAddr NULL static PyObject *BMObj_get_rowBytes(BitMapObject *self, void *closure) { - return PyInt_FromLong((long)self->ob_itself->rowBytes); + return PyLong_FromLong((long)self->ob_itself->rowBytes); } #define BMObj_set_rowBytes NULL Modified: python/branches/py3k/Mac/Modules/res/_Resmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/res/_Resmodule.c (original) +++ python/branches/py3k/Mac/Modules/res/_Resmodule.c Sun Dec 2 15:31:20 2007 @@ -556,7 +556,7 @@ static PyObject *ResObj_get_size(ResourceObject *self, void *closure) { - return PyInt_FromLong(GetHandleSize(self->ob_itself)); + return PyLong_FromLong(GetHandleSize(self->ob_itself)); } #define ResObj_set_size NULL Modified: python/branches/py3k/Mac/Modules/snd/_Sndihooks.c ============================================================================== --- python/branches/py3k/Mac/Modules/snd/_Sndihooks.c (original) +++ python/branches/py3k/Mac/Modules/snd/_Sndihooks.c Sun Dec 2 15:31:20 2007 @@ -409,7 +409,7 @@ if( (rsizes = PyTuple_New(arg.numsizes)) == NULL) return NULL; for( i=0; idata = malloc(sizeof(db_recno_t)); if (key->data == NULL) { PyErr_SetString(PyExc_MemoryError, "Key memory allocation failed"); @@ -738,7 +738,7 @@ /* add an integer to a dictionary using the given name as a key */ static void _addIntToDict(PyObject* dict, char *name, int value) { - PyObject* v = PyInt_FromLong((long) value); + PyObject* v = PyLong_FromLong((long) value); if (!v || PyDict_SetItemString(dict, name, v)) PyErr_Clear(); @@ -755,7 +755,7 @@ v = PyLong_FromLongLong((PY_LONG_LONG) value); else #endif - v = PyInt_FromLong((long) value); + v = PyLong_FromLong((long) value); if (!v || PyDict_SetItemString(dict, name, v)) PyErr_Clear(); @@ -1132,7 +1132,7 @@ } free_buf_view(dataobj, data_buf_view); - return PyInt_FromLong(recno); + return PyLong_FromLong(recno); } @@ -1168,8 +1168,8 @@ else if (result == Py_None) { retval = DB_DONOTINDEX; } - else if (PyInt_Check(result)) { - retval = PyInt_AsLong(result); + else if (PyLong_Check(result)) { + retval = PyLong_AsLong(result); } else if (PyBytes_Check(result) || PyString_Check(result)) { char* data; @@ -1457,7 +1457,7 @@ err = self->db->fd(self->db, &the_fd); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); - return PyInt_FromLong(the_fd); + return PyLong_FromLong(the_fd); } @@ -1594,7 +1594,7 @@ if (self->primaryDBType == DB_RECNO || self->primaryDBType == DB_QUEUE) - pkeyObj = PyInt_FromLong(*(int *)pkey.data); + pkeyObj = PyLong_FromLong(*(int *)pkey.data); else pkeyObj = PyString_FromStringAndSize(pkey.data, pkey.size); @@ -1603,7 +1603,7 @@ PyObject *keyObj; int type = _DB_get_type(self); if (type == DB_RECNO || type == DB_QUEUE) - keyObj = PyInt_FromLong(*(int *)key.data); + keyObj = PyLong_FromLong(*(int *)key.data); else keyObj = PyString_FromStringAndSize(key.data, key.size); #if (PY_VERSION_HEX >= 0x02040000) @@ -1667,7 +1667,7 @@ err = self->db->get(self->db, txn, &key, &data, flags); MYDB_END_ALLOW_THREADS; if (err == DB_BUFFER_SMALL) { - retval = PyInt_FromLong((long)data.size); + retval = PyLong_FromLong((long)data.size); err = 0; } @@ -1769,7 +1769,7 @@ retval = self->db->get_byteswapped(self->db); MYDB_END_ALLOW_THREADS; #endif - return PyInt_FromLong(retval); + return PyLong_FromLong(retval); } @@ -1785,7 +1785,7 @@ type = _DB_get_type(self); if (type == -1) return NULL; - return PyInt_FromLong(type); + return PyLong_FromLong(type); } @@ -2004,7 +2004,7 @@ } if (flags & DB_APPEND) - retval = PyInt_FromLong(*((db_recno_t*)key.data)); + retval = PyLong_FromLong(*((db_recno_t*)key.data)); else { retval = Py_None; Py_INCREF(retval); @@ -2130,8 +2130,8 @@ /* we're in a callback within the DB code, we can't raise */ PyErr_Print(); res = _default_cmp(leftKey, rightKey); - } else if (PyInt_Check(result)) { - res = PyInt_AsLong(result); + } else if (PyLong_Check(result)) { + res = PyLong_AsLong(result); } else { PyErr_SetString(PyExc_TypeError, "DB_bt_compare callback MUST return an int."); @@ -2175,11 +2175,11 @@ Py_DECREF(tuple); if (result == NULL) return NULL; - if (!PyInt_Check(result)) { + if (!PyLong_Check(result)) { PyErr_SetString(PyExc_TypeError, "callback MUST return an int"); return NULL; - } else if (PyInt_AsLong(result) != 0) { + } else if (PyLong_AsLong(result) != 0) { PyErr_SetString(PyExc_TypeError, "callback failed to return 0 on two empty strings"); return NULL; @@ -2581,7 +2581,7 @@ err = self->db->truncate(self->db, txn, &count, flags); MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); - return PyInt_FromLong(count); + return PyLong_FromLong(count); } #endif @@ -2662,7 +2662,7 @@ ++oldValue; self->moduleFlags.getReturnsNone = (flags >= 1); self->moduleFlags.cursorSetReturnsNone = (flags >= 2); - return PyInt_FromLong(oldValue); + return PyLong_FromLong(oldValue); } #if (DBVER >= 41) @@ -2866,9 +2866,9 @@ FREE_DBT_VIEW(key, keyobj, key_buf_view); if (err == DB_BUFFER_SMALL || err == 0) { - return PyInt_FromLong(1); + return PyLong_FromLong(1); } else if (err == DB_NOTFOUND || err == DB_KEYEMPTY) { - return PyInt_FromLong(0); + return PyLong_FromLong(0); } makeDBError(err); @@ -2936,7 +2936,7 @@ break; case DB_RECNO: case DB_QUEUE: - item = PyInt_FromLong(*((db_recno_t*)key.data)); + item = PyLong_FromLong(*((db_recno_t*)key.data)); break; } break; @@ -3071,7 +3071,7 @@ MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); - return PyInt_FromLong(count); + return PyLong_FromLong(count); } @@ -3294,7 +3294,7 @@ if (self->mydb->primaryDBType == DB_RECNO || self->mydb->primaryDBType == DB_QUEUE) - pkeyObj = PyInt_FromLong(*(int *)pkey.data); + pkeyObj = PyLong_FromLong(*(int *)pkey.data); else pkeyObj = PyString_FromStringAndSize(pkey.data, pkey.size); @@ -3303,7 +3303,7 @@ PyObject *keyObj; int type = _DB_get_type(self->mydb); if (type == DB_RECNO || type == DB_QUEUE) - keyObj = PyInt_FromLong(*(int *)key.data); + keyObj = PyLong_FromLong(*(int *)key.data); else keyObj = PyString_FromStringAndSize(key.data, key.size); retval = PyTuple_Pack(3, keyObj, pkeyObj, dataObj); @@ -3359,7 +3359,7 @@ recno = *((db_recno_t*)data.data); free_dbt(&key); free_dbt(&data); - return PyInt_FromLong(recno); + return PyLong_FromLong(recno); } @@ -3661,7 +3661,7 @@ MYDB_END_ALLOW_THREADS; if (err == DB_BUFFER_SMALL || !err) { /* DB_BUFFER_SMALL means positive size, !err means zero length value */ - retval = PyInt_FromLong((long)data.size); + retval = PyLong_FromLong((long)data.size); err = 0; } @@ -4336,7 +4336,7 @@ #endif MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); - return PyInt_FromLong(aborted); + return PyLong_FromLong(aborted); } @@ -4380,7 +4380,7 @@ MYDB_END_ALLOW_THREADS; RETURN_IF_ERR(); - return PyInt_FromLong((long)theID); + return PyLong_FromLong((long)theID); } #if (DBVER >= 40) @@ -4695,7 +4695,7 @@ ++oldValue; self->moduleFlags.getReturnsNone = (flags >= 1); self->moduleFlags.cursorSetReturnsNone = (flags >= 2); - return PyInt_FromLong(oldValue); + return PyLong_FromLong(oldValue); } @@ -4839,7 +4839,7 @@ id = txn_id(self->txn); #endif MYDB_END_ALLOW_THREADS; - return PyInt_FromLong(id); + return PyLong_FromLong(id); } #if (DBVER >= 43) @@ -5022,7 +5022,7 @@ MYDB_END_ALLOW_THREADS RETURN_IF_ERR(); - return PyInt_FromLong(size); + return PyLong_FromLong(size); } static PyObject* @@ -5056,7 +5056,7 @@ MYDB_END_ALLOW_THREADS RETURN_IF_ERR(); - return PyInt_FromLong((int)flags); + return PyLong_FromLong((int)flags); } static PyObject* Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Sun Dec 2 15:31:20 2007 @@ -775,7 +775,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist, &iterable, &maxlenobj)) return -1; if (maxlenobj != NULL && maxlenobj != Py_None) { - maxlen = PyInt_AsLong(maxlenobj); + maxlen = PyLong_AsLong(maxlenobj); if (maxlen == -1 && PyErr_Occurred()) return -1; if (maxlen < 0) { @@ -954,7 +954,7 @@ static PyObject * dequeiter_len(dequeiterobject *it) { - return PyInt_FromLong(it->counter); + return PyLong_FromLong(it->counter); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/Modules/_csv.c ============================================================================== --- python/branches/py3k/Modules/_csv.c (original) +++ python/branches/py3k/Modules/_csv.c Sun Dec 2 15:31:20 2007 @@ -162,7 +162,7 @@ static PyObject * Dialect_get_quoting(DialectObj *self) { - return PyInt_FromLong(self->quoting); + return PyLong_FromLong(self->quoting); } static int @@ -186,7 +186,7 @@ "\"%s\" must be an integer", name); return -1; } - *target = PyInt_AsLong(src); + *target = PyLong_AsLong(src); } return 0; } @@ -1390,9 +1390,9 @@ "limit must be an integer"); return NULL; } - field_limit = PyInt_AsLong(new_limit); + field_limit = PyLong_AsLong(new_limit); } - return PyInt_FromLong(old_limit); + return PyLong_FromLong(old_limit); } /* Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Sun Dec 2 15:31:20 2007 @@ -236,7 +236,7 @@ CDataType_from_address(PyObject *type, PyObject *value) { void *buf; - if (!PyInt_Check(value)) { + if (!PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "integer expected"); return NULL; @@ -265,7 +265,7 @@ obj = PyObject_GetAttrString(dll, "_handle"); if (!obj) return NULL; - if (!PyInt_Check(obj)) { + if (!PyLong_Check(obj)) { PyErr_SetString(PyExc_TypeError, "the _handle attribute of the second argument must be an integer"); Py_DECREF(obj); @@ -641,7 +641,7 @@ StgDictObject *typedict; if (value == Py_None) - return PyInt_FromLong(0); /* NULL pointer */ + return PyLong_FromLong(0); /* NULL pointer */ typedict = PyType_stgdict(type); assert(typedict); /* Cannot be NULL for pointer types */ @@ -969,7 +969,7 @@ "which must be a positive integer"); return NULL; } - length = PyInt_AS_LONG(proto); + length = PyLong_AS_LONG(proto); proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */ if (!proto) { @@ -1233,7 +1233,7 @@ } /* Should probably allow buffer interface as well */ /* int, long */ - if (PyInt_Check(value)) { + if (PyLong_Check(value)) { PyCArgObject *parg; struct fielddesc *fd = getentry("P"); @@ -1784,12 +1784,12 @@ stgdict->ffi_type_pointer = ffi_type_pointer; ob = PyDict_GetItemString((PyObject *)stgdict, "_flags_"); - if (!ob || !PyInt_Check(ob)) { + if (!ob || !PyLong_Check(ob)) { PyErr_SetString(PyExc_TypeError, "class must define _flags_ which must be an integer"); return -1; } - stgdict->flags = PyInt_AS_LONG(ob); + stgdict->flags = PyLong_AS_LONG(ob); /* _argtypes_ is optional... */ ob = PyDict_GetItemString((PyObject *)stgdict, "_argtypes_"); @@ -2697,11 +2697,11 @@ _get_name(PyObject *obj, char **pname) { #ifdef MS_WIN32 - if (PyInt_Check(obj)) { + if (PyLong_Check(obj)) { /* We have to use MAKEINTRESOURCEA for Windows CE. Works on Windows as well, of course. */ - *pname = MAKEINTRESOURCEA(PyInt_AsUnsignedLongMask(obj) & 0xFFFF); + *pname = MAKEINTRESOURCEA(PyLong_AsUnsignedLongMask(obj) & 0xFFFF); return 1; } #endif @@ -2738,7 +2738,7 @@ obj = PyObject_GetAttrString(dll, "_handle"); if (!obj) return NULL; - if (!PyInt_Check(obj)) { + if (!PyLong_Check(obj)) { PyErr_SetString(PyExc_TypeError, "the _handle attribute of the second argument must be an integer"); Py_DECREF(obj); @@ -2858,12 +2858,12 @@ return CFuncPtr_FromDll(type, args, kwds); #ifdef MS_WIN32 - if (2 <= PyTuple_GET_SIZE(args) && PyInt_Check(PyTuple_GET_ITEM(args, 0))) + if (2 <= PyTuple_GET_SIZE(args) && PyLong_Check(PyTuple_GET_ITEM(args, 0))) return CFuncPtr_FromVtblIndex(type, args, kwds); #endif if (1 == PyTuple_GET_SIZE(args) - && (PyInt_Check(PyTuple_GET_ITEM(args, 0)))) { + && (PyLong_Check(PyTuple_GET_ITEM(args, 0)))) { CDataObject *ob; void *ptr = PyLong_AsVoidPtr(PyTuple_GET_ITEM(args, 0)); if (ptr == NULL) @@ -3068,7 +3068,7 @@ calls below. */ /* We HAVE already checked that the tuple can be parsed with "i|ZO", so... */ Py_ssize_t tsize = PyTuple_GET_SIZE(item); - flag = PyInt_AS_LONG(PyTuple_GET_ITEM(item, 0)); + flag = PyLong_AS_LONG(PyTuple_GET_ITEM(item, 0)); name = tsize > 1 ? PyTuple_GET_ITEM(item, 1) : NULL; defval = tsize > 2 ? PyTuple_GET_ITEM(item, 2) : NULL; @@ -3077,7 +3077,7 @@ /* ['in', 'lcid'] parameter. Always taken from defval, if given, else the integer 0. */ if (defval == NULL) { - defval = PyInt_FromLong(0); + defval = PyLong_FromLong(0); if (defval == NULL) goto error; } else @@ -4864,11 +4864,11 @@ return; PyModule_AddObject(m, "COMError", ComError); - PyModule_AddObject(m, "FUNCFLAG_HRESULT", PyInt_FromLong(FUNCFLAG_HRESULT)); - PyModule_AddObject(m, "FUNCFLAG_STDCALL", PyInt_FromLong(FUNCFLAG_STDCALL)); + PyModule_AddObject(m, "FUNCFLAG_HRESULT", PyLong_FromLong(FUNCFLAG_HRESULT)); + PyModule_AddObject(m, "FUNCFLAG_STDCALL", PyLong_FromLong(FUNCFLAG_STDCALL)); #endif - PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL)); - PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI)); + PyModule_AddObject(m, "FUNCFLAG_CDECL", PyLong_FromLong(FUNCFLAG_CDECL)); + PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyLong_FromLong(FUNCFLAG_PYTHONAPI)); PyModule_AddStringConstant(m, "__version__", "1.1.0"); PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove)); @@ -4891,8 +4891,8 @@ #define RTLD_GLOBAL RTLD_LOCAL #endif - PyModule_AddObject(m, "RTLD_LOCAL", PyInt_FromLong(RTLD_LOCAL)); - PyModule_AddObject(m, "RTLD_GLOBAL", PyInt_FromLong(RTLD_GLOBAL)); + PyModule_AddObject(m, "RTLD_LOCAL", PyLong_FromLong(RTLD_LOCAL)); + PyModule_AddObject(m, "RTLD_GLOBAL", PyLong_FromLong(RTLD_GLOBAL)); PyExc_ArgError = PyErr_NewException("ctypes.ArgumentError", NULL, NULL); if (PyExc_ArgError) { Modified: python/branches/py3k/Modules/_ctypes/callbacks.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/callbacks.c (original) +++ python/branches/py3k/Modules/_ctypes/callbacks.c Sun Dec 2 15:31:20 2007 @@ -408,7 +408,7 @@ return E_FAIL; } - retval = PyInt_AsLong(result); + retval = PyLong_AsLong(result); if (PyErr_Occurred()) { PyErr_WriteUnraisable(context ? context : Py_None); retval = E_FAIL; @@ -469,7 +469,7 @@ return E_FAIL; } - retval = PyInt_AsLong(result); + retval = PyLong_AsLong(result); if (PyErr_Occurred()) { PyErr_WriteUnraisable(context ? context : Py_None); retval = E_FAIL; Modified: python/branches/py3k/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/callproc.c (original) +++ python/branches/py3k/Modules/_ctypes/callproc.c Sun Dec 2 15:31:20 2007 @@ -269,7 +269,7 @@ return NULL; if (FAILED(hr)) return PyErr_SetFromWindowsErr(hr); - return PyInt_FromLong(hr); + return PyLong_FromLong(hr); } #endif @@ -727,7 +727,7 @@ PyObject *retval, *v; if (restype == NULL) - return PyInt_FromLong(*(int *)result); + return PyLong_FromLong(*(int *)result); if (restype == Py_None) { Py_INCREF(Py_None); @@ -1020,12 +1020,12 @@ if (*(int *)resbuf & 0x80000000) retval = GetComError(*(HRESULT *)resbuf, iid, pIunk); else - retval = PyInt_FromLong(*(int *)resbuf); + retval = PyLong_FromLong(*(int *)resbuf); } else if (flags & FUNCFLAG_HRESULT) { if (*(int *)resbuf & 0x80000000) retval = PyErr_SetFromWindowsErr(*(int *)resbuf); else - retval = PyInt_FromLong(*(int *)resbuf); + retval = PyLong_FromLong(*(int *)resbuf); } else #endif retval = GetResult(restype, resbuf, checker); @@ -1198,12 +1198,12 @@ pdst = (IUnknown **)b.value.p; if (pdst == NULL) - r = PyInt_FromLong(E_POINTER); + r = PyLong_FromLong(E_POINTER); else { if (src) src->lpVtbl->AddRef(src); *pdst = src; - r = PyInt_FromLong(S_OK); + r = PyLong_FromLong(S_OK); } done: Py_XDECREF(a.keep); @@ -1345,10 +1345,10 @@ dict = PyType_stgdict(obj); if (dict) - return PyInt_FromSsize_t(dict->size); + return PyLong_FromSsize_t(dict->size); if (CDataObject_Check(obj)) - return PyInt_FromSsize_t(((CDataObject *)obj)->b_size); + return PyLong_FromSsize_t(((CDataObject *)obj)->b_size); PyErr_SetString(PyExc_TypeError, "this type has no size"); return NULL; @@ -1366,11 +1366,11 @@ dict = PyType_stgdict(obj); if (dict) - return PyInt_FromSsize_t(dict->align); + return PyLong_FromSsize_t(dict->align); dict = PyObject_stgdict(obj); if (dict) - return PyInt_FromSsize_t(dict->align); + return PyLong_FromSsize_t(dict->align); PyErr_SetString(PyExc_TypeError, "no alignment info"); Modified: python/branches/py3k/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/cfield.c (original) +++ python/branches/py3k/Modules/_ctypes/cfield.c Sun Dec 2 15:31:20 2007 @@ -216,13 +216,13 @@ static PyObject * CField_get_offset(PyObject *self, void *data) { - return PyInt_FromSsize_t(((CFieldObject *)self)->offset); + return PyLong_FromSsize_t(((CFieldObject *)self)->offset); } static PyObject * CField_get_size(PyObject *self, void *data) { - return PyInt_FromSsize_t(((CFieldObject *)self)->size); + return PyLong_FromSsize_t(((CFieldObject *)self)->size); } static PyGetSetDef CField_getset[] = { @@ -329,13 +329,13 @@ get_long(PyObject *v, long *p) { long x; - if (!PyInt_Check(v)) { + if (!PyLong_Check(v)) { PyErr_Format(PyExc_TypeError, "int expected instead of %s instance", v->ob_type->tp_name); return -1; } - x = PyInt_AsUnsignedLongMask(v); + x = PyLong_AsUnsignedLongMask(v); if (x == -1 && PyErr_Occurred()) return -1; *p = x; @@ -348,13 +348,13 @@ get_ulong(PyObject *v, unsigned long *p) { unsigned long x; - if (!PyInt_Check(v)) { + if (!PyLong_Check(v)) { PyErr_Format(PyExc_TypeError, "int expected instead of %s instance", v->ob_type->tp_name); return -1; } - x = PyInt_AsUnsignedLongMask(v); + x = PyLong_AsUnsignedLongMask(v); if (x == -1 && PyErr_Occurred()) return -1; *p = x; @@ -369,13 +369,13 @@ get_longlong(PyObject *v, PY_LONG_LONG *p) { PY_LONG_LONG x; - if (!PyInt_Check(v)) { + if (!PyLong_Check(v)) { PyErr_Format(PyExc_TypeError, "int expected instead of %s instance", v->ob_type->tp_name); return -1; } - x = PyInt_AsUnsignedLongLongMask(v); + x = PyLong_AsUnsignedLongLongMask(v); if (x == -1 && PyErr_Occurred()) return -1; *p = x; @@ -388,13 +388,13 @@ get_ulonglong(PyObject *v, unsigned PY_LONG_LONG *p) { unsigned PY_LONG_LONG x; - if (!PyInt_Check(v)) { + if (!PyLong_Check(v)) { PyErr_Format(PyExc_TypeError, "int expected instead of %s instance", v->ob_type->tp_name); return -1; } - x = PyInt_AsUnsignedLongLongMask(v); + x = PyLong_AsUnsignedLongLongMask(v); if (x == -1 && PyErr_Occurred()) return -1; *p = x; @@ -513,7 +513,7 @@ { signed char val = *(signed char *)ptr; GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -533,7 +533,7 @@ { unsigned char val = *(unsigned char *)ptr; GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -571,7 +571,7 @@ short val; memcpy(&val, ptr, sizeof(val)); GET_BITFIELD(val, size); - return PyInt_FromLong((long)val); + return PyLong_FromLong((long)val); } static PyObject * @@ -581,7 +581,7 @@ memcpy(&val, ptr, sizeof(val)); val = SWAP_2(val); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -619,7 +619,7 @@ unsigned short val; memcpy(&val, ptr, sizeof(val)); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -629,7 +629,7 @@ memcpy(&val, ptr, sizeof(val)); val = SWAP_2(val); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -667,7 +667,7 @@ int val; memcpy(&val, ptr, sizeof(val)); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -677,7 +677,7 @@ memcpy(&val, ptr, sizeof(val)); val = SWAP_INT(val); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } #ifdef MS_WIN32 @@ -815,7 +815,7 @@ long val; memcpy(&val, ptr, sizeof(val)); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -825,7 +825,7 @@ memcpy(&val, ptr, sizeof(val)); val = SWAP_LONG(val); GET_BITFIELD(val, size); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -1173,9 +1173,9 @@ *(char *)ptr = PyBytes_AS_STRING(value)[0]; _RET(value); } - if (PyInt_Check(value)) + if (PyLong_Check(value)) { - long longval = PyInt_AS_LONG(value); + long longval = PyLong_AS_LONG(value); if (longval < 0 || longval >= 256) goto error; *(char *)ptr = (char)longval; @@ -1384,11 +1384,11 @@ return NULL; *(char **)ptr = PyString_AS_STRING(str); return str; - } else if (PyInt_Check(value)) { + } else if (PyLong_Check(value)) { #if SIZEOF_VOID_P == SIZEOF_LONG_LONG - *(char **)ptr = (char *)PyInt_AsUnsignedLongLongMask(value); + *(char **)ptr = (char *)PyLong_AsUnsignedLongLongMask(value); #else - *(char **)ptr = (char *)PyInt_AsUnsignedLongMask(value); + *(char **)ptr = (char *)PyLong_AsUnsignedLongMask(value); #endif _RET(value); } @@ -1427,11 +1427,11 @@ Py_INCREF(value); return value; } - if (PyInt_Check(value) || PyLong_Check(value)) { + if (PyLong_Check(value) || PyLong_Check(value)) { #if SIZEOF_VOID_P == SIZEOF_LONG_LONG - *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongLongMask(value); + *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongLongMask(value); #else - *(wchar_t **)ptr = (wchar_t *)PyInt_AsUnsignedLongMask(value); + *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value); #endif Py_INCREF(Py_None); return Py_None; @@ -1585,21 +1585,21 @@ _RET(value); } - if (!PyInt_Check(value) && !PyLong_Check(value)) { + if (!PyLong_Check(value) && !PyLong_Check(value)) { PyErr_SetString(PyExc_TypeError, "cannot be converted to pointer"); return NULL; } #if SIZEOF_VOID_P <= SIZEOF_LONG - v = (void *)PyInt_AsUnsignedLongMask(value); + v = (void *)PyLong_AsUnsignedLongMask(value); #else #ifndef HAVE_LONG_LONG # error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long" #elif SIZEOF_LONG_LONG < SIZEOF_VOID_P # error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)" #endif - v = (void *)PyInt_AsUnsignedLongLongMask(value); + v = (void *)PyLong_AsUnsignedLongLongMask(value); #endif if (PyErr_Occurred()) Modified: python/branches/py3k/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/stgdict.c (original) +++ python/branches/py3k/Modules/_ctypes/stgdict.c Sun Dec 2 15:31:20 2007 @@ -311,7 +311,7 @@ isPacked = PyObject_GetAttrString(type, "_pack_"); if (isPacked) { - pack = PyInt_AsLong(isPacked); + pack = PyLong_AsLong(isPacked); if (pack < 0 || PyErr_Occurred()) { Py_XDECREF(isPacked); PyErr_SetString(PyExc_ValueError, Modified: python/branches/py3k/Modules/_cursesmodule.c ============================================================================== --- python/branches/py3k/Modules/_cursesmodule.c (original) +++ python/branches/py3k/Modules/_cursesmodule.c Sun Dec 2 15:31:20 2007 @@ -197,7 +197,7 @@ PyCurses_ConvertToChtype(PyObject *obj, chtype *ch) { if (PyInt_CheckExact(obj)) { - *ch = (chtype) PyInt_AsLong(obj); + *ch = (chtype) PyLong_AsLong(obj); } else if(PyString_Check(obj) && (PyString_Size(obj) == 1)) { *ch = (chtype) *PyString_AsString(obj); @@ -777,14 +777,14 @@ if (!PyArg_ParseTuple(args,"ii;y,x", &y, &x)) return NULL; - return PyInt_FromLong( wenclose(self->win,y,x) ); + return PyLong_FromLong( wenclose(self->win,y,x) ); } #endif static PyObject * PyCursesWindow_GetBkgd(PyCursesWindowObject *self) { - return PyInt_FromLong((long) getbkgd(self->win)); + return PyLong_FromLong((long) getbkgd(self->win)); } static PyObject * @@ -810,7 +810,7 @@ PyErr_SetString(PyExc_TypeError, "getch requires 0 or 2 arguments"); return NULL; } - return PyInt_FromLong((long)rtn); + return PyLong_FromLong((long)rtn); } static PyObject * @@ -1012,7 +1012,7 @@ PyErr_SetString(PyExc_TypeError, "inch requires 0 or 2 arguments"); return NULL; } - return PyInt_FromLong((long) rtn); + return PyLong_FromLong((long) rtn); } static PyObject * @@ -1679,7 +1679,7 @@ PyCursesInitialisedColor if (!PyArg_ParseTuple(args, "i:color_pair", &n)) return NULL; - return PyInt_FromLong((long) (n << 8)); + return PyLong_FromLong((long) (n << 8)); } static PyObject * @@ -1694,7 +1694,7 @@ erg = curs_set(vis); if (erg == ERR) return PyCursesCheckERR(erg, "curs_set"); - return PyInt_FromLong((long) erg); + return PyLong_FromLong((long) erg); } static PyObject * @@ -1912,7 +1912,7 @@ where they're not defined until you've called initscr() */ #define SetDictInt(string,ch) \ do { \ - PyObject *o = PyInt_FromLong((long) (ch)); \ + PyObject *o = PyLong_FromLong((long) (ch)); \ if (o && PyDict_SetItemString(ModDict, string, o) == 0) { \ Py_DECREF(o); \ } \ @@ -2269,7 +2269,7 @@ return NULL; } - return PyInt_FromLong((long) ((n & A_COLOR) >> 8)); + return PyLong_FromLong((long) ((n & A_COLOR) >> 8)); } static PyObject * @@ -2316,7 +2316,7 @@ if (!m) return 0; - o = PyInt_FromLong(LINES); + o = PyLong_FromLong(LINES); if (!o) { Py_DECREF(m); return 0; @@ -2332,7 +2332,7 @@ return 0; } Py_DECREF(o); - o = PyInt_FromLong(COLS); + o = PyLong_FromLong(COLS); if (!o) { Py_DECREF(m); return 0; @@ -2429,10 +2429,10 @@ code = start_color(); if (code != ERR) { initialisedcolors = TRUE; - c = PyInt_FromLong((long) COLORS); + c = PyLong_FromLong((long) COLORS); PyDict_SetItemString(ModDict, "COLORS", c); Py_DECREF(c); - cp = PyInt_FromLong((long) COLOR_PAIRS); + cp = PyLong_FromLong((long) COLOR_PAIRS); PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp); Py_DECREF(cp); Py_INCREF(Py_None); @@ -2453,7 +2453,7 @@ if (!PyArg_ParseTuple(args, "z", &capname)) return NULL; - return PyInt_FromLong( (long) tigetflag( capname ) ); + return PyLong_FromLong( (long) tigetflag( capname ) ); } static PyObject * @@ -2466,7 +2466,7 @@ if (!PyArg_ParseTuple(args, "z", &capname)) return NULL; - return PyInt_FromLong( (long) tigetnum( capname ) ); + return PyLong_FromLong( (long) tigetnum( capname ) ); } static PyObject * Modified: python/branches/py3k/Modules/_elementtree.c ============================================================================== --- python/branches/py3k/Modules/_elementtree.c (original) +++ python/branches/py3k/Modules/_elementtree.c Sun Dec 2 15:31:20 2007 @@ -677,7 +677,7 @@ } /* add object to memo dictionary (so deepcopy won't visit it again) */ - id = PyInt_FromLong((Py_uintptr_t) self); + id = PyLong_FromLong((Py_uintptr_t) self); i = PyDict_SetItem(memo, id, (PyObject*) element); Modified: python/branches/py3k/Modules/_fileio.c ============================================================================== --- python/branches/py3k/Modules/_fileio.c (original) +++ python/branches/py3k/Modules/_fileio.c Sun Dec 2 15:31:20 2007 @@ -326,7 +326,7 @@ { if (self->fd < 0) return err_closed(); - return PyInt_FromLong((long) self->fd); + return PyLong_FromLong((long) self->fd); } static PyObject * @@ -388,7 +388,7 @@ return NULL; } - return PyInt_FromSsize_t(n); + return PyLong_FromSsize_t(n); } #define DEFAULT_BUFFER_SIZE (8*1024) @@ -521,7 +521,7 @@ return NULL; } - return PyInt_FromSsize_t(n); + return PyLong_FromSsize_t(n); } /* XXX Windows support below is likely incomplete */ @@ -561,10 +561,10 @@ return NULL; } #if !defined(HAVE_LARGEFILE_SUPPORT) - pos = PyInt_AsLong(posobj); + pos = PyLong_AsLong(posobj); #else pos = PyLong_Check(posobj) ? - PyLong_AsLongLong(posobj) : PyInt_AsLong(posobj); + PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj); #endif if (PyErr_Occurred()) return NULL; @@ -581,7 +581,7 @@ return PyErr_SetFromErrno(PyExc_IOError); #if !defined(HAVE_LARGEFILE_SUPPORT) - return PyInt_FromLong(res); + return PyLong_FromLong(res); #else return PyLong_FromLongLong(res); #endif @@ -639,10 +639,10 @@ } #if !defined(HAVE_LARGEFILE_SUPPORT) - pos = PyInt_AsLong(posobj); + pos = PyLong_AsLong(posobj); #else pos = PyLong_Check(posobj) ? - PyLong_AsLongLong(posobj) : PyInt_AsLong(posobj); + PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj); #endif if (PyErr_Occurred()) { Py_DECREF(posobj); Modified: python/branches/py3k/Modules/_hashopenssl.c ============================================================================== --- python/branches/py3k/Modules/_hashopenssl.c (original) +++ python/branches/py3k/Modules/_hashopenssl.c Sun Dec 2 15:31:20 2007 @@ -203,13 +203,13 @@ static PyObject * EVP_get_block_size(EVPobject *self, void *closure) { - return PyInt_FromLong(EVP_MD_CTX_block_size(&((EVPobject *)self)->ctx)); + return PyLong_FromLong(EVP_MD_CTX_block_size(&((EVPobject *)self)->ctx)); } static PyObject * EVP_get_digest_size(EVPobject *self, void *closure) { - return PyInt_FromLong(EVP_MD_CTX_size(&((EVPobject *)self)->ctx)); + return PyLong_FromLong(EVP_MD_CTX_size(&((EVPobject *)self)->ctx)); } static PyMemberDef EVP_members[] = { Modified: python/branches/py3k/Modules/_localemodule.c ============================================================================== --- python/branches/py3k/Modules/_localemodule.c (original) +++ python/branches/py3k/Modules/_localemodule.c Sun Dec 2 15:31:20 2007 @@ -71,7 +71,7 @@ i = -1; do { i++; - val = PyInt_FromLong(s[i]); + val = PyLong_FromLong(s[i]); if (!val) break; if (PyList_SetItem(result, i, val)) { @@ -149,7 +149,7 @@ Py_XDECREF(x) #define RESULT_INT(i)\ - x = PyInt_FromLong(l->i);\ + x = PyLong_FromLong(l->i);\ if (!x) goto failed;\ PyDict_SetItemString(result, #i, x);\ Py_XDECREF(x) @@ -202,7 +202,7 @@ if (!PyArg_ParseTuple(args, "ss:strcoll", &s1, &s2)) return NULL; - return PyInt_FromLong(strcoll(s1, s2)); + return PyLong_FromLong(strcoll(s1, s2)); #else PyObject *os1, *os2, *result = NULL; wchar_t *ws1 = NULL, *ws2 = NULL; @@ -234,7 +234,7 @@ goto done; ws2[len2 - 1] = 0; /* Collate the strings. */ - result = PyInt_FromLong(wcscoll(ws1, ws2)); + result = PyLong_FromLong(wcscoll(ws1, ws2)); done: /* Deallocate everything. */ if (ws1) PyMem_FREE(ws1); @@ -628,37 +628,37 @@ d = PyModule_GetDict(m); - x = PyInt_FromLong(LC_CTYPE); + x = PyLong_FromLong(LC_CTYPE); PyDict_SetItemString(d, "LC_CTYPE", x); Py_XDECREF(x); - x = PyInt_FromLong(LC_TIME); + x = PyLong_FromLong(LC_TIME); PyDict_SetItemString(d, "LC_TIME", x); Py_XDECREF(x); - x = PyInt_FromLong(LC_COLLATE); + x = PyLong_FromLong(LC_COLLATE); PyDict_SetItemString(d, "LC_COLLATE", x); Py_XDECREF(x); - x = PyInt_FromLong(LC_MONETARY); + x = PyLong_FromLong(LC_MONETARY); PyDict_SetItemString(d, "LC_MONETARY", x); Py_XDECREF(x); #ifdef LC_MESSAGES - x = PyInt_FromLong(LC_MESSAGES); + x = PyLong_FromLong(LC_MESSAGES); PyDict_SetItemString(d, "LC_MESSAGES", x); Py_XDECREF(x); #endif /* LC_MESSAGES */ - x = PyInt_FromLong(LC_NUMERIC); + x = PyLong_FromLong(LC_NUMERIC); PyDict_SetItemString(d, "LC_NUMERIC", x); Py_XDECREF(x); - x = PyInt_FromLong(LC_ALL); + x = PyLong_FromLong(LC_ALL); PyDict_SetItemString(d, "LC_ALL", x); Py_XDECREF(x); - x = PyInt_FromLong(CHAR_MAX); + x = PyLong_FromLong(CHAR_MAX); PyDict_SetItemString(d, "CHAR_MAX", x); Py_XDECREF(x); Modified: python/branches/py3k/Modules/_randommodule.c ============================================================================== --- python/branches/py3k/Modules/_randommodule.c (original) +++ python/branches/py3k/Modules/_randommodule.c Sun Dec 2 15:31:20 2007 @@ -259,7 +259,7 @@ masklower = PyLong_FromUnsignedLong(0xffffffffU); if (masklower == NULL) goto Done; - thirtytwo = PyInt_FromLong(32L); + thirtytwo = PyLong_FromLong(32L); if (thirtytwo == NULL) goto Done; while ((err=PyObject_IsTrue(n))) { @@ -319,12 +319,12 @@ if (state == NULL) return NULL; for (i=0; istate[i])); + element = PyLong_FromLong((long)(self->state[i])); if (element == NULL) goto Fail; PyTuple_SET_ITEM(state, i, element); } - element = PyInt_FromLong((long)(self->index)); + element = PyLong_FromLong((long)(self->index)); if (element == NULL) goto Fail; PyTuple_SET_ITEM(state, i, element); @@ -353,13 +353,13 @@ } for (i=0; istate[i] = (unsigned long)element; } - element = PyInt_AsLong(PyTuple_GET_ITEM(state, i)); + element = PyLong_AsLong(PyTuple_GET_ITEM(state, i)); if (element == -1 && PyErr_Occurred()) return NULL; self->index = (int)element; @@ -410,14 +410,14 @@ mt = self->state; for (i = N-1; i > 1; i--) { - iobj = PyInt_FromLong(i); + iobj = PyLong_FromLong(i); if (iobj == NULL) return NULL; remobj = PyNumber_Remainder(n, iobj); Py_DECREF(iobj); if (remobj == NULL) return NULL; - j = PyInt_AsLong(remobj); + j = PyLong_AsLong(remobj); Py_DECREF(remobj); if (j == -1L && PyErr_Occurred()) return NULL; Modified: python/branches/py3k/Modules/_sqlite/connection.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/connection.c (original) +++ python/branches/py3k/Modules/_sqlite/connection.c Sun Dec 2 15:31:20 2007 @@ -420,8 +420,8 @@ sqlite3_result_null(context); } else if (py_val == Py_None) { sqlite3_result_null(context); - } else if (PyInt_Check(py_val)) { - longval = PyInt_AsLong(py_val); + } else if (PyLong_Check(py_val)) { + longval = PyLong_AsLong(py_val); sqlite3_result_int64(context, (PY_LONG_LONG)longval); } else if (PyFloat_Check(py_val)) { sqlite3_result_double(context, PyFloat_AsDouble(py_val)); @@ -458,7 +458,7 @@ switch (sqlite3_value_type(argv[i])) { case SQLITE_INTEGER: val_int = sqlite3_value_int64(cur_value); - cur_py_value = PyInt_FromLong((long)val_int); + cur_py_value = PyLong_FromLong((long)val_int); break; case SQLITE_FLOAT: cur_py_value = PyFloat_FromDouble(sqlite3_value_double(cur_value)); @@ -734,8 +734,8 @@ rc = SQLITE_DENY; } else { - if (PyInt_Check(ret)) { - rc = (int)PyInt_AsLong(ret); + if (PyLong_Check(ret)) { + rc = (int)PyLong_AsLong(ret); } else { rc = SQLITE_DENY; } @@ -1036,7 +1036,7 @@ goto finally; } - result = PyInt_AsLong(retval); + result = PyLong_AsLong(retval); if (PyErr_Occurred()) { result = 0; } Modified: python/branches/py3k/Modules/_sqlite/cursor.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/cursor.c (original) +++ python/branches/py3k/Modules/_sqlite/cursor.c Sun Dec 2 15:31:20 2007 @@ -26,7 +26,7 @@ #include "util.h" #include "sqlitecompat.h" -/* used to decide wether to call PyInt_FromLong or PyLong_FromLongLong */ +/* used to decide wether to call PyLong_FromLong or PyLong_FromLongLong */ #ifndef INT32_MIN #define INT32_MIN (-2147483647 - 1) #endif @@ -101,7 +101,7 @@ self->arraysize = 1; - self->rowcount = PyInt_FromLong(-1L); + self->rowcount = PyLong_FromLong(-1L); if (!self->rowcount) { return -1; } @@ -344,7 +344,7 @@ if (intval < INT32_MIN || intval > INT32_MAX) { converted = PyLong_FromLongLong(intval); } else { - converted = PyInt_FromLong((long)intval); + converted = PyLong_FromLong((long)intval); } } else if (coltype == SQLITE_FLOAT) { converted = PyFloat_FromDouble(sqlite3_column_double(self->statement->st, i)); @@ -499,7 +499,7 @@ self->description = Py_None; Py_DECREF(self->rowcount); - self->rowcount = PyInt_FromLong(-1L); + self->rowcount = PyLong_FromLong(-1L); if (!self->rowcount) { goto error; } @@ -680,7 +680,7 @@ rowcount += (long)sqlite3_changes(self->connection->db); Py_END_ALLOW_THREADS Py_DECREF(self->rowcount); - self->rowcount = PyInt_FromLong(rowcount); + self->rowcount = PyLong_FromLong(rowcount); } Py_DECREF(self->lastrowid); @@ -688,7 +688,7 @@ Py_BEGIN_ALLOW_THREADS lastrowid = sqlite3_last_insert_rowid(self->connection->db); Py_END_ALLOW_THREADS - self->lastrowid = PyInt_FromLong((long)lastrowid); + self->lastrowid = PyLong_FromLong((long)lastrowid); } else { Py_INCREF(Py_None); self->lastrowid = Py_None; Modified: python/branches/py3k/Modules/_sqlite/module.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/module.c (original) +++ python/branches/py3k/Modules/_sqlite/module.c Sun Dec 2 15:31:20 2007 @@ -351,7 +351,7 @@ /* Set integer constants */ for (i = 0; _int_constants[i].constant_name != 0; i++) { - tmp_obj = PyInt_FromLong(_int_constants[i].constant_value); + tmp_obj = PyLong_FromLong(_int_constants[i].constant_value); if (!tmp_obj) { goto error; } Modified: python/branches/py3k/Modules/_sre.c ============================================================================== --- python/branches/py3k/Modules/_sre.c (original) +++ python/branches/py3k/Modules/_sre.c Sun Dec 2 15:31:20 2007 @@ -2756,8 +2756,8 @@ /* Default value */ return 0; - if (PyInt_Check(index)) - return PyInt_AsSsize_t(index); + if (PyLong_Check(index)) + return PyLong_AsSsize_t(index); i = -1; @@ -2765,7 +2765,7 @@ index = PyObject_GetItem(self->pattern->groupindex, index); if (index) { if (PyLong_Check(index)) - i = PyInt_AsSsize_t(index); + i = PyLong_AsSsize_t(index); Py_DECREF(index); } else PyErr_Clear(); @@ -2957,12 +2957,12 @@ if (!pair) return NULL; - item = PyInt_FromSsize_t(i1); + item = PyLong_FromSsize_t(i1); if (!item) goto error; PyTuple_SET_ITEM(pair, 0, item); - item = PyInt_FromSsize_t(i2); + item = PyLong_FromSsize_t(i2); if (!item) goto error; PyTuple_SET_ITEM(pair, 1, item); @@ -3397,13 +3397,13 @@ return; d = PyModule_GetDict(m); - x = PyInt_FromLong(SRE_MAGIC); + x = PyLong_FromLong(SRE_MAGIC); if (x) { PyDict_SetItemString(d, "MAGIC", x); Py_DECREF(x); } - x = PyInt_FromLong(sizeof(SRE_CODE)); + x = PyLong_FromLong(sizeof(SRE_CODE)); if (x) { PyDict_SetItemString(d, "CODESIZE", x); Py_DECREF(x); Modified: python/branches/py3k/Modules/_ssl.c ============================================================================== --- python/branches/py3k/Modules/_ssl.c (original) +++ python/branches/py3k/Modules/_ssl.c Sun Dec 2 15:31:20 2007 @@ -818,7 +818,7 @@ } Py_DECREF(issuer); - version = PyInt_FromLong(X509_get_version(certificate) + 1); + version = PyLong_FromLong(X509_get_version(certificate) + 1); if (PyDict_SetItemString(retval, "version", version) < 0) { Py_DECREF(version); goto fail0; @@ -1039,7 +1039,7 @@ goto fail0; PyTuple_SET_ITEM(retval, 1, v); } - v = PyInt_FromLong(SSL_CIPHER_get_bits(current, NULL)); + v = PyLong_FromLong(SSL_CIPHER_get_bits(current, NULL)); if (v == NULL) goto fail0; PyTuple_SET_ITEM(retval, 2, v); @@ -1194,7 +1194,7 @@ } } while (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE); if (len > 0) - return PyInt_FromLong(len); + return PyLong_FromLong(len); else return PySSL_SetError(self, len, __FILE__, __LINE__); } @@ -1215,7 +1215,7 @@ if (count < 0) return PySSL_SetError(self, count, __FILE__, __LINE__); else - return PyInt_FromLong(count); + return PyLong_FromLong(count); } PyDoc_STRVAR(PySSL_SSLpending_doc, @@ -1240,8 +1240,8 @@ if ((buf == NULL) || (buf == Py_None)) { if (!(buf = PyBytes_FromStringAndSize((char *) 0, len))) return NULL; - } else if (PyInt_Check(buf)) { - len = PyInt_AS_LONG(buf); + } else if (PyLong_Check(buf)) { + len = PyLong_AS_LONG(buf); if (!(buf = PyBytes_FromStringAndSize((char *) 0, len))) return NULL; } else { @@ -1336,7 +1336,7 @@ Py_DECREF(buf); return res; } else { - return PyInt_FromLong(count); + return PyLong_FromLong(count); } } @@ -1408,7 +1408,7 @@ static PyObject * PySSL_RAND_status(PyObject *self) { - return PyInt_FromLong(RAND_status()); + return PyLong_FromLong(RAND_status()); } PyDoc_STRVAR(PySSL_RAND_status_doc, @@ -1434,7 +1434,7 @@ "enough data to seed the PRNG"); return NULL; } - return PyInt_FromLong(bytes); + return PyLong_FromLong(bytes); } PyDoc_STRVAR(PySSL_RAND_egd_doc, Modified: python/branches/py3k/Modules/_struct.c ============================================================================== --- python/branches/py3k/Modules/_struct.c (original) +++ python/branches/py3k/Modules/_struct.c Sun Dec 2 15:31:20 2007 @@ -146,7 +146,7 @@ static int get_long(PyObject *v, long *p) { - long x = PyInt_AsLong(v); + long x = PyLong_AsLong(v); if (x == -1 && PyErr_Occurred()) { #ifdef PY_STRUCT_FLOAT_COERCE if (PyFloat_Check(v)) { @@ -445,13 +445,13 @@ static PyObject * nu_byte(const char *p, const formatdef *f) { - return PyInt_FromLong((long) *(signed char *)p); + return PyLong_FromLong((long) *(signed char *)p); } static PyObject * nu_ubyte(const char *p, const formatdef *f) { - return PyInt_FromLong((long) *(unsigned char *)p); + return PyLong_FromLong((long) *(unsigned char *)p); } static PyObject * @@ -459,7 +459,7 @@ { short x; memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); } static PyObject * @@ -467,7 +467,7 @@ { unsigned short x; memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); } static PyObject * @@ -475,7 +475,7 @@ { int x; memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); } static PyObject * @@ -484,10 +484,10 @@ unsigned int x; memcpy((char *)&x, p, sizeof x); #if (SIZEOF_LONG > SIZEOF_INT) - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); #else if (x <= ((unsigned int)LONG_MAX)) - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); return PyLong_FromUnsignedLong((unsigned long)x); #endif } @@ -497,7 +497,7 @@ { long x; memcpy((char *)&x, p, sizeof x); - return PyInt_FromLong(x); + return PyLong_FromLong(x); } static PyObject * @@ -506,7 +506,7 @@ unsigned long x; memcpy((char *)&x, p, sizeof x); if (x <= LONG_MAX) - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); return PyLong_FromUnsignedLong(x); } @@ -521,7 +521,7 @@ PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); if (x >= LONG_MIN && x <= LONG_MAX) - return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); return PyLong_FromLongLong(x); } @@ -531,7 +531,7 @@ unsigned PY_LONG_LONG x; memcpy((char *)&x, p, sizeof x); if (x <= LONG_MAX) - return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); return PyLong_FromUnsignedLongLong(x); } @@ -818,7 +818,7 @@ /* Extend the sign bit. */ if (SIZEOF_LONG > f->size) x |= -(x & (1L << ((8 * f->size) - 1))); - return PyInt_FromLong(x); + return PyLong_FromLong(x); } static PyObject * @@ -831,7 +831,7 @@ x = (x<<8) | *bytes++; } while (--i > 0); if (x <= LONG_MAX) - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); return PyLong_FromUnsignedLong(x); } @@ -849,7 +849,7 @@ if (SIZEOF_LONG_LONG > f->size) x |= -(x & ((PY_LONG_LONG)1 << ((8 * f->size) - 1))); if (x >= LONG_MIN && x <= LONG_MAX) - return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); return PyLong_FromLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -870,7 +870,7 @@ x = (x<<8) | *bytes++; } while (--i > 0); if (x <= LONG_MAX) - return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); return PyLong_FromUnsignedLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -1054,7 +1054,7 @@ /* Extend the sign bit. */ if (SIZEOF_LONG > f->size) x |= -(x & (1L << ((8 * f->size) - 1))); - return PyInt_FromLong(x); + return PyLong_FromLong(x); } static PyObject * @@ -1067,7 +1067,7 @@ x = (x<<8) | bytes[--i]; } while (i > 0); if (x <= LONG_MAX) - return PyInt_FromLong((long)x); + return PyLong_FromLong((long)x); return PyLong_FromUnsignedLong((long)x); } @@ -1085,7 +1085,7 @@ if (SIZEOF_LONG_LONG > f->size) x |= -(x & ((PY_LONG_LONG)1 << ((8 * f->size) - 1))); if (x >= LONG_MIN && x <= LONG_MAX) - return PyInt_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, PY_LONG_LONG, long)); return PyLong_FromLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -1106,7 +1106,7 @@ x = (x<<8) | bytes[--i]; } while (i > 0); if (x <= LONG_MAX) - return PyInt_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); + return PyLong_FromLong(Py_SAFE_DOWNCAST(x, unsigned PY_LONG_LONG, long)); return PyLong_FromUnsignedLongLong(x); #else return _PyLong_FromByteArray((const unsigned char *)p, @@ -1762,7 +1762,7 @@ assert( buffer_len >= 0 ); /* Extract the offset from the first argument */ - offset = PyInt_AsSsize_t(PyTuple_GET_ITEM(args, 1)); + offset = PyLong_AsSsize_t(PyTuple_GET_ITEM(args, 1)); /* Support negative offsets. */ if (offset < 0) @@ -1794,7 +1794,7 @@ static PyObject * s_get_size(PyStructObject *self, void *unused) { - return PyInt_FromSsize_t(self->s_size); + return PyLong_FromSsize_t(self->s_size); } /* List of functions */ @@ -1876,7 +1876,7 @@ #ifdef PY_STRUCT_OVERFLOW_MASKING if (pyint_zero == NULL) { - pyint_zero = PyInt_FromLong(0); + pyint_zero = PyLong_FromLong(0); if (pyint_zero == NULL) return; } Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Sun Dec 2 15:31:20 2007 @@ -85,7 +85,7 @@ return (PyObject*)NULL; /* list = range(NLIST) */ for (i = 0; i < NLIST; ++i) { - PyObject* anint = PyInt_FromLong(i); + PyObject* anint = PyLong_FromLong(i); if (anint == (PyObject*)NULL) { Py_DECREF(list); return (PyObject*)NULL; @@ -101,7 +101,7 @@ /* Check that list == range(29, -1, -1) now */ for (i = 0; i < NLIST; ++i) { PyObject* anint = PyList_GET_ITEM(list, i); - if (PyInt_AS_LONG(anint) != NLIST-1-i) { + if (PyLong_AS_LONG(anint) != NLIST-1-i) { PyErr_SetString(TestError, "test_list_api: reverse screwed up"); Py_DECREF(list); @@ -127,7 +127,7 @@ return -1; for (i = 0; i < count; i++) { - v = PyInt_FromLong(i); + v = PyLong_FromLong(i); PyDict_SetItem(dict, v, v); Py_DECREF(v); } @@ -136,8 +136,8 @@ PyObject *o; iterations++; - i = PyInt_AS_LONG(v) + 1; - o = PyInt_FromLong(i); + i = PyLong_AS_LONG(v) + 1; + o = PyLong_FromLong(i); if (o == NULL) return -1; if (PyDict_SetItem(dict, k, o) < 0) { @@ -278,7 +278,7 @@ "L code returned wrong value for long 42"); Py_DECREF(num); - num = PyInt_FromLong(42); + num = PyLong_FromLong(42); if (num == NULL) return NULL; @@ -404,7 +404,7 @@ #endif /* This function not only tests the 'k' getargs code, but also the - PyInt_AsUnsignedLongMask() and PyInt_AsUnsignedLongMask() functions. */ + PyLong_AsUnsignedLongMask() and PyLong_AsUnsignedLongMask() functions. */ static PyObject * test_k_code(PyObject *self) { @@ -420,10 +420,10 @@ if (num == NULL) return NULL; - value = PyInt_AsUnsignedLongMask(num); + value = PyLong_AsUnsignedLongMask(num); if (value != ULONG_MAX) return raiseTestError("test_k_code", - "PyInt_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); + "PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); PyTuple_SET_ITEM(tuple, 0, num); @@ -439,10 +439,10 @@ if (num == NULL) return NULL; - value = PyInt_AsUnsignedLongMask(num); + value = PyLong_AsUnsignedLongMask(num); if (value != (unsigned long)-0x42) return raiseTestError("test_k_code", - "PyInt_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); + "PyLong_AsUnsignedLongMask() returned wrong value for long 0xFFF...FFF"); PyTuple_SET_ITEM(tuple, 0, num); @@ -642,7 +642,7 @@ if (exc_args == NULL) return NULL; for (i = 0; i < num_args; ++i) { - v = PyInt_FromLong(i); + v = PyLong_FromLong(i); if (v == NULL) { Py_DECREF(exc_args); return NULL; @@ -796,7 +796,7 @@ gettimeofday(&start, NULL); for(k=0; k < 20000; k++) for(i=0; i < 1000; i++) { - single = PyInt_FromLong(i); + single = PyLong_FromLong(i); Py_DECREF(single); } gettimeofday(&stop, NULL); @@ -807,7 +807,7 @@ gettimeofday(&start, NULL); for(k=0; k < 20000; k++) for(i=0; i < 1000; i++) { - single = PyInt_FromLong(i+1000000); + single = PyLong_FromLong(i+1000000); Py_DECREF(single); } gettimeofday(&stop, NULL); @@ -819,7 +819,7 @@ gettimeofday(&start, NULL); for(k=0; k < 20000; k++) { for(i=0; i < 1000; i++) { - multiple[i] = PyInt_FromLong(i+1000000); + multiple[i] = PyLong_FromLong(i+1000000); } for(i=0; i < 1000; i++) { Py_DECREF(multiple[i]); @@ -834,7 +834,7 @@ gettimeofday(&start, NULL); for(k=0; k < 20; k++) { for(i=0; i < 1000000; i++) { - multiple[i] = PyInt_FromLong(i+1000000); + multiple[i] = PyLong_FromLong(i+1000000); } for(i=0; i < 1000000; i++) { Py_DECREF(multiple[i]); @@ -848,7 +848,7 @@ gettimeofday(&start, NULL); for(k=0; k < 10; k++) { for(i=0; i < 1000000; i++) { - multiple[i] = PyInt_FromLong(i+1000); + multiple[i] = PyLong_FromLong(i+1000); } for(i=0; i < 1000000; i++) { Py_DECREF(multiple[i]); @@ -858,7 +858,7 @@ print_delta(5, &start, &stop); /* Test 6: Perform small int addition */ - op1 = PyInt_FromLong(1); + op1 = PyLong_FromLong(1); gettimeofday(&start, NULL); for(i=0; i < 10000000; i++) { result = PyNumber_Add(op1, op1); @@ -869,7 +869,7 @@ print_delta(6, &start, &stop); /* Test 7: Perform medium int addition */ - op1 = PyInt_FromLong(1000); + op1 = PyLong_FromLong(1000); gettimeofday(&start, NULL); for(i=0; i < 10000000; i++) { result = PyNumber_Add(op1, op1); @@ -1061,17 +1061,17 @@ Py_INCREF(&test_structmembersType); PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); - PyModule_AddObject(m, "CHAR_MAX", PyInt_FromLong(CHAR_MAX)); - PyModule_AddObject(m, "CHAR_MIN", PyInt_FromLong(CHAR_MIN)); - PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX)); - PyModule_AddObject(m, "SHRT_MAX", PyInt_FromLong(SHRT_MAX)); - PyModule_AddObject(m, "SHRT_MIN", PyInt_FromLong(SHRT_MIN)); - PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX)); + PyModule_AddObject(m, "CHAR_MAX", PyLong_FromLong(CHAR_MAX)); + PyModule_AddObject(m, "CHAR_MIN", PyLong_FromLong(CHAR_MIN)); + PyModule_AddObject(m, "UCHAR_MAX", PyLong_FromLong(UCHAR_MAX)); + PyModule_AddObject(m, "SHRT_MAX", PyLong_FromLong(SHRT_MAX)); + PyModule_AddObject(m, "SHRT_MIN", PyLong_FromLong(SHRT_MIN)); + PyModule_AddObject(m, "USHRT_MAX", PyLong_FromLong(USHRT_MAX)); PyModule_AddObject(m, "INT_MAX", PyLong_FromLong(INT_MAX)); PyModule_AddObject(m, "INT_MIN", PyLong_FromLong(INT_MIN)); PyModule_AddObject(m, "UINT_MAX", PyLong_FromUnsignedLong(UINT_MAX)); - PyModule_AddObject(m, "LONG_MAX", PyInt_FromLong(LONG_MAX)); - PyModule_AddObject(m, "LONG_MIN", PyInt_FromLong(LONG_MIN)); + PyModule_AddObject(m, "LONG_MAX", PyLong_FromLong(LONG_MAX)); + PyModule_AddObject(m, "LONG_MIN", PyLong_FromLong(LONG_MIN)); PyModule_AddObject(m, "ULONG_MAX", PyLong_FromUnsignedLong(ULONG_MAX)); PyModule_AddObject(m, "FLT_MAX", PyFloat_FromDouble(FLT_MAX)); PyModule_AddObject(m, "FLT_MIN", PyFloat_FromDouble(FLT_MIN)); @@ -1080,8 +1080,8 @@ PyModule_AddObject(m, "LLONG_MAX", PyLong_FromLongLong(PY_LLONG_MAX)); PyModule_AddObject(m, "LLONG_MIN", PyLong_FromLongLong(PY_LLONG_MIN)); PyModule_AddObject(m, "ULLONG_MAX", PyLong_FromUnsignedLongLong(PY_ULLONG_MAX)); - PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyInt_FromSsize_t(PY_SSIZE_T_MAX)); - PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyInt_FromSsize_t(PY_SSIZE_T_MIN)); + PyModule_AddObject(m, "PY_SSIZE_T_MAX", PyLong_FromSsize_t(PY_SSIZE_T_MAX)); + PyModule_AddObject(m, "PY_SSIZE_T_MIN", PyLong_FromSsize_t(PY_SSIZE_T_MIN)); TestError = PyErr_NewException("_testcapi.error", NULL, NULL); Py_INCREF(TestError); Modified: python/branches/py3k/Modules/_tkinter.c ============================================================================== --- python/branches/py3k/Modules/_tkinter.c (original) +++ python/branches/py3k/Modules/_tkinter.c Sun Dec 2 15:31:20 2007 @@ -44,7 +44,7 @@ #ifndef PyBool_Check #define PyBool_Check(o) 0 -#define PyBool_FromLong PyInt_FromLong +#define PyBool_FromLong PyLong_FromLong #endif /* Starting with Tcl 8.4, many APIs offer const-correctness. Unfortunately, @@ -870,7 +870,7 @@ else if (PyBool_Check(value)) return Tcl_NewBooleanObj(PyObject_IsTrue(value)); else if (PyInt_CheckExact(value)) - return Tcl_NewLongObj(PyInt_AS_LONG(value)); + return Tcl_NewLongObj(PyLong_AS_LONG(value)); else if (PyFloat_Check(value)) return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value)); else if (PyTuple_Check(value)) { @@ -960,7 +960,7 @@ } if (value->typePtr == app->IntType) { - return PyInt_FromLong(value->internalRep.longValue); + return PyLong_FromLong(value->internalRep.longValue); } if (value->typePtr == app->ListType) { @@ -1647,7 +1647,7 @@ if (PyTuple_Size(args) == 1) { PyObject* o = PyTuple_GetItem(args, 0); - if (PyInt_Check(o)) { + if (PyLong_Check(o)) { Py_INCREF(o); return o; } @@ -1687,7 +1687,7 @@ if (PyTuple_Size(args) == 1) { PyObject *o = PyTuple_GetItem(args, 0); - if (PyInt_Check(o)) { + if (PyLong_Check(o)) { Py_INCREF(o); return o; } @@ -2527,7 +2527,7 @@ if (!PyArg_ParseTuple(args, ":interpaddr")) return NULL; - return PyInt_FromLong((long)Tkapp_Interp(self)); + return PyLong_FromLong((long)Tkapp_Interp(self)); } static PyObject * @@ -2856,7 +2856,7 @@ static PyObject * Tkinter_getbusywaitinterval(PyObject *self, PyObject *args) { - return PyInt_FromLong(Tkinter_busywaitinterval); + return PyLong_FromLong(Tkinter_busywaitinterval); } static char getbusywaitinterval_doc[] = @@ -2987,7 +2987,7 @@ static void ins_long(PyObject *d, char *name, long val) { - PyObject *v = PyInt_FromLong(val); + PyObject *v = PyLong_FromLong(val); if (v) { PyDict_SetItemString(d, name, v); Py_DECREF(v); Modified: python/branches/py3k/Modules/_weakref.c ============================================================================== --- python/branches/py3k/Modules/_weakref.c (original) +++ python/branches/py3k/Modules/_weakref.c Sun Dec 2 15:31:20 2007 @@ -17,10 +17,10 @@ if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); - result = PyInt_FromSsize_t(_PyWeakref_GetWeakrefCount(*list)); + result = PyLong_FromSsize_t(_PyWeakref_GetWeakrefCount(*list)); } else - result = PyInt_FromLong(0); + result = PyLong_FromLong(0); return result; } Modified: python/branches/py3k/Modules/arraymodule.c ============================================================================== --- python/branches/py3k/Modules/arraymodule.c (original) +++ python/branches/py3k/Modules/arraymodule.c Sun Dec 2 15:31:20 2007 @@ -115,7 +115,7 @@ long x = ((char *)ap->ob_item)[i]; if (x >= 128) x -= 256; - return PyInt_FromLong(x); + return PyLong_FromLong(x); } static int @@ -146,7 +146,7 @@ BB_getitem(arrayobject *ap, Py_ssize_t i) { long x = ((unsigned char *)ap->ob_item)[i]; - return PyInt_FromLong(x); + return PyLong_FromLong(x); } static int @@ -189,7 +189,7 @@ static PyObject * h_getitem(arrayobject *ap, Py_ssize_t i) { - return PyInt_FromLong((long) ((short *)ap->ob_item)[i]); + return PyLong_FromLong((long) ((short *)ap->ob_item)[i]); } @@ -208,7 +208,7 @@ static PyObject * HH_getitem(arrayobject *ap, Py_ssize_t i) { - return PyInt_FromLong((long) ((unsigned short *)ap->ob_item)[i]); + return PyLong_FromLong((long) ((unsigned short *)ap->ob_item)[i]); } static int @@ -237,7 +237,7 @@ static PyObject * i_getitem(arrayobject *ap, Py_ssize_t i) { - return PyInt_FromLong((long) ((int *)ap->ob_item)[i]); + return PyLong_FromLong((long) ((int *)ap->ob_item)[i]); } static int @@ -294,7 +294,7 @@ static PyObject * l_getitem(arrayobject *ap, Py_ssize_t i) { - return PyInt_FromLong(((long *)ap->ob_item)[i]); + return PyLong_FromLong(((long *)ap->ob_item)[i]); } static int @@ -899,7 +899,7 @@ else if (cmp < 0) return NULL; } - return PyInt_FromSsize_t(count); + return PyLong_FromSsize_t(count); } PyDoc_STRVAR(count_doc, @@ -917,7 +917,7 @@ int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); if (cmp > 0) { - return PyInt_FromLong((long)i); + return PyLong_FromLong((long)i); } else if (cmp < 0) return NULL; @@ -1043,7 +1043,7 @@ return NULL; PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyInt_FromLong((long)(Py_Size(self)))); + PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_Size(self)))); return retval; } @@ -1483,7 +1483,7 @@ static PyObject * array_get_itemsize(arrayobject *a, void *closure) { - return PyInt_FromLong((long)a->ob_descr->itemsize); + return PyLong_FromLong((long)a->ob_descr->itemsize); } static PyGetSetDef array_getsets [] = { Modified: python/branches/py3k/Modules/audioop.c ============================================================================== --- python/branches/py3k/Modules/audioop.c (original) +++ python/branches/py3k/Modules/audioop.c Sun Dec 2 15:31:20 2007 @@ -315,7 +315,7 @@ if ( size == 1 ) val = (int)*CHARP(cp, i); else if ( size == 2 ) val = (int)*SHORTP(cp, i*2); else if ( size == 4 ) val = (int)*LONGP(cp, i*4); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -339,7 +339,7 @@ if ( val < 0 ) val = (-val); if ( val > max ) max = val; } - return PyInt_FromLong(max); + return PyLong_FromLong(max); } static PyObject * @@ -390,7 +390,7 @@ val = 0; else val = (int)(avg / (double)(len/size)); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -417,7 +417,7 @@ val = 0; else val = (int)sqrt(sum_squares / (double)(len/size)); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static double _sum2(short *a, short *b, int len) @@ -599,7 +599,7 @@ } - return PyInt_FromLong(best_j); + return PyLong_FromLong(best_j); } static PyObject * @@ -656,7 +656,7 @@ val = 0; else val = (int)(avg / (double)nextreme); - return PyInt_FromLong(val); + return PyLong_FromLong(val); } static PyObject * @@ -709,7 +709,7 @@ if ( diff != 0 ) prevdiff = diff; } - return PyInt_FromLong(max); + return PyLong_FromLong(max); } static PyObject * @@ -736,7 +736,7 @@ if ( val != prevval ) ncross++; prevval = val; } - return PyInt_FromLong(ncross); + return PyLong_FromLong(ncross); } static PyObject * Modified: python/branches/py3k/Modules/binascii.c ============================================================================== --- python/branches/py3k/Modules/binascii.c (original) +++ python/branches/py3k/Modules/binascii.c Sun Dec 2 15:31:20 2007 @@ -924,7 +924,7 @@ */ result |= -(result & (1L << 31)); #endif - return PyInt_FromLong(result); + return PyLong_FromLong(result); } Modified: python/branches/py3k/Modules/bz2module.c ============================================================================== --- python/branches/py3k/Modules/bz2module.c (original) +++ python/branches/py3k/Modules/bz2module.c Sun Dec 2 15:31:20 2007 @@ -894,10 +894,10 @@ if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &where)) return NULL; #if !defined(HAVE_LARGEFILE_SUPPORT) - offset = PyInt_AsLong(offobj); + offset = PyLong_AsLong(offobj); #else offset = PyLong_Check(offobj) ? - PyLong_AsLongLong(offobj) : PyInt_AsLong(offobj); + PyLong_AsLongLong(offobj) : PyLong_AsLong(offobj); #endif if (PyErr_Occurred()) return NULL; @@ -1028,7 +1028,7 @@ } #if !defined(HAVE_LARGEFILE_SUPPORT) - ret = PyInt_FromLong(self->pos); + ret = PyLong_FromLong(self->pos); #else ret = PyLong_FromLongLong(self->pos); #endif @@ -1102,7 +1102,7 @@ static PyObject * BZ2File_get_closed(BZ2FileObject *self, void *closure) { - return PyInt_FromLong(self->mode == MODE_CLOSED); + return PyLong_FromLong(self->mode == MODE_CLOSED); } static PyGetSetDef BZ2File_getset[] = { Modified: python/branches/py3k/Modules/cStringIO.c ============================================================================== --- python/branches/py3k/Modules/cStringIO.c (original) +++ python/branches/py3k/Modules/cStringIO.c Sun Dec 2 15:31:20 2007 @@ -276,7 +276,7 @@ if (!IO__opencheck(self)) return NULL; - return PyInt_FromSsize_t(self->pos); + return PyLong_FromSsize_t(self->pos); } PyDoc_STRVAR(IO_truncate__doc__, Modified: python/branches/py3k/Modules/cjkcodecs/multibytecodec.c ============================================================================== --- python/branches/py3k/Modules/cjkcodecs/multibytecodec.c (original) +++ python/branches/py3k/Modules/cjkcodecs/multibytecodec.c Sun Dec 2 15:31:20 2007 @@ -65,7 +65,7 @@ } PyTuple_SET_ITEM(v, 0, object); - w = PyInt_FromSsize_t(len); + w = PyLong_FromSsize_t(len); if (w == NULL) { Py_DECREF(v); return NULL; @@ -313,7 +313,7 @@ if (!PyTuple_Check(retobj) || PyTuple_GET_SIZE(retobj) != 2 || !PyUnicode_Check((tobj = PyTuple_GET_ITEM(retobj, 0))) || - !PyInt_Check(PyTuple_GET_ITEM(retobj, 1))) { + !PyLong_Check(PyTuple_GET_ITEM(retobj, 1))) { PyErr_SetString(PyExc_TypeError, "encoding error handler must return " "(unicode, int) tuple"); @@ -337,7 +337,7 @@ memcpy(buf->outbuf, PyString_AS_STRING(retstr), retstrsize); buf->outbuf += retstrsize; - newpos = PyInt_AsSsize_t(PyTuple_GET_ITEM(retobj, 1)); + newpos = PyLong_AsSsize_t(PyTuple_GET_ITEM(retobj, 1)); if (newpos < 0 && !PyErr_Occurred()) newpos += (Py_ssize_t)(buf->inbuf_end - buf->inbuf_top); if (newpos < 0 || buf->inbuf_top + newpos > buf->inbuf_end) { @@ -432,7 +432,7 @@ if (!PyTuple_Check(retobj) || PyTuple_GET_SIZE(retobj) != 2 || !PyUnicode_Check((retuni = PyTuple_GET_ITEM(retobj, 0))) || - !PyInt_Check(PyTuple_GET_ITEM(retobj, 1))) { + !PyLong_Check(PyTuple_GET_ITEM(retobj, 1))) { PyErr_SetString(PyExc_TypeError, "decoding error handler must return " "(unicode, int) tuple"); @@ -447,7 +447,7 @@ buf->outbuf += retunisize; } - newpos = PyInt_AsSsize_t(PyTuple_GET_ITEM(retobj, 1)); + newpos = PyLong_AsSsize_t(PyTuple_GET_ITEM(retobj, 1)); if (newpos < 0 && !PyErr_Occurred()) newpos += (Py_ssize_t)(buf->inbuf_end - buf->inbuf_top); if (newpos < 0 || buf->inbuf_top + newpos > buf->inbuf_end) { @@ -1317,8 +1317,8 @@ if (sizeobj == Py_None || sizeobj == NULL) size = -1; - else if (PyInt_Check(sizeobj)) - size = PyInt_AsSsize_t(sizeobj); + else if (PyLong_Check(sizeobj)) + size = PyLong_AsSsize_t(sizeobj); else { PyErr_SetString(PyExc_TypeError, "arg 1 must be an integer"); return NULL; @@ -1341,8 +1341,8 @@ if (sizeobj == Py_None || sizeobj == NULL) size = -1; - else if (PyInt_Check(sizeobj)) - size = PyInt_AsSsize_t(sizeobj); + else if (PyLong_Check(sizeobj)) + size = PyLong_AsSsize_t(sizeobj); else { PyErr_SetString(PyExc_TypeError, "arg 1 must be an integer"); return NULL; @@ -1365,8 +1365,8 @@ if (sizehintobj == Py_None || sizehintobj == NULL) sizehint = -1; - else if (PyInt_Check(sizehintobj)) - sizehint = PyInt_AsSsize_t(sizehintobj); + else if (PyLong_Check(sizehintobj)) + sizehint = PyLong_AsSsize_t(sizehintobj); else { PyErr_SetString(PyExc_TypeError, "arg 1 must be an integer"); return NULL; Modified: python/branches/py3k/Modules/datetimemodule.c ============================================================================== --- python/branches/py3k/Modules/datetimemodule.c (original) +++ python/branches/py3k/Modules/datetimemodule.c Sun Dec 2 15:31:20 2007 @@ -1220,8 +1220,8 @@ long year; PyObject *pyyear = PySequence_GetItem(timetuple, 0); if (pyyear == NULL) return NULL; - assert(PyInt_Check(pyyear)); - year = PyInt_AsLong(pyyear); + assert(PyLong_Check(pyyear)); + year = PyLong_AsLong(pyyear); Py_DECREF(pyyear); if (year < 1900) { PyErr_Format(PyExc_ValueError, "year=%ld is before " @@ -1465,7 +1465,7 @@ PyObject *x3 = NULL; PyObject *result = NULL; - x1 = PyInt_FromLong(GET_TD_DAYS(self)); + x1 = PyLong_FromLong(GET_TD_DAYS(self)); if (x1 == NULL) goto Done; x2 = PyNumber_Multiply(x1, seconds_per_day); /* days in seconds */ @@ -1475,7 +1475,7 @@ x1 = NULL; /* x2 has days in seconds */ - x1 = PyInt_FromLong(GET_TD_SECONDS(self)); /* seconds */ + x1 = PyLong_FromLong(GET_TD_SECONDS(self)); /* seconds */ if (x1 == NULL) goto Done; x3 = PyNumber_Add(x1, x2); /* days and seconds in seconds */ @@ -1493,7 +1493,7 @@ x3 = NULL; /* x1 has days+seconds in us */ - x2 = PyInt_FromLong(GET_TD_MICROSECONDS(self)); + x2 = PyLong_FromLong(GET_TD_MICROSECONDS(self)); if (x2 == NULL) goto Done; result = PyNumber_Add(x1, x2); @@ -1902,7 +1902,7 @@ &ms, &minute, &hour, &week) == 0) goto Done; - x = PyInt_FromLong(0); + x = PyLong_FromLong(0); if (x == NULL) goto Done; @@ -2149,19 +2149,19 @@ static PyObject * date_year(PyDateTime_Date *self, void *unused) { - return PyInt_FromLong(GET_YEAR(self)); + return PyLong_FromLong(GET_YEAR(self)); } static PyObject * date_month(PyDateTime_Date *self, void *unused) { - return PyInt_FromLong(GET_MONTH(self)); + return PyLong_FromLong(GET_MONTH(self)); } static PyObject * date_day(PyDateTime_Date *self, void *unused) { - return PyInt_FromLong(GET_DAY(self)); + return PyLong_FromLong(GET_DAY(self)); } static PyGetSetDef date_getset[] = { @@ -2456,7 +2456,7 @@ { int dow = weekday(GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); - return PyInt_FromLong(dow + 1); + return PyLong_FromLong(dow + 1); } static PyObject * @@ -2563,7 +2563,7 @@ static PyObject * date_toordinal(PyDateTime_Date *self) { - return PyInt_FromLong(ymd_to_ord(GET_YEAR(self), GET_MONTH(self), + return PyLong_FromLong(ymd_to_ord(GET_YEAR(self), GET_MONTH(self), GET_DAY(self))); } @@ -2572,7 +2572,7 @@ { int dow = weekday(GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); - return PyInt_FromLong(dow); + return PyLong_FromLong(dow); } /* Pickle support, a simple use of __reduce__. */ @@ -2975,26 +2975,26 @@ static PyObject * time_hour(PyDateTime_Time *self, void *unused) { - return PyInt_FromLong(TIME_GET_HOUR(self)); + return PyLong_FromLong(TIME_GET_HOUR(self)); } static PyObject * time_minute(PyDateTime_Time *self, void *unused) { - return PyInt_FromLong(TIME_GET_MINUTE(self)); + return PyLong_FromLong(TIME_GET_MINUTE(self)); } /* The name time_second conflicted with some platform header file. */ static PyObject * py_time_second(PyDateTime_Time *self, void *unused) { - return PyInt_FromLong(TIME_GET_SECOND(self)); + return PyLong_FromLong(TIME_GET_SECOND(self)); } static PyObject * time_microsecond(PyDateTime_Time *self, void *unused) { - return PyInt_FromLong(TIME_GET_MICROSECOND(self)); + return PyLong_FromLong(TIME_GET_MICROSECOND(self)); } static PyObject * @@ -3505,25 +3505,25 @@ static PyObject * datetime_hour(PyDateTime_DateTime *self, void *unused) { - return PyInt_FromLong(DATE_GET_HOUR(self)); + return PyLong_FromLong(DATE_GET_HOUR(self)); } static PyObject * datetime_minute(PyDateTime_DateTime *self, void *unused) { - return PyInt_FromLong(DATE_GET_MINUTE(self)); + return PyLong_FromLong(DATE_GET_MINUTE(self)); } static PyObject * datetime_second(PyDateTime_DateTime *self, void *unused) { - return PyInt_FromLong(DATE_GET_SECOND(self)); + return PyLong_FromLong(DATE_GET_SECOND(self)); } static PyObject * datetime_microsecond(PyDateTime_DateTime *self, void *unused) { - return PyInt_FromLong(DATE_GET_MICROSECOND(self)); + return PyLong_FromLong(DATE_GET_MICROSECOND(self)); } static PyObject * @@ -3837,7 +3837,7 @@ return NULL; } if (PyInt_CheckExact(p)) - ia[i] = PyInt_AsLong(p); + ia[i] = PyLong_AsLong(p); else good_timetuple = 0; Py_DECREF(p); @@ -4753,11 +4753,11 @@ assert(DI100Y == 25 * DI4Y - 1); assert(DI100Y == days_before_year(100+1)); - us_per_us = PyInt_FromLong(1); - us_per_ms = PyInt_FromLong(1000); - us_per_second = PyInt_FromLong(1000000); - us_per_minute = PyInt_FromLong(60000000); - seconds_per_day = PyInt_FromLong(24 * 3600); + us_per_us = PyLong_FromLong(1); + us_per_ms = PyLong_FromLong(1000); + us_per_second = PyLong_FromLong(1000000); + us_per_minute = PyLong_FromLong(60000000); + seconds_per_day = PyLong_FromLong(24 * 3600); if (us_per_us == NULL || us_per_ms == NULL || us_per_second == NULL || us_per_minute == NULL || seconds_per_day == NULL) return; Modified: python/branches/py3k/Modules/dlmodule.c ============================================================================== --- python/branches/py3k/Modules/dlmodule.c (original) +++ python/branches/py3k/Modules/dlmodule.c Sun Dec 2 15:31:20 2007 @@ -70,7 +70,7 @@ Py_INCREF(Py_None); return Py_None; } - return PyInt_FromLong((long)func); + return PyLong_FromLong((long)func); } static PyObject * @@ -107,8 +107,8 @@ } for (i = 1; i < n; i++) { PyObject *v = PyTuple_GetItem(args, i); - if (PyInt_Check(v)) { - alist[i-1] = PyInt_AsLong(v); + if (PyLong_Check(v)) { + alist[i-1] = PyLong_AsLong(v); if (alist[i-1] == -1 && PyErr_Occurred()) return NULL; } else if (PyUnicode_Check(v)) @@ -125,7 +125,7 @@ alist[i-1] = 0; res = (*func)(alist[0], alist[1], alist[2], alist[3], alist[4], alist[5], alist[6], alist[7], alist[8], alist[9]); - return PyInt_FromLong(res); + return PyLong_FromLong(res); } static PyMethodDef dlobject_methods[] = { @@ -225,7 +225,7 @@ static void insint(PyObject *d, char *name, int value) { - PyObject *v = PyInt_FromLong((long) value); + PyObject *v = PyLong_FromLong((long) value); if (!v || PyDict_SetItemString(d, name, v)) PyErr_Clear(); @@ -249,7 +249,7 @@ d = PyModule_GetDict(m); Dlerror = x = PyErr_NewException("dl.error", NULL, NULL); PyDict_SetItemString(d, "error", x); - x = PyInt_FromLong((long)RTLD_LAZY); + x = PyLong_FromLong((long)RTLD_LAZY); PyDict_SetItemString(d, "RTLD_LAZY", x); #define INSINT(X) insint(d,#X,X) #ifdef RTLD_NOW Modified: python/branches/py3k/Modules/errnomodule.c ============================================================================== --- python/branches/py3k/Modules/errnomodule.c (original) +++ python/branches/py3k/Modules/errnomodule.c Sun Dec 2 15:31:20 2007 @@ -22,7 +22,7 @@ _inscode(PyObject *d, PyObject *de, const char *name, int code) { PyObject *u = PyUnicode_FromString(name); - PyObject *v = PyInt_FromLong((long) code); + PyObject *v = PyLong_FromLong((long) code); /* Don't bother checking for errors; they'll be caught at the end * of the module initialization function by the caller of Modified: python/branches/py3k/Modules/fcntlmodule.c ============================================================================== --- python/branches/py3k/Modules/fcntlmodule.c (original) +++ python/branches/py3k/Modules/fcntlmodule.c Sun Dec 2 15:31:20 2007 @@ -73,7 +73,7 @@ PyErr_SetFromErrno(PyExc_IOError); return NULL; } - return PyInt_FromLong((long)ret); + return PyLong_FromLong((long)ret); } PyDoc_STRVAR(fcntl_doc, @@ -152,7 +152,7 @@ return NULL; } if (mutate_arg) { - return PyInt_FromLong(ret); + return PyLong_FromLong(ret); } else { return PyString_FromStringAndSize(buf, len); @@ -198,7 +198,7 @@ PyErr_SetFromErrno(PyExc_IOError); return NULL; } - return PyInt_FromLong((long)ret); + return PyLong_FromLong((long)ret); #undef IOCTL_BUFSZ } @@ -333,22 +333,22 @@ l.l_start = l.l_len = 0; if (startobj != NULL) { #if !defined(HAVE_LARGEFILE_SUPPORT) - l.l_start = PyInt_AsLong(startobj); + l.l_start = PyLong_AsLong(startobj); #else l.l_start = PyLong_Check(startobj) ? PyLong_AsLongLong(startobj) : - PyInt_AsLong(startobj); + PyLong_AsLong(startobj); #endif if (PyErr_Occurred()) return NULL; } if (lenobj != NULL) { #if !defined(HAVE_LARGEFILE_SUPPORT) - l.l_len = PyInt_AsLong(lenobj); + l.l_len = PyLong_AsLong(lenobj); #else l.l_len = PyLong_Check(lenobj) ? PyLong_AsLongLong(lenobj) : - PyInt_AsLong(lenobj); + PyLong_AsLong(lenobj); #endif if (PyErr_Occurred()) return NULL; @@ -414,7 +414,7 @@ static int ins(PyObject* d, char* symbol, long value) { - PyObject* v = PyInt_FromLong(value); + PyObject* v = PyLong_FromLong(value); if (!v || PyDict_SetItemString(d, symbol, v) < 0) return -1; Modified: python/branches/py3k/Modules/gcmodule.c ============================================================================== --- python/branches/py3k/Modules/gcmodule.c (original) +++ python/branches/py3k/Modules/gcmodule.c Sun Dec 2 15:31:20 2007 @@ -944,7 +944,7 @@ collecting = 0; } - return PyInt_FromSsize_t(n); + return PyLong_FromSsize_t(n); } PyDoc_STRVAR(gc_set_debug__doc__, Modified: python/branches/py3k/Modules/grpmodule.c ============================================================================== --- python/branches/py3k/Modules/grpmodule.c (original) +++ python/branches/py3k/Modules/grpmodule.c Sun Dec 2 15:31:20 2007 @@ -70,7 +70,7 @@ Py_INCREF(Py_None); } #endif - SET(setIndex++, PyInt_FromLong((long) p->gr_gid)); + SET(setIndex++, PyLong_FromLong((long) p->gr_gid)); SET(setIndex++, w); #undef SET @@ -93,7 +93,7 @@ py_int_id = PyNumber_Int(pyo_id); if (!py_int_id) return NULL; - gid = PyInt_AS_LONG(py_int_id); + gid = PyLong_AS_LONG(py_int_id); Py_DECREF(py_int_id); if ((p = getgrgid(gid)) == NULL) { Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Sun Dec 2 15:31:20 2007 @@ -1122,7 +1122,7 @@ numargs = PyTuple_Size(args); if (numargs == 2) { if (a1 != Py_None) { - stop = PyInt_AsSsize_t(a1); + stop = PyLong_AsSsize_t(a1); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1133,11 +1133,11 @@ } } else { if (a1 != Py_None) - start = PyInt_AsSsize_t(a1); + start = PyLong_AsSsize_t(a1); if (start == -1 && PyErr_Occurred()) PyErr_Clear(); if (a2 != Py_None) { - stop = PyInt_AsSsize_t(a2); + stop = PyLong_AsSsize_t(a2); if (stop == -1) { if (PyErr_Occurred()) PyErr_Clear(); @@ -1155,7 +1155,7 @@ if (a3 != NULL) { if (a3 != Py_None) - step = PyInt_AsSsize_t(a3); + step = PyLong_AsSsize_t(a3); if (step == -1 && PyErr_Occurred()) PyErr_Clear(); } @@ -2052,7 +2052,7 @@ return NULL; if (cnt_arg != NULL) { - cnt = PyInt_AsSsize_t(cnt_arg); + cnt = PyLong_AsSsize_t(cnt_arg); if (cnt == -1 && PyErr_Occurred()) { PyErr_Clear(); if (!PyLong_Check(cnt_arg)) { @@ -2092,12 +2092,12 @@ PyObject *stepped_up; if (lz->long_cnt == NULL) { - lz->long_cnt = PyInt_FromSsize_t(PY_SSIZE_T_MAX); + lz->long_cnt = PyLong_FromSsize_t(PY_SSIZE_T_MAX); if (lz->long_cnt == NULL) return NULL; } if (one == NULL) { - one = PyInt_FromLong(1); + one = PyLong_FromLong(1); if (one == NULL) return NULL; } @@ -2115,7 +2115,7 @@ { if (lz->cnt == PY_SSIZE_T_MAX) return count_nextlong(lz); - return PyInt_FromSsize_t(lz->cnt++); + return PyLong_FromSsize_t(lz->cnt++); } static PyObject * @@ -2440,7 +2440,7 @@ PyErr_SetString(PyExc_TypeError, "len() of unsized object"); return NULL; } - return PyInt_FromSize_t(ro->cnt); + return PyLong_FromSize_t(ro->cnt); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/Modules/md5module.c ============================================================================== --- python/branches/py3k/Modules/md5module.c (original) +++ python/branches/py3k/Modules/md5module.c Sun Dec 2 15:31:20 2007 @@ -434,7 +434,7 @@ static PyObject * MD5_get_block_size(PyObject *self, void *closure) { - return PyInt_FromLong(MD5_BLOCKSIZE); + return PyLong_FromLong(MD5_BLOCKSIZE); } static PyObject * @@ -446,7 +446,7 @@ static PyObject * md5_get_digest_size(PyObject *self, void *closure) { - return PyInt_FromLong(MD5_DIGESTSIZE); + return PyLong_FromLong(MD5_DIGESTSIZE); } Modified: python/branches/py3k/Modules/mmapmodule.c ============================================================================== --- python/branches/py3k/Modules/mmapmodule.c (original) +++ python/branches/py3k/Modules/mmapmodule.c Sun Dec 2 15:31:20 2007 @@ -280,10 +280,10 @@ for (i = 0; i < len && needle[i] == p[i]; ++i) /* nothing */; if (i == len) { - return PyInt_FromSsize_t(p - self->data); + return PyLong_FromSsize_t(p - self->data); } } - return PyInt_FromLong(-1); + return PyLong_FromLong(-1); } } @@ -373,11 +373,11 @@ return PyErr_SetFromWindowsErr(error); } if (!high && low < LONG_MAX) - return PyInt_FromLong((long)low); + return PyLong_FromLong((long)low); size = (((PY_LONG_LONG)high)<<32) + low; return PyLong_FromLongLong(size); } else { - return PyInt_FromSsize_t(self->size); + return PyLong_FromSsize_t(self->size); } #endif /* MS_WINDOWS */ @@ -388,7 +388,7 @@ PyErr_SetFromErrno(mmap_module_error); return NULL; } - return PyInt_FromSsize_t(buf.st_size); + return PyLong_FromSsize_t(buf.st_size); } #endif /* UNIX */ } @@ -501,7 +501,7 @@ mmap_tell_method(mmap_object *self, PyObject *unused) { CHECK_VALID(NULL); - return PyInt_FromSize_t(self->pos); + return PyLong_FromSize_t(self->pos); } static PyObject * @@ -517,7 +517,7 @@ return NULL; } else { #ifdef MS_WINDOWS - return PyInt_FromLong((long) + return PyLong_FromLong((long) FlushViewOfFile(self->data+offset, size)); #endif /* MS_WINDOWS */ #ifdef UNIX @@ -529,7 +529,7 @@ PyErr_SetFromErrno(mmap_module_error); return NULL; } - return PyInt_FromLong(0); + return PyLong_FromLong(0); #endif /* UNIX */ } } @@ -676,7 +676,7 @@ "mmap index out of range"); return NULL; } - return PyInt_FromLong(Py_CHARMASK(self->data[i])); + return PyLong_FromLong(Py_CHARMASK(self->data[i])); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelen; @@ -1241,7 +1241,7 @@ static void setint(PyObject *d, const char *name, long value) { - PyObject *o = PyInt_FromLong(value); + PyObject *o = PyLong_FromLong(value); if (o && PyDict_SetItemString(d, name, o) == 0) { Py_DECREF(o); } Modified: python/branches/py3k/Modules/operator.c ============================================================================== --- python/branches/py3k/Modules/operator.c (original) +++ python/branches/py3k/Modules/operator.c Sun Dec 2 15:31:20 2007 @@ -46,13 +46,13 @@ PyObject *a1, *a2; long r; \ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ if(-1 == (r=AOP(a1,a2))) return NULL; \ - return PyInt_FromLong(r); } + return PyLong_FromLong(r); } #define spamn2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ PyObject *a1, *a2; Py_ssize_t r; \ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ if(-1 == (r=AOP(a1,a2))) return NULL; \ - return PyInt_FromSsize_t(r); } + return PyLong_FromSsize_t(r); } #define spami2b(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ PyObject *a1, *a2; long r; \ Modified: python/branches/py3k/Modules/ossaudiodev.c ============================================================================== --- python/branches/py3k/Modules/ossaudiodev.c (original) +++ python/branches/py3k/Modules/ossaudiodev.c Sun Dec 2 15:31:20 2007 @@ -235,7 +235,7 @@ if (ioctl(fd, cmd, &arg) == -1) return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(arg); + return PyLong_FromLong(arg); } @@ -260,7 +260,7 @@ if (ioctl(fd, cmd, &arg) == -1) return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(arg); + return PyLong_FromLong(arg); } @@ -320,7 +320,7 @@ int mask; if (ioctl(self->fd, SNDCTL_DSP_GETFMTS, &mask) == -1) return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(mask); + return PyLong_FromLong(mask); } static PyObject * @@ -404,7 +404,7 @@ } else { self->ocount += rv; } - return PyInt_FromLong(rv); + return PyLong_FromLong(rv); } static PyObject * @@ -472,7 +472,7 @@ static PyObject * oss_fileno(oss_audio_t *self, PyObject *unused) { - return PyInt_FromLong(self->fd); + return PyLong_FromLong(self->fd); } @@ -529,9 +529,9 @@ rv = PyTuple_New(3); if (rv == NULL) return NULL; - PyTuple_SET_ITEM(rv, 0, PyInt_FromLong(fmt)); - PyTuple_SET_ITEM(rv, 1, PyInt_FromLong(channels)); - PyTuple_SET_ITEM(rv, 2, PyInt_FromLong(rate)); + PyTuple_SET_ITEM(rv, 0, PyLong_FromLong(fmt)); + PyTuple_SET_ITEM(rv, 1, PyLong_FromLong(channels)); + PyTuple_SET_ITEM(rv, 2, PyLong_FromLong(rate)); return rv; } @@ -584,7 +584,7 @@ PyErr_SetFromErrno(PyExc_IOError); return NULL; } - return PyInt_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); + return PyLong_FromLong((ai.fragstotal * ai.fragsize) / (nchannels * ssize)); } /* obufcount returns the number of samples that are available in the @@ -603,7 +603,7 @@ PyErr_SetFromErrno(PyExc_IOError); return NULL; } - return PyInt_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / + return PyLong_FromLong((ai.fragstotal * ai.fragsize - ai.bytes) / (ssize * nchannels)); } @@ -623,7 +623,7 @@ PyErr_SetFromErrno(PyExc_IOError); return NULL; } - return PyInt_FromLong(ai.bytes / (ssize * nchannels)); + return PyLong_FromLong(ai.bytes / (ssize * nchannels)); } static PyObject * @@ -662,7 +662,7 @@ static PyObject * oss_mixer_fileno(oss_mixer_t *self, PyObject *unused) { - return PyInt_FromLong(self->fd); + return PyLong_FromLong(self->fd); } /* Simple mixer interface methods */ Modified: python/branches/py3k/Modules/parsermodule.c ============================================================================== --- python/branches/py3k/Modules/parsermodule.c (original) +++ python/branches/py3k/Modules/parsermodule.c Sun Dec 2 15:31:20 2007 @@ -89,7 +89,7 @@ v = mkseq(1 + NCH(n) + (TYPE(n) == encoding_decl)); if (v == NULL) return (v); - w = PyInt_FromLong(TYPE(n)); + w = PyLong_FromLong(TYPE(n)); if (w == NULL) { Py_DECREF(v); return ((PyObject*) NULL); @@ -111,12 +111,12 @@ else if (ISTERMINAL(TYPE(n))) { PyObject *result = mkseq(2 + lineno + col_offset); if (result != NULL) { - (void) addelem(result, 0, PyInt_FromLong(TYPE(n))); + (void) addelem(result, 0, PyLong_FromLong(TYPE(n))); (void) addelem(result, 1, PyUnicode_FromString(STR(n))); if (lineno == 1) - (void) addelem(result, 2, PyInt_FromLong(n->n_lineno)); + (void) addelem(result, 2, PyLong_FromLong(n->n_lineno)); if (col_offset == 1) - (void) addelem(result, 3, PyInt_FromLong(n->n_col_offset)); + (void) addelem(result, 3, PyLong_FromLong(n->n_col_offset)); } return (result); } @@ -664,9 +664,9 @@ if (temp == NULL) ok = 0; else { - ok = PyInt_Check(temp); + ok = PyLong_Check(temp); if (ok) - type = PyInt_AS_LONG(temp); + type = PyLong_AS_LONG(temp); Py_DECREF(temp); } } @@ -702,8 +702,8 @@ if (len == 3) { PyObject *o = PySequence_GetItem(elem, 2); if (o != NULL) { - if (PyInt_Check(o)) - *line_num = PyInt_AS_LONG(o); + if (PyLong_Check(o)) + *line_num = PyLong_AS_LONG(o); else { PyErr_Format(parser_error, "third item in terminal node must be an" @@ -774,7 +774,7 @@ long num = -1; if (temp != NULL) - num = PyInt_AsLong(temp); + num = PyLong_AsLong(temp); Py_XDECREF(temp); if (ISTERMINAL(num)) { /* Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Sun Dec 2 15:31:20 2007 @@ -1281,7 +1281,7 @@ #if SIZEOF_TIME_T > SIZEOF_LONG ival = PyLong_FromLongLong((PY_LONG_LONG)sec); #else - ival = PyInt_FromLong((long)sec); + ival = PyLong_FromLong((long)sec); #endif if (!ival) return; @@ -1305,27 +1305,27 @@ if (v == NULL) return NULL; - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long)st->st_mode)); + PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long)st->st_mode)); #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 1, PyLong_FromLongLong((PY_LONG_LONG)st->st_ino)); #else - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long)st->st_ino)); + PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long)st->st_ino)); #endif #if defined(HAVE_LONG_LONG) && !defined(MS_WINDOWS) PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG)st->st_dev)); #else - PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long)st->st_dev)); + PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long)st->st_dev)); #endif - PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long)st->st_nlink)); - PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long)st->st_uid)); - PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long)st->st_gid)); + PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long)st->st_nlink)); + PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long)st->st_uid)); + PyStructSequence_SET_ITEM(v, 5, PyLong_FromLong((long)st->st_gid)); #ifdef HAVE_LARGEFILE_SUPPORT PyStructSequence_SET_ITEM(v, 6, PyLong_FromLongLong((PY_LONG_LONG)st->st_size)); #else - PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong(st->st_size)); + PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong(st->st_size)); #endif #if defined(HAVE_STAT_TV_NSEC) @@ -1349,19 +1349,19 @@ #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE PyStructSequence_SET_ITEM(v, ST_BLKSIZE_IDX, - PyInt_FromLong((long)st->st_blksize)); + PyLong_FromLong((long)st->st_blksize)); #endif #ifdef HAVE_STRUCT_STAT_ST_BLOCKS PyStructSequence_SET_ITEM(v, ST_BLOCKS_IDX, - PyInt_FromLong((long)st->st_blocks)); + PyLong_FromLong((long)st->st_blocks)); #endif #ifdef HAVE_STRUCT_STAT_ST_RDEV PyStructSequence_SET_ITEM(v, ST_RDEV_IDX, - PyInt_FromLong((long)st->st_rdev)); + PyLong_FromLong((long)st->st_rdev)); #endif #ifdef HAVE_STRUCT_STAT_ST_GEN PyStructSequence_SET_ITEM(v, ST_GEN_IDX, - PyInt_FromLong((long)st->st_gen)); + PyLong_FromLong((long)st->st_gen)); #endif #ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME { @@ -1376,7 +1376,7 @@ if (_stat_float_times) { val = PyFloat_FromDouble(bsec + 1e-9*bnsec); } else { - val = PyInt_FromLong((long)bsec); + val = PyLong_FromLong((long)bsec); } PyStructSequence_SET_ITEM(v, ST_BIRTHTIME_IDX, val); @@ -1384,7 +1384,7 @@ #endif #ifdef HAVE_STRUCT_STAT_ST_FLAGS PyStructSequence_SET_ITEM(v, ST_FLAGS_IDX, - PyInt_FromLong((long)st->st_flags)); + PyLong_FromLong((long)st->st_flags)); #endif if (PyErr_Occurred()) { @@ -2528,7 +2528,7 @@ if (value == -1 && errno != 0) /* either nice() or getpriority() returned an error */ return posix_error(); - return PyInt_FromLong((long) value); + return PyLong_FromLong((long) value); } #endif /* HAVE_NICE */ @@ -2631,7 +2631,7 @@ sts = system(command); #endif Py_END_ALLOW_THREADS - return PyInt_FromLong(sts); + return PyLong_FromLong(sts); } #endif @@ -2649,7 +2649,7 @@ i = (int)umask(i); if (i < 0) return posix_error(); - return PyInt_FromLong((long)i); + return PyLong_FromLong((long)i); } @@ -2706,7 +2706,7 @@ PyObject *intobj = Py_Type(t)->tp_as_number->nb_int(t); if (!intobj) return -1; - intval = PyInt_AsLong(intobj); + intval = PyLong_AsLong(intobj); Py_DECREF(intobj); if (intval == -1 && PyErr_Occurred()) return -1; @@ -2718,7 +2718,7 @@ *usec = 0; return 0; } - intval = PyInt_AsLong(t); + intval = PyLong_AsLong(t); if (intval == -1 && PyErr_Occurred()) return -1; *sec = intval; @@ -3617,7 +3617,7 @@ if (pid == -1) return posix_error(); PyOS_AfterFork(); - return PyInt_FromLong((long)pid); + return PyLong_FromLong((long)pid); } #endif @@ -3636,7 +3636,7 @@ return posix_error(); if (pid == 0) PyOS_AfterFork(); - return PyInt_FromLong((long)pid); + return PyLong_FromLong((long)pid); } #endif @@ -3757,7 +3757,7 @@ static PyObject * posix_getegid(PyObject *self, PyObject *noargs) { - return PyInt_FromLong((long)getegid()); + return PyLong_FromLong((long)getegid()); } #endif @@ -3770,7 +3770,7 @@ static PyObject * posix_geteuid(PyObject *self, PyObject *noargs) { - return PyInt_FromLong((long)geteuid()); + return PyLong_FromLong((long)geteuid()); } #endif @@ -3783,7 +3783,7 @@ static PyObject * posix_getgid(PyObject *self, PyObject *noargs) { - return PyInt_FromLong((long)getgid()); + return PyLong_FromLong((long)getgid()); } #endif @@ -3795,7 +3795,7 @@ static PyObject * posix_getpid(PyObject *self, PyObject *noargs) { - return PyInt_FromLong((long)getpid()); + return PyLong_FromLong((long)getpid()); } @@ -3826,7 +3826,7 @@ if (result != NULL) { int i; for (i = 0; i < n; ++i) { - PyObject *o = PyInt_FromLong((long)grouplist[i]); + PyObject *o = PyLong_FromLong((long)grouplist[i]); if (o == NULL) { Py_DECREF(result); result = NULL; @@ -3855,7 +3855,7 @@ pgid = getpgid(pid); if (pgid < 0) return posix_error(); - return PyInt_FromLong((long)pgid); + return PyLong_FromLong((long)pgid); } #endif /* HAVE_GETPGID */ @@ -3869,9 +3869,9 @@ posix_getpgrp(PyObject *self, PyObject *noargs) { #ifdef GETPGRP_HAVE_ARG - return PyInt_FromLong((long)getpgrp(0)); + return PyLong_FromLong((long)getpgrp(0)); #else /* GETPGRP_HAVE_ARG */ - return PyInt_FromLong((long)getpgrp()); + return PyLong_FromLong((long)getpgrp()); #endif /* GETPGRP_HAVE_ARG */ } #endif /* HAVE_GETPGRP */ @@ -3905,7 +3905,7 @@ static PyObject * posix_getppid(PyObject *self, PyObject *noargs) { - return PyInt_FromLong((long)getppid()); + return PyLong_FromLong((long)getppid()); } #endif @@ -3947,7 +3947,7 @@ static PyObject * posix_getuid(PyObject *self, PyObject *noargs) { - return PyInt_FromLong((long)getuid()); + return PyLong_FromLong((long)getuid()); } #endif @@ -4237,7 +4237,7 @@ PyStructSequence_SET_ITEM(result, 1, PyFloat_FromDouble(doubletime(ru->ru_stime))); #define SET_INT(result, index, value)\ - PyStructSequence_SET_ITEM(result, index, PyInt_FromLong(value)) + PyStructSequence_SET_ITEM(result, index, PyLong_FromLong(value)) SET_INT(result, 2, ru->ru_maxrss); SET_INT(result, 3, ru->ru_ixrss); SET_INT(result, 4, ru->ru_idrss); @@ -4569,7 +4569,7 @@ sid = getsid(pid); if (sid < 0) return posix_error(); - return PyInt_FromLong((long)sid); + return PyLong_FromLong((long)sid); } #endif /* HAVE_GETSID */ @@ -4622,7 +4622,7 @@ pgid = tcgetpgrp(fd); if (pgid < 0) return posix_error(); - return PyInt_FromLong((long)pgid); + return PyLong_FromLong((long)pgid); } #endif /* HAVE_TCGETPGRP */ @@ -4670,7 +4670,7 @@ Py_END_ALLOW_THREADS if (fd < 0) return posix_error(); - return PyInt_FromLong((long)fd); + return PyLong_FromLong((long)fd); } /* Drop the argument parsing error as narrow strings are also valid. */ @@ -4689,7 +4689,7 @@ if (fd < 0) return posix_error_with_allocated_filename(file); PyMem_Free(file); - return PyInt_FromLong((long)fd); + return PyLong_FromLong((long)fd); } @@ -4728,7 +4728,7 @@ Py_END_ALLOW_THREADS if (fd < 0) return posix_error(); - return PyInt_FromLong((long)fd); + return PyLong_FromLong((long)fd); } @@ -4778,10 +4778,10 @@ #endif /* SEEK_END */ #if !defined(HAVE_LARGEFILE_SUPPORT) - pos = PyInt_AsLong(posobj); + pos = PyLong_AsLong(posobj); #else pos = PyLong_Check(posobj) ? - PyLong_AsLongLong(posobj) : PyInt_AsLong(posobj); + PyLong_AsLongLong(posobj) : PyLong_AsLong(posobj); #endif if (PyErr_Occurred()) return NULL; @@ -4797,7 +4797,7 @@ return posix_error(); #if !defined(HAVE_LARGEFILE_SUPPORT) - return PyInt_FromLong(res); + return PyLong_FromLong(res); #else return PyLong_FromLongLong(res); #endif @@ -4854,7 +4854,7 @@ Py_END_ALLOW_THREADS if (size < 0) return posix_error(); - return PyInt_FromSsize_t(size); + return PyLong_FromSsize_t(size); } @@ -5014,7 +5014,7 @@ int device; if (!PyArg_ParseTuple(args, "i:major", &device)) return NULL; - return PyInt_FromLong((long)major(device)); + return PyLong_FromLong((long)major(device)); } PyDoc_STRVAR(posix_minor__doc__, @@ -5027,7 +5027,7 @@ int device; if (!PyArg_ParseTuple(args, "i:minor", &device)) return NULL; - return PyInt_FromLong((long)minor(device)); + return PyLong_FromLong((long)minor(device)); } PyDoc_STRVAR(posix_makedev__doc__, @@ -5040,7 +5040,7 @@ int major, minor; if (!PyArg_ParseTuple(args, "ii:makedev", &major, &minor)) return NULL; - return PyInt_FromLong((long)makedev(major, minor)); + return PyLong_FromLong((long)makedev(major, minor)); } #endif /* device macros */ @@ -5062,10 +5062,10 @@ return NULL; #if !defined(HAVE_LARGEFILE_SUPPORT) - length = PyInt_AsLong(lenobj); + length = PyLong_AsLong(lenobj); #else length = PyLong_Check(lenobj) ? - PyLong_AsLongLong(lenobj) : PyInt_AsLong(lenobj); + PyLong_AsLongLong(lenobj) : PyLong_AsLong(lenobj); #endif if (PyErr_Occurred()) return NULL; @@ -5401,19 +5401,19 @@ return NULL; #if !defined(HAVE_LARGEFILE_SUPPORT) - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long) st.f_bsize)); - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) st.f_frsize)); - PyStructSequence_SET_ITEM(v, 2, PyInt_FromLong((long) st.f_blocks)); - PyStructSequence_SET_ITEM(v, 3, PyInt_FromLong((long) st.f_bfree)); - PyStructSequence_SET_ITEM(v, 4, PyInt_FromLong((long) st.f_bavail)); - PyStructSequence_SET_ITEM(v, 5, PyInt_FromLong((long) st.f_files)); - PyStructSequence_SET_ITEM(v, 6, PyInt_FromLong((long) st.f_ffree)); - PyStructSequence_SET_ITEM(v, 7, PyInt_FromLong((long) st.f_favail)); - PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) st.f_flag)); - PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) st.f_namemax)); + PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize)); + PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize)); + PyStructSequence_SET_ITEM(v, 2, PyLong_FromLong((long) st.f_blocks)); + PyStructSequence_SET_ITEM(v, 3, PyLong_FromLong((long) st.f_bfree)); + PyStructSequence_SET_ITEM(v, 4, PyLong_FromLong((long) st.f_bavail)); + PyStructSequence_SET_ITEM(v, 5, PyLong_FromLong((long) st.f_files)); + PyStructSequence_SET_ITEM(v, 6, PyLong_FromLong((long) st.f_ffree)); + PyStructSequence_SET_ITEM(v, 7, PyLong_FromLong((long) st.f_favail)); + PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); + PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #else - PyStructSequence_SET_ITEM(v, 0, PyInt_FromLong((long) st.f_bsize)); - PyStructSequence_SET_ITEM(v, 1, PyInt_FromLong((long) st.f_frsize)); + PyStructSequence_SET_ITEM(v, 0, PyLong_FromLong((long) st.f_bsize)); + PyStructSequence_SET_ITEM(v, 1, PyLong_FromLong((long) st.f_frsize)); PyStructSequence_SET_ITEM(v, 2, PyLong_FromLongLong((PY_LONG_LONG) st.f_blocks)); PyStructSequence_SET_ITEM(v, 3, @@ -5426,8 +5426,8 @@ PyLong_FromLongLong((PY_LONG_LONG) st.f_ffree)); PyStructSequence_SET_ITEM(v, 7, PyLong_FromLongLong((PY_LONG_LONG) st.f_favail)); - PyStructSequence_SET_ITEM(v, 8, PyInt_FromLong((long) st.f_flag)); - PyStructSequence_SET_ITEM(v, 9, PyInt_FromLong((long) st.f_namemax)); + PyStructSequence_SET_ITEM(v, 8, PyLong_FromLong((long) st.f_flag)); + PyStructSequence_SET_ITEM(v, 9, PyLong_FromLong((long) st.f_namemax)); #endif return v; @@ -5501,8 +5501,8 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table, size_t tablesize) { - if (PyInt_Check(arg)) { - *valuep = PyInt_AS_LONG(arg); + if (PyLong_Check(arg)) { + *valuep = PyLong_AS_LONG(arg); return 1; } else { @@ -5625,7 +5625,7 @@ if (limit == -1 && errno != 0) posix_error(); else - result = PyInt_FromLong(limit); + result = PyLong_FromLong(limit); } return result; } @@ -5659,7 +5659,7 @@ posix_error_with_filename(path); } else - result = PyInt_FromLong(limit); + result = PyLong_FromLong(limit); } return result; } @@ -6383,7 +6383,7 @@ if (value == -1 && errno != 0) posix_error(); else - result = PyInt_FromLong(value); + result = PyLong_FromLong(value); } return result; } @@ -6424,7 +6424,7 @@ return -1; for (i=0; i < tablesize; ++i) { - PyObject *o = PyInt_FromLong(table[i].value); + PyObject *o = PyLong_FromLong(table[i].value); if (o == NULL || PyDict_SetItemString(d, table[i].name, o) == -1) { Py_XDECREF(o); Py_DECREF(d); Modified: python/branches/py3k/Modules/pwdmodule.c ============================================================================== --- python/branches/py3k/Modules/pwdmodule.c (original) +++ python/branches/py3k/Modules/pwdmodule.c Sun Dec 2 15:31:20 2007 @@ -67,7 +67,7 @@ if (v == NULL) return NULL; -#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) +#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyLong_FromLong((long) val)) #define SETS(i,val) sets(v, i, val) SETS(setIndex++, p->pw_name); Modified: python/branches/py3k/Modules/pyexpat.c ============================================================================== --- python/branches/py3k/Modules/pyexpat.c (original) +++ python/branches/py3k/Modules/pyexpat.c Sun Dec 2 15:31:20 2007 @@ -83,7 +83,7 @@ static int set_error_attr(PyObject *err, char *name, int value) { - PyObject *v = PyInt_FromLong(value); + PyObject *v = PyLong_FromLong(value); if (v == NULL || PyObject_SetAttrString(err, name, v) == -1) { Py_XDECREF(v); @@ -583,7 +583,7 @@ #define INT_HANDLER(NAME, PARAMS, PARAM_FORMAT)\ RC_HANDLER(int, NAME, PARAMS, int rc=0;, PARAM_FORMAT, \ - rc = PyInt_AsLong(rv);, rc, \ + rc = PyLong_AsLong(rv);, rc, \ (xmlparseobject *)userData) VOID_HANDLER(EndElement, @@ -784,7 +784,7 @@ ("(O&NNN)", conv_string_to_unicode ,context, string_intern(self, base), string_intern(self, systemId), string_intern(self, publicId)), - rc = PyInt_AsLong(rv);, rc, + rc = PyLong_AsLong(rv);, rc, XML_GetUserData(parser)) /* XXX UnknownEncodingHandler */ @@ -813,7 +813,7 @@ if (flush_character_buffer(self) < 0) { return NULL; } - return PyInt_FromLong(rv); + return PyLong_FromLong(rv); } PyDoc_STRVAR(xmlparse_Parse__doc__, @@ -846,7 +846,7 @@ int len = -1; char *ptr; - if ((bytes = PyInt_FromLong(buf_size)) == NULL) + if ((bytes = PyLong_FromLong(buf_size)) == NULL) goto finally; if ((arg = PyTuple_New(1)) == NULL) { @@ -1103,7 +1103,7 @@ if (!PyArg_ParseTuple(args, "i", &flag)) return NULL; flag = XML_SetParamEntityParsing(p->itself, flag); - return PyInt_FromLong(flag); + return PyLong_FromLong(flag); } @@ -1342,36 +1342,36 @@ } if (name[0] == 'E') { if (strcmp(name, "ErrorCode") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetErrorCode(self->itself)); if (strcmp(name, "ErrorLineNumber") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetErrorLineNumber(self->itself)); if (strcmp(name, "ErrorColumnNumber") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetErrorColumnNumber(self->itself)); if (strcmp(name, "ErrorByteIndex") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetErrorByteIndex(self->itself)); } if (name[0] == 'C') { if (strcmp(name, "CurrentLineNumber") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetCurrentLineNumber(self->itself)); if (strcmp(name, "CurrentColumnNumber") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetCurrentColumnNumber(self->itself)); if (strcmp(name, "CurrentByteIndex") == 0) - return PyInt_FromLong((long) + return PyLong_FromLong((long) XML_GetCurrentByteIndex(self->itself)); } if (name[0] == 'b') { if (strcmp(name, "buffer_size") == 0) - return PyInt_FromLong((long) self->buffer_size); + return PyLong_FromLong((long) self->buffer_size); if (strcmp(name, "buffer_text") == 0) return get_pybool(self->buffer != NULL); if (strcmp(name, "buffer_used") == 0) - return PyInt_FromLong((long) self->buffer_used); + return PyLong_FromLong((long) self->buffer_used); } if (strcmp(name, "namespace_prefixes") == 0) return get_pybool(self->ns_prefixes); Modified: python/branches/py3k/Modules/readline.c ============================================================================== --- python/branches/py3k/Modules/readline.c (original) +++ python/branches/py3k/Modules/readline.c Sun Dec 2 15:31:20 2007 @@ -154,7 +154,7 @@ static PyObject* get_history_length(PyObject *self, PyObject *noarg) { - return PyInt_FromLong(_history_length); + return PyLong_FromLong(_history_length); } PyDoc_STRVAR(get_history_length_doc, @@ -271,7 +271,7 @@ static PyObject * get_completion_type(PyObject *self, PyObject *noarg) { - return PyInt_FromLong(rl_completion_type); + return PyLong_FromLong(rl_completion_type); } PyDoc_STRVAR(doc_get_completion_type, @@ -490,7 +490,7 @@ HISTORY_STATE *hist_st; hist_st = history_get_history_state(); - return PyInt_FromLong(hist_st ? (long) hist_st->length : (long) 0); + return PyLong_FromLong(hist_st ? (long) hist_st->length : (long) 0); } PyDoc_STRVAR(doc_get_current_history_length, @@ -628,7 +628,7 @@ if (r == Py_None) result = 0; else { - result = PyInt_AsLong(r); + result = PyLong_AsLong(r); if (result == -1 && PyErr_Occurred()) goto error; } @@ -688,7 +688,7 @@ Py_DECREF(m), m=NULL; if (r == NULL || - (r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) { + (r != Py_None && PyLong_AsLong(r) == -1 && PyErr_Occurred())) { goto error; } Py_XDECREF(r), r=NULL; @@ -752,8 +752,8 @@ { Py_XDECREF(begidx); Py_XDECREF(endidx); - begidx = PyInt_FromLong((long) start); - endidx = PyInt_FromLong((long) end); + begidx = PyLong_FromLong((long) start); + endidx = PyLong_FromLong((long) end); return completion_matches(text, *on_completion); } @@ -796,8 +796,8 @@ rl_completion_append_character ='\0'; #endif - begidx = PyInt_FromLong(0L); - endidx = PyInt_FromLong(0L); + begidx = PyLong_FromLong(0L); + endidx = PyLong_FromLong(0L); /* Initialize (allows .inputrc to override) * * XXX: A bug in the readline-2.2 library causes a memory leak Modified: python/branches/py3k/Modules/resource.c ============================================================================== --- python/branches/py3k/Modules/resource.c (original) +++ python/branches/py3k/Modules/resource.c Sun Dec 2 15:31:20 2007 @@ -86,20 +86,20 @@ PyFloat_FromDouble(doubletime(ru.ru_utime))); PyStructSequence_SET_ITEM(result, 1, PyFloat_FromDouble(doubletime(ru.ru_stime))); - PyStructSequence_SET_ITEM(result, 2, PyInt_FromLong(ru.ru_maxrss)); - PyStructSequence_SET_ITEM(result, 3, PyInt_FromLong(ru.ru_ixrss)); - PyStructSequence_SET_ITEM(result, 4, PyInt_FromLong(ru.ru_idrss)); - PyStructSequence_SET_ITEM(result, 5, PyInt_FromLong(ru.ru_isrss)); - PyStructSequence_SET_ITEM(result, 6, PyInt_FromLong(ru.ru_minflt)); - PyStructSequence_SET_ITEM(result, 7, PyInt_FromLong(ru.ru_majflt)); - PyStructSequence_SET_ITEM(result, 8, PyInt_FromLong(ru.ru_nswap)); - PyStructSequence_SET_ITEM(result, 9, PyInt_FromLong(ru.ru_inblock)); - PyStructSequence_SET_ITEM(result, 10, PyInt_FromLong(ru.ru_oublock)); - PyStructSequence_SET_ITEM(result, 11, PyInt_FromLong(ru.ru_msgsnd)); - PyStructSequence_SET_ITEM(result, 12, PyInt_FromLong(ru.ru_msgrcv)); - PyStructSequence_SET_ITEM(result, 13, PyInt_FromLong(ru.ru_nsignals)); - PyStructSequence_SET_ITEM(result, 14, PyInt_FromLong(ru.ru_nvcsw)); - PyStructSequence_SET_ITEM(result, 15, PyInt_FromLong(ru.ru_nivcsw)); + PyStructSequence_SET_ITEM(result, 2, PyLong_FromLong(ru.ru_maxrss)); + PyStructSequence_SET_ITEM(result, 3, PyLong_FromLong(ru.ru_ixrss)); + PyStructSequence_SET_ITEM(result, 4, PyLong_FromLong(ru.ru_idrss)); + PyStructSequence_SET_ITEM(result, 5, PyLong_FromLong(ru.ru_isrss)); + PyStructSequence_SET_ITEM(result, 6, PyLong_FromLong(ru.ru_minflt)); + PyStructSequence_SET_ITEM(result, 7, PyLong_FromLong(ru.ru_majflt)); + PyStructSequence_SET_ITEM(result, 8, PyLong_FromLong(ru.ru_nswap)); + PyStructSequence_SET_ITEM(result, 9, PyLong_FromLong(ru.ru_inblock)); + PyStructSequence_SET_ITEM(result, 10, PyLong_FromLong(ru.ru_oublock)); + PyStructSequence_SET_ITEM(result, 11, PyLong_FromLong(ru.ru_msgsnd)); + PyStructSequence_SET_ITEM(result, 12, PyLong_FromLong(ru.ru_msgrcv)); + PyStructSequence_SET_ITEM(result, 13, PyLong_FromLong(ru.ru_nsignals)); + PyStructSequence_SET_ITEM(result, 14, PyLong_FromLong(ru.ru_nvcsw)); + PyStructSequence_SET_ITEM(result, 15, PyLong_FromLong(ru.ru_nivcsw)); if (PyErr_Occurred()) { Py_DECREF(result); @@ -158,20 +158,20 @@ } #if !defined(HAVE_LARGEFILE_SUPPORT) - rl.rlim_cur = PyInt_AsLong(curobj); + rl.rlim_cur = PyLong_AsLong(curobj); if (rl.rlim_cur == -1 && PyErr_Occurred()) return NULL; - rl.rlim_max = PyInt_AsLong(maxobj); + rl.rlim_max = PyLong_AsLong(maxobj); if (rl.rlim_max == -1 && PyErr_Occurred()) return NULL; #else /* The limits are probably bigger than a long */ rl.rlim_cur = PyLong_Check(curobj) ? - PyLong_AsLongLong(curobj) : PyInt_AsLong(curobj); + PyLong_AsLongLong(curobj) : PyLong_AsLong(curobj); if (rl.rlim_cur == -1 && PyErr_Occurred()) return NULL; rl.rlim_max = PyLong_Check(maxobj) ? - PyLong_AsLongLong(maxobj) : PyInt_AsLong(maxobj); + PyLong_AsLongLong(maxobj) : PyLong_AsLong(maxobj); if (rl.rlim_max == -1 && PyErr_Occurred()) return NULL; #endif @@ -320,7 +320,7 @@ } else #endif { - v = PyInt_FromLong((long) RLIM_INFINITY); + v = PyLong_FromLong((long) RLIM_INFINITY); } if (v) { PyModule_AddObject(m, "RLIM_INFINITY", v); Modified: python/branches/py3k/Modules/selectmodule.c ============================================================================== --- python/branches/py3k/Modules/selectmodule.c (original) +++ python/branches/py3k/Modules/selectmodule.c Sun Dec 2 15:31:20 2007 @@ -355,8 +355,8 @@ i = pos = 0; while (PyDict_Next(self->dict, &pos, &key, &value)) { - self->ufds[i].fd = PyInt_AsLong(key); - self->ufds[i].events = (short)PyInt_AsLong(value); + self->ufds[i].fd = PyLong_AsLong(key); + self->ufds[i].events = (short)PyLong_AsLong(value); i++; } self->ufd_uptodate = 1; @@ -386,10 +386,10 @@ /* Add entry to the internal dictionary: the key is the file descriptor, and the value is the event mask. */ - key = PyInt_FromLong(fd); + key = PyLong_FromLong(fd); if (key == NULL) return NULL; - value = PyInt_FromLong(events); + value = PyLong_FromLong(events); if (value == NULL) { Py_DECREF(key); return NULL; @@ -421,7 +421,7 @@ return NULL; /* Check whether the fd is already in the array */ - key = PyInt_FromLong(fd); + key = PyLong_FromLong(fd); if (key == NULL) return NULL; @@ -467,7 +467,7 @@ tout = PyNumber_Int(tout); if (!tout) return NULL; - timeout = PyInt_AsLong(tout); + timeout = PyLong_AsLong(tout); Py_DECREF(tout); if (timeout == -1 && PyErr_Occurred()) return NULL; @@ -505,7 +505,7 @@ value = PyTuple_New(2); if (value == NULL) goto error; - num = PyInt_FromLong(self->ufds[i].fd); + num = PyLong_FromLong(self->ufds[i].fd); if (num == NULL) { Py_DECREF(value); goto error; @@ -516,7 +516,7 @@ is a 16-bit short, and IBM assigned POLLNVAL to be 0x8000, so the conversion to int results in a negative number. See SF bug #923315. */ - num = PyInt_FromLong(self->ufds[i].revents & 0xffff); + num = PyLong_FromLong(self->ufds[i].revents & 0xffff); if (num == NULL) { Py_DECREF(value); goto error; Modified: python/branches/py3k/Modules/sha1module.c ============================================================================== --- python/branches/py3k/Modules/sha1module.c (original) +++ python/branches/py3k/Modules/sha1module.c Sun Dec 2 15:31:20 2007 @@ -410,7 +410,7 @@ static PyObject * SHA1_get_block_size(PyObject *self, void *closure) { - return PyInt_FromLong(SHA1_BLOCKSIZE); + return PyLong_FromLong(SHA1_BLOCKSIZE); } static PyObject * @@ -422,7 +422,7 @@ static PyObject * sha1_get_digest_size(PyObject *self, void *closure) { - return PyInt_FromLong(SHA1_DIGESTSIZE); + return PyLong_FromLong(SHA1_DIGESTSIZE); } Modified: python/branches/py3k/Modules/sha256module.c ============================================================================== --- python/branches/py3k/Modules/sha256module.c (original) +++ python/branches/py3k/Modules/sha256module.c Sun Dec 2 15:31:20 2007 @@ -503,7 +503,7 @@ static PyObject * SHA256_get_block_size(PyObject *self, void *closure) { - return PyInt_FromLong(SHA_BLOCKSIZE); + return PyLong_FromLong(SHA_BLOCKSIZE); } static PyObject * Modified: python/branches/py3k/Modules/sha512module.c ============================================================================== --- python/branches/py3k/Modules/sha512module.c (original) +++ python/branches/py3k/Modules/sha512module.c Sun Dec 2 15:31:20 2007 @@ -569,7 +569,7 @@ static PyObject * SHA512_get_block_size(PyObject *self, void *closure) { - return PyInt_FromLong(SHA_BLOCKSIZE); + return PyLong_FromLong(SHA_BLOCKSIZE); } static PyObject * Modified: python/branches/py3k/Modules/signalmodule.c ============================================================================== --- python/branches/py3k/Modules/signalmodule.c (original) +++ python/branches/py3k/Modules/signalmodule.c Sun Dec 2 15:31:20 2007 @@ -149,7 +149,7 @@ if (!PyArg_ParseTuple(args, "i:alarm", &t)) return NULL; /* alarm() returns the number of seconds remaining */ - return PyInt_FromLong((long)alarm(t)); + return PyLong_FromLong((long)alarm(t)); } PyDoc_STRVAR(alarm_doc, @@ -331,7 +331,7 @@ if (!x || PyDict_SetItemString(d, "SIG_IGN", x) < 0) goto finally; - x = PyInt_FromLong((long)NSIG); + x = PyLong_FromLong((long)NSIG); if (!x || PyDict_SetItemString(d, "NSIG", x) < 0) goto finally; Py_DECREF(x); @@ -363,192 +363,192 @@ } #ifdef SIGHUP - x = PyInt_FromLong(SIGHUP); + x = PyLong_FromLong(SIGHUP); PyDict_SetItemString(d, "SIGHUP", x); Py_XDECREF(x); #endif #ifdef SIGINT - x = PyInt_FromLong(SIGINT); + x = PyLong_FromLong(SIGINT); PyDict_SetItemString(d, "SIGINT", x); Py_XDECREF(x); #endif #ifdef SIGBREAK - x = PyInt_FromLong(SIGBREAK); + x = PyLong_FromLong(SIGBREAK); PyDict_SetItemString(d, "SIGBREAK", x); Py_XDECREF(x); #endif #ifdef SIGQUIT - x = PyInt_FromLong(SIGQUIT); + x = PyLong_FromLong(SIGQUIT); PyDict_SetItemString(d, "SIGQUIT", x); Py_XDECREF(x); #endif #ifdef SIGILL - x = PyInt_FromLong(SIGILL); + x = PyLong_FromLong(SIGILL); PyDict_SetItemString(d, "SIGILL", x); Py_XDECREF(x); #endif #ifdef SIGTRAP - x = PyInt_FromLong(SIGTRAP); + x = PyLong_FromLong(SIGTRAP); PyDict_SetItemString(d, "SIGTRAP", x); Py_XDECREF(x); #endif #ifdef SIGIOT - x = PyInt_FromLong(SIGIOT); + x = PyLong_FromLong(SIGIOT); PyDict_SetItemString(d, "SIGIOT", x); Py_XDECREF(x); #endif #ifdef SIGABRT - x = PyInt_FromLong(SIGABRT); + x = PyLong_FromLong(SIGABRT); PyDict_SetItemString(d, "SIGABRT", x); Py_XDECREF(x); #endif #ifdef SIGEMT - x = PyInt_FromLong(SIGEMT); + x = PyLong_FromLong(SIGEMT); PyDict_SetItemString(d, "SIGEMT", x); Py_XDECREF(x); #endif #ifdef SIGFPE - x = PyInt_FromLong(SIGFPE); + x = PyLong_FromLong(SIGFPE); PyDict_SetItemString(d, "SIGFPE", x); Py_XDECREF(x); #endif #ifdef SIGKILL - x = PyInt_FromLong(SIGKILL); + x = PyLong_FromLong(SIGKILL); PyDict_SetItemString(d, "SIGKILL", x); Py_XDECREF(x); #endif #ifdef SIGBUS - x = PyInt_FromLong(SIGBUS); + x = PyLong_FromLong(SIGBUS); PyDict_SetItemString(d, "SIGBUS", x); Py_XDECREF(x); #endif #ifdef SIGSEGV - x = PyInt_FromLong(SIGSEGV); + x = PyLong_FromLong(SIGSEGV); PyDict_SetItemString(d, "SIGSEGV", x); Py_XDECREF(x); #endif #ifdef SIGSYS - x = PyInt_FromLong(SIGSYS); + x = PyLong_FromLong(SIGSYS); PyDict_SetItemString(d, "SIGSYS", x); Py_XDECREF(x); #endif #ifdef SIGPIPE - x = PyInt_FromLong(SIGPIPE); + x = PyLong_FromLong(SIGPIPE); PyDict_SetItemString(d, "SIGPIPE", x); Py_XDECREF(x); #endif #ifdef SIGALRM - x = PyInt_FromLong(SIGALRM); + x = PyLong_FromLong(SIGALRM); PyDict_SetItemString(d, "SIGALRM", x); Py_XDECREF(x); #endif #ifdef SIGTERM - x = PyInt_FromLong(SIGTERM); + x = PyLong_FromLong(SIGTERM); PyDict_SetItemString(d, "SIGTERM", x); Py_XDECREF(x); #endif #ifdef SIGUSR1 - x = PyInt_FromLong(SIGUSR1); + x = PyLong_FromLong(SIGUSR1); PyDict_SetItemString(d, "SIGUSR1", x); Py_XDECREF(x); #endif #ifdef SIGUSR2 - x = PyInt_FromLong(SIGUSR2); + x = PyLong_FromLong(SIGUSR2); PyDict_SetItemString(d, "SIGUSR2", x); Py_XDECREF(x); #endif #ifdef SIGCLD - x = PyInt_FromLong(SIGCLD); + x = PyLong_FromLong(SIGCLD); PyDict_SetItemString(d, "SIGCLD", x); Py_XDECREF(x); #endif #ifdef SIGCHLD - x = PyInt_FromLong(SIGCHLD); + x = PyLong_FromLong(SIGCHLD); PyDict_SetItemString(d, "SIGCHLD", x); Py_XDECREF(x); #endif #ifdef SIGPWR - x = PyInt_FromLong(SIGPWR); + x = PyLong_FromLong(SIGPWR); PyDict_SetItemString(d, "SIGPWR", x); Py_XDECREF(x); #endif #ifdef SIGIO - x = PyInt_FromLong(SIGIO); + x = PyLong_FromLong(SIGIO); PyDict_SetItemString(d, "SIGIO", x); Py_XDECREF(x); #endif #ifdef SIGURG - x = PyInt_FromLong(SIGURG); + x = PyLong_FromLong(SIGURG); PyDict_SetItemString(d, "SIGURG", x); Py_XDECREF(x); #endif #ifdef SIGWINCH - x = PyInt_FromLong(SIGWINCH); + x = PyLong_FromLong(SIGWINCH); PyDict_SetItemString(d, "SIGWINCH", x); Py_XDECREF(x); #endif #ifdef SIGPOLL - x = PyInt_FromLong(SIGPOLL); + x = PyLong_FromLong(SIGPOLL); PyDict_SetItemString(d, "SIGPOLL", x); Py_XDECREF(x); #endif #ifdef SIGSTOP - x = PyInt_FromLong(SIGSTOP); + x = PyLong_FromLong(SIGSTOP); PyDict_SetItemString(d, "SIGSTOP", x); Py_XDECREF(x); #endif #ifdef SIGTSTP - x = PyInt_FromLong(SIGTSTP); + x = PyLong_FromLong(SIGTSTP); PyDict_SetItemString(d, "SIGTSTP", x); Py_XDECREF(x); #endif #ifdef SIGCONT - x = PyInt_FromLong(SIGCONT); + x = PyLong_FromLong(SIGCONT); PyDict_SetItemString(d, "SIGCONT", x); Py_XDECREF(x); #endif #ifdef SIGTTIN - x = PyInt_FromLong(SIGTTIN); + x = PyLong_FromLong(SIGTTIN); PyDict_SetItemString(d, "SIGTTIN", x); Py_XDECREF(x); #endif #ifdef SIGTTOU - x = PyInt_FromLong(SIGTTOU); + x = PyLong_FromLong(SIGTTOU); PyDict_SetItemString(d, "SIGTTOU", x); Py_XDECREF(x); #endif #ifdef SIGVTALRM - x = PyInt_FromLong(SIGVTALRM); + x = PyLong_FromLong(SIGVTALRM); PyDict_SetItemString(d, "SIGVTALRM", x); Py_XDECREF(x); #endif #ifdef SIGPROF - x = PyInt_FromLong(SIGPROF); + x = PyLong_FromLong(SIGPROF); PyDict_SetItemString(d, "SIGPROF", x); Py_XDECREF(x); #endif #ifdef SIGXCPU - x = PyInt_FromLong(SIGXCPU); + x = PyLong_FromLong(SIGXCPU); PyDict_SetItemString(d, "SIGXCPU", x); Py_XDECREF(x); #endif #ifdef SIGXFSZ - x = PyInt_FromLong(SIGXFSZ); + x = PyLong_FromLong(SIGXFSZ); PyDict_SetItemString(d, "SIGXFSZ", x); Py_XDECREF(x); #endif #ifdef SIGRTMIN - x = PyInt_FromLong(SIGRTMIN); + x = PyLong_FromLong(SIGRTMIN); PyDict_SetItemString(d, "SIGRTMIN", x); Py_XDECREF(x); #endif #ifdef SIGRTMAX - x = PyInt_FromLong(SIGRTMAX); + x = PyLong_FromLong(SIGRTMAX); PyDict_SetItemString(d, "SIGRTMAX", x); Py_XDECREF(x); #endif #ifdef SIGINFO - x = PyInt_FromLong(SIGINFO); + x = PyLong_FromLong(SIGINFO); PyDict_SetItemString(d, "SIGINFO", x); Py_XDECREF(x); #endif Modified: python/branches/py3k/Modules/socketmodule.c ============================================================================== --- python/branches/py3k/Modules/socketmodule.c (original) +++ python/branches/py3k/Modules/socketmodule.c Sun Dec 2 15:31:20 2007 @@ -1508,7 +1508,7 @@ { int block; - block = PyInt_AsLong(arg); + block = PyLong_AsLong(arg); if (block == -1 && PyErr_Occurred()) return NULL; @@ -1649,7 +1649,7 @@ (void *)&flag, &flagsize); if (res < 0) return s->errorhandler(); - return PyInt_FromLong(flag); + return PyLong_FromLong(flag); } #ifdef __VMS /* socklen_t is unsigned so no negative test is needed, @@ -1874,7 +1874,7 @@ return NULL; #endif - return PyInt_FromLong((long) res); + return PyLong_FromLong((long) res); } PyDoc_STRVAR(connect_ex_doc, @@ -1965,7 +1965,7 @@ int backlog; int res; - backlog = PyInt_AsLong(arg); + backlog = PyLong_AsLong(arg); if (backlog == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -2167,7 +2167,7 @@ /* Return the number of bytes read. Note that we do not do anything special here in the case that readlen < recvlen. */ - return PyInt_FromSsize_t(readlen); + return PyLong_FromSsize_t(readlen); } PyDoc_STRVAR(recv_into_doc, @@ -2375,7 +2375,7 @@ } if (n < 0) return s->errorhandler(); - return PyInt_FromLong((long)n); + return PyLong_FromLong((long)n); } PyDoc_STRVAR(send_doc, @@ -2474,7 +2474,7 @@ } if (n < 0) return s->errorhandler(); - return PyInt_FromLong((long)n); + return PyLong_FromLong((long)n); } PyDoc_STRVAR(sendto_doc, @@ -2492,7 +2492,7 @@ int how; int res; - how = PyInt_AsLong(arg); + how = PyLong_AsLong(arg); if (how == -1 && PyErr_Occurred()) return NULL; Py_BEGIN_ALLOW_THREADS @@ -3071,7 +3071,7 @@ PyErr_SetString(socket_error, "service/proto not found"); return NULL; } - return PyInt_FromLong((long) ntohs(sp->s_port)); + return PyLong_FromLong((long) ntohs(sp->s_port)); } PyDoc_STRVAR(getservbyname_doc, @@ -3131,7 +3131,7 @@ PyErr_SetString(socket_error, "protocol not found"); return NULL; } - return PyInt_FromLong((long) sp->p_proto); + return PyLong_FromLong((long) sp->p_proto); } PyDoc_STRVAR(getprotobyname_doc, @@ -3242,7 +3242,7 @@ return NULL; } x2 = (unsigned int)ntohs((unsigned short)x1); - return PyInt_FromLong(x2); + return PyLong_FromLong(x2); } PyDoc_STRVAR(ntohs_doc, @@ -3301,7 +3301,7 @@ return NULL; } x2 = (unsigned int)htons((unsigned short)x1); - return PyInt_FromLong(x2); + return PyLong_FromLong(x2); } PyDoc_STRVAR(htons_doc, @@ -3596,7 +3596,7 @@ return NULL; } if (PyInt_CheckExact(pobj)) { - PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyInt_AsLong(pobj)); + PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyLong_AsLong(pobj)); pptr = pbuf; } else if (PyUnicode_Check(pobj)) { pptr = PyUnicode_AsString(pobj); Modified: python/branches/py3k/Modules/spwdmodule.c ============================================================================== --- python/branches/py3k/Modules/spwdmodule.c (original) +++ python/branches/py3k/Modules/spwdmodule.c Sun Dec 2 15:31:20 2007 @@ -74,7 +74,7 @@ if (v == NULL) return NULL; -#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) +#define SETI(i,val) PyStructSequence_SET_ITEM(v, i, PyLong_FromLong((long) val)) #define SETS(i,val) sets(v, i, val) SETS(setIndex++, p->sp_namp); Modified: python/branches/py3k/Modules/syslogmodule.c ============================================================================== --- python/branches/py3k/Modules/syslogmodule.c (original) +++ python/branches/py3k/Modules/syslogmodule.c Sun Dec 2 15:31:20 2007 @@ -123,7 +123,7 @@ if (!PyArg_ParseTuple(args, "l;mask for priority", &maskpri)) return NULL; omaskpri = setlogmask(maskpri); - return PyInt_FromLong(omaskpri); + return PyLong_FromLong(omaskpri); } static PyObject * @@ -134,7 +134,7 @@ if (!PyArg_ParseTuple(args, "l:LOG_MASK", &pri)) return NULL; mask = LOG_MASK(pri); - return PyInt_FromLong(mask); + return PyLong_FromLong(mask); } static PyObject * @@ -145,7 +145,7 @@ if (!PyArg_ParseTuple(args, "l:LOG_UPTO", &pri)) return NULL; mask = LOG_UPTO(pri); - return PyInt_FromLong(mask); + return PyLong_FromLong(mask); } /* List of functions defined in the module */ Modified: python/branches/py3k/Modules/termios.c ============================================================================== --- python/branches/py3k/Modules/termios.c (original) +++ python/branches/py3k/Modules/termios.c Sun Dec 2 15:31:20 2007 @@ -101,11 +101,11 @@ MIN and TIME slots are the same as the EOF and EOL slots. So we only do this in noncanonical input mode. */ if ((mode.c_lflag & ICANON) == 0) { - v = PyInt_FromLong((long)mode.c_cc[VMIN]); + v = PyLong_FromLong((long)mode.c_cc[VMIN]); if (v == NULL) goto err; PyList_SetItem(cc, VMIN, v); - v = PyInt_FromLong((long)mode.c_cc[VTIME]); + v = PyLong_FromLong((long)mode.c_cc[VTIME]); if (v == NULL) goto err; PyList_SetItem(cc, VTIME, v); @@ -114,12 +114,12 @@ if (!(v = PyList_New(7))) goto err; - PyList_SetItem(v, 0, PyInt_FromLong((long)mode.c_iflag)); - PyList_SetItem(v, 1, PyInt_FromLong((long)mode.c_oflag)); - PyList_SetItem(v, 2, PyInt_FromLong((long)mode.c_cflag)); - PyList_SetItem(v, 3, PyInt_FromLong((long)mode.c_lflag)); - PyList_SetItem(v, 4, PyInt_FromLong((long)ispeed)); - PyList_SetItem(v, 5, PyInt_FromLong((long)ospeed)); + PyList_SetItem(v, 0, PyLong_FromLong((long)mode.c_iflag)); + PyList_SetItem(v, 1, PyLong_FromLong((long)mode.c_oflag)); + PyList_SetItem(v, 2, PyLong_FromLong((long)mode.c_cflag)); + PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag)); + PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed)); + PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed)); PyList_SetItem(v, 6, cc); if (PyErr_Occurred()){ Py_DECREF(v); @@ -163,12 +163,12 @@ /* Get the old mode, in case there are any hidden fields... */ if (tcgetattr(fd, &mode) == -1) return PyErr_SetFromErrno(TermiosError); - mode.c_iflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 0)); - mode.c_oflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 1)); - mode.c_cflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 2)); - mode.c_lflag = (tcflag_t) PyInt_AsLong(PyList_GetItem(term, 3)); - ispeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 4)); - ospeed = (speed_t) PyInt_AsLong(PyList_GetItem(term, 5)); + mode.c_iflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 0)); + mode.c_oflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 1)); + mode.c_cflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 2)); + mode.c_lflag = (tcflag_t) PyLong_AsLong(PyList_GetItem(term, 3)); + ispeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 4)); + ospeed = (speed_t) PyLong_AsLong(PyList_GetItem(term, 5)); cc = PyList_GetItem(term, 6); if (PyErr_Occurred()) return NULL; @@ -185,8 +185,8 @@ if (PyString_Check(v) && PyString_Size(v) == 1) mode.c_cc[i] = (cc_t) * PyString_AsString(v); - else if (PyInt_Check(v)) - mode.c_cc[i] = (cc_t) PyInt_AsLong(v); + else if (PyLong_Check(v)) + mode.c_cc[i] = (cc_t) PyLong_AsLong(v); else { PyErr_SetString(PyExc_TypeError, "tcsetattr: elements of attributes must be characters or integers"); Modified: python/branches/py3k/Modules/threadmodule.c ============================================================================== --- python/branches/py3k/Modules/threadmodule.c (original) +++ python/branches/py3k/Modules/threadmodule.c Sun Dec 2 15:31:20 2007 @@ -493,7 +493,7 @@ PyMem_DEL(boot); return NULL; } - return PyInt_FromLong(ident); + return PyLong_FromLong(ident); } PyDoc_STRVAR(start_new_doc, @@ -571,7 +571,7 @@ PyErr_SetString(ThreadError, "no current thread ident"); return NULL; } - return PyInt_FromLong(ident); + return PyLong_FromLong(ident); } PyDoc_STRVAR(get_ident_doc, @@ -616,7 +616,7 @@ return NULL; } - return PyInt_FromSsize_t((Py_ssize_t) old_size); + return PyLong_FromSsize_t((Py_ssize_t) old_size); } PyDoc_STRVAR(stack_size_doc, Modified: python/branches/py3k/Modules/timemodule.c ============================================================================== --- python/branches/py3k/Modules/timemodule.c (original) +++ python/branches/py3k/Modules/timemodule.c Sun Dec 2 15:31:20 2007 @@ -237,7 +237,7 @@ if (v == NULL) return NULL; -#define SET(i,val) PyStructSequence_SET_ITEM(v, i, PyInt_FromLong((long) val)) +#define SET(i,val) PyStructSequence_SET_ITEM(v, i, PyLong_FromLong((long) val)) SET(0, p->tm_year + 1900); SET(1, p->tm_mon + 1); /* Want January == 1 */ @@ -393,7 +393,7 @@ PyObject *accept = PyDict_GetItemString(moddict, "accept2dyear"); if (accept == NULL || !PyInt_CheckExact(accept) || - PyInt_AsLong(accept) == 0) { + PyLong_AsLong(accept) == 0) { PyErr_SetString(PyExc_ValueError, "year >= 1900 required"); return 0; Modified: python/branches/py3k/Modules/unicodedata.c ============================================================================== --- python/branches/py3k/Modules/unicodedata.c (original) +++ python/branches/py3k/Modules/unicodedata.c Sun Dec 2 15:31:20 2007 @@ -143,7 +143,7 @@ return defobj; } } - return PyInt_FromLong(rc); + return PyLong_FromLong(rc); } PyDoc_STRVAR(unicodedata_digit__doc__, @@ -178,7 +178,7 @@ return defobj; } } - return PyInt_FromLong(rc); + return PyLong_FromLong(rc); } PyDoc_STRVAR(unicodedata_numeric__doc__, @@ -320,7 +320,7 @@ if (old->category_changed == 0) index = 0; /* unassigned */ } - return PyInt_FromLong(index); + return PyLong_FromLong(index); } PyDoc_STRVAR(unicodedata_mirrored__doc__, @@ -350,7 +350,7 @@ if (old->category_changed == 0) index = 0; /* unassigned */ } - return PyInt_FromLong(index); + return PyLong_FromLong(index); } PyDoc_STRVAR(unicodedata_east_asian_width__doc__, Modified: python/branches/py3k/Modules/xxmodule.c ============================================================================== --- python/branches/py3k/Modules/xxmodule.c (original) +++ python/branches/py3k/Modules/xxmodule.c Sun Dec 2 15:31:20 2007 @@ -156,7 +156,7 @@ if (!PyArg_ParseTuple(args, "ll:foo", &i, &j)) return NULL; res = i+j; /* XXX Do something here */ - return PyInt_FromLong(res); + return PyLong_FromLong(res); } @@ -187,7 +187,7 @@ item = PyList_GetItem(list, 0); /* Py_INCREF(item); */ - PyList_SetItem(list, 1, PyInt_FromLong(0L)); + PyList_SetItem(list, 1, PyLong_FromLong(0L)); PyObject_Print(item, stdout, 0); printf("\n"); /* Py_DECREF(item); */ Modified: python/branches/py3k/Modules/xxsubtype.c ============================================================================== --- python/branches/py3k/Modules/xxsubtype.c (original) +++ python/branches/py3k/Modules/xxsubtype.c Sun Dec 2 15:31:20 2007 @@ -28,7 +28,7 @@ { if (!PyArg_ParseTuple(args, ":getstate")) return NULL; - return PyInt_FromLong(self->state); + return PyLong_FromLong(self->state); } static PyObject * @@ -91,7 +91,7 @@ static PyObject * spamlist_state_get(spamlistobject *self) { - return PyInt_FromLong(self->state); + return PyLong_FromLong(self->state); } static PyGetSetDef spamlist_getsets[] = { @@ -153,7 +153,7 @@ { if (!PyArg_ParseTuple(args, ":getstate")) return NULL; - return PyInt_FromLong(self->state); + return PyLong_FromLong(self->state); } static PyObject * Modified: python/branches/py3k/Modules/zipimport.c ============================================================================== --- python/branches/py3k/Modules/zipimport.c (original) +++ python/branches/py3k/Modules/zipimport.c Sun Dec 2 15:31:20 2007 @@ -1028,8 +1028,8 @@ /* fetch the time stamp of the .py file for comparison with an embedded pyc time stamp */ int time, date; - time = PyInt_AsLong(PyTuple_GetItem(toc_entry, 5)); - date = PyInt_AsLong(PyTuple_GetItem(toc_entry, 6)); + time = PyLong_AsLong(PyTuple_GetItem(toc_entry, 5)); + date = PyLong_AsLong(PyTuple_GetItem(toc_entry, 6)); mtime = parse_dostime(time, date); } path[lastchar] = savechar; Modified: python/branches/py3k/Modules/zlibmodule.c ============================================================================== --- python/branches/py3k/Modules/zlibmodule.c (original) +++ python/branches/py3k/Modules/zlibmodule.c Sun Dec 2 15:31:20 2007 @@ -922,7 +922,7 @@ if (!PyArg_ParseTuple(args, "s#|k:adler32", &buf, &len, &adler32val)) return NULL; adler32val = adler32(adler32val, buf, len); - return PyInt_FromLong(adler32val); + return PyLong_FromLong(adler32val); } PyDoc_STRVAR(crc32__doc__, @@ -940,7 +940,7 @@ if (!PyArg_ParseTuple(args, "s#|k:crc32", &buf, &len, &crc32val)) return NULL; crc32val = crc32(crc32val, buf, len); - return PyInt_FromLong(crc32val); + return PyLong_FromLong(crc32val); } Modified: python/branches/py3k/Objects/abstract.c ============================================================================== --- python/branches/py3k/Objects/abstract.c (original) +++ python/branches/py3k/Objects/abstract.c Sun Dec 2 15:31:20 2007 @@ -93,7 +93,7 @@ PyErr_Fetch(&err_type, &err_value, &err_tb); ro = PyObject_CallMethod(o, "__length_hint__", NULL); if (ro != NULL) { - rv = PyInt_AsLong(ro); + rv = PyLong_AsLong(ro); Py_DECREF(ro); Py_XDECREF(err_type); Py_XDECREF(err_value); @@ -1188,8 +1188,8 @@ if (value == NULL) return -1; - /* We're done if PyInt_AsSsize_t() returns without error. */ - result = PyInt_AsSsize_t(value); + /* We're done if PyLong_AsSsize_t() returns without error. */ + result = PyLong_AsSsize_t(value); if (result != -1 || !(runerr = PyErr_Occurred())) goto finish; @@ -1413,7 +1413,7 @@ to nb_multiply if o appears to be a sequence. */ if (PySequence_Check(o)) { PyObject *n, *result; - n = PyInt_FromSsize_t(count); + n = PyLong_FromSsize_t(count); if (n == NULL) return NULL; result = binary_op1(o, n, NB_SLOT(nb_multiply)); @@ -1465,7 +1465,7 @@ if (PySequence_Check(o)) { PyObject *n, *result; - n = PyInt_FromSsize_t(count); + n = PyLong_FromSsize_t(count); if (n == NULL) return NULL; result = binary_iop1(o, n, NB_SLOT(nb_inplace_multiply), Modified: python/branches/py3k/Objects/bytesobject.c ============================================================================== --- python/branches/py3k/Objects/bytesobject.c (original) +++ python/branches/py3k/Objects/bytesobject.c Sun Dec 2 15:31:20 2007 @@ -34,8 +34,8 @@ { long face_value; - if (PyInt_Check(arg)) { - face_value = PyInt_AsLong(arg); + if (PyLong_Check(arg)) { + face_value = PyLong_AsLong(arg); if (face_value < 0 || face_value >= 256) { PyErr_SetString(PyExc_ValueError, "byte must be in range(0, 256)"); return 0; @@ -350,7 +350,7 @@ PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; } - return PyInt_FromLong((unsigned char)(self->ob_bytes[i])); + return PyLong_FromLong((unsigned char)(self->ob_bytes[i])); } static PyObject * @@ -369,7 +369,7 @@ PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; } - return PyInt_FromLong((unsigned char)(self->ob_bytes[i])); + return PyLong_FromLong((unsigned char)(self->ob_bytes[i])); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, cur, i; @@ -1091,7 +1091,7 @@ Py_ssize_t result = bytes_find_internal(self, args, +1); if (result == -2) return NULL; - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } PyDoc_STRVAR(count__doc__, @@ -1119,7 +1119,7 @@ _adjust_indices(&start, &end, PyBytes_GET_SIZE(self)); - count_obj = PyInt_FromSsize_t( + count_obj = PyLong_FromSsize_t( stringlib_count(str + start, end - start, vsub.buf, vsub.len) ); PyObject_ReleaseBuffer(sub_obj, &vsub); @@ -1143,7 +1143,7 @@ "subsection not found"); return NULL; } - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -1162,7 +1162,7 @@ Py_ssize_t result = bytes_find_internal(self, args, -1); if (result == -2) return NULL; - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -1182,7 +1182,7 @@ "subsection not found"); return NULL; } - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -2622,7 +2622,7 @@ if (PyBytes_Resize((PyObject *)self, n - 1) < 0) return NULL; - return PyInt_FromLong(value); + return PyLong_FromLong(value); } PyDoc_STRVAR(remove__doc__, @@ -2809,7 +2809,7 @@ static PyObject * bytes_alloc(PyBytesObject *self) { - return PyInt_FromSsize_t(self->ob_alloc); + return PyLong_FromSsize_t(self->ob_alloc); } PyDoc_STRVAR(join_doc, @@ -3161,7 +3161,7 @@ assert(PyBytes_Check(seq)); if (it->it_index < PyBytes_GET_SIZE(seq)) { - item = PyInt_FromLong( + item = PyLong_FromLong( (unsigned char)seq->ob_bytes[it->it_index]); if (item != NULL) ++it->it_index; @@ -3179,7 +3179,7 @@ Py_ssize_t len = 0; if (it->it_seq) len = PyBytes_GET_SIZE(it->it_seq) - it->it_index; - return PyInt_FromSsize_t(len); + return PyLong_FromSsize_t(len); } PyDoc_STRVAR(length_hint_doc, Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Sun Dec 2 15:31:20 2007 @@ -2094,7 +2094,7 @@ Py_ssize_t len = 0; if (di->di_dict != NULL && di->di_used == di->di_dict->ma_used) len = di->len; - return PyInt_FromSize_t(len); + return PyLong_FromSize_t(len); } PyDoc_STRVAR(length_hint_doc, Modified: python/branches/py3k/Objects/enumobject.c ============================================================================== --- python/branches/py3k/Objects/enumobject.c (original) +++ python/branches/py3k/Objects/enumobject.c Sun Dec 2 15:31:20 2007 @@ -67,12 +67,12 @@ PyObject *stepped_up; if (en->en_longindex == NULL) { - en->en_longindex = PyInt_FromLong(LONG_MAX); + en->en_longindex = PyLong_FromLong(LONG_MAX); if (en->en_longindex == NULL) return NULL; } if (one == NULL) { - one = PyInt_FromLong(1); + one = PyLong_FromLong(1); if (one == NULL) return NULL; } @@ -115,7 +115,7 @@ if (en->en_index == LONG_MAX) return enum_next_long(en, next_item); - next_index = PyInt_FromLong(en->en_index); + next_index = PyLong_FromLong(en->en_index); if (next_index == NULL) { Py_DECREF(next_item); return NULL; @@ -279,12 +279,12 @@ Py_ssize_t position, seqsize; if (ro->seq == NULL) - return PyInt_FromLong(0); + return PyLong_FromLong(0); seqsize = PySequence_Size(ro->seq); if (seqsize == -1) return NULL; position = ro->index + 1; - return PyInt_FromSsize_t((seqsize < position) ? 0 : position); + return PyLong_FromSsize_t((seqsize < position) ? 0 : position); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Sun Dec 2 15:31:20 2007 @@ -720,7 +720,7 @@ /* Set errno to the POSIX errno, and winerror to the Win32 error code. */ - errcode = PyInt_AsLong(self->myerrno); + errcode = PyLong_AsLong(self->myerrno); if (errcode == -1 && PyErr_Occurred()) return -1; posix_errno = winerror_to_errno(errcode); @@ -728,7 +728,7 @@ Py_CLEAR(self->winerror); self->winerror = self->myerrno; - o_errcode = PyInt_FromLong(posix_errno); + o_errcode = PyLong_FromLong(posix_errno); if (!o_errcode) return -1; @@ -945,7 +945,7 @@ return PyUnicode_FromFormat("%S (%s, line %ld)", self->msg ? self->msg : Py_None, my_basename(filename), - PyInt_AsLong(self->lineno)); + PyLong_AsLong(self->lineno)); else if (filename) return PyUnicode_FromFormat("%S (%s)", self->msg ? self->msg : Py_None, @@ -953,7 +953,7 @@ else /* only have_lineno */ return PyUnicode_FromFormat("%S (line %ld)", self->msg ? self->msg : Py_None, - PyInt_AsLong(self->lineno)); + PyLong_AsLong(self->lineno)); } static PyMemberDef SyntaxError_members[] = { Modified: python/branches/py3k/Objects/fileobject.c ============================================================================== --- python/branches/py3k/Objects/fileobject.c (original) +++ python/branches/py3k/Objects/fileobject.c Sun Dec 2 15:31:20 2007 @@ -413,7 +413,7 @@ static PyObject * stdprinter_fileno(PyStdPrinter_Object *self) { - return PyInt_FromLong((long) self->fd); + return PyLong_FromLong((long) self->fd); } static PyObject * Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Sun Dec 2 15:31:20 2007 @@ -72,7 +72,7 @@ if (PyDict_SetItemString(d, key, tmp)) return NULL; \ Py_DECREF(tmp) #define SET_INT_CONST(d, key, const) \ - tmp = PyInt_FromLong(const); \ + tmp = PyLong_FromLong(const); \ if (tmp == NULL) return NULL; \ if (PyDict_SetItemString(d, key, tmp)) return NULL; \ Py_DECREF(tmp) @@ -481,7 +481,7 @@ */ PyObject *temp; - one = PyInt_FromLong(1); + one = PyLong_FromLong(1); if (one == NULL) goto Error; @@ -808,7 +808,7 @@ */ if (LONG_MIN < wholepart && wholepart < LONG_MAX) { const long aslong = (long)wholepart; - return PyInt_FromLong(aslong); + return PyLong_FromLong(aslong); } return PyLong_FromDouble(wholepart); } Modified: python/branches/py3k/Objects/frameobject.c ============================================================================== --- python/branches/py3k/Objects/frameobject.c (original) +++ python/branches/py3k/Objects/frameobject.c Sun Dec 2 15:31:20 2007 @@ -44,7 +44,7 @@ else lineno = PyCode_Addr2Line(f->f_code, f->f_lasti); - return PyInt_FromLong(lineno); + return PyLong_FromLong(lineno); } /* Setter for f_lineno - you can set f_lineno from within a trace function in @@ -104,7 +104,7 @@ } /* Fail if the line comes before the start of the code block. */ - new_lineno = (int) PyInt_AsLong(p_new_lineno); + new_lineno = (int) PyLong_AsLong(p_new_lineno); if (new_lineno < f->f_code->co_firstlineno) { PyErr_Format(PyExc_ValueError, "line %d comes before the current code block", Modified: python/branches/py3k/Objects/iterobject.c ============================================================================== --- python/branches/py3k/Objects/iterobject.c (original) +++ python/branches/py3k/Objects/iterobject.c Sun Dec 2 15:31:20 2007 @@ -81,9 +81,9 @@ return NULL; len = seqsize - it->it_index; if (len >= 0) - return PyInt_FromSsize_t(len); + return PyLong_FromSsize_t(len); } - return PyInt_FromLong(0); + return PyLong_FromLong(0); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Sun Dec 2 15:31:20 2007 @@ -931,7 +931,7 @@ Py_DECREF(res); return -1; } - i = PyInt_AsLong(res); + i = PyLong_AsLong(res); Py_DECREF(res); return i < 0; } @@ -2226,7 +2226,7 @@ for (i = start; i < stop && i < Py_Size(self); i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) - return PyInt_FromSsize_t(i); + return PyLong_FromSsize_t(i); else if (cmp < 0) return NULL; } @@ -2247,7 +2247,7 @@ else if (cmp < 0) return NULL; } - return PyInt_FromSsize_t(count); + return PyLong_FromSsize_t(count); } static PyObject * @@ -2823,9 +2823,9 @@ if (it->it_seq) { len = PyList_GET_SIZE(it->it_seq) - it->it_index; if (len >= 0) - return PyInt_FromSsize_t(len); + return PyLong_FromSsize_t(len); } - return PyInt_FromLong(0); + return PyLong_FromLong(0); } /*********************** List Reverse Iterator **************************/ Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Sun Dec 2 15:31:20 2007 @@ -59,7 +59,7 @@ be a small integer, so negating it must go to PyLong_FromLong */ #define NEGATE(x) \ do if (Py_Refcnt(x) == 1) Py_Size(x) = -Py_Size(x); \ - else { PyObject* tmp=PyInt_FromLong(-MEDIUM_VALUE(x)); \ + else { PyObject* tmp=PyLong_FromLong(-MEDIUM_VALUE(x)); \ Py_DECREF(x); (x) = (PyLongObject*)tmp; } \ while(0) /* For long multiplication, use the O(N**2) school algorithm unless @@ -976,7 +976,7 @@ #endif /* special-case null pointer */ if (!p) - return PyInt_FromLong(0); + return PyLong_FromLong(0); return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)(Py_uintptr_t)p); } @@ -2315,7 +2315,7 @@ CHECK_BINOP(a, b); if (ABS(Py_Size(a)) <= 1 && ABS(Py_Size(b)) <= 1) { - PyObject *result = PyInt_FromLong(MEDIUM_VALUE(a) + + PyObject *result = PyLong_FromLong(MEDIUM_VALUE(a) + MEDIUM_VALUE(b)); return result; } Modified: python/branches/py3k/Objects/memoryobject.c ============================================================================== --- python/branches/py3k/Objects/memoryobject.c (original) +++ python/branches/py3k/Objects/memoryobject.c Sun Dec 2 15:31:20 2007 @@ -303,7 +303,7 @@ static PyObject * memory_itemsize_get(PyMemoryViewObject *self) { - return PyInt_FromSsize_t(self->view.itemsize); + return PyLong_FromSsize_t(self->view.itemsize); } static PyObject * @@ -320,7 +320,7 @@ intTuple = PyTuple_New(len); if (!intTuple) return NULL; for(i=0; iview.len); + return PyLong_FromSsize_t(self->view.len); } static PyObject * @@ -363,7 +363,7 @@ static PyObject * memory_ndim_get(PyMemoryViewObject *self) { - return PyInt_FromLong(self->view.ndim); + return PyLong_FromLong(self->view.ndim); } static PyGetSetDef memory_getsetlist[] ={ Modified: python/branches/py3k/Objects/rangeobject.c ============================================================================== --- python/branches/py3k/Objects/rangeobject.c (original) +++ python/branches/py3k/Objects/rangeobject.c Sun Dec 2 15:31:20 2007 @@ -24,7 +24,7 @@ { /* No step specified, use a step of 1. */ if (!step) - return PyInt_FromLong(1); + return PyLong_FromLong(1); step = PyNumber_Index(step); if (step) { @@ -63,8 +63,8 @@ stop = PyNumber_Index(stop); if (!stop) goto Fail; - start = PyInt_FromLong(0); - step = PyInt_FromLong(1); + start = PyLong_FromLong(0); + step = PyLong_FromLong(1); if (!start || !step) goto Fail; } @@ -113,7 +113,7 @@ /* Return number of items in range (lo, hi, step), when arguments are * PyInt or PyLong objects. step > 0 required. Return a value < 0 if * & only if the true value is too large to fit in a signed long. - * Arguments MUST return 1 with either PyInt_Check() or + * Arguments MUST return 1 with either PyLong_Check() or * PyLong_Check(). Return -1 when there is an error. */ static PyObject* @@ -332,14 +332,14 @@ rangeiter_next(rangeiterobject *r) { if (r->index < r->len) - return PyInt_FromLong(r->start + (r->index++) * r->step); + return PyLong_FromLong(r->start + (r->index++) * r->step); return NULL; } static PyObject * rangeiter_len(rangeiterobject *r) { - return PyInt_FromLong(r->len - r->index); + return PyLong_FromLong(r->len - r->index); } typedef struct { Modified: python/branches/py3k/Objects/setobject.c ============================================================================== --- python/branches/py3k/Objects/setobject.c (original) +++ python/branches/py3k/Objects/setobject.c Sun Dec 2 15:31:20 2007 @@ -801,7 +801,7 @@ Py_ssize_t len = 0; if (si->si_set != NULL && si->si_used == si->si_set->used) len = si->len; - return PyInt_FromLong(len); + return PyLong_FromLong(len); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/Objects/sliceobject.c ============================================================================== --- python/branches/py3k/Objects/sliceobject.c (original) +++ python/branches/py3k/Objects/sliceobject.c Sun Dec 2 15:31:20 2007 @@ -83,10 +83,10 @@ _PySlice_FromIndices(Py_ssize_t istart, Py_ssize_t istop) { PyObject *start, *end, *slice; - start = PyInt_FromSsize_t(istart); + start = PyLong_FromSsize_t(istart); if (!start) return NULL; - end = PyInt_FromSsize_t(istop); + end = PyLong_FromSsize_t(istop); if (!end) { Py_DECREF(start); return NULL; @@ -107,20 +107,20 @@ *step = 1; } else { if (!PyLong_Check(r->step)) return -1; - *step = PyInt_AsSsize_t(r->step); + *step = PyLong_AsSsize_t(r->step); } if (r->start == Py_None) { *start = *step < 0 ? length-1 : 0; } else { - if (!PyInt_Check(r->start)) return -1; - *start = PyInt_AsSsize_t(r->start); + if (!PyLong_Check(r->start)) return -1; + *start = PyLong_AsSsize_t(r->start); if (*start < 0) *start += length; } if (r->stop == Py_None) { *stop = *step < 0 ? -1 : length; } else { - if (!PyInt_Check(r->stop)) return -1; - *stop = PyInt_AsSsize_t(r->stop); + if (!PyLong_Check(r->stop)) return -1; + *stop = PyLong_AsSsize_t(r->stop); if (*stop < 0) *stop += length; } if (*stop > length) return -1; Modified: python/branches/py3k/Objects/stringlib/formatter.h ============================================================================== --- python/branches/py3k/Objects/stringlib/formatter.h (original) +++ python/branches/py3k/Objects/stringlib/formatter.h Sun Dec 2 15:31:20 2007 @@ -469,7 +469,7 @@ /* taken from unicodeobject.c formatchar() */ /* Integer input truncated to a character */ - x = PyInt_AsLong(value); + x = PyLong_AsLong(value); if (x == -1 && PyErr_Occurred()) goto done; #ifdef Py_UNICODE_WIDE Modified: python/branches/py3k/Objects/stringlib/string_format.h ============================================================================== --- python/branches/py3k/Objects/stringlib/string_format.h (original) +++ python/branches/py3k/Objects/stringlib/string_format.h Sun Dec 2 15:31:20 2007 @@ -204,7 +204,7 @@ getitem_idx(PyObject *obj, Py_ssize_t idx) { PyObject *newobj; - PyObject *idx_obj = PyInt_FromSsize_t(idx); + PyObject *idx_obj = PyLong_FromSsize_t(idx); if (idx_obj == NULL) return NULL; newobj = PyObject_GetItem(obj, idx_obj); @@ -1160,7 +1160,7 @@ /* either an integer or a string */ if (idx != -1) - obj = PyInt_FromSsize_t(idx); + obj = PyLong_FromSsize_t(idx); else obj = SubString_new_object(&name); if (obj == NULL) @@ -1245,7 +1245,7 @@ /* first becomes an integer, if possible; else a string */ if (first_idx != -1) - first_obj = PyInt_FromSsize_t(first_idx); + first_obj = PyLong_FromSsize_t(first_idx); else /* convert "first" into a string object */ first_obj = SubString_new_object(&first); Modified: python/branches/py3k/Objects/stringobject.c ============================================================================== --- python/branches/py3k/Objects/stringobject.c (original) +++ python/branches/py3k/Objects/stringobject.c Sun Dec 2 15:31:20 2007 @@ -803,7 +803,7 @@ PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } - return PyInt_FromLong((unsigned char)a->ob_sval[i]); + return PyLong_FromLong((unsigned char)a->ob_sval[i]); } static PyObject* @@ -922,7 +922,7 @@ "string index out of range"); return NULL; } - return PyInt_FromLong((unsigned char)self->ob_sval[i]); + return PyLong_FromLong((unsigned char)self->ob_sval[i]); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, cur, i; @@ -1586,7 +1586,7 @@ Py_ssize_t result = string_find_internal(self, args, +1); if (result == -2) return NULL; - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -1606,7 +1606,7 @@ "substring not found"); return NULL; } - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -1625,7 +1625,7 @@ Py_ssize_t result = string_find_internal(self, args, -1); if (result == -2) return NULL; - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -1645,7 +1645,7 @@ "substring not found"); return NULL; } - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } @@ -1808,7 +1808,7 @@ string_adjust_indices(&start, &end, PyString_GET_SIZE(self)); - return PyInt_FromSsize_t( + return PyLong_FromSsize_t( stringlib_count(str + start, end - start, sub, sub_len) ); } @@ -3332,7 +3332,7 @@ assert(PyString_Check(seq)); if (it->it_index < PyString_GET_SIZE(seq)) { - item = PyInt_FromLong( + item = PyLong_FromLong( (unsigned char)seq->ob_sval[it->it_index]); if (item != NULL) ++it->it_index; @@ -3350,7 +3350,7 @@ Py_ssize_t len = 0; if (it->it_seq) len = PyString_GET_SIZE(it->it_seq) - it->it_index; - return PyInt_FromSsize_t(len); + return PyLong_FromSsize_t(len); } PyDoc_STRVAR(length_hint_doc, Modified: python/branches/py3k/Objects/structseq.c ============================================================================== --- python/branches/py3k/Objects/structseq.c (original) +++ python/branches/py3k/Objects/structseq.c Sun Dec 2 15:31:20 2007 @@ -14,14 +14,14 @@ char *PyStructSequence_UnnamedField = "unnamed field"; #define VISIBLE_SIZE(op) Py_Size(op) -#define VISIBLE_SIZE_TP(tp) PyInt_AsLong( \ +#define VISIBLE_SIZE_TP(tp) PyLong_AsLong( \ PyDict_GetItemString((tp)->tp_dict, visible_length_key)) -#define REAL_SIZE_TP(tp) PyInt_AsLong( \ +#define REAL_SIZE_TP(tp) PyLong_AsLong( \ PyDict_GetItemString((tp)->tp_dict, real_length_key)) #define REAL_SIZE(op) REAL_SIZE_TP(Py_Type(op)) -#define UNNAMED_FIELDS_TP(tp) PyInt_AsLong( \ +#define UNNAMED_FIELDS_TP(tp) PyLong_AsLong( \ PyDict_GetItemString((tp)->tp_dict, unnamed_fields_key)) #define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_Type(op)) @@ -451,9 +451,9 @@ dict = type->tp_dict; PyDict_SetItemString(dict, visible_length_key, - PyInt_FromLong((long) desc->n_in_sequence)); + PyLong_FromLong((long) desc->n_in_sequence)); PyDict_SetItemString(dict, real_length_key, - PyInt_FromLong((long) n_members)); + PyLong_FromLong((long) n_members)); PyDict_SetItemString(dict, unnamed_fields_key, - PyInt_FromLong((long) n_unnamed_members)); + PyLong_FromLong((long) n_unnamed_members)); } Modified: python/branches/py3k/Objects/tupleobject.c ============================================================================== --- python/branches/py3k/Objects/tupleobject.c (original) +++ python/branches/py3k/Objects/tupleobject.c Sun Dec 2 15:31:20 2007 @@ -828,7 +828,7 @@ Py_ssize_t len = 0; if (it->it_seq) len = PyTuple_GET_SIZE(it->it_seq) - it->it_index; - return PyInt_FromSsize_t(len); + return PyLong_FromSsize_t(len); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/Objects/typeobject.c ============================================================================== --- python/branches/py3k/Objects/typeobject.c (original) +++ python/branches/py3k/Objects/typeobject.c Sun Dec 2 15:31:20 2007 @@ -3623,7 +3623,7 @@ res = (*func)(self); if (res == -1 && PyErr_Occurred()) return NULL; - return PyInt_FromLong((long)res); + return PyLong_FromLong((long)res); } static PyObject * @@ -3887,7 +3887,7 @@ res = (*func)(self, other); if (PyErr_Occurred()) return NULL; - return PyInt_FromLong((long)res); + return PyLong_FromLong((long)res); } /* Helper to check for object.__setattr__ or __delattr__ applied to a type. @@ -3958,7 +3958,7 @@ res = (*func)(self); if (res == -1 && PyErr_Occurred()) return NULL; - return PyInt_FromLong(res); + return PyLong_FromLong(res); } static PyObject * @@ -4270,7 +4270,7 @@ if (res == NULL) return -1; - len = PyInt_AsSsize_t(res); + len = PyLong_AsSsize_t(res); Py_DECREF(res); if (len < 0) { if (!PyErr_Occurred()) @@ -4305,7 +4305,7 @@ return NULL; } } - ival = PyInt_FromSsize_t(i); + ival = PyLong_FromSsize_t(i); if (ival != NULL) { args = PyTuple_New(1); if (args != NULL) { @@ -4538,7 +4538,7 @@ if (res != Py_NotImplemented) { if (res == NULL) return -2; - c = PyInt_AsLong(res); + c = PyLong_AsLong(res); Py_DECREF(res); if (c == -1 && PyErr_Occurred()) return -2; @@ -4639,7 +4639,7 @@ if (PyLong_Check(res)) h = PyLong_Type.tp_hash(res); else - h = PyInt_AsLong(res); + h = PyLong_AsLong(res); Py_DECREF(res); if (h == -1 && !PyErr_Occurred()) h = -2; Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Sun Dec 2 15:31:20 2007 @@ -3980,7 +3980,7 @@ PyObject *w, *x; /* Get mapping (char ordinal -> integer, Unicode char or None) */ - w = PyInt_FromLong((long)ch); + w = PyLong_FromLong((long)ch); if (w == NULL) goto onError; x = PyObject_GetItem(mapping, w); @@ -3996,8 +3996,8 @@ } /* Apply mapping */ - if (PyInt_Check(x)) { - long value = PyInt_AS_LONG(x); + if (PyLong_Check(x)) { + long value = PyLong_AS_LONG(x); if (value < 0 || value > 65535) { PyErr_SetString(PyExc_TypeError, "character mapping must be in range(65536)"); @@ -4091,7 +4091,7 @@ encoding_map_size(PyObject *obj, PyObject* args) { struct encoding_map *map = (struct encoding_map*)obj; - return PyInt_FromLong(sizeof(*map) - 1 + 16*map->count2 + + return PyLong_FromLong(sizeof(*map) - 1 + 16*map->count2 + 128*map->count3); } @@ -4208,8 +4208,8 @@ return NULL; for (i = 0; i < 256; i++) { key = value = NULL; - key = PyInt_FromLong(decode[i]); - value = PyInt_FromLong(i); + key = PyLong_FromLong(decode[i]); + value = PyLong_FromLong(i); if (!key || !value) goto failed1; if (PyDict_SetItem(result, key, value) == -1) @@ -4297,7 +4297,7 @@ error occurred). */ static PyObject *charmapencode_lookup(Py_UNICODE c, PyObject *mapping) { - PyObject *w = PyInt_FromLong((long)c); + PyObject *w = PyLong_FromLong((long)c); PyObject *x; if (w == NULL) @@ -4316,8 +4316,8 @@ } else if (x == Py_None) return x; - else if (PyInt_Check(x)) { - long value = PyInt_AS_LONG(x); + else if (PyLong_Check(x)) { + long value = PyLong_AS_LONG(x); if (value < 0 || value > 255) { PyErr_SetString(PyExc_TypeError, "character mapping must be in range(256)"); @@ -4387,7 +4387,7 @@ Py_DECREF(rep); return enc_FAILED; } else { - if (PyInt_Check(rep)) { + if (PyLong_Check(rep)) { Py_ssize_t requiredsize = *outpos+1; if (outsize max) { PyErr_Format(PyExc_TypeError, @@ -4790,9 +4790,9 @@ } else if (*res==Py_None) ; - else if (PyInt_Check(*res)) { + else if (PyLong_Check(*res)) { /* no overflow check, because we know that the space is enough */ - *(*outp)++ = (Py_UNICODE)PyInt_AS_LONG(*res); + *(*outp)++ = (Py_UNICODE)PyLong_AS_LONG(*res); } else if (PyUnicode_Check(*res)) { Py_ssize_t repsize = PyUnicode_GET_SIZE(*res); @@ -6469,7 +6469,7 @@ FIX_START_END(self); - result = PyInt_FromSsize_t( + result = PyLong_FromSsize_t( stringlib_count(self->str + start, end - start, substring->str, substring->length) ); @@ -6622,7 +6622,7 @@ Py_DECREF(substring); - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } static PyObject * @@ -6688,7 +6688,7 @@ return NULL; } - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } PyDoc_STRVAR(islower__doc__, @@ -7514,7 +7514,7 @@ Py_DECREF(substring); - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } PyDoc_STRVAR(rindex__doc__, @@ -7545,7 +7545,7 @@ PyErr_SetString(PyExc_ValueError, "substring not found"); return NULL; } - return PyInt_FromSsize_t(result); + return PyLong_FromSsize_t(result); } PyDoc_STRVAR(rjust__doc__, @@ -7833,8 +7833,8 @@ } /* create entries for translating chars in x to those in y */ for (i = 0; i < PyUnicode_GET_SIZE(x); i++) { - key = PyInt_FromLong(PyUnicode_AS_UNICODE(x)[i]); - value = PyInt_FromLong(PyUnicode_AS_UNICODE(y)[i]); + key = PyLong_FromLong(PyUnicode_AS_UNICODE(x)[i]); + value = PyLong_FromLong(PyUnicode_AS_UNICODE(y)[i]); if (!key || !value) goto err; res = PyDict_SetItem(new, key, value); @@ -7846,7 +7846,7 @@ /* create entries for deleting chars in z */ if (z != NULL) { for (i = 0; i < PyUnicode_GET_SIZE(z); i++) { - key = PyInt_FromLong(PyUnicode_AS_UNICODE(z)[i]); + key = PyLong_FromLong(PyUnicode_AS_UNICODE(z)[i]); if (!key) goto err; res = PyDict_SetItem(new, key, Py_None); @@ -7872,14 +7872,14 @@ "table must be of length 1"); goto err; } - newkey = PyInt_FromLong(PyUnicode_AS_UNICODE(key)[0]); + newkey = PyLong_FromLong(PyUnicode_AS_UNICODE(key)[0]); if (!newkey) goto err; res = PyDict_SetItem(new, newkey, value); Py_DECREF(newkey); if (res < 0) goto err; - } else if (PyInt_Check(key)) { + } else if (PyLong_Check(key)) { /* just keep integer keys */ if (PyDict_SetItem(new, key, value) < 0) goto err; @@ -7970,7 +7970,7 @@ static PyObject* unicode_freelistsize(PyUnicodeObject *self) { - return PyInt_FromLong(unicode_freelist_size); + return PyLong_FromLong(unicode_freelist_size); } #endif @@ -8368,7 +8368,7 @@ char *sign; long x; - x = PyInt_AsLong(v); + x = PyLong_AsLong(v); if (x == -1 && PyErr_Occurred()) return -1; if (x < 0 && type == 'u') { @@ -8441,7 +8441,7 @@ else { /* Integer input truncated to a character */ long x; - x = PyInt_AsLong(v); + x = PyLong_AsLong(v); if (x == -1 && PyErr_Occurred()) goto onError; #ifdef Py_UNICODE_WIDE @@ -8613,12 +8613,12 @@ v = getnextarg(args, arglen, &argidx); if (v == NULL) goto onError; - if (!PyInt_Check(v)) { + if (!PyLong_Check(v)) { PyErr_SetString(PyExc_TypeError, "* wants int"); goto onError; } - width = PyInt_AsLong(v); + width = PyLong_AsLong(v); if (width == -1 && PyErr_Occurred()) goto onError; if (width < 0) { @@ -8650,12 +8650,12 @@ v = getnextarg(args, arglen, &argidx); if (v == NULL) goto onError; - if (!PyInt_Check(v)) { + if (!PyLong_Check(v)) { PyErr_SetString(PyExc_TypeError, "* wants int"); goto onError; } - prec = PyInt_AsLong(v); + prec = PyLong_AsLong(v); if (prec == -1 && PyErr_Occurred()) goto onError; if (prec < 0) @@ -9250,7 +9250,7 @@ Py_ssize_t len = 0; if (it->it_seq) len = PyUnicode_GET_SIZE(it->it_seq) - it->it_index; - return PyInt_FromSsize_t(len); + return PyLong_FromSsize_t(len); } PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); Modified: python/branches/py3k/PC/_msi.c ============================================================================== --- python/branches/py3k/PC/_msi.c (original) +++ python/branches/py3k/PC/_msi.c Sun Dec 2 15:31:20 2007 @@ -335,7 +335,7 @@ static PyObject* record_getfieldcount(msiobj* record, PyObject* args) { - return PyInt_FromLong(MsiRecordGetFieldCount(record->h)); + return PyLong_FromLong(MsiRecordGetFieldCount(record->h)); } static PyObject* @@ -502,7 +502,7 @@ switch(type) { case VT_I2: case VT_I4: - return PyInt_FromLong(ival); + return PyLong_FromLong(ival); case VT_FILETIME: PyErr_SetString(PyExc_NotImplementedError, "FILETIME result"); return NULL; @@ -526,7 +526,7 @@ if (status != ERROR_SUCCESS) return msierror(status); - return PyInt_FromLong(result); + return PyLong_FromLong(result); } static PyObject* @@ -544,7 +544,7 @@ 0, NULL, PyString_AsString(data)); } else if (PyInt_CheckExact(data)) { status = MsiSummaryInfoSetProperty(si->h, field, VT_I4, - PyInt_AsLong(data), NULL, NULL); + PyLong_AsLong(data), NULL, NULL); } else { PyErr_SetString(PyExc_TypeError, "unsupported type"); return NULL; Modified: python/branches/py3k/PC/_subprocess.c ============================================================================== --- python/branches/py3k/PC/_subprocess.c (original) +++ python/branches/py3k/PC/_subprocess.c Sun Dec 2 15:31:20 2007 @@ -79,7 +79,7 @@ self->handle = NULL; /* note: return the current handle, as an integer */ - return PyInt_FromLong((long) handle); + return PyLong_FromLong((long) handle); } static PyObject* @@ -119,7 +119,7 @@ static PyObject* sp_handle_as_int(sp_handle_object* self) { - return PyInt_FromLong((long) self->handle); + return PyLong_FromLong((long) self->handle); } static PyNumberMethods sp_handle_as_number; @@ -164,7 +164,7 @@ } /* note: returns integer, not handle object */ - return PyInt_FromLong((long) handle); + return PyLong_FromLong((long) handle); } static PyObject * @@ -253,7 +253,7 @@ PyErr_Clear(); /* FIXME: propagate error? */ return 0; } - ret = (int) PyInt_AsLong(value); + ret = (int) PyLong_AsLong(value); Py_DECREF(value); return ret; } @@ -462,7 +462,7 @@ if (! result) return PyErr_SetFromWindowsErr(GetLastError()); - return PyInt_FromLong(exit_code); + return PyLong_FromLong(exit_code); } static PyObject * @@ -484,7 +484,7 @@ if (result == WAIT_FAILED) return PyErr_SetFromWindowsErr(GetLastError()); - return PyInt_FromLong((int) result); + return PyLong_FromLong((int) result); } static PyObject * @@ -493,7 +493,7 @@ if (! PyArg_ParseTuple(args, ":GetVersion")) return NULL; - return PyInt_FromLong((int) GetVersion()); + return PyLong_FromLong((int) GetVersion()); } static PyObject * @@ -534,7 +534,7 @@ static void defint(PyObject* d, const char* name, int value) { - PyObject* v = PyInt_FromLong((long) value); + PyObject* v = PyLong_FromLong((long) value); if (v) { PyDict_SetItemString(d, (char*) name, v); Py_DECREF(v); Modified: python/branches/py3k/PC/_winreg.c ============================================================================== --- python/branches/py3k/PC/_winreg.c (original) +++ python/branches/py3k/PC/_winreg.c Sun Dec 2 15:31:20 2007 @@ -614,8 +614,8 @@ ok = PyHKEY_Close(obHandle); } #if SIZEOF_LONG >= SIZEOF_HKEY - else if (PyInt_Check(obHandle)) { - long rc = RegCloseKey((HKEY)PyInt_AsLong(obHandle)); + else if (PyLong_Check(obHandle)) { + long rc = RegCloseKey((HKEY)PyLong_AsLong(obHandle)); ok = (rc == ERROR_SUCCESS); if (!ok) PyErr_SetFromWindowsErrWithFunction(rc, "RegCloseKey"); @@ -810,9 +810,9 @@ switch (typ) { case REG_DWORD: if (retDataSize == 0) - obData = PyInt_FromLong(0); + obData = PyLong_FromLong(0); else - obData = PyInt_FromLong(*(int *)retDataBuf); + obData = PyLong_FromLong(*(int *)retDataBuf); break; case REG_SZ: case REG_EXPAND_SZ: @@ -1362,7 +1362,7 @@ static void insint(PyObject * d, char * name, long value) { - PyObject *v = PyInt_FromLong(value); + PyObject *v = PyLong_FromLong(value); if (!v || PyDict_SetItemString(d, name, v)) PyErr_Clear(); Py_XDECREF(v); Modified: python/branches/py3k/PC/msvcrtmodule.c ============================================================================== --- python/branches/py3k/PC/msvcrtmodule.c (original) +++ python/branches/py3k/PC/msvcrtmodule.c Sun Dec 2 15:31:20 2007 @@ -74,7 +74,7 @@ if (flags == -1) return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(flags); + return PyLong_FromLong(flags); } // Convert an OS file handle to a C runtime file descriptor. @@ -92,7 +92,7 @@ if (fd == -1) return PyErr_SetFromErrno(PyExc_IOError); - return PyInt_FromLong(fd); + return PyLong_FromLong(fd); } // Convert a C runtime file descriptor to an OS file handle. @@ -126,7 +126,7 @@ return NULL; ok = _kbhit(); - return PyInt_FromLong(ok); + return PyLong_FromLong(ok); } static PyObject * @@ -192,7 +192,7 @@ static void insertint(PyObject *d, char *name, int value) { - PyObject *v = PyInt_FromLong((long) value); + PyObject *v = PyLong_FromLong((long) value); if (v == NULL) { /* Don't bother reporting this error */ PyErr_Clear(); @@ -214,7 +214,7 @@ if (!PyArg_ParseTuple(args, "ii", &type, &file)) return NULL; res = _CrtSetReportFile(type, (_HFILE)file); - return PyInt_FromLong((long)res); + return PyLong_FromLong((long)res); Py_INCREF(Py_None); return Py_None; } Modified: python/branches/py3k/Python/Python-ast.c ============================================================================== --- python/branches/py3k/Python/Python-ast.c (original) +++ python/branches/py3k/Python/Python-ast.c Sun Dec 2 15:31:20 2007 @@ -464,7 +464,7 @@ static PyObject* ast2obj_int(long b) { - return PyInt_FromLong(b); + return PyLong_FromLong(b); } static int init_types(void) Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Sun Dec 2 15:31:20 2007 @@ -110,7 +110,7 @@ if (!errstr) return; Py_INCREF(errstr); - lineno = PyInt_AsLong(PyTuple_GetItem(value, 1)); + lineno = PyLong_AsLong(PyTuple_GetItem(value, 1)); if (lineno == -1) { Py_DECREF(errstr); return; @@ -3074,7 +3074,7 @@ if (*end == '\0') { if (errno != 0) return PyLong_FromString((char *)s, (char **)0, 0); - return PyInt_FromLong(x); + return PyLong_FromLong(x); } /* XXX Huge floats may silently fail */ #ifndef WITHOUT_COMPLEX Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Sun Dec 2 15:31:20 2007 @@ -378,7 +378,7 @@ return NULL; if (PyObject_Cmp(a, b, &c) < 0) return NULL; - return PyInt_FromLong((long)c); + return PyLong_FromLong((long)c); } PyDoc_STRVAR(cmp_doc, @@ -890,7 +890,7 @@ x = PyObject_Hash(v); if (x == -1) return NULL; - return PyInt_FromLong(x); + return PyLong_FromLong(x); } PyDoc_STRVAR(hash_doc, @@ -946,7 +946,7 @@ res = PyObject_Size(v); if (res < 0 && PyErr_Occurred()) return NULL; - return PyInt_FromSsize_t(res); + return PyLong_FromSsize_t(res); } PyDoc_STRVAR(len_doc, @@ -1105,14 +1105,14 @@ size = PyString_GET_SIZE(obj); if (size == 1) { ord = (long)((unsigned char)*PyString_AS_STRING(obj)); - return PyInt_FromLong(ord); + return PyLong_FromLong(ord); } } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); if (size == 1) { ord = (long)*PyUnicode_AS_UNICODE(obj); - return PyInt_FromLong(ord); + return PyLong_FromLong(ord); } #ifndef Py_UNICODE_WIDE if (size == 2) { @@ -1123,7 +1123,7 @@ 0xDC00 <= c1 && c1 <= 0xDFFF) { ord = ((((c0 & 0x03FF) << 10) | (c1 & 0x03FF)) + 0x00010000); - return PyInt_FromLong(ord); + return PyLong_FromLong(ord); } } #endif @@ -1133,7 +1133,7 @@ size = PyBytes_GET_SIZE(obj); if (size == 1) { ord = (long)((unsigned char)*PyBytes_AS_STRING(obj)); - return PyInt_FromLong(ord); + return PyLong_FromLong(ord); } } else { @@ -1300,7 +1300,7 @@ tty = 0; } else { - fd = PyInt_AsLong(tmp); + fd = PyLong_AsLong(tmp); Py_DECREF(tmp); if (fd < 0 && PyErr_Occurred()) return NULL; @@ -1311,7 +1311,7 @@ if (tmp == NULL) PyErr_Clear(); else { - fd = PyInt_AsLong(tmp); + fd = PyLong_AsLong(tmp); Py_DECREF(tmp); if (fd < 0 && PyErr_Occurred()) return NULL; @@ -1595,7 +1595,7 @@ return NULL; if (result == NULL) { - result = PyInt_FromLong(0); + result = PyLong_FromLong(0); if (result == NULL) { Py_DECREF(iter); return NULL; @@ -1624,7 +1624,7 @@ to the more general routine. */ if (PyInt_CheckExact(result)) { - long i_result = PyInt_AS_LONG(result); + long i_result = PyLong_AS_LONG(result); Py_DECREF(result); result = NULL; while(result == NULL) { @@ -1633,10 +1633,10 @@ Py_DECREF(iter); if (PyErr_Occurred()) return NULL; - return PyInt_FromLong(i_result); + return PyLong_FromLong(i_result); } if (PyInt_CheckExact(item)) { - long b = PyInt_AS_LONG(item); + long b = PyLong_AS_LONG(item); long x = i_result + b; if ((x^i_result) >= 0 || (x^b) >= 0) { i_result = x; @@ -1645,7 +1645,7 @@ } } /* Either overflowed or is not an int. Restore real objects and process normally */ - result = PyInt_FromLong(i_result); + result = PyLong_FromLong(i_result); temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item); @@ -1678,7 +1678,7 @@ } if (PyInt_CheckExact(item)) { PyFPE_START_PROTECT("add", return 0) - f_result += (double)PyInt_AS_LONG(item); + f_result += (double)PyLong_AS_LONG(item); PyFPE_END_PROTECT(f_result) Py_DECREF(item); continue; Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Sun Dec 2 15:31:20 2007 @@ -1121,12 +1121,12 @@ if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { /* INLINE: int + int */ register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); + a = PyLong_AS_LONG(v); + b = PyLong_AS_LONG(w); i = a + b; if ((i^a) < 0 && (i^b) < 0) goto slow_add; - x = PyInt_FromLong(i); + x = PyLong_FromLong(i); } else if (PyUnicode_CheckExact(v) && PyUnicode_CheckExact(w)) { @@ -1151,12 +1151,12 @@ if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { /* INLINE: int - int */ register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); + a = PyLong_AS_LONG(v); + b = PyLong_AS_LONG(w); i = a - b; if ((i^a) < 0 && (i^~b) < 0) goto slow_sub; - x = PyInt_FromLong(i); + x = PyLong_FromLong(i); } else { slow_sub: @@ -1173,7 +1173,7 @@ v = TOP(); if (PyList_CheckExact(v) && PyInt_CheckExact(w)) { /* INLINE: list[int] */ - Py_ssize_t i = PyInt_AsSsize_t(w); + Py_ssize_t i = PyLong_AsSsize_t(w); if (i < 0) i += PyList_GET_SIZE(v); if (i >= 0 && i < PyList_GET_SIZE(v)) { @@ -1322,12 +1322,12 @@ if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { /* INLINE: int + int */ register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); + a = PyLong_AS_LONG(v); + b = PyLong_AS_LONG(w); i = a + b; if ((i^a) < 0 && (i^b) < 0) goto slow_iadd; - x = PyInt_FromLong(i); + x = PyLong_FromLong(i); } else if (PyUnicode_CheckExact(v) && PyUnicode_CheckExact(w)) { @@ -1352,12 +1352,12 @@ if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { /* INLINE: int - int */ register long a, b, i; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); + a = PyLong_AS_LONG(v); + b = PyLong_AS_LONG(w); i = a - b; if ((i^a) < 0 && (i^~b) < 0) goto slow_isub; - x = PyInt_FromLong(i); + x = PyLong_FromLong(i); } else { slow_isub: @@ -1518,8 +1518,8 @@ case END_FINALLY: v = POP(); - if (PyInt_Check(v)) { - why = (enum why_code) PyInt_AS_LONG(v); + if (PyLong_Check(v)) { + why = (enum why_code) PyLong_AS_LONG(v); assert(why != WHY_YIELD); if (why == WHY_RETURN || why == WHY_CONTINUE) @@ -1869,8 +1869,8 @@ /* INLINE: cmp(int, int) */ register long a, b; register int res; - a = PyInt_AS_LONG(v); - b = PyInt_AS_LONG(w); + a = PyLong_AS_LONG(v); + b = PyLong_AS_LONG(w); switch (oparg) { case PyCmp_LT: res = a < b; break; case PyCmp_LE: res = a <= b; break; @@ -1907,7 +1907,7 @@ } v = POP(); u = TOP(); - if (PyInt_AsLong(u) != -1 || PyErr_Occurred()) + if (PyLong_AsLong(u) != -1 || PyErr_Occurred()) w = PyTuple_Pack(5, w, f->f_globals, @@ -2066,7 +2066,7 @@ goto fast_block_end; case CONTINUE_LOOP: - retval = PyInt_FromLong(oparg); + retval = PyLong_FromLong(oparg); if (!retval) { x = NULL; break; @@ -2109,7 +2109,7 @@ x = TOP(); u = SECOND(); - if (PyInt_Check(u) || u == Py_None) { + if (PyLong_Check(u) || u == Py_None) { u = v = w = Py_None; } else { @@ -2392,7 +2392,7 @@ PyFrame_BlockSetup(f, b->b_type, b->b_handler, b->b_level); why = WHY_NOT; - JUMPTO(PyInt_AS_LONG(retval)); + JUMPTO(PyLong_AS_LONG(retval)); Py_DECREF(retval); break; } @@ -2438,7 +2438,7 @@ else { if (why & (WHY_RETURN | WHY_CONTINUE)) PUSH(retval); - v = PyInt_FromLong((long)why); + v = PyLong_FromLong((long)why); PUSH(v); } why = WHY_NOT; @@ -3797,11 +3797,11 @@ if (v != NULL) { Py_ssize_t x; if (PyInt_CheckExact(v)) { - /* XXX(nnorwitz): I think PyInt_AS_LONG is correct, + /* XXX(nnorwitz): I think PyLong_AS_LONG is correct, however, it looks like it should be AsSsize_t. There should be a comment here explaining why. */ - x = PyInt_AS_LONG(v); + x = PyLong_AS_LONG(v); } else if (PyIndex_Check(v)) { x = PyNumber_AsSsize_t(v, NULL); @@ -4051,7 +4051,7 @@ PyObject *l = PyList_New(256); if (l == NULL) return NULL; for (i = 0; i < 256; i++) { - PyObject *x = PyInt_FromLong(a[i]); + PyObject *x = PyLong_FromLong(a[i]); if (x == NULL) { Py_DECREF(l); return NULL; Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Sun Dec 2 15:31:20 2007 @@ -335,7 +335,7 @@ n = PyList_Size(list); for (i = 0; i < n; i++) { - v = PyInt_FromLong(i); + v = PyLong_FromLong(i); if (!v) { Py_DECREF(dict); return NULL; @@ -375,12 +375,12 @@ while (PyDict_Next(src, &pos, &k, &v)) { /* XXX this should probably be a macro in symtable.h */ long vi; - assert(PyInt_Check(v)); - vi = PyInt_AS_LONG(v); + assert(PyLong_Check(v)); + vi = PyLong_AS_LONG(v); scope = (vi >> SCOPE_OFFSET) & SCOPE_MASK; if (scope == scope_type || vi & flag) { - PyObject *tuple, *item = PyInt_FromLong(i); + PyObject *tuple, *item = PyLong_FromLong(i); if (item == NULL) { Py_DECREF(dest); return NULL; @@ -907,7 +907,7 @@ if (PyErr_Occurred()) return -1; arg = PyDict_Size(dict); - v = PyInt_FromLong(arg); + v = PyLong_FromLong(arg); if (!v) { Py_DECREF(t); return -1; @@ -920,7 +920,7 @@ Py_DECREF(v); } else - arg = PyInt_AsLong(v); + arg = PyLong_AsLong(v); Py_DECREF(t); return arg; } @@ -1208,7 +1208,7 @@ Py_DECREF(k); if (v == NULL) return -1; - return PyInt_AS_LONG(v); + return PyLong_AS_LONG(v); } static int @@ -2065,7 +2065,7 @@ int r; PyObject *level; - level = PyInt_FromLong(0); + level = PyLong_FromLong(0); if (level == NULL) return 0; @@ -2108,7 +2108,7 @@ if (!names) return 0; - level = PyInt_FromLong(s->v.ImportFrom.level); + level = PyLong_FromLong(s->v.ImportFrom.level); if (!level) { Py_DECREF(names); return 0; @@ -3916,7 +3916,7 @@ if (tuple == NULL) return NULL; while (PyDict_Next(dict, &pos, &k, &v)) { - i = PyInt_AS_LONG(v); + i = PyLong_AS_LONG(v); k = PyTuple_GET_ITEM(k, 0); Py_INCREF(k); assert((i - offset) < size); Modified: python/branches/py3k/Python/errors.c ============================================================================== --- python/branches/py3k/Python/errors.c (original) +++ python/branches/py3k/Python/errors.c Sun Dec 2 15:31:20 2007 @@ -752,7 +752,7 @@ PyErr_NormalizeException(&exc, &v, &tb); /* XXX check that it is, indeed, a syntax error. It might not * be, though. */ - tmp = PyInt_FromLong(lineno); + tmp = PyLong_FromLong(lineno); if (tmp == NULL) PyErr_Clear(); else { Modified: python/branches/py3k/Python/getargs.c ============================================================================== --- python/branches/py3k/Python/getargs.c (original) +++ python/branches/py3k/Python/getargs.c Sun Dec 2 15:31:20 2007 @@ -556,7 +556,7 @@ long ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = PyInt_AsLong(arg); + ival = PyLong_AsLong(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else if (ival < 0) { @@ -580,7 +580,7 @@ long ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = PyInt_AsUnsignedLongMask(arg); + ival = PyLong_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else @@ -593,7 +593,7 @@ long ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = PyInt_AsLong(arg); + ival = PyLong_AsLong(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else if (ival < SHRT_MIN) { @@ -617,7 +617,7 @@ long ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = PyInt_AsUnsignedLongMask(arg); + ival = PyLong_AsUnsignedLongMask(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else @@ -630,7 +630,7 @@ long ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = PyInt_AsLong(arg); + ival = PyLong_AsLong(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else if (ival > INT_MAX) { @@ -654,7 +654,7 @@ unsigned int ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = (unsigned int)PyInt_AsUnsignedLongMask(arg); + ival = (unsigned int)PyLong_AsUnsignedLongMask(arg); if (ival == (unsigned int)-1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else @@ -672,7 +672,7 @@ return converterr("integer", arg, msgbuf, bufsize); iobj = PyNumber_Index(arg); if (iobj != NULL) - ival = PyInt_AsSsize_t(arg); + ival = PyLong_AsSsize_t(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); *p = ival; @@ -685,7 +685,7 @@ long ival; if (float_argument_error(arg)) return converterr("integer", arg, msgbuf, bufsize); - ival = PyInt_AsLong(arg); + ival = PyLong_AsLong(arg); if (ival == -1 && PyErr_Occurred()) return converterr("integer", arg, msgbuf, bufsize); else Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Sun Dec 2 15:31:20 2007 @@ -2687,7 +2687,7 @@ char *name; if (!PyArg_ParseTuple(args, "s:is_builtin", &name)) return NULL; - return PyInt_FromLong(is_builtin(name)); + return PyLong_FromLong(is_builtin(name)); } static PyObject * @@ -2921,7 +2921,7 @@ PyObject *v; int err; - v = PyInt_FromLong((long)value); + v = PyLong_FromLong((long)value); err = PyDict_SetItemString(d, name, v); Py_XDECREF(v); return err; Modified: python/branches/py3k/Python/mactoolboxglue.c ============================================================================== --- python/branches/py3k/Python/mactoolboxglue.c (original) +++ python/branches/py3k/Python/mactoolboxglue.c Sun Dec 2 15:31:20 2007 @@ -348,9 +348,9 @@ int PyMac_Getwide(PyObject *v, wide *rv) { - if (PyInt_Check(v)) { + if (PyLong_Check(v)) { rv->hi = 0; - rv->lo = PyInt_AsLong(v); + rv->lo = PyLong_AsLong(v); if( rv->lo & 0x80000000 ) rv->hi = -1; return 1; @@ -364,7 +364,7 @@ { if ( (w->hi == 0 && (w->lo & 0x80000000) == 0) || (w->hi == -1 && (w->lo & 0x80000000) ) ) - return PyInt_FromLong(w->lo); + return PyLong_FromLong(w->lo); return Py_BuildValue("(ll)", w->hi, w->lo); } Modified: python/branches/py3k/Python/marshal.c ============================================================================== --- python/branches/py3k/Python/marshal.c (original) +++ python/branches/py3k/Python/marshal.c Sun Dec 2 15:31:20 2007 @@ -460,7 +460,7 @@ long hi4 = r_long(p); #if SIZEOF_LONG > 4 long x = (hi4 << 32) | (lo4 & 0xFFFFFFFFL); - return PyInt_FromLong(x); + return PyLong_FromLong(x); #else unsigned char buf[8]; int one = 1; @@ -533,7 +533,7 @@ break; case TYPE_INT: - retval = PyInt_FromLong(r_long(p)); + retval = PyLong_FromLong(r_long(p)); break; case TYPE_INT64: Modified: python/branches/py3k/Python/modsupport.c ============================================================================== --- python/branches/py3k/Python/modsupport.c (original) +++ python/branches/py3k/Python/modsupport.c Sun Dec 2 15:31:20 2007 @@ -307,10 +307,10 @@ case 'B': case 'h': case 'i': - return PyInt_FromLong((long)va_arg(*p_va, int)); + return PyLong_FromLong((long)va_arg(*p_va, int)); case 'H': - return PyInt_FromLong((long)va_arg(*p_va, unsigned int)); + return PyLong_FromLong((long)va_arg(*p_va, unsigned int)); case 'I': { @@ -319,16 +319,16 @@ if (n > (unsigned long)PyInt_GetMax()) return PyLong_FromUnsignedLong((unsigned long)n); else - return PyInt_FromLong(n); + return PyLong_FromLong(n); } case 'n': #if SIZEOF_SIZE_T!=SIZEOF_LONG - return PyInt_FromSsize_t(va_arg(*p_va, Py_ssize_t)); + return PyLong_FromSsize_t(va_arg(*p_va, Py_ssize_t)); #endif /* Fall through from 'n' to 'l' if Py_ssize_t is long */ case 'l': - return PyInt_FromLong(va_arg(*p_va, long)); + return PyLong_FromLong(va_arg(*p_va, long)); case 'k': { @@ -337,7 +337,7 @@ if (n > (unsigned long)PyInt_GetMax()) return PyLong_FromUnsignedLong(n); else - return PyInt_FromLong(n); + return PyLong_FromLong(n); } #ifdef HAVE_LONG_LONG @@ -702,7 +702,7 @@ int PyModule_AddIntConstant(PyObject *m, const char *name, long value) { - return PyModule_AddObject(m, name, PyInt_FromLong(value)); + return PyModule_AddObject(m, name, PyLong_FromLong(value)); } int Modified: python/branches/py3k/Python/pystate.c ============================================================================== --- python/branches/py3k/Python/pystate.c (original) +++ python/branches/py3k/Python/pystate.c Sun Dec 2 15:31:20 2007 @@ -445,7 +445,7 @@ struct _frame *frame = t->frame; if (frame == NULL) continue; - id = PyInt_FromLong(t->thread_id); + id = PyLong_FromLong(t->thread_id); if (id == NULL) goto Fail; stat = PyDict_SetItem(result, id, (PyObject *)frame); Modified: python/branches/py3k/Python/pythonrun.c ============================================================================== --- python/branches/py3k/Python/pythonrun.c (original) +++ python/branches/py3k/Python/pythonrun.c Sun Dec 2 15:31:20 2007 @@ -1109,7 +1109,7 @@ Py_DECREF(v); if (!(v = PyObject_GetAttrString(err, "lineno"))) goto finally; - hold = PyInt_AsLong(v); + hold = PyLong_AsLong(v); Py_DECREF(v); v = NULL; if (hold < 0 && PyErr_Occurred()) @@ -1123,7 +1123,7 @@ Py_DECREF(v); v = NULL; } else { - hold = PyInt_AsLong(v); + hold = PyLong_AsLong(v); Py_DECREF(v); v = NULL; if (hold < 0 && PyErr_Occurred()) @@ -1213,8 +1213,8 @@ /* If we failed to dig out the 'code' attribute, just let the else clause below print the error. */ } - if (PyInt_Check(value)) - exitcode = (int)PyInt_AsLong(value); + if (PyLong_Check(value)) + exitcode = (int)PyLong_AsLong(value); else { PyObject_Print(value, stderr, Py_PRINT_RAW); PySys_WriteStderr("\n"); Modified: python/branches/py3k/Python/structmember.c ============================================================================== --- python/branches/py3k/Python/structmember.c (original) +++ python/branches/py3k/Python/structmember.c Sun Dec 2 15:31:20 2007 @@ -13,31 +13,31 @@ addr += l->offset; switch (l->type) { case T_BYTE: - v = PyInt_FromLong(*(char*)addr); + v = PyLong_FromLong(*(char*)addr); break; case T_UBYTE: v = PyLong_FromUnsignedLong(*(unsigned char*)addr); break; case T_SHORT: - v = PyInt_FromLong(*(short*)addr); + v = PyLong_FromLong(*(short*)addr); break; case T_USHORT: v = PyLong_FromUnsignedLong(*(unsigned short*)addr); break; case T_INT: - v = PyInt_FromLong(*(int*)addr); + v = PyLong_FromLong(*(int*)addr); break; case T_UINT: v = PyLong_FromUnsignedLong(*(unsigned int*)addr); break; case T_LONG: - v = PyInt_FromLong(*(long*)addr); + v = PyLong_FromLong(*(long*)addr); break; case T_ULONG: v = PyLong_FromUnsignedLong(*(unsigned long*)addr); break; case T_PYSSIZET: - v = PyInt_FromSsize_t(*(Py_ssize_t*)addr); + v = PyLong_FromSsize_t(*(Py_ssize_t*)addr); break; case T_FLOAT: v = PyFloat_FromDouble((double)*(float*)addr); @@ -114,7 +114,7 @@ addr += l->offset; switch (l->type) { case T_BYTE:{ - long long_val = PyInt_AsLong(v); + long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; *(char*)addr = (char)long_val; @@ -125,7 +125,7 @@ break; } case T_UBYTE:{ - long long_val = PyInt_AsLong(v); + long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; *(unsigned char*)addr = (unsigned char)long_val; @@ -134,7 +134,7 @@ break; } case T_SHORT:{ - long long_val = PyInt_AsLong(v); + long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; *(short*)addr = (short)long_val; @@ -143,7 +143,7 @@ break; } case T_USHORT:{ - long long_val = PyInt_AsLong(v); + long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; *(unsigned short*)addr = (unsigned short)long_val; @@ -152,7 +152,7 @@ break; } case T_INT:{ - long long_val = PyInt_AsLong(v); + long long_val = PyLong_AsLong(v); if ((long_val == -1) && PyErr_Occurred()) return -1; *(int *)addr = (int)long_val; @@ -199,7 +199,7 @@ break; } case T_PYSSIZET:{ - *(Py_ssize_t*)addr = PyInt_AsSsize_t(v); + *(Py_ssize_t*)addr = PyLong_AsSsize_t(v); if ((*(Py_ssize_t*)addr == (Py_ssize_t)-1) && PyErr_Occurred()) return -1; @@ -248,7 +248,7 @@ if (PyLong_Check(v)) *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsUnsignedLongLong(v); else - *(unsigned PY_LONG_LONG*)addr = value = PyInt_AsLong(v); + *(unsigned PY_LONG_LONG*)addr = value = PyLong_AsLong(v); if ((value == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred()) return -1; break; Modified: python/branches/py3k/Python/symtable.c ============================================================================== --- python/branches/py3k/Python/symtable.c (original) +++ python/branches/py3k/Python/symtable.c Sun Dec 2 15:31:20 2007 @@ -90,7 +90,7 @@ { return PyUnicode_FromFormat("", ste->ste_name, - PyInt_AS_LONG(ste->ste_id), ste->ste_lineno); + PyLong_AS_LONG(ste->ste_id), ste->ste_lineno); } static void @@ -310,8 +310,8 @@ PyObject *v = PyDict_GetItem(ste->ste_symbols, name); if (!v) return 0; - assert(PyInt_Check(v)); - return (PyInt_AS_LONG(v) >> SCOPE_OFFSET) & SCOPE_MASK; + assert(PyLong_Check(v)); + return (PyLong_AS_LONG(v) >> SCOPE_OFFSET) & SCOPE_MASK; } @@ -361,7 +361,7 @@ */ #define SET_SCOPE(DICT, NAME, I) { \ - PyObject *o = PyInt_FromLong(I); \ + PyObject *o = PyLong_FromLong(I); \ if (!o) \ return 0; \ if (PyDict_SetItem((DICT), (NAME), o) < 0) { \ @@ -476,13 +476,13 @@ int success = 0; Py_ssize_t pos = 0; - v_cell = PyInt_FromLong(CELL); + v_cell = PyLong_FromLong(CELL); if (!v_cell) return 0; while (PyDict_Next(scopes, &pos, &name, &v)) { long scope; - assert(PyInt_Check(v)); - scope = PyInt_AS_LONG(v); + assert(PyLong_Check(v)); + scope = PyLong_AS_LONG(v); if (scope != LOCAL) continue; if (!PySet_Contains(free, name)) @@ -548,13 +548,13 @@ /* Update scope information for all symbols in this scope */ while (PyDict_Next(symbols, &pos, &name, &v)) { long scope, flags; - assert(PyInt_Check(v)); - flags = PyInt_AS_LONG(v); + assert(PyLong_Check(v)); + flags = PyLong_AS_LONG(v); v_scope = PyDict_GetItem(scopes, name); - assert(v_scope && PyInt_Check(v_scope)); - scope = PyInt_AS_LONG(v_scope); + assert(v_scope && PyLong_Check(v_scope)); + scope = PyLong_AS_LONG(v_scope); flags |= (scope << SCOPE_OFFSET); - v_new = PyInt_FromLong(flags); + v_new = PyLong_FromLong(flags); if (!v_new) return 0; if (PyDict_SetItem(symbols, name, v_new) < 0) { @@ -565,7 +565,7 @@ } /* Record not yet resolved free variables from children (if any) */ - v_free = PyInt_FromLong(FREE << SCOPE_OFFSET); + v_free = PyLong_FromLong(FREE << SCOPE_OFFSET); if (!v_free) return 0; @@ -583,9 +583,9 @@ or global in the class scope. */ if (classflag && - PyInt_AS_LONG(v) & (DEF_BOUND | DEF_GLOBAL)) { - long flags = PyInt_AS_LONG(v) | DEF_FREE_CLASS; - v_new = PyInt_FromLong(flags); + PyLong_AS_LONG(v) & (DEF_BOUND | DEF_GLOBAL)) { + long flags = PyLong_AS_LONG(v) | DEF_FREE_CLASS; + v_new = PyLong_FromLong(flags); if (!v_new) { goto error; } @@ -675,7 +675,7 @@ assert(PySTEntry_Check(ste)); assert(PyDict_Check(ste->ste_symbols)); while (PyDict_Next(ste->ste_symbols, &pos, &name, &v)) { - long flags = PyInt_AS_LONG(v); + long flags = PyLong_AS_LONG(v); if (!analyze_name(ste, scopes, name, flags, bound, local, free, global)) goto error; @@ -849,7 +849,7 @@ Py_DECREF(mangled); if (!o) return 0; - return PyInt_AsLong(o); + return PyLong_AsLong(o); } static int @@ -865,7 +865,7 @@ return 0; dict = st->st_cur->ste_symbols; if ((o = PyDict_GetItem(dict, mangled))) { - val = PyInt_AS_LONG(o); + val = PyLong_AS_LONG(o); if ((flag & DEF_PARAM) && (val & DEF_PARAM)) { /* Is it better to use 'mangled' or 'name' here? */ PyErr_Format(PyExc_SyntaxError, DUPLICATE_ARGUMENT, name); @@ -876,7 +876,7 @@ val |= flag; } else val = flag; - o = PyInt_FromLong(val); + o = PyLong_FromLong(val); if (o == NULL) goto error; if (PyDict_SetItem(dict, mangled, o) < 0) { @@ -893,9 +893,9 @@ perhaps only DEF_FREE_GLOBAL */ val = flag; if ((o = PyDict_GetItem(st->st_global, mangled))) { - val |= PyInt_AS_LONG(o); + val |= PyLong_AS_LONG(o); } - o = PyInt_FromLong(val); + o = PyLong_FromLong(val); if (o == NULL) goto error; if (PyDict_SetItem(st->st_global, mangled, o) < 0) { Modified: python/branches/py3k/Python/sysmodule.c ============================================================================== --- python/branches/py3k/Python/sysmodule.c (original) +++ python/branches/py3k/Python/sysmodule.c Sun Dec 2 15:31:20 2007 @@ -411,7 +411,7 @@ static PyObject * sys_getcheckinterval(PyObject *self, PyObject *args) { - return PyInt_FromLong(_Py_CheckInterval); + return PyLong_FromLong(_Py_CheckInterval); } PyDoc_STRVAR(getcheckinterval_doc, @@ -473,7 +473,7 @@ static PyObject * sys_getrecursionlimit(PyObject *self) { - return PyInt_FromLong(Py_GetRecursionLimit()); + return PyLong_FromLong(Py_GetRecursionLimit()); } PyDoc_STRVAR(getrecursionlimit_doc, @@ -543,7 +543,7 @@ PyThreadState *tstate = PyThreadState_GET(); if (!tstate) return NULL; - return PyInt_FromLong(tstate->interp->dlopenflags); + return PyLong_FromLong(tstate->interp->dlopenflags); } PyDoc_STRVAR(getdlopenflags_doc, @@ -573,14 +573,14 @@ static PyObject * sys_getrefcount(PyObject *self, PyObject *arg) { - return PyInt_FromSsize_t(arg->ob_refcnt); + return PyLong_FromSsize_t(arg->ob_refcnt); } #ifdef Py_REF_DEBUG static PyObject * sys_gettotalrefcount(PyObject *self) { - return PyInt_FromSsize_t(_Py_GetRefTotal()); + return PyLong_FromSsize_t(_Py_GetRefTotal()); } #endif /* Py_REF_DEBUG */ @@ -1034,7 +1034,7 @@ v = PyUnicode_FromString(Py_GetVersion())); Py_XDECREF(v); PyDict_SetItemString(sysdict, "hexversion", - v = PyInt_FromLong(PY_VERSION_HEX)); + v = PyLong_FromLong(PY_VERSION_HEX)); Py_XDECREF(v); svnversion_init(); v = Py_BuildValue("(UUU)", "CPython", branch, svn_revision); @@ -1066,7 +1066,7 @@ PY_MICRO_VERSION, s, PY_RELEASE_SERIAL)); SET_SYS_FROM_STRING("api_version", - PyInt_FromLong(PYTHON_API_VERSION)); + PyLong_FromLong(PYTHON_API_VERSION)); SET_SYS_FROM_STRING("copyright", PyUnicode_FromString(Py_GetCopyright())); SET_SYS_FROM_STRING("platform", @@ -1079,13 +1079,13 @@ SET_SYS_FROM_STRING("exec_prefix", PyUnicode_DecodeFSDefault(Py_GetExecPrefix())); SET_SYS_FROM_STRING("maxint", - PyInt_FromLong(PyInt_GetMax())); + PyLong_FromLong(PyInt_GetMax())); SET_SYS_FROM_STRING("maxsize", - PyInt_FromSsize_t(PY_SSIZE_T_MAX)); + PyLong_FromSsize_t(PY_SSIZE_T_MAX)); SET_SYS_FROM_STRING("float_info", PyFloat_GetInfo()); SET_SYS_FROM_STRING("maxunicode", - PyInt_FromLong(PyUnicode_GetMax())); + PyLong_FromLong(PyUnicode_GetMax())); SET_SYS_FROM_STRING("builtin_module_names", list_builtin_module_names()); { Modified: python/branches/py3k/Python/traceback.c ============================================================================== --- python/branches/py3k/Python/traceback.c (original) +++ python/branches/py3k/Python/traceback.c Sun Dec 2 15:31:20 2007 @@ -256,7 +256,7 @@ } limitv = PySys_GetObject("tracebacklimit"); if (limitv && PyInt_CheckExact(limitv)) { - limit = PyInt_AsLong(limitv); + limit = PyLong_AsLong(limitv); if (limit <= 0) return 0; } From python-3000-checkins at python.org Sun Dec 2 15:44:18 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 15:44:18 +0100 (CET) Subject: [Python-3000-checkins] r59273 - python/branches/py3k/Include/intobject.h Message-ID: <20071202144418.2F7171E4062@bag.python.org> Author: christian.heimes Date: Sun Dec 2 15:44:17 2007 New Revision: 59273 Modified: python/branches/py3k/Include/intobject.h Log: Changed #ifdef 0 to #if 0. Modified: python/branches/py3k/Include/intobject.h ============================================================================== --- python/branches/py3k/Include/intobject.h (original) +++ python/branches/py3k/Include/intobject.h Sun Dec 2 15:44:17 2007 @@ -31,7 +31,7 @@ #define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op)) -#ifdef 0 +#if 0 # define PyInt_Check(op) PyLong_Check(op) # define PyInt_FromString PyLong_FromString # define PyInt_FromUnicode PyLong_FromUnicode From python-3000-checkins at python.org Sun Dec 2 16:22:17 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 16:22:17 +0100 (CET) Subject: [Python-3000-checkins] r59275 - in python/branches/py3k: Doc/ACKS.txt Doc/Makefile Doc/README.txt Doc/c-api/init.rst Doc/c-api/utilities.rst Doc/c-api/veryhigh.rst Doc/data/refcounts.dat Doc/distutils/extending.rst Doc/extending/extending.rst Doc/glossary.rst Doc/library/atexit.rst Doc/library/bdb.rst Doc/library/codeop.rst Doc/library/contextlib.rst Doc/library/doctest.rst Doc/library/functions.rst Doc/library/functools.rst Doc/library/inspect.rst Doc/library/mmap.rst Doc/library/operator.rst Doc/library/stdtypes.rst Doc/library/sys.rst Doc/library/timeit.rst Doc/library/weakref.rst Doc/library/windows.rst Doc/library/xml.etree.elementtree.rst Doc/reference/compound_stmts.rst Doc/tutorial/stdlib2.rst Doc/using/cmdline.rst Doc/using/index.rst Doc/using/windows.rst Lib/tarfile.py Lib/test/test_cmd.py Lib/test/test_tarfile.py Misc/ACKS Message-ID: <20071202152217.C4FA21E4A9A@bag.python.org> Author: christian.heimes Date: Sun Dec 2 16:22:16 2007 New Revision: 59275 Added: python/branches/py3k/Doc/using/windows.rst - copied unchanged from r59274, python/trunk/Doc/using/windows.rst python/branches/py3k/Lib/test/test_cmd.py - copied unchanged from r59274, python/trunk/Lib/test/test_cmd.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/Makefile python/branches/py3k/Doc/README.txt python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Doc/c-api/utilities.rst python/branches/py3k/Doc/c-api/veryhigh.rst python/branches/py3k/Doc/data/refcounts.dat python/branches/py3k/Doc/distutils/extending.rst python/branches/py3k/Doc/extending/extending.rst python/branches/py3k/Doc/glossary.rst python/branches/py3k/Doc/library/atexit.rst python/branches/py3k/Doc/library/bdb.rst python/branches/py3k/Doc/library/codeop.rst python/branches/py3k/Doc/library/contextlib.rst python/branches/py3k/Doc/library/doctest.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/functools.rst python/branches/py3k/Doc/library/inspect.rst python/branches/py3k/Doc/library/mmap.rst python/branches/py3k/Doc/library/operator.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Doc/library/timeit.rst python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Doc/library/windows.rst python/branches/py3k/Doc/library/xml.etree.elementtree.rst python/branches/py3k/Doc/reference/compound_stmts.rst python/branches/py3k/Doc/tutorial/stdlib2.rst python/branches/py3k/Doc/using/cmdline.rst python/branches/py3k/Doc/using/index.rst python/branches/py3k/Lib/tarfile.py python/branches/py3k/Lib/test/test_tarfile.py python/branches/py3k/Misc/ACKS Log: Merged revisions 59259-59274 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59260 | lars.gustaebel | 2007-12-01 22:02:12 +0100 (Sat, 01 Dec 2007) | 5 lines Issue #1531: Read fileobj from the current offset, do not seek to the start. (will backport to 2.5) ........ r59262 | georg.brandl | 2007-12-01 23:24:47 +0100 (Sat, 01 Dec 2007) | 4 lines Document PyEval_* functions from ceval.c. Credits to Michael Sloan from GHOP. ........ r59263 | georg.brandl | 2007-12-01 23:27:56 +0100 (Sat, 01 Dec 2007) | 2 lines Add a few refcount data entries. ........ r59264 | georg.brandl | 2007-12-01 23:38:48 +0100 (Sat, 01 Dec 2007) | 4 lines Add test suite for cmd module. Written by Michael Schneider for GHOP. ........ r59265 | georg.brandl | 2007-12-01 23:42:46 +0100 (Sat, 01 Dec 2007) | 3 lines Add examples to the ElementTree documentation. Written by h4wk.cz for GHOP. ........ r59266 | georg.brandl | 2007-12-02 00:12:45 +0100 (Sun, 02 Dec 2007) | 3 lines Add "Using Python on Windows" document, by Robert Lehmann. Written for GHOP. ........ r59271 | georg.brandl | 2007-12-02 15:34:34 +0100 (Sun, 02 Dec 2007) | 3 lines Add example to mmap docs. Written for GHOP by Rafal Rawicki. ........ r59272 | georg.brandl | 2007-12-02 15:37:29 +0100 (Sun, 02 Dec 2007) | 2 lines Convert bdb.rst line endings to Unix style. ........ r59274 | georg.brandl | 2007-12-02 15:58:50 +0100 (Sun, 02 Dec 2007) | 4 lines Add more entries to the glossary. Written by Jeff Wheeler for GHOP. ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Sun Dec 2 16:22:16 2007 @@ -163,6 +163,7 @@ * Justin Sheehy * Michael Simcich * Ionel Simionescu +* Michael Sloan * Gregory P. Smith * Roy Smith * Clay Spence @@ -185,6 +186,7 @@ * Glyn Webster * Bob Weiner * Eddy Welbourne +* Jeff Wheeler * Mats Wichmann * Gerry Wiener * Timothy Wild Modified: python/branches/py3k/Doc/Makefile ============================================================================== --- python/branches/py3k/Doc/Makefile (original) +++ python/branches/py3k/Doc/Makefile Sun Dec 2 16:22:16 2007 @@ -57,6 +57,10 @@ @echo "Build finished; now you can run HTML Help Workshop with the" \ "build/htmlhelp/pydoc.hhp project file." +latex: BUILDER = latex +latex: build + @echo "Build finished; the LaTeX files are in build/latex." + clean: -rm -rf build/* -rm -rf tools/sphinx Modified: python/branches/py3k/Doc/README.txt ============================================================================== --- python/branches/py3k/Doc/README.txt (original) +++ python/branches/py3k/Doc/README.txt Sun Dec 2 16:22:16 2007 @@ -53,6 +53,9 @@ To create the CHM file, you need to run the Microsoft HTML Help Workshop over the generated project (.hhp) file. + * "latex", which builds LaTeX source files that can be run with "pdflatex" + to produce PDF documents. + A "make update" updates the Subversion checkouts in `tools/`. Modified: python/branches/py3k/Doc/c-api/init.rst ============================================================================== --- python/branches/py3k/Doc/c-api/init.rst (original) +++ python/branches/py3k/Doc/c-api/init.rst Sun Dec 2 16:22:16 2007 @@ -615,6 +615,14 @@ deadlock ensues. (This function is available even when thread support is disabled at compile time.) + +.. cfunction:: void PyEval_ReInitThreads() + + This function is called from :cfunc:`PyOS_AfterFork` to ensure that newly + created child processes don't hold locks referring to threads which + are not running in the child process. + + The following macros are normally used without a trailing semicolon; look for example usage in the Python source distribution. @@ -876,6 +884,46 @@ :cfunc:`PyEval_SetProfile`, except the tracing function does receive line-number events. +.. cfunction:: PyObject* PyEval_GetCallStats(PyObject *self) + + Return a tuple of function call counts. There are constants defined for the + positions within the tuple: + + +-------------------------------+-------+ + | Name | Value | + +===============================+=======+ + | :const:`PCALL_ALL` | 0 | + +-------------------------------+-------+ + | :const:`PCALL_FUNCTION` | 1 | + +-------------------------------+-------+ + | :const:`PCALL_FAST_FUNCTION` | 2 | + +-------------------------------+-------+ + | :const:`PCALL_FASTER_FUNCTION`| 3 | + +-------------------------------+-------+ + | :const:`PCALL_METHOD` | 4 | + +-------------------------------+-------+ + | :const:`PCALL_BOUND_METHOD` | 5 | + +-------------------------------+-------+ + | :const:`PCALL_CFUNCTION` | 6 | + +-------------------------------+-------+ + | :const:`PCALL_TYPE` | 7 | + +-------------------------------+-------+ + | :const:`PCALL_GENERATOR` | 8 | + +-------------------------------+-------+ + | :const:`PCALL_OTHER` | 9 | + +-------------------------------+-------+ + | :const:`PCALL_POP` | 10 | + +-------------------------------+-------+ + + :const:`PCALL_FAST_FUNCTION` means no argument tuple needs to be created. + :const:`PCALL_FASTER_FUNCTION` means that the fast-path frame setup code is used. + + If there is a method call where the call can be optimized by changing + the argument tuple and calling the function directly, it gets recorded + twice. + + This function is only present if Python is compiled with :const:`CALL_PROFILE` + defined. .. _advanced-debugging: Modified: python/branches/py3k/Doc/c-api/utilities.rst ============================================================================== --- python/branches/py3k/Doc/c-api/utilities.rst (original) +++ python/branches/py3k/Doc/c-api/utilities.rst Sun Dec 2 16:22:16 2007 @@ -989,3 +989,52 @@ See the Unix man page :manpage:`atof(2)` for details. + +.. _reflection: + +Reflection +========== + +.. cfunction:: PyObject* PyEval_GetBuiltins() + + Return a dictionary of the builtins in the current execution frame, + or the interpreter of the thread state if no frame is currently executing. + + +.. cfunction:: PyObject* PyEval_GetLocals() + + Return a dictionary of the local variables in the current execution frame, + or *NULL* if no frame is currently executing. + + +.. cfunction:: PyObject* PyEval_GetGlobals() + + Return a dictionary of the global variables in the current execution frame, + or *NULL* if no frame is currently executing. + + +.. cfunction:: PyFrameObject* PyEval_GetFrame() + + Return the current thread state's frame, which is *NULL* if no frame is + currently executing. + + +.. cfunction:: int PyEval_GetRestricted() + + If there is a current frame and it is executing in restricted mode, return true, + otherwise false. + + +.. cfunction:: const char* PyEval_GetFuncName(PyObject *func) + + Return the name of *func* if it is a function, class or instance object, else the + name of *func*\s type. + + +.. cfunction:: const char* PyEval_GetFuncDesc(PyObject *func) + + Return a description string, depending on the type of *func*. + Return values include "()" for functions and methods, " constructor", + " instance", and " object". Concatenated with the result of + :cfunc:`PyEval_GetFuncName`, the result will be a description of + *func*. Modified: python/branches/py3k/Doc/c-api/veryhigh.rst ============================================================================== --- python/branches/py3k/Doc/c-api/veryhigh.rst (original) +++ python/branches/py3k/Doc/c-api/veryhigh.rst Sun Dec 2 16:22:16 2007 @@ -229,6 +229,43 @@ be parsed or compiled. +.. cfunction:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) + + This is a simplified interface to :cfunc:`PyEval_EvalCodeEx`, with just + the code object, and the dictionaries of global and local variables. + The other arguments are set to *NULL*. + + +.. cfunction:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure) + + Evaluate a precompiled code object, given a particular environment for its + evaluation. This environment consists of dictionaries of global and local + variables, arrays of arguments, keywords and defaults, and a closure tuple of + cells. + + +.. cfunction:: PyObject* PyEval_EvalFrame(PyFrameObject *f) + + Evaluate an execution frame. This is a simplified interface to + PyEval_EvalFrameEx, for backward compatibility. + + +.. cfunction:: PyObject* PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) + + This is the main, unvarnished function of Python interpretation. It is + literally 2000 lines long. The code object associated with the execution + frame *f* is executed, interpreting bytecode and executing calls as needed. + The additional *throwflag* parameter can mostly be ignored - if true, then + it causes an exception to immediately be thrown; this is used for the + :meth:`throw` methods of generator objects. + + +.. cfunction:: int PyEval_MergeCompilerFlags(PyCompilerFlags *cf) + + This function changes the flags of the current evaluation frame, and returns + true on success, false on failure. + + .. cvar:: int Py_eval_input .. index:: single: Py_CompileString() Modified: python/branches/py3k/Doc/data/refcounts.dat ============================================================================== --- python/branches/py3k/Doc/data/refcounts.dat (original) +++ python/branches/py3k/Doc/data/refcounts.dat Sun Dec 2 16:22:16 2007 @@ -309,6 +309,11 @@ PyEval_AcquireThread:void::: PyEval_AcquireThread:PyThreadState*:tstate:: +PyEval_GetBuiltins:PyObject*::0: +PyEval_GetLocals:PyObject*::0: +PyEval_GetGlobals:PyObject*::0: +PyEval_GetFrame:PyObject*::0: + PyEval_InitThreads:void::: PyEval_ReleaseLock:void::: Modified: python/branches/py3k/Doc/distutils/extending.rst ============================================================================== --- python/branches/py3k/Doc/distutils/extending.rst (original) +++ python/branches/py3k/Doc/distutils/extending.rst Sun Dec 2 16:22:16 2007 @@ -1,4 +1,4 @@ -.. _extending: +.. _extending-distutils: ******************* Extending Distutils Modified: python/branches/py3k/Doc/extending/extending.rst ============================================================================== --- python/branches/py3k/Doc/extending/extending.rst (original) +++ python/branches/py3k/Doc/extending/extending.rst Sun Dec 2 16:22:16 2007 @@ -466,10 +466,10 @@ :cfunc:`PyEval_CallObject`. This function has two arguments, both pointers to arbitrary Python objects: the Python function, and the argument list. The argument list must always be a tuple object, whose length is the number of -arguments. To call the Python function with no arguments, pass an empty tuple; -to call it with one argument, pass a singleton tuple. :cfunc:`Py_BuildValue` -returns a tuple when its format string consists of zero or more format codes -between parentheses. For example:: +arguments. To call the Python function with no arguments, pass in NULL, or +an empty tuple; to call it with one argument, pass a singleton tuple. +:cfunc:`Py_BuildValue` returns a tuple when its format string consists of zero +or more format codes between parentheses. For example:: int arg; PyObject *arglist; @@ -527,9 +527,22 @@ Py_DECREF(result); Note the placement of ``Py_DECREF(arglist)`` immediately after the call, before -the error check! Also note that strictly spoken this code is not complete: +the error check! Also note that strictly speaking this code is not complete: :cfunc:`Py_BuildValue` may run out of memory, and this should be checked. +You may also call a function with keyword arguments by using +:cfunc:`PyEval_CallObjectWithKeywords`. As in the above example, we use +:cfunc:`Py_BuildValue` to construct the dictionary. :: + + PyObject *dict; + ... + dict = Py_BuildValue("{s:i}", "name", val); + result = PyEval_CallObjectWithKeywords(my_callback, NULL, dict); + Py_DECREF(dict); + if (result == NULL) + return NULL; /* Pass error back */ + /* Here maybe use the result */ + Py_DECREF(result); .. _parsetuple: Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Sun Dec 2 16:22:16 2007 @@ -15,6 +15,17 @@ ``...`` The typical Python prompt of the interactive shell when entering code for an indented code block. + + argument + A value passed to a function or method, assigned to a name local to + the body. A function or method may have both positional arguments and + keyword arguments in its definition. Positional and keyword arguments + may be variable-length: ``*`` accepts or passes (if in the function + definition or call) several positional arguments in a list, while ``**`` + does the same for keyword arguments in a dictionary. + + Any expression may be used within the argument list, and the evaluated + value is passed to the local variable. BDFL Benevolent Dictator For Life, a.k.a. `Guido van Rossum @@ -44,6 +55,22 @@ advanced mathematical feature. If you're not aware of a need for them, it's almost certain you can safely ignore them. + decorator + A function returning another function, usually applied as a function + transformation using the ``@wrapper`` syntax. Common examples for + decorators are :func:`classmethod` and :func:`staticmethod`. + + The decorator syntax is merely syntactic sugar, the following two + function definitions are semantically equivalent:: + + def f(...): + ... + f = staticmethod(f) + + @staticmethod + def f(...): + ... + descriptor An object that defines the methods :meth:`__get__`, :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a descriptor, its special @@ -81,10 +108,24 @@ statements. The technique contrasts with the :term:`LBYL` style that is common in many other languages such as C. + expression + A piece of syntax which can be evaluated to some value. In other words, + an expression is an accumulation of expression elements like literals, names, + attribute access, operators or function calls that all return a value. + In contrast to other languages, not all language constructs are expressions, + but there are also :term:`statement`\s that cannot be used as expressions, + such as :keyword:`print` or :keyword:`if`. Assignments are also not + expressions. + extension module A module written in C, using Python's C API to interact with the core and with user code. - + + function + A series of statements which returns some value to a caller. It can also + be passed zero or more arguments which may be used in the execution of + the body. See also :term:`argument` and :term:`method`. + __future__ A pseudo module which programmers can use to enable new language features which are not compatible with the current interpreter. For example, the @@ -228,6 +269,17 @@ More information can be found in :ref:`typeiter`. + keyword argument + Arguments which are preceded with a ``variable_name=`` in the call. + The variable name designates the local name in the function to which the + value is assigned. ``**`` is used to accept or pass a dictionary of + keyword arguments. See :term:`argument`. + + lambda + An anonymous inline function consisting of a single :term:`expression` + which is evaluated when the function is called. The syntax to create + a lambda function is ``lambda [arguments]: expression`` + LBYL Look before you leap. This coding style explicitly tests for pre-conditions before making calls or lookups. This style contrasts with @@ -258,6 +310,12 @@ singletons, and many other tasks. More information can be found in :ref:`metaclasses`. + + method + A function that is defined inside a class body. If called as an attribute + of an instance of that class, the method will get the instance object as + its first :term:`argument` (which is usually called ``self``). + See :term:`function` and :term:`nested scope`. mutable Mutable objects can change their value but keep their :func:`id`. See @@ -291,10 +349,32 @@ More information can be found in :ref:`newstyle`. + positional argument + The arguments assigned to local names inside a function or method, + determined by the order in which they were given in the call. ``*`` is + used to either accept multiple positional arguments (when in the + definition), or pass several arguments as a list to a function. See + :term:`argument`. + Python 3000 Nickname for the next major Python version, 3.0 (coined long ago when the release of version 3 was something in the distant future.) + Pythonic + An idea or piece of code which closely follows the most common idioms of + the Python language, rather than implementing code using concepts common + in other languages. For example, a common idiom in Python is the :keyword:`for` + loop structure; other languages don't have this easy keyword, so people + use a numerical counter instead:: + + for i in range(len(food)): + print food[i] + + As opposed to the cleaner, Pythonic method:: + + for piece in food: + print piece + reference count The number of places where a certain object is referenced to. When the reference count drops to zero, an object is deallocated. While reference @@ -317,6 +397,18 @@ mapping rather than a sequence because the lookups use arbitrary :term:`immutable` keys rather than integers. + slice + A list containing a portion of an indexed list-like object. A slice is + created using the subscript notation, ``[]`` with colons between numbers + when several are given, such as in ``variable_name[1:3:5]``. The bracket + (subscript) notation uses :class:`slice` objects internally (or in older + versions, :meth:`__getslice__` and :meth:`__setslice__`). + + statement + A statement is part of a suite (a "block" of code). A statement is either + an :term:`expression` or a one of several constructs with a keyword, such + as :keyword:`if`, :keyword:`while` or :keyword:`print`. + type The type of a Python object determines what kind of object it is; every object has a type. An object's type is accessible as its Modified: python/branches/py3k/Doc/library/atexit.rst ============================================================================== --- python/branches/py3k/Doc/library/atexit.rst (original) +++ python/branches/py3k/Doc/library/atexit.rst Sun Dec 2 16:22:16 2007 @@ -88,7 +88,7 @@ # or: atexit.register(goodbye, adjective='nice', name='Donny') -Usage as a decorator:: +Usage as a :term:`decorator`:: import atexit Modified: python/branches/py3k/Doc/library/bdb.rst ============================================================================== --- python/branches/py3k/Doc/library/bdb.rst (original) +++ python/branches/py3k/Doc/library/bdb.rst Sun Dec 2 16:22:16 2007 @@ -1,337 +1,337 @@ -:mod:`bdb` --- Debugger framework -================================= - -.. module:: bdb - :synopsis: Debugger framework. - -The :mod:`bdb` module handles basic debugger functions, like setting breakpoints -or managing execution via the debugger. - -The following exception is defined: - -.. exception:: BdbQuit - - Exception raised by the :class:`Bdb` class for quitting the debugger. - - -The :mod:`bdb` module also defines two classes: - -.. class:: Breakpoint(self, file, line[, temporary=0[, cond=None [, funcname=None]]]) - - This class implements temporary breakpoints, ignore counts, disabling and - (re-)enabling, and conditionals. - - Breakpoints are indexed by number through a list called :attr:`bpbynumber` - and by ``(file, line)`` pairs through :attr:`bplist`. The former points to a - single instance of class :class:`Breakpoint`. The latter points to a list of - such instances since there may be more than one breakpoint per line. - - When creating a breakpoint, its associated filename should be in canonical - form. If a *funcname* is defined, a breakpoint hit will be counted when the - first line of that function is executed. A conditional breakpoint always - counts a hit. - -:class:`Breakpoint` instances have the following methods: - -.. method:: Breakpoint.deleteMe() - - Delete the breakpoint from the list associated to a file/line. If it is the - last breakpoint in that position, it also deletes the entry for the - file/line. - -.. method:: Breakpoint.enable() - - Mark the breakpoint as enabled. - -.. method:: Breakpoint.disable() - - Mark the breakpoint as disabled. - -.. method:: Breakpoint.bpprint([out]) - - Print all the information about the breakpoint: - - * The breakpoint number. - * If it is temporary or not. - * Its file,line position. - * The condition that causes a break. - * If it must be ignored the next N times. - * The breakpoint hit count. - - -.. class:: Bdb() - - The :class:`Bdb` acts as a generic Python debugger base class. - - This class takes care of the details of the trace facility; a derived class - should implement user interaction. The standard debugger class - (:class:`pdb.Pdb`) is an example. - - -The following methods of :class:`Bdb` normally don't need to be overridden. - -.. method:: Bdb.canonic(filename) - - Auxiliary method for getting a filename in a canonical form, that is, as a - case-normalized (on case-insensitive filesystems) absolute path, stripped - of surrounding angle brackets. - -.. method:: Bdb.reset() - - Set the :attr:`botframe`, :attr:`stopframe`, :attr:`returnframe` and - :attr:`quitting` attributes with values ready to start debugging. - - -.. method:: Bdb.trace_dispatch(frame, event, arg) - - This function is installed as the trace function of debugged frames. Its - return value is the new trace function (in most cases, that is, itself). - - The default implementation decides how to dispatch a frame, depending on the - type of event (passed as a string) that is about to be executed. *event* can - be one of the following: - - * ``"line"``: A new line of code is going to be executed. - * ``"call"``: A function is about to be called, or another code block - entered. - * ``"return"``: A function or other code block is about to return. - * ``"exception"``: An exception has occurred. - * ``"c_call"``: A C function is about to be called. - * ``"c_return"``: A C function has returned. - * ``"c_exception"``: A C function has thrown an exception. - - For the Python events, specialized functions (see below) are called. For the - C events, no action is taken. - - The *arg* parameter depends on the previous event. - - For more information on trace functions, see :ref:`debugger-hooks`. For more - information on code and frame objects, refer to :ref:`types`. - -.. method:: Bdb.dispatch_line(frame) - - If the debugger should stop on the current line, invoke the :meth:`user_line` - method (which should be overridden in subclasses). Raise a :exc:`BdbQuit` - exception if the :attr:`Bdb.quitting` flag is set (which can be set from - :meth:`user_line`). Return a reference to the :meth:`trace_dispatch` method - for further tracing in that scope. - -.. method:: Bdb.dispatch_call(frame, arg) - - If the debugger should stop on this function call, invoke the - :meth:`user_call` method (which should be overridden in subclasses). Raise a - :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set (which can - be set from :meth:`user_call`). Return a reference to the - :meth:`trace_dispatch` method for further tracing in that scope. - -.. method:: Bdb.dispatch_return(frame, arg) - - If the debugger should stop on this function return, invoke the - :meth:`user_return` method (which should be overridden in subclasses). Raise - a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set (which can - be set from :meth:`user_return`). Return a reference to the - :meth:`trace_dispatch` method for further tracing in that scope. - -.. method:: Bdb.dispatch_exception(frame, arg) - - If the debugger should stop at this exception, invokes the - :meth:`user_exception` method (which should be overridden in subclasses). - Raise a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set - (which can be set from :meth:`user_exception`). Return a reference to the - :meth:`trace_dispatch` method for further tracing in that scope. - -Normally derived classes don't override the following methods, but they may if -they want to redefine the definition of stopping and breakpoints. - -.. method:: Bdb.stop_here(frame) - - This method checks if the *frame* is somewhere below :attr:`botframe` in the - call stack. :attr:`botframe` is the frame in which debugging started. - -.. method:: Bdb.break_here(frame) - - This method checks if there is a breakpoint in the filename and line - belonging to *frame* or, at least, in the current function. If the - breakpoint is a temporary one, this method deletes it. - -.. method:: Bdb.break_anywhere(frame) - - This method checks if there is a breakpoint in the filename of the current - frame. - -Derived classes should override these methods to gain control over debugger -operation. - -.. method:: Bdb.user_call(frame, argument_list) - - This method is called from :meth:`dispatch_call` when there is the - possibility that a break might be necessary anywhere inside the called - function. - -.. method:: Bdb.user_line(frame) - - This method is called from :meth:`dispatch_line` when either - :meth:`stop_here` or :meth:`break_here` yields True. - -.. method:: Bdb.user_return(frame, return_value) - - This method is called from :meth:`dispatch_return` when :meth:`stop_here` - yields True. - -.. method:: Bdb.user_exception(frame, exc_info) - - This method is called from :meth:`dispatch_exception` when :meth:`stop_here` - yields True. - -.. method:: Bdb.do_clear(arg) - - Handle how a breakpoint must be removed when it is a temporary one. - - This method must be implemented by derived classes. - - -Derived classes and clients can call the following methods to affect the -stepping state. - -.. method:: Bdb.set_step() - - Stop after one line of code. - -.. method:: Bdb.set_next(frame) - - Stop on the next line in or below the given frame. - -.. method:: Bdb.set_return(frame) - - Stop when returning from the given frame. - -.. method:: Bdb.set_trace([frame]) - - Start debugging from *frame*. If *frame* is not specified, debugging starts - from caller's frame. - -.. method:: Bdb.set_continue() - - Stop only at breakpoints or when finished. If there are no breakpoints, set - the system trace function to None. - -.. method:: Bdb.set_quit() - - Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in - the next call to one of the :meth:`dispatch_\*` methods. - - -Derived classes and clients can call the following methods to manipulate -breakpoints. These methods return a string containing an error message if -something went wrong, or ``None`` if all is well. - -.. method:: Bdb.set_break(filename, lineno[, temporary=0[, cond[, funcname]]]) - - Set a new breakpoint. If the *lineno* line doesn't exist for the *filename* - passed as argument, return an error message. The *filename* should be in - canonical form, as described in the :meth:`canonic` method. - -.. method:: Bdb.clear_break(filename, lineno) - - Delete the breakpoints in *filename* and *lineno*. If none were set, an - error message is returned. - -.. method:: Bdb.clear_bpbynumber(arg) - - Delete the breakpoint which has the index *arg* in the - :attr:`Breakpoint.bpbynumber`. If `arg` is not numeric or out of range, - return an error message. - -.. method:: Bdb.clear_all_file_breaks(filename) - - Delete all breakpoints in *filename*. If none were set, an error message is - returned. - -.. method:: Bdb.clear_all_breaks() - - Delete all existing breakpoints. - -.. method:: Bdb.get_break(filename, lineno) - - Check if there is a breakpoint for *lineno* of *filename*. - -.. method:: Bdb.get_breaks(filename, lineno) - - Return all breakpoints for *lineno* in *filename*, or an empty list if none - are set. - -.. method:: Bdb.get_file_breaks(filename) - - Return all breakpoints in *filename*, or an empty list if none are set. - -.. method:: Bdb.get_all_breaks() - - Return all breakpoints that are set. - - -Derived classes and clients can call the following methods to get a data -structure representing a stack trace. - -.. method:: Bdb.get_stack(f, t) - - Get a list of records for a frame and all higher (calling) and lower frames, - and the size of the higher part. - -.. method:: Bdb.format_stack_entry(frame_lineno, [lprefix=': ']) - - Return a string with information about a stack entry, identified by a - ``(frame, lineno)`` tuple: - - * The canonical form of the filename which contains the frame. - * The function name, or ``""``. - * The input arguments. - * The return value. - * The line of code (if it exists). - - -The following two methods can be called by clients to use a debugger to debug a -statement, given as a string. - -.. method:: Bdb.run(cmd, [globals, [locals]]) - - Debug a statement executed via the :func:`exec` function. *globals* - defaults to :attr:`__main__.__dict__`, *locals* defaults to *globals*. - -.. method:: Bdb.runeval(expr, [globals, [locals]]) - - Debug an expression executed via the :func:`eval` function. *globals* and - *locals* have the same meaning as in :meth:`run`. - -.. method:: Bdb.runctx(cmd, globals, locals) - - For backwards compatibility. Calls the :meth:`run` method. - -.. method:: Bdb.runcall(func, *args, **kwds) - - Debug a single function call, and return its result. - - -Finally, the module defines the following functions: - -.. function:: checkfuncname(b, frame) - - Check whether we should break here, depending on the way the breakpoint *b* - was set. - - If it was set via line number, it checks if ``b.line`` is the same as the one - in the frame also passed as argument. If the breakpoint was set via function - name, we have to check we are in the right frame (the right function) and if - we are in its first executable line. - -.. function:: effective(file, line, frame) - - Determine if there is an effective (active) breakpoint at this line of code. - Return breakpoint number or 0 if none. - - Called only if we know there is a breakpoint at this location. Returns the - breakpoint that was triggered and a flag that indicates if it is ok to delete - a temporary breakpoint. - -.. function:: set_trace() - - Starts debugging with a :class:`Bdb` instance from caller's frame. +:mod:`bdb` --- Debugger framework +================================= + +.. module:: bdb + :synopsis: Debugger framework. + +The :mod:`bdb` module handles basic debugger functions, like setting breakpoints +or managing execution via the debugger. + +The following exception is defined: + +.. exception:: BdbQuit + + Exception raised by the :class:`Bdb` class for quitting the debugger. + + +The :mod:`bdb` module also defines two classes: + +.. class:: Breakpoint(self, file, line[, temporary=0[, cond=None [, funcname=None]]]) + + This class implements temporary breakpoints, ignore counts, disabling and + (re-)enabling, and conditionals. + + Breakpoints are indexed by number through a list called :attr:`bpbynumber` + and by ``(file, line)`` pairs through :attr:`bplist`. The former points to a + single instance of class :class:`Breakpoint`. The latter points to a list of + such instances since there may be more than one breakpoint per line. + + When creating a breakpoint, its associated filename should be in canonical + form. If a *funcname* is defined, a breakpoint hit will be counted when the + first line of that function is executed. A conditional breakpoint always + counts a hit. + +:class:`Breakpoint` instances have the following methods: + +.. method:: Breakpoint.deleteMe() + + Delete the breakpoint from the list associated to a file/line. If it is the + last breakpoint in that position, it also deletes the entry for the + file/line. + +.. method:: Breakpoint.enable() + + Mark the breakpoint as enabled. + +.. method:: Breakpoint.disable() + + Mark the breakpoint as disabled. + +.. method:: Breakpoint.bpprint([out]) + + Print all the information about the breakpoint: + + * The breakpoint number. + * If it is temporary or not. + * Its file,line position. + * The condition that causes a break. + * If it must be ignored the next N times. + * The breakpoint hit count. + + +.. class:: Bdb() + + The :class:`Bdb` acts as a generic Python debugger base class. + + This class takes care of the details of the trace facility; a derived class + should implement user interaction. The standard debugger class + (:class:`pdb.Pdb`) is an example. + + +The following methods of :class:`Bdb` normally don't need to be overridden. + +.. method:: Bdb.canonic(filename) + + Auxiliary method for getting a filename in a canonical form, that is, as a + case-normalized (on case-insensitive filesystems) absolute path, stripped + of surrounding angle brackets. + +.. method:: Bdb.reset() + + Set the :attr:`botframe`, :attr:`stopframe`, :attr:`returnframe` and + :attr:`quitting` attributes with values ready to start debugging. + + +.. method:: Bdb.trace_dispatch(frame, event, arg) + + This function is installed as the trace function of debugged frames. Its + return value is the new trace function (in most cases, that is, itself). + + The default implementation decides how to dispatch a frame, depending on the + type of event (passed as a string) that is about to be executed. *event* can + be one of the following: + + * ``"line"``: A new line of code is going to be executed. + * ``"call"``: A function is about to be called, or another code block + entered. + * ``"return"``: A function or other code block is about to return. + * ``"exception"``: An exception has occurred. + * ``"c_call"``: A C function is about to be called. + * ``"c_return"``: A C function has returned. + * ``"c_exception"``: A C function has thrown an exception. + + For the Python events, specialized functions (see below) are called. For the + C events, no action is taken. + + The *arg* parameter depends on the previous event. + + For more information on trace functions, see :ref:`debugger-hooks`. For more + information on code and frame objects, refer to :ref:`types`. + +.. method:: Bdb.dispatch_line(frame) + + If the debugger should stop on the current line, invoke the :meth:`user_line` + method (which should be overridden in subclasses). Raise a :exc:`BdbQuit` + exception if the :attr:`Bdb.quitting` flag is set (which can be set from + :meth:`user_line`). Return a reference to the :meth:`trace_dispatch` method + for further tracing in that scope. + +.. method:: Bdb.dispatch_call(frame, arg) + + If the debugger should stop on this function call, invoke the + :meth:`user_call` method (which should be overridden in subclasses). Raise a + :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set (which can + be set from :meth:`user_call`). Return a reference to the + :meth:`trace_dispatch` method for further tracing in that scope. + +.. method:: Bdb.dispatch_return(frame, arg) + + If the debugger should stop on this function return, invoke the + :meth:`user_return` method (which should be overridden in subclasses). Raise + a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set (which can + be set from :meth:`user_return`). Return a reference to the + :meth:`trace_dispatch` method for further tracing in that scope. + +.. method:: Bdb.dispatch_exception(frame, arg) + + If the debugger should stop at this exception, invokes the + :meth:`user_exception` method (which should be overridden in subclasses). + Raise a :exc:`BdbQuit` exception if the :attr:`Bdb.quitting` flag is set + (which can be set from :meth:`user_exception`). Return a reference to the + :meth:`trace_dispatch` method for further tracing in that scope. + +Normally derived classes don't override the following methods, but they may if +they want to redefine the definition of stopping and breakpoints. + +.. method:: Bdb.stop_here(frame) + + This method checks if the *frame* is somewhere below :attr:`botframe` in the + call stack. :attr:`botframe` is the frame in which debugging started. + +.. method:: Bdb.break_here(frame) + + This method checks if there is a breakpoint in the filename and line + belonging to *frame* or, at least, in the current function. If the + breakpoint is a temporary one, this method deletes it. + +.. method:: Bdb.break_anywhere(frame) + + This method checks if there is a breakpoint in the filename of the current + frame. + +Derived classes should override these methods to gain control over debugger +operation. + +.. method:: Bdb.user_call(frame, argument_list) + + This method is called from :meth:`dispatch_call` when there is the + possibility that a break might be necessary anywhere inside the called + function. + +.. method:: Bdb.user_line(frame) + + This method is called from :meth:`dispatch_line` when either + :meth:`stop_here` or :meth:`break_here` yields True. + +.. method:: Bdb.user_return(frame, return_value) + + This method is called from :meth:`dispatch_return` when :meth:`stop_here` + yields True. + +.. method:: Bdb.user_exception(frame, exc_info) + + This method is called from :meth:`dispatch_exception` when :meth:`stop_here` + yields True. + +.. method:: Bdb.do_clear(arg) + + Handle how a breakpoint must be removed when it is a temporary one. + + This method must be implemented by derived classes. + + +Derived classes and clients can call the following methods to affect the +stepping state. + +.. method:: Bdb.set_step() + + Stop after one line of code. + +.. method:: Bdb.set_next(frame) + + Stop on the next line in or below the given frame. + +.. method:: Bdb.set_return(frame) + + Stop when returning from the given frame. + +.. method:: Bdb.set_trace([frame]) + + Start debugging from *frame*. If *frame* is not specified, debugging starts + from caller's frame. + +.. method:: Bdb.set_continue() + + Stop only at breakpoints or when finished. If there are no breakpoints, set + the system trace function to None. + +.. method:: Bdb.set_quit() + + Set the :attr:`quitting` attribute to True. This raises :exc:`BdbQuit` in + the next call to one of the :meth:`dispatch_\*` methods. + + +Derived classes and clients can call the following methods to manipulate +breakpoints. These methods return a string containing an error message if +something went wrong, or ``None`` if all is well. + +.. method:: Bdb.set_break(filename, lineno[, temporary=0[, cond[, funcname]]]) + + Set a new breakpoint. If the *lineno* line doesn't exist for the *filename* + passed as argument, return an error message. The *filename* should be in + canonical form, as described in the :meth:`canonic` method. + +.. method:: Bdb.clear_break(filename, lineno) + + Delete the breakpoints in *filename* and *lineno*. If none were set, an + error message is returned. + +.. method:: Bdb.clear_bpbynumber(arg) + + Delete the breakpoint which has the index *arg* in the + :attr:`Breakpoint.bpbynumber`. If `arg` is not numeric or out of range, + return an error message. + +.. method:: Bdb.clear_all_file_breaks(filename) + + Delete all breakpoints in *filename*. If none were set, an error message is + returned. + +.. method:: Bdb.clear_all_breaks() + + Delete all existing breakpoints. + +.. method:: Bdb.get_break(filename, lineno) + + Check if there is a breakpoint for *lineno* of *filename*. + +.. method:: Bdb.get_breaks(filename, lineno) + + Return all breakpoints for *lineno* in *filename*, or an empty list if none + are set. + +.. method:: Bdb.get_file_breaks(filename) + + Return all breakpoints in *filename*, or an empty list if none are set. + +.. method:: Bdb.get_all_breaks() + + Return all breakpoints that are set. + + +Derived classes and clients can call the following methods to get a data +structure representing a stack trace. + +.. method:: Bdb.get_stack(f, t) + + Get a list of records for a frame and all higher (calling) and lower frames, + and the size of the higher part. + +.. method:: Bdb.format_stack_entry(frame_lineno, [lprefix=': ']) + + Return a string with information about a stack entry, identified by a + ``(frame, lineno)`` tuple: + + * The canonical form of the filename which contains the frame. + * The function name, or ``""``. + * The input arguments. + * The return value. + * The line of code (if it exists). + + +The following two methods can be called by clients to use a debugger to debug a +:term:`statement`, given as a string. + +.. method:: Bdb.run(cmd, [globals, [locals]]) + + Debug a statement executed via the :keyword:`exec` statement. *globals* + defaults to :attr:`__main__.__dict__`, *locals* defaults to *globals*. + +.. method:: Bdb.runeval(expr, [globals, [locals]]) + + Debug an expression executed via the :func:`eval` function. *globals* and + *locals* have the same meaning as in :meth:`run`. + +.. method:: Bdb.runctx(cmd, globals, locals) + + For backwards compatibility. Calls the :meth:`run` method. + +.. method:: Bdb.runcall(func, *args, **kwds) + + Debug a single function call, and return its result. + + +Finally, the module defines the following functions: + +.. function:: checkfuncname(b, frame) + + Check whether we should break here, depending on the way the breakpoint *b* + was set. + + If it was set via line number, it checks if ``b.line`` is the same as the one + in the frame also passed as argument. If the breakpoint was set via function + name, we have to check we are in the right frame (the right function) and if + we are in its first executable line. + +.. function:: effective(file, line, frame) + + Determine if there is an effective (active) breakpoint at this line of code. + Return breakpoint number or 0 if none. + + Called only if we know there is a breakpoint at this location. Returns the + breakpoint that was triggered and a flag that indicates if it is ok to delete + a temporary breakpoint. + +.. function:: set_trace() + + Starts debugging with a :class:`Bdb` instance from caller's frame. Modified: python/branches/py3k/Doc/library/codeop.rst ============================================================================== --- python/branches/py3k/Doc/library/codeop.rst (original) +++ python/branches/py3k/Doc/library/codeop.rst Sun Dec 2 16:22:16 2007 @@ -43,8 +43,8 @@ :exc:`OverflowError` or :exc:`ValueError` if there is an invalid literal. The *symbol* argument determines whether *source* is compiled as a statement - (``'single'``, the default) or as an expression (``'eval'``). Any other value - will cause :exc:`ValueError` to be raised. + (``'single'``, the default) or as an :term:`expression` (``'eval'``). Any + other value will cause :exc:`ValueError` to be raised. .. warning:: Modified: python/branches/py3k/Doc/library/contextlib.rst ============================================================================== --- python/branches/py3k/Doc/library/contextlib.rst (original) +++ python/branches/py3k/Doc/library/contextlib.rst Sun Dec 2 16:22:16 2007 @@ -15,9 +15,9 @@ .. function:: contextmanager(func) - This function is a decorator that can be used to define a factory function for - :keyword:`with` statement context managers, without needing to create a class or - separate :meth:`__enter__` and :meth:`__exit__` methods. + This function is a :term:`decorator` that can be used to define a factory + function for :keyword:`with` statement context managers, without needing to + create a class or separate :meth:`__enter__` and :meth:`__exit__` methods. A simple example (this is not recommended as a real way of generating HTML!):: Modified: python/branches/py3k/Doc/library/doctest.rst ============================================================================== --- python/branches/py3k/Doc/library/doctest.rst (original) +++ python/branches/py3k/Doc/library/doctest.rst Sun Dec 2 16:22:16 2007 @@ -1070,7 +1070,8 @@ The advanced API revolves around two container classes, which are used to store the interactive examples extracted from doctest cases: -* :class:`Example`: A single python statement, paired with its expected output. +* :class:`Example`: A single python :term:`statement`, paired with its expected + output. * :class:`DocTest`: A collection of :class:`Example`\ s, typically extracted from a single docstring or text file. Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Sun Dec 2 16:22:16 2007 @@ -177,8 +177,8 @@ @classmethod def f(cls, arg1, arg2, ...): ... - The ``@classmethod`` form is a function decorator -- see the description of - function definitions in :ref:`function` for details. + The ``@classmethod`` form is a function :term:`decorator` -- see the description + of function definitions in :ref:`function` for details. It can be called either on the class (such as ``C.f()``) or on an instance (such as ``C().f()``). The instance is ignored except for its class. If a class @@ -814,7 +814,7 @@ If given, *doc* will be the docstring of the property attribute. Otherwise, the property will copy *fget*'s docstring (if it exists). This makes it possible to - create read-only properties easily using :func:`property` as a decorator:: + create read-only properties easily using :func:`property` as a :term:`decorator`:: class Parrot(object): def __init__(self): @@ -906,7 +906,7 @@ .. index:: single: Numerical Python - Return a slice object representing the set of indices specified by + Return a :term:`slice` object representing the set of indices specified by ``range(start, stop, step)``. The *start* and *step* arguments default to ``None``. Slice objects have read-only data attributes :attr:`start`, :attr:`stop` and :attr:`step` which merely return the argument values (or their @@ -952,8 +952,8 @@ @staticmethod def f(arg1, arg2, ...): ... - The ``@staticmethod`` form is a function decorator -- see the description of - function definitions in :ref:`function` for details. + The ``@staticmethod`` form is a function :term:`decorator` -- see the + description of function definitions in :ref:`function` for details. It can be called either on the class (such as ``C.f()``) or on an instance (such as ``C().f()``). The instance is ignored except for its class. Modified: python/branches/py3k/Doc/library/functools.rst ============================================================================== --- python/branches/py3k/Doc/library/functools.rst (original) +++ python/branches/py3k/Doc/library/functools.rst Sun Dec 2 16:22:16 2007 @@ -76,9 +76,9 @@ *WRAPPER_UPDATES* (which updates the wrapper function's *__dict__*, i.e. the instance dictionary). - The main intended use for this function is in decorator functions which wrap the - decorated function and return the wrapper. If the wrapper function is not - updated, the metadata of the returned function will reflect the wrapper + The main intended use for this function is in :term:`decorator` functions which + wrap the decorated function and return the wrapper. If the wrapper function is + not updated, the metadata of the returned function will reflect the wrapper definition rather than the original function definition, which is typically less than helpful. Modified: python/branches/py3k/Doc/library/inspect.rst ============================================================================== --- python/branches/py3k/Doc/library/inspect.rst (original) +++ python/branches/py3k/Doc/library/inspect.rst Sun Dec 2 16:22:16 2007 @@ -220,7 +220,7 @@ .. function:: isfunction(object) - Return true if the object is a Python function or unnamed (lambda) function. + Return true if the object is a Python function or unnamed (:term:`lambda`) function. .. function:: istraceback(object) Modified: python/branches/py3k/Doc/library/mmap.rst ============================================================================== --- python/branches/py3k/Doc/library/mmap.rst (original) +++ python/branches/py3k/Doc/library/mmap.rst Sun Dec 2 16:22:16 2007 @@ -84,6 +84,49 @@ *offset* may be specified as a non-negative integer offset. mmap references will be relative to the offset from the beginning of the file. *offset* defaults to 0. *offset* must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY. + + This example shows a simple way of using :func:`mmap`:: + + import mmap + + # write a simple example file + with open("hello.txt", "w") as f: + f.write("Hello Python!\n") + + with open("hello.txt", "r+") as f: + # memory-map the file, size 0 means whole file + map = mmap.mmap(f.fileno(), 0) + # read content via standard file methods + print map.readline() # prints "Hello Python!" + # read content via slice notation + print map[:5] # prints "Hello" + # update content using slice notation; + # note that new content must have same size + map[6:] = " world!\n" + # ... and read again using standard file methods + map.seek(0) + print map.readline() # prints "Hello world!" + # close the map + map.close() + + + The next example demonstrates how to create an anonymous map and exchange + data between the parent and child processes:: + + import mmap + import os + + map = mmap.mmap(-1, 13) + map.write("Hello world!") + + pid = os.fork() + + if pid == 0: # In a child process + map.seek(0) + print map.readline() + + map.close() + Memory-mapped file objects support the following methods: Modified: python/branches/py3k/Doc/library/operator.rst ============================================================================== --- python/branches/py3k/Doc/library/operator.rst (original) +++ python/branches/py3k/Doc/library/operator.rst Sun Dec 2 16:22:16 2007 @@ -262,10 +262,10 @@ Many operations have an "in-place" version. The following functions provide a more primitive access to in-place operators than the usual syntax does; for -example, the statement ``x += y`` is equivalent to ``x = operator.iadd(x, y)``. -Another way to put it is to say that ``z = operator.iadd(x, y)`` is equivalent -to the compound statement ``z = x; z += y``. - +example, the :term:`statement` ``x += y`` is equivalent to +``x = operator.iadd(x, y)``. Another way to put it is to say that +``z = operator.iadd(x, y)`` is equivalent to the compound statement +``z = x; z += y``. .. function:: iadd(a, b) __iadd__(a, b) Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Sun Dec 2 16:22:16 2007 @@ -2149,8 +2149,8 @@ their implementation of the context management protocol. See the :mod:`contextlib` module for some examples. -Python's :term:`generator`\s and the ``contextlib.contextfactory`` decorator provide a -convenient way to implement these protocols. If a generator function is +Python's :term:`generator`\s and the ``contextlib.contextfactory`` :term:`decorator` +provide a convenient way to implement these protocols. If a generator function is decorated with the ``contextlib.contextfactory`` decorator, it will return a context manager implementing the necessary :meth:`__enter__` and :meth:`__exit__` methods, rather than the iterator produced by an undecorated Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Sun Dec 2 16:22:16 2007 @@ -80,9 +80,9 @@ If *value* is not ``None``, this function prints it to ``sys.stdout``, and saves it in ``builtins._``. - ``sys.displayhook`` is called on the result of evaluating an expression entered - in an interactive Python session. The display of these values can be customized - by assigning another one-argument function to ``sys.displayhook``. + ``sys.displayhook`` is called on the result of evaluating an :term:`expression` + entered in an interactive Python session. The display of these values can be + customized by assigning another one-argument function to ``sys.displayhook``. .. function:: excepthook(type, value, traceback) @@ -536,14 +536,16 @@ stderr File objects corresponding to the interpreter's standard input, output and error - streams. ``stdin`` is used for all interpreter input except for scripts. - ``stdout`` is used for the output of :func:`print` and expression statements. - The interpreter's own prompts and (almost all of) its error messages go to - ``stderr``. ``stdout`` and ``stderr`` needn't be built-in file objects: any - object is acceptable as long as it has a :meth:`write` method that takes a - string argument. (Changing these objects doesn't affect the standard I/O - streams of processes executed by :func:`os.popen`, :func:`os.system` or the - :func:`exec\*` family of functions in the :mod:`os` module.) + streams. ``stdin`` is used for all interpreter input except for scripts but + including calls to :func:`input`. ``stdout`` is used for + the output of :func:`print` and :term:`expression` statements and for the + prompts of :func:`input`. The interpreter's own prompts + and (almost all of) its error messages go to ``stderr``. ``stdout`` and + ``stderr`` needn't be built-in file objects: any object is acceptable as long + as it has a :meth:`write` method that takes a string argument. (Changing these + objects doesn't affect the standard I/O streams of processes executed by + :func:`os.popen`, :func:`os.system` or the :func:`exec\*` family of functions in + the :mod:`os` module.) .. data:: __stdin__ Modified: python/branches/py3k/Doc/library/timeit.rst ============================================================================== --- python/branches/py3k/Doc/library/timeit.rst (original) +++ python/branches/py3k/Doc/library/timeit.rst Sun Dec 2 16:22:16 2007 @@ -85,11 +85,12 @@ .. note:: - By default, :meth:`timeit` temporarily turns off garbage collection during the - timing. The advantage of this approach is that it makes independent timings - more comparable. This disadvantage is that GC may be an important component of - the performance of the function being measured. If so, GC can be re-enabled as - the first statement in the *setup* string. For example:: + By default, :meth:`timeit` temporarily turns off :term:`garbage collection` + during the timing. The advantage of this approach is that it makes + independent timings more comparable. This disadvantage is that GC may be + an important component of the performance of the function being measured. + If so, GC can be re-enabled as the first statement in the *setup* string. + For example:: timeit.Timer('for i in range(10): oct(i)', 'gc.enable()').timeit() Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Sun Dec 2 16:22:16 2007 @@ -20,22 +20,22 @@ by a weak reference. A weak reference to an object is not enough to keep the object alive: when the -only remaining references to a referent are weak references, garbage collection -is free to destroy the referent and reuse its memory for something else. A -primary use for weak references is to implement caches or mappings holding large -objects, where it's desired that a large object not be kept alive solely because -it appears in a cache or mapping. For example, if you have a number of large -binary image objects, you may wish to associate a name with each. If you used a -Python dictionary to map names to images, or images to names, the image objects -would remain alive just because they appeared as values or keys in the -dictionaries. The :class:`WeakKeyDictionary`, :class:`WeakValueDictionary` -and :class:`WeakSet` classes supplied by the :mod:`weakref` module are an -alternative, using weak references to construct mappings that don't keep objects -alive solely because they appear in the container objects. -If, for example, an image object is a value in a :class:`WeakValueDictionary`, -then when the last remaining references to that image object are the weak -references held by weak mappings, garbage collection can reclaim the object, -and its corresponding entries in weak mappings are simply deleted. +only remaining references to a referent are weak references, +:term:`garbage collection` is free to destroy the referent and reuse its memory +for something else. A primary use for weak references is to implement caches or +mappings holding large objects, where it's desired that a large object not be +kept alive solely because it appears in a cache or mapping. For example, if you +have a number of large binary image objects, you may wish to associate a name +with each. If you used a Python dictionary to map names to images, or images to +names, the image objects would remain alive just because they appeared as values +or keys in the dictionaries. The :class:`WeakKeyDictionary` and +:class:`WeakValueDictionary` classes supplied by the :mod:`weakref` module are +an alternative, using weak references to construct mappings that don't keep +objects alive solely because they appear in the mapping objects. If, for +example, an image object is a value in a :class:`WeakValueDictionary`, then when +the last remaining references to that image object are the weak references held +by weak mappings, garbage collection can reclaim the object, and its +corresponding entries in weak mappings are simply deleted. :class:`WeakKeyDictionary` and :class:`WeakValueDictionary` use weak references in their implementation, setting up callback functions on the weak references Modified: python/branches/py3k/Doc/library/windows.rst ============================================================================== --- python/branches/py3k/Doc/library/windows.rst (original) +++ python/branches/py3k/Doc/library/windows.rst Sun Dec 2 16:22:16 2007 @@ -1,3 +1,4 @@ +.. _mswin-specific-services: **************************** MS Windows Specific Services Modified: python/branches/py3k/Doc/library/xml.etree.elementtree.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.etree.elementtree.rst (original) +++ python/branches/py3k/Doc/library/xml.etree.elementtree.rst Sun Dec 2 16:22:16 2007 @@ -31,6 +31,9 @@ A C implementation of this API is available as :mod:`xml.etree.cElementTree`. +See http://effbot.org/zone/element-index.htm for tutorials and links to other +docs. Fredrik Lundh's page is also the location of the development version of the +xml.etree.ElementTree. .. _elementtree-functions: @@ -355,6 +358,33 @@ object opened for writing. *encoding* is the output encoding (default is US-ASCII). +This is the XML file that is going to be manipulated:: + + + + Example page + + +

Moved to example.org + or example.com.

+ + + +Example of changing the attribute "target" of every link in first paragraph:: + + >>> from xml.etree.ElementTree import ElementTree + >>> tree = ElementTree() + >>> tree.parse("index.xhtml") + + >>> p = tree.find("body/p") # Finds first occurrence of tag p in body + >>> p + + >>> links = p.getiterator("a") # Returns list of all links + >>> links + [, ] + >>> for i in links: # Iterates through all found links + ... i.attrib["target"] = "blank" + >>> tree.write("output.xhtml") .. _elementtree-qname-objects: @@ -440,3 +470,41 @@ Feeds data to the parser. *data* is encoded data. +:meth:`XMLTreeBuilder.feed` calls *target*\'s :meth:`start` method +for each opening tag, its :meth:`end` method for each closing tag, +and data is processed by method :meth:`data`. :meth:`XMLTreeBuilder.close` +calls *target*\'s method :meth:`close`. +:class:`XMLTreeBuilder` can be used not only for building a tree structure. +This is an example of counting the maximum depth of an XML file:: + + >>> from xml.etree.ElementTree import XMLTreeBuilder + >>> class MaxDepth: # The target object of the parser + ... maxDepth = 0 + ... depth = 0 + ... def start(self, tag, attrib): # Called for each opening tag. + ... self.depth += 1 + ... if self.depth > self.maxDepth: + ... self.maxDepth = self.depth + ... def end(self, tag): # Called for each closing tag. + ... self.depth -= 1 + ... def data(self, data): + ... pass # We do not need to do anything with data. + ... def close(self): # Called when all data has been parsed. + ... return self.maxDepth + ... + >>> target = MaxDepth() + >>> parser = XMLTreeBuilder(target=target) + >>> exampleXml = """ + ... + ... + ... + ... + ... + ... + ... + ... + ... + ... """ + >>> parser.feed(exampleXml) + >>> parser.close() + 4 Modified: python/branches/py3k/Doc/reference/compound_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/compound_stmts.rst (original) +++ python/branches/py3k/Doc/reference/compound_stmts.rst Sun Dec 2 16:22:16 2007 @@ -421,7 +421,7 @@ The function definition does not execute the function body; this gets executed only when the function is called. -A function definition may be wrapped by one or more decorator expressions. +A function definition may be wrapped by one or more :term:`decorator` expressions. Decorator expressions are evaluated when the function is defined, in the scope that contains the function definition. The result must be a callable, which is invoked with the function object as the only argument. The returned value is Modified: python/branches/py3k/Doc/tutorial/stdlib2.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/stdlib2.rst (original) +++ python/branches/py3k/Doc/tutorial/stdlib2.rst Sun Dec 2 16:22:16 2007 @@ -244,8 +244,8 @@ =============== Python does automatic memory management (reference counting for most objects and -garbage collection to eliminate cycles). The memory is freed shortly after the -last reference to it has been eliminated. +:term:`garbage collection` to eliminate cycles). The memory is freed shortly +after the last reference to it has been eliminated. This approach works fine for most applications but occasionally there is a need to track objects only as long as they are being used by something else. Modified: python/branches/py3k/Doc/using/cmdline.rst ============================================================================== --- python/branches/py3k/Doc/using/cmdline.rst (original) +++ python/branches/py3k/Doc/using/cmdline.rst Sun Dec 2 16:22:16 2007 @@ -1,5 +1,7 @@ .. highlightlang:: none +.. _using-on-general: + Command line and environment ============================ @@ -12,6 +14,8 @@ :ref:`implementations` for further resources. +.. _using-on-cmdline: + Command line ------------ @@ -289,35 +293,7 @@ .. warning:: The line numbers in error messages will be off by one! - -Related files -- UNIX ---------------------- - -These are subject to difference depending on local installation conventions; -:envvar:`prefix` (``${prefix}``) and :envvar:`exec_prefix` (``${exec_prefix}``) -are installation-dependent and should be interpreted as for GNU software; they -may be the same. - -For example, on most Linux systems, the default for both is :file:`/usr`. - -+-----------------------------------------------+------------------------------------------+ -| File/directory | Meaning | -+===============================================+==========================================+ -| :file:`{exec_prefix}/bin/python` | Recommended location of the interpreter. | -+-----------------------------------------------+------------------------------------------+ -| :file:`{prefix}/lib/python{version}`, | Recommended locations of the directories | -| :file:`{exec_prefix}/lib/python{version}` | containing the standard modules. | -+-----------------------------------------------+------------------------------------------+ -| :file:`{prefix}/include/python{version}`, | Recommended locations of the directories | -| :file:`{exec_prefix}/include/python{version}` | containing the include files needed for | -| | developing Python extensions and | -| | embedding the interpreter. | -+-----------------------------------------------+------------------------------------------+ -| :file:`~/.pythonrc.py` | User-specific initialization file loaded | -| | by the user module; not used by default | -| | or by most applications. | -+-----------------------------------------------+------------------------------------------+ - +.. _using-on-envvars: Environment variables --------------------- Modified: python/branches/py3k/Doc/using/index.rst ============================================================================== --- python/branches/py3k/Doc/using/index.rst (original) +++ python/branches/py3k/Doc/using/index.rst Sun Dec 2 16:22:16 2007 @@ -13,5 +13,6 @@ .. toctree:: cmdline.rst + windows.rst mac.rst Modified: python/branches/py3k/Lib/tarfile.py ============================================================================== --- python/branches/py3k/Lib/tarfile.py (original) +++ python/branches/py3k/Lib/tarfile.py Sun Dec 2 16:22:16 2007 @@ -1542,7 +1542,8 @@ self.closed = False self.members = [] # list of members as TarInfo objects self._loaded = False # flag if all members have been read - self.offset = 0 # current position in the archive file + self.offset = self.fileobj.tell() + # current position in the archive file self.inodes = {} # dictionary caching the inodes of # archive members already added Modified: python/branches/py3k/Lib/test/test_tarfile.py ============================================================================== --- python/branches/py3k/Lib/test/test_tarfile.py (original) +++ python/branches/py3k/Lib/test/test_tarfile.py Sun Dec 2 16:22:16 2007 @@ -159,6 +159,38 @@ tar = tarfile.open(fileobj=fobj, mode=self.mode) self.assertEqual(tar.name, None) + def test_fileobj_with_offset(self): + # Skip the first member and store values from the second member + # of the testtar. + tar = tarfile.open(self.tarname, mode=self.mode) + tar.next() + t = tar.next() + name = t.name + offset = t.offset + data = tar.extractfile(t).read() + tar.close() + + # Open the testtar and seek to the offset of the second member. + if self.mode.endswith(":gz"): + _open = gzip.GzipFile + elif self.mode.endswith(":bz2"): + _open = bz2.BZ2File + else: + _open = open + fobj = _open(self.tarname, "rb") + fobj.seek(offset) + + # Test if the tarfile starts with the second member. + tar = tar.open(self.tarname, mode="r:", fileobj=fobj) + t = tar.next() + self.assertEqual(t.name, name) + # Read to the end of fileobj and test if seeking back to the + # beginning works. + tar.getmembers() + self.assertEqual(tar.extractfile(t).read(), data, + "seek back did not work") + tar.close() + def test_fail_comp(self): # For Gzip and Bz2 Tests: fail with a ReadError on an uncompressed file. if self.mode == "r:": Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Sun Dec 2 16:22:16 2007 @@ -579,6 +579,7 @@ David Scherer Gregor Schmid Ralf Schmitt +Michael Schneider Peter Schneider-Kamp Arvin Schnell Chad J. Schroeder From python-3000-checkins at python.org Sun Dec 2 16:27:39 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 16:27:39 +0100 (CET) Subject: [Python-3000-checkins] r59276 - python/branches/py3k/Lib/encodings/aliases.py python/branches/py3k/Lib/encodings/bz2_codec.py Message-ID: <20071202152739.44FEA1E4022@bag.python.org> Author: christian.heimes Date: Sun Dec 2 16:27:38 2007 New Revision: 59276 Removed: python/branches/py3k/Lib/encodings/bz2_codec.py Modified: python/branches/py3k/Lib/encodings/aliases.py Log: The bz2 codec isn't supported any more. I've also commented out several codecs which were removed in the past. Modified: python/branches/py3k/Lib/encodings/aliases.py ============================================================================== --- python/branches/py3k/Lib/encodings/aliases.py (original) +++ python/branches/py3k/Lib/encodings/aliases.py Sun Dec 2 16:27:38 2007 @@ -33,9 +33,9 @@ 'us' : 'ascii', 'us_ascii' : 'ascii', - # base64_codec codec - 'base64' : 'base64_codec', - 'base_64' : 'base64_codec', + ## base64_codec codec + #'base64' : 'base64_codec', + #'base_64' : 'base64_codec', # big5 codec 'big5_tw' : 'big5', @@ -45,8 +45,8 @@ 'big5_hkscs' : 'big5hkscs', 'hkscs' : 'big5hkscs', - # bz2_codec codec - 'bz2' : 'bz2_codec', + ## bz2_codec codec + #'bz2' : 'bz2_codec', # cp037 codec '037' : 'cp037', @@ -243,8 +243,8 @@ 'cp936' : 'gbk', 'ms936' : 'gbk', - # hex_codec codec - 'hex' : 'hex_codec', + ## hex_codec codec + #'hex' : 'hex_codec', # hp_roman8 codec 'roman8' : 'hp_roman8', @@ -444,13 +444,13 @@ 'cp154' : 'ptcp154', 'cyrillic-asian' : 'ptcp154', - # quopri_codec codec - 'quopri' : 'quopri_codec', - 'quoted_printable' : 'quopri_codec', - 'quotedprintable' : 'quopri_codec', + ## quopri_codec codec + #'quopri' : 'quopri_codec', + #'quoted_printable' : 'quopri_codec', + #'quotedprintable' : 'quopri_codec', - # rot_13 codec - 'rot13' : 'rot_13', + ## rot_13 codec + #'rot13' : 'rot_13', # shift_jis codec 'csshiftjis' : 'shift_jis', @@ -512,11 +512,11 @@ 'utf8_ucs2' : 'utf_8', 'utf8_ucs4' : 'utf_8', - # uu_codec codec - 'uu' : 'uu_codec', + ## uu_codec codec + #'uu' : 'uu_codec', - # zlib_codec codec - 'zip' : 'zlib_codec', - 'zlib' : 'zlib_codec', + ## zlib_codec codec + #'zip' : 'zlib_codec', + #'zlib' : 'zlib_codec', } Deleted: /python/branches/py3k/Lib/encodings/bz2_codec.py ============================================================================== --- /python/branches/py3k/Lib/encodings/bz2_codec.py Sun Dec 2 16:27:38 2007 +++ (empty file) @@ -1,102 +0,0 @@ -""" Python 'bz2_codec' Codec - bz2 compression encoding - - Unlike most of the other codecs which target Unicode, this codec - will return Python string objects for both encode and decode. - - Adapted by Raymond Hettinger from zlib_codec.py which was written - by Marc-Andre Lemburg (mal at lemburg.com). - -""" -import codecs -import bz2 # this codec needs the optional bz2 module ! - -### Codec APIs - -def bz2_encode(input,errors='strict'): - - """ Encodes the object input and returns a tuple (output - object, length consumed). - - errors defines the error handling to apply. It defaults to - 'strict' handling which is the only currently supported - error handling for this codec. - - """ - assert errors == 'strict' - output = bz2.compress(input) - return (output, len(input)) - -def bz2_decode(input,errors='strict'): - - """ Decodes the object input and returns a tuple (output - object, length consumed). - - input must be an object which provides the bf_getreadbuf - buffer slot. Python strings, buffer objects and memory - mapped files are examples of objects providing this slot. - - errors defines the error handling to apply. It defaults to - 'strict' handling which is the only currently supported - error handling for this codec. - - """ - assert errors == 'strict' - output = bz2.decompress(input) - return (output, len(input)) - -class Codec(codecs.Codec): - - def encode(self, input, errors='strict'): - return bz2_encode(input, errors) - def decode(self, input, errors='strict'): - return bz2_decode(input, errors) - -class IncrementalEncoder(codecs.IncrementalEncoder): - def __init__(self, errors='strict'): - assert errors == 'strict' - self.errors = errors - self.compressobj = bz2.BZ2Compressor() - - def encode(self, input, final=False): - if final: - c = self.compressobj.compress(input) - return c + self.compressobj.flush() - else: - return self.compressobj.compress(input) - - def reset(self): - self.compressobj = bz2.BZ2Compressor() - -class IncrementalDecoder(codecs.IncrementalDecoder): - def __init__(self, errors='strict'): - assert errors == 'strict' - self.errors = errors - self.decompressobj = bz2.BZ2Decompressor() - - def decode(self, input, final=False): - try: - return self.decompressobj.decompress(input) - except EOFError: - return '' - - def reset(self): - self.decompressobj = bz2.BZ2Decompressor() - -class StreamWriter(Codec,codecs.StreamWriter): - pass - -class StreamReader(Codec,codecs.StreamReader): - pass - -### encodings module API - -def getregentry(): - return codecs.CodecInfo( - name="bz2", - encode=bz2_encode, - decode=bz2_decode, - incrementalencoder=IncrementalEncoder, - incrementaldecoder=IncrementalDecoder, - streamwriter=StreamWriter, - streamreader=StreamReader, - ) From python-3000-checkins at python.org Sun Dec 2 17:50:20 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 17:50:20 +0100 (CET) Subject: [Python-3000-checkins] r59277 - python/branches/py3k/Lib/test/test_cmd.py Message-ID: <20071202165020.760501E47B9@bag.python.org> Author: christian.heimes Date: Sun Dec 2 17:50:20 2007 New Revision: 59277 Modified: python/branches/py3k/Lib/test/test_cmd.py Log: Fixed merge accident. Next time I'm going to run the entire test suite ... Modified: python/branches/py3k/Lib/test/test_cmd.py ============================================================================== --- python/branches/py3k/Lib/test/test_cmd.py (original) +++ python/branches/py3k/Lib/test/test_cmd.py Sun Dec 2 17:50:20 2007 @@ -8,6 +8,9 @@ from test import test_support import cmd import sys +import trace +import re +from io import StringIO class samplecmdclass(cmd.Cmd): """ @@ -95,9 +98,9 @@ Test for the function columnize(): - >>> mycmd.columnize([str(i) for i in xrange(20)]) + >>> mycmd.columnize([str(i) for i in range(20)]) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 - >>> mycmd.columnize([str(i) for i in xrange(20)], 10) + >>> mycmd.columnize([str(i) for i in range(20)], 10) 0 7 14 1 8 15 2 9 16 @@ -131,18 +134,16 @@ """ def preloop(self): - print "Hello from preloop" + print("Hello from preloop") def postloop(self): - print "Hello from postloop" + print("Hello from postloop") def completedefault(self, *ignored): - print "This is the completedefault methode" - return + print("This is the completedefault methode") def complete_command(self): - print "complete command" - return + print("complete command") def do_shell(self): pass @@ -150,17 +151,17 @@ def do_add(self, s): l = s.split() if len(l) != 2: - print "*** invalid number of arguments" + print("*** invalid number of arguments") return try: l = [int(i) for i in l] except ValueError: - print "*** arguments should be numbers" + print("*** arguments should be numbers") return - print l[0]+l[1] + print(l[0]+l[1]) def help_add(self): - print "help text for add" + print("help text for add") return def do_exit(self, arg): @@ -170,13 +171,12 @@ from test import test_support, test_cmd test_support.run_doctest(test_cmd, verbose) -import trace, sys,re,StringIO def test_coverage(coverdir): tracer=trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0, count=1) tracer.run('reload(cmd);test_main()') r=tracer.results() - print "Writing coverage results..." + print("Writing coverage results...") r.write_results(show_missing=True, summary=True, coverdir=coverdir) if __name__ == "__main__": From python-3000-checkins at python.org Sun Dec 2 17:52:32 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 17:52:32 +0100 (CET) Subject: [Python-3000-checkins] r59278 - in python/branches/py3k: Doc/whatsnew/3.0.rst Include/Python.h Include/intobject.h Include/longobject.h Makefile.pre.in Misc/NEWS Message-ID: <20071202165232.D91CD1E47BE@bag.python.org> Author: christian.heimes Date: Sun Dec 2 17:52:32 2007 New Revision: 59278 Modified: python/branches/py3k/Doc/whatsnew/3.0.rst python/branches/py3k/Include/Python.h python/branches/py3k/Include/intobject.h python/branches/py3k/Include/longobject.h python/branches/py3k/Makefile.pre.in python/branches/py3k/Misc/NEWS Log: I've moved the remains of PyInt_ to the longobject.h header file and removed the inclusing of intobject.h from Python.h. Now the intobject.h exists only to provide some aliases for porters from Python 2.x. Modified: python/branches/py3k/Doc/whatsnew/3.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/3.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/3.0.rst Sun Dec 2 17:52:32 2007 @@ -387,6 +387,8 @@ * Everything is all in the details! +* Developers can include intobject.h after Python.h for some PyInt_ aliases. + .. ====================================================================== Modified: python/branches/py3k/Include/Python.h ============================================================================== --- python/branches/py3k/Include/Python.h (original) +++ python/branches/py3k/Include/Python.h Sun Dec 2 17:52:32 2007 @@ -66,7 +66,6 @@ #include "bytesobject.h" #include "unicodeobject.h" -#include "intobject.h" #include "longobject.h" #include "longintrepr.h" #include "boolobject.h" Modified: python/branches/py3k/Include/intobject.h ============================================================================== --- python/branches/py3k/Include/intobject.h (original) +++ python/branches/py3k/Include/intobject.h Sun Dec 2 17:52:32 2007 @@ -1,18 +1,9 @@ +/* Integer object interface -/* Integer object interface */ - -/* -PyIntObject represents a (long) integer. This is an immutable object; -an integer cannot change its value after creation. - -There are functions to create new integer objects, to test an object -for integer-ness, and to get the integer value. The latter functions -returns -1 and sets errno to EBADF if the object is not an PyIntObject. -None of the functions should be applied to nil objects. - -The type PyIntObject is (unfortunately) exposed here so we can declare -_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this. -*/ + This header files exists to make porting code to Python 3.0 easier. It + defines aliases from PyInt_* to PyLong_*. Only PyInt_GetMax() and + PyInt_CheckExact() remain in longobject.h. + */ #ifndef Py_INTOBJECT_H #define Py_INTOBJECT_H @@ -20,38 +11,19 @@ extern "C" { #endif -/* -typedef struct { - PyObject_HEAD - long ob_ival; -} PyIntObject; - -PyAPI_DATA(PyTypeObject) PyInt_Type; -*/ - -#define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op)) - -#if 0 -# define PyInt_Check(op) PyLong_Check(op) -# define PyInt_FromString PyLong_FromString -# define PyInt_FromUnicode PyLong_FromUnicode -# define PyInt_FromLong PyLong_FromLong -# define PyInt_FromSize_t PyLong_FromSize_t -# define PyInt_FromSsize_t PyLong_FromSsize_t -# define PyInt_AsLong PyLong_AsLong -# define PyInt_AsSsize_t PyLong_AsSsize_t -# define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask -# define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask -# define PyInt_AS_LONG PyLong_AS_LONG -#endif - -PyAPI_FUNC(long) PyInt_GetMax(void); +#warning "DeprecationWarning: intobject.h is going to be removed in 3.1" -/* These aren't really part of the Int object, but they're handy; the protos - * are necessary for systems that need the magic of PyAPI_FUNC. - */ -PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); -PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); +#define PyInt_Check(op) PyLong_Check(op) +#define PyInt_FromString PyLong_FromString +#define PyInt_FromUnicode PyLong_FromUnicode +#define PyInt_FromLong PyLong_FromLong +#define PyInt_FromSize_t PyLong_FromSize_t +#define PyInt_FromSsize_t PyLong_FromSsize_t +#define PyInt_AsLong PyLong_AsLong +#define PyInt_AsSsize_t PyLong_AsSsize_t +#define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask +#define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask +#define PyInt_AS_LONG PyLong_AS_LONG #ifdef __cplusplus } Modified: python/branches/py3k/Include/longobject.h ============================================================================== --- python/branches/py3k/Include/longobject.h (original) +++ python/branches/py3k/Include/longobject.h Sun Dec 2 17:52:32 2007 @@ -14,6 +14,7 @@ #define PyLong_Check(op) \ PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LONG_SUBCLASS) #define PyLong_CheckExact(op) (Py_Type(op) == &PyLong_Type) +#define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op)) PyAPI_FUNC(PyObject *) PyLong_FromLong(long); PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); @@ -30,6 +31,8 @@ cleanup to keep the extra information. [CH] */ #define PyLong_AS_LONG(op) PyLong_AsLong(op) +PyAPI_FUNC(long) PyInt_GetMax(void); + /* Used by socketmodule.c */ #if SIZEOF_SOCKET_T <= SIZEOF_LONG #define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd)) @@ -127,6 +130,12 @@ appending a base prefix of 0[box] if base is 2, 8 or 16. */ PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base); +/* These aren't really part of the long object, but they're handy. The + functions are in Python/mystrtoul.c. + */ +PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); +PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); + #ifdef __cplusplus } #endif Modified: python/branches/py3k/Makefile.pre.in ============================================================================== --- python/branches/py3k/Makefile.pre.in (original) +++ python/branches/py3k/Makefile.pre.in Sun Dec 2 17:52:32 2007 @@ -546,6 +546,7 @@ Include/asdl.h \ Include/abstract.h \ Include/boolobject.h \ + Include/bytes_methods.h \ Include/bytesobject.h \ Include/ceval.h \ Include/classobject.h \ @@ -563,10 +564,10 @@ Include/formatter_unicode.h \ Include/funcobject.h \ Include/import.h \ - Include/intobject.h \ Include/intrcheck.h \ Include/iterobject.h \ Include/listobject.h \ + Include/longintrepr.h \ Include/longobject.h \ Include/memoryobject.h \ Include/methodobject.h \ Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Sun Dec 2 17:52:32 2007 @@ -50,6 +50,10 @@ removed and im_func + im_self are renamed to __func__ and __self__. The factory PyMethod_New takes only func and instance as argument. +- intobject.h is no longer included by Python.h. The remains were moved + to longobject.h. It still exists to define several aliases from PyInt_ + to PyLong_ functions. + Extension Modules ----------------- From python-3000-checkins at python.org Sun Dec 2 19:20:13 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Sun, 2 Dec 2007 19:20:13 +0100 (CET) Subject: [Python-3000-checkins] r59280 - in python/branches/py3k/Doc: glossary.rst library/mmap.rst Message-ID: <20071202182013.1F7131E4020@bag.python.org> Author: georg.brandl Date: Sun Dec 2 19:20:12 2007 New Revision: 59280 Modified: python/branches/py3k/Doc/glossary.rst python/branches/py3k/Doc/library/mmap.rst Log: Fix some 2.xisms in merged docs. Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Sun Dec 2 19:20:12 2007 @@ -71,6 +71,8 @@ def f(...): ... + The same concept exists for classes, but is less commonly used there. + descriptor An object that defines the methods :meth:`__get__`, :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a descriptor, its special @@ -114,7 +116,7 @@ attribute access, operators or function calls that all return a value. In contrast to other languages, not all language constructs are expressions, but there are also :term:`statement`\s that cannot be used as expressions, - such as :keyword:`print` or :keyword:`if`. Assignments are also not + such as :keyword:`while` or :keyword:`if`. Assignments are also not expressions. extension module @@ -357,7 +359,7 @@ :term:`argument`. Python 3000 - Nickname for the next major Python version, 3.0 (coined long ago when the + Nickname for the Python 3.x release line (coined long ago when the release of version 3 was something in the distant future.) Pythonic @@ -368,12 +370,12 @@ use a numerical counter instead:: for i in range(len(food)): - print food[i] + print(food[i]) As opposed to the cleaner, Pythonic method:: for piece in food: - print piece + print(piece) reference count The number of places where a certain object is referenced to. When the @@ -398,16 +400,15 @@ :term:`immutable` keys rather than integers. slice - A list containing a portion of an indexed list-like object. A slice is + An object usually containing a portion of a :term:`sequence`. A slice is created using the subscript notation, ``[]`` with colons between numbers when several are given, such as in ``variable_name[1:3:5]``. The bracket - (subscript) notation uses :class:`slice` objects internally (or in older - versions, :meth:`__getslice__` and :meth:`__setslice__`). + (subscript) notation uses :class:`slice` objects internally. statement A statement is part of a suite (a "block" of code). A statement is either an :term:`expression` or a one of several constructs with a keyword, such - as :keyword:`if`, :keyword:`while` or :keyword:`print`. + as :keyword:`if`, :keyword:`while` or :keyword:`for`. type The type of a Python object determines what kind of object it is; every Modified: python/branches/py3k/Doc/library/mmap.rst ============================================================================== --- python/branches/py3k/Doc/library/mmap.rst (original) +++ python/branches/py3k/Doc/library/mmap.rst Sun Dec 2 19:20:12 2007 @@ -97,15 +97,15 @@ # memory-map the file, size 0 means whole file map = mmap.mmap(f.fileno(), 0) # read content via standard file methods - print map.readline() # prints "Hello Python!" + print(map.readline()) # prints "Hello Python!" # read content via slice notation - print map[:5] # prints "Hello" + print(map[:5]) # prints "Hello" # update content using slice notation; # note that new content must have same size map[6:] = " world!\n" # ... and read again using standard file methods map.seek(0) - print map.readline() # prints "Hello world!" + print(map.readline()) # prints "Hello world!" # close the map map.close() @@ -123,7 +123,7 @@ if pid == 0: # In a child process map.seek(0) - print map.readline() + print(map.readline()) map.close() From python-3000-checkins at python.org Sun Dec 2 23:43:01 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sun, 2 Dec 2007 23:43:01 +0100 (CET) Subject: [Python-3000-checkins] r59282 - python/branches/py3k/Parser/asdl_c.py Message-ID: <20071202224301.252DF1E4021@bag.python.org> Author: christian.heimes Date: Sun Dec 2 23:43:00 2007 New Revision: 59282 Modified: python/branches/py3k/Parser/asdl_c.py Log: Fixed a problem found by Bill Janssen on Mac OS X There was one occurence of PyInt_FromLong left in Parser/asdl_c.py. The files creates some C code. Modified: python/branches/py3k/Parser/asdl_c.py ============================================================================== --- python/branches/py3k/Parser/asdl_c.py (original) +++ python/branches/py3k/Parser/asdl_c.py Sun Dec 2 23:43:00 2007 @@ -469,7 +469,7 @@ static PyObject* ast2obj_int(long b) { - return PyInt_FromLong(b); + return PyLong_FromLong(b); } """, 0, reflow=False) From python-3000-checkins at python.org Sun Dec 2 23:48:17 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Sun, 2 Dec 2007 23:48:17 +0100 (CET) Subject: [Python-3000-checkins] r59283 - in python/branches/py3k/Doc: library/crypt.rst library/smtplib.rst library/telnetlib.rst library/termios.rst library/traceback.rst tutorial/stdlib2.rst Message-ID: <20071202224817.6EFB21E4025@bag.python.org> Author: georg.brandl Date: Sun Dec 2 23:48:17 2007 New Revision: 59283 Modified: python/branches/py3k/Doc/library/crypt.rst python/branches/py3k/Doc/library/smtplib.rst python/branches/py3k/Doc/library/telnetlib.rst python/branches/py3k/Doc/library/termios.rst python/branches/py3k/Doc/library/traceback.rst python/branches/py3k/Doc/tutorial/stdlib2.rst Log: Remove all definitions of raw_input() that were still scattered throughout the docs from the time where there was neither input() nor raw_input(). Modified: python/branches/py3k/Doc/library/crypt.rst ============================================================================== --- python/branches/py3k/Doc/library/crypt.rst (original) +++ python/branches/py3k/Doc/library/crypt.rst Sun Dec 2 23:48:17 2007 @@ -47,14 +47,8 @@ import crypt, getpass, pwd - def raw_input(prompt): - import sys - sys.stdout.write(prompt) - sys.stdout.flush() - return sys.stdin.readline() - def login(): - username = raw_input('Python login:') + username = input('Python login:') cryptedpasswd = pwd.getpwnam(username)[1] if cryptedpasswd: if cryptedpasswd == 'x' or cryptedpasswd == '*': Modified: python/branches/py3k/Doc/library/smtplib.rst ============================================================================== --- python/branches/py3k/Doc/library/smtplib.rst (original) +++ python/branches/py3k/Doc/library/smtplib.rst Sun Dec 2 23:48:17 2007 @@ -306,14 +306,8 @@ import smtplib - def raw_input(prompt): - import sys - sys.stdout.write(prompt) - sys.stdout.flush() - return sys.stdin.readline() - def prompt(prompt): - return raw_input(prompt).strip() + return input(prompt).strip() fromaddr = prompt("From: ") toaddrs = prompt("To: ").split() @@ -324,7 +318,7 @@ % (fromaddr, ", ".join(toaddrs))) while True: try: - line = raw_input() + line = input() except EOFError: break if not line: Modified: python/branches/py3k/Doc/library/telnetlib.rst ============================================================================== --- python/branches/py3k/Doc/library/telnetlib.rst (original) +++ python/branches/py3k/Doc/library/telnetlib.rst Sun Dec 2 23:48:17 2007 @@ -211,16 +211,10 @@ A simple example illustrating typical use:: import getpass - import sys import telnetlib - def raw_input(prompt): - sys.stdout.write(prompt) - sys.stdout.flush() - return sys.stdin.readline() - HOST = "localhost" - user = raw_input("Enter your remote account: ") + user = input("Enter your remote account: ") password = getpass.getpass() tn = telnetlib.Telnet(HOST) Modified: python/branches/py3k/Doc/library/termios.rst ============================================================================== --- python/branches/py3k/Doc/library/termios.rst (original) +++ python/branches/py3k/Doc/library/termios.rst Sun Dec 2 23:48:17 2007 @@ -90,12 +90,6 @@ :keyword:`finally` statement to ensure that the old tty attributes are restored exactly no matter what happens:: - def raw_input(prompt): - import sys - sys.stdout.write(prompt) - sys.stdout.flush() - return sys.stdin.readline() - def getpass(prompt = "Password: "): import termios, sys fd = sys.stdin.fileno() @@ -104,7 +98,7 @@ new[3] = new[3] & ~termios.ECHO # lflags try: termios.tcsetattr(fd, termios.TCSADRAIN, new) - passwd = raw_input(prompt) + passwd = input(prompt) finally: termios.tcsetattr(fd, termios.TCSADRAIN, old) return passwd Modified: python/branches/py3k/Doc/library/traceback.rst ============================================================================== --- python/branches/py3k/Doc/library/traceback.rst (original) +++ python/branches/py3k/Doc/library/traceback.rst Sun Dec 2 23:48:17 2007 @@ -143,7 +143,7 @@ import sys, traceback def run_user_code(envdir): - source = raw_input(">>> ") + source = input(">>> ") try: exec(source, envdir) except: Modified: python/branches/py3k/Doc/tutorial/stdlib2.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/stdlib2.rst (original) +++ python/branches/py3k/Doc/tutorial/stdlib2.rst Sun Dec 2 23:48:17 2007 @@ -104,16 +104,11 @@ renaming utility for a photo browser may elect to use percent signs for placeholders such as the current date, image sequence number, or file format:: - >>> import time, os.path, sys - >>> def raw_input(prompt): - ... sys.stdout.write(prompt) - ... sys.stdout.flush() - ... return sys.stdin.readline() - ... + >>> import time, os.path >>> photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg'] >>> class BatchRename(Template): ... delimiter = '%' - >>> fmt = raw_input('Enter rename style (%d-date %n-seqnum %f-format): ') + >>> fmt = input('Enter rename style (%d-date %n-seqnum %f-format): ') Enter rename style (%d-date %n-seqnum %f-format): Ashley_%n%f >>> t = BatchRename(fmt) From python-3000-checkins at python.org Mon Dec 3 00:08:39 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 3 Dec 2007 00:08:39 +0100 (CET) Subject: [Python-3000-checkins] r59284 - in python/branches/py3k/Doc: c-api/concrete.rst extending/extending.rst Message-ID: <20071202230839.E253F1E4021@bag.python.org> Author: georg.brandl Date: Mon Dec 3 00:08:39 2007 New Revision: 59284 Modified: python/branches/py3k/Doc/c-api/concrete.rst python/branches/py3k/Doc/extending/extending.rst Log: Remove PyInt API from the docs. Extend PyLong docs to cover all public functions in longobject.c. Modified: python/branches/py3k/Doc/c-api/concrete.rst ============================================================================== --- python/branches/py3k/Doc/c-api/concrete.rst (original) +++ python/branches/py3k/Doc/c-api/concrete.rst Mon Dec 3 00:08:39 2007 @@ -132,115 +132,6 @@ .. index:: object: numeric -.. _intobjects: - -Plain Integer Objects ---------------------- - -.. index:: object: integer - - -.. ctype:: PyIntObject - - This subtype of :ctype:`PyObject` represents a Python integer object. - - -.. cvar:: PyTypeObject PyInt_Type - - .. index:: single: IntType (in modules types) - - This instance of :ctype:`PyTypeObject` represents the Python plain integer type. - This is the same object as ``int`` and ``types.IntType``. - - -.. cfunction:: int PyInt_Check(PyObject *o) - - Return true if *o* is of type :cdata:`PyInt_Type` or a subtype of - :cdata:`PyInt_Type`. - - -.. cfunction:: int PyInt_CheckExact(PyObject *o) - - Return true if *o* is of type :cdata:`PyInt_Type`, but not a subtype of - :cdata:`PyInt_Type`. - - -.. cfunction:: PyObject* PyInt_FromString(char *str, char **pend, int base) - - Return a new :ctype:`PyIntObject` or :ctype:`PyLongObject` based on the string - value in *str*, which is interpreted according to the radix in *base*. If - *pend* is non-*NULL*, ``*pend`` will point to the first character in *str* which - follows the representation of the number. If *base* is ``0``, the radix will be - determined based on the leading characters of *str*: if *str* starts with - ``'0x'`` or ``'0X'``, radix 16 will be used; if *str* starts with ``'0'``, radix - 8 will be used; otherwise radix 10 will be used. If *base* is not ``0``, it - must be between ``2`` and ``36``, inclusive. Leading spaces are ignored. If - there are no digits, :exc:`ValueError` will be raised. If the string represents - a number too large to be contained within the machine's :ctype:`long int` type - and overflow warnings are being suppressed, a :ctype:`PyLongObject` will be - returned. If overflow warnings are not being suppressed, *NULL* will be - returned in this case. - - -.. cfunction:: PyObject* PyInt_FromLong(long ival) - - Create a new integer object with a value of *ival*. - - The current implementation keeps an array of integer objects for all integers - between ``-5`` and ``256``, when you create an int in that range you actually - just get back a reference to the existing object. So it should be possible to - change the value of ``1``. I suspect the behaviour of Python in this case is - undefined. :-) - - -.. cfunction:: PyObject* PyInt_FromSsize_t(Py_ssize_t ival) - - Create a new integer object with a value of *ival*. If the value exceeds - ``LONG_MAX``, a long integer object is returned. - - -.. cfunction:: long PyInt_AsLong(PyObject *io) - - Will first attempt to cast the object to a :ctype:`PyIntObject`, if it is not - already one, and then return its value. If there is an error, ``-1`` is - returned, and the caller should check ``PyErr_Occurred()`` to find out whether - there was an error, or whether the value just happened to be -1. - - -.. cfunction:: long PyInt_AS_LONG(PyObject *io) - - Return the value of the object *io*. No error checking is performed. - - -.. cfunction:: unsigned long PyInt_AsUnsignedLongMask(PyObject *io) - - Will first attempt to cast the object to a :ctype:`PyIntObject` or - :ctype:`PyLongObject`, if it is not already one, and then return its value as - unsigned long. This function does not check for overflow. - - -.. cfunction:: unsigned PY_LONG_LONG PyInt_AsUnsignedLongLongMask(PyObject *io) - - Will first attempt to cast the object to a :ctype:`PyIntObject` or - :ctype:`PyLongObject`, if it is not already one, and then return its value as - unsigned long long, without checking for overflow. - - -.. cfunction:: Py_ssize_t PyInt_AsSsize_t(PyObject *io) - - Will first attempt to cast the object to a :ctype:`PyIntObject` or - :ctype:`PyLongObject`, if it is not already one, and then return its value as - :ctype:`Py_ssize_t`. - - -.. cfunction:: long PyInt_GetMax() - - .. index:: single: LONG_MAX - - Return the system's idea of the largest integer it can handle - (:const:`LONG_MAX`, as defined in the system header files). - - .. _boolobjects: Boolean Objects @@ -289,23 +180,23 @@ .. _longobjects: -Long Integer Objects --------------------- +Integer Objects +--------------- .. index:: object: long integer + object: integer +All integers are implemented as "long" integer objects of arbitrary size. .. ctype:: PyLongObject - This subtype of :ctype:`PyObject` represents a Python long integer object. + This subtype of :ctype:`PyObject` represents a Python integer object. .. cvar:: PyTypeObject PyLong_Type - .. index:: single: LongType (in modules types) - - This instance of :ctype:`PyTypeObject` represents the Python long integer type. - This is the same object as ``long`` and ``types.LongType``. + This instance of :ctype:`PyTypeObject` represents the Python integer type. + This is the same object as ``int``. .. cfunction:: int PyLong_Check(PyObject *p) @@ -320,10 +211,20 @@ :ctype:`PyLongObject`. +.. XXX cfunction PyInt_CheckExact(PyObject *p) checks if argument is a long + object and fits into a C long + + .. cfunction:: PyObject* PyLong_FromLong(long v) Return a new :ctype:`PyLongObject` object from *v*, or *NULL* on failure. + The current implementation keeps an array of integer objects for all integers + between ``-5`` and ``256``, when you create an int in that range you actually + just get back a reference to the existing object. So it should be possible to + change the value of ``1``. I suspect the behaviour of Python in this case is + undefined. :-) + .. cfunction:: PyObject* PyLong_FromUnsignedLong(unsigned long v) @@ -331,6 +232,18 @@ *NULL* on failure. +.. cfunction:: PyObject* PyLong_FromSsize_t(Py_ssize_t v) + + Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL* + on failure. + + +.. cfunction:: PyObject* PyLong_FromSize_t(size_t v) + + Return a new :ctype:`PyLongObject` object with a value of *v*, or *NULL* + on failure. + + .. cfunction:: PyObject* PyLong_FromLongLong(PY_LONG_LONG v) Return a new :ctype:`PyLongObject` object from a C :ctype:`long long`, or *NULL* @@ -351,33 +264,32 @@ .. cfunction:: PyObject* PyLong_FromString(char *str, char **pend, int base) - Return a new :ctype:`PyLongObject` based on the string value in *str*, which is - interpreted according to the radix in *base*. If *pend* is non-*NULL*, + Return a new :ctype:`PyLongObject` based on the string value in *str*, which + is interpreted according to the radix in *base*. If *pend* is non-*NULL*, ``*pend`` will point to the first character in *str* which follows the - representation of the number. If *base* is ``0``, the radix will be determined - based on the leading characters of *str*: if *str* starts with ``'0x'`` or - ``'0X'``, radix 16 will be used; if *str* starts with ``'0'``, radix 8 will be - used; otherwise radix 10 will be used. If *base* is not ``0``, it must be - between ``2`` and ``36``, inclusive. Leading spaces are ignored. If there are - no digits, :exc:`ValueError` will be raised. + representation of the number. If *base* is ``0``, the radix will be + determined based on the leading characters of *str*: if *str* starts with + ``'0x'`` or ``'0X'``, radix 16 will be used; if *str* starts with ``'0o'`` or + ``'0O'``, radix 8 will be used; if *str* starts with ``'0b'`` or ``'0B'``, + radix 2 will be used; otherwise radix 10 will be used. If *base* is not + ``0``, it must be between ``2`` and ``36``, inclusive. Leading spaces are + ignored. If there are no digits, :exc:`ValueError` will be raised. .. cfunction:: PyObject* PyLong_FromUnicode(Py_UNICODE *u, Py_ssize_t length, int base) - Convert a sequence of Unicode digits to a Python long integer value. The first - parameter, *u*, points to the first character of the Unicode string, *length* - gives the number of characters, and *base* is the radix for the conversion. The - radix must be in the range [2, 36]; if it is out of range, :exc:`ValueError` - will be raised. + Convert a sequence of Unicode digits to a Python integer value. The Unicode + string is first encoded to a byte string using :cfunc:`PyUnicode_EncodeDecimal` + and then converted using :cfunc:`PyLong_FromString`. .. cfunction:: PyObject* PyLong_FromVoidPtr(void *p) - Create a Python integer or long integer from the pointer *p*. The pointer value - can be retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`. - If the integer is larger than LONG_MAX, a positive long integer is returned. + Create a Python integer from the pointer *p*. The pointer value can be + retrieved from the resulting value using :cfunc:`PyLong_AsVoidPtr`. +.. XXX alias PyLong_AS_LONG (for now) .. cfunction:: long PyLong_AsLong(PyObject *pylong) .. index:: @@ -399,15 +311,32 @@ raised. +.. cfunction:: Py_ssize_t PyLong_AsSsize_t(PyObject *pylong) + + .. index:: + single: PY_SSIZE_T_MAX + + Return a :ctype:`Py_ssize_t` representation of the contents of *pylong*. If + *pylong* is greater than :const:`PY_SSIZE_T_MAX`, an :exc:`OverflowError` is + raised. + + +.. cfunction:: size_t PyLong_AsSize_t(PyObject *pylong) + + Return a :ctype:`size_t` representation of the contents of *pylong*. If + *pylong* is greater than the maximum value for a :ctype:`size_t`, an + :exc:`OverflowError` is raised. + + .. cfunction:: PY_LONG_LONG PyLong_AsLongLong(PyObject *pylong) - Return a C :ctype:`long long` from a Python long integer. If *pylong* cannot be + Return a C :ctype:`long long` from a Python integer. If *pylong* cannot be represented as a :ctype:`long long`, an :exc:`OverflowError` will be raised. .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLong(PyObject *pylong) - Return a C :ctype:`unsigned long long` from a Python long integer. If *pylong* + Return a C :ctype:`unsigned long long` from a Python integer. If *pylong* cannot be represented as an :ctype:`unsigned long long`, an :exc:`OverflowError` will be raised if the value is positive, or a :exc:`TypeError` will be raised if the value is negative. @@ -415,13 +344,13 @@ .. cfunction:: unsigned long PyLong_AsUnsignedLongMask(PyObject *io) - Return a C :ctype:`unsigned long` from a Python long integer, without checking - for overflow. + Return a C :ctype:`unsigned long` from a Python integer, without checking for + overflow. .. cfunction:: unsigned PY_LONG_LONG PyLong_AsUnsignedLongLongMask(PyObject *io) - Return a C :ctype:`unsigned long long` from a Python long integer, without + Return a C :ctype:`unsigned long long` from a Python integer, without checking for overflow. @@ -434,12 +363,19 @@ .. cfunction:: void* PyLong_AsVoidPtr(PyObject *pylong) - Convert a Python integer or long integer *pylong* to a C :ctype:`void` pointer. - If *pylong* cannot be converted, an :exc:`OverflowError` will be raised. This - is only assured to produce a usable :ctype:`void` pointer for values created - with :cfunc:`PyLong_FromVoidPtr`. + Convert a Python integer *pylong* to a C :ctype:`void` pointer. If *pylong* + cannot be converted, an :exc:`OverflowError` will be raised. This is only + assured to produce a usable :ctype:`void` pointer for values created with + :cfunc:`PyLong_FromVoidPtr`. + - For values outside 0..LONG_MAX, both signed and unsigned integers are acccepted. +.. XXX name? +.. cfunction:: long PyInt_GetMax() + + .. index:: single: LONG_MAX + + Return the system's idea of the largest integer it can handle + (:const:`LONG_MAX`, as defined in the system header files). .. _floatobjects: @@ -2435,7 +2371,7 @@ .. cfunction:: int PyObject_AsFileDescriptor(PyObject *p) Return the file descriptor associated with *p* as an :ctype:`int`. If the - object is an integer or long integer, its value is returned. If not, the + object is an integer, its value is returned. If not, the object's :meth:`fileno` method is called if it exists; the method must return an integer, which is returned as the file descriptor value. Sets an exception and returns ``-1`` on failure. Modified: python/branches/py3k/Doc/extending/extending.rst ============================================================================== --- python/branches/py3k/Doc/extending/extending.rst (original) +++ python/branches/py3k/Doc/extending/extending.rst Mon Dec 3 00:08:39 2007 @@ -165,7 +165,7 @@ Every failing :cfunc:`malloc` call must be turned into an exception --- the direct caller of :cfunc:`malloc` (or :cfunc:`realloc`) must call :cfunc:`PyErr_NoMemory` and return a failure indicator itself. All the -object-creating functions (for example, :cfunc:`PyInt_FromLong`) already do +object-creating functions (for example, :cfunc:`PyLong_FromLong`) already do this, so this note is only relevant to those who call :cfunc:`malloc` directly. Also note that, with the important exception of :cfunc:`PyArg_ParseTuple` and @@ -889,10 +889,10 @@ Most functions that return a reference to an object pass on ownership with the reference. In particular, all functions whose function it is to create a new -object, such as :cfunc:`PyInt_FromLong` and :cfunc:`Py_BuildValue`, pass +object, such as :cfunc:`PyLong_FromLong` and :cfunc:`Py_BuildValue`, pass ownership to the receiver. Even if the object is not actually new, you still receive ownership of a new reference to that object. For instance, -:cfunc:`PyInt_FromLong` maintains a cache of popular values and can return a +:cfunc:`PyLong_FromLong` maintains a cache of popular values and can return a reference to a cached item. Many functions that extract objects from other objects also transfer ownership @@ -942,7 +942,7 @@ { PyObject *item = PyList_GetItem(list, 0); - PyList_SetItem(list, 1, PyInt_FromLong(0L)); + PyList_SetItem(list, 1, PyLong_FromLong(0L)); PyObject_Print(item, stdout, 0); /* BUG! */ } @@ -974,7 +974,7 @@ PyObject *item = PyList_GetItem(list, 0); Py_INCREF(item); - PyList_SetItem(list, 1, PyInt_FromLong(0L)); + PyList_SetItem(list, 1, PyLong_FromLong(0L)); PyObject_Print(item, stdout, 0); Py_DECREF(item); } From python-3000-checkins at python.org Mon Dec 3 00:11:00 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 3 Dec 2007 00:11:00 +0100 (CET) Subject: [Python-3000-checkins] r59285 - python/branches/py3k/Doc/c-api/abstract.rst python/branches/py3k/Doc/c-api/utilities.rst Message-ID: <20071202231100.77E1F1E4021@bag.python.org> Author: georg.brandl Date: Mon Dec 3 00:11:00 2007 New Revision: 59285 Modified: python/branches/py3k/Doc/c-api/abstract.rst python/branches/py3k/Doc/c-api/utilities.rst Log: Remove mentions of "long integer" in the API docs. Modified: python/branches/py3k/Doc/c-api/abstract.rst ============================================================================== --- python/branches/py3k/Doc/c-api/abstract.rst (original) +++ python/branches/py3k/Doc/c-api/abstract.rst Mon Dec 3 00:11:00 2007 @@ -583,7 +583,7 @@ .. index:: builtin: long - Returns the *o* converted to a long integer object on success, or *NULL* on + Returns the *o* converted to an integer object on success, or *NULL* on failure. This is the equivalent of the Python expression ``long(o)``. Modified: python/branches/py3k/Doc/c-api/utilities.rst ============================================================================== --- python/branches/py3k/Doc/c-api/utilities.rst (original) +++ python/branches/py3k/Doc/c-api/utilities.rst Mon Dec 3 00:11:00 2007 @@ -557,7 +557,7 @@ Convert a Python integer to a C :ctype:`long int`. ``k`` (integer) [unsigned long] - Convert a Python integer or long integer to a C :ctype:`unsigned long` without + Convert a Python integer to a C :ctype:`unsigned long` without overflow checking. ``L`` (integer) [PY_LONG_LONG] @@ -566,12 +566,12 @@ Windows). ``K`` (integer) [unsigned PY_LONG_LONG] - Convert a Python integer or long integer to a C :ctype:`unsigned long long` + Convert a Python integer to a C :ctype:`unsigned long long` without overflow checking. This format is only available on platforms that support :ctype:`unsigned long long` (or :ctype:`unsigned _int64` on Windows). ``n`` (integer) [Py_ssize_t] - Convert a Python integer or long integer to a C :ctype:`Py_ssize_t`. + Convert a Python integer to a C :ctype:`Py_ssize_t`. ``c`` (string of length 1) [char] Convert a Python character, represented as a string of length 1, to a C @@ -647,11 +647,11 @@ in *items*. The C arguments must correspond to the individual format units in *items*. Format units for sequences may be nested. -It is possible to pass Python long integers where integers are requested; -however no proper range checking is done --- the most significant bits are -silently truncated when the receiving field is too small to receive the value -(actually, the semantics are inherited from downcasts in C --- your mileage may -vary). +It is possible to pass "long" integers (integers whose value exceeds the +platform's :const:`LONG_MAX`) however no proper range checking is done --- the +most significant bits are silently truncated when the receiving field is too +small to receive the value (actually, the semantics are inherited from downcasts +in C --- your mileage may vary). A few other characters have a meaning in a format string. These may not occur inside nested parentheses. They are: @@ -849,15 +849,15 @@ integer object, if it is larger than ``sys.maxint``. ``L`` (long) [PY_LONG_LONG] - Convert a C :ctype:`long long` to a Python long integer object. Only available + Convert a C :ctype:`long long` to a Python integer object. Only available on platforms that support :ctype:`long long`. ``K`` (long) [unsigned PY_LONG_LONG] - Convert a C :ctype:`unsigned long long` to a Python long integer object. Only + Convert a C :ctype:`unsigned long long` to a Python integer object. Only available on platforms that support :ctype:`unsigned long long`. ``n`` (int) [Py_ssize_t] - Convert a C :ctype:`Py_ssize_t` to a Python integer or long integer. + Convert a C :ctype:`Py_ssize_t` to a Python integer. ``c`` (string of length 1) [char] Convert a C :ctype:`int` representing a character to a Python string of length From python-3000-checkins at python.org Mon Dec 3 00:15:43 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 3 Dec 2007 00:15:43 +0100 (CET) Subject: [Python-3000-checkins] r59286 - python/branches/py3k/Doc/library/csv.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/library/readline.rst python/branches/py3k/Doc/library/socket.rst python/branches/py3k/Doc/library/stdtypes.rst Message-ID: <20071202231543.C39D11E4021@bag.python.org> Author: georg.brandl Date: Mon Dec 3 00:15:43 2007 New Revision: 59286 Modified: python/branches/py3k/Doc/library/csv.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/library/readline.rst python/branches/py3k/Doc/library/socket.rst python/branches/py3k/Doc/library/stdtypes.rst Log: Remove a few merged versionadded/changed. Modified: python/branches/py3k/Doc/library/csv.rst ============================================================================== --- python/branches/py3k/Doc/library/csv.rst (original) +++ python/branches/py3k/Doc/library/csv.rst Mon Dec 3 00:15:43 2007 @@ -121,13 +121,9 @@ .. function:: get_dialect(name) - Return the dialect associated with *name*. An :exc:`Error` is raised if *name* - is not a registered dialect name. - - .. versionchanged:: 2.5 - This function now returns an immutable :class:`Dialect`. Previously an - instance of the requested dialect was returned. Users could modify the - underlying class, changing the behavior of active readers and writers. + Return the dialect associated with *name*. An :exc:`Error` is raised if + *name* is not a registered dialect name. This function returns an immutable + :class:`Dialect`. .. function:: list_dialects() Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Mon Dec 3 00:15:43 2007 @@ -337,7 +337,6 @@ encoding of a :class:`Decimal` instance is always canonical, so this operation returns its argument unchanged. - .. versionadded:: 2.6 .. method:: Decimal.compare(other[, context]) @@ -359,7 +358,6 @@ NaN then any quiet NaN operand is treated as though it were a signaling NaN. - .. versionadded:: 2.6 .. method:: Decimal.compare_total(other) @@ -381,7 +379,6 @@ than the second operand. See the specification for details of the total order. - .. versionadded:: 2.6 .. method:: Decimal.compare_total_mag(other) @@ -390,7 +387,6 @@ of each operand. ``x.compare_total_mag(y)`` is equivalent to ``x.copy_abs().compare_total(y.copy_abs())``. - .. versionadded:: 2.6 .. method:: Decimal.copy_abs() @@ -398,7 +394,6 @@ unaffected by the context and is quiet: no flags are changed and no rounding is performed. - .. versionadded:: 2.6 .. method:: Decimal.copy_negate() @@ -406,7 +401,6 @@ by the context and is quiet: no flags are changed and no rounding is performed. - .. versionadded:: 2.6 .. method:: Decimal.copy_sign(other) @@ -419,7 +413,6 @@ This operation is unaffected by the context and is quiet: no flags are changed and no rounding is performed. - .. versionadded:: 2.6 .. method:: Decimal.exp([context]) @@ -432,7 +425,6 @@ >>> Decimal(321).exp() Decimal("2.561702493119680037517373933E+139") - .. versionadded:: 2.6 .. method:: Decimal.fma(other, third[, context]) @@ -442,7 +434,6 @@ >>> Decimal(2).fma(3, 5) Decimal("11") - .. versionadded:: 2.6 .. method:: Decimal.is_canonical() @@ -451,28 +442,24 @@ is always canonical, so this operation always returns :const:`True`. - .. versionadded:: 2.6 .. method:: is_finite() Return :const:`True` if the argument is a finite number, and :const:`False` if the argument is an infinity or a NaN. - .. versionadded:: 2.6 .. method:: is_infinite() Return :const:`True` if the argument is either positive or negative infinity and :const:`False` otherwise. - .. versionadded:: 2.6 .. method:: is_nan() Return :const:`True` if the argument is a (quiet or signaling) NaN and :const:`False` otherwise. - .. versionadded:: 2.6 .. method:: is_normal() @@ -480,14 +467,12 @@ Return :const:`False` if the argument is zero, subnormal, infinite or a NaN. - .. versionadded:: 2.6 .. method:: is_qnan() Return :const:`True` if the argument is a quiet NaN, and :const:`False` otherwise. - .. versionadded:: 2.6 .. method:: is_signed() @@ -495,28 +480,24 @@ :const:`False` otherwise. Note that zeros and NaNs can both carry signs. - .. versionadded:: 2.6 .. method:: is_snan() Return :const:`True` if the argument is a signaling NaN and :const:`False` otherwise. - .. versionadded:: 2.6 .. method:: is_subnormal() Return :const:`True` if the argument is subnormal, and :const:`False` otherwise. - .. versionadded:: 2.6 .. method:: is_zero() Return :const:`True` if the argument is a (positive or negative) zero and :const:`False` otherwise. - .. versionadded:: 2.6 .. method:: Decimal.ln([context]) @@ -524,14 +505,12 @@ is correctly rounded using the :const:`ROUND_HALF_EVEN` rounding mode. - .. versionadded:: 2.6 .. method:: Decimal.log10([context]) Return the base ten logarithm of the operand. The result is correctly rounded using the :const:`ROUND_HALF_EVEN` rounding mode. - .. versionadded:: 2.6 .. method: Decimal.logb([context]) @@ -541,7 +520,6 @@ :const:`DivisionByZero` flag is raised. If the operand is an infinity then ``Decimal("Infinity")`` is returned. - .. versionadded:: 2.6 .. method:: Decimal.logical_and(other[, context]) @@ -549,7 +527,6 @@ *logical operands* (see :ref:`logical_operands_label`). The result is the digit-wise ``and`` of the two operands. - .. versionadded:: 2.6 .. method:: Decimal.logical_invert(other[, context]) @@ -557,7 +534,6 @@ be a *logical operand* (see :ref:`logical_operands_label`). The result is the digit-wise inversion of the operand. - .. versionadded:: 2.6 .. method:: Decimal.logical_or(other[, context]) @@ -565,7 +541,6 @@ operands* (see :ref:`logical_operands_label`). The result is the digit-wise ``or`` of the two operands. - .. versionadded:: 2.6 .. method:: Decimal.logical_xor(other[, context]) @@ -573,7 +548,6 @@ *logical operands* (see :ref:`logical_operands_label`). The result is the digit-wise exclusive or of the two operands. - .. versionadded:: 2.6 .. method:: Decimal.max(other[, context]) @@ -581,12 +555,12 @@ before returning and that :const:`NaN` values are either signaled or ignored (depending on the context and whether they are signaling or quiet). + .. method:: Decimal.max_mag(other[, context]) Similar to the :meth:`max` method, but the comparison is done using the absolute values of the operands. - .. versionadded:: 2.6 .. method:: Decimal.min(other[, context]) @@ -599,7 +573,6 @@ Similar to the :meth:`min` method, but the comparison is done using the absolute values of the operands. - .. versionadded:: 2.6 .. method:: Decimal.next_minus([context]) @@ -607,7 +580,6 @@ in the current thread's context if no context is given) that is smaller than the given operand. - .. versionadded:: 2.6 .. method:: Decimal.next_plus([context]) @@ -615,7 +587,6 @@ in the current thread's context if no context is given) that is larger than the given operand. - .. versionadded:: 2.6 .. method:: Decimal.next_toward(other[, context]) @@ -624,7 +595,6 @@ operands are numerically equal, return a copy of the first operand with the sign set to be the same as the sign of the second operand. - .. versionadded:: 2.6 .. method:: Decimal.normalize([context]) @@ -634,6 +604,7 @@ ``Decimal("32.100")`` and ``Decimal("0.321000e+2")`` both normalize to the equivalent value ``Decimal("32.1")``. + .. method:: Decimal.number_class([context]) Return a string describing the *class* of the operand. The @@ -650,7 +621,6 @@ * ``"NaN"``, indicating that the operand is a quiet NaN (Not a Number). * ``"sNaN"``, indicating that the operand is a signaling NaN. - .. versionadded:: 2.6 .. method:: Decimal.quantize(exp[, rounding[, context[, watchexp]]]) @@ -684,7 +654,6 @@ :class:`Decimal` class does all its arithmetic. Included for compatibility with the specification. - .. versionadded:: 2.6 .. method:: Decimal.remainder_near(other[, context]) @@ -706,7 +675,6 @@ if necessary. The sign and exponent of the first operand are unchanged. - .. versionadded:: 2.6 .. method:: Decimal.same_quantum(other[, context]) @@ -719,7 +687,6 @@ Equivalently, return the first operand multiplied by ``10**other``. The second operand must be an integer. - .. versionadded:: 2.6 .. method:: Decimal.shift(other[, context]) @@ -732,7 +699,6 @@ coefficient are zeros. The sign and exponent of the first operand are unchanged. - .. versionadded:: 2.6 .. method:: Decimal.sqrt([context]) @@ -761,7 +727,6 @@ parameter is given then the rounding mode of the current context is used. - .. versionadded:: 2.6 .. method:: Decimal.to_integral_value([rounding[, context]]) @@ -769,9 +734,6 @@ :const:`Rounded`. If given, applies *rounding*; otherwise, uses the rounding method in either the supplied *context* or the current context. - .. versionchanged:: 2.6 - renamed from ``to_integral`` to ``to_integral_value``. The old name - remains valid for compatibility. .. method:: Decimal.trim() @@ -781,7 +743,6 @@ is, the last element of the :meth:`as_tuple` representation) is positive. - .. versionadded:: 2.6 .. _logical_operands_label: @@ -921,8 +882,6 @@ :const:`1`, exponents are printed with a capital :const:`E`; otherwise, a lowercase :const:`e` is used: :const:`Decimal('6.02e+23')`. - .. versionchanged:: 2.6 - The :const:`ROUND_05UP` rounding mode was added. The :class:`Context` class defines several general purpose methods as well as a large number of methods for doing arithmetic directly in a @@ -1048,10 +1007,6 @@ modulo`` with unbounded precision, but is computed more efficiently. It is always exact. - .. versionchanged:: 2.6 - ``y`` may now be nonintegral in ``x**y``. - Stricter requirements for the three-argument version. - .. method:: Context.remainder(x, y) Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Mon Dec 3 00:15:43 2007 @@ -147,9 +147,6 @@ This class is derived from :exc:`EnvironmentError`. See the discussion above for more information on exception instance attributes. - .. versionchanged:: 2.6 - Changed :exc:`socket.error` to use this as a base class. - .. exception:: ImportError Modified: python/branches/py3k/Doc/library/readline.rst ============================================================================== --- python/branches/py3k/Doc/library/readline.rst (original) +++ python/branches/py3k/Doc/library/readline.rst Mon Dec 3 00:15:43 2007 @@ -132,7 +132,6 @@ Get the type of completion being attempted. - .. versionadded:: 2.6 .. function:: get_begidx() @@ -153,6 +152,7 @@ Get the readline word delimiters for tab-completion. + .. function:: set_completion_display_matches_hook([function]) Set or remove the completion display function. If *function* is @@ -162,7 +162,6 @@ ``function(substitution, [matches], longest_match_length)`` once each time matches need to be displayed. - .. versionadded:: 2.6 .. function:: add_history(line) Modified: python/branches/py3k/Doc/library/socket.rst ============================================================================== --- python/branches/py3k/Doc/library/socket.rst (original) +++ python/branches/py3k/Doc/library/socket.rst Mon Dec 3 00:15:43 2007 @@ -85,9 +85,6 @@ accompanying :exc:`os.error`. See the module :mod:`errno`, which contains names for the error codes defined by the underlying operating system. - .. versionchanged:: 2.6 - :exc:`socket.error` is now a child class of :exc:`IOError`. - .. exception:: herror Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Mon Dec 3 00:15:43 2007 @@ -1438,8 +1438,6 @@ Return True if the set has no elements in common with *other*. Sets are disjoint if and only if their interesection is the empty set. - .. versionadded:: 2.6 - .. method:: set.issubset(other) set <= other From python-3000-checkins at python.org Mon Dec 3 20:47:55 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 3 Dec 2007 20:47:55 +0100 (CET) Subject: [Python-3000-checkins] r59296 - in python/branches/py3k: Doc/library/exceptions.rst Doc/reference/expressions.rst Lib/distutils/msvc9compiler.py Lib/test/exception_hierarchy.txt Lib/test/test_generators.py Misc/NEWS Objects/exceptions.c Message-ID: <20071203194755.7BA941E4016@bag.python.org> Author: christian.heimes Date: Mon Dec 3 20:47:54 2007 New Revision: 59296 Added: python/branches/py3k/Lib/distutils/msvc9compiler.py - copied unchanged from r59290, python/trunk/Lib/distutils/msvc9compiler.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Lib/test/exception_hierarchy.txt python/branches/py3k/Lib/test/test_generators.py python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/exceptions.c Log: Patch #1537 from Chad Austin Change GeneratorExit's base class from Exception to BaseException Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Mon Dec 3 20:47:54 2007 @@ -135,6 +135,13 @@ .. exception:: GeneratorExit + Raise when a :term:`generator`\'s :meth:`close` method is called. It + directly inherits from :exc:`BaseException` instead of :exc:`Exception` since + it is technically not an error. + + .. versionchanged:: 3.0 + Changed to inherit from :exc:`BaseException`. + Raise when a :term:`generator`\'s :meth:`close` method is called. Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Mon Dec 3 20:47:54 2007 @@ -413,9 +413,6 @@ ... while True: ... try: ... value = (yield value) - ... except GeneratorExit: - ... # never catch GeneratorExit - ... raise ... except Exception, e: ... value = e ... finally: Modified: python/branches/py3k/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/py3k/Lib/test/exception_hierarchy.txt (original) +++ python/branches/py3k/Lib/test/exception_hierarchy.txt Mon Dec 3 20:47:54 2007 @@ -1,8 +1,8 @@ BaseException +-- SystemExit +-- KeyboardInterrupt + +-- GeneratorExit +-- Exception - +-- GeneratorExit +-- StopIteration +-- ArithmeticError | +-- FloatingPointError Modified: python/branches/py3k/Lib/test/test_generators.py ============================================================================== --- python/branches/py3k/Lib/test/test_generators.py (original) +++ python/branches/py3k/Lib/test/test_generators.py Mon Dec 3 20:47:54 2007 @@ -1668,6 +1668,19 @@ exiting +GeneratorExit is not caught by except Exception: + +>>> def f(): +... try: yield +... except Exception: print 'except' +... finally: print 'finally' + +>>> g = f() +>>> g.next() +>>> del g +finally + + Now let's try some ill-behaved generators: >>> def f(): Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Dec 3 20:47:54 2007 @@ -245,6 +245,8 @@ * operator module: div, idiv, __div__, __idiv__, isCallable, sequenceIncludes * sys module: exc_clear(), exc_type, exc_value, exc_traceback +- Issue #1537: Changed GeneratorExit's base class from Exception to BaseException. + Library ------- Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Mon Dec 3 20:47:54 2007 @@ -424,9 +424,9 @@ /* - * GeneratorExit extends Exception + * GeneratorExit extends BaseException */ -SimpleExtendsException(PyExc_Exception, GeneratorExit, +SimpleExtendsException(PyExc_BaseException, GeneratorExit, "Request that a generator exit."); From python-3000-checkins at python.org Mon Dec 3 20:53:57 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 3 Dec 2007 20:53:57 +0100 (CET) Subject: [Python-3000-checkins] r59298 - in python/branches/py3k: Doc/library/exceptions.rst Doc/reference/expressions.rst Lib/distutils/msvc9compiler.py Lib/test/exception_hierarchy.txt Lib/test/test_generators.py Misc/NEWS Objects/exceptions.c Message-ID: <20071203195357.D34151E4009@bag.python.org> Author: christian.heimes Date: Mon Dec 3 20:53:57 2007 New Revision: 59298 Removed: python/branches/py3k/Lib/distutils/msvc9compiler.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Lib/test/exception_hierarchy.txt python/branches/py3k/Lib/test/test_generators.py python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/exceptions.c Log: Reverting last commit. I had some staled data from an attempted svnmerge in my local sandbox Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Mon Dec 3 20:53:57 2007 @@ -135,13 +135,6 @@ .. exception:: GeneratorExit - Raise when a :term:`generator`\'s :meth:`close` method is called. It - directly inherits from :exc:`BaseException` instead of :exc:`Exception` since - it is technically not an error. - - .. versionchanged:: 3.0 - Changed to inherit from :exc:`BaseException`. - Raise when a :term:`generator`\'s :meth:`close` method is called. Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Mon Dec 3 20:53:57 2007 @@ -413,6 +413,9 @@ ... while True: ... try: ... value = (yield value) + ... except GeneratorExit: + ... # never catch GeneratorExit + ... raise ... except Exception, e: ... value = e ... finally: Deleted: /python/branches/py3k/Lib/distutils/msvc9compiler.py ============================================================================== --- /python/branches/py3k/Lib/distutils/msvc9compiler.py Mon Dec 3 20:53:57 2007 +++ (empty file) @@ -1,658 +0,0 @@ -"""distutils.msvc9compiler - -Contains MSVCCompiler, an implementation of the abstract CCompiler class -for the Microsoft Visual Studio 2008. - -The module is compatible with VS 2005 and VS 2008. You can find legacy support -for older versions of VS in distutils.msvccompiler. -""" - -# Written by Perry Stoll -# hacked by Robin Becker and Thomas Heller to do a better job of -# finding DevStudio (through the registry) -# ported to VS2005 and VS 2008 by Christian Heimes - -__revision__ = "$Id$" - -import os -import subprocess -import sys -from distutils.errors import (DistutilsExecError, DistutilsPlatformError, - CompileError, LibError, LinkError) -from distutils.ccompiler import (CCompiler, gen_preprocess_options, - gen_lib_options) -from distutils import log - -import _winreg - -RegOpenKeyEx = _winreg.OpenKeyEx -RegEnumKey = _winreg.EnumKey -RegEnumValue = _winreg.EnumValue -RegError = _winreg.error - -HKEYS = (_winreg.HKEY_USERS, - _winreg.HKEY_CURRENT_USER, - _winreg.HKEY_LOCAL_MACHINE, - _winreg.HKEY_CLASSES_ROOT) - -VS_BASE = r"Software\Microsoft\VisualStudio\%0.1f" -WINSDK_BASE = r"Software\Microsoft\Microsoft SDKs\Windows" -NET_BASE = r"Software\Microsoft\.NETFramework" -ARCHS = {'DEFAULT' : 'x86', - 'intel' : 'x86', 'x86' : 'x86', - 'amd64' : 'x64', 'x64' : 'x64', - 'itanium' : 'ia64', 'ia64' : 'ia64', - } - -# The globals VERSION, ARCH, MACROS and VC_ENV are defined later - -class Reg: - """Helper class to read values from the registry - """ - - @classmethod - def get_value(cls, path, key): - for base in HKEYS: - d = cls.read_values(base, path) - if d and key in d: - return d[key] - raise KeyError(key) - - @classmethod - def read_keys(cls, base, key): - """Return list of registry keys.""" - try: - handle = RegOpenKeyEx(base, key) - except RegError: - return None - L = [] - i = 0 - while True: - try: - k = RegEnumKey(handle, i) - except RegError: - break - L.append(k) - i += 1 - return L - - @classmethod - def read_values(cls, base, key): - """Return dict of registry keys and values. - - All names are converted to lowercase. - """ - try: - handle = RegOpenKeyEx(base, key) - except RegError: - return None - d = {} - i = 0 - while True: - try: - name, value, type = RegEnumValue(handle, i) - except RegError: - break - name = name.lower() - d[cls.convert_mbcs(name)] = cls.convert_mbcs(value) - i += 1 - return d - - @staticmethod - def convert_mbcs(s): - dec = getattr(s, "decode", None) - if dec is not None: - try: - s = dec("mbcs") - except UnicodeError: - pass - return s - -class MacroExpander: - - def __init__(self, version): - self.macros = {} - self.vsbase = VS_BASE % version - self.load_macros(version) - - def set_macro(self, macro, path, key): - self.macros["$(%s)" % macro] = Reg.get_value(path, key) - - def load_macros(self, version): - self.set_macro("VCInstallDir", self.vsbase + r"\Setup\VC", "productdir") - self.set_macro("VSInstallDir", self.vsbase + r"\Setup\VS", "productdir") - self.set_macro("FrameworkDir", NET_BASE, "installroot") - try: - if version >= 8.0: - self.set_macro("FrameworkSDKDir", NET_BASE, - "sdkinstallrootv2.0") - else: - raise KeyError("sdkinstallrootv2.0") - except KeyError as exc: # - raise DistutilsPlatformError( - """Python was built with Visual Studio 2008; -extensions must be built with a compiler than can generate compatible binaries. -Visual Studio 2008 was not found on this system. If you have Cygwin installed, -you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""") - - if version >= 9.0: - self.set_macro("FrameworkVersion", self.vsbase, "clr version") - self.set_macro("WindowsSdkDir", WINSDK_BASE, "currentinstallfolder") - else: - p = r"Software\Microsoft\NET Framework Setup\Product" - for base in HKEYS: - try: - h = RegOpenKeyEx(base, p) - except RegError: - continue - key = RegEnumKey(h, 0) - d = Reg.get_value(base, r"%s\%s" % (p, key)) - self.macros["$(FrameworkVersion)"] = d["version"] - - def sub(self, s): - for k, v in self.macros.items(): - s = s.replace(k, v) - return s - -def get_build_version(): - """Return the version of MSVC that was used to build Python. - - For Python 2.3 and up, the version number is included in - sys.version. For earlier versions, assume the compiler is MSVC 6. - """ - prefix = "MSC v." - i = sys.version.find(prefix) - if i == -1: - return 6 - i = i + len(prefix) - s, rest = sys.version[i:].split(" ", 1) - majorVersion = int(s[:-2]) - 6 - minorVersion = int(s[2:3]) / 10.0 - # I don't think paths are affected by minor version in version 6 - if majorVersion == 6: - minorVersion = 0 - if majorVersion >= 6: - return majorVersion + minorVersion - # else we don't know what version of the compiler this is - return None - -def get_build_architecture(): - """Return the processor architecture. - - Possible results are "x86" or "amd64". - """ - prefix = " bit (" - i = sys.version.find(prefix) - if i == -1: - return "x86" - j = sys.version.find(")", i) - sysarch = sys.version[i+len(prefix):j].lower() - arch = ARCHS.get(sysarch, None) - if arch is None: - return ARCHS['DEFAULT'] - else: - return arch - -def normalize_and_reduce_paths(paths): - """Return a list of normalized paths with duplicates removed. - - The current order of paths is maintained. - """ - # Paths are normalized so things like: /a and /a/ aren't both preserved. - reduced_paths = [] - for p in paths: - np = os.path.normpath(p) - # XXX(nnorwitz): O(n**2), if reduced_paths gets long perhaps use a set. - if np not in reduced_paths: - reduced_paths.append(np) - return reduced_paths - -def find_vcvarsall(version): - """Find the vcvarsall.bat file - - At first it tries to find the productdir of VS 2008 in the registry. If - that fails it falls back to the VS90COMNTOOLS env var. - """ - vsbase = VS_BASE % version - try: - productdir = Reg.get_value(r"%s\Setup\VC" % vsbase, - "productdir") - except KeyError: - log.debug("Unable to find productdir in registry") - productdir = None - - if not productdir or not os.path.isdir(productdir): - toolskey = "VS%0.f0COMNTOOLS" % version - toolsdir = os.environ.get(toolskey, None) - - if toolsdir and os.path.isdir(toolsdir): - productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC") - productdir = os.path.abspath(productdir) - if not os.path.isdir(productdir): - log.debug("%s is not a valid directory" % productdir) - return None - else: - log.debug("Env var %s is not set or invalid" % toolskey) - if not productdir: - log.debug("No productdir found") - return None - vcvarsall = os.path.join(productdir, "vcvarsall.bat") - if os.path.isfile(vcvarsall): - return vcvarsall - log.debug("Unable to find vcvarsall.bat") - return None - -def query_vcvarsall(version, arch="x86"): - """Launch vcvarsall.bat and read the settings from its environment - """ - vcvarsall = find_vcvarsall(version) - interesting = set(("include", "lib", "libpath", "path")) - result = {} - - if vcvarsall is None: - raise IOError("Unable to find vcvarsall.bat") - popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch), - stdout=subprocess.PIPE, - stderr=subprocess.PIPE) - if popen.wait() != 0: - raise IOError(popen.stderr.read()) - - for line in popen.stdout: - line = Reg.convert_mbcs(line) - if '=' not in line: - continue - line = line.strip() - key, value = line.split('=') - key = key.lower() - if key in interesting: - if value.endswith(os.pathsep): - value = value[:-1] - result[key] = value - - if len(result) != len(interesting): - raise ValueError(str(list(result.keys()))) - - return result - -# More globals -VERSION = get_build_version() -if VERSION < 8.0: - raise DistutilsPlatformError("VC %0.1f is not supported by this module" % VERSION) -ARCH = get_build_architecture() -# MACROS = MacroExpander(VERSION) -VC_ENV = query_vcvarsall(VERSION, ARCH) - -class MSVCCompiler(CCompiler) : - """Concrete class that implements an interface to Microsoft Visual C++, - as defined by the CCompiler abstract class.""" - - compiler_type = 'msvc' - - # Just set this so CCompiler's constructor doesn't barf. We currently - # don't use the 'set_executables()' bureaucracy provided by CCompiler, - # as it really isn't necessary for this sort of single-compiler class. - # Would be nice to have a consistent interface with UnixCCompiler, - # though, so it's worth thinking about. - executables = {} - - # Private class data (need to distinguish C from C++ source for compiler) - _c_extensions = ['.c'] - _cpp_extensions = ['.cc', '.cpp', '.cxx'] - _rc_extensions = ['.rc'] - _mc_extensions = ['.mc'] - - # Needed for the filename generation methods provided by the - # base class, CCompiler. - src_extensions = (_c_extensions + _cpp_extensions + - _rc_extensions + _mc_extensions) - res_extension = '.res' - obj_extension = '.obj' - static_lib_extension = '.lib' - shared_lib_extension = '.dll' - static_lib_format = shared_lib_format = '%s%s' - exe_extension = '.exe' - - def __init__(self, verbose=0, dry_run=0, force=0): - CCompiler.__init__ (self, verbose, dry_run, force) - self.__version = VERSION - self.__arch = ARCH - self.__root = r"Software\Microsoft\VisualStudio" - # self.__macros = MACROS - self.__path = [] - self.initialized = False - - def initialize(self): - if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and self.find_exe("cl.exe"): - # Assume that the SDK set up everything alright; don't try to be - # smarter - self.cc = "cl.exe" - self.linker = "link.exe" - self.lib = "lib.exe" - self.rc = "rc.exe" - self.mc = "mc.exe" - else: - self.__paths = VC_ENV['path'].split(os.pathsep) - os.environ['lib'] = VC_ENV['lib'] - os.environ['include'] = VC_ENV['include'] - - if len(self.__paths) == 0: - raise DistutilsPlatformError("Python was built with %s, " - "and extensions need to be built with the same " - "version of the compiler, but it isn't installed." - % self.__product) - - self.cc = self.find_exe("cl.exe") - self.linker = self.find_exe("link.exe") - self.lib = self.find_exe("lib.exe") - self.rc = self.find_exe("rc.exe") # resource compiler - self.mc = self.find_exe("mc.exe") # message compiler - #self.set_path_env_var('lib') - #self.set_path_env_var('include') - - # extend the MSVC path with the current path - try: - for p in os.environ['path'].split(';'): - self.__paths.append(p) - except KeyError: - pass - self.__paths = normalize_and_reduce_paths(self.__paths) - os.environ['path'] = ";".join(self.__paths) - - self.preprocess_options = None - if self.__arch == "x86": - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', - '/DNDEBUG'] - self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', - '/Z7', '/D_DEBUG'] - else: - # Win64 - self.compile_options = [ '/nologo', '/Ox', '/MD', '/W3', '/GS-' , - '/DNDEBUG'] - self.compile_options_debug = ['/nologo', '/Od', '/MDd', '/W3', '/GS-', - '/Z7', '/D_DEBUG'] - - self.ldflags_shared = ['/DLL', '/nologo', '/INCREMENTAL:NO'] - if self.__version >= 7: - self.ldflags_shared_debug = [ - '/DLL', '/nologo', '/INCREMENTAL:no', '/DEBUG', '/pdb:None' - ] - self.ldflags_static = [ '/nologo'] - - self.initialized = True - - # -- Worker methods ------------------------------------------------ - - def object_filenames(self, - source_filenames, - strip_dir=0, - output_dir=''): - # Copied from ccompiler.py, extended to return .res as 'object'-file - # for .rc input file - if output_dir is None: output_dir = '' - obj_names = [] - for src_name in source_filenames: - (base, ext) = os.path.splitext (src_name) - base = os.path.splitdrive(base)[1] # Chop off the drive - base = base[os.path.isabs(base):] # If abs, chop off leading / - if ext not in self.src_extensions: - # Better to raise an exception instead of silently continuing - # and later complain about sources and targets having - # different lengths - raise CompileError ("Don't know how to compile %s" % src_name) - if strip_dir: - base = os.path.basename (base) - if ext in self._rc_extensions: - obj_names.append (os.path.join (output_dir, - base + self.res_extension)) - elif ext in self._mc_extensions: - obj_names.append (os.path.join (output_dir, - base + self.res_extension)) - else: - obj_names.append (os.path.join (output_dir, - base + self.obj_extension)) - return obj_names - - - def compile(self, sources, - output_dir=None, macros=None, include_dirs=None, debug=0, - extra_preargs=None, extra_postargs=None, depends=None): - - if not self.initialized: - self.initialize() - compile_info = self._setup_compile(output_dir, macros, include_dirs, - sources, depends, extra_postargs) - macros, objects, extra_postargs, pp_opts, build = compile_info - - compile_opts = extra_preargs or [] - compile_opts.append ('/c') - if debug: - compile_opts.extend(self.compile_options_debug) - else: - compile_opts.extend(self.compile_options) - - for obj in objects: - try: - src, ext = build[obj] - except KeyError: - continue - if debug: - # pass the full pathname to MSVC in debug mode, - # this allows the debugger to find the source file - # without asking the user to browse for it - src = os.path.abspath(src) - - if ext in self._c_extensions: - input_opt = "/Tc" + src - elif ext in self._cpp_extensions: - input_opt = "/Tp" + src - elif ext in self._rc_extensions: - # compile .RC to .RES file - input_opt = src - output_opt = "/fo" + obj - try: - self.spawn([self.rc] + pp_opts + - [output_opt] + [input_opt]) - except DistutilsExecError as msg: - raise CompileError(msg) - continue - elif ext in self._mc_extensions: - # Compile .MC to .RC file to .RES file. - # * '-h dir' specifies the directory for the - # generated include file - # * '-r dir' specifies the target directory of the - # generated RC file and the binary message resource - # it includes - # - # For now (since there are no options to change this), - # we use the source-directory for the include file and - # the build directory for the RC file and message - # resources. This works at least for win32all. - h_dir = os.path.dirname(src) - rc_dir = os.path.dirname(obj) - try: - # first compile .MC to .RC and .H file - self.spawn([self.mc] + - ['-h', h_dir, '-r', rc_dir] + [src]) - base, _ = os.path.splitext (os.path.basename (src)) - rc_file = os.path.join (rc_dir, base + '.rc') - # then compile .RC to .RES file - self.spawn([self.rc] + - ["/fo" + obj] + [rc_file]) - - except DistutilsExecError as msg: - raise CompileError(msg) - continue - else: - # how to handle this file? - raise CompileError("Don't know how to compile %s to %s" - % (src, obj)) - - output_opt = "/Fo" + obj - try: - self.spawn([self.cc] + compile_opts + pp_opts + - [input_opt, output_opt] + - extra_postargs) - except DistutilsExecError as msg: - raise CompileError(msg) - - return objects - - - def create_static_lib(self, - objects, - output_libname, - output_dir=None, - debug=0, - target_lang=None): - - if not self.initialized: - self.initialize() - (objects, output_dir) = self._fix_object_args(objects, output_dir) - output_filename = self.library_filename(output_libname, - output_dir=output_dir) - - if self._need_link(objects, output_filename): - lib_args = objects + ['/OUT:' + output_filename] - if debug: - pass # XXX what goes here? - try: - self.spawn([self.lib] + lib_args) - except DistutilsExecError as msg: - raise LibError(msg) - else: - log.debug("skipping %s (up-to-date)", output_filename) - - - def link(self, - target_desc, - objects, - output_filename, - output_dir=None, - libraries=None, - library_dirs=None, - runtime_library_dirs=None, - export_symbols=None, - debug=0, - extra_preargs=None, - extra_postargs=None, - build_temp=None, - target_lang=None): - - if not self.initialized: - self.initialize() - (objects, output_dir) = self._fix_object_args(objects, output_dir) - fixed_args = self._fix_lib_args(libraries, library_dirs, - runtime_library_dirs) - (libraries, library_dirs, runtime_library_dirs) = fixed_args - - if runtime_library_dirs: - self.warn ("I don't know what to do with 'runtime_library_dirs': " - + str (runtime_library_dirs)) - - lib_opts = gen_lib_options(self, - library_dirs, runtime_library_dirs, - libraries) - if output_dir is not None: - output_filename = os.path.join(output_dir, output_filename) - - if self._need_link(objects, output_filename): - if target_desc == CCompiler.EXECUTABLE: - if debug: - ldflags = self.ldflags_shared_debug[1:] - else: - ldflags = self.ldflags_shared[1:] - else: - if debug: - ldflags = self.ldflags_shared_debug - else: - ldflags = self.ldflags_shared - - export_opts = [] - for sym in (export_symbols or []): - export_opts.append("/EXPORT:" + sym) - - ld_args = (ldflags + lib_opts + export_opts + - objects + ['/OUT:' + output_filename]) - - # The MSVC linker generates .lib and .exp files, which cannot be - # suppressed by any linker switches. The .lib files may even be - # needed! Make sure they are generated in the temporary build - # directory. Since they have different names for debug and release - # builds, they can go into the same directory. - if export_symbols is not None: - (dll_name, dll_ext) = os.path.splitext( - os.path.basename(output_filename)) - implib_file = os.path.join( - os.path.dirname(objects[0]), - self.library_filename(dll_name)) - ld_args.append ('/IMPLIB:' + implib_file) - - if extra_preargs: - ld_args[:0] = extra_preargs - if extra_postargs: - ld_args.extend(extra_postargs) - - self.mkpath(os.path.dirname(output_filename)) - try: - self.spawn([self.linker] + ld_args) - except DistutilsExecError as msg: - raise LinkError(msg) - - else: - log.debug("skipping %s (up-to-date)", output_filename) - - - # -- Miscellaneous methods ----------------------------------------- - # These are all used by the 'gen_lib_options() function, in - # ccompiler.py. - - def library_dir_option(self, dir): - return "/LIBPATH:" + dir - - def runtime_library_dir_option(self, dir): - raise DistutilsPlatformError( - "don't know how to set runtime library search path for MSVC++") - - def library_option(self, lib): - return self.library_filename(lib) - - - def find_library_file(self, dirs, lib, debug=0): - # Prefer a debugging library if found (and requested), but deal - # with it if we don't have one. - if debug: - try_names = [lib + "_d", lib] - else: - try_names = [lib] - for dir in dirs: - for name in try_names: - libfile = os.path.join(dir, self.library_filename (name)) - if os.path.exists(libfile): - return libfile - else: - # Oops, didn't find it in *any* of 'dirs' - return None - - # Helper methods for using the MSVC registry settings - - def find_exe(self, exe): - """Return path to an MSVC executable program. - - Tries to find the program in several places: first, one of the - MSVC program search paths from the registry; next, the directories - in the PATH environment variable. If any of those work, return an - absolute path that is known to exist. If none of them work, just - return the original program name, 'exe'. - """ - for p in self.__paths: - fn = os.path.join(os.path.abspath(p), exe) - if os.path.isfile(fn): - return fn - - # didn't find it; try existing path - for p in os.environ['Path'].split(';'): - fn = os.path.join(os.path.abspath(p),exe) - if os.path.isfile(fn): - return fn - - return exe Modified: python/branches/py3k/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/py3k/Lib/test/exception_hierarchy.txt (original) +++ python/branches/py3k/Lib/test/exception_hierarchy.txt Mon Dec 3 20:53:57 2007 @@ -1,8 +1,8 @@ BaseException +-- SystemExit +-- KeyboardInterrupt - +-- GeneratorExit +-- Exception + +-- GeneratorExit +-- StopIteration +-- ArithmeticError | +-- FloatingPointError Modified: python/branches/py3k/Lib/test/test_generators.py ============================================================================== --- python/branches/py3k/Lib/test/test_generators.py (original) +++ python/branches/py3k/Lib/test/test_generators.py Mon Dec 3 20:53:57 2007 @@ -1668,19 +1668,6 @@ exiting -GeneratorExit is not caught by except Exception: - ->>> def f(): -... try: yield -... except Exception: print 'except' -... finally: print 'finally' - ->>> g = f() ->>> g.next() ->>> del g -finally - - Now let's try some ill-behaved generators: >>> def f(): Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Mon Dec 3 20:53:57 2007 @@ -245,8 +245,6 @@ * operator module: div, idiv, __div__, __idiv__, isCallable, sequenceIncludes * sys module: exc_clear(), exc_type, exc_value, exc_traceback -- Issue #1537: Changed GeneratorExit's base class from Exception to BaseException. - Library ------- Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Mon Dec 3 20:53:57 2007 @@ -424,9 +424,9 @@ /* - * GeneratorExit extends BaseException + * GeneratorExit extends Exception */ -SimpleExtendsException(PyExc_BaseException, GeneratorExit, +SimpleExtendsException(PyExc_Exception, GeneratorExit, "Request that a generator exit."); From python-3000-checkins at python.org Mon Dec 3 22:02:04 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 3 Dec 2007 22:02:04 +0100 (CET) Subject: [Python-3000-checkins] r59304 - in python/branches/py3k: Doc/ACKS.txt Doc/c-api/init.rst Doc/c-api/utilities.rst Doc/data/refcounts.dat Doc/glossary.rst Doc/library/exceptions.rst Doc/library/random.rst Doc/library/simplexmlrpcserver.rst Doc/library/xmlrpclib.rst Doc/reference/expressions.rst Doc/using/cmdline.rst Doc/whatsnew/2.6.rst Lib/decimal.py Lib/distutils/command/build_ext.py Lib/distutils/cygwinccompiler.py Lib/distutils/msvc9compiler.py Lib/distutils/msvccompiler.py Lib/random.py Lib/runpy.py Lib/test/exception_hierarchy.txt Lib/test/randv2_32.pck Lib/test/randv2_64.pck Lib/test/randv3.pck Lib/test/test_cmd_line_script.py Lib/test/test_frozen.py Lib/test/test_generators.py Lib/test/test_pkg.py Lib/test/test_random.py Lib/test/test_runpy.py Misc/ACKS Modules/_randommodule.c Modules/xxmodule.c Objects/exceptions.c Objects/moduleobject.c Tools/msi/msi.py Message-ID: <20071203210204.8939D1E4009@bag.python.org> Author: christian.heimes Date: Mon Dec 3 22:02:03 2007 New Revision: 59304 Added: python/branches/py3k/Lib/distutils/msvc9compiler.py - copied unchanged from r59302, python/trunk/Lib/distutils/msvc9compiler.py python/branches/py3k/Lib/test/randv2_32.pck - copied unchanged from r59302, python/trunk/Lib/test/randv2_32.pck python/branches/py3k/Lib/test/randv2_64.pck - copied unchanged from r59302, python/trunk/Lib/test/randv2_64.pck python/branches/py3k/Lib/test/randv3.pck - copied unchanged from r59302, python/trunk/Lib/test/randv3.pck Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Doc/c-api/utilities.rst python/branches/py3k/Doc/data/refcounts.dat python/branches/py3k/Doc/glossary.rst python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/library/random.rst python/branches/py3k/Doc/library/simplexmlrpcserver.rst python/branches/py3k/Doc/library/xmlrpclib.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Doc/using/cmdline.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/distutils/command/build_ext.py python/branches/py3k/Lib/distutils/cygwinccompiler.py python/branches/py3k/Lib/distutils/msvccompiler.py python/branches/py3k/Lib/random.py python/branches/py3k/Lib/runpy.py python/branches/py3k/Lib/test/exception_hierarchy.txt python/branches/py3k/Lib/test/test_cmd_line_script.py python/branches/py3k/Lib/test/test_frozen.py python/branches/py3k/Lib/test/test_generators.py python/branches/py3k/Lib/test/test_pkg.py python/branches/py3k/Lib/test/test_random.py python/branches/py3k/Lib/test/test_runpy.py python/branches/py3k/Misc/ACKS python/branches/py3k/Modules/_randommodule.c python/branches/py3k/Modules/xxmodule.c python/branches/py3k/Objects/exceptions.c python/branches/py3k/Objects/moduleobject.c python/branches/py3k/Tools/msi/msi.py Log: Merged revisions 59275-59303 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOTE: The merge does NOT contain the modified file Python/import.c from r59288. I can't get it running. Nick, please check in the PEP 366 manually. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ........ r59279 | georg.brandl | 2007-12-02 19:17:50 +0100 (Sun, 02 Dec 2007) | 2 lines Fix a sentence I missed before. Do not merge to 3k. ........ r59281 | georg.brandl | 2007-12-02 22:58:54 +0100 (Sun, 02 Dec 2007) | 3 lines Add documentation for PySys_* functions. Written by Charlie Shepherd for GHOP. Also fixes #1245. ........ r59288 | nick.coghlan | 2007-12-03 13:55:17 +0100 (Mon, 03 Dec 2007) | 1 line Implement PEP 366 ........ r59290 | christian.heimes | 2007-12-03 14:47:29 +0100 (Mon, 03 Dec 2007) | 3 lines Applied my patch #1455 with some extra fixes for VS 2005 The new msvc9compiler module supports VS 2005 and VS 2008. I've also fixed build_ext to support PCbuild8 and PCbuild9 and backported my fix for xxmodule.c from py3k. The old code msvccompiler is still in place in case somebody likes to build an extension with VS 2003 or earlier. I've also updated the cygwin compiler module for VS 2005 and VS 2008. It works with VS 2005 but I'm unable to test it with VS 2008. We have to wait for a new version of cygwin. ........ r59291 | christian.heimes | 2007-12-03 14:55:16 +0100 (Mon, 03 Dec 2007) | 1 line Added comment to Misc/NEWS for r59290 ........ r59292 | christian.heimes | 2007-12-03 15:28:04 +0100 (Mon, 03 Dec 2007) | 1 line I followed MA Lemberg's suggestion and added comments to the late initialization of the type slots. ........ r59293 | facundo.batista | 2007-12-03 17:29:52 +0100 (Mon, 03 Dec 2007) | 3 lines Speedup and cleaning of __str__. Thanks Mark Dickinson. ........ r59294 | facundo.batista | 2007-12-03 18:55:00 +0100 (Mon, 03 Dec 2007) | 4 lines Faster _fix function, and some reordering for a more elegant coding. Thanks Mark Dickinson. ........ r59295 | martin.v.loewis | 2007-12-03 20:20:02 +0100 (Mon, 03 Dec 2007) | 5 lines Issue #1727780: Support loading pickles of random.Random objects created on 32-bit systems on 64-bit systems, and vice versa. As a consequence of the change, Random pickles created by Python 2.6 cannot be loaded in Python 2.5. ........ r59297 | facundo.batista | 2007-12-03 20:49:54 +0100 (Mon, 03 Dec 2007) | 3 lines Two small fixes. Issue 1547. ........ r59299 | georg.brandl | 2007-12-03 20:57:02 +0100 (Mon, 03 Dec 2007) | 2 lines #1548: fix apostroph placement. ........ r59300 | christian.heimes | 2007-12-03 21:01:02 +0100 (Mon, 03 Dec 2007) | 3 lines Patch #1537 from Chad Austin Change GeneratorExit's base class from Exception to BaseException (This time I'm applying the patch to the correct sandbox.) ........ r59302 | georg.brandl | 2007-12-03 21:03:46 +0100 (Mon, 03 Dec 2007) | 3 lines Add examples to the xmlrpclib docs. Written for GHOP by Josip Dzolonga. ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Mon Dec 3 22:02:03 2007 @@ -161,6 +161,7 @@ * Barry Scott * Joakim Sernbrant * Justin Sheehy +* Charlie Shepherd * Michael Simcich * Ionel Simionescu * Michael Sloan Modified: python/branches/py3k/Doc/c-api/init.rst ============================================================================== --- python/branches/py3k/Doc/c-api/init.rst (original) +++ python/branches/py3k/Doc/c-api/init.rst Mon Dec 3 22:02:03 2007 @@ -360,8 +360,6 @@ .. % XXX impl. doesn't seem consistent in allowing 0/NULL for the params; .. % check w/ Guido. -.. % XXX Other PySys thingies (doesn't really belong in this chapter) - .. _threads: Modified: python/branches/py3k/Doc/c-api/utilities.rst ============================================================================== --- python/branches/py3k/Doc/c-api/utilities.rst (original) +++ python/branches/py3k/Doc/c-api/utilities.rst Mon Dec 3 22:02:03 2007 @@ -66,6 +66,66 @@ not call those functions directly! :ctype:`PyOS_sighandler_t` is a typedef alias for :ctype:`void (\*)(int)`. +.. _systemfunctions: + +System Functions +================ + +These are utility functions that make functionality from the :mod:`sys` module +accessible to C code. They all work with the current interpreter thread's +:mod:`sys` module's dict, which is contained in the internal thread state structure. + +.. cfunction:: PyObject *PySys_GetObject(char *name) + + Return the object *name* from the :mod:`sys` module or *NULL* if it does + not exist, without setting an exception. + +.. cfunction:: FILE *PySys_GetFile(char *name, FILE *def) + + Return the :ctype:`FILE*` associated with the object *name* in the + :mod:`sys` module, or *def* if *name* is not in the module or is not associated + with a :ctype:`FILE*`. + +.. cfunction:: int PySys_SetObject(char *name, PyObject *v) + + Set *name* in the :mod:`sys` module to *v* unless *v* is *NULL*, in which + case *name* is deleted from the sys module. Returns ``0`` on success, ``-1`` + on error. + +.. cfunction:: void PySys_ResetWarnOptions(void) + + Reset :data:`sys.warnoptions` to an empty list. + +.. cfunction:: void PySys_AddWarnOption(char *s) + + Append *s* to :data:`sys.warnoptions`. + +.. cfunction:: void PySys_SetPath(char *path) + + Set :data:`sys.path` to a list object of paths found in *path* which should + be a list of paths separated with the platform's search path delimiter + (``:`` on Unix, ``;`` on Windows). + +.. cfunction:: void PySys_WriteStdout(const char *format, ...) + + Write the output string described by *format* to :data:`sys.stdout`. No + exceptions are raised, even if truncation occurs (see below). + + *format* should limit the total size of the formatted output string to + 1000 bytes or less -- after 1000 bytes, the output string is truncated. + In particular, this means that no unrestricted "%s" formats should occur; + these should be limited using "%.s" where is a decimal number + calculated so that plus the maximum size of other formatted text does not + exceed 1000 bytes. Also watch out for "%f", which can print hundreds of + digits for very large numbers. + + If a problem occurs, or :data:`sys.stdout` is unset, the formatted message + is written to the real (C level) *stdout*. + +.. cfunction:: void PySys_WriteStderr(const char *format, ...) + + As above, but write to :data:`sys.stderr` or *stderr* instead. + .. _processcontrol: Modified: python/branches/py3k/Doc/data/refcounts.dat ============================================================================== --- python/branches/py3k/Doc/data/refcounts.dat (original) +++ python/branches/py3k/Doc/data/refcounts.dat Mon Dec 3 22:02:03 2007 @@ -1251,10 +1251,32 @@ PyString_AsEncodedString:const char*:encoding:: PyString_AsEncodedString:const char*:errors:: +PySys_AddWarnOption:void::: +PySys_AddWarnOption:char*:s:: + +PySys_GetFile:FILE*::: +PySys_GetFile:char*:name:: +PySys_GetFile:FILE*:def:: + +PySys_GetObject:PyObject*::0: +PySys_GetObject:char*:name:: + PySys_SetArgv:int::: PySys_SetArgv:int:argc:: PySys_SetArgv:char**:argv:: +PySys_SetObject:int::: +PySys_SetObject:char*:name:: +PySys_SetObject:PyObject*:v:+1: + +PySys_ResetWarnOptions:void::: + +PySys_WriteStdout:void::: +PySys_WriteStdout:char*:format:: + +PySys_WriteStderr:void::: +PySys_WriteStderr:char*:format:: + PyThreadState_Clear:void::: PyThreadState_Clear:PyThreadState*:tstate:: Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Mon Dec 3 22:02:03 2007 @@ -400,7 +400,7 @@ :term:`immutable` keys rather than integers. slice - An object usually containing a portion of a :term:`sequence`. A slice is + A list containing a portion of an indexed list-like object. A slice is created using the subscript notation, ``[]`` with colons between numbers when several are given, such as in ``variable_name[1:3:5]``. The bracket (subscript) notation uses :class:`slice` objects internally. Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Mon Dec 3 22:02:03 2007 @@ -135,7 +135,9 @@ .. exception:: GeneratorExit - Raise when a :term:`generator`\'s :meth:`close` method is called. + Raise when a :term:`generator`\'s :meth:`close` method is called. It + directly inherits from :exc:`BaseException` instead of :exc:`Exception` since + it is technically not an error. .. exception:: IOError Modified: python/branches/py3k/Doc/library/random.rst ============================================================================== --- python/branches/py3k/Doc/library/random.rst (original) +++ python/branches/py3k/Doc/library/random.rst Mon Dec 3 22:02:03 2007 @@ -69,6 +69,8 @@ Return an object capturing the current internal state of the generator. This object can be passed to :func:`setstate` to restore the state. + State values produced in Python 2.6 cannot be loaded into earlier versions. + .. function:: setstate(state) Modified: python/branches/py3k/Doc/library/simplexmlrpcserver.rst ============================================================================== --- python/branches/py3k/Doc/library/simplexmlrpcserver.rst (original) +++ python/branches/py3k/Doc/library/simplexmlrpcserver.rst Mon Dec 3 22:02:03 2007 @@ -109,7 +109,11 @@ considered valid. The default value is ``('/', '/RPC2')``. -Example:: +.. _simplexmlrpcserver-example: + +SimpleXMLRPCServer Example +^^^^^^^^^^^^^^^^^^^^^^^^^^ +Server code:: from SimpleXMLRPCServer import SimpleXMLRPCServer @@ -137,7 +141,7 @@ # Run the server's main loop server.serve_forever() -The following client code will call the methods made available by the preceding +The following client code will call the methods made available by the preceding server:: import xmlrpclib Modified: python/branches/py3k/Doc/library/xmlrpclib.rst ============================================================================== --- python/branches/py3k/Doc/library/xmlrpclib.rst (original) +++ python/branches/py3k/Doc/library/xmlrpclib.rst Mon Dec 3 22:02:03 2007 @@ -192,6 +192,26 @@ Write the XML-RPC encoding of this Boolean item to the out stream object. +A working example follows. The server code:: + + import xmlrpclib + from SimpleXMLRPCServer import SimpleXMLRPCServer + + def is_even(n): + return n%2 == 0 + + server = SimpleXMLRPCServer(("localhost", 8000)) + print "Listening on port 8000..." + server.register_function(is_even, "is_even") + server.serve_forever() + +The client code for the preceding server:: + + import xmlrpclib + + proxy = xmlrpclib.ServerProxy("http://localhost:8000/") + print "3 is even: %s" % str(proxy.is_even(3)) + print "100 is even: %s" % str(proxy.is_even(100)) .. _datetime-objects: @@ -217,6 +237,32 @@ It also supports certain of Python's built-in operators through :meth:`__cmp__` and :meth:`__repr__` methods. +A working example follows. The server code:: + + import datetime + from SimpleXMLRPCServer import SimpleXMLRPCServer + import xmlrpclib + + def today(): + today = datetime.datetime.today() + return xmlrpclib.DateTime(today) + + server = SimpleXMLRPCServer(("localhost", 8000)) + print "Listening on port 8000..." + server.register_function(today, "today") + server.serve_forever() + +The client code for the preceding server:: + + import xmlrpclib + import datetime + + proxy = xmlrpclib.ServerProxy("http://localhost:8000/") + + today = proxy.today() + # convert the ISO8601 string to a datetime object + converted = datetime.datetime.strptime(today.value, "%Y%m%dT%H:%M:%S") + print "Today: %s" % converted.strftime("%d.%m.%Y, %H:%M") .. _binary-objects: @@ -249,6 +295,31 @@ It also supports certain of Python's built-in operators through a :meth:`__cmp__` method. +Example usage of the binary objects. We're going to transfer an image over +XMLRPC:: + + from SimpleXMLRPCServer import SimpleXMLRPCServer + import xmlrpclib + + def python_logo(): + handle = open("python_logo.jpg") + return xmlrpclib.Binary(handle.read()) + handle.close() + + server = SimpleXMLRPCServer(("localhost", 8000)) + print "Listening on port 8000..." + server.register_function(python_logo, 'python_logo') + + server.serve_forever() + +The client gets the image and saves it to a file:: + + import xmlrpclib + + proxy = xmlrpclib.ServerProxy("http://localhost:8000/") + handle = open("fetched_python_logo.jpg", "w") + handle.write(proxy.python_logo().data) + handle.close() .. _fault-objects: @@ -268,6 +339,35 @@ A string containing a diagnostic message associated with the fault. +In the following example we're going to intentionally cause a :exc:`Fault` by +returning a complex type object. The server code:: + + from SimpleXMLRPCServer import SimpleXMLRPCServer + + # A marshalling error is going to occur because we're returning a + # complex number + def add(x,y): + return x+y+0j + + server = SimpleXMLRPCServer(("localhost", 8000)) + print "Listening on port 8000..." + server.register_function(add, 'add') + + server.serve_forever() + +The client code for the preceding server:: + + import xmlrpclib + + proxy = xmlrpclib.ServerProxy("http://localhost:8000/") + try: + proxy.add(2, 5) + except xmlrpclib.Fault, err: + print "A fault occured" + print "Fault code: %d" % err.faultCode + print "Fault string: %s" % err.faultString + + .. _protocol-error-objects: @@ -299,6 +399,22 @@ A dict containing the headers of the HTTP/HTTPS request that triggered the error. +In the following example we're going to intentionally cause a :exc:`ProtocolError` +by providing an invalid URI:: + + import xmlrpclib + + # create a ServerProxy with an invalid URI + proxy = xmlrpclib.ServerProxy("http://invalidaddress/") + + try: + proxy.some_method() + except xmlrpclib.ProtocolError, err: + print "A protocol error occured" + print "URL: %s" % err.url + print "HTTP/HTTPS headers: %s" % err.headers + print "Error code: %d" % err.errcode + print "Error message: %s" % err.errmsg MultiCall Objects ----------------- @@ -317,12 +433,45 @@ is a :term:`generator`; iterating over this generator yields the individual results. -A usage example of this class is :: +A usage example of this class follows. The server code :: + + from SimpleXMLRPCServer import SimpleXMLRPCServer + + def add(x,y): + return x+y - multicall = MultiCall(server_proxy) - multicall.add(2,3) - multicall.get_address("Guido") - add_result, address = multicall() + def subtract(x, y): + return x-y + + def multiply(x, y): + return x*y + + def divide(x, y): + return x/y + + # A simple server with simple arithmetic functions + server = SimpleXMLRPCServer(("localhost", 8000)) + print "Listening on port 8000..." + server.register_multicall_functions() + server.register_function(add, 'add') + server.register_function(subtract, 'subtract') + server.register_function(multiply, 'multiply') + server.register_function(divide, 'divide') + server.serve_forever() + +The client code for the preceding server:: + + import xmlrpclib + + proxy = xmlrpclib.ServerProxy("http://localhost:8000/") + multicall = xmlrpclib.MultiCall(proxy) + multicall.add(7,3) + multicall.subtract(7,3) + multicall.multiply(7,3) + multicall.divide(7,3) + result = multicall() + + print "7+3=%d, 7-3=%d, 7*3=%d, 7/3=%d" % tuple(result) Convenience Functions @@ -407,3 +556,10 @@ server = xmlrpclib.Server('http://time.xmlrpc.com/RPC2', transport=p) print(server.currentTime.getCurrentTime()) + +Example of Client and Server Usage +---------------------------------- + +See :ref:`simplexmlrpcserver-example`. + + Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Mon Dec 3 22:02:03 2007 @@ -413,9 +413,6 @@ ... while True: ... try: ... value = (yield value) - ... except GeneratorExit: - ... # never catch GeneratorExit - ... raise ... except Exception, e: ... value = e ... finally: Modified: python/branches/py3k/Doc/using/cmdline.rst ============================================================================== --- python/branches/py3k/Doc/using/cmdline.rst (original) +++ python/branches/py3k/Doc/using/cmdline.rst Mon Dec 3 22:02:03 2007 @@ -10,7 +10,7 @@ .. note:: - Other implementation's command line schemes may differ. See + Other implementations' command line schemes may differ. See :ref:`implementations` for further resources. Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Mon Dec 3 22:02:03 2007 @@ -108,7 +108,7 @@ The previous version, Python 2.5, added the ':keyword:`with`' statement an optional feature, to be enabled by a ``from __future__ -import generators`` directive. In 2.6 the statement no longer need to +import with_statement`` directive. In 2.6 the statement no longer need to be specially enabled; this means that :keyword:`with` is now always a keyword. The rest of this section is a copy of the corresponding section from "What's New in Python 2.5" document; if you read @@ -481,7 +481,7 @@ of strings containing the names of valid attributes for the object, and lets the object control the value that :func:`dir` produces. Objects that have :meth:`__getattr__` or :meth:`__getattribute__` - methods. + methods can use this to advertise pseudo-attributes they will honor. .. % Patch 1591665 Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Mon Dec 3 22:02:03 2007 @@ -857,81 +857,51 @@ Captures all of the information in the underlying representation. """ + sign = ['', '-'][self._sign] if self._is_special: - if self._isnan(): - minus = '-'*self._sign - if self._int == '0': - info = '' - else: - info = self._int - if self._isnan() == 2: - return minus + 'sNaN' + info - return minus + 'NaN' + info - if self._isinfinity(): - minus = '-'*self._sign - return minus + 'Infinity' - - if context is None: - context = getcontext() + if self._exp == 'F': + return sign + 'Infinity' + elif self._exp == 'n': + return sign + 'NaN' + self._int + else: # self._exp == 'N' + return sign + 'sNaN' + self._int + + # number of digits of self._int to left of decimal point + leftdigits = self._exp + len(self._int) + + # dotplace is number of digits of self._int to the left of the + # decimal point in the mantissa of the output string (that is, + # after adjusting the exponent) + if self._exp <= 0 and leftdigits > -6: + # no exponent required + dotplace = leftdigits + elif not eng: + # usual scientific notation: 1 digit on left of the point + dotplace = 1 + elif self._int == '0': + # engineering notation, zero + dotplace = (leftdigits + 1) % 3 - 1 + else: + # engineering notation, nonzero + dotplace = (leftdigits - 1) % 3 + 1 - tmp = list(self._int) - numdigits = len(self._int) - leftdigits = self._exp + numdigits - if eng and not self: # self = 0eX wants 0[.0[0]]eY, not [[0]0]0eY - if self._exp < 0 and self._exp >= -6: # short, no need for e/E - s = '-'*self._sign + '0.' + '0'*(abs(self._exp)) - return s - # exp is closest mult. of 3 >= self._exp - exp = ((self._exp - 1)// 3 + 1) * 3 - if exp != self._exp: - s = '0.'+'0'*(exp - self._exp) - else: - s = '0' - if exp != 0: - if context.capitals: - s += 'E' - else: - s += 'e' - if exp > 0: - s += '+' # 0.0e+3, not 0.0e3 - s += str(exp) - s = '-'*self._sign + s - return s - if eng: - dotplace = (leftdigits-1)%3+1 - adjexp = leftdigits -1 - (leftdigits-1)%3 + if dotplace <= 0: + intpart = '0' + fracpart = '.' + '0'*(-dotplace) + self._int + elif dotplace >= len(self._int): + intpart = self._int+'0'*(dotplace-len(self._int)) + fracpart = '' else: - adjexp = leftdigits-1 - dotplace = 1 - if self._exp == 0: - pass - elif self._exp < 0 and adjexp >= 0: - tmp.insert(leftdigits, '.') - elif self._exp < 0 and adjexp >= -6: - tmp[0:0] = ['0'] * int(-leftdigits) - tmp.insert(0, '0.') - else: - if numdigits > dotplace: - tmp.insert(dotplace, '.') - elif numdigits < dotplace: - tmp.extend(['0']*(dotplace-numdigits)) - if adjexp: - if not context.capitals: - tmp.append('e') - else: - tmp.append('E') - if adjexp > 0: - tmp.append('+') - tmp.append(str(adjexp)) - if eng: - while tmp[0:1] == ['0']: - tmp[0:1] = [] - if len(tmp) == 0 or tmp[0] == '.' or tmp[0].lower() == 'e': - tmp[0:0] = ['0'] - if self._sign: - tmp.insert(0, '-') + intpart = self._int[:dotplace] + fracpart = '.' + self._int[dotplace:] + if leftdigits == dotplace: + exp = '' + else: + if context is None: + context = getcontext() + exp = ['e', 'E'][context.capitals] + "%+d" % (leftdigits-dotplace) - return ''.join(tmp) + return sign + intpart + fracpart + exp def to_eng_string(self, context=None): """Convert to engineering-type string. @@ -1127,29 +1097,6 @@ return other.__sub__(self, context=context) - def _increment(self): - """Special case of add, adding 1eExponent - - Since it is common, (rounding, for example) this adds - (sign)*one E self._exp to the number more efficiently than add. - - Assumes that self is nonspecial. - - For example: - Decimal('5.624e10')._increment() == Decimal('5.625e10') - """ - L = list(map(int, self._int)) - L[-1] += 1 - spot = len(L)-1 - while L[spot] == 10: - L[spot] = 0 - if spot == 0: - L[0:0] = [1] - break - L[spot-1] += 1 - spot -= 1 - return _dec_from_triple(self._sign, "".join(map(str, L)), self._exp) - def __mul__(self, other, context=None): """Return self * other. @@ -1580,8 +1527,18 @@ # round if self has too many digits if self._exp < exp_min: context._raise_error(Rounded) - ans = self._rescale(exp_min, context.rounding) - if ans != self: + digits = len(self._int) + self._exp - exp_min + if digits < 0: + self = _dec_from_triple(self._sign, '1', exp_min-1) + digits = 0 + this_function = getattr(self, self._pick_rounding_function[context.rounding]) + changed = this_function(digits) + coeff = self._int[:digits] or '0' + if changed == 1: + coeff = str(int(coeff)+1) + ans = _dec_from_triple(self._sign, coeff, exp_min) + + if changed: context._raise_error(Inexact) if self_is_subnormal: context._raise_error(Underflow) @@ -1614,66 +1571,68 @@ # for each of the rounding functions below: # self is a finite, nonzero Decimal # prec is an integer satisfying 0 <= prec < len(self._int) - # the rounded result will have exponent self._exp + len(self._int) - prec; + # + # each function returns either -1, 0, or 1, as follows: + # 1 indicates that self should be rounded up (away from zero) + # 0 indicates that self should be truncated, and that all the + # digits to be truncated are zeros (so the value is unchanged) + # -1 indicates that there are nonzero digits to be truncated def _round_down(self, prec): """Also known as round-towards-0, truncate.""" - newexp = self._exp + len(self._int) - prec - return _dec_from_triple(self._sign, self._int[:prec] or '0', newexp) + if _all_zeros(self._int, prec): + return 0 + else: + return -1 def _round_up(self, prec): """Rounds away from 0.""" - newexp = self._exp + len(self._int) - prec - tmp = _dec_from_triple(self._sign, self._int[:prec] or '0', newexp) - for digit in self._int[prec:]: - if digit != '0': - return tmp._increment() - return tmp + return -self._round_down(prec) def _round_half_up(self, prec): """Rounds 5 up (away from 0)""" if self._int[prec] in '56789': - return self._round_up(prec) + return 1 + elif _all_zeros(self._int, prec): + return 0 else: - return self._round_down(prec) + return -1 def _round_half_down(self, prec): """Round 5 down""" - if self._int[prec] == '5': - for digit in self._int[prec+1:]: - if digit != '0': - break - else: - return self._round_down(prec) - return self._round_half_up(prec) + if _exact_half(self._int, prec): + return -1 + else: + return self._round_half_up(prec) def _round_half_even(self, prec): """Round 5 to even, rest to nearest.""" - if prec and self._int[prec-1] in '13579': - return self._round_half_up(prec) + if _exact_half(self._int, prec) and \ + (prec == 0 or self._int[prec-1] in '02468'): + return -1 else: - return self._round_half_down(prec) + return self._round_half_up(prec) def _round_ceiling(self, prec): """Rounds up (not away from 0 if negative.)""" if self._sign: return self._round_down(prec) else: - return self._round_up(prec) + return -self._round_down(prec) def _round_floor(self, prec): """Rounds down (not towards 0 if negative)""" if not self._sign: return self._round_down(prec) else: - return self._round_up(prec) + return -self._round_down(prec) def _round_05up(self, prec): """Round down unless digit prec-1 is 0 or 5.""" - if prec == 0 or self._int[prec-1] in '05': - return self._round_up(prec) - else: + if prec and self._int[prec-1] not in '05': return self._round_down(prec) + else: + return -self._round_down(prec) def fma(self, other, third, context=None): """Fused multiply-add. @@ -2330,7 +2289,11 @@ self = _dec_from_triple(self._sign, '1', exp-1) digits = 0 this_function = getattr(self, self._pick_rounding_function[rounding]) - return this_function(digits) + changed = this_function(digits) + coeff = self._int[:digits] or '0' + if changed == 1: + coeff = str(int(coeff)+1) + return _dec_from_triple(self._sign, coeff, exp) def to_integral_exact(self, rounding=None, context=None): """Rounds to a nearby integer. @@ -5236,6 +5199,8 @@ $ """, re.VERBOSE | re.IGNORECASE).match +_all_zeros = re.compile('0*$').match +_exact_half = re.compile('50*$').match del re Modified: python/branches/py3k/Lib/distutils/command/build_ext.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/build_ext.py (original) +++ python/branches/py3k/Lib/distutils/command/build_ext.py Mon Dec 3 22:02:03 2007 @@ -14,6 +14,10 @@ from distutils.extension import Extension from distutils import log +if os.name == 'nt': + from distutils.msvccompiler import get_build_version + MSVC_VERSION = int(get_build_version()) + # An extension name is just a dot-separated list of Python NAMEs (ie. # the same as a fully-qualified module name). extension_name_re = re.compile \ @@ -172,7 +176,15 @@ # Append the source distribution include and library directories, # this allows distutils on windows to work in the source tree self.include_dirs.append(os.path.join(sys.exec_prefix, 'PC')) - self.library_dirs.append(os.path.join(sys.exec_prefix, 'PCBuild')) + if MSVC_VERSION == 9: + self.library_dirs.append(os.path.join(sys.exec_prefix, + 'PCBuild9')) + elif MSVC_VERSION == 8: + self.library_dirs.append(os.path.join(sys.exec_prefix, + 'PCBuild8', 'win32release')) + else: + self.library_dirs.append(os.path.join(sys.exec_prefix, + 'PCBuild')) # OS/2 (EMX) doesn't support Debug vs Release builds, but has the # import libraries in its "Config" subdirectory Modified: python/branches/py3k/Lib/distutils/cygwinccompiler.py ============================================================================== --- python/branches/py3k/Lib/distutils/cygwinccompiler.py (original) +++ python/branches/py3k/Lib/distutils/cygwinccompiler.py Mon Dec 3 22:02:03 2007 @@ -54,6 +54,29 @@ from distutils.errors import DistutilsExecError, CompileError, UnknownFileError from distutils import log +def get_msvcr(): + """Include the appropriate MSVC runtime library if Python was built + with MSVC 7.0 or later. + """ + msc_pos = sys.version.find('MSC v.') + if msc_pos != -1: + msc_ver = sys.version[msc_pos+6:msc_pos+10] + if msc_ver == '1300': + # MSVC 7.0 + return ['msvcr70'] + elif msc_ver == '1310': + # MSVC 7.1 + return ['msvcr71'] + elif msc_ver == '1400': + # VS2005 / MSVC 8.0 + return ['msvcr80'] + elif msc_ver == '1500': + # VS2008 / MSVC 9.0 + return ['msvcr90'] + else: + raise ValueError("Unknown MS Compiler version %i " % msc_Ver) + + class CygwinCCompiler (UnixCCompiler): compiler_type = 'cygwin' @@ -119,18 +142,9 @@ self.warn( "Consider upgrading to a newer version of gcc") else: - self.dll_libraries=[] # Include the appropriate MSVC runtime library if Python was built - # with MSVC 7.0 or 7.1. - msc_pos = sys.version.find('MSC v.') - if msc_pos != -1: - msc_ver = sys.version[msc_pos+6:msc_pos+10] - if msc_ver == '1300': - # MSVC 7.0 - self.dll_libraries = ['msvcr70'] - elif msc_ver == '1310': - # MSVC 7.1 - self.dll_libraries = ['msvcr71'] + # with MSVC 7.0 or later. + self.dll_libraries = get_msvcr() # __init__ () @@ -317,16 +331,8 @@ self.dll_libraries=[] # Include the appropriate MSVC runtime library if Python was built - # with MSVC 7.0 or 7.1. - msc_pos = sys.version.find('MSC v.') - if msc_pos != -1: - msc_ver = sys.version[msc_pos+6:msc_pos+10] - if msc_ver == '1300': - # MSVC 7.0 - self.dll_libraries = ['msvcr70'] - elif msc_ver == '1310': - # MSVC 7.1 - self.dll_libraries = ['msvcr71'] + # with MSVC 7.0 or later. + self.dll_libraries = get_msvcr() # __init__ () Modified: python/branches/py3k/Lib/distutils/msvccompiler.py ============================================================================== --- python/branches/py3k/Lib/distutils/msvccompiler.py (original) +++ python/branches/py3k/Lib/distutils/msvccompiler.py Mon Dec 3 22:02:03 2007 @@ -632,3 +632,11 @@ p = self.get_msvc_paths(name) if p: os.environ[name] = ';'.join(p) + + +if get_build_version() >= 8.0: + log.debug("Importing new compiler from distutils.msvc9compiler") + OldMSVCCompiler = MSVCCompiler + from distutils.msvc9compiler import MSVCCompiler + from distutils.msvc9compiler import get_build_architecture + from distutils.msvc9compiler import MacroExpander Modified: python/branches/py3k/Lib/random.py ============================================================================== --- python/branches/py3k/Lib/random.py (original) +++ python/branches/py3k/Lib/random.py Mon Dec 3 22:02:03 2007 @@ -83,7 +83,7 @@ """ - VERSION = 2 # used by getstate/setstate + VERSION = 3 # used by getstate/setstate def __init__(self, x=None): """Initialize an instance. @@ -120,9 +120,20 @@ def setstate(self, state): """Restore internal state from object returned by getstate().""" version = state[0] - if version == 2: + if version == 3: version, internalstate, self.gauss_next = state super().setstate(internalstate) + elif version == 2: + version, internalstate, self.gauss_next = state + # In version 2, the state was saved as signed ints, which causes + # inconsistencies between 32/64-bit systems. The state is + # really unsigned 32-bit ints, so we convert negative ints from + # version 2 to positive longs for version 3. + try: + internalstate = tuple( x % (2**32) for x in internalstate ) + except ValueError as e: + raise TypeError from e + super(Random, self).setstate(internalstate) else: raise ValueError("state with version %s passed to " "Random.setstate() of version %s" % Modified: python/branches/py3k/Lib/runpy.py ============================================================================== --- python/branches/py3k/Lib/runpy.py (original) +++ python/branches/py3k/Lib/runpy.py Mon Dec 3 22:02:03 2007 @@ -23,19 +23,20 @@ def _run_code(code, run_globals, init_globals=None, mod_name=None, mod_fname=None, - mod_loader=None): + mod_loader=None, pkg_name=None): """Helper for _run_module_code""" if init_globals is not None: run_globals.update(init_globals) run_globals.update(__name__ = mod_name, __file__ = mod_fname, - __loader__ = mod_loader) + __loader__ = mod_loader, + __package__ = pkg_name) exec(code, run_globals) return run_globals def _run_module_code(code, init_globals=None, mod_name=None, mod_fname=None, - mod_loader=None): + mod_loader=None, pkg_name=None): """Helper for run_module""" # Set up the top level namespace dictionary temp_module = imp.new_module(mod_name) @@ -49,7 +50,8 @@ sys.modules[mod_name] = temp_module try: _run_code(code, mod_globals, init_globals, - mod_name, mod_fname, mod_loader) + mod_name, mod_fname, + mod_loader, pkg_name) finally: sys.argv[0] = saved_argv0 if restore_module: @@ -95,11 +97,12 @@ __loader__ """ loader, code, fname = _get_module_details(mod_name) + pkg_name = mod_name.rpartition('.')[0] main_globals = sys.modules["__main__"].__dict__ if set_argv0: sys.argv[0] = fname return _run_code(code, main_globals, None, - "__main__", fname, loader) + "__main__", fname, loader, pkg_name) def run_module(mod_name, init_globals=None, run_name=None, alter_sys=False): @@ -110,13 +113,14 @@ loader, code, fname = _get_module_details(mod_name) if run_name is None: run_name = mod_name + pkg_name = mod_name.rpartition('.')[0] if alter_sys: return _run_module_code(code, init_globals, run_name, - fname, loader) + fname, loader, pkg_name) else: # Leave the sys module alone - return _run_code(code, {}, init_globals, - run_name, fname, loader) + return _run_code(code, {}, init_globals, run_name, + fname, loader, pkg_name) if __name__ == "__main__": Modified: python/branches/py3k/Lib/test/exception_hierarchy.txt ============================================================================== --- python/branches/py3k/Lib/test/exception_hierarchy.txt (original) +++ python/branches/py3k/Lib/test/exception_hierarchy.txt Mon Dec 3 22:02:03 2007 @@ -1,8 +1,8 @@ BaseException +-- SystemExit +-- KeyboardInterrupt + +-- GeneratorExit +-- Exception - +-- GeneratorExit +-- StopIteration +-- ArithmeticError | +-- FloatingPointError Modified: python/branches/py3k/Lib/test/test_cmd_line_script.py ============================================================================== --- python/branches/py3k/Lib/test/test_cmd_line_script.py (original) +++ python/branches/py3k/Lib/test/test_cmd_line_script.py Mon Dec 3 22:02:03 2007 @@ -35,15 +35,15 @@ finally: shutil.rmtree(dirname) -test_source = ("""\ +test_source = """\ # Script may be run with optimisation enabled, so don't rely on assert # statements being executed def assertEqual(lhs, rhs): if lhs != rhs: - raise AssertionError("%r != %r" % (lhs, rhs)) + raise AssertionError('%r != %r' % (lhs, rhs)) def assertIdentical(lhs, rhs): if lhs is not rhs: - raise AssertionError("%r is not %r" % (lhs, rhs)) + raise AssertionError('%r is not %r' % (lhs, rhs)) # Check basic code execution result = ['Top level assignment'] def f(): @@ -53,17 +53,18 @@ # Check population of magic variables assertEqual(__name__, '__main__') print('__file__==%r' % __file__) +print('__package__==%r' % __package__) # Check the sys module import sys assertIdentical(globals(), sys.modules[__name__].__dict__) print('sys.argv[0]==%r' % sys.argv[0]) -""") +""" -def _make_test_script(script_dir, script_basename): - script_filename = script_basename+os.path.extsep+"py" +def _make_test_script(script_dir, script_basename, source=test_source): + script_filename = script_basename+os.path.extsep+'py' script_name = os.path.join(script_dir, script_filename) - script_file = open(script_name, "w") - script_file.write(test_source) + script_file = open(script_name, 'w') + script_file.write(source) script_file.close() return script_name @@ -88,59 +89,96 @@ # zip_file.close() return zip_name +def _make_test_pkg(pkg_dir): + os.mkdir(pkg_dir) + _make_test_script(pkg_dir, '__init__', '') + +# There's no easy way to pass the script directory in to get +# -m to work (avoiding that is the whole point of making +# directories and zipfiles executable!) +# So we fake it for testing purposes with a custom launch script +launch_source = """\ +import sys, os.path, runpy +sys.path[0:0] = os.path.dirname(__file__) +runpy._run_module_as_main(%r) +""" + +def _make_launch_script(script_dir, script_basename, module_name): + return _make_test_script(script_dir, script_basename, + launch_source % module_name) + class CmdLineTest(unittest.TestCase): - def _check_script(self, script_name, expected_file, expected_argv0): - exit_code, data = _run_python(script_name) + def _check_script(self, script_name, expected_file, + expected_argv0, expected_package, + *cmd_line_switches): + run_args = cmd_line_switches + (script_name,) + exit_code, data = _run_python(*run_args) if verbose: print("Output from test script %r:" % script_name) print(data) - self.assertEqual(exit_code, 0, data) + self.assertEqual(exit_code, 0) printed_file = '__file__==%r' % expected_file printed_argv0 = 'sys.argv[0]==%r' % expected_argv0 - self.assert_(printed_file in data, (printed_file, data)) - self.assert_(printed_argv0 in data, (printed_argv0, data)) + printed_package = '__package__==%r' % expected_package + if verbose: + print('Expected output:') + print(printed_file) + print(printed_package) + print(printed_argv0) + self.assert_(printed_file in data) + self.assert_(printed_package in data) + self.assert_(printed_argv0 in data) def test_basic_script(self): with temp_dir() as script_dir: - script_name = _make_test_script(script_dir, "script") - self._check_script(script_name, script_name, script_name) + script_name = _make_test_script(script_dir, 'script') + self._check_script(script_name, script_name, script_name, None) def test_script_compiled(self): with temp_dir() as script_dir: - script_name = _make_test_script(script_dir, "script") + script_name = _make_test_script(script_dir, 'script') compiled_name = _compile_test_script(script_name) os.remove(script_name) - self._check_script(compiled_name, compiled_name, compiled_name) + self._check_script(compiled_name, compiled_name, compiled_name, None) def test_directory(self): with temp_dir() as script_dir: - script_name = _make_test_script(script_dir, "__main__") - self._check_script(script_dir, script_name, script_dir) + script_name = _make_test_script(script_dir, '__main__') + self._check_script(script_dir, script_name, script_dir, '') def test_directory_compiled(self): with temp_dir() as script_dir: - script_name = _make_test_script(script_dir, "__main__") + script_name = _make_test_script(script_dir, '__main__') compiled_name = _compile_test_script(script_name) os.remove(script_name) - self._check_script(script_dir, compiled_name, script_dir) + self._check_script(script_dir, compiled_name, script_dir, '') def test_zipfile(self): with temp_dir() as script_dir: - script_name = _make_test_script(script_dir, "__main__") - zip_name = _make_test_zip(script_dir, "test_zip", script_name) - self._check_script(zip_name, None, zip_name) + script_name = _make_test_script(script_dir, '__main__') + zip_name = _make_test_zip(script_dir, 'test_zip', script_name) + self._check_script(zip_name, None, zip_name, '') def test_zipfile_compiled(self): with temp_dir() as script_dir: - script_name = _make_test_script(script_dir, "__main__") + script_name = _make_test_script(script_dir, '__main__') compiled_name = _compile_test_script(script_name) - zip_name = _make_test_zip(script_dir, "test_zip", compiled_name) - self._check_script(zip_name, None, zip_name) + zip_name = _make_test_zip(script_dir, 'test_zip', compiled_name) + self._check_script(zip_name, None, zip_name, '') + + def test_module_in_package(self): + with temp_dir() as script_dir: + pkg_dir = os.path.join(script_dir, 'test_pkg') + _make_test_pkg(pkg_dir) + script_name = _make_test_script(pkg_dir, 'script') + launch_name = _make_launch_script(script_dir, 'launch', 'test_pkg.script') + self._check_script(launch_name, script_name, + script_name, 'test_pkg') def test_main(): test.test_support.run_unittest(CmdLineTest) test.test_support.reap_children() -if __name__ == "__main__": +if __name__ == '__main__': test_main() Modified: python/branches/py3k/Lib/test/test_frozen.py ============================================================================== --- python/branches/py3k/Lib/test/test_frozen.py (original) +++ python/branches/py3k/Lib/test/test_frozen.py Mon Dec 3 22:02:03 2007 @@ -12,7 +12,7 @@ except ImportError as x: self.fail("import __hello__ failed:" + str(x)) self.assertEqual(__hello__.initialized, True) - self.assertEqual(len(dir(__hello__)), 5) + self.assertEqual(len(dir(__hello__)), 6, dir(__hello__)) try: import __phello__ @@ -20,17 +20,17 @@ self.fail("import __phello__ failed:" + str(x)) self.assertEqual(__phello__.initialized, True) if not "__phello__.spam" in sys.modules: - self.assertEqual(len(dir(__phello__)), 6, dir(__phello__)) - else: self.assertEqual(len(dir(__phello__)), 7, dir(__phello__)) + else: + self.assertEqual(len(dir(__phello__)), 8, dir(__phello__)) try: import __phello__.spam except ImportError as x: self.fail("import __phello__.spam failed:" + str(x)) self.assertEqual(__phello__.spam.initialized, True) - self.assertEqual(len(dir(__phello__.spam)), 5) - self.assertEqual(len(dir(__phello__)), 7) + self.assertEqual(len(dir(__phello__.spam)), 6) + self.assertEqual(len(dir(__phello__)), 8) try: import __phello__.foo Modified: python/branches/py3k/Lib/test/test_generators.py ============================================================================== --- python/branches/py3k/Lib/test/test_generators.py (original) +++ python/branches/py3k/Lib/test/test_generators.py Mon Dec 3 22:02:03 2007 @@ -1668,6 +1668,21 @@ exiting +GeneratorExit is not caught by except Exception: + +>>> def f(): +... try: yield +... except Exception: +... print('except') +... finally: +... print('finally') + +>>> g = f() +>>> next(g) +>>> del g +finally + + Now let's try some ill-behaved generators: >>> def f(): Modified: python/branches/py3k/Lib/test/test_pkg.py ============================================================================== --- python/branches/py3k/Lib/test/test_pkg.py (original) +++ python/branches/py3k/Lib/test/test_pkg.py Mon Dec 3 22:02:03 2007 @@ -192,11 +192,13 @@ import t5 self.assertEqual(fixdir(dir(t5)), ['__doc__', '__file__', '__name__', - '__path__', 'foo', 'string', 't5']) + '__package__', '__path__', 'foo', 'string', 't5']) self.assertEqual(fixdir(dir(t5.foo)), - ['__doc__', '__file__', '__name__', 'string']) + ['__doc__', '__file__', '__name__', '__package__', + 'string']) self.assertEqual(fixdir(dir(t5.string)), - ['__doc__', '__file__', '__name__', 'spam']) + ['__doc__', '__file__', '__name__','__package__', + 'spam']) def test_6(self): hier = [ @@ -212,14 +214,14 @@ import t6 self.assertEqual(fixdir(dir(t6)), ['__all__', '__doc__', '__file__', - '__name__', '__path__']) + '__name__', '__package__', '__path__']) s = """ import t6 from t6 import * self.assertEqual(fixdir(dir(t6)), ['__all__', '__doc__', '__file__', - '__name__', '__path__', 'eggs', - 'ham', 'spam']) + '__name__', '__package__', '__path__', + 'eggs', 'ham', 'spam']) self.assertEqual(dir(), ['eggs', 'ham', 'self', 'spam', 't6']) """ self.run_code(s) @@ -245,17 +247,19 @@ t7, sub, subsub = None, None, None import t7 as tas self.assertEqual(fixdir(dir(tas)), - ['__doc__', '__file__', '__name__', '__path__']) + ['__doc__', '__file__', '__name__', + '__package__', '__path__']) self.failIf(t7) from t7 import sub as subpar self.assertEqual(fixdir(dir(subpar)), - ['__doc__', '__file__', '__name__', '__path__']) + ['__doc__', '__file__', '__name__', + '__package__', '__path__']) self.failIf(t7) self.failIf(sub) from t7.sub import subsub as subsubsub self.assertEqual(fixdir(dir(subsubsub)), - ['__doc__', '__file__', '__name__', '__path__', - 'spam']) + ['__doc__', '__file__', '__name__', + '__package__', '__path__', 'spam']) self.failIf(t7) self.failIf(sub) self.failIf(subsub) Modified: python/branches/py3k/Lib/test/test_random.py ============================================================================== --- python/branches/py3k/Lib/test/test_random.py (original) +++ python/branches/py3k/Lib/test/test_random.py Mon Dec 3 22:02:03 2007 @@ -144,6 +144,19 @@ restoredseq = [newgen.random() for i in range(10)] self.assertEqual(origseq, restoredseq) + def test_bug_1727780(self): + # verify that version-2-pickles can be loaded + # fine, whether they are created on 32-bit or 64-bit + # platforms, and that version-3-pickles load fine. + files = [("randv2_32.pck", 780), + ("randv2_64.pck", 866), + ("randv3.pck", 343)] + for file, value in files: + f = open(test_support.findfile(file),"rb") + r = pickle.load(f) + f.close() + self.assertEqual(r.randrange(1000), value) + class WichmannHill_TestBasicOps(TestBasicOps): gen = random.WichmannHill() Modified: python/branches/py3k/Lib/test/test_runpy.py ============================================================================== --- python/branches/py3k/Lib/test/test_runpy.py (original) +++ python/branches/py3k/Lib/test/test_runpy.py Mon Dec 3 22:02:03 2007 @@ -5,7 +5,12 @@ import sys import tempfile from test.test_support import verbose, run_unittest, forget -from runpy import _run_code, _run_module_code, _run_module_as_main, run_module +from runpy import _run_code, _run_module_code, run_module + +# Note: This module can't safely test _run_module_as_main as it +# runs its tests in the current process, which would mess with the +# real __main__ module (usually test.regrtest) +# See test_cmd_line_script for a test that executes that code path # Set up the test code and expected results @@ -36,6 +41,7 @@ self.failUnless(d["__name__"] is None) self.failUnless(d["__file__"] is None) self.failUnless(d["__loader__"] is None) + self.failUnless(d["__package__"] is None) self.failUnless(d["run_argv0"] is saved_argv0) self.failUnless("run_name" not in d) self.failUnless(sys.argv[0] is saved_argv0) @@ -45,13 +51,15 @@ name = "" file = "Some other nonsense" loader = "Now you're just being silly" + package = '' # Treat as a top level module d1 = dict(initial=initial) saved_argv0 = sys.argv[0] d2 = _run_module_code(self.test_source, d1, name, file, - loader) + loader, + package) self.failUnless("result" not in d1) self.failUnless(d2["initial"] is initial) self.assertEqual(d2["result"], self.expected_result) @@ -62,6 +70,7 @@ self.failUnless(d2["__file__"] is file) self.failUnless(d2["run_argv0"] is file) self.failUnless(d2["__loader__"] is loader) + self.failUnless(d2["__package__"] is package) self.failUnless(sys.argv[0] is saved_argv0) self.failUnless(name not in sys.modules) @@ -164,7 +173,7 @@ self._del_pkg(pkg_dir, depth, mod_name) if verbose: print("Module executed successfully") - def _add_relative_modules(self, base_dir, depth): + def _add_relative_modules(self, base_dir, source, depth): if depth <= 1: raise ValueError("Relative module test needs depth > 1") pkg_name = "__runpy_pkg__" @@ -190,7 +199,7 @@ if verbose: print(" Added nephew module:", nephew_fname) def _check_relative_imports(self, depth, run_name=None): - contents = """\ + contents = r"""\ from __future__ import absolute_import from . import sibling from ..uncle.cousin import nephew @@ -198,16 +207,21 @@ pkg_dir, mod_fname, mod_name = ( self._make_pkg(contents, depth)) try: - self._add_relative_modules(pkg_dir, depth) + self._add_relative_modules(pkg_dir, contents, depth) + pkg_name = mod_name.rpartition('.')[0] if verbose: print("Running from source:", mod_name) - d1 = run_module(mod_name) # Read from source + d1 = run_module(mod_name, run_name=run_name) # Read from source + self.failUnless("__package__" in d1) + self.failUnless(d1["__package__"] == pkg_name) self.failUnless("sibling" in d1) self.failUnless("nephew" in d1) del d1 # Ensure __loader__ entry doesn't keep file open __import__(mod_name) os.remove(mod_fname) if verbose: print("Running from compiled:", mod_name) - d2 = run_module(mod_name) # Read from bytecode + d2 = run_module(mod_name, run_name=run_name) # Read from bytecode + self.failUnless("__package__" in d2) + self.failUnless(d2["__package__"] == pkg_name) self.failUnless("sibling" in d2) self.failUnless("nephew" in d2) del d2 # Ensure __loader__ entry doesn't keep file open @@ -225,6 +239,11 @@ if verbose: print("Testing relative imports at depth:", depth) self._check_relative_imports(depth) + def test_main_relative_import(self): + for depth in range(2, 5): + if verbose: print("Testing main relative imports at depth:", depth) + self._check_relative_imports(depth, "__main__") + def test_main(): run_unittest(RunModuleCodeTest) Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Mon Dec 3 22:02:03 2007 @@ -398,6 +398,7 @@ Mark Levinson William Lewis Robert van Liere +Shawn Ligocki Martin Ligr Christopher Lindblad Eric Lindvall Modified: python/branches/py3k/Modules/_randommodule.c ============================================================================== --- python/branches/py3k/Modules/_randommodule.c (original) +++ python/branches/py3k/Modules/_randommodule.c Mon Dec 3 22:02:03 2007 @@ -319,7 +319,7 @@ if (state == NULL) return NULL; for (i=0; istate[i])); + element = PyLong_FromUnsignedLong(self->state[i]); if (element == NULL) goto Fail; PyTuple_SET_ITEM(state, i, element); @@ -339,7 +339,8 @@ random_setstate(RandomObject *self, PyObject *state) { int i; - long element; + unsigned long element; + long index; if (!PyTuple_Check(state)) { PyErr_SetString(PyExc_TypeError, @@ -353,16 +354,16 @@ } for (i=0; istate[i] = (unsigned long)element; + self->state[i] = element & 0xffffffffUL; /* Make sure we get sane state */ } - element = PyLong_AsLong(PyTuple_GET_ITEM(state, i)); - if (element == -1 && PyErr_Occurred()) + index = PyLong_AsLong(PyTuple_GET_ITEM(state, i)); + if (index == -1 && PyErr_Occurred()) return NULL; - self->index = (int)element; + self->index = (int)index; Py_INCREF(Py_None); return Py_None; Modified: python/branches/py3k/Modules/xxmodule.c ============================================================================== --- python/branches/py3k/Modules/xxmodule.c (original) +++ python/branches/py3k/Modules/xxmodule.c Mon Dec 3 22:02:03 2007 @@ -246,7 +246,7 @@ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ - 0, /*tp_base*/ + 0, /* see initxx */ /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ @@ -301,14 +301,14 @@ 0, /*tp_methods*/ 0, /*tp_members*/ 0, /*tp_getset*/ - 0, /*tp_base*/ + 0, /* see initxx */ /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ 0, /*tp_init*/ 0, /*tp_alloc*/ - PyType_GenericNew, /*tp_new*/ + 0, /* see initxx */ /*tp_new*/ 0, /*tp_free*/ 0, /*tp_is_gc*/ }; @@ -341,12 +341,15 @@ { PyObject *m; + /* Due to cross platform compiler issues the slots must be filled + * here. It's required for portability to Windows without requiring + * C++. */ Null_Type.tp_base = &PyBaseObject_Type; + Null_Type.tp_new = PyType_GenericNew; Str_Type.tp_base = &PyUnicode_Type; /* Finalize the type object including setting type of the new type - * object; doing it here is required for portability to Windows - * without requiring C++. */ + * object; doing it here is required for portability, too. /* if (PyType_Ready(&Xxo_Type) < 0) return; Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Mon Dec 3 22:02:03 2007 @@ -424,9 +424,9 @@ /* - * GeneratorExit extends Exception + * GeneratorExit extends BaseException */ -SimpleExtendsException(PyExc_Exception, GeneratorExit, +SimpleExtendsException(PyExc_BaseException, GeneratorExit, "Request that a generator exit."); Modified: python/branches/py3k/Objects/moduleobject.c ============================================================================== --- python/branches/py3k/Objects/moduleobject.c (original) +++ python/branches/py3k/Objects/moduleobject.c Mon Dec 3 22:02:03 2007 @@ -30,6 +30,8 @@ goto fail; if (PyDict_SetItemString(m->md_dict, "__doc__", Py_None) != 0) goto fail; + if (PyDict_SetItemString(m->md_dict, "__package__", Py_None) != 0) + goto fail; Py_DECREF(nameobj); PyObject_GC_Track(m); return (PyObject *)m; Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Mon Dec 3 22:02:03 2007 @@ -975,6 +975,7 @@ lib.add_file("empty.vbs") lib.glob("*.uue") lib.glob("*.pem") + lib.glob("*.pck") lib.add_file("readme.txt", src="README") if dir=='decimaltestdata': lib.glob("*.decTest") From python-3000-checkins at python.org Mon Dec 3 22:07:25 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Mon, 3 Dec 2007 22:07:25 +0100 (CET) Subject: [Python-3000-checkins] r59305 - python/branches/py3k/Doc/glossary.rst Message-ID: <20071203210725.6E8821E4012@bag.python.org> Author: georg.brandl Date: Mon Dec 3 22:07:25 2007 New Revision: 59305 Modified: python/branches/py3k/Doc/glossary.rst Log: Fix merging glitch. Modified: python/branches/py3k/Doc/glossary.rst ============================================================================== --- python/branches/py3k/Doc/glossary.rst (original) +++ python/branches/py3k/Doc/glossary.rst Mon Dec 3 22:07:25 2007 @@ -400,7 +400,7 @@ :term:`immutable` keys rather than integers. slice - A list containing a portion of an indexed list-like object. A slice is + An object usually containing a portion of a :term:`sequence`. A slice is created using the subscript notation, ``[]`` with colons between numbers when several are given, such as in ``variable_name[1:3:5]``. The bracket (subscript) notation uses :class:`slice` objects internally. From g.brandl at gmx.net Mon Dec 3 22:08:34 2007 From: g.brandl at gmx.net (Georg Brandl) Date: Mon, 03 Dec 2007 22:08:34 +0100 Subject: [Python-3000-checkins] r59304 - in python/branches/py3k: Doc/ACKS.txt Doc/c-api/init.rst Doc/c-api/utilities.rst Doc/data/refcounts.dat Doc/glossary.rst Doc/library/exceptions.rst Doc/library/random.rst Doc/library/simplexmlrpcserver.rst Doc/library/xmlrpclib.rst Doc/reference/expressions.rst Doc/using/cmdline.rst Doc/whatsnew/2.6.rst Lib/decimal.py Lib/distutils/command/build_ext.py Lib/distutils/cygwinccompiler.py Lib/distutils/msvc9compiler.py Lib/distutils/msvccompiler.py Lib/random.py Lib/runpy.py Lib/test/exception_hierarchy.txt Lib/test/randv2_32.pck Lib/test/randv2_64.pck Lib/test/randv3.pck Lib/test/test_cmd_line_script.py Lib/test/test_frozen.py Lib/test/test_generators.py Lib/test/test_pkg.py Lib/test/test_random.py Lib/test/test_runpy.py Misc/ACKS Modules/_randommodule.c Modules/xxmodule.c Objects/exceptions.c Objects/moduleobject.c Tools/msi/msi.py In-Reply-To: <20071203210204.8939D1E4009@bag.python.org> References: <20071203210204.8939D1E4009@bag.python.org> Message-ID: christian.heimes schrieb: > Modified: python/branches/py3k/Doc/glossary.rst > ============================================================================== > --- python/branches/py3k/Doc/glossary.rst (original) > +++ python/branches/py3k/Doc/glossary.rst Mon Dec 3 22:02:03 2007 > @@ -400,7 +400,7 @@ > :term:`immutable` keys rather than integers. > > slice > - An object usually containing a portion of a :term:`sequence`. A slice is > + A list containing a portion of an indexed list-like object. A slice is > created using the subscript notation, ``[]`` with colons between numbers > when several are given, such as in ``variable_name[1:3:5]``. The bracket > (subscript) notation uses :class:`slice` objects internally. That seems to be an accident. The original is correct. Georg From python-3000-checkins at python.org Mon Dec 3 23:54:21 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Mon, 3 Dec 2007 23:54:21 +0100 (CET) Subject: [Python-3000-checkins] r59311 - in python/branches/py3k: Include/fileobject.h Lib/io.py Lib/test/test_io.py Objects/complexobject.c Objects/fileobject.c Python/import.c Python/pythonrun.c Message-ID: <20071203225421.E4B371E4010@bag.python.org> Author: guido.van.rossum Date: Mon Dec 3 23:54:21 2007 New Revision: 59311 Modified: python/branches/py3k/Include/fileobject.h python/branches/py3k/Lib/io.py python/branches/py3k/Lib/test/test_io.py python/branches/py3k/Objects/complexobject.c python/branches/py3k/Objects/fileobject.c python/branches/py3k/Python/import.c python/branches/py3k/Python/pythonrun.c Log: Add an errors parameter to open() and TextIOWrapper() to specify error handling. Modified: python/branches/py3k/Include/fileobject.h ============================================================================== --- python/branches/py3k/Include/fileobject.h (original) +++ python/branches/py3k/Include/fileobject.h Mon Dec 3 23:54:21 2007 @@ -9,7 +9,7 @@ #define PY_STDIOTEXTMODE "b" PyAPI_FUNC(PyObject *) PyFile_FromFd(int, char *, char *, int, char *, char *, - int); + char *, int); PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); Modified: python/branches/py3k/Lib/io.py ============================================================================== --- python/branches/py3k/Lib/io.py (original) +++ python/branches/py3k/Lib/io.py Mon Dec 3 23:54:21 2007 @@ -49,8 +49,8 @@ self.characters_written = characters_written -def open(file, mode="r", buffering=None, encoding=None, newline=None, - closefd=True): +def open(file, mode="r", buffering=None, encoding=None, errors=None, + newline=None, closefd=True): r"""Replacement for the built-in open function. Args: @@ -61,6 +61,7 @@ can be: 0 = unbuffered, 1 = line buffered, larger = fully buffered. encoding: optional string giving the text encoding. + errors: optional string giving the encoding error handling. newline: optional newlines specifier; must be None, '', '\n', '\r' or '\r\n'; all other values are illegal. It controls the handling of line endings. It works as follows: @@ -99,7 +100,7 @@ 'U': universal newline mode (for backwards compatibility) Constraints: - - encoding must not be given when a binary mode is given + - encoding or errors must not be given when a binary mode is given - buffering must not be zero when a text mode is given Returns: @@ -115,6 +116,8 @@ raise TypeError("invalid buffering: %r" % buffering) if encoding is not None and not isinstance(encoding, str): raise TypeError("invalid encoding: %r" % encoding) + if errors is not None and not isinstance(errors, str): + raise TypeError("invalid errors: %r" % errors) modes = set(mode) if modes - set("arwb+tU") or len(mode) > len(modes): raise ValueError("invalid mode: %r" % mode) @@ -136,6 +139,8 @@ raise ValueError("must have exactly one of read/write/append mode") if binary and encoding is not None: raise ValueError("binary mode doesn't take an encoding argument") + if binary and errors is not None: + raise ValueError("binary mode doesn't take an errors argument") if binary and newline is not None: raise ValueError("binary mode doesn't take a newline argument") raw = FileIO(file, @@ -177,7 +182,7 @@ buffer.name = file buffer.mode = mode return buffer - text = TextIOWrapper(buffer, encoding, newline) + text = TextIOWrapper(buffer, encoding, errors, newline) text.name = file text.mode = mode return text @@ -1128,7 +1133,7 @@ _CHUNK_SIZE = 128 - def __init__(self, buffer, encoding=None, newline=None): + def __init__(self, buffer, encoding=None, errors=None, newline=None): if newline not in (None, "", "\n", "\r", "\r\n"): raise ValueError("illegal newline value: %r" % (newline,)) if encoding is None: @@ -1148,8 +1153,15 @@ if not isinstance(encoding, str): raise ValueError("invalid encoding: %r" % encoding) + if errors is None: + errors = "strict" + else: + if not isinstance(errors, str): + raise ValueError("invalid errors: %r" % errors) + self.buffer = buffer self._encoding = encoding + self._errors = errors self._readuniversal = not newline self._readtranslate = newline is None self._readnl = newline @@ -1164,6 +1176,10 @@ def encoding(self): return self._encoding + @property + def errors(self): + return self._errors + # A word about _snapshot. This attribute is either None, or a # tuple (decoder_state, readahead, pending) where decoder_state is # the second (integer) item of the decoder state, readahead is the @@ -1206,7 +1222,7 @@ if haslf and self._writetranslate and self._writenl != "\n": s = s.replace("\n", self._writenl) # XXX What if we were just reading? - b = s.encode(self._encoding) + b = s.encode(self._encoding, self._errors) self.buffer.write(b) if haslf and self.isatty(): self.flush() @@ -1220,7 +1236,7 @@ if make_decoder is None: raise IOError("Can't find an incremental decoder for encoding %s" % self._encoding) - decoder = make_decoder() # XXX: errors + decoder = make_decoder(self._errors) if self._readuniversal: decoder = IncrementalNewlineDecoder(decoder, self._readtranslate) self._decoder = decoder @@ -1447,9 +1463,11 @@ # XXX This is really slow, but fully functional - def __init__(self, initial_value="", encoding="utf-8", newline="\n"): + def __init__(self, initial_value="", encoding="utf-8", + errors="strict", newline="\n"): super(StringIO, self).__init__(BytesIO(), encoding=encoding, + errors=errors, newline=newline) if initial_value: if not isinstance(initial_value, str): @@ -1459,4 +1477,4 @@ def getvalue(self): self.flush() - return self.buffer.getvalue().decode(self._encoding) + return self.buffer.getvalue().decode(self._encoding, self._errors) Modified: python/branches/py3k/Lib/test/test_io.py ============================================================================== --- python/branches/py3k/Lib/test/test_io.py (original) +++ python/branches/py3k/Lib/test/test_io.py Mon Dec 3 23:54:21 2007 @@ -496,6 +496,46 @@ def tearDown(self): test_support.unlink(test_support.TESTFN) + def testEncodingErrorsReading(self): + # (1) default + b = io.BytesIO(b"abc\n\xff\n") + t = io.TextIOWrapper(b, encoding="ascii") + self.assertRaises(UnicodeError, t.read) + # (2) explicit strict + b = io.BytesIO(b"abc\n\xff\n") + t = io.TextIOWrapper(b, encoding="ascii", errors="strict") + self.assertRaises(UnicodeError, t.read) + # (3) ignore + b = io.BytesIO(b"abc\n\xff\n") + t = io.TextIOWrapper(b, encoding="ascii", errors="ignore") + self.assertEquals(t.read(), "abc\n\n") + # (4) replace + b = io.BytesIO(b"abc\n\xff\n") + t = io.TextIOWrapper(b, encoding="ascii", errors="replace") + self.assertEquals(t.read(), "abc\n\ufffd\n") + + def testEncodingErrorsWriting(self): + # (1) default + b = io.BytesIO() + t = io.TextIOWrapper(b, encoding="ascii") + self.assertRaises(UnicodeError, t.write, "\xff") + # (2) explicit strict + b = io.BytesIO() + t = io.TextIOWrapper(b, encoding="ascii", errors="strict") + self.assertRaises(UnicodeError, t.write, "\xff") + # (3) ignore + b = io.BytesIO() + t = io.TextIOWrapper(b, encoding="ascii", errors="ignore") + t.write("abc\xffdef\n") + t.flush() + self.assertEquals(b.getvalue(), b"abcdef\n") + # (4) replace + b = io.BytesIO() + t = io.TextIOWrapper(b, encoding="ascii", errors="replace") + t.write("abc\xffdef\n") + t.flush() + self.assertEquals(b.getvalue(), b"abc?def\n") + def testNewlinesInput(self): testdata = b"AAA\nBBB\nCCC\rDDD\rEEE\r\nFFF\r\nGGG" normalized = testdata.replace(b"\r\n", b"\n").replace(b"\r", b"\n") Modified: python/branches/py3k/Objects/complexobject.c ============================================================================== --- python/branches/py3k/Objects/complexobject.c (original) +++ python/branches/py3k/Objects/complexobject.c Mon Dec 3 23:54:21 2007 @@ -915,6 +915,7 @@ return NULL; } cr.real = PyFloat_AsDouble(tmp); + cr.imag = 0.0; /* Shut up compiler warning */ Py_DECREF(tmp); } if (i == NULL) { Modified: python/branches/py3k/Objects/fileobject.c ============================================================================== --- python/branches/py3k/Objects/fileobject.c (original) +++ python/branches/py3k/Objects/fileobject.c Mon Dec 3 23:54:21 2007 @@ -27,15 +27,16 @@ PyObject * PyFile_FromFd(int fd, char *name, char *mode, int buffering, char *encoding, - char *newline, int closefd) + char *errors, char *newline, int closefd) { PyObject *io, *stream, *nameobj = NULL; io = PyImport_ImportModule("io"); if (io == NULL) return NULL; - stream = PyObject_CallMethod(io, "open", "isissi", fd, mode, - buffering, encoding, newline, closefd); + stream = PyObject_CallMethod(io, "open", "isisssi", fd, mode, + buffering, encoding, errors, + newline, closefd); Py_DECREF(io); if (stream == NULL) return NULL; Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Mon Dec 3 23:54:21 2007 @@ -2602,7 +2602,7 @@ (char*)PyUnicode_GetDefaultEncoding(); } fob = PyFile_FromFd(fd, pathname, fdp->mode, -1, - (char*)encoding, NULL, 1); + (char*)encoding, NULL, NULL, 1); if (fob == NULL) { close(fd); PyMem_FREE(found_encoding); Modified: python/branches/py3k/Python/pythonrun.c ============================================================================== --- python/branches/py3k/Python/pythonrun.c (original) +++ python/branches/py3k/Python/pythonrun.c Mon Dec 3 23:54:21 2007 @@ -770,7 +770,7 @@ #endif } else { - if (!(std = PyFile_FromFd(fd, "", "r", -1, NULL, + if (!(std = PyFile_FromFd(fd, "", "r", -1, NULL, NULL, "\n", 0))) { goto error; } @@ -790,7 +790,7 @@ #endif } else { - if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, + if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, NULL, "\n", 0))) { goto error; } @@ -811,7 +811,7 @@ #endif } else { - if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, + if (!(std = PyFile_FromFd(fd, "", "w", -1, NULL, NULL, "\n", 0))) { goto error; } From python-3000-checkins at python.org Tue Dec 4 02:13:14 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Tue, 4 Dec 2007 02:13:14 +0100 (CET) Subject: [Python-3000-checkins] r59313 - in python/branches/py3k: Doc/whatsnew/2.6.rst Modules/posixmodule.c Message-ID: <20071204011314.CC32A1E4023@bag.python.org> Author: guido.van.rossum Date: Tue Dec 4 02:13:14 2007 New Revision: 59313 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Modules/posixmodule.c Log: Merged revisions 59304-59312 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59306 | andrew.kuchling | 2007-12-03 13:28:41 -0800 (Mon, 03 Dec 2007) | 1 line Grammar fix ........ r59307 | guido.van.rossum | 2007-12-03 14:02:10 -0800 (Mon, 03 Dec 2007) | 2 lines Shut up a compiler warning. ........ r59312 | martin.v.loewis | 2007-12-03 15:09:04 -0800 (Mon, 03 Dec 2007) | 3 lines Forward-port r59310: os.access now returns True on Windows for any existing directory. ........ Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Tue Dec 4 02:13:14 2007 @@ -108,7 +108,7 @@ The previous version, Python 2.5, added the ':keyword:`with`' statement an optional feature, to be enabled by a ``from __future__ -import with_statement`` directive. In 2.6 the statement no longer need to +import with_statement`` directive. In 2.6 the statement no longer needs to be specially enabled; this means that :keyword:`with` is now always a keyword. The rest of this section is a copy of the corresponding section from "What's New in Python 2.5" document; if you read Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Tue Dec 4 02:13:14 2007 @@ -1565,8 +1565,11 @@ /* File does not exist, or cannot read attributes */ return PyBool_FromLong(0); /* Access is possible if either write access wasn't requested, or - the file isn't read-only. */ - return PyBool_FromLong(!(mode & 2) || !(attr & FILE_ATTRIBUTE_READONLY)); + the file isn't read-only, or if it's a directory, as there are + no read-only directories on Windows. */ + return PyBool_FromLong(!(mode & 2) + || !(attr & FILE_ATTRIBUTE_READONLY) + || (attr & FILE_ATTRIBUTE_DIRECTORY)); #else int res; if (!PyArg_ParseTuple(args, "eti:access", From python-3000-checkins at python.org Tue Dec 4 06:51:13 2007 From: python-3000-checkins at python.org (alexandre.vassalotti) Date: Tue, 4 Dec 2007 06:51:13 +0100 (CET) Subject: [Python-3000-checkins] r59314 - in python/branches/py3k: Lib/test/test_bytes.py Objects/bytesobject.c Message-ID: <20071204055113.CF6251E4012@bag.python.org> Author: alexandre.vassalotti Date: Tue Dec 4 06:51:13 2007 New Revision: 59314 Modified: python/branches/py3k/Lib/test/test_bytes.py python/branches/py3k/Objects/bytesobject.c Log: Issue #1283: Allow any iterable of integers to be passed to bytearray.extend(). Modified: python/branches/py3k/Lib/test/test_bytes.py ============================================================================== --- python/branches/py3k/Lib/test/test_bytes.py (original) +++ python/branches/py3k/Lib/test/test_bytes.py Tue Dec 4 06:51:13 2007 @@ -529,6 +529,24 @@ a.extend(a) self.assertEqual(a, orig + orig) self.assertEqual(a[5:], orig) + a = bytearray(b'') + # Test iterators that don't have a __length_hint__ + a.extend(map(int, orig * 25)) + a.extend(int(x) for x in orig * 25) + self.assertEqual(a, orig * 50) + self.assertEqual(a[-5:], orig) + a = bytearray(b'') + a.extend(iter(map(int, orig * 50))) + self.assertEqual(a, orig * 50) + self.assertEqual(a[-5:], orig) + a = bytearray(b'') + a.extend(list(map(int, orig * 50))) + self.assertEqual(a, orig * 50) + self.assertEqual(a[-5:], orig) + a = bytearray(b'') + self.assertRaises(ValueError, a.extend, [0, 1, 2, 256]) + self.assertRaises(ValueError, a.extend, [0, 1, 2, -1]) + self.assertEqual(len(a), 0) def test_remove(self): b = bytearray(b'hello') Modified: python/branches/py3k/Objects/bytesobject.c ============================================================================== --- python/branches/py3k/Objects/bytesobject.c (original) +++ python/branches/py3k/Objects/bytesobject.c Tue Dec 4 06:51:13 2007 @@ -2487,24 +2487,6 @@ return NULL; } -PyDoc_STRVAR(extend__doc__, -"B.extend(iterable int) -> None\n\ -\n\ -Append all the elements from the iterator or sequence to the\n\ -end of B."); -static PyObject * -bytes_extend(PyBytesObject *self, PyObject *arg) -{ - /* XXX(gps): The docstring says any iterable int will do but the - * bytes_setslice code only accepts something supporting PEP 3118. - * A list or tuple of 0 <= int <= 255 is supposed to work. */ - /* bug being tracked on: http://bugs.python.org/issue1283 */ - if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1) - return NULL; - Py_RETURN_NONE; -} - - PyDoc_STRVAR(reverse__doc__, "B.reverse() -> None\n\ \n\ @@ -2591,6 +2573,77 @@ Py_RETURN_NONE; } +PyDoc_STRVAR(extend__doc__, +"B.extend(iterable int) -> None\n\ +\n\ +Append all the elements from the iterator or sequence to the\n\ +end of B."); +static PyObject * +bytes_extend(PyBytesObject *self, PyObject *arg) +{ + PyObject *it, *item, *tmp, *res; + Py_ssize_t buf_size = 0, len = 0; + int value; + char *buf; + + /* bytes_setslice code only accepts something supporting PEP 3118. */ + if (PyObject_CheckBuffer(arg)) { + if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1) + return NULL; + + Py_RETURN_NONE; + } + + it = PyObject_GetIter(arg); + if (it == NULL) + return NULL; + + /* Try to determine the length of the argument. */ + buf_size = _PyObject_LengthHint(arg); + /* The length of the argument is unknown or invalid. */ + if (buf_size < 0) { + if (PyErr_Occurred() + && !PyErr_ExceptionMatches(PyExc_TypeError) + && !PyErr_ExceptionMatches(PyExc_AttributeError)) { + Py_DECREF(it); + return NULL; + } + PyErr_Clear(); + buf_size = 32; /* arbitrary */ + } + + buf = (char *)PyMem_Malloc(buf_size * sizeof(char)); + if (buf == NULL) + return PyErr_NoMemory(); + + while ((item = PyIter_Next(it)) != NULL) { + if (! _getbytevalue(item, &value)) { + Py_DECREF(item); + Py_DECREF(it); + return NULL; + } + buf[len++] = value; + Py_DECREF(item); + if (len >= buf_size) { + buf_size = len + (len >> 1) + 1; + buf = (char *)PyMem_Realloc(buf, buf_size * sizeof(char)); + if (buf == NULL) { + Py_DECREF(it); + return PyErr_NoMemory(); + } + } + } + Py_DECREF(it); + + /* XXX: Is possible to avoid a full copy of the buffer? */ + tmp = PyBytes_FromStringAndSize(buf, len); + res = bytes_extend(self, tmp); + Py_DECREF(tmp); + PyMem_Free(buf); + + return res; +} + PyDoc_STRVAR(pop__doc__, "B.pop([index]) -> int\n\ \n\ From python-3000-checkins at python.org Tue Dec 4 06:56:12 2007 From: python-3000-checkins at python.org (alexandre.vassalotti) Date: Tue, 4 Dec 2007 06:56:12 +0100 (CET) Subject: [Python-3000-checkins] r59315 - python/branches/py3k/Objects/bytesobject.c Message-ID: <20071204055612.05D0F1E4012@bag.python.org> Author: alexandre.vassalotti Date: Tue Dec 4 06:56:11 2007 New Revision: 59315 Modified: python/branches/py3k/Objects/bytesobject.c Log: Remove a few tab characters introduced by r59314. Modified: python/branches/py3k/Objects/bytesobject.c ============================================================================== --- python/branches/py3k/Objects/bytesobject.c (original) +++ python/branches/py3k/Objects/bytesobject.c Tue Dec 4 06:56:11 2007 @@ -2602,12 +2602,12 @@ buf_size = _PyObject_LengthHint(arg); /* The length of the argument is unknown or invalid. */ if (buf_size < 0) { - if (PyErr_Occurred() + if (PyErr_Occurred() && !PyErr_ExceptionMatches(PyExc_TypeError) && !PyErr_ExceptionMatches(PyExc_AttributeError)) { Py_DECREF(it); - return NULL; - } + return NULL; + } PyErr_Clear(); buf_size = 32; /* arbitrary */ } From python-3000-checkins at python.org Tue Dec 4 07:20:33 2007 From: python-3000-checkins at python.org (alexandre.vassalotti) Date: Tue, 4 Dec 2007 07:20:33 +0100 (CET) Subject: [Python-3000-checkins] r59316 - python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/listobject.c Message-ID: <20071204062033.8E08B1E4011@bag.python.org> Author: alexandre.vassalotti Date: Tue Dec 4 07:20:30 2007 New Revision: 59316 Modified: python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/listobject.c Log: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError. Modified: python/branches/py3k/Objects/abstract.c ============================================================================== --- python/branches/py3k/Objects/abstract.c (original) +++ python/branches/py3k/Objects/abstract.c Tue Dec 4 07:20:30 2007 @@ -1657,8 +1657,9 @@ /* Guess result size and allocate space. */ n = _PyObject_LengthHint(v); if (n < 0) { - if (!PyErr_ExceptionMatches(PyExc_TypeError) && - !PyErr_ExceptionMatches(PyExc_AttributeError)) { + if (PyErr_Occurred() + && !PyErr_ExceptionMatches(PyExc_TypeError) + && !PyErr_ExceptionMatches(PyExc_AttributeError)) { Py_DECREF(it); return NULL; } Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Tue Dec 4 07:20:30 2007 @@ -760,8 +760,9 @@ /* Guess a result list size. */ n = _PyObject_LengthHint(b); if (n < 0) { - if (!PyErr_ExceptionMatches(PyExc_TypeError) && - !PyErr_ExceptionMatches(PyExc_AttributeError)) { + if (PyErr_Occurred() + && !PyErr_ExceptionMatches(PyExc_TypeError) + && !PyErr_ExceptionMatches(PyExc_AttributeError)) { Py_DECREF(it); return NULL; } From python-3000-checkins at python.org Tue Dec 4 13:22:52 2007 From: python-3000-checkins at python.org (nick.coghlan) Date: Tue, 4 Dec 2007 13:22:52 +0100 (CET) Subject: [Python-3000-checkins] r59319 - python/branches/py3k/Python/import.c Message-ID: <20071204122252.AC4491E4015@bag.python.org> Author: nick.coghlan Date: Tue Dec 4 13:22:52 2007 New Revision: 59319 Modified: python/branches/py3k/Python/import.c Log: Manual merge of PEP 366 implementation from trunk (the automatic merge choked on the PyString->PyUnicode changes) Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Tue Dec 4 13:22:52 2007 @@ -2016,7 +2016,8 @@ { static PyObject *namestr = NULL; static PyObject *pathstr = NULL; - PyObject *modname, *modpath, *modules, *parent; + static PyObject *pkgstr = NULL; + PyObject *pkgname, *modname, *modpath, *modules, *parent; if (globals == NULL || !PyDict_Check(globals) || !level) return Py_None; @@ -2031,44 +2032,103 @@ if (pathstr == NULL) return NULL; } + if (pkgstr == NULL) { + pkgstr = PyUnicode_InternFromString("__package__"); + if (pkgstr == NULL) + return NULL; + } *buf = '\0'; *p_buflen = 0; - modname = PyDict_GetItem(globals, namestr); - if (modname == NULL || !PyUnicode_Check(modname)) - return Py_None; + pkgname = PyDict_GetItem(globals, pkgstr); - modpath = PyDict_GetItem(globals, pathstr); - if (modpath != NULL) { - Py_ssize_t len = PyUnicode_GET_SIZE(modname); - if (len > MAXPATHLEN) { + if ((pkgname != NULL) && (pkgname != Py_None)) { + /* __package__ is set, so use it */ + Py_ssize_t len; + if (!PyUnicode_Check(pkgname)) { PyErr_SetString(PyExc_ValueError, - "Module name too long"); + "__package__ set to non-string"); return NULL; } - strcpy(buf, PyUnicode_AsString(modname)); - } - else { - char *start = PyUnicode_AsString(modname); - char *lastdot = strrchr(start, '.'); - size_t len; - if (lastdot == NULL && level > 0) { + len = PyUnicode_GET_SIZE(pkgname); + if (len == 0) { + if (level > 0) { + PyErr_SetString(PyExc_ValueError, + "Attempted relative import in non-package"); + return NULL; + } + return Py_None; + } + if (len > MAXPATHLEN) { PyErr_SetString(PyExc_ValueError, - "Attempted relative import in non-package"); + "Package name too long"); return NULL; } - if (lastdot == NULL) + strcpy(buf, PyUnicode_AsString(pkgname)); + } else { + /* __package__ not set, so figure it out and set it */ + modname = PyDict_GetItem(globals, namestr); + if (modname == NULL || !PyUnicode_Check(modname)) return Py_None; - len = lastdot - start; - if (len >= MAXPATHLEN) { - PyErr_SetString(PyExc_ValueError, - "Module name too long"); - return NULL; + + modpath = PyDict_GetItem(globals, pathstr); + if (modpath != NULL) { + /* __path__ is set, so modname is already the package name */ + Py_ssize_t len = PyUnicode_GET_SIZE(modname); + int error; + if (len > MAXPATHLEN) { + PyErr_SetString(PyExc_ValueError, + "Module name too long"); + return NULL; + } + strcpy(buf, PyUnicode_AsString(modname)); + error = PyDict_SetItem(globals, pkgstr, modname); + if (error) { + PyErr_SetString(PyExc_ValueError, + "Could not set __package__"); + return NULL; + } + } else { + /* Normal module, so work out the package name if any */ + char *start = PyUnicode_AsString(modname); + char *lastdot = strrchr(start, '.'); + size_t len; + int error; + if (lastdot == NULL && level > 0) { + PyErr_SetString(PyExc_ValueError, + "Attempted relative import in non-package"); + return NULL; + } + if (lastdot == NULL) { + error = PyDict_SetItem(globals, pkgstr, Py_None); + if (error) { + PyErr_SetString(PyExc_ValueError, + "Could not set __package__"); + return NULL; + } + return Py_None; + } + len = lastdot - start; + if (len >= MAXPATHLEN) { + PyErr_SetString(PyExc_ValueError, + "Module name too long"); + return NULL; + } + strncpy(buf, start, len); + buf[len] = '\0'; + pkgname = PyUnicode_FromString(buf); + if (pkgname == NULL) { + return NULL; + } + error = PyDict_SetItem(globals, pkgstr, pkgname); + Py_DECREF(pkgname); + if (error) { + PyErr_SetString(PyExc_ValueError, + "Could not set __package__"); + return NULL; + } } - strncpy(buf, start, len); - buf[len] = '\0'; } - while (--level > 0) { char *dot = strrchr(buf, '.'); if (dot == NULL) { From python-3000-checkins at python.org Tue Dec 4 16:00:34 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 4 Dec 2007 16:00:34 +0100 (CET) Subject: [Python-3000-checkins] r59321 - in python/branches/py3k: Tools/msi/msi.py configure configure.in Message-ID: <20071204150034.170A51E4018@bag.python.org> Author: christian.heimes Date: Tue Dec 4 16:00:33 2007 New Revision: 59321 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Tools/msi/msi.py python/branches/py3k/configure python/branches/py3k/configure.in Log: Merged revisions 59313-59320 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59317 | martin.v.loewis | 2007-12-04 09:37:59 +0100 (Tue, 04 Dec 2007) | 2 lines Fix chflags issue on Tru64, from #1490190. ........ r59318 | martin.v.loewis | 2007-12-04 09:39:16 +0100 (Tue, 04 Dec 2007) | 2 lines Move nt.access change into the right section. ........ r59320 | christian.heimes | 2007-12-04 15:57:30 +0100 (Tue, 04 Dec 2007) | 2 lines Added self generated UUID for msvcr90.dll to msi.py Readded a missing line. ........ Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Tue Dec 4 16:00:33 2007 @@ -106,8 +106,9 @@ # from 1 to 2 (due to what I consider a bug in MSI) # Using the same UUID is fine since these files are versioned, # so Installer will always keep the newest version. +# NOTE: All uuids are self generated. msvcr71_uuid = "{8666C8DD-D0B4-4B42-928E-A69E32FA5D4D}" -msvcr90_uuid = "" # XXX +msvcr90_uuid = "{9C28CD84-397C-4045-855C-28B02291A272}" pythondll_uuid = { "24":"{9B81E618-2301-4035-AC77-75D9ABEB7301}", "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}", @@ -824,7 +825,8 @@ dir = _winreg.QueryValueEx(k, "MSMDir")[0] _winreg.CloseKey(k) files = glob.glob1(dir, "*CRT71*") - assert len(files) > 0, (dir, files) + assert len(files) == 1, (dir, files) + file = os.path.join(dir, files[0]) # Extract msvcr71.dll m = msilib.MakeMerge2() m.OpenModule(file, 0) Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Tue Dec 4 16:00:33 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 58817 . +# From configure.in Revision: 59247 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -15441,13 +15441,11 @@ - - -for ac_func in alarm bind_textdomain_codeset chflags chown clock confstr \ +for ac_func in alarm bind_textdomain_codeset chown clock confstr \ ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getspnam getspent getsid getwd \ - kill killpg lchflags lchmod lchown lstat mkfifo mknod mktime \ + kill killpg lchmod lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ putenv readlink realpath \ select setegid seteuid setgid \ @@ -16211,6 +16209,144 @@ fi +# On Tru64, chflags seems to be present, but calling it will +# exit Python +{ echo "$as_me:$LINENO: checking for chflags" >&5 +echo $ECHO_N "checking for chflags... $ECHO_C" >&6; } +if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +int main(int argc, char*argv[]) +{ + if(chflags(argv[0], 0) != 0) + return 1; + return 0; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_CHFLAGS 1 +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + +{ echo "$as_me:$LINENO: checking for lchflags" >&5 +echo $ECHO_N "checking for lchflags... $ECHO_C" >&6; } +if test "$cross_compiling" = yes; then + { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run test program while cross compiling +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#include +int main(int argc, char*argv[]) +{ + if(lchflags(argv[0], 0) != 0) + return 1; + return 0; +} + +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_LCHFLAGS 1 +_ACEOF + + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +{ echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + case $ac_sys_system/$ac_sys_release in Darwin/*) _CUR_CFLAGS="${CFLAGS}" Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Tue Dec 4 16:00:33 2007 @@ -2274,11 +2274,11 @@ AC_MSG_RESULT(MACHDEP_OBJS) # checks for library functions -AC_CHECK_FUNCS(alarm bind_textdomain_codeset chflags chown clock confstr \ +AC_CHECK_FUNCS(alarm bind_textdomain_codeset chown clock confstr \ ctermid execv fchmod fchown fork fpathconf ftime ftruncate \ gai_strerror getgroups getlogin getloadavg getpeername getpgid getpid \ getpriority getpwent getspnam getspent getsid getwd \ - kill killpg lchflags lchmod lchown lstat mkfifo mknod mktime \ + kill killpg lchmod lchown lstat mkfifo mknod mktime \ mremap nice pathconf pause plock poll pthread_init \ putenv readlink realpath \ select setegid seteuid setgid \ @@ -2371,6 +2371,38 @@ AC_CHECK_LIB(resolv, inet_aton) ) +# On Tru64, chflags seems to be present, but calling it will +# exit Python +AC_MSG_CHECKING(for chflags) +AC_TRY_RUN([ +#include +#include +int main(int argc, char*argv[]) +{ + if(chflags(argv[0], 0) != 0) + return 1; + return 0; +} +],AC_DEFINE(HAVE_CHFLAGS, 1, Define to 1 if you have the `chflags' function.) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) +) + +AC_MSG_CHECKING(for lchflags) +AC_TRY_RUN([ +#include +#include +int main(int argc, char*argv[]) +{ + if(lchflags(argv[0], 0) != 0) + return 1; + return 0; +} +],AC_DEFINE(HAVE_LCHFLAGS, 1, Define to 1 if you have the `lchflags' function.) + AC_MSG_RESULT(yes), + AC_MSG_RESULT(no) +) + dnl Check if system zlib has *Copy() functions dnl dnl On MacOSX the linker will search for dylibs on the entire linker path From python-3000-checkins at python.org Tue Dec 4 16:54:13 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 4 Dec 2007 16:54:13 +0100 (CET) Subject: [Python-3000-checkins] r59323 - in python/branches/py3k: Tools/msi/msilib.py Message-ID: <20071204155413.AC1F91E4012@bag.python.org> Author: christian.heimes Date: Tue Dec 4 16:54:13 2007 New Revision: 59323 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Tools/msi/msilib.py Log: Merged revisions 59321-59322 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59322 | christian.heimes | 2007-12-04 16:52:14 +0100 (Tue, 04 Dec 2007) | 1 line Added VS 2005 and VS 2008 to the search path for cabarc.exe ........ Modified: python/branches/py3k/Tools/msi/msilib.py ============================================================================== --- python/branches/py3k/Tools/msi/msilib.py (original) +++ python/branches/py3k/Tools/msi/msilib.py Tue Dec 4 16:54:13 2007 @@ -376,14 +376,19 @@ except OSError: pass for k, v in [(r"Software\Microsoft\VisualStudio\7.1\Setup\VS", "VS7CommonBinDir"), - (r"Software\Microsoft\Win32SDK\Directories", "Install Dir")]: + (r"Software\Microsoft\VisualStudio\8.0\Setup\VS", "VS7CommonBinDir"), + (r"Software\Microsoft\VisualStudio\9.0\Setup\VS", "VS7CommonBinDir"), + (r"Software\Microsoft\Win32SDK\Directories", "Install Dir"), + ]: try: key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, k) - except WindowsError: + dir = _winreg.QueryValueEx(key, v)[0] + _winreg.CloseKey(key) + except (WindowsError, IndexError): + continue + cabarc = os.path.join(dir, r"Bin", "cabarc.exe") + if not os.path.exists(cabarc): continue - cabarc = os.path.join(_winreg.QueryValueEx(key, v)[0], r"Bin", "cabarc.exe") - _winreg.CloseKey(key) - if not os.path.exists(cabarc):continue break else: print("WARNING: cabarc.exe not found in registry") From python-3000-checkins at python.org Tue Dec 4 19:11:03 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Tue, 4 Dec 2007 19:11:03 +0100 (CET) Subject: [Python-3000-checkins] r59330 - in python/branches/py3k/Doc: reference/simple_stmts.rst tutorial/classes.rst Message-ID: <20071204181103.696171E4016@bag.python.org> Author: georg.brandl Date: Tue Dec 4 19:11:03 2007 New Revision: 59330 Modified: python/branches/py3k/Doc/reference/simple_stmts.rst python/branches/py3k/Doc/tutorial/classes.rst Log: Document nonlocal statement. Written for GHOP by "Canadabear". Modified: python/branches/py3k/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/simple_stmts.rst (original) +++ python/branches/py3k/Doc/reference/simple_stmts.rst Tue Dec 4 19:11:03 2007 @@ -765,12 +765,42 @@ .. productionlist:: nonlocal_stmt: "nonlocal" `identifier` ("," `identifier`)* -XXX: To be documented. +.. XXX add when implemented + : ["=" (`target_list` "=")+ `expression_list`] + : | "nonlocal" `identifier` `augop` `expression_list` + +The :keyword:`nonlocal` statement causes the listed identifiers to refer to +previously bound variables in the nearest enclosing scope. This is important +because the default behavior for binding is to search the local namespace +first. The statement allows encapsulated code to rebind variables outside of +the local scope besides the global (module) scope. + +.. note:: + + The outer scope for :keyword:`nonlocal` statements cannot be the module + scope. + +.. XXX not implemented + The :keyword:`nonlocal` statement may prepend an assignment or augmented + assignment, but not an expression. + +Names listed in a :keyword:`nonlocal` statement, unlike to those listed in a +:keyword:`global` statement, must refer to pre-existing bindings in an +enclosing scope (the scope in which a new binding should be created cannot +be determined unambiguously). + +Names listed in a :keyword:`nonlocal` statement must not collide with +pre-existing bindings in the local scope. + +.. seealso:: + + :pep:`3104` - Access to Names in Outer Scopes + The specification for the :keyword:`nonlocal` statement. .. rubric:: Footnotes .. [#] It may occur within an :keyword:`except` or :keyword:`else` clause. The - restriction on occurring in the :keyword:`try` clause is implementor's laziness - and will eventually be lifted. + restriction on occurring in the :keyword:`try` clause is implementor's + laziness and will eventually be lifted. Modified: python/branches/py3k/Doc/tutorial/classes.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/classes.rst (original) +++ python/branches/py3k/Doc/tutorial/classes.rst Tue Dec 4 19:11:03 2007 @@ -137,14 +137,62 @@ time, so don't rely on dynamic name resolution! (In fact, local variables are already determined statically.) -A special quirk of Python is that assignments always go into the innermost +A special quirk of Python is that assignments normally go into the innermost scope. Assignments do not copy data --- they just bind names to objects. The same is true for deletions: the statement ``del x`` removes the binding of ``x`` from the namespace referenced by the local scope. In fact, all operations that introduce new names use the local scope: in particular, import statements and -function definitions bind the module or function name in the local scope. (The -:keyword:`global` statement can be used to indicate that particular variables -live in the global scope.) +function definitions bind the module or function name in the local scope. + +The :keyword:`global` statement can be used to indicate that particular +variables live in the global scope and should be rebound there; the +:keyword:`nonlocal` statement indicates that particular variables live in +an enclosing scope and should be rebound there. + +.. _tut-scopeexample: + +Scopes and Namespaces Example +----------------------------- + +This is an example demonstrating how to reference the different scopes and +namespaces, and how :keyword:`global` and :keyword:`nonlocal` affect variable +binding:: + + def scope_test(): + def do_local(): + spam = "local spam" + def do_nonlocal(): + nonlocal spam + spam = "nonlocal spam" + def do_global(): + global spam + spam = "global spam" + + spam = "test spam" + do_local() + print("After local assignment:", spam) + do_nonlocal() + print("After nonlocal assignment:", spam) + do_global() + print("After global assignment:", spam) + + scope_test() + print("In global scope:", spam) + +The output of the example code is:: + + After local assignment: test spam + After nonlocal assignment: nonlocal spam + After global assignment: nonlocal spam + In global scope: global spam + +Note how the *local* assignment (which is default) didn't change *scope_test*\'s +binding of *spam*. The :keyword:`nonlocal` assignment changed *scope_test*\'s +binding of *spam*, and the :keyword:`global` assignment changed the module-level +binding. + +You can also see that there was no previous binding for *spam* before the +:keyword:`global` assignment. .. _tut-firstclasses: From python-3000-checkins at python.org Tue Dec 4 19:42:04 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 4 Dec 2007 19:42:04 +0100 (CET) Subject: [Python-3000-checkins] r59331 - python/branches/py3k/PCbuild9/pginstrument.vsprops Message-ID: <20071204184204.CF66A1E4025@bag.python.org> Author: christian.heimes Date: Tue Dec 4 19:42:04 2007 New Revision: 59331 Modified: python/branches/py3k/PCbuild9/pginstrument.vsprops Log: These optimizations create smaller and a bit faster code on my machine. I've also disabled an optimization that may be dangerous. Intrinsic functions conflict with errno. Modified: python/branches/py3k/PCbuild9/pginstrument.vsprops ============================================================================== --- python/branches/py3k/PCbuild9/pginstrument.vsprops (original) +++ python/branches/py3k/PCbuild9/pginstrument.vsprops Tue Dec 4 19:42:04 2007 @@ -8,10 +8,10 @@ > Author: christian.heimes Date: Tue Dec 4 20:30:01 2007 New Revision: 59333 Added: python/branches/py3k/Doc/using/unix.rst - copied unchanged from r59332, python/trunk/Doc/using/unix.rst Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Doc/using/index.rst python/branches/py3k/Doc/using/windows.rst python/branches/py3k/Lib/decimal.py Log: Merged revisions 59323-59332 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59324 | georg.brandl | 2007-12-04 17:10:02 +0100 (Tue, 04 Dec 2007) | 3 lines Add "Python on Unix" document, mostly written for GHOP by Shriphani Palakodety. ........ r59325 | facundo.batista | 2007-12-04 17:31:53 +0100 (Tue, 04 Dec 2007) | 3 lines fma speedup by avoiding to create a Context. Thanks Mark Dickinson. ........ r59326 | christian.heimes | 2007-12-04 17:36:20 +0100 (Tue, 04 Dec 2007) | 2 lines Added warning that make install may overwrite or masquerade the default python binary. Use make altinstall instead. A native English speaker may want to rephrase the paragraph. ;) ........ r59327 | georg.brandl | 2007-12-04 17:50:28 +0100 (Tue, 04 Dec 2007) | 2 lines Fix duplicate label and a typo. ........ r59329 | georg.brandl | 2007-12-04 18:46:27 +0100 (Tue, 04 Dec 2007) | 2 lines Add tutorial and examples to logging docs, from GHOP student "oscar8thegrouch". ........ r59332 | christian.heimes | 2007-12-04 19:43:19 +0100 (Tue, 04 Dec 2007) | 1 line These optimizations create smaller and a bit faster code on my machine. I've also disabled an optimization that may be dangerous. Intrinsic functions conflict with errno. ........ Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Tue Dec 4 20:30:01 2007 @@ -9,10 +9,6 @@ .. sectionauthor:: Vinay Sajip -.. % These apply to all modules, and may be given more than once: - - - .. index:: pair: Errors; logging This module defines functions and classes which implement a flexible error @@ -34,6 +30,400 @@ constrained to use these levels: you can specify your own and use a more general :class:`Logger` method, :meth:`log`, which takes an explicit level argument. + +Logging tutorial +---------------- + +The key benefit of having the logging API provided by a standard library module +is that all Python modules can participate in logging, so your application log +can include messages from third-party modules. + +It is, of course, possible to log messages with different verbosity levels or to +different destinations. Support for writing log messages to files, HTTP +GET/POST locations, email via SMTP, generic sockets, or OS-specific logging +mechnisms are all supported by the standard module. You can also create your +own log destination class if you have special requirements not met by any of the +built-in classes. + +Simple examples +^^^^^^^^^^^^^^^ + +.. sectionauthor:: Doug Hellmann +.. (see ) + +Most applications are probably going to want to log to a file, so let's start +with that case. Using the :func:`basicConfig` function, we can set up the +default handler so that debug messages are written to a file:: + + import logging + LOG_FILENAME = '/tmp/logging_example.out' + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,) + + logging.debug('This message should go to the log file') + +And now if we open the file and look at what we have, we should find the log +message:: + + DEBUG:root:This message should go to the log file + +If you run the script repeatedly, the additional log messages are appended to +the file. To create a new file each time, you can pass a filemode argument to +:func:`basicConfig` with a value of ``'w'``. Rather than managing the file size +yourself, though, it is simpler to use a :class:`RotatingFileHandler`:: + + import glob + import logging + import logging.handlers + + LOG_FILENAME = '/tmp/logging_rotatingfile_example.out' + + # Set up a specific logger with our desired output level + my_logger = logging.getLogger('MyLogger') + my_logger.setLevel(logging.DEBUG) + + # Add the log message handler to the logger + handler = logging.handlers.RotatingFileHandler( + LOG_FILENAME, maxBytes=20, backupCount=5) + + my_logger.addHandler(handler) + + # Log some messages + for i in range(20): + my_logger.debug('i = %d' % i) + + # See what files are created + logfiles = glob.glob('%s*' % LOG_FILENAME) + + for filename in logfiles: + print filename + +The result should be 6 separate files, each with part of the log history for the +application:: + + /tmp/logging_rotatingfile_example.out + /tmp/logging_rotatingfile_example.out.1 + /tmp/logging_rotatingfile_example.out.2 + /tmp/logging_rotatingfile_example.out.3 + /tmp/logging_rotatingfile_example.out.4 + /tmp/logging_rotatingfile_example.out.5 + +The most current file is always :file:`/tmp/logging_rotatingfile_example.out`, +and each time it reaches the size limit it is renamed with the suffix +``.1``. Each of the existing backup files is renamed to increment the suffix +(``.1`` becomes ``.2``, etc.) and the ``.5`` file is erased. + +Obviously this example sets the log length much much too small as an extreme +example. You would want to set *maxBytes* to an appropriate value. + +Another useful feature of the logging API is the ability to produce different +messages at different log levels. This allows you to instrument your code with +debug messages, for example, but turning the log level down so that those debug +messages are not written for your production system. The default levels are +``CRITICAL``, ``ERROR``, ``WARNING``, ``INFO``, ``DEBUG`` and ``UNSET``. + +The logger, handler, and log message call each specify a level. The log message +is only emitted if the handler and logger are configured to emit messages of +that level or lower. For example, if a message is ``CRITICAL``, and the logger +is set to ``ERROR``, the message is emitted. If a message is a ``WARNING``, and +the logger is set to produce only ``ERROR``\s, the message is not emitted:: + + import logging + import sys + + LEVELS = {'debug': logging.DEBUG, + 'info': logging.INFO, + 'warning': logging.WARNING, + 'error': logging.ERROR, + 'critical': logging.CRITICAL} + + if len(sys.argv) > 1: + level_name = sys.argv[1] + level = LEVELS.get(level_name, logging.NOTSET) + logging.basicConfig(level=level) + + logging.debug('This is a debug message') + logging.info('This is an info message') + logging.warning('This is a warning message') + logging.error('This is an error message') + logging.critical('This is a critical error message') + +Run the script with an argument like 'debug' or 'warning' to see which messages +show up at different levels:: + + $ python logging_level_example.py debug + DEBUG:root:This is a debug message + INFO:root:This is an info message + WARNING:root:This is a warning message + ERROR:root:This is an error message + CRITICAL:root:This is a critical error message + + $ python logging_level_example.py info + INFO:root:This is an info message + WARNING:root:This is a warning message + ERROR:root:This is an error message + CRITICAL:root:This is a critical error message + +You will notice that these log messages all have ``root`` embedded in them. The +logging module supports a hierarchy of loggers with different names. An easy +way to tell where a specific log message comes from is to use a separate logger +object for each of your modules. Each new logger "inherits" the configuration +of its parent, and log messages sent to a logger include the name of that +logger. Optionally, each logger can be configured differently, so that messages +from different modules are handled in different ways. Let's look at a simple +example of how to log from different modules so it is easy to trace the source +of the message:: + + import logging + + logging.basicConfig(level=logging.WARNING) + + logger1 = logging.getLogger('package1.module1') + logger2 = logging.getLogger('package2.module2') + + logger1.warning('This message comes from one module') + logger2.warning('And this message comes from another module') + +And the output:: + + $ python logging_modules_example.py + WARNING:package1.module1:This message comes from one module + WARNING:package2.module2:And this message comes from another module + +There are many more options for configuring logging, including different log +message formatting options, having messages delivered to multiple destinations, +and changing the configuration of a long-running application on the fly using a +socket interface. All of these options are covered in depth in the library +module documentation. + +Loggers +^^^^^^^ + +The logging library takes a modular approach and offers the several categories +of components: loggers, handlers, filters, and formatters. Loggers expose the +interface that application code directly uses. Handlers send the log records to +the appropriate destination. Filters provide a finer grained facility for +determining which log records to send on to a handler. Formatters specify the +layout of the resultant log record. + +:class:`Logger` objects have a threefold job. First, they expose several +methods to application code so that applications can log messages at runtime. +Second, logger objects determine which log messages to act upon based upon +severity (the default filtering facility) or filter objects. Third, logger +objects pass along relevant log messages to all interested log handlers. + +The most widely used methods on logger objects fall into two categories: +configuration and message sending. + +* :meth:`Logger.setLevel` specifies the lowest-severity log message a logger + will handle, where debug is the lowest built-in severity level and critical is + the highest built-in severity. For example, if the severity level is info, + the logger will handle only info, warning, error, and critical messages and + will ignore debug messages. + +* :meth:`Logger.addFilter` and :meth:`Logger.removeFilter` add and remove filter + objects from the logger object. This tutorial does not address filters. + +With the logger object configured, the following methods create log messages: + +* :meth:`Logger.debug`, :meth:`Logger.info`, :meth:`Logger.warning`, + :meth:`Logger.error`, and :meth:`Logger.critical` all create log records with + a message and a level that corresponds to their respective method names. The + message is actually a format string, which may contain the standard string + substitution syntax of :const:`%s`, :const:`%d`, :const:`%f`, and so on. The + rest of their arguments is a list of objects that correspond with the + substitution fields in the message. With regard to :const:`**kwargs`, the + logging methods care only about a keyword of :const:`exc_info` and use it to + determine whether to log exception information. + +* :meth:`Logger.exception` creates a log message similar to + :meth:`Logger.error`. The difference is that :meth:`Logger.exception` dumps a + stack trace along with it. Call this method only from an exception handler. + +* :meth:`Logger.log` takes a log level as an explicit argument. This is a + little more verbose for logging messages than using the log level convenience + methods listed above, but this is how to log at custom log levels. + +:func:`getLogger` returns a reference to a logger instance with a name of name +if a name is provided, or root if not. The names are period-separated +hierarchical structures. Multiple calls to :func:`getLogger` with the same name +will return a reference to the same logger object. Loggers that are further +down in the hierarchical list are children of loggers higher up in the list. +For example, given a logger with a name of ``foo``, loggers with names of +``foo.bar``, ``foo.bar.baz``, and ``foo.bam`` are all children of ``foo``. +Child loggers propagate messages up to their parent loggers. Because of this, +it is unnecessary to define and configure all the loggers an application uses. +It is sufficient to configure a top-level logger and create child loggers as +needed. + + +Handlers +^^^^^^^^ + +:class:`Handler` objects are responsible for dispatching the appropriate log +messages (based on the log messages' severity) to the handler's specified +destination. Logger objects can add zero or more handler objects to themselves +with an :func:`addHandler` method. As an example scenario, an application may +want to send all log messages to a log file, all log messages of error or higher +to stdout, and all messages of critical to an email address. This scenario +requires three individual handlers where each hander is responsible for sending +messages of a specific severity to a specific location. + +The standard library includes quite a few handler types; this tutorial uses only +:class:`StreamHandler` and :class:`FileHandler` in its examples. + +There are very few methods in a handler for application developers to concern +themselves with. The only handler methods that seem relevant for application +developers who are using the built-in handler objects (that is, not creating +custom handlers) are the following configuration methods: + +* The :meth:`Handler.setLevel` method, just as in logger objects, specifies the + lowest severity that will be dispatched to the appropriate destination. Why + are there two :func:`setLevel` methods? The level set in the logger + determines which severity of messages it will pass to its handlers. The level + set in each handler determines which messages that handler will send on. + :func:`setFormatter` selects a Formatter object for this handler to use. + +* :func:`addFilter` and :func:`removeFilter` respectively configure and + deconfigure filter objects on handlers. + +Application code should not directly instantiate and use handlers. Instead, the +:class:`Handler` class is a base class that defines the interface that all +Handlers should have and establishes some default behavior that child classes +can use (or override). + + +Formatters +^^^^^^^^^^ + +Formatter objects configure the final order, structure, and contents of the log +message. Unlike the base logging.Handler class, application code may +instantiate formatter classes, although you could likely subclass the formatter +if your application needs special behavior. The constructor takes two optional +arguments: a message format string and a date format string. If there is no +message format string, the default is to use the raw message. If there is no +date format string, the default date format is:: + + %Y-%m-%d %H:%M:%S + +with the milliseconds tacked on at the end. + +The message format string uses ``%()s`` styled string +substitution; the possible keys are documented in :ref:`formatter-objects`. + +The following message format string will log the time in a human-readable +format, the severity of the message, and the contents of the message, in that +order:: + + "%(asctime)s - %(levelname)s - %(message)s" + + +Configuring Logging +^^^^^^^^^^^^^^^^^^^ + +Programmers can configure logging either by creating loggers, handlers, and +formatters explicitly in a main module with the configuration methods listed +above (using Python code), or by creating a logging config file. The following +code is an example of configuring a very simple logger, a console handler, and a +simple formatter in a Python module:: + + import logging + + # create logger + logger = logging.getLogger("simple_example") + logger.setLevel(logging.DEBUG) + # create console handler and set level to debug + ch = logging.StreamHandler() + ch.setLevel(logging.DEBUG) + # create formatter + formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") + # add formatter to ch + ch.setFormatter(formatter) + # add ch to logger + logger.addHandler(ch) + + # "application" code + logger.debug("debug message") + logger.info("info message") + logger.warn("warn message") + logger.error("error message") + logger.critical("critical message") + +Running this module from the command line produces the following output:: + + $ python simple_logging_module.py + 2005-03-19 15:10:26,618 - simple_example - DEBUG - debug message + 2005-03-19 15:10:26,620 - simple_example - INFO - info message + 2005-03-19 15:10:26,695 - simple_example - WARNING - warn message + 2005-03-19 15:10:26,697 - simple_example - ERROR - error message + 2005-03-19 15:10:26,773 - simple_example - CRITICAL - critical message + +The following Python module creates a logger, handler, and formatter nearly +identical to those in the example listed above, with the only difference being +the names of the objects:: + + import logging + import logging.config + + logging.config.fileConfig("logging.conf") + + # create logger + logger = logging.getLogger("simpleExample") + + # "application" code + logger.debug("debug message") + logger.info("info message") + logger.warn("warn message") + logger.error("error message") + logger.critical("critical message") + +Here is the logging.conf file:: + + [loggers] + keys=root,simpleExample + + [handlers] + keys=consoleHandler + + [formatters] + keys=simpleFormatter + + [logger_root] + level=DEBUG + handlers=consoleHandler + + [logger_simpleExample] + level=DEBUG + handlers=consoleHandler + qualname=simpleExample + propagate=0 + + [handler_consoleHandler] + class=StreamHandler + level=DEBUG + formatter=simpleFormatter + args=(sys.stdout,) + + [formatter_simpleFormatter] + format=%(asctime)s - %(name)s - %(levelname)s - %(message)s + datefmt= + +The output is nearly identical to that of the non-config-file-based example:: + + $ python simple_logging_config.py + 2005-03-19 15:38:55,977 - simpleExample - DEBUG - debug message + 2005-03-19 15:38:55,979 - simpleExample - INFO - info message + 2005-03-19 15:38:56,054 - simpleExample - WARNING - warn message + 2005-03-19 15:38:56,055 - simpleExample - ERROR - error message + 2005-03-19 15:38:56,130 - simpleExample - CRITICAL - critical message + +You can see that the config file approach has a few advantages over the Python +code approach, mainly separation of configuration and code and the ability of +noncoders to easily modify the logging properties. + + +Logging Levels +-------------- + The numeric values of logging levels are given in the following table. These are primarily of interest if you want to define your own levels, and need them to have specific values relative to the predefined levels. If you define a level @@ -1446,6 +1836,8 @@ Sends the record to the Web server as an URL-encoded dictionary. +.. _formatter-objects: + Formatter Objects ----------------- @@ -1654,15 +2046,17 @@ sent as a file suitable for processing by :func:`fileConfig`. Returns a :class:`Thread` instance on which you can call :meth:`start` to start the server, and which you can :meth:`join` when appropriate. To stop the server, - call :func:`stopListening`. To send a configuration to the socket, read in the - configuration file and send it to the socket as a string of bytes preceded by a - four-byte length packed in binary using struct.\ ``pack('>L', n)``. + call :func:`stopListening`. + + To send a configuration to the socket, read in the configuration file and + send it to the socket as a string of bytes preceded by a four-byte length + string packed in binary using ``struct.pack('>L', n)``. .. function:: stopListening() - Stops the listening server which was created with a call to :func:`listen`. This - is typically called before calling :meth:`join` on the return value from + Stops the listening server which was created with a call to :func:`listen`. + This is typically called before calling :meth:`join` on the return value from :func:`listen`. @@ -1671,8 +2065,6 @@ Configuration file format ^^^^^^^^^^^^^^^^^^^^^^^^^ -.. % - The configuration file format understood by :func:`fileConfig` is based on ConfigParser functionality. The file must contain sections called ``[loggers]``, ``[handlers]`` and ``[formatters]`` which identify by name the entities of each @@ -1825,3 +2217,194 @@ :class:`Formatter` subclass. Subclasses of :class:`Formatter` can present exception tracebacks in an expanded or condensed format. + +Configuration server example +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Here is an example of a module using the logging configuration server:: + + import logging + import logging.config + import time + import os + + # read initial config file + logging.config.fileConfig("logging.conf") + + # create and start listener on port 9999 + t = logging.config.listen(9999) + t.start() + + logger = logging.getLogger("simpleExample") + + try: + # loop through logging calls to see the difference + # new configurations make, until Ctrl+C is pressed + while True: + logger.debug("debug message") + logger.info("info message") + logger.warn("warn message") + logger.error("error message") + logger.critical("critical message") + time.sleep(5) + except KeyboardInterrupt: + # cleanup + logging.config.stopListening() + t.join() + +And here is a script that takes a filename and sends that file to the server, +properly preceded with the binary-encoded length, as the new logging +configuration:: + + #!/usr/bin/env python + import socket, sys, struct + + data_to_send = open(sys.argv[1], "r").read() + + HOST = 'localhost' + PORT = 9999 + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + print "connecting..." + s.connect((HOST, PORT)) + print "sending config..." + s.send(struct.pack(">L", len(data_to_send))) + s.send(data_to_send) + s.close() + print "complete" + + +More examples +------------- + +Multiple handlers and formatters +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Loggers are plain Python objects. The :func:`addHandler` method has no minimum +or maximum quota for the number of handlers you may add. Sometimes it will be +beneficial for an application to log all messages of all severities to a text +file while simultaneously logging errors or above to the console. To set this +up, simply configure the appropriate handlers. The logging calls in the +application code will remain unchanged. Here is a slight modification to the +previous simple module-based configuration example:: + + import logging + + logger = logging.getLogger("simple_example") + logger.setLevel(logging.DEBUG) + # create file handler which logs even debug messages + fh = logging.FileHandler("spam.log") + fh.setLevel(logging.DEBUG) + # create console handler with a higher log level + ch = logging.StreamHandler() + ch.setLevel(logging.ERROR) + # create formatter and add it to the handlers + formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") + ch.setFormatter(formatter) + fh.setFormatter(formatter) + # add the handlers to logger + logger.addHandler(ch) + logger.addHandler(fh) + + # "application" code + logger.debug("debug message") + logger.info("info message") + logger.warn("warn message") + logger.error("error message") + logger.critical("critical message") + +Notice that the "application" code does not care about multiple handlers. All +that changed was the addition and configuration of a new handler named *fh*. + +The ability to create new handlers with higher- or lower-severity filters can be +very helpful when writing and testing an application. Instead of using many +``print`` statements for debugging, use ``logger.debug``: Unlike the print +statements, which you will have to delete or comment out later, the logger.debug +statements can remain intact in the source code and remain dormant until you +need them again. At that time, the only change that needs to happen is to +modify the severity level of the logger and/or handler to debug. + + +Using logging in multiple modules +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +It was mentioned above that multiple calls to +``logging.getLogger('someLogger')`` return a reference to the same logger +object. This is true not only within the same module, but also across modules +as long as it is in the same Python interpreter process. It is true for +references to the same object; additionally, application code can define and +configure a parent logger in one module and create (but not configure) a child +logger in a separate module, and all logger calls to the child will pass up to +the parent. Here is a main module:: + + import logging + import auxiliary_module + + # create logger with "spam_application" + logger = logging.getLogger("spam_application") + logger.setLevel(logging.DEBUG) + # create file handler which logs even debug messages + fh = logging.FileHandler("spam.log") + fh.setLevel(logging.DEBUG) + # create console handler with a higher log level + ch = logging.StreamHandler() + ch.setLevel(logging.ERROR) + # create formatter and add it to the handlers + formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") + fh.setFormatter(formatter) + ch.setFormatter(formatter) + # add the handlers to the logger + logger.addHandler(fh) + logger.addHandler(ch) + + logger.info("creating an instance of auxiliary_module.Auxiliary") + a = auxiliary_module.Auxiliary() + logger.info("created an instance of auxiliary_module.Auxiliary") + logger.info("calling auxiliary_module.Auxiliary.do_something") + a.do_something() + logger.info("finished auxiliary_module.Auxiliary.do_something") + logger.info("calling auxiliary_module.some_function()") + auxiliary_module.some_function() + logger.info("done with auxiliary_module.some_function()") + +Here is the auxiliary module:: + + import logging + + # create logger + module_logger = logging.getLogger("spam_application.auxiliary") + + class Auxiliary: + def __init__(self): + self.logger = logging.getLogger("spam_application.auxiliary.Auxiliary") + self.logger.info("creating an instance of Auxiliary") + def do_something(self): + self.logger.info("doing something") + a = 1 + 1 + self.logger.info("done doing something") + + def some_function(): + module_logger.info("received a call to \"some_function\"") + +The output looks like this:: + + 2005-03-23 23:47:11,663 - spam_application - INFO - + creating an instance of auxiliary_module.Auxiliary + 2005-03-23 23:47:11,665 - spam_application.auxiliary.Auxiliary - INFO - + creating an instance of Auxiliary + 2005-03-23 23:47:11,665 - spam_application - INFO - + created an instance of auxiliary_module.Auxiliary + 2005-03-23 23:47:11,668 - spam_application - INFO - + calling auxiliary_module.Auxiliary.do_something + 2005-03-23 23:47:11,668 - spam_application.auxiliary.Auxiliary - INFO - + doing something + 2005-03-23 23:47:11,669 - spam_application.auxiliary.Auxiliary - INFO - + done doing something + 2005-03-23 23:47:11,670 - spam_application - INFO - + finished auxiliary_module.Auxiliary.do_something + 2005-03-23 23:47:11,671 - spam_application - INFO - + calling auxiliary_module.some_function() + 2005-03-23 23:47:11,672 - spam_application.auxiliary - INFO - + received a call to "some_function" + 2005-03-23 23:47:11,673 - spam_application - INFO - + done with auxiliary_module.some_function() + Modified: python/branches/py3k/Doc/using/index.rst ============================================================================== --- python/branches/py3k/Doc/using/index.rst (original) +++ python/branches/py3k/Doc/using/index.rst Tue Dec 4 20:30:01 2007 @@ -13,6 +13,7 @@ .. toctree:: cmdline.rst + unix.rst windows.rst mac.rst Modified: python/branches/py3k/Doc/using/windows.rst ============================================================================== --- python/branches/py3k/Doc/using/windows.rst (original) +++ python/branches/py3k/Doc/using/windows.rst Tue Dec 4 20:30:01 2007 @@ -260,8 +260,7 @@ If you want to compile CPython yourself, first thing you should do is get the `source `_. You can download either the latest release's source or just grab a fresh `checkout -`_. +`_. For Microsoft Visual C++, which is the compiler with which official Python releases are built, the source tree contains solutions/project files. View the Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Tue Dec 4 20:30:01 2007 @@ -1646,24 +1646,39 @@ """ other = _convert_other(other, raiseit=True) - third = _convert_other(third, raiseit=True) - - if context is None: - context = getcontext() - # do self*other in fresh context with no traps and no rounding - mul_context = Context(traps=[], flags=[], - _rounding_decision=NEVER_ROUND) - product = self.__mul__(other, mul_context) - - if mul_context.flags[InvalidOperation]: - # reraise in current context - return context._raise_error(InvalidOperation, - 'invalid multiplication in fma', - 1, product) + # compute product; raise InvalidOperation if either operand is + # a signaling NaN or if the product is zero times infinity. + if self._is_special or other._is_special: + if context is None: + context = getcontext() + if self._exp == 'N': + return context._raise_error(InvalidOperation, 'sNaN', + 1, self) + if other._exp == 'N': + return context._raise_error(InvalidOperation, 'sNaN', + 1, other) + if self._exp == 'n': + product = self + elif other._exp == 'n': + product = other + elif self._exp == 'F': + if not other: + return context._raise_error(InvalidOperation, + 'INF * 0 in fma') + product = Infsign[self._sign ^ other._sign] + elif other._exp == 'F': + if not self: + return context._raise_error(InvalidOperation, + '0 * INF in fma') + product = Infsign[self._sign ^ other._sign] + else: + product = _dec_from_triple(self._sign ^ other._sign, + str(int(self._int) * int(other._int)), + self._exp + other._exp) - ans = product.__add__(third, context) - return ans + third = _convert_other(third, raiseit=True) + return product.__add__(third, context) def _power_modulo(self, other, modulo, context=None): """Three argument version of __pow__""" From python-3000-checkins at python.org Tue Dec 4 21:34:13 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Tue, 4 Dec 2007 21:34:13 +0100 (CET) Subject: [Python-3000-checkins] r59334 - python/branches/py3k/Python/ceval.c Message-ID: <20071204203413.571081E4016@bag.python.org> Author: martin.v.loewis Date: Tue Dec 4 21:34:12 2007 New Revision: 59334 Modified: python/branches/py3k/Python/ceval.c Log: Remove special-casing of integer operations, to stop using PyInt_CheckExact. Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Tue Dec 4 21:34:12 2007 @@ -1118,24 +1118,13 @@ case BINARY_ADD: w = POP(); v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int + int */ - register long a, b, i; - a = PyLong_AS_LONG(v); - b = PyLong_AS_LONG(w); - i = a + b; - if ((i^a) < 0 && (i^b) < 0) - goto slow_add; - x = PyLong_FromLong(i); - } - else if (PyUnicode_CheckExact(v) && + if (PyUnicode_CheckExact(v) && PyUnicode_CheckExact(w)) { x = unicode_concatenate(v, w, f, next_instr); /* unicode_concatenate consumed the ref to v */ goto skip_decref_vx; } else { - slow_add: x = PyNumber_Add(v, w); } Py_DECREF(v); @@ -1148,20 +1137,7 @@ case BINARY_SUBTRACT: w = POP(); v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int - int */ - register long a, b, i; - a = PyLong_AS_LONG(v); - b = PyLong_AS_LONG(w); - i = a - b; - if ((i^a) < 0 && (i^~b) < 0) - goto slow_sub; - x = PyLong_FromLong(i); - } - else { - slow_sub: - x = PyNumber_Subtract(v, w); - } + x = PyNumber_Subtract(v, w); Py_DECREF(v); Py_DECREF(w); SET_TOP(x); @@ -1171,21 +1147,7 @@ case BINARY_SUBSCR: w = POP(); v = TOP(); - if (PyList_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: list[int] */ - Py_ssize_t i = PyLong_AsSsize_t(w); - if (i < 0) - i += PyList_GET_SIZE(v); - if (i >= 0 && i < PyList_GET_SIZE(v)) { - x = PyList_GET_ITEM(v, i); - Py_INCREF(x); - } - else - goto slow_get; - } - else - slow_get: - x = PyObject_GetItem(v, w); + x = PyObject_GetItem(v, w); Py_DECREF(v); Py_DECREF(w); SET_TOP(x); @@ -1319,24 +1281,13 @@ case INPLACE_ADD: w = POP(); v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int + int */ - register long a, b, i; - a = PyLong_AS_LONG(v); - b = PyLong_AS_LONG(w); - i = a + b; - if ((i^a) < 0 && (i^b) < 0) - goto slow_iadd; - x = PyLong_FromLong(i); - } - else if (PyUnicode_CheckExact(v) && + if (PyUnicode_CheckExact(v) && PyUnicode_CheckExact(w)) { x = unicode_concatenate(v, w, f, next_instr); /* unicode_concatenate consumed the ref to v */ goto skip_decref_v; } else { - slow_iadd: x = PyNumber_InPlaceAdd(v, w); } Py_DECREF(v); @@ -1349,20 +1300,7 @@ case INPLACE_SUBTRACT: w = POP(); v = TOP(); - if (PyInt_CheckExact(v) && PyInt_CheckExact(w)) { - /* INLINE: int - int */ - register long a, b, i; - a = PyLong_AS_LONG(v); - b = PyLong_AS_LONG(w); - i = a - b; - if ((i^a) < 0 && (i^~b) < 0) - goto slow_isub; - x = PyLong_FromLong(i); - } - else { - slow_isub: - x = PyNumber_InPlaceSubtract(v, w); - } + x = PyNumber_InPlaceSubtract(v, w); Py_DECREF(v); Py_DECREF(w); SET_TOP(x); @@ -1865,30 +1803,7 @@ case COMPARE_OP: w = POP(); v = TOP(); - if (PyInt_CheckExact(w) && PyInt_CheckExact(v)) { - /* INLINE: cmp(int, int) */ - register long a, b; - register int res; - a = PyLong_AS_LONG(v); - b = PyLong_AS_LONG(w); - switch (oparg) { - case PyCmp_LT: res = a < b; break; - case PyCmp_LE: res = a <= b; break; - case PyCmp_EQ: res = a == b; break; - case PyCmp_NE: res = a != b; break; - case PyCmp_GT: res = a > b; break; - case PyCmp_GE: res = a >= b; break; - case PyCmp_IS: res = v == w; break; - case PyCmp_IS_NOT: res = v != w; break; - default: goto slow_compare; - } - x = res ? Py_True : Py_False; - Py_INCREF(x); - } - else { - slow_compare: - x = cmp_outcome(oparg, v, w); - } + x = cmp_outcome(oparg, v, w); Py_DECREF(v); Py_DECREF(w); SET_TOP(x); From python-3000-checkins at python.org Tue Dec 4 22:55:19 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 4 Dec 2007 22:55:19 +0100 (CET) Subject: [Python-3000-checkins] r59335 - python/branches/py3k/Python/traceback.c Message-ID: <20071204215519.03FD91E4016@bag.python.org> Author: christian.heimes Date: Tue Dec 4 22:55:18 2007 New Revision: 59335 Modified: python/branches/py3k/Python/traceback.c Log: Removed another occurrence of PyInt_ExactCheck() I've modified the semantic of PyTraceBack_Print and sys.tracebacklimit slightly. Overfloats or values <= 0 are replaced with a default value to avoid infinite recursion and other issues. Modified: python/branches/py3k/Python/traceback.c ============================================================================== --- python/branches/py3k/Python/traceback.c (original) +++ python/branches/py3k/Python/traceback.c Tue Dec 4 22:55:18 2007 @@ -242,12 +242,15 @@ return err; } +#define PyTraceBack_LIMIT 1000 + int PyTraceBack_Print(PyObject *v, PyObject *f) { int err; PyObject *limitv; - int limit = 1000; + int limit = PyTraceBack_LIMIT; + if (v == NULL) return 0; if (!PyTraceBack_Check(v)) { @@ -255,10 +258,26 @@ return -1; } limitv = PySys_GetObject("tracebacklimit"); - if (limitv && PyInt_CheckExact(limitv)) { + if (limitv) { + PyObject *exc_type, *exc_value, *exc_tb; + + PyErr_Fetch(&exc_type, &exc_value, &exc_tb); limit = PyLong_AsLong(limitv); - if (limit <= 0) - return 0; + if (limit == -1 && PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_OverflowError)) { + limit = PyTraceBack_LIMIT; + } + else { + Py_XDECREF(exc_type); + Py_XDECREF(exc_value); + Py_XDECREF(exc_tb); + return 0; + } + } + else if (limit <= 0) { + limit = PyTraceBack_LIMIT; + } + PyErr_Restore(exc_type, exc_value, exc_tb); } err = PyFile_WriteString("Traceback (most recent call last):\n", f); if (!err) From python-3000-checkins at python.org Tue Dec 4 23:10:38 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Tue, 4 Dec 2007 23:10:38 +0100 (CET) Subject: [Python-3000-checkins] r59336 - in python/branches/py3k: Doc/c-api/concrete.rst Include/longobject.h Modules/_csv.c Modules/_cursesmodule.c Modules/_tkinter.c Modules/datetimemodule.c Modules/socketmodule.c Modules/timemodule.c Objects/exceptions.c Objects/frameobject.c Objects/listobject.c Objects/longobject.c PC/_msi.c Python/bltinmodule.c Python/ceval.c Message-ID: <20071204221038.06AFC1E4016@bag.python.org> Author: martin.v.loewis Date: Tue Dec 4 23:10:37 2007 New Revision: 59336 Modified: python/branches/py3k/Doc/c-api/concrete.rst python/branches/py3k/Include/longobject.h python/branches/py3k/Modules/_csv.c python/branches/py3k/Modules/_cursesmodule.c python/branches/py3k/Modules/_tkinter.c python/branches/py3k/Modules/datetimemodule.c python/branches/py3k/Modules/socketmodule.c python/branches/py3k/Modules/timemodule.c python/branches/py3k/Objects/exceptions.c python/branches/py3k/Objects/frameobject.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Objects/longobject.c python/branches/py3k/PC/_msi.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/ceval.c Log: Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow. Modified: python/branches/py3k/Doc/c-api/concrete.rst ============================================================================== --- python/branches/py3k/Doc/c-api/concrete.rst (original) +++ python/branches/py3k/Doc/c-api/concrete.rst Tue Dec 4 23:10:37 2007 @@ -211,10 +211,6 @@ :ctype:`PyLongObject`. -.. XXX cfunction PyInt_CheckExact(PyObject *p) checks if argument is a long - object and fits into a C long - - .. cfunction:: PyObject* PyLong_FromLong(long v) Return a new :ctype:`PyLongObject` object from *v*, or *NULL* on failure. @@ -297,7 +293,16 @@ single: OverflowError (built-in exception) Return a C :ctype:`long` representation of the contents of *pylong*. If - *pylong* is greater than :const:`LONG_MAX`, an :exc:`OverflowError` is raised. + *pylong* is greater than :const:`LONG_MAX`, raise an :exc:`OverflowError`, + and return -1. Convert non-long objects automatically to long first, + and return -1 if that raises exceptions. + +.. cfunction:: long PyLong_AsLongAndOverflow(PyObject *pylong, int* overflow) + + Return a C :ctype:`long` representation of the contents of *pylong*. If + *pylong* is greater than :const:`LONG_MAX`, return -1 and + set `*overflow` to 1 (for overflow) or -1 (for underflow). + If an exception is set because of type errors, also return -1. .. cfunction:: unsigned long PyLong_AsUnsignedLong(PyObject *pylong) Modified: python/branches/py3k/Include/longobject.h ============================================================================== --- python/branches/py3k/Include/longobject.h (original) +++ python/branches/py3k/Include/longobject.h Tue Dec 4 23:10:37 2007 @@ -14,7 +14,6 @@ #define PyLong_Check(op) \ PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LONG_SUBCLASS) #define PyLong_CheckExact(op) (Py_Type(op) == &PyLong_Type) -#define PyInt_CheckExact(op) (PyLong_CheckExact(op) && _PyLong_FitsInLong(op)) PyAPI_FUNC(PyObject *) PyLong_FromLong(long); PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); @@ -22,6 +21,7 @@ PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); PyAPI_FUNC(long) PyLong_AsLong(PyObject *); +PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); Modified: python/branches/py3k/Modules/_csv.c ============================================================================== --- python/branches/py3k/Modules/_csv.c (original) +++ python/branches/py3k/Modules/_csv.c Tue Dec 4 23:10:37 2007 @@ -181,12 +181,23 @@ if (src == NULL) *target = dflt; else { - if (!PyInt_CheckExact(src)) { + long value; + if (!PyLong_CheckExact(src)) { PyErr_Format(PyExc_TypeError, "\"%s\" must be an integer", name); return -1; } - *target = PyLong_AsLong(src); + value = PyLong_AsLong(src); + if (value == -1 && PyErr_Occurred()) + return -1; +#if SIZEOF_LONG > SIZEOF_INT + if (value > INT_MAX || value < INT_MIN) { + PyErr_Format(PyExc_ValueError, + "integer out of range for \"%s\"", name); + return -1; + } +#endif + *target = (int)value; } return 0; } @@ -1385,12 +1396,16 @@ if (!PyArg_UnpackTuple(args, "field_size_limit", 0, 1, &new_limit)) return NULL; if (new_limit != NULL) { - if (!PyInt_CheckExact(new_limit)) { + if (!PyLong_CheckExact(new_limit)) { PyErr_Format(PyExc_TypeError, "limit must be an integer"); return NULL; } field_limit = PyLong_AsLong(new_limit); + if (field_limit == -1 && PyErr_Occurred()) { + field_limit = old_limit; + return NULL; + } } return PyLong_FromLong(old_limit); } Modified: python/branches/py3k/Modules/_cursesmodule.c ============================================================================== --- python/branches/py3k/Modules/_cursesmodule.c (original) +++ python/branches/py3k/Modules/_cursesmodule.c Tue Dec 4 23:10:37 2007 @@ -196,8 +196,13 @@ static int PyCurses_ConvertToChtype(PyObject *obj, chtype *ch) { - if (PyInt_CheckExact(obj)) { - *ch = (chtype) PyLong_AsLong(obj); + if (PyLong_CheckExact(obj)) { + int overflow; + /* XXX should the truncation by the cast also be reported + as an error? */ + *ch = (chtype) PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow) + return 0; } else if(PyString_Check(obj) && (PyString_Size(obj) == 1)) { *ch = (chtype) *PyString_AsString(obj); Modified: python/branches/py3k/Modules/_tkinter.c ============================================================================== --- python/branches/py3k/Modules/_tkinter.c (original) +++ python/branches/py3k/Modules/_tkinter.c Tue Dec 4 23:10:37 2007 @@ -863,14 +863,21 @@ AsObj(PyObject *value) { Tcl_Obj *result; + long longVal; + int overflow; if (PyString_Check(value)) return Tcl_NewStringObj(PyString_AS_STRING(value), PyString_GET_SIZE(value)); else if (PyBool_Check(value)) return Tcl_NewBooleanObj(PyObject_IsTrue(value)); - else if (PyInt_CheckExact(value)) - return Tcl_NewLongObj(PyLong_AS_LONG(value)); + else if (PyLong_CheckExact(value) && + ((longVal = PyLong_AsLongAndOverflow(value, &overflow)), + !overflow)) { + /* If there is an overflow in the long conversion, + fall through to default object handling. */ + return Tcl_NewLongObj(longVal); + } else if (PyFloat_Check(value)) return Tcl_NewDoubleObj(PyFloat_AS_DOUBLE(value)); else if (PyTuple_Check(value)) { Modified: python/branches/py3k/Modules/datetimemodule.c ============================================================================== --- python/branches/py3k/Modules/datetimemodule.c (original) +++ python/branches/py3k/Modules/datetimemodule.c Tue Dec 4 23:10:37 2007 @@ -3827,7 +3827,7 @@ Py_DECREF(module); if (obj != NULL) { - int i, good_timetuple = 1; + int i, good_timetuple = 1, overflow; long int ia[6]; if (PySequence_Check(obj) && PySequence_Size(obj) >= 6) for (i=0; i < 6; i++) { @@ -3836,8 +3836,11 @@ Py_DECREF(obj); return NULL; } - if (PyInt_CheckExact(p)) - ia[i] = PyLong_AsLong(p); + if (PyLong_CheckExact(p)) { + ia[i] = PyLong_AsLongAndOverflow(p, &overflow); + if (overflow) + good_timetuple = 0; + } else good_timetuple = 0; Py_DECREF(p); Modified: python/branches/py3k/Modules/socketmodule.c ============================================================================== --- python/branches/py3k/Modules/socketmodule.c (original) +++ python/branches/py3k/Modules/socketmodule.c Tue Dec 4 23:10:37 2007 @@ -3595,8 +3595,11 @@ "getaddrinfo() argument 1 must be string or None"); return NULL; } - if (PyInt_CheckExact(pobj)) { - PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", PyLong_AsLong(pobj)); + if (PyLong_CheckExact(pobj)) { + long value = PyLong_AsLong(pobj); + if (value == -1 && PyErr_Occurred()) + goto err; + PyOS_snprintf(pbuf, sizeof(pbuf), "%ld", value); pptr = pbuf; } else if (PyUnicode_Check(pobj)) { pptr = PyUnicode_AsString(pobj); Modified: python/branches/py3k/Modules/timemodule.c ============================================================================== --- python/branches/py3k/Modules/timemodule.c (original) +++ python/branches/py3k/Modules/timemodule.c Tue Dec 4 23:10:37 2007 @@ -392,8 +392,8 @@ if (y < 1900) { PyObject *accept = PyDict_GetItemString(moddict, "accept2dyear"); - if (accept == NULL || !PyInt_CheckExact(accept) || - PyLong_AsLong(accept) == 0) { + if (accept == NULL || !PyLong_CheckExact(accept) || + !PyObject_IsTrue(accept)) { PyErr_SetString(PyExc_ValueError, "year >= 1900 required"); return 0; Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Tue Dec 4 23:10:37 2007 @@ -929,6 +929,10 @@ { int have_lineno = 0; char *filename = 0; + /* Below, we always ignore overflow errors, just printing -1. + Still, we cannot allow an OverflowError to be raised, so + we need to call PyLong_AsLongAndOverflow. */ + int overflow; /* XXX -- do all the additional formatting with filename and lineno here */ @@ -936,7 +940,7 @@ if (self->filename && PyUnicode_Check(self->filename)) { filename = PyUnicode_AsString(self->filename); } - have_lineno = (self->lineno != NULL) && PyInt_CheckExact(self->lineno); + have_lineno = (self->lineno != NULL) && PyLong_CheckExact(self->lineno); if (!filename && !have_lineno) return PyObject_Str(self->msg ? self->msg : Py_None); @@ -945,7 +949,7 @@ return PyUnicode_FromFormat("%S (%s, line %ld)", self->msg ? self->msg : Py_None, my_basename(filename), - PyLong_AsLong(self->lineno)); + PyLong_AsLongAndOverflow(self->lineno, &overflow)); else if (filename) return PyUnicode_FromFormat("%S (%s)", self->msg ? self->msg : Py_None, @@ -953,7 +957,7 @@ else /* only have_lineno */ return PyUnicode_FromFormat("%S (line %ld)", self->msg ? self->msg : Py_None, - PyLong_AsLong(self->lineno)); + PyLong_AsLongAndOverflow(self->lineno, &overflow)); } static PyMemberDef SyntaxError_members[] = { Modified: python/branches/py3k/Objects/frameobject.c ============================================================================== --- python/branches/py3k/Objects/frameobject.c (original) +++ python/branches/py3k/Objects/frameobject.c Tue Dec 4 23:10:37 2007 @@ -66,6 +66,8 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno) { int new_lineno = 0; /* The new value of f_lineno */ + long l_new_lineno; + int overflow; int new_lasti = 0; /* The new value of f_lasti */ int new_iblock = 0; /* The new value of f_iblock */ unsigned char *code = NULL; /* The bytecode for the frame... */ @@ -88,7 +90,7 @@ unsigned char setup_op = 0; /* (ditto) */ /* f_lineno must be an integer. */ - if (!PyInt_CheckExact(p_new_lineno)) { + if (!PyLong_CheckExact(p_new_lineno)) { PyErr_SetString(PyExc_ValueError, "lineno must be an integer"); return -1; @@ -104,7 +106,19 @@ } /* Fail if the line comes before the start of the code block. */ - new_lineno = (int) PyLong_AsLong(p_new_lineno); + l_new_lineno = PyLong_AsLongAndOverflow(p_new_lineno, &overflow); + if (overflow +#if SIZEOF_LONG > SIZEOF_INT + || l_new_lineno > INT_MAX + || l_new_lineno < INT_MIN +#endif + ) { + PyErr_SetString(PyExc_ValueError, + "lineno out of range"); + return -1; + } + new_lineno = (int)l_new_lineno; + if (new_lineno < f->f_code->co_firstlineno) { PyErr_Format(PyExc_ValueError, "line %d comes before the current code block", Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Tue Dec 4 23:10:37 2007 @@ -925,7 +925,7 @@ Py_DECREF(args); if (res == NULL) return -1; - if (!PyInt_CheckExact(res)) { + if (!PyLong_CheckExact(res)) { PyErr_Format(PyExc_TypeError, "comparison function must return int, not %.200s", res->ob_type->tp_name); @@ -934,6 +934,10 @@ } i = PyLong_AsLong(res); Py_DECREF(res); + if (i == -1 && PyErr_Occurred()) { + /* Overflow in long conversion. */ + return -1; + } return i < 0; } Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Tue Dec 4 23:10:37 2007 @@ -299,7 +299,7 @@ Returns -1 and sets an error condition if overflow occurs. */ long -PyLong_AsLong(PyObject *vv) +PyLong_AsLongAndOverflow(PyObject *vv, int *overflow) { /* This version by Tim Peters */ register PyLongObject *v; @@ -309,6 +309,7 @@ int sign; int do_decref = 0; /* if nb_int was called */ + *overflow = 0; if (vv == NULL) { PyErr_BadInternalCall(); return -1; @@ -358,8 +359,7 @@ prev = x; x = (x << PyLong_SHIFT) + v->ob_digit[i]; if ((x >> PyLong_SHIFT) != prev) { - PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to C long"); + *overflow = Py_Size(v) > 0 ? 1 : -1; goto exit; } } @@ -373,8 +373,8 @@ res = LONG_MIN; } else { - PyErr_SetString(PyExc_OverflowError, - "Python int too large to convert to C long"); + *overflow = Py_Size(v) > 0 ? 1 : -1; + /* res is already set to -1 */ } } exit: @@ -384,6 +384,20 @@ return res; } +long +PyLong_AsLong(PyObject *obj) +{ + int overflow; + long result = PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow) { + /* XXX: could be cute and give a different + message for overflow == -1 */ + PyErr_SetString(PyExc_OverflowError, + "Python int too large to convert to C long"); + } + return result; +} + int _PyLong_FitsInLong(PyObject *vv) { Modified: python/branches/py3k/PC/_msi.c ============================================================================== --- python/branches/py3k/PC/_msi.c (original) +++ python/branches/py3k/PC/_msi.c Tue Dec 4 23:10:37 2007 @@ -542,9 +542,13 @@ if (PyString_Check(data)) { status = MsiSummaryInfoSetProperty(si->h, field, VT_LPSTR, 0, NULL, PyString_AsString(data)); - } else if (PyInt_CheckExact(data)) { + } else if (PyLong_CheckExact(data)) { + long value = PyLong_AsLong(data); + if (value == -1 && PyErr_Occurred()) { + return NULL; + } status = MsiSummaryInfoSetProperty(si->h, field, VT_I4, - PyLong_AsLong(data), NULL, NULL); + value, NULL, NULL); } else { PyErr_SetString(PyExc_TypeError, "unsupported type"); return NULL; Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Tue Dec 4 23:10:37 2007 @@ -1623,10 +1623,14 @@ Assumes all inputs are the same type. If the assumption fails, default to the more general routine. */ - if (PyInt_CheckExact(result)) { - long i_result = PyLong_AS_LONG(result); - Py_DECREF(result); - result = NULL; + if (PyLong_CheckExact(result)) { + int overflow; + long i_result = PyLong_AsLongAndOverflow(result, &overflow); + /* If this already overflowed, don't even enter the loop. */ + if (overflow == 0) { + Py_DECREF(result); + result = NULL; + } while(result == NULL) { item = PyIter_Next(iter); if (item == NULL) { @@ -1635,10 +1639,10 @@ return NULL; return PyLong_FromLong(i_result); } - if (PyInt_CheckExact(item)) { - long b = PyLong_AS_LONG(item); + if (PyLong_CheckExact(item)) { + long b = PyLong_AsLongAndOverflow(item, &overflow); long x = i_result + b; - if ((x^i_result) >= 0 || (x^b) >= 0) { + if (overflow == 0 && ((x^i_result) >= 0 || (x^b) >= 0)) { i_result = x; Py_DECREF(item); continue; @@ -1676,12 +1680,17 @@ Py_DECREF(item); continue; } - if (PyInt_CheckExact(item)) { - PyFPE_START_PROTECT("add", return 0) - f_result += (double)PyLong_AS_LONG(item); - PyFPE_END_PROTECT(f_result) - Py_DECREF(item); - continue; + if (PyLong_CheckExact(item)) { + long value; + int overflow; + value = PyLong_AsLongAndOverflow(item, &overflow); + if (!overflow) { + PyFPE_START_PROTECT("add", return 0) + f_result += (double)value; + PyFPE_END_PROTECT(f_result) + Py_DECREF(item); + continue; + } } result = PyFloat_FromDouble(f_result); temp = PyNumber_Add(result, item); Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Tue Dec 4 23:10:37 2007 @@ -3711,14 +3711,7 @@ { if (v != NULL) { Py_ssize_t x; - if (PyInt_CheckExact(v)) { - /* XXX(nnorwitz): I think PyLong_AS_LONG is correct, - however, it looks like it should be AsSsize_t. - There should be a comment here explaining why. - */ - x = PyLong_AS_LONG(v); - } - else if (PyIndex_Check(v)) { + if (PyIndex_Check(v)) { x = PyNumber_AsSsize_t(v, NULL); if (x == -1 && PyErr_Occurred()) return 0; From python-3000-checkins at python.org Tue Dec 4 23:18:27 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Tue, 4 Dec 2007 23:18:27 +0100 (CET) Subject: [Python-3000-checkins] r59337 - in python/branches/py3k: Doc/c-api/utilities.rst Python/modsupport.c Message-ID: <20071204221827.584BC1E4016@bag.python.org> Author: martin.v.loewis Date: Tue Dec 4 23:18:27 2007 New Revision: 59337 Modified: python/branches/py3k/Doc/c-api/utilities.rst python/branches/py3k/Python/modsupport.c Log: Eliminate outdated usages of PyInt_GetMax. Modified: python/branches/py3k/Doc/c-api/utilities.rst ============================================================================== --- python/branches/py3k/Doc/c-api/utilities.rst (original) +++ python/branches/py3k/Doc/c-api/utilities.rst Tue Dec 4 23:18:27 2007 @@ -901,12 +901,10 @@ Convert a C :ctype:`unsigned short int` to a Python integer object. ``I`` (integer/long) [unsigned int] - Convert a C :ctype:`unsigned int` to a Python integer object or a Python long - integer object, if it is larger than ``sys.maxint``. + Convert a C :ctype:`unsigned int` to a Python long integer object. ``k`` (integer/long) [unsigned long] - Convert a C :ctype:`unsigned long` to a Python integer object or a Python long - integer object, if it is larger than ``sys.maxint``. + Convert a C :ctype:`unsigned long` to a Python long integer object. ``L`` (long) [PY_LONG_LONG] Convert a C :ctype:`long long` to a Python integer object. Only available Modified: python/branches/py3k/Python/modsupport.c ============================================================================== --- python/branches/py3k/Python/modsupport.c (original) +++ python/branches/py3k/Python/modsupport.c Tue Dec 4 23:18:27 2007 @@ -316,10 +316,7 @@ { unsigned int n; n = va_arg(*p_va, unsigned int); - if (n > (unsigned long)PyInt_GetMax()) - return PyLong_FromUnsignedLong((unsigned long)n); - else - return PyLong_FromLong(n); + return PyLong_FromUnsignedLong(n); } case 'n': @@ -334,10 +331,7 @@ { unsigned long n; n = va_arg(*p_va, unsigned long); - if (n > (unsigned long)PyInt_GetMax()) - return PyLong_FromUnsignedLong(n); - else - return PyLong_FromLong(n); + return PyLong_FromUnsignedLong(n); } #ifdef HAVE_LONG_LONG From python-3000-checkins at python.org Wed Dec 5 00:02:21 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 00:02:21 +0100 (CET) Subject: [Python-3000-checkins] r59338 - in python/branches/py3k: Doc/library/itertools.rst Doc/library/sys.rst Include/longobject.h Lib/UserString.py Lib/_abcoll.py Lib/ctypes/__init__.py Lib/ctypes/util.py Lib/email/generator.py Lib/gzip.py Lib/inspect.py Lib/mhlib.py Lib/sre_parse.py Lib/subprocess.py Lib/test/buffer_tests.py Lib/test/list_tests.py Lib/test/pickletester.py Lib/test/regrtest.py Lib/test/string_tests.py Lib/test/test_builtin.py Lib/test/test_bytes.py Lib/test/test_compile.py Lib/test/test_descr.py Lib/test/test_format.py Lib/test/test_grammar.py Lib/test/test_hexoct.py Lib/test/test_index.py Lib/test/test_itertools.py Lib/test/test_list.py Lib/test/test_long.py Lib/test/test_marshal.py Lib/test/test_multibytecodec.py Lib/test/test_multibytecodec_support.py Lib/test/test_range.py Lib/test/test_slice.py Lib/test/test_struct.py Lib/test/test_sys.py Lib/test/test_threading.py Lib/test/test_types.py Lib/test/test_unicode.py Lib/test/test_xmlrpc.py Lib/zipfile.py Misc/NEWS Objects/longobject.c Python/sysmodule.c Tools/scripts/h2py.py Tools/unicode/makeunicodedata.py setup.py Message-ID: <20071204230221.B4F061E4025@bag.python.org> Author: christian.heimes Date: Wed Dec 5 00:02:19 2007 New Revision: 59338 Modified: python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Include/longobject.h python/branches/py3k/Lib/UserString.py python/branches/py3k/Lib/_abcoll.py python/branches/py3k/Lib/ctypes/__init__.py python/branches/py3k/Lib/ctypes/util.py python/branches/py3k/Lib/email/generator.py python/branches/py3k/Lib/gzip.py python/branches/py3k/Lib/inspect.py python/branches/py3k/Lib/mhlib.py python/branches/py3k/Lib/sre_parse.py python/branches/py3k/Lib/subprocess.py python/branches/py3k/Lib/test/buffer_tests.py python/branches/py3k/Lib/test/list_tests.py python/branches/py3k/Lib/test/pickletester.py python/branches/py3k/Lib/test/regrtest.py python/branches/py3k/Lib/test/string_tests.py python/branches/py3k/Lib/test/test_builtin.py python/branches/py3k/Lib/test/test_bytes.py python/branches/py3k/Lib/test/test_compile.py python/branches/py3k/Lib/test/test_descr.py python/branches/py3k/Lib/test/test_format.py python/branches/py3k/Lib/test/test_grammar.py python/branches/py3k/Lib/test/test_hexoct.py python/branches/py3k/Lib/test/test_index.py python/branches/py3k/Lib/test/test_itertools.py python/branches/py3k/Lib/test/test_list.py python/branches/py3k/Lib/test/test_long.py python/branches/py3k/Lib/test/test_marshal.py python/branches/py3k/Lib/test/test_multibytecodec.py python/branches/py3k/Lib/test/test_multibytecodec_support.py python/branches/py3k/Lib/test/test_range.py python/branches/py3k/Lib/test/test_slice.py python/branches/py3k/Lib/test/test_struct.py python/branches/py3k/Lib/test/test_sys.py python/branches/py3k/Lib/test/test_threading.py python/branches/py3k/Lib/test/test_types.py python/branches/py3k/Lib/test/test_unicode.py python/branches/py3k/Lib/test/test_xmlrpc.py python/branches/py3k/Lib/zipfile.py python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/longobject.c python/branches/py3k/Python/sysmodule.c python/branches/py3k/Tools/scripts/h2py.py python/branches/py3k/Tools/unicode/makeunicodedata.py python/branches/py3k/setup.py Log: Removed PyInt_GetMax and sys.maxint I replaced sys.maxint with sys.maxsize in Lib/*.py. Does anybody see a problem with the change on Win 64bit platforms? Win 64's long is just 32bit but the sys.maxsize is now 2**63-1 on every 64bit platform. Also added docs for sys.maxsize. Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Wed Dec 5 00:02:19 2007 @@ -235,7 +235,7 @@ def islice(iterable, *args): s = slice(*args) - it = iter(range(s.start or 0, s.stop or sys.maxint, s.step or 1)) + it = iter(range(s.start or 0, s.stop or sys.maxsize, s.step or 1)) nexti = next(it) for i, element in enumerate(iterable): if i == nexti: Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Wed Dec 5 00:02:19 2007 @@ -365,11 +365,12 @@ etc.) -.. data:: maxint +.. data:: maxsize - The largest positive integer supported by Python's regular integer type. This - is at least 2\*\*31-1. The largest negative integer is ``-maxint-1`` --- the - asymmetry results from the use of 2's complement binary arithmetic. + An integer giving the size of ``Py_ssize_t``. It's usually 2**31-1 on a 32 + bit platform and 2**63-1 on a 64bit platform. + + ..versionadded:: 3.0 .. data:: maxunicode Modified: python/branches/py3k/Include/longobject.h ============================================================================== --- python/branches/py3k/Include/longobject.h (original) +++ python/branches/py3k/Include/longobject.h Wed Dec 5 00:02:19 2007 @@ -31,8 +31,6 @@ cleanup to keep the extra information. [CH] */ #define PyLong_AS_LONG(op) PyLong_AsLong(op) -PyAPI_FUNC(long) PyInt_GetMax(void); - /* Used by socketmodule.c */ #if SIZEOF_SOCKET_T <= SIZEOF_LONG #define PyLong_FromSocket_t(fd) PyLong_FromLong((SOCKET_T)(fd)) Modified: python/branches/py3k/Lib/UserString.py ============================================================================== --- python/branches/py3k/Lib/UserString.py (original) +++ python/branches/py3k/Lib/UserString.py Wed Dec 5 00:02:19 2007 @@ -85,7 +85,7 @@ def capitalize(self): return self.__class__(self.data.capitalize()) def center(self, width, *args): return self.__class__(self.data.center(width, *args)) - def count(self, sub, start=0, end=sys.maxint): + def count(self, sub, start=0, end=sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.count(sub, start, end) @@ -105,15 +105,15 @@ return self.__class__(self.data.encode(encoding)) else: return self.__class__(self.data.encode()) - def endswith(self, suffix, start=0, end=sys.maxint): + def endswith(self, suffix, start=0, end=sys.maxsize): return self.data.endswith(suffix, start, end) def expandtabs(self, tabsize=8): return self.__class__(self.data.expandtabs(tabsize)) - def find(self, sub, start=0, end=sys.maxint): + def find(self, sub, start=0, end=sys.maxsize): if isinstance(sub, UserString): sub = sub.data return self.data.find(sub, start, end) - def index(self, sub, start=0, end=sys.maxint): + def index(self, sub, start=0, end=sys.maxsize): return self.data.index(sub, start, end) def isalpha(self): return self.data.isalpha() def isalnum(self): return self.data.isalnum() @@ -137,9 +137,9 @@ if isinstance(new, UserString): new = new.data return self.__class__(self.data.replace(old, new, maxsplit)) - def rfind(self, sub, start=0, end=sys.maxint): + def rfind(self, sub, start=0, end=sys.maxsize): return self.data.rfind(sub, start, end) - def rindex(self, sub, start=0, end=sys.maxint): + def rindex(self, sub, start=0, end=sys.maxsize): return self.data.rindex(sub, start, end) def rjust(self, width, *args): return self.__class__(self.data.rjust(width, *args)) @@ -151,7 +151,7 @@ def rsplit(self, sep=None, maxsplit=-1): return self.data.rsplit(sep, maxsplit) def splitlines(self, keepends=0): return self.data.splitlines(keepends) - def startswith(self, prefix, start=0, end=sys.maxint): + def startswith(self, prefix, start=0, end=sys.maxsize): return self.data.startswith(prefix, start, end) def strip(self, chars=None): return self.__class__(self.data.strip(chars)) def swapcase(self): return self.__class__(self.data.swapcase()) Modified: python/branches/py3k/Lib/_abcoll.py ============================================================================== --- python/branches/py3k/Lib/_abcoll.py (original) +++ python/branches/py3k/Lib/_abcoll.py Wed Dec 5 00:02:19 2007 @@ -246,7 +246,7 @@ freedom for __eq__ or __hash__. We match the algorithm used by the built-in frozenset type. """ - MAX = sys.maxint + MAX = sys.maxsize MASK = 2 * MAX + 1 n = len(self) h = 1927868237 * (n + 1) Modified: python/branches/py3k/Lib/ctypes/__init__.py ============================================================================== --- python/branches/py3k/Lib/ctypes/__init__.py (original) +++ python/branches/py3k/Lib/ctypes/__init__.py Wed Dec 5 00:02:19 2007 @@ -348,8 +348,8 @@ def __repr__(self): return "<%s '%s', handle %x at %x>" % \ (self.__class__.__name__, self._name, - (self._handle & (_sys.maxint*2 + 1)), - id(self) & (_sys.maxint*2 + 1)) + (self._handle & (_sys.maxsize*2 + 1)), + id(self) & (_sys.maxsize*2 + 1)) def __getattr__(self, name): if name.startswith('__') and name.endswith('__'): Modified: python/branches/py3k/Lib/ctypes/util.py ============================================================================== --- python/branches/py3k/Lib/ctypes/util.py (original) +++ python/branches/py3k/Lib/ctypes/util.py Wed Dec 5 00:02:19 2007 @@ -98,7 +98,7 @@ nums.insert(0, int(parts.pop())) except ValueError: pass - return nums or [ sys.maxint ] + return nums or [ sys.maxsize ] def find_library(name): ename = re.escape(name) Modified: python/branches/py3k/Lib/email/generator.py ============================================================================== --- python/branches/py3k/Lib/email/generator.py (original) +++ python/branches/py3k/Lib/email/generator.py Wed Dec 5 00:02:19 2007 @@ -307,13 +307,13 @@ # Helper -_width = len(repr(sys.maxint-1)) +_width = len(repr(sys.maxsize-1)) _fmt = '%%0%dd' % _width def _make_boundary(text=None): # Craft a random boundary. If text is given, ensure that the chosen # boundary doesn't appear in the text. - token = random.randrange(sys.maxint) + token = random.randrange(sys.maxsize) boundary = ('=' * 15) + (_fmt % token) + '==' if text is None: return boundary Modified: python/branches/py3k/Lib/gzip.py ============================================================================== --- python/branches/py3k/Lib/gzip.py (original) +++ python/branches/py3k/Lib/gzip.py Wed Dec 5 00:02:19 2007 @@ -409,7 +409,7 @@ def readline(self, size=-1): if size < 0: - size = sys.maxint + size = sys.maxsize readsize = self.min_readsize else: readsize = size @@ -441,7 +441,7 @@ def readlines(self, sizehint=0): # Negative numbers result in reading all the lines if sizehint <= 0: - sizehint = sys.maxint + sizehint = sys.maxsize L = [] while sizehint > 0: line = self.readline() Modified: python/branches/py3k/Lib/inspect.py ============================================================================== --- python/branches/py3k/Lib/inspect.py (original) +++ python/branches/py3k/Lib/inspect.py Wed Dec 5 00:02:19 2007 @@ -320,7 +320,7 @@ return None else: # Find minimum indentation of any non-blank lines after first line. - margin = sys.maxint + margin = sys.maxsize for line in lines[1:]: content = len(line.lstrip()) if content: @@ -329,7 +329,7 @@ # Remove indentation. if lines: lines[0] = lines[0].lstrip() - if margin < sys.maxint: + if margin < sys.maxsize: for i in range(1, len(lines)): lines[i] = lines[i][margin:] # Remove any trailing or leading blank lines. while lines and not lines[-1]: Modified: python/branches/py3k/Lib/mhlib.py ============================================================================== --- python/branches/py3k/Lib/mhlib.py (original) +++ python/branches/py3k/Lib/mhlib.py Wed Dec 5 00:02:19 2007 @@ -365,7 +365,7 @@ try: count = int(tail) except (ValueError, OverflowError): - # Can't use sys.maxint because of i+count below + # Can't use sys.maxsize because of i+count below count = len(all) try: anchor = self._parseindex(head, all) @@ -428,7 +428,7 @@ try: return int(seq) except (OverflowError, ValueError): - return sys.maxint + return sys.maxsize if seq in ('cur', '.'): return self.getcurrent() if seq == 'first': Modified: python/branches/py3k/Lib/sre_parse.py ============================================================================== --- python/branches/py3k/Lib/sre_parse.py (original) +++ python/branches/py3k/Lib/sre_parse.py Wed Dec 5 00:02:19 2007 @@ -152,7 +152,7 @@ REPEATCODES = (MIN_REPEAT, MAX_REPEAT) for op, av in self.data: if op is BRANCH: - i = sys.maxint + i = sys.maxsize j = 0 for av in av[1]: l, h = av.getwidth() @@ -177,7 +177,7 @@ hi = hi + 1 elif op == SUCCESS: break - self.width = int(min(lo, sys.maxint)), int(min(hi, sys.maxint)) + self.width = int(min(lo, sys.maxsize)), int(min(hi, sys.maxsize)) return self.width class Tokenizer: Modified: python/branches/py3k/Lib/subprocess.py ============================================================================== --- python/branches/py3k/Lib/subprocess.py (original) +++ python/branches/py3k/Lib/subprocess.py Wed Dec 5 00:02:19 2007 @@ -344,7 +344,7 @@ def _cleanup(): for inst in _active[:]: - res = inst.poll(_deadstate=sys.maxint) + res = inst.poll(_deadstate=sys.maxsize) if res is not None and res >= 0: try: _active.remove(inst) @@ -562,7 +562,7 @@ # We didn't get to successfully create a child process. return # In case the child hasn't been waited on, check if it's done. - self.poll(_deadstate=sys.maxint) + self.poll(_deadstate=sys.maxsize) if self.returncode is None and _active is not None: # Child is still running, keep us alive until we can wait on it. _active.append(self) Modified: python/branches/py3k/Lib/test/buffer_tests.py ============================================================================== --- python/branches/py3k/Lib/test/buffer_tests.py (original) +++ python/branches/py3k/Lib/test/buffer_tests.py Wed Dec 5 00:02:19 2007 @@ -172,9 +172,9 @@ self.assertRaises(TypeError, self.marshal(b'hello').expandtabs, 42, 42) # This test is only valid when sizeof(int) == sizeof(void*) == 4. - if sys.maxint < (1 << 32) and struct.calcsize('P') == 4: + if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4: self.assertRaises(OverflowError, - self.marshal(b'\ta\n\tb').expandtabs, sys.maxint) + self.marshal(b'\ta\n\tb').expandtabs, sys.maxsize) def test_title(self): self.assertEqual(b' Hello ', self.marshal(b' hello ').title()) Modified: python/branches/py3k/Lib/test/list_tests.py ============================================================================== --- python/branches/py3k/Lib/test/list_tests.py (original) +++ python/branches/py3k/Lib/test/list_tests.py Wed Dec 5 00:02:19 2007 @@ -388,8 +388,8 @@ self.assertEqual(a.index(0, -3), 3) self.assertEqual(a.index(0, 3, 4), 3) self.assertEqual(a.index(0, -3, -2), 3) - self.assertEqual(a.index(0, -4*sys.maxint, 4*sys.maxint), 2) - self.assertRaises(ValueError, a.index, 0, 4*sys.maxint,-4*sys.maxint) + self.assertEqual(a.index(0, -4*sys.maxsize, 4*sys.maxsize), 2) + self.assertRaises(ValueError, a.index, 0, 4*sys.maxsize,-4*sys.maxsize) self.assertRaises(ValueError, a.index, 2, 0, -10) a.remove(0) self.assertRaises(ValueError, a.index, 2, 0, 4) Modified: python/branches/py3k/Lib/test/pickletester.py ============================================================================== --- python/branches/py3k/Lib/test/pickletester.py (original) +++ python/branches/py3k/Lib/test/pickletester.py Wed Dec 5 00:02:19 2007 @@ -493,7 +493,7 @@ def test_ints(self): import sys for proto in protocols: - n = sys.maxint + n = sys.maxsize while n: for expected in (-n, n): s = self.dumps(expected, proto) Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Wed Dec 5 00:02:19 2007 @@ -140,7 +140,7 @@ # putting them in test_grammar.py has no effect: warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning, ".*test.test_grammar$") -if sys.maxint > 0x7fffffff: +if sys.maxsize > 0x7fffffff: # Also suppress them in , because for 64-bit platforms, # that's where test_grammar.py hides them. warnings.filterwarnings("ignore", "hex/oct constants", FutureWarning, Modified: python/branches/py3k/Lib/test/string_tests.py ============================================================================== --- python/branches/py3k/Lib/test/string_tests.py (original) +++ python/branches/py3k/Lib/test/string_tests.py Wed Dec 5 00:02:19 2007 @@ -265,9 +265,9 @@ self.checkraises(TypeError, 'hello', 'expandtabs', 42, 42) # This test is only valid when sizeof(int) == sizeof(void*) == 4. - if sys.maxint < (1 << 32) and struct.calcsize('P') == 4: + if sys.maxsize < (1 << 32) and struct.calcsize('P') == 4: self.checkraises(OverflowError, - '\ta\n\tb', 'expandtabs', sys.maxint) + '\ta\n\tb', 'expandtabs', sys.maxsize) def test_split(self): # by a char @@ -278,7 +278,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', 4) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'split', '|', - sys.maxint-2) + sys.maxsize-2) self.checkequal(['a|b|c|d'], 'a|b|c|d', 'split', '|', 0) self.checkequal(['a', '', 'b||c||d'], 'a||b||c||d', 'split', '|', 2) self.checkequal(['endcase ', ''], 'endcase |', 'split', '|') @@ -297,7 +297,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', 4) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'split', '//', - sys.maxint-10) + sys.maxsize-10) self.checkequal(['a//b//c//d'], 'a//b//c//d', 'split', '//', 0) self.checkequal(['a', '', 'b////c////d'], 'a////b////c////d', 'split', '//', 2) self.checkequal(['endcase ', ''], 'endcase test', 'split', 'test') @@ -334,7 +334,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', 4) self.checkequal(['a', 'b', 'c', 'd'], 'a|b|c|d', 'rsplit', '|', - sys.maxint-100) + sys.maxsize-100) self.checkequal(['a|b|c|d'], 'a|b|c|d', 'rsplit', '|', 0) self.checkequal(['a||b||c', '', 'd'], 'a||b||c||d', 'rsplit', '|', 2) self.checkequal(['', ' begincase'], '| begincase', 'rsplit', '|') @@ -354,7 +354,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 3) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', 4) self.checkequal(['a', 'b', 'c', 'd'], 'a//b//c//d', 'rsplit', '//', - sys.maxint-5) + sys.maxsize-5) self.checkequal(['a//b//c//d'], 'a//b//c//d', 'rsplit', '//', 0) self.checkequal(['a////b////c', '', 'd'], 'a////b////c////d', 'rsplit', '//', 2) self.checkequal(['', ' begincase'], 'test begincase', 'rsplit', 'test') @@ -392,7 +392,7 @@ EQ("", "", "replace", "A", "") EQ("", "", "replace", "A", "A") EQ("", "", "replace", "", "", 100) - EQ("", "", "replace", "", "", sys.maxint) + EQ("", "", "replace", "", "", sys.maxsize) # interleave (from=="", 'to' gets inserted everywhere) EQ("A", "A", "replace", "", "") @@ -401,7 +401,7 @@ EQ("*-#A*-#", "A", "replace", "", "*-#") EQ("*-A*-A*-", "AA", "replace", "", "*-") EQ("*-A*-A*-", "AA", "replace", "", "*-", -1) - EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxint) + EQ("*-A*-A*-", "AA", "replace", "", "*-", sys.maxsize) EQ("*-A*-A*-", "AA", "replace", "", "*-", 4) EQ("*-A*-A*-", "AA", "replace", "", "*-", 3) EQ("*-A*-A", "AA", "replace", "", "*-", 2) @@ -412,7 +412,7 @@ EQ("", "A", "replace", "A", "") EQ("", "AAA", "replace", "A", "") EQ("", "AAA", "replace", "A", "", -1) - EQ("", "AAA", "replace", "A", "", sys.maxint) + EQ("", "AAA", "replace", "A", "", sys.maxsize) EQ("", "AAA", "replace", "A", "", 4) EQ("", "AAA", "replace", "A", "", 3) EQ("A", "AAA", "replace", "A", "", 2) @@ -421,7 +421,7 @@ EQ("", "AAAAAAAAAA", "replace", "A", "") EQ("BCD", "ABACADA", "replace", "A", "") EQ("BCD", "ABACADA", "replace", "A", "", -1) - EQ("BCD", "ABACADA", "replace", "A", "", sys.maxint) + EQ("BCD", "ABACADA", "replace", "A", "", sys.maxsize) EQ("BCD", "ABACADA", "replace", "A", "", 5) EQ("BCD", "ABACADA", "replace", "A", "", 4) EQ("BCDA", "ABACADA", "replace", "A", "", 3) @@ -444,7 +444,7 @@ EQ("thaet", "thaet", "replace", "the", "") EQ("here and re", "here and there", "replace", "the", "") EQ("here and re and re", "here and there and there", - "replace", "the", "", sys.maxint) + "replace", "the", "", sys.maxsize) EQ("here and re and re", "here and there and there", "replace", "the", "", -1) EQ("here and re and re", "here and there and there", @@ -469,7 +469,7 @@ # single character replace in place (len(from)==len(to)==1) EQ("Who goes there?", "Who goes there?", "replace", "o", "o") EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O") - EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxint) + EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", sys.maxsize) EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", -1) EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 3) EQ("WhO gOes there?", "Who goes there?", "replace", "o", "O", 2) @@ -486,7 +486,7 @@ # substring replace in place (len(from)==len(to) > 1) EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**") - EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxint) + EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", sys.maxsize) EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", -1) EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 4) EQ("Th** ** a t**sue", "This is a tissue", "replace", "is", "**", 3) @@ -500,7 +500,7 @@ # replace single character (len(from)==1, len(to)>1) EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK") EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", -1) - EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxint) + EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", sys.maxsize) EQ("ReyKKjaviKK", "Reykjavik", "replace", "k", "KK", 2) EQ("ReyKKjavik", "Reykjavik", "replace", "k", "KK", 1) EQ("Reykjavik", "Reykjavik", "replace", "k", "KK", 0) @@ -512,7 +512,7 @@ EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", "replace", "spam", "ham") EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", - "replace", "spam", "ham", sys.maxint) + "replace", "spam", "ham", sys.maxsize) EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", "replace", "spam", "ham", -1) EQ("ham, ham, eggs and ham", "spam, spam, eggs and spam", @@ -567,7 +567,7 @@ def test_replace_overflow(self): # Check for overflow checking on 32 bit machines - if sys.maxint != 2147483647 or struct.calcsize("P") > 4: + if sys.maxsize != 2147483647 or struct.calcsize("P") > 4: return A2_16 = "A" * (2**16) self.checkraises(OverflowError, A2_16, "replace", "", A2_16) @@ -631,7 +631,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 3) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, 4) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'split', None, - sys.maxint-1) + sys.maxsize-1) self.checkequal(['a b c d'], 'a b c d', 'split', None, 0) self.checkequal(['a b c d'], ' a b c d', 'split', None, 0) self.checkequal(['a', 'b', 'c d'], 'a b c d', 'split', None, 2) @@ -662,7 +662,7 @@ self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 3) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, 4) self.checkequal(['a', 'b', 'c', 'd'], 'a b c d', 'rsplit', None, - sys.maxint-20) + sys.maxsize-20) self.checkequal(['a b c d'], 'a b c d', 'rsplit', None, 0) self.checkequal(['a b c d'], 'a b c d ', 'rsplit', None, 0) self.checkequal(['a b', 'c', 'd'], 'a b c d', 'rsplit', None, 2) Modified: python/branches/py3k/Lib/test/test_builtin.py ============================================================================== --- python/branches/py3k/Lib/test/test_builtin.py (original) +++ python/branches/py3k/Lib/test/test_builtin.py Wed Dec 5 00:02:19 2007 @@ -60,7 +60,7 @@ (' 314', 314), ('314 ', 314), (' \t\t 314 \t\t ', 314), - (repr(sys.maxint), sys.maxint), + (repr(sys.maxsize), sys.maxsize), (' 1x', ValueError), (' 1 ', 1), (' 1\02 ', ValueError), @@ -97,7 +97,7 @@ self.assertEqual(abs(0), 0) self.assertEqual(abs(1234), 1234) self.assertEqual(abs(-1234), 1234) - self.assertTrue(abs(-sys.maxint-1) > 0) + self.assertTrue(abs(-sys.maxsize-1) > 0) # float self.assertEqual(abs(0.0), 0.0) self.assertEqual(abs(3.14), 3.14) @@ -138,9 +138,9 @@ self.assertEqual(any(x > 42 for x in S), False) def test_neg(self): - x = -sys.maxint-1 + x = -sys.maxsize-1 self.assert_(isinstance(x, int)) - self.assertEqual(-x, sys.maxint+1) + self.assertEqual(-x, sys.maxsize+1) # XXX(nnorwitz): This test case for callable should probably be removed. def test_callable(self): @@ -306,8 +306,8 @@ self.assertEqual(divmod(12, -7), (-2, -2)) self.assertEqual(divmod(-12, -7), (1, -5)) - self.assertEqual(divmod(-sys.maxint-1, -1), - (sys.maxint+1, 0)) + self.assertEqual(divmod(-sys.maxsize-1, -1), + (sys.maxsize+1, 0)) self.assert_(not fcmp(divmod(3.25, 1.0), (3.0, 0.25))) self.assert_(not fcmp(divmod(-3.25, 1.0), (-4.0, 0.75))) @@ -644,12 +644,12 @@ except v: pass - s = repr(-1-sys.maxint) + s = repr(-1-sys.maxsize) x = int(s) - self.assertEqual(x+1, -sys.maxint) + self.assertEqual(x+1, -sys.maxsize) self.assert_(isinstance(x, int)) # should return long - self.assertEqual(int(s[1:]), sys.maxint+1) + self.assertEqual(int(s[1:]), sys.maxsize+1) # should return long x = int(1e100) @@ -661,7 +661,7 @@ # SF bug 434186: 0x80000000/2 != 0x80000000>>1. # Worked by accident in Windows release build, but failed in debug build. # Failed in all Linux builds. - x = -1-sys.maxint + x = -1-sys.maxsize self.assertEqual(x >> 1, x//2) self.assertRaises(ValueError, int, '123\0') @@ -881,12 +881,12 @@ self.assertEqual(list(''), []) self.assertEqual(list('spam'), ['s', 'p', 'a', 'm']) - if sys.maxint == 0x7fffffff: + if sys.maxsize == 0x7fffffff: # This test can currently only work on 32-bit machines. # XXX If/when PySequence_Length() returns a ssize_t, it should be # XXX re-enabled. # Verify clearing of bug #556025. - # This assumes that the max data size (sys.maxint) == max + # This assumes that the max data size (sys.maxsize) == max # address size this also assumes that the address size is at # least 4 bytes with 8 byte addresses, the bug is not well # tested @@ -896,7 +896,7 @@ # thread for the details: # http://sources.redhat.com/ml/newlib/2002/msg00369.html - self.assertRaises(MemoryError, list, range(sys.maxint // 2)) + self.assertRaises(MemoryError, list, range(sys.maxsize // 2)) # This code used to segfault in Py2.4a3 x = [] @@ -1384,9 +1384,9 @@ self.assertEqual(list(range(0, 2**100, -1)), []) self.assertEqual(list(range(0, 2**100, -1)), []) - a = int(10 * sys.maxint) - b = int(100 * sys.maxint) - c = int(50 * sys.maxint) + a = int(10 * sys.maxsize) + b = int(100 * sys.maxsize) + c = int(50 * sys.maxsize) self.assertEqual(list(range(a, a+2)), [a, a+1]) self.assertEqual(list(range(a+2, a, -1)), [a+2, a+1]) @@ -1428,10 +1428,10 @@ self.assertRaises(TypeError, range, 0, "spam") self.assertRaises(TypeError, range, 0, 42, "spam") - #NEAL self.assertRaises(OverflowError, range, -sys.maxint, sys.maxint) - #NEAL self.assertRaises(OverflowError, range, 0, 2*sys.maxint) + #NEAL self.assertRaises(OverflowError, range, -sys.maxsize, sys.maxsize) + #NEAL self.assertRaises(OverflowError, range, 0, 2*sys.maxsize) - self.assertRaises(OverflowError, len, range(0, sys.maxint**10)) + self.assertRaises(OverflowError, len, range(0, sys.maxsize**10)) def test_input(self): self.write_testfile() Modified: python/branches/py3k/Lib/test/test_bytes.py ============================================================================== --- python/branches/py3k/Lib/test/test_bytes.py (original) +++ python/branches/py3k/Lib/test/test_bytes.py Wed Dec 5 00:02:19 2007 @@ -36,14 +36,14 @@ self.assertEqual(len(b), 0) self.assertRaises(IndexError, lambda: b[0]) self.assertRaises(IndexError, lambda: b[1]) - self.assertRaises(IndexError, lambda: b[sys.maxint]) - self.assertRaises(IndexError, lambda: b[sys.maxint+1]) + self.assertRaises(IndexError, lambda: b[sys.maxsize]) + self.assertRaises(IndexError, lambda: b[sys.maxsize+1]) self.assertRaises(IndexError, lambda: b[10**100]) self.assertRaises(IndexError, lambda: b[-1]) self.assertRaises(IndexError, lambda: b[-2]) - self.assertRaises(IndexError, lambda: b[-sys.maxint]) - self.assertRaises(IndexError, lambda: b[-sys.maxint-1]) - self.assertRaises(IndexError, lambda: b[-sys.maxint-2]) + self.assertRaises(IndexError, lambda: b[-sys.maxsize]) + self.assertRaises(IndexError, lambda: b[-sys.maxsize-1]) + self.assertRaises(IndexError, lambda: b[-sys.maxsize-2]) self.assertRaises(IndexError, lambda: b[-10**100]) def test_from_list(self): @@ -83,14 +83,14 @@ def test_constructor_value_errors(self): self.assertRaises(ValueError, bytearray, [-1]) - self.assertRaises(ValueError, bytearray, [-sys.maxint]) - self.assertRaises(ValueError, bytearray, [-sys.maxint-1]) - self.assertRaises(ValueError, bytearray, [-sys.maxint-2]) + self.assertRaises(ValueError, bytearray, [-sys.maxsize]) + self.assertRaises(ValueError, bytearray, [-sys.maxsize-1]) + self.assertRaises(ValueError, bytearray, [-sys.maxsize-2]) self.assertRaises(ValueError, bytearray, [-10**100]) self.assertRaises(ValueError, bytearray, [256]) self.assertRaises(ValueError, bytearray, [257]) - self.assertRaises(ValueError, bytearray, [sys.maxint]) - self.assertRaises(ValueError, bytearray, [sys.maxint+1]) + self.assertRaises(ValueError, bytearray, [sys.maxsize]) + self.assertRaises(ValueError, bytearray, [sys.maxsize+1]) self.assertRaises(ValueError, bytearray, [10**100]) def test_repr_str(self): @@ -412,7 +412,7 @@ self.assertRaises(TypeError, lambda: 3.14 * b) # XXX Shouldn't bytes and bytearray agree on what to raise? self.assertRaises((OverflowError, MemoryError), - lambda: b * sys.maxint) + lambda: b * sys.maxsize) def test_repeat_1char(self): self.assertEqual(b'x'*100, bytearray([ord('x')]*100)) Modified: python/branches/py3k/Lib/test/test_compile.py ============================================================================== --- python/branches/py3k/Lib/test/test_compile.py (original) +++ python/branches/py3k/Lib/test/test_compile.py Wed Dec 5 00:02:19 2007 @@ -194,24 +194,24 @@ def test_unary_minus(self): # Verify treatment of unary minus on negative numbers SF bug #660455 - if sys.maxint == 2147483647: + if sys.maxsize == 2147483647: # 32-bit machine all_one_bits = '0xffffffff' self.assertEqual(eval(all_one_bits), 4294967295) self.assertEqual(eval("-" + all_one_bits), -4294967295) - elif sys.maxint == 9223372036854775807: + elif sys.maxsize == 9223372036854775807: # 64-bit machine all_one_bits = '0xffffffffffffffff' self.assertEqual(eval(all_one_bits), 18446744073709551615) self.assertEqual(eval("-" + all_one_bits), -18446744073709551615) else: self.fail("How many bits *does* this machine have???") - # Verify treatment of contant folding on -(sys.maxint+1) + # Verify treatment of contant folding on -(sys.maxsize+1) # i.e. -2147483648 on 32 bit platforms. Should return int, not long. - self.assertTrue(isinstance(eval("%s" % (-sys.maxint - 1)), int)) - self.assertTrue(isinstance(eval("%s" % (-sys.maxint - 2)), int)) + self.assertTrue(isinstance(eval("%s" % (-sys.maxsize - 1)), int)) + self.assertTrue(isinstance(eval("%s" % (-sys.maxsize - 2)), int)) - if sys.maxint == 9223372036854775807: + if sys.maxsize == 9223372036854775807: def test_32_63_bit_values(self): a = +4294967296 # 1 << 32 b = -4294967296 # 1 << 32 Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Wed Dec 5 00:02:19 2007 @@ -4118,8 +4118,8 @@ else: raise TestFailed("no TypeError from %r" % (expr,)) - N1 = sys.maxint + 1 # might trigger OverflowErrors instead of TypeErrors - N2 = sys.maxint # if sizeof(int) < sizeof(long), might trigger + N1 = sys.maxsize + 1 # might trigger OverflowErrors instead of TypeErrors + N2 = sys.maxsize # if sizeof(int) < sizeof(long), might trigger # ValueErrors instead of TypeErrors if 1: metaclass = type Modified: python/branches/py3k/Lib/test/test_format.py ============================================================================== --- python/branches/py3k/Lib/test/test_format.py (original) +++ python/branches/py3k/Lib/test/test_format.py Wed Dec 5 00:02:19 2007 @@ -40,7 +40,7 @@ print('yes') testformat("%.1d", (1,), "1") -testformat("%.*d", (sys.maxint,1)) # expect overflow +testformat("%.*d", (sys.maxsize,1)) # expect overflow testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testformat("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') testformat("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001') Modified: python/branches/py3k/Lib/test/test_grammar.py ============================================================================== --- python/branches/py3k/Lib/test/test_grammar.py (original) +++ python/branches/py3k/Lib/test/test_grammar.py Wed Dec 5 00:02:19 2007 @@ -32,8 +32,8 @@ self.assertEquals(0o377, 255) self.assertEquals(2147483647, 0o17777777777) self.assertEquals(0b1001, 9) - from sys import maxint - if maxint == 2147483647: + from sys import maxsize + if maxsize == 2147483647: self.assertEquals(-2147483647-1, -0o20000000000) # XXX -2147483648 self.assert_(0o37777777777 > 0) @@ -45,7 +45,7 @@ x = eval(s) except OverflowError: self.fail("OverflowError on huge integer literal %r" % s) - elif maxint == 9223372036854775807: + elif maxsize == 9223372036854775807: self.assertEquals(-9223372036854775807-1, -0o1000000000000000000000) self.assert_(0o1777777777777777777777 > 0) self.assert_(0xffffffffffffffff > 0) @@ -58,7 +58,7 @@ except OverflowError: self.fail("OverflowError on huge integer literal %r" % s) else: - self.fail('Weird maxint value %r' % maxint) + self.fail('Weird maxsize value %r' % maxsize) def testLongIntegers(self): x = 0 Modified: python/branches/py3k/Lib/test/test_hexoct.py ============================================================================== --- python/branches/py3k/Lib/test/test_hexoct.py (original) +++ python/branches/py3k/Lib/test/test_hexoct.py Wed Dec 5 00:02:19 2007 @@ -4,7 +4,7 @@ """ import sys -platform_long_is_32_bits = sys.maxint == 2147483647 +platform_long_is_32_bits = sys.maxsize == 2147483647 import unittest from test import test_support Modified: python/branches/py3k/Lib/test/test_index.py ============================================================================== --- python/branches/py3k/Lib/test/test_index.py (original) +++ python/branches/py3k/Lib/test/test_index.py Wed Dec 5 00:02:19 2007 @@ -2,7 +2,6 @@ from test import test_support import operator import sys -from sys import maxint maxsize = test_support.MAX_Py_ssize_t minsize = -maxsize-1 @@ -180,7 +179,7 @@ def test_getitem(self): class GetItem(object): def __len__(self): - return maxint #cannot return long here + return sys.maxsize def __getitem__(self, key): return key x = GetItem() Modified: python/branches/py3k/Lib/test/test_itertools.py ============================================================================== --- python/branches/py3k/Lib/test/test_itertools.py (original) +++ python/branches/py3k/Lib/test/test_itertools.py Wed Dec 5 00:02:19 2007 @@ -71,7 +71,7 @@ self.assertEqual(repr(c), 'count(-9)') next(c) self.assertEqual(next(c), -8) - for i in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 10, sys.maxint-5, sys.maxint+5): + for i in (-sys.maxsize-5, -sys.maxsize+5 ,-10, -1, 0, 10, sys.maxsize-5, sys.maxsize+5): # Test repr (ignoring the L in longs) r1 = repr(count(i)).replace('L', '') r2 = 'count(%r)'.__mod__(i).replace('L', '') Modified: python/branches/py3k/Lib/test/test_list.py ============================================================================== --- python/branches/py3k/Lib/test/test_list.py (original) +++ python/branches/py3k/Lib/test/test_list.py Wed Dec 5 00:02:19 2007 @@ -21,7 +21,7 @@ def test_overflow(self): lst = [4, 5, 6, 7] - n = int((sys.maxint*2+2) // len(lst)) + n = int((sys.maxsize*2+2) // len(lst)) def mul(a, b): return a * b def imul(a, b): a *= b self.assertRaises((MemoryError, OverflowError), mul, lst, n) Modified: python/branches/py3k/Lib/test/test_long.py ============================================================================== --- python/branches/py3k/Lib/test/test_long.py (original) +++ python/branches/py3k/Lib/test/test_long.py Wed Dec 5 00:02:19 2007 @@ -233,48 +233,48 @@ import sys # check the extremes in int<->long conversion - hugepos = sys.maxint + hugepos = sys.maxsize hugeneg = -hugepos - 1 hugepos_aslong = int(hugepos) hugeneg_aslong = int(hugeneg) - self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxint) != sys.maxint") + self.assertEqual(hugepos, hugepos_aslong, "long(sys.maxsize) != sys.maxsize") self.assertEqual(hugeneg, hugeneg_aslong, - "long(-sys.maxint-1) != -sys.maxint-1") + "long(-sys.maxsize-1) != -sys.maxsize-1") # long -> int should not fail for hugepos_aslong or hugeneg_aslong x = int(hugepos_aslong) try: self.assertEqual(x, hugepos, - "converting sys.maxint to long and back to int fails") + "converting sys.maxsize to long and back to int fails") except OverflowError: - self.fail("int(long(sys.maxint)) overflowed!") + self.fail("int(long(sys.maxsize)) overflowed!") if not isinstance(x, int): - raise TestFailed("int(long(sys.maxint)) should have returned int") + raise TestFailed("int(long(sys.maxsize)) should have returned int") x = int(hugeneg_aslong) try: self.assertEqual(x, hugeneg, - "converting -sys.maxint-1 to long and back to int fails") + "converting -sys.maxsize-1 to long and back to int fails") except OverflowError: - self.fail("int(long(-sys.maxint-1)) overflowed!") + self.fail("int(long(-sys.maxsize-1)) overflowed!") if not isinstance(x, int): - raise TestFailed("int(long(-sys.maxint-1)) should have " + raise TestFailed("int(long(-sys.maxsize-1)) should have " "returned int") # but long -> int should overflow for hugepos+1 and hugeneg-1 x = hugepos_aslong + 1 try: y = int(x) except OverflowError: - self.fail("int(long(sys.maxint) + 1) mustn't overflow") + self.fail("int(long(sys.maxsize) + 1) mustn't overflow") self.assert_(isinstance(y, int), - "int(long(sys.maxint) + 1) should have returned long") + "int(long(sys.maxsize) + 1) should have returned long") x = hugeneg_aslong - 1 try: y = int(x) except OverflowError: - self.fail("int(long(-sys.maxint-1) - 1) mustn't overflow") + self.fail("int(long(-sys.maxsize-1) - 1) mustn't overflow") self.assert_(isinstance(y, int), - "int(long(-sys.maxint-1) - 1) should have returned long") + "int(long(-sys.maxsize-1) - 1) should have returned long") class long2(int): pass @@ -288,8 +288,8 @@ def test_auto_overflow(self): import math, sys - special = [0, 1, 2, 3, sys.maxint-1, sys.maxint, sys.maxint+1] - sqrt = int(math.sqrt(sys.maxint)) + special = [0, 1, 2, 3, sys.maxsize-1, sys.maxsize, sys.maxsize+1] + sqrt = int(math.sqrt(sys.maxsize)) special.extend([sqrt-1, sqrt, sqrt+1]) special.extend([-i for i in special]) @@ -462,7 +462,7 @@ for t in 2.0**48, 2.0**50, 2.0**53: cases.extend([t - 1.0, t - 0.3, t, t + 0.3, t + 1.0, int(t-1), int(t), int(t+1)]) - cases.extend([0, 1, 2, sys.maxint, float(sys.maxint)]) + cases.extend([0, 1, 2, sys.maxsize, float(sys.maxsize)]) # 1L<<20000 should exceed all double formats. long(1e200) is to # check that we get equality with 1e200 above. t = int(1e200) Modified: python/branches/py3k/Lib/test/test_marshal.py ============================================================================== --- python/branches/py3k/Lib/test/test_marshal.py (original) +++ python/branches/py3k/Lib/test/test_marshal.py Wed Dec 5 00:02:19 2007 @@ -28,7 +28,7 @@ class IntTestCase(unittest.TestCase, HelperMixin): def test_ints(self): # Test the full range of Python ints. - n = sys.maxint + n = sys.maxsize while n: for expected in (-n, n): self.helper(expected) @@ -66,7 +66,7 @@ def test_floats(self): # Test a few floats small = 1e-25 - n = sys.maxint * 3.7e250 + n = sys.maxsize * 3.7e250 while n > small: for expected in (-n, n): self.helper(float(expected)) @@ -81,7 +81,7 @@ got = marshal.loads(s) self.assertEqual(f, got) - n = sys.maxint * 3.7e-250 + n = sys.maxsize * 3.7e-250 while n < small: for expected in (-n, n): f = float(expected) Modified: python/branches/py3k/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/py3k/Lib/test/test_multibytecodec.py (original) +++ python/branches/py3k/Lib/test/test_multibytecodec.py Wed Dec 5 00:02:19 2007 @@ -40,7 +40,7 @@ def test_errorcallback_longindex(self): dec = codecs.getdecoder('euc-kr') - myreplace = lambda exc: ('', sys.maxint+1) + myreplace = lambda exc: ('', sys.maxsize+1) codecs.register_error('test.cjktest', myreplace) self.assertRaises(IndexError, dec, 'apple\x92ham\x93spam', 'test.cjktest') Modified: python/branches/py3k/Lib/test/test_multibytecodec_support.py ============================================================================== --- python/branches/py3k/Lib/test/test_multibytecodec_support.py (original) +++ python/branches/py3k/Lib/test/test_multibytecodec_support.py Wed Dec 5 00:02:19 2007 @@ -114,7 +114,7 @@ 'test.cjktest'), (b'abcdxefgh', 9)) def myreplace(exc): - return ('x', sys.maxint + 1) + return ('x', sys.maxsize + 1) codecs.register_error("test.cjktest", myreplace) self.assertRaises(IndexError, self.encode, self.unmappedunicode, 'test.cjktest') Modified: python/branches/py3k/Lib/test/test_range.py ============================================================================== --- python/branches/py3k/Lib/test/test_range.py (original) +++ python/branches/py3k/Lib/test/test_range.py Wed Dec 5 00:02:19 2007 @@ -51,10 +51,10 @@ self.assertRaises(TypeError, range, 0, "spam") self.assertRaises(TypeError, range, 0, 42, "spam") - self.assertEqual(len(range(0, sys.maxint, sys.maxint-1)), 2) + self.assertEqual(len(range(0, sys.maxsize, sys.maxsize-1)), 2) - r = range(-sys.maxint, sys.maxint, 2) - self.assertEqual(len(r), sys.maxint) + r = range(-sys.maxsize, sys.maxsize, 2) + self.assertEqual(len(r), sys.maxsize) def test_repr(self): self.assertEqual(repr(range(1)), 'range(0, 1)') Modified: python/branches/py3k/Lib/test/test_slice.py ============================================================================== --- python/branches/py3k/Lib/test/test_slice.py (original) +++ python/branches/py3k/Lib/test/test_slice.py Wed Dec 5 00:02:19 2007 @@ -92,7 +92,7 @@ ) self.assertEqual(slice(-100, 100, 2).indices(10), (0, 10, 2)) - self.assertEqual(list(range(10))[::sys.maxint - 1], [0]) + self.assertEqual(list(range(10))[::sys.maxsize - 1], [0]) self.assertRaises(OverflowError, slice(None).indices, 1<<100) Modified: python/branches/py3k/Lib/test/test_struct.py ============================================================================== --- python/branches/py3k/Lib/test/test_struct.py (original) +++ python/branches/py3k/Lib/test/test_struct.py Wed Dec 5 00:02:19 2007 @@ -506,8 +506,8 @@ deprecated_err(struct.pack, endian + 'B', 300) deprecated_err(struct.pack, endian + 'H', 70000) - deprecated_err(struct.pack, endian + 'I', sys.maxint * 4) - deprecated_err(struct.pack, endian + 'L', sys.maxint * 4) + deprecated_err(struct.pack, endian + 'I', sys.maxsize * 4) + deprecated_err(struct.pack, endian + 'L', sys.maxsize * 4) if PY_STRUCT_RANGE_CHECKING: test_1229380() Modified: python/branches/py3k/Lib/test/test_sys.py ============================================================================== --- python/branches/py3k/Lib/test/test_sys.py (original) +++ python/branches/py3k/Lib/test/test_sys.py Wed Dec 5 00:02:19 2007 @@ -282,7 +282,7 @@ self.assert_(isinstance(sys.float_info, dict)) self.assertEqual(len(sys.float_info), 11) self.assert_(isinstance(sys.hexversion, int)) - self.assert_(isinstance(sys.maxint, int)) + self.assert_(isinstance(sys.maxsize, int)) self.assert_(isinstance(sys.maxunicode, int)) self.assert_(isinstance(sys.platform, str)) self.assert_(isinstance(sys.prefix, str)) Modified: python/branches/py3k/Lib/test/test_threading.py ============================================================================== --- python/branches/py3k/Lib/test/test_threading.py (original) +++ python/branches/py3k/Lib/test/test_threading.py Wed Dec 5 00:02:19 2007 @@ -258,7 +258,7 @@ def test_semaphore_with_negative_value(self): self.assertRaises(ValueError, threading.Semaphore, value = -1) - self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxint) + self.assertRaises(ValueError, threading.Semaphore, value = -sys.maxsize) def test_joining_current_thread(self): currentThread = threading.currentThread() Modified: python/branches/py3k/Lib/test/test_types.py ============================================================================== --- python/branches/py3k/Lib/test/test_types.py (original) +++ python/branches/py3k/Lib/test/test_types.py Wed Dec 5 00:02:19 2007 @@ -105,7 +105,7 @@ if not (xsize*ysize*zsize == zsize*xsize*ysize == 338912): self.fail('int mul commutativity') # And another. - m = -sys.maxint - 1 + m = -sys.maxsize - 1 for divisor in 1, 2, 4, 8, 16, 32: j = m // divisor prod = divisor * j @@ -122,7 +122,7 @@ self.fail("expected type(%r) to be long, not %r" % (prod, type(prod))) # Check for expected * overflow to long. - m = sys.maxint + m = sys.maxsize for divisor in 1, 2, 4, 8, 16, 32: j = m // divisor + 1 prod = divisor * j @@ -137,7 +137,7 @@ if (-12) + (-24) != -36: self.fail('long op') if not 12 < 24: self.fail('long op') if not -24 < -12: self.fail('long op') - x = sys.maxint + x = sys.maxsize if int(int(x)) != x: self.fail('long op') try: y = int(int(x)+1) except OverflowError: self.fail('long op') Modified: python/branches/py3k/Lib/test/test_unicode.py ============================================================================== --- python/branches/py3k/Lib/test/test_unicode.py (original) +++ python/branches/py3k/Lib/test/test_unicode.py Wed Dec 5 00:02:19 2007 @@ -1055,9 +1055,9 @@ # This test only affects 32-bit platforms because expandtabs can only take # an int as the max value, not a 64-bit C long. If expandtabs is changed # to take a 64-bit long, this test should apply to all platforms. - if sys.maxint > (1 << 32) or struct.calcsize('P') != 4: + if sys.maxsize > (1 << 32) or struct.calcsize('P') != 4: return - self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxint) + self.assertRaises(OverflowError, 't\tt\t'.expandtabs, sys.maxsize) def test_main(): Modified: python/branches/py3k/Lib/test/test_xmlrpc.py ============================================================================== --- python/branches/py3k/Lib/test/test_xmlrpc.py (original) +++ python/branches/py3k/Lib/test/test_xmlrpc.py Wed Dec 5 00:02:19 2007 @@ -117,7 +117,7 @@ self.assertRaises(TypeError, xmlrpclib.dumps, (d,)) def test_dump_big_int(self): - if sys.maxint > 2**31-1: + if sys.maxsize > 2**31-1: self.assertRaises(OverflowError, xmlrpclib.dumps, (int(2**34),)) Modified: python/branches/py3k/Lib/zipfile.py ============================================================================== --- python/branches/py3k/Lib/zipfile.py (original) +++ python/branches/py3k/Lib/zipfile.py Wed Dec 5 00:02:19 2007 @@ -428,7 +428,7 @@ read a whole line. """ if size < 0: - size = sys.maxint + size = sys.maxsize elif size == 0: return b'' Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Wed Dec 5 00:02:19 2007 @@ -54,6 +54,8 @@ to longobject.h. It still exists to define several aliases from PyInt_ to PyLong_ functions. +- Removed sys.maxint, use sys.maxsize instead. + Extension Modules ----------------- Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Wed Dec 5 00:02:19 2007 @@ -9,12 +9,6 @@ #include -long -PyInt_GetMax(void) -{ - return LONG_MAX; /* To initialize sys.maxint */ -} - #ifndef NSMALLPOSINTS #define NSMALLPOSINTS 257 #endif Modified: python/branches/py3k/Python/sysmodule.c ============================================================================== --- python/branches/py3k/Python/sysmodule.c (original) +++ python/branches/py3k/Python/sysmodule.c Wed Dec 5 00:02:19 2007 @@ -1078,8 +1078,6 @@ PyUnicode_DecodeFSDefault(Py_GetPrefix())); SET_SYS_FROM_STRING("exec_prefix", PyUnicode_DecodeFSDefault(Py_GetExecPrefix())); - SET_SYS_FROM_STRING("maxint", - PyLong_FromLong(PyInt_GetMax())); SET_SYS_FROM_STRING("maxsize", PyLong_FromSsize_t(PY_SSIZE_T_MAX)); SET_SYS_FROM_STRING("float_info", Modified: python/branches/py3k/Tools/scripts/h2py.py ============================================================================== --- python/branches/py3k/Tools/scripts/h2py.py (original) +++ python/branches/py3k/Tools/scripts/h2py.py Wed Dec 5 00:02:19 2007 @@ -96,13 +96,13 @@ body = p_char.sub('ord(\\0)', body) # Compute negative hexadecimal constants start = 0 - UMAX = 2*(sys.maxint+1) + UMAX = 2*(sys.maxsize+1) while 1: m = p_hex.search(body, start) if not m: break s,e = m.span() val = long(body[slice(*m.span(1))], 16) - if val > sys.maxint: + if val > sys.maxsize: val -= UMAX body = body[:s] + "(" + str(val) + ")" + body[e:] start = s + 1 Modified: python/branches/py3k/Tools/unicode/makeunicodedata.py ============================================================================== --- python/branches/py3k/Tools/unicode/makeunicodedata.py (original) +++ python/branches/py3k/Tools/unicode/makeunicodedata.py Wed Dec 5 00:02:19 2007 @@ -948,7 +948,7 @@ n >>= 1 maxshift += 1 del n - bytes = sys.maxint # smallest total size so far + bytes = sys.maxsize # smallest total size so far t = tuple(t) # so slices can be dict keys for shift in range(maxshift + 1): t1 = [] Modified: python/branches/py3k/setup.py ============================================================================== --- python/branches/py3k/setup.py (original) +++ python/branches/py3k/setup.py Wed Dec 5 00:02:19 2007 @@ -1074,7 +1074,7 @@ ['cjkcodecs/_codecs_%s.c' % loc])) # Dynamic loading module - if sys.maxint == 0x7fffffff: + if sys.maxsize == 0x7fffffff: # This requires sizeof(int) == sizeof(long) == sizeof(char*) dl_inc = find_file('dlfcn.h', [], inc_dirs) if (dl_inc is not None) and (platform not in ['atheos']): From python-3000-checkins at python.org Wed Dec 5 04:38:10 2007 From: python-3000-checkins at python.org (bill.janssen) Date: Wed, 5 Dec 2007 04:38:10 +0100 (CET) Subject: [Python-3000-checkins] r59340 - in python/branches/py3k: Doc/library/ssl.rst Lib/ssl.py Message-ID: <20071205033810.BC1E81E4016@bag.python.org> Author: bill.janssen Date: Wed Dec 5 04:38:10 2007 New Revision: 59340 Modified: python/branches/py3k/Doc/library/ssl.rst python/branches/py3k/Lib/ssl.py Log: most recent changes to SSL module to support non-blocking sockets properly Modified: python/branches/py3k/Doc/library/ssl.rst ============================================================================== --- python/branches/py3k/Doc/library/ssl.rst (original) +++ python/branches/py3k/Doc/library/ssl.rst Wed Dec 5 04:38:10 2007 @@ -51,7 +51,7 @@ network connection. This error is a subtype of :exc:`socket.error`, which in turn is a subtype of :exc:`IOError`. -.. function:: wrap_socket (sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version={see docs}, ca_certs=None) +.. function:: wrap_socket (sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version={see docs}, ca_certs=None, do_handshake_on_connect=True, suppress_ragged_eofs=True) Takes an instance ``sock`` of :class:`socket.socket`, and returns an instance of :class:`ssl.SSLSocket`, a subtype of :class:`socket.socket`, which wraps the underlying socket in an SSL context. @@ -118,6 +118,18 @@ `*` In some older versions of OpenSSL (for instance, 0.9.7l on OS X 10.4), an SSLv2 client could not connect to an SSLv23 server. + The parameter ``do_handshake_on_connect`` specifies whether to do the SSL + handshake automatically after doing a :meth:`socket.connect`, or whether the + application program will call it explicitly, by invoking the :meth:`SSLSocket.do_handshake` + method. Calling :meth:`SSLSocket.do_handshake` explicitly gives the program control over + the blocking behavior of the socket I/O involved in the handshake. + + The parameter ``suppress_ragged_eofs`` specifies how the :meth:`SSLSocket.read` + method should signal unexpected EOF from the other end of the connection. If specified + as :const:`True` (the default), it returns a normal EOF in response to unexpected + EOF errors raised from the underlying socket; if :const:`False`, it will raise + the exceptions back the caller. + .. function:: RAND_status() Returns True if the SSL pseudo-random number generator has been @@ -231,15 +243,41 @@ SSLSocket Objects ----------------- -.. method:: SSLSocket.read([nbytes=1024]) +.. method:: SSLSocket.read(nbytes=1024, buffer=None) Reads up to ``nbytes`` bytes from the SSL-encrypted channel and returns them. + If the ``buffer`` is specified, it will attempt to read into the buffer + the minimum of the size of the buffer and ``nbytes``, if that is specified. + If no buffer is specified, an immutable buffer is allocated and returned + with the data read from the socket. .. method:: SSLSocket.write(data) Writes the ``data`` to the other side of the connection, using the SSL channel to encrypt. Returns the number of bytes written. +.. method:: SSLSocket.do_handshake() + + Performs the SSL setup handshake. If the socket is non-blocking, + this method may raise :exc:`SSLError` with the value of the exception + instance's ``args[0]`` + being either :const:`SSL_ERROR_WANT_READ` or + :const:`SSL_ERROR_WANT_WRITE`, and should be called again until + it stops raising those exceptions. Here's an example of how to do + that:: + + while True: + try: + sock.do_handshake() + break + except ssl.SSLError as err: + if err.args[0] == ssl.SSL_ERROR_WANT_READ: + select.select([sock], [], []) + elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE: + select.select([], [sock], []) + else: + raise + .. method:: SSLSocket.getpeercert(binary_form=False) If there is no certificate for the peer on the other end of the Modified: python/branches/py3k/Lib/ssl.py ============================================================================== --- python/branches/py3k/Lib/ssl.py (original) +++ python/branches/py3k/Lib/ssl.py Wed Dec 5 04:38:10 2007 @@ -126,12 +126,20 @@ keyfile, certfile, cert_reqs, ssl_version, ca_certs) if do_handshake_on_connect: + timeout = self.gettimeout() + if timeout == 0.0: + # non-blocking + raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") self.do_handshake() + except socket_error as x: self.close() raise x - self._base = sock + if sock and (self.fileno() != sock.fileno()): + self._base = sock + else: + self._base = None self.keyfile = keyfile self.certfile = certfile self.cert_reqs = cert_reqs @@ -148,7 +156,7 @@ # raise an exception here if you wish to check for spurious closes pass - def read(self, len=1024, buffer=None): + def read(self, len=None, buffer=None): """Read up to LEN bytes and return them. Return zero-length string on EOF.""" @@ -157,7 +165,7 @@ if buffer: return self._sslobj.read(buffer, len) else: - return self._sslobj.read(len) + return self._sslobj.read(len or 1024) except SSLError as x: if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: return b'' @@ -296,16 +304,18 @@ # self._closed = True if self._base: self._base.close() - socket._real_close(self) + socket.close(self) - def do_handshake(self): + def do_handshake(self, block=False): """Perform a TLS/SSL handshake.""" + timeout = self.gettimeout() try: + if timeout == 0.0 and block: + self.settimeout(None) self._sslobj.do_handshake() - except: - self._sslobj = None - raise + finally: + self.settimeout(timeout) def connect(self, addr): """Connects to remote ADDR, and then wraps the connection in @@ -339,15 +349,20 @@ addr) + def __del__(self): + self._real_close() + def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, - do_handshake_on_connect=True): + do_handshake_on_connect=True, + suppress_ragged_eofs=True): return SSLSocket(sock=sock, keyfile=keyfile, certfile=certfile, server_side=server_side, cert_reqs=cert_reqs, ssl_version=ssl_version, ca_certs=ca_certs, - do_handshake_on_connect=do_handshake_on_connect) + do_handshake_on_connect=do_handshake_on_connect, + suppress_ragged_eofs=suppress_ragged_eofs) # some utility functions From python-3000-checkins at python.org Wed Dec 5 06:14:58 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 5 Dec 2007 06:14:58 +0100 (CET) Subject: [Python-3000-checkins] r59341 - python/branches/py3k/Python/pythonrun.c Message-ID: <20071205051458.EE49A1E4016@bag.python.org> Author: guido.van.rossum Date: Wed Dec 5 06:14:58 2007 New Revision: 59341 Modified: python/branches/py3k/Python/pythonrun.c Log: Solve issue 1400 at least in part -- whenever we run Python code, at the end we also flush stderr and stdout. (XXX this may override errors if there's a problem flushing.) Modified: python/branches/py3k/Python/pythonrun.c ============================================================================== --- python/branches/py3k/Python/pythonrun.c (original) +++ python/branches/py3k/Python/pythonrun.c Wed Dec 5 06:14:58 2007 @@ -1442,6 +1442,28 @@ return ret; } +static void +flush_io(void) +{ + PyObject *f, *r; + f = PySys_GetObject("stderr"); + if (f != NULL) { + r = PyObject_CallMethod(f, "flush", ""); + if (r) + Py_DECREF(r); + else + PyErr_Clear(); + } + f = PySys_GetObject("stdout"); + if (f != NULL) { + r = PyObject_CallMethod(f, "flush", ""); + if (r) + Py_DECREF(r); + else + PyErr_Clear(); + } +} + static PyObject * run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals, PyCompilerFlags *flags, PyArena *arena) @@ -1453,6 +1475,7 @@ return NULL; v = PyEval_EvalCode(co, globals, locals); Py_DECREF(co); + flush_io(); return v; } @@ -1485,6 +1508,7 @@ if (v && flags) flags->cf_flags |= (co->co_flags & PyCF_MASK); Py_DECREF(co); + flush_io(); return v; } From python-3000-checkins at python.org Wed Dec 5 07:08:21 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 5 Dec 2007 07:08:21 +0100 (CET) Subject: [Python-3000-checkins] r59342 - python/branches/py3k/Lib/test/output/test_cProfile python/branches/py3k/Lib/test/output/test_profile Message-ID: <20071205060821.B27451E4016@bag.python.org> Author: guido.van.rossum Date: Wed Dec 5 07:08:21 2007 New Revision: 59342 Modified: python/branches/py3k/Lib/test/output/test_cProfile python/branches/py3k/Lib/test/output/test_profile Log: Believe it or not, the addition of flush() calls broke two unittests. This fixes them (by updating the "golden" output file). Modified: python/branches/py3k/Lib/test/output/test_cProfile ============================================================================== --- python/branches/py3k/Lib/test/output/test_cProfile (original) +++ python/branches/py3k/Lib/test/output/test_cProfile Wed Dec 5 07:08:21 2007 @@ -1,10 +1,14 @@ test_cProfile - 119 function calls (99 primitive calls) in 1.000 CPU seconds + 124 function calls (104 primitive calls) in 1.000 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.000 1.000 :1() + 2 0.000 0.000 0.000 0.000 io.py:1193(flush) + 1 0.000 0.000 0.000 0.000 io.py:257(flush) + 1 0.000 0.000 0.000 0.000 io.py:644(closed) + 1 0.000 0.000 0.000 0.000 io.py:862(flush) 8 0.064 0.008 0.080 0.010 test_cProfile.py:103(subhelper) 28 0.028 0.001 0.028 0.001 test_cProfile.py:115(__getattr__) 1 0.270 0.270 1.000 1.000 test_cProfile.py:30(testfunc) @@ -26,6 +30,11 @@ Function called... ncalls tottime cumtime :1() -> 1 0.270 1.000 test_cProfile.py:30(testfunc) +io.py:1193(flush) -> 1 0.000 0.000 io.py:257(flush) + 1 0.000 0.000 io.py:862(flush) +io.py:257(flush) -> +io.py:644(closed) -> +io.py:862(flush) -> 1 0.000 0.000 io.py:644(closed) test_cProfile.py:103(subhelper) -> 16 0.016 0.016 test_cProfile.py:115(__getattr__) test_cProfile.py:115(__getattr__) -> test_cProfile.py:30(testfunc) -> 1 0.014 0.130 test_cProfile.py:40(factorial) @@ -44,6 +53,7 @@ test_cProfile.py:93(helper2) -> 8 0.064 0.080 test_cProfile.py:103(subhelper) 8 0.000 0.008 {hasattr} {exec} -> 1 0.000 1.000 :1() + 2 0.000 0.000 io.py:1193(flush) {hasattr} -> 12 0.012 0.012 test_cProfile.py:115(__getattr__) {method 'append' of 'list' objects} -> {method 'disable' of '_lsprof.Profiler' objects} -> @@ -55,6 +65,10 @@ Function was called by... ncalls tottime cumtime :1() <- 1 0.000 1.000 {exec} +io.py:1193(flush) <- 2 0.000 0.000 {exec} +io.py:257(flush) <- 1 0.000 0.000 io.py:1193(flush) +io.py:644(closed) <- 1 0.000 0.000 io.py:862(flush) +io.py:862(flush) <- 1 0.000 0.000 io.py:1193(flush) test_cProfile.py:103(subhelper) <- 8 0.064 0.080 test_cProfile.py:93(helper2) test_cProfile.py:115(__getattr__) <- 16 0.016 0.016 test_cProfile.py:103(subhelper) 12 0.012 0.012 {hasattr} Modified: python/branches/py3k/Lib/test/output/test_profile ============================================================================== --- python/branches/py3k/Lib/test/output/test_profile (original) +++ python/branches/py3k/Lib/test/output/test_profile Wed Dec 5 07:08:21 2007 @@ -1,5 +1,5 @@ test_profile - 120 function calls (100 primitive calls) in 1.000 CPU seconds + 125 function calls (105 primitive calls) in 1.000 CPU seconds Ordered by: standard name @@ -10,6 +10,10 @@ 12 0.000 0.000 0.012 0.001 :0(hasattr) 1 0.000 0.000 0.000 0.000 :0(setprofile) 1 0.000 0.000 1.000 1.000 :1() + 2 0.000 0.000 0.000 0.000 io.py:1193(flush) + 1 0.000 0.000 0.000 0.000 io.py:257(flush) + 1 0.000 0.000 0.000 0.000 io.py:644(closed) + 1 0.000 0.000 0.000 0.000 io.py:862(flush) 0 0.000 0.000 profile:0(profiler) 1 0.000 0.000 1.000 1.000 profile:0(testfunc()) 8 0.064 0.008 0.080 0.010 test_profile.py:103(subhelper) @@ -29,9 +33,15 @@ :0(append) -> :0(exc_info) -> :0(exec) -> :1()(1) 1.000 + io.py:1193(flush)(2) 0.000 :0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028 :0(setprofile) -> :1() -> test_profile.py:30(testfunc)(1) 1.000 +io.py:1193(flush) -> io.py:257(flush)(1) 0.000 + io.py:862(flush)(1) 0.000 +io.py:257(flush) -> +io.py:644(closed) -> +io.py:862(flush) -> io.py:644(closed)(1) 0.000 profile:0(profiler) -> profile:0(testfunc())(1) 1.000 profile:0(testfunc()) -> :0(exec)(1) 1.000 :0(setprofile)(1) 0.000 @@ -64,6 +74,10 @@ test_profile.py:93(helper2)(8) 0.400 :0(setprofile) <- profile:0(testfunc())(1) 1.000 :1() <- :0(exec)(1) 1.000 +io.py:1193(flush) <- :0(exec)(2) 1.000 +io.py:257(flush) <- io.py:1193(flush)(1) 0.000 +io.py:644(closed) <- io.py:862(flush)(1) 0.000 +io.py:862(flush) <- io.py:1193(flush)(1) 0.000 profile:0(profiler) <- profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400 From python-3000-checkins at python.org Wed Dec 5 10:33:01 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 10:33:01 +0100 (CET) Subject: [Python-3000-checkins] r59344 - python/branches/py3k/Modules/_ctypes/_ctypes.c Message-ID: <20071205093301.0BA541E4016@bag.python.org> Author: christian.heimes Date: Wed Dec 5 10:33:00 2007 New Revision: 59344 Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c Log: Fixed problem with missing PyInt_CheckExact() macro in _ctypes.c Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Wed Dec 5 10:33:00 2007 @@ -954,8 +954,8 @@ StgDictObject *itemdict; PyObject *proto; PyObject *typedict; - int length; - + long length; + int overflow; Py_ssize_t itemsize, itemalign; typedict = PyTuple_GetItem(args, 2); @@ -963,13 +963,18 @@ return NULL; proto = PyDict_GetItemString(typedict, "_length_"); /* Borrowed ref */ - if (!proto || !PyInt_CheckExact(proto)) { + if (!proto || !PyLong_Check(proto)) { PyErr_SetString(PyExc_AttributeError, "class must define a '_length_' attribute, " "which must be a positive integer"); return NULL; } - length = PyLong_AS_LONG(proto); + length = PyLong_AsLongAndOverflow(proto, &overflow); + if (overflow) { + PyErr_SetString(PyExc_OverflowError, + "The '_length_' attribute is too large"); + return NULL; + } proto = PyDict_GetItemString(typedict, "_type_"); /* Borrowed ref */ if (!proto) { From python-3000-checkins at python.org Wed Dec 5 10:34:12 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 10:34:12 +0100 (CET) Subject: [Python-3000-checkins] r59345 - in python/branches/py3k: PCbuild9/_sqlite3.vcproj PCbuild9/build_tkinter.py Tools/pybench/pybench.py Message-ID: <20071205093412.768671E4016@bag.python.org> Author: christian.heimes Date: Wed Dec 5 10:34:12 2007 New Revision: 59345 Modified: python/branches/py3k/PCbuild9/_sqlite3.vcproj python/branches/py3k/PCbuild9/build_tkinter.py python/branches/py3k/Tools/pybench/pybench.py Log: Fixed quoting and paths in the sqlite project file Modified: python/branches/py3k/PCbuild9/_sqlite3.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/_sqlite3.vcproj (original) +++ python/branches/py3k/PCbuild9/_sqlite3.vcproj Wed Dec 5 10:34:12 2007 @@ -54,7 +54,7 @@ 0.1: From python-3000-checkins at python.org Wed Dec 5 10:36:42 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 10:36:42 +0100 (CET) Subject: [Python-3000-checkins] r59346 - in python/branches/py3k: PCbuild9/build_tkinter.py Tools/pybench/pybench.py Message-ID: <20071205093642.7E6051E4016@bag.python.org> Author: christian.heimes Date: Wed Dec 5 10:36:42 2007 New Revision: 59346 Modified: python/branches/py3k/PCbuild9/build_tkinter.py python/branches/py3k/Tools/pybench/pybench.py Log: Reverted two commit accidents Modified: python/branches/py3k/PCbuild9/build_tkinter.py ============================================================================== --- python/branches/py3k/PCbuild9/build_tkinter.py (original) +++ python/branches/py3k/PCbuild9/build_tkinter.py Wed Dec 5 10:36:42 2007 @@ -12,12 +12,12 @@ here = os.path.abspath(os.path.dirname(__file__)) par = os.path.pardir -TCL = "tcl8.4.16" -TIX = "Tix8.4.2" -TK = "tk8.4.16" -#TCL = "tcl8.4.12" -#TIX = "Tix8.4.0" -#TK = "tk8.4.12" +#TCL = "tcl8.4.16" +#TIX = "Tix8.4.2" +#TK = "tk8.4.16" +TCL = "tcl8.4.12" +TIX = "Tix8.4.0" +TK = "tk8.4.12" ROOT = os.path.abspath(os.path.join(here, par, par)) NMAKE = "nmake /nologo " Modified: python/branches/py3k/Tools/pybench/pybench.py ============================================================================== --- python/branches/py3k/Tools/pybench/pybench.py (original) +++ python/branches/py3k/Tools/pybench/pybench.py Wed Dec 5 10:36:42 2007 @@ -301,7 +301,6 @@ if _debug: print('Calib. overhead time = %.6fms' % ( min_overhead * MILLI_SECONDS)) - return if min_overhead < 0.0: raise ValueError('calibration setup did not work') if max_overhead - min_overhead > 0.1: From python-3000-checkins at python.org Wed Dec 5 13:45:56 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 13:45:56 +0100 (CET) Subject: [Python-3000-checkins] r59349 - python/branches/py3k/Lib/test/regrtest.py Message-ID: <20071205124556.62F811E4018@bag.python.org> Author: christian.heimes Date: Wed Dec 5 13:45:55 2007 New Revision: 59349 Modified: python/branches/py3k/Lib/test/regrtest.py Log: Fixed two small problems in regrtest found by Amaury. This fixes issue #1539. Thanks Amaury! Modified: python/branches/py3k/Lib/test/regrtest.py ============================================================================== --- python/branches/py3k/Lib/test/regrtest.py (original) +++ python/branches/py3k/Lib/test/regrtest.py Wed Dec 5 13:45:55 2007 @@ -701,7 +701,7 @@ pic = sys.path_importer_cache.copy() abcs = {} for abc in [getattr(_abcoll, a) for a in _abcoll.__all__]: - if not isinstance(abc, _Abstract): + if not issubclass(abc, _Abstract): continue for obj in abc.__subclasses__() + [abc]: abcs[obj] = obj._abc_registry.copy() @@ -743,6 +743,7 @@ import struct, filecmp, _abcoll from abc import _Abstract from distutils.dir_util import _path_created + from weakref import WeakSet # Restore some original values. warnings.filters[:] = fs @@ -756,7 +757,7 @@ if not issubclass(abc, _Abstract): continue for obj in abc.__subclasses__() + [abc]: - obj._abc_registry = abcs.get(obj, {}).copy() + obj._abc_registry = abcs.get(obj, WeakSet()).copy() obj._abc_cache.clear() obj._abc_negative_cache.clear() From python-3000-checkins at python.org Wed Dec 5 14:24:28 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 14:24:28 +0100 (CET) Subject: [Python-3000-checkins] r59353 - python/branches/py3k/Lib/test/test_io.py Message-ID: <20071205132428.C05EE1E4032@bag.python.org> Author: christian.heimes Date: Wed Dec 5 14:24:28 2007 New Revision: 59353 Modified: python/branches/py3k/Lib/test/test_io.py Log: Fixed line separator problem on Windows Modified: python/branches/py3k/Lib/test/test_io.py ============================================================================== --- python/branches/py3k/Lib/test/test_io.py (original) +++ python/branches/py3k/Lib/test/test_io.py Wed Dec 5 14:24:28 2007 @@ -528,13 +528,13 @@ t = io.TextIOWrapper(b, encoding="ascii", errors="ignore") t.write("abc\xffdef\n") t.flush() - self.assertEquals(b.getvalue(), b"abcdef\n") + self.assertEquals(b.getvalue(), b"abcdef" + os.linesep.encode()) # (4) replace b = io.BytesIO() t = io.TextIOWrapper(b, encoding="ascii", errors="replace") t.write("abc\xffdef\n") t.flush() - self.assertEquals(b.getvalue(), b"abc?def\n") + self.assertEquals(b.getvalue(), b"abc?def" + os.linesep.encode()) def testNewlinesInput(self): testdata = b"AAA\nBBB\nCCC\rDDD\rEEE\r\nFFF\r\nGGG" From guido at python.org Wed Dec 5 18:22:26 2007 From: guido at python.org (Guido van Rossum) Date: Wed, 5 Dec 2007 09:22:26 -0800 Subject: [Python-3000-checkins] r59353 - python/branches/py3k/Lib/test/test_io.py In-Reply-To: <20071205132428.C05EE1E4032@bag.python.org> References: <20071205132428.C05EE1E4032@bag.python.org> Message-ID: Thanks for fixing this! (Though personally I'd have fixed this by forcing the newline delimiter in the TextIOWrapper() call. What do you think?) On Dec 5, 2007 5:24 AM, christian.heimes wrote: > Author: christian.heimes > Date: Wed Dec 5 14:24:28 2007 > New Revision: 59353 > > Modified: > python/branches/py3k/Lib/test/test_io.py > Log: > Fixed line separator problem on Windows > > Modified: python/branches/py3k/Lib/test/test_io.py > ============================================================================== > --- python/branches/py3k/Lib/test/test_io.py (original) > +++ python/branches/py3k/Lib/test/test_io.py Wed Dec 5 14:24:28 2007 > @@ -528,13 +528,13 @@ > t = io.TextIOWrapper(b, encoding="ascii", errors="ignore") > t.write("abc\xffdef\n") > t.flush() > - self.assertEquals(b.getvalue(), b"abcdef\n") > + self.assertEquals(b.getvalue(), b"abcdef" + os.linesep.encode()) > # (4) replace > b = io.BytesIO() > t = io.TextIOWrapper(b, encoding="ascii", errors="replace") > t.write("abc\xffdef\n") > t.flush() > - self.assertEquals(b.getvalue(), b"abc?def\n") > + self.assertEquals(b.getvalue(), b"abc?def" + os.linesep.encode()) > > def testNewlinesInput(self): > testdata = b"AAA\nBBB\nCCC\rDDD\rEEE\r\nFFF\r\nGGG" > _______________________________________________ > Python-3000-checkins mailing list > Python-3000-checkins at python.org > http://mail.python.org/mailman/listinfo/python-3000-checkins > -- --Guido van Rossum (home page: http://www.python.org/~guido/) From python-3000-checkins at python.org Wed Dec 5 18:59:44 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 18:59:44 +0100 (CET) Subject: [Python-3000-checkins] r59357 - python/branches/py3k/Lib/test/test_io.py Message-ID: <20071205175944.9E6AA1E4002@bag.python.org> Author: christian.heimes Date: Wed Dec 5 18:59:44 2007 New Revision: 59357 Modified: python/branches/py3k/Lib/test/test_io.py Log: You are right, Guido. The newline argument is easier to use. Modified: python/branches/py3k/Lib/test/test_io.py ============================================================================== --- python/branches/py3k/Lib/test/test_io.py (original) +++ python/branches/py3k/Lib/test/test_io.py Wed Dec 5 18:59:44 2007 @@ -525,16 +525,16 @@ self.assertRaises(UnicodeError, t.write, "\xff") # (3) ignore b = io.BytesIO() - t = io.TextIOWrapper(b, encoding="ascii", errors="ignore") + t = io.TextIOWrapper(b, encoding="ascii", errors="ignore", newline="\n") t.write("abc\xffdef\n") t.flush() - self.assertEquals(b.getvalue(), b"abcdef" + os.linesep.encode()) + self.assertEquals(b.getvalue(), b"abcdef\n") # (4) replace b = io.BytesIO() - t = io.TextIOWrapper(b, encoding="ascii", errors="replace") + t = io.TextIOWrapper(b, encoding="ascii", errors="replace", newline="\n") t.write("abc\xffdef\n") t.flush() - self.assertEquals(b.getvalue(), b"abc?def" + os.linesep.encode()) + self.assertEquals(b.getvalue(), b"abc?def\n") def testNewlinesInput(self): testdata = b"AAA\nBBB\nCCC\rDDD\rEEE\r\nFFF\r\nGGG" From python-3000-checkins at python.org Wed Dec 5 19:44:04 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Wed, 5 Dec 2007 19:44:04 +0100 (CET) Subject: [Python-3000-checkins] r59360 - python/branches/py3k/PCbuild9/readme.txt Message-ID: <20071205184404.054681E400F@bag.python.org> Author: martin.v.loewis Date: Wed Dec 5 19:44:03 2007 New Revision: 59360 Modified: python/branches/py3k/PCbuild9/readme.txt Log: Update build instructions Tcl/Tk to use 8.4.12, and python9.mak. Modified: python/branches/py3k/PCbuild9/readme.txt ============================================================================== --- python/branches/py3k/PCbuild9/readme.txt (original) +++ python/branches/py3k/PCbuild9/readme.txt Wed Dec 5 19:44:03 2007 @@ -72,15 +72,15 @@ _tkinter Python wrapper for the Tk windowing system. Requires building - Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.12. + Tcl/Tk first. Following are instructions for Tcl/Tk 8.4.16. NOTE: The 64 build builds must land in tcltk64 instead of tcltk. Get source ---------- In the dist directory, run - svn export http://svn.python.org/projects/external/tcl8.4.12 - svn export http://svn.python.org/projects/external/tk8.4.12 + svn export http://svn.python.org/projects/external/tcl8.4.16 + svn export http://svn.python.org/projects/external/tk8.4.16 svn export http://svn.python.org/projects/external/tix-8.4.0 Build Tcl first (done here w/ MSVC 7.1 on Windows XP) @@ -88,7 +88,7 @@ Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" to get a shell window with the correct environment settings - cd dist\tcl8.4.12\win + cd dist\tcl8.4.16\win nmake -f makefile.vc nmake -f makefile.vc INSTALLDIR=..\..\tcltk install @@ -103,9 +103,9 @@ Build Tk -------- - cd dist\tk8.4.12\win - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 INSTALLDIR=..\..\tcltk install + cd dist\tk8.4.16\win + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 INSTALLDIR=..\..\tcltk install XXX Should we compile with OPTS=threads? @@ -113,7 +113,7 @@ XXX directory. Is all of that really needed for Python use of Tcl/Tk? Optional: run tests, via - nmake -f makefile.vc TCLDIR=..\..\tcl8.4.12 test + nmake -f makefile.vc TCLDIR=..\..\tcl8.4.16 test On WinXP Pro, wholly up to date as of 30-Aug-2004: all.tcl: Total 8420 Passed 6826 Skipped 1581 Failed 13 @@ -123,8 +123,8 @@ Built Tix --------- cd dist\tix-8.4.0\win - nmake -f python.mak - nmake -f python.mak install + nmake -f python9.mak + nmake -f python9.mak install bz2 Python wrapper for the libbz2 compression library. Homepage From python-3000-checkins at python.org Wed Dec 5 20:42:36 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 20:42:36 +0100 (CET) Subject: [Python-3000-checkins] r59365 - python/branches/py3k/Tools Message-ID: <20071205194236.BF18D1E400F@bag.python.org> Author: christian.heimes Date: Wed Dec 5 20:42:36 2007 New Revision: 59365 Modified: python/branches/py3k/Tools/ (props changed) Log: Added 2to3 tools via svn:externals from http://svn.python.org/projects/sandbox/trunk/2to3/ From python-3000-checkins at python.org Wed Dec 5 21:18:39 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 21:18:39 +0100 (CET) Subject: [Python-3000-checkins] r59371 - in python/branches/py3k: Doc/ACKS.txt Doc/c-api/refcounting.rst Doc/documenting/fromlatex.rst Doc/library/csv.rst Doc/library/pprint.rst Doc/library/re.rst Doc/library/traceback.rst Lib/collections.py Lib/distutils/msvc9compiler.py Lib/test/test_collections.py Mac/Modules/osa/_OSAmodule.c PCbuild9/build_tkinter.py PCbuild9/readme.txt Python/ceval.c Message-ID: <20071205201839.819611E4027@bag.python.org> Author: christian.heimes Date: Wed Dec 5 21:18:38 2007 New Revision: 59371 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/c-api/refcounting.rst python/branches/py3k/Doc/documenting/fromlatex.rst python/branches/py3k/Doc/library/csv.rst python/branches/py3k/Doc/library/pprint.rst python/branches/py3k/Doc/library/re.rst python/branches/py3k/Doc/library/traceback.rst python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/distutils/msvc9compiler.py python/branches/py3k/Lib/test/test_collections.py python/branches/py3k/Mac/Modules/osa/_OSAmodule.c python/branches/py3k/PCbuild9/build_tkinter.py python/branches/py3k/PCbuild9/readme.txt python/branches/py3k/Python/ceval.c Log: Merged revisions 59333-59370 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59343 | georg.brandl | 2007-12-05 08:02:47 +0100 (Wed, 05 Dec 2007) | 2 lines Fix typo. ........ r59347 | christian.heimes | 2007-12-05 13:31:44 +0100 (Wed, 05 Dec 2007) | 1 line Fixed quoting and paths in the sqlite project file ........ r59348 | christian.heimes | 2007-12-05 13:45:11 +0100 (Wed, 05 Dec 2007) | 1 line Fixed error in regrtest. I must have missed the spot. ........ r59350 | christian.heimes | 2007-12-05 13:49:14 +0100 (Wed, 05 Dec 2007) | 1 line merge -r59315:59316 from py3k: Fix issue #1553: An errornous __length_hint__ can make list() raise a SystemError ........ r59352 | christian.heimes | 2007-12-05 13:52:34 +0100 (Wed, 05 Dec 2007) | 1 line Added msg to Misc/NEWS ........ r59354 | andrew.kuchling | 2007-12-05 14:27:20 +0100 (Wed, 05 Dec 2007) | 1 line Spelling fix ........ r59356 | georg.brandl | 2007-12-05 18:56:50 +0100 (Wed, 05 Dec 2007) | 3 lines Add examples to csv, pprint and traceback docs. Written by Ross for GHOP. ........ r59358 | raymond.hettinger | 2007-12-05 19:11:08 +0100 (Wed, 05 Dec 2007) | 1 line Error checking was too aggressive (reported by Chris Tismer) ........ r59359 | georg.brandl | 2007-12-05 19:30:48 +0100 (Wed, 05 Dec 2007) | 2 lines Add examples to re docs. Written for GHOP by Dan Finnie. ........ r59366 | georg.brandl | 2007-12-05 20:49:21 +0100 (Wed, 05 Dec 2007) | 2 lines Fix markup. ........ r59367 | christian.heimes | 2007-12-05 20:57:54 +0100 (Wed, 05 Dec 2007) | 1 line Updated documentation and build_tkinter.py script ........ r59368 | georg.brandl | 2007-12-05 21:03:57 +0100 (Wed, 05 Dec 2007) | 2 lines Another markup fix. ........ r59369 | ronald.oussoren | 2007-12-05 21:07:36 +0100 (Wed, 05 Dec 2007) | 7 lines This "fixes" compilation issues for the Carbon._OSA module on OSX Leopard by purging bindings to OSA's debug API's. Those APIs we're completely unsupported on OSX 10.4 and are no longer available on OSX 10.5. Note that this patches a generated file. This is somewhat acceptable because regenerating the file is non-trivial and wouldn't use system headers anyway. ........ r59370 | christian.heimes | 2007-12-05 21:10:38 +0100 (Wed, 05 Dec 2007) | 1 line Fixed bug #1557 by using popen.communicate() before popen.wait() ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Wed Dec 5 21:18:38 2007 @@ -48,6 +48,7 @@ * Carey Evans * Martijn Faassen * Carl Feynman +* Dan Finnie * Hern?n Mart?nez Foffani * Stefan Franke * Jim Fulton Modified: python/branches/py3k/Doc/c-api/refcounting.rst ============================================================================== --- python/branches/py3k/Doc/c-api/refcounting.rst (original) +++ python/branches/py3k/Doc/c-api/refcounting.rst Wed Dec 5 21:18:38 2007 @@ -63,9 +63,9 @@ The following functions are for runtime dynamic embedding of Python: -``Py_IncRef(PyObject \*o)``, `Py_DecRef(PyObject \*o)``. They are simply -exported function versions of :cfunc:`Py_XINCREF` and :cfunc:`Py_XDECREF`, -respectively. +``Py_IncRef(PyObject *o)``, ``Py_DecRef(PyObject *o)``. They are +simply exported function versions of :cfunc:`Py_XINCREF` and +:cfunc:`Py_XDECREF`, respectively. The following functions or macros are only for use within the interpreter core: :cfunc:`_Py_Dealloc`, :cfunc:`_Py_ForgetReference`, :cfunc:`_Py_NewReference`, Modified: python/branches/py3k/Doc/documenting/fromlatex.rst ============================================================================== --- python/branches/py3k/Doc/documenting/fromlatex.rst (original) +++ python/branches/py3k/Doc/documenting/fromlatex.rst Wed Dec 5 21:18:38 2007 @@ -183,8 +183,8 @@ * :file:`ext` -> :file:`extending` * :file:`inst` -> :file:`installing` * :file:`lib` -> :file:`library` -* :file:`mac` -> merged into :file:`library`, with `mac/using.tex` - moved to `howto/pythonmac.rst` +* :file:`mac` -> merged into :file:`library`, with :file:`mac/using.tex` + moved to :file:`howto/pythonmac.rst` * :file:`ref` -> :file:`reference` * :file:`tut` -> :file:`tutorial`, with the single TeX file split up Modified: python/branches/py3k/Doc/library/csv.rst ============================================================================== --- python/branches/py3k/Doc/library/csv.rst (original) +++ python/branches/py3k/Doc/library/csv.rst Wed Dec 5 21:18:38 2007 @@ -43,8 +43,6 @@ .. seealso:: - .. % \seemodule{array}{Arrays of uniformly types numeric values.} - :pep:`305` - CSV File API The Python Enhancement Proposal which proposed this addition to Python. @@ -83,6 +81,15 @@ consequence, if newlines embedded within fields are important, the input should be split into lines in a manner which preserves the newline characters. + A short usage example:: + + >>> import csv + >>> spamReader = csv.reader(open('eggs.csv'), delimiter=' ', quotechar='|') + >>> for row in spamReader: + ... print ', '.join(row) + Spam, Spam, Spam, Spam, Spam, Baked Beans + Spam, Lovely Spam, Wonderful Spam + .. function:: writer(csvfile[, dialect='excel'][, fmtparam]) @@ -103,6 +110,14 @@ CSV files without preprocessing the data returned from a ``cursor.fetch*`` call. All other non-string data are stringified with :func:`str` before being written. + A short usage example:: + + >>> import csv + >>> spamWriter = csv.writer(open('eggs.csv', 'w'), delimiter=' ', + ... quotechar='|', quoting=QUOTE_MINIMAL) + >>> spamWriter.writerow(['Spam'] * 5 + ['Baked Beans']) + >>> spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam']) + .. function:: register_dialect(name[, dialect][, fmtparam]) Modified: python/branches/py3k/Doc/library/pprint.rst ============================================================================== --- python/branches/py3k/Doc/library/pprint.rst (original) +++ python/branches/py3k/Doc/library/pprint.rst Wed Dec 5 21:18:38 2007 @@ -45,30 +45,23 @@ structure cannot be formatted within the constrained width, a best effort will be made. :: - >>> import pprint, sys - >>> stuff = sys.path[:] + >>> import pprint + >>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni'] >>> stuff.insert(0, stuff[:]) >>> pp = pprint.PrettyPrinter(indent=4) >>> pp.pprint(stuff) - [ [ '', - '/usr/local/lib/python1.5', - '/usr/local/lib/python1.5/test', - '/usr/local/lib/python1.5/sunos5', - '/usr/local/lib/python1.5/sharedmodules', - '/usr/local/lib/python1.5/tkinter'], - '', - '/usr/local/lib/python1.5', - '/usr/local/lib/python1.5/test', - '/usr/local/lib/python1.5/sunos5', - '/usr/local/lib/python1.5/sharedmodules', - '/usr/local/lib/python1.5/tkinter'] - >>> - >>> import parser - >>> tup = parser.ast2tuple( - ... parser.suite(open('pprint.py').read()))[1][1][1] + [ ['spam', 'eggs', 'lumberjack', 'knights', 'ni'], + 'spam', + 'eggs', + 'lumberjack', + 'knights', + 'ni'] + >>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', + ... ('parrot', ('fresh fruit',)))))))) >>> pp = pprint.PrettyPrinter(depth=6) >>> pp.pprint(tup) - (266, (267, (307, (287, (288, (...)))))) + ('spam', + ('eggs', ('lumberjack', ('knights', ('ni', ('dead', ('parrot', (...,)))))))) The :class:`PrettyPrinter` class supports several derivative functions: @@ -91,7 +84,8 @@ within a scope). *indent*, *width* and *depth* will be passed to the :class:`PrettyPrinter` constructor as formatting parameters. :: - >>> stuff = sys.path[:] + >>> import pprint + >>> stuff = ['spam', 'eggs', 'lumberjack', 'knights', 'ni'] >>> stuff.insert(0, stuff) >>> pprint.pprint(stuff) [, @@ -200,3 +194,40 @@ is no requested limit. This argument should be passed unmodified to recursive calls. The fourth argument, *level*, gives the current level; recursive calls should be passed a value less than that of the current call. + + +.. _pprint-example: + +pprint Example +-------------- + +This example demonstrates several uses of the :func:`pprint` function and its parameters. + + >>> import pprint + >>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', + ... ('parrot', ('fresh fruit',)))))))) + >>> stuff = ['a' * 10, tup, ['a' * 30, 'b' * 30], ['c' * 20, 'd' * 20]] + >>> pprint.pprint(stuff) + ['aaaaaaaaaa', + ('spam', + ('eggs', + ('lumberjack', + ('knights', ('ni', ('dead', ('parrot', ('fresh fruit',)))))))), + ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'], + ['cccccccccccccccccccc', 'dddddddddddddddddddd']] + >>> pprint.pprint(stuff, depth=3) + ['aaaaaaaaaa', + ('spam', ('eggs', ('lumberjack', (...)))), + ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'], + ['cccccccccccccccccccc', 'dddddddddddddddddddd']] + >>> pprint.pprint(stuff, width=60) + ['aaaaaaaaaa', + ('spam', + ('eggs', + ('lumberjack', + ('knights', + ('ni', ('dead', ('parrot', ('fresh fruit',)))))))), + ['aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', + 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'], + ['cccccccccccccccccccc', 'dddddddddddddddddddd']] + Modified: python/branches/py3k/Doc/library/re.rst ============================================================================== --- python/branches/py3k/Doc/library/re.rst (original) +++ python/branches/py3k/Doc/library/re.rst Wed Dec 5 21:18:38 2007 @@ -31,6 +31,11 @@ newline. Usually patterns will be expressed in Python code using this raw string notation. +It is important to note that most regular expression operations are available as +module-level functions and :class:`RegexObject` methods. The functions are +shortcuts that don't require you to compile a regex object first, but miss some +fine-tuning parameters. + .. seealso:: Mastering Regular Expressions @@ -407,11 +412,9 @@ :: - re.compile("a").match("ba", 1) # succeeds - re.compile("^a").search("ba", 1) # fails; 'a' not at start - re.compile("^a").search("\na", 1) # fails; 'a' not at start - re.compile("^a", re.M).search("\na", 1) # succeeds - re.compile("^a", re.M).search("ba", 1) # fails; no preceding \n + >>> re.match("c", "abcdef") # No match + >>> re.search("c", "abcdef") + <_sre.SRE_Match object at 0x827e9c0> # Match .. _contents-of-module-re: @@ -501,12 +504,13 @@ character class or preceded by an unescaped backslash, all characters from the leftmost such ``'#'`` through the end of the line are ignored. - This means that the two following regular expression objects are equal:: + That means that the two following regular expression objects that match a + decimal number are functionally equal:: - re.compile(r""" [a-z]+ # some letters - \.\. # two dots - [a-z]* # perhaps more letters""") - re.compile(r"[a-z]+\.\.[a-z]*") + a = re.compile(r"""\d + # the integral part + \. # the decimal point + \d * # some fractional digits""", re.X) + b = re.compile(r"\d+\.\d*") .. function:: search(pattern, string[, flags]) @@ -527,7 +531,8 @@ .. note:: - If you want to locate a match anywhere in *string*, use :meth:`search` instead. + If you want to locate a match anywhere in *string*, use :meth:`search` + instead. .. function:: split(pattern, string[, maxsplit=0]) @@ -655,7 +660,8 @@ .. note:: - If you want to locate a match anywhere in *string*, use :meth:`search` instead. + If you want to locate a match anywhere in *string*, use :meth:`search` + instead. The optional second parameter *pos* gives an index in the string where the search is to start; it defaults to ``0``. This is not completely equivalent to @@ -668,7 +674,12 @@ from *pos* to ``endpos - 1`` will be searched for a match. If *endpos* is less than *pos*, no match will be found, otherwise, if *rx* is a compiled regular expression object, ``rx.match(string, 0, 50)`` is equivalent to - ``rx.match(string[:50], 0)``. + ``rx.match(string[:50], 0)``. :: + + >>> pattern = re.compile("o") + >>> pattern.match("dog") # No match as "o" is not at the start of "dog." + >>> pattern.match("dog", 1) # Match as "o" is the 2nd character of "dog". + <_sre.SRE_Match object at 0x827eb10> .. method:: RegexObject.search(string[, pos[, endpos]]) @@ -756,7 +767,17 @@ pattern, an :exc:`IndexError` exception is raised. If a group is contained in a part of the pattern that did not match, the corresponding result is ``None``. If a group is contained in a part of the pattern that matched multiple times, - the last match is returned. + the last match is returned. :: + + >>> m = re.match(r"(\w+) (\w+)", "Isaac Newton, physicist") + >>> m.group(0) + 'Isaac Newton' # The entire match + >>> m.group(1) + 'Isaac' # The first parenthesized subgroup. + >>> m.group(2) + 'Newton' # The second parenthesized subgroup. + >>> m.group(1, 2) + ('Isaac', 'Newton') # Multiple arguments give us a tuple. If the regular expression uses the ``(?P...)`` syntax, the *groupN* arguments may also be strings identifying groups by their group name. If a @@ -765,10 +786,23 @@ A moderately complicated example:: - m = re.match(r"(?P\d+)\.(\d*)", '3.14') - - After performing this match, ``m.group(1)`` is ``'3'``, as is - ``m.group('int')``, and ``m.group(2)`` is ``'14'``. + >>> m = re.match(r"(?P\w+) (?P\w+)", "Malcom Reynolds") + >>> m.group('first_name') + 'Malcom' + >>> m.group('last_name') + 'Reynolds' + + Named groups can also be referred to by their index:: + + >>> m.group(1) + 'Malcom' + >>> m.group(2) + 'Reynolds' + + If a group matches multiple times, only the last match is accessible:: + >>> m = re.match(r"(..)+", "a1b2c3") # Matches 3 times. + >>> m.group(1) # Returns only the last match. + 'c3' .. method:: MatchObject.groups([default]) @@ -780,12 +814,32 @@ string would be returned instead. In later versions (from 1.5.1 on), a singleton tuple is returned in such cases.) + For example:: + + >>> m = re.match(r"(\d+)\.(\d+)", "24.1632") + >>> m.groups() + ('24', '1632') + + If we make the decimal place and everything after it optional, not all groups + might participate in the match. These groups will default to ``None`` unless + the *default* argument is given:: + + >>> m = re.match(r"(\d+)\.?(\d+)?", "24") + >>> m.groups() + ('24', None) # Second group defaults to None. + >>> m.groups('0') + ('24', '0') # Now, the second group defaults to '0'. + .. method:: MatchObject.groupdict([default]) Return a dictionary containing all the *named* subgroups of the match, keyed by the subgroup name. The *default* argument is used for groups that did not - participate in the match; it defaults to ``None``. + participate in the match; it defaults to ``None``. For example:: + + >>> m = re.match(r"(?P\w+) (?P\w+)", "Malcom Reynolds") + >>> m.groupdict() + {'first_name': 'Malcom', 'last_name': 'Reynolds'} .. method:: MatchObject.start([group]) @@ -804,12 +858,19 @@ ``m.start(0)`` is 1, ``m.end(0)`` is 2, ``m.start(1)`` and ``m.end(1)`` are both 2, and ``m.start(2)`` raises an :exc:`IndexError` exception. + An example that will remove *remove_this* from email addresses:: + + >>> email = "tony at tiremove_thisger.net" + >>> m = re.search("remove_this", email) + >>> email[:m.start()] + email[m.end():] + 'tony at tiger.net' + .. method:: MatchObject.span([group]) For :class:`MatchObject` *m*, return the 2-tuple ``(m.start(group), m.end(group))``. Note that if *group* did not contribute to the match, this is - ``(-1, -1)``. Again, *group* defaults to zero. + ``(-1, -1)``. *group* defaults to zero, the entire match. .. attribute:: MatchObject.pos @@ -855,7 +916,62 @@ Examples -------- -**Simulating scanf()** + +Checking For a Pair +^^^^^^^^^^^^^^^^^^^ + +In this example, we'll use the following helper function to display match +objects a little more gracefully:: + + def displaymatch(match): + if match is None: + return None + return '' % (match.group(), match.groups()) + +Suppose you are writing a poker program where a player's hand is represented as +a 5-character string with each character representing a card, "a" for ace, "k" +for king, "q" for queen, j for jack, "0" for 10, and "1" through "9" +representing the card with that value. + +To see if a given string is a valid hand, one could do the following:: + + >>> valid = re.compile(r"[0-9akqj]{5}$" + >>> displaymatch(valid.match("ak05q")) # Valid. + + >>> displaymatch(valid.match("ak05e")) # Invalid. + >>> displaymatch(valid.match("ak0")) # Invalid. + >>> displaymatch(valid.match("727ak")) # Valid. + + +That last hand, ``"727ak"``, contained a pair, or two of the same valued cards. +To match this with a regular expression, one could use backreferences as such:: + + >>> pair = re.compile(r".*(.).*\1") + >>> displaymatch(pair.match("717ak")) # Pair of 7s. + + >>> displaymatch(pair.match("718ak")) # No pairs. + >>> displaymatch(pair.match("354aa")) # Pair of aces. + + +To find out what card the pair consists of, one could use the :func:`group` +method of :class:`MatchObject` in the following manner:: + + >>> pair.match("717ak").group(1) + '7' + + # Error because re.match() returns None, which doesn't have a group() method: + >>> pair.match("718ak").group(1) + Traceback (most recent call last): + File "", line 1, in + re.match(r".*(.).*\1", "718ak").group(1) + AttributeError: 'NoneType' object has no attribute 'group' + + >>> pair.match("354aa").group(1) + 'a' + + +Simulating scanf() +^^^^^^^^^^^^^^^^^^ .. index:: single: scanf() @@ -899,7 +1015,9 @@ (\S+) - (\d+) errors, (\d+) warnings -**Avoiding recursion** + +Avoiding recursion +^^^^^^^^^^^^^^^^^^ If you create regular expressions that require the engine to perform a lot of recursion, you may encounter a :exc:`RuntimeError` exception with the message @@ -921,3 +1039,148 @@ being recast as ``Begin [a-zA-Z0-9_ ]*?end``. As a further benefit, such regular expressions will run faster than their recursive equivalents. + +search() vs. match() +^^^^^^^^^^^^^^^^^^^^ + +In a nutshell, :func:`match` only attempts to match a pattern at the beginning +of a string where :func:`search` will match a pattern anywhere in a string. +For example:: + + >>> re.match("o", "dog") # No match as "o" is not the first letter of "dog". + >>> re.search("o", "dog") # Match as search() looks everywhere in the string. + <_sre.SRE_Match object at 0x827e9f8> + +.. note:: + + The following applies only to regular expression objects like those created + with ``re.compile("pattern")``, not the primitives + ``re.match(pattern, string)`` or ``re.search(pattern, string)``. + +:func:`match` has an optional second parameter that gives an index in the string +where the search is to start:: + + >>> pattern = re.compile("o") + >>> pattern.match("dog") # No match as "o" is not at the start of "dog." + # Equivalent to the above expression as 0 is the default starting index: + >>> pattern.match("dog", 0) + # Match as "o" is the 2nd character of "dog" (index 0 is the first): + >>> pattern.match("dog", 1) + <_sre.SRE_Match object at 0x827eb10> + >>> pattern.match("dog", 2) # No match as "o" is not the 3rd character of "dog." + + +Making a Phonebook +^^^^^^^^^^^^^^^^^^ + +:func:`split` splits a string into a list delimited by the passed pattern. The +method is invaluable for converting textual data into data structures that can be +easily read and modified by Python as demonstrated in the following example that +creates a phonebook. + +First, get the input using triple-quoted string syntax:: + + >>> input = """Ross McFluff 834.345.1254 155 Elm Street + Ronald Heathmore 892.345.3428 436 Finley Avenue + Frank Burger 925.541.7625 662 South Dogwood Way + Heather Albrecht 548.326.4584 919 Park Place""" + +Then, convert the string into a list with each line having its own entry:: + + >>> entries = re.split("\n", input) + >>> entries + ['Ross McFluff 834.345.1254 155 Elm Street', + 'Ronald Heathmore 892.345.3428 436 Finley Avenue', + 'Frank Burger 925.541.7625 662 South Dogwood Way', + 'Heather Albrecht 548.326.4584 919 Park Place'] + +Finally, split each entry into a list with first name, last name, telephone +number, and address. We use the ``maxsplit`` paramater of :func:`split` +because the address has spaces, our splitting pattern, in it:: + + >>> [re.split(" ", entry, 3) for entry in entries] + [['Ross', 'McFluff', '834.345.1254', '155 Elm Street'], + ['Ronald', 'Heathmore', '892.345.3428', '436 Finley Avenue'], + ['Frank', 'Burger', '925.541.7625', '662 South Dogwood Way'], + ['Heather', 'Albrecht', '548.326.4584', '919 Park Place']] + +With a ``maxsplit`` of ``4``, we could seperate the house number from the street +name:: + + >>> [re.split(" ", entry, 4) for entry in entries] + [['Ross', 'McFluff', '834.345.1254', '155', 'Elm Street'], + ['Ronald', 'Heathmore', '892.345.3428', '436', 'Finley Avenue'], + ['Frank', 'Burger', '925.541.7625', '662', 'South Dogwood Way'], + ['Heather', 'Albrecht', '548.326.4584', '919', 'Park Place']] + + +Text Munging +^^^^^^^^^^^^ + +:func:`sub` replaces every occurrence of a pattern with a string or the +result of a function. This example demonstrates using :func:`sub` with +a function to "munge" text, or randomize the order of all the characters +in each word of a sentence except for the first and last characters:: + + >>> def repl(m): + ... inner_word = list(m.group(2)) + ... random.shuffle(inner_word) + ... return m.group(1) + "".join(inner_word) + m.group(3) + >>> text = "Professor Abdolmalek, please report your absences promptly." + >>> re.sub("(\w)(\w+)(\w)", repl, text) + 'Poefsrosr Aealmlobdk, pslaee reorpt your abnseces plmrptoy.' + >>> re.sub("(\w)(\w+)(\w)", repl, text) + 'Pofsroser Aodlambelk, plasee reoprt yuor asnebces potlmrpy.' + + +Finding all Adverbs +^^^^^^^^^^^^^^^^^^^ + +:func:`findall` matches *all* occurences of a pattern, not just the first +one as :func:`search` does. For example, if one was a writer and wanted to +find all of the adverbs in some text, he or she might use :func:`findall` in +the following manner:: + + >>> text = "He was carefully disguised but captured quickly by police." + >>> re.findall(r"\w+ly", text) + ['carefully', 'quickly'] + + +Finding all Adverbs and their Positions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If one wants more information about all matches of a pattern than the matched +text, :func:`finditer` is useful as it provides instances of +:class:`MatchObject` instead of strings. Continuing with the previous example, +if one was a writer who wanted to find all of the adverbs *and their positions* +in some text, he or she would use :func:`finditer` in the following manner:: + + >>> text = "He was carefully disguised but captured quickly by police." + >>> for m in re.finditer(r"\w+ly", text): + print '%02d-%02d: %s' % (m.start(), m.end(), m.group(0)) + 07-16: carefully + 40-47: quickly + + +Raw String Notation +^^^^^^^^^^^^^^^^^^^ + +Raw string notation (``r"text"``) keeps regular expressions sane. Without it, +every backslash (``'\'``) in a regular expression would have to be prefixed with +another one to escape it. For example, the two following lines of code are +functionally identical:: + + >>> re.match(r"\W(.)\1\W", " ff ") + <_sre.SRE_Match object at 0x8262760> + >>> re.match("\\W(.)\\1\\W", " ff ") + <_sre.SRE_Match object at 0x82627a0> + +When one wants to match a literal backslash, it must be escaped in the regular +expression. With raw string notation, this means ``r"\\"``. Without raw string +notation, one must use ``"\\\\"``, making the following lines of code +functionally identical:: + + >>> re.match(r"\\", r"\\") + <_sre.SRE_Match object at 0x827eb48> + >>> re.match("\\\\", r"\\") + <_sre.SRE_Match object at 0x827ec60> Modified: python/branches/py3k/Doc/library/traceback.rst ============================================================================== --- python/branches/py3k/Doc/library/traceback.rst (original) +++ python/branches/py3k/Doc/library/traceback.rst Wed Dec 5 21:18:38 2007 @@ -132,8 +132,8 @@ .. _traceback-example: -Traceback Example ------------------ +Traceback Examples +------------------ This simple example implements a basic read-eval-print loop, similar to (but less useful than) the standard Python interactive interpreter loop. For a more @@ -156,3 +156,124 @@ while True: run_user_code(envdir) + +The following example demonstrates the different ways to print and format the +exception and traceback:: + + import sys, traceback + + def lumberjack(): + bright_side_of_death() + + def bright_side_of_death(): + return tuple()[0] + + try: + lumberjack() + except: + exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() + print "*** print_tb:" + traceback.print_tb(exceptionTraceback, limit=1, file=sys.stdout) + print "*** print_exception:" + traceback.print_exception(exceptionType, exceptionValue, exceptionTraceback, + limit=2, file=sys.stdout) + print "*** print_exc:" + traceback.print_exc() + print "*** format_exc, first and last line:" + formatted_lines = traceback.format_exc().splitlines() + print formatted_lines[0] + print formatted_lines[-1] + print "*** format_exception:" + print repr(traceback.format_exception(exceptionType, exceptionValue, + exceptionTraceback)) + print "*** extract_tb:" + print repr(traceback.extract_tb(exceptionTraceback)) + print "*** format_tb:" + print repr(traceback.format_tb(exceptionTraceback)) + print "*** tb_lineno:", traceback.tb_lineno(exceptionTraceback) + print "*** print_last:" + traceback.print_last() + + +The output for the example would look similar to this:: + + *** print_tb: + File "", line 9, in + lumberjack() + *** print_exception: + Traceback (most recent call last): + File "", line 9, in + lumberjack() + File "", line 3, in lumberjack + bright_side_of_death() + IndexError: tuple index out of range + *** print_exc: + Traceback (most recent call last): + File "", line 9, in + lumberjack() + File "", line 3, in lumberjack + bright_side_of_death() + IndexError: tuple index out of range + *** format_exc, first and last line: + Traceback (most recent call last): + IndexError: tuple index out of range + *** format_exception: + ['Traceback (most recent call last):\n', + ' File "", line 9, in \n lumberjack()\n', + ' File "", line 3, in lumberjack\n bright_side_of_death()\n', + ' File "", line 6, in bright_side_of_death\n return tuple()[0]\n', + 'IndexError: tuple index out of range\n'] + *** extract_tb: + [('', 9, '', 'lumberjack()'), + ('', 3, 'lumberjack', 'bright_side_of_death()'), + ('', 6, 'bright_side_of_death', 'return tuple()[0]')] + *** format_tb: + [' File "", line 9, in \n lumberjack()\n', + ' File "", line 3, in lumberjack\n bright_side_of_death()\n', + ' File "", line 6, in bright_side_of_death\n return tuple()[0]\n'] + *** tb_lineno: 2 + *** print_last: + Traceback (most recent call last): + File "", line 9, in + lumberjack() + File "", line 3, in lumberjack + bright_side_of_death() + IndexError: tuple index out of range + + +The following example shows the different ways to print and format the stack:: + + >>> import traceback + >>> def another_function(): + ... lumberstack() + ... + >>> def lumberstack(): + ... traceback.print_stack() + ... print repr(traceback.extract_stack()) + ... print repr(traceback.format_stack()) + ... + >>> another_function() + File "", line 10, in + another_function() + File "", line 3, in another_function + lumberstack() + File "", line 6, in lumberstack + traceback.print_stack() + [('', 10, '', 'another_function()'), + ('', 3, 'another_function', 'lumberstack()'), + ('', 7, 'lumberstack', 'print repr(traceback.extract_stack())')] + [' File "", line 10, in \n another_function()\n', + ' File "", line 3, in another_function\n lumberstack()\n', + ' File "", line 8, in lumberstack\n print repr(traceback.format_stack())\n'] + + +This last example demonstrates the final few formatting functions:: + + >>> import traceback + >>> format_list([('spam.py', 3, '', 'spam.eggs()'), + ... ('eggs.py', 42, 'eggs', 'return "bacon"')]) + [' File "spam.py", line 3, in \n spam.eggs()\n', + ' File "eggs.py", line 42, in eggs\n return "bacon"\n'] + >>> theError = IndexError('tuple indx out of range') + >>> traceback.format_exception_only(type(theError), theError) + ['IndexError: tuple index out of range\n'] Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Wed Dec 5 21:18:38 2007 @@ -40,7 +40,7 @@ field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas field_names = tuple(field_names) for name in (typename,) + field_names: - if not name.replace('_', '').isalnum(): + if not all(c.isalnum() or c=='_' for c in name): raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name) if _iskeyword(name): raise ValueError('Type names and field names cannot be a keyword: %r' % name) @@ -48,7 +48,7 @@ raise ValueError('Type names and field names cannot start with a number: %r' % name) seen_names = set() for name in field_names: - if name.startswith('__') and name.endswith('__'): + if name.startswith('__') and name.endswith('__') and len(name) > 3: raise ValueError('Field names cannot start and end with double underscores: %r' % name) if name in seen_names: raise ValueError('Encountered duplicate field name: %r' % name) Modified: python/branches/py3k/Lib/distutils/msvc9compiler.py ============================================================================== --- python/branches/py3k/Lib/distutils/msvc9compiler.py (original) +++ python/branches/py3k/Lib/distutils/msvc9compiler.py Wed Dec 5 21:18:38 2007 @@ -254,10 +254,13 @@ popen = subprocess.Popen('"%s" %s & set' % (vcvarsall, arch), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + stdout, stderr = popen.communicate() if popen.wait() != 0: - raise IOError(popen.stderr.read()) + raise IOError(stderr.decode("mbcs")) - for line in popen.stdout: + stdout = stdout.decode("mbcs") + for line in stdout.split("\n"): line = Reg.convert_mbcs(line) if '=' not in line: continue Modified: python/branches/py3k/Lib/test/test_collections.py ============================================================================== --- python/branches/py3k/Lib/test/test_collections.py (original) +++ python/branches/py3k/Lib/test/test_collections.py Wed Dec 5 21:18:38 2007 @@ -32,6 +32,7 @@ self.assertRaises(ValueError, namedtuple, 'abc', 'efg efg ghi') # duplicate field namedtuple('Point0', 'x1 y2') # Verify that numbers are allowed in names + namedtuple('_', '_ __ ___') # Verify that underscores are allowed def test_instance(self): Point = namedtuple('Point', 'x y') Modified: python/branches/py3k/Mac/Modules/osa/_OSAmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/osa/_OSAmodule.c (original) +++ python/branches/py3k/Mac/Modules/osa/_OSAmodule.c Wed Dec 5 21:18:38 2007 @@ -726,314 +726,6 @@ return _res; } -static PyObject *OSAObj_OSADebuggerCreateSession(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSAID inScript; - OSAID inContext; - OSADebugSessionRef outSession; -#ifndef OSADebuggerCreateSession - PyMac_PRECHECK(OSADebuggerCreateSession); -#endif - if (!PyArg_ParseTuple(_args, "ll", - &inScript, - &inContext)) - return NULL; - _err = OSADebuggerCreateSession(_self->ob_itself, - inScript, - inContext, - &outSession); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - outSession); - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetSessionState(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - AERecord outState; -#ifndef OSADebuggerGetSessionState - PyMac_PRECHECK(OSADebuggerGetSessionState); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inSession)) - return NULL; - _err = OSADebuggerGetSessionState(_self->ob_itself, - inSession, - &outState); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &outState); - return _res; -} - -static PyObject *OSAObj_OSADebuggerSessionStep(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - OSADebugStepKind inKind; -#ifndef OSADebuggerSessionStep - PyMac_PRECHECK(OSADebuggerSessionStep); -#endif - if (!PyArg_ParseTuple(_args, "ll", - &inSession, - &inKind)) - return NULL; - _err = OSADebuggerSessionStep(_self->ob_itself, - inSession, - inKind); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *OSAObj_OSADebuggerDisposeSession(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; -#ifndef OSADebuggerDisposeSession - PyMac_PRECHECK(OSADebuggerDisposeSession); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inSession)) - return NULL; - _err = OSADebuggerDisposeSession(_self->ob_itself, - inSession); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetStatementRanges(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - AEDescList outStatementRangeArray; -#ifndef OSADebuggerGetStatementRanges - PyMac_PRECHECK(OSADebuggerGetStatementRanges); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inSession)) - return NULL; - _err = OSADebuggerGetStatementRanges(_self->ob_itself, - inSession, - &outStatementRangeArray); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &outStatementRangeArray); - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetBreakpoint(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - UInt32 inSrcOffset; - OSAID outBreakpoint; -#ifndef OSADebuggerGetBreakpoint - PyMac_PRECHECK(OSADebuggerGetBreakpoint); -#endif - if (!PyArg_ParseTuple(_args, "ll", - &inSession, - &inSrcOffset)) - return NULL; - _err = OSADebuggerGetBreakpoint(_self->ob_itself, - inSession, - inSrcOffset, - &outBreakpoint); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - outBreakpoint); - return _res; -} - -static PyObject *OSAObj_OSADebuggerSetBreakpoint(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - UInt32 inSrcOffset; - OSAID inBreakpoint; -#ifndef OSADebuggerSetBreakpoint - PyMac_PRECHECK(OSADebuggerSetBreakpoint); -#endif - if (!PyArg_ParseTuple(_args, "lll", - &inSession, - &inSrcOffset, - &inBreakpoint)) - return NULL; - _err = OSADebuggerSetBreakpoint(_self->ob_itself, - inSession, - inSrcOffset, - inBreakpoint); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetDefaultBreakpoint(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - OSAID outBreakpoint; -#ifndef OSADebuggerGetDefaultBreakpoint - PyMac_PRECHECK(OSADebuggerGetDefaultBreakpoint); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inSession)) - return NULL; - _err = OSADebuggerGetDefaultBreakpoint(_self->ob_itself, - inSession, - &outBreakpoint); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - outBreakpoint); - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetCurrentCallFrame(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugSessionRef inSession; - OSADebugCallFrameRef outCallFrame; -#ifndef OSADebuggerGetCurrentCallFrame - PyMac_PRECHECK(OSADebuggerGetCurrentCallFrame); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inSession)) - return NULL; - _err = OSADebuggerGetCurrentCallFrame(_self->ob_itself, - inSession, - &outCallFrame); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - outCallFrame); - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetCallFrameState(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugCallFrameRef inCallFrame; - AERecord outState; -#ifndef OSADebuggerGetCallFrameState - PyMac_PRECHECK(OSADebuggerGetCallFrameState); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inCallFrame)) - return NULL; - _err = OSADebuggerGetCallFrameState(_self->ob_itself, - inCallFrame, - &outState); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("O&", - AEDesc_New, &outState); - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetVariable(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugCallFrameRef inCallFrame; - AEDesc inVariableName; - OSAID outVariable; -#ifndef OSADebuggerGetVariable - PyMac_PRECHECK(OSADebuggerGetVariable); -#endif - if (!PyArg_ParseTuple(_args, "lO&", - &inCallFrame, - AEDesc_Convert, &inVariableName)) - return NULL; - _err = OSADebuggerGetVariable(_self->ob_itself, - inCallFrame, - &inVariableName, - &outVariable); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - outVariable); - return _res; -} - -static PyObject *OSAObj_OSADebuggerSetVariable(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugCallFrameRef inCallFrame; - AEDesc inVariableName; - OSAID inVariable; -#ifndef OSADebuggerSetVariable - PyMac_PRECHECK(OSADebuggerSetVariable); -#endif - if (!PyArg_ParseTuple(_args, "lO&l", - &inCallFrame, - AEDesc_Convert, &inVariableName, - &inVariable)) - return NULL; - _err = OSADebuggerSetVariable(_self->ob_itself, - inCallFrame, - &inVariableName, - inVariable); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - -static PyObject *OSAObj_OSADebuggerGetPreviousCallFrame(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugCallFrameRef inCurrentFrame; - OSADebugCallFrameRef outPrevFrame; -#ifndef OSADebuggerGetPreviousCallFrame - PyMac_PRECHECK(OSADebuggerGetPreviousCallFrame); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inCurrentFrame)) - return NULL; - _err = OSADebuggerGetPreviousCallFrame(_self->ob_itself, - inCurrentFrame, - &outPrevFrame); - if (_err != noErr) return PyMac_Error(_err); - _res = Py_BuildValue("l", - outPrevFrame); - return _res; -} - -static PyObject *OSAObj_OSADebuggerDisposeCallFrame(OSAComponentInstanceObject *_self, PyObject *_args) -{ - PyObject *_res = NULL; - OSAError _err; - OSADebugCallFrameRef inCallFrame; -#ifndef OSADebuggerDisposeCallFrame - PyMac_PRECHECK(OSADebuggerDisposeCallFrame); -#endif - if (!PyArg_ParseTuple(_args, "l", - &inCallFrame)) - return NULL; - _err = OSADebuggerDisposeCallFrame(_self->ob_itself, - inCallFrame); - if (_err != noErr) return PyMac_Error(_err); - Py_INCREF(Py_None); - _res = Py_None; - return _res; -} - static PyMethodDef OSAObj_methods[] = { {"OSALoad", (PyCFunction)OSAObj_OSALoad, 1, PyDoc_STR("(AEDesc scriptData, long modeFlags) -> (OSAID resultingScriptID)")}, @@ -1091,34 +783,6 @@ PyDoc_STR("(AppleEvent theAppleEvent, OSAID contextID, long modeFlags) -> (AppleEvent reply)")}, {"OSAMakeContext", (PyCFunction)OSAObj_OSAMakeContext, 1, PyDoc_STR("(AEDesc contextName, OSAID parentContext) -> (OSAID resultingContextID)")}, - {"OSADebuggerCreateSession", (PyCFunction)OSAObj_OSADebuggerCreateSession, 1, - PyDoc_STR("(OSAID inScript, OSAID inContext) -> (OSADebugSessionRef outSession)")}, - {"OSADebuggerGetSessionState", (PyCFunction)OSAObj_OSADebuggerGetSessionState, 1, - PyDoc_STR("(OSADebugSessionRef inSession) -> (AERecord outState)")}, - {"OSADebuggerSessionStep", (PyCFunction)OSAObj_OSADebuggerSessionStep, 1, - PyDoc_STR("(OSADebugSessionRef inSession, OSADebugStepKind inKind) -> None")}, - {"OSADebuggerDisposeSession", (PyCFunction)OSAObj_OSADebuggerDisposeSession, 1, - PyDoc_STR("(OSADebugSessionRef inSession) -> None")}, - {"OSADebuggerGetStatementRanges", (PyCFunction)OSAObj_OSADebuggerGetStatementRanges, 1, - PyDoc_STR("(OSADebugSessionRef inSession) -> (AEDescList outStatementRangeArray)")}, - {"OSADebuggerGetBreakpoint", (PyCFunction)OSAObj_OSADebuggerGetBreakpoint, 1, - PyDoc_STR("(OSADebugSessionRef inSession, UInt32 inSrcOffset) -> (OSAID outBreakpoint)")}, - {"OSADebuggerSetBreakpoint", (PyCFunction)OSAObj_OSADebuggerSetBreakpoint, 1, - PyDoc_STR("(OSADebugSessionRef inSession, UInt32 inSrcOffset, OSAID inBreakpoint) -> None")}, - {"OSADebuggerGetDefaultBreakpoint", (PyCFunction)OSAObj_OSADebuggerGetDefaultBreakpoint, 1, - PyDoc_STR("(OSADebugSessionRef inSession) -> (OSAID outBreakpoint)")}, - {"OSADebuggerGetCurrentCallFrame", (PyCFunction)OSAObj_OSADebuggerGetCurrentCallFrame, 1, - PyDoc_STR("(OSADebugSessionRef inSession) -> (OSADebugCallFrameRef outCallFrame)")}, - {"OSADebuggerGetCallFrameState", (PyCFunction)OSAObj_OSADebuggerGetCallFrameState, 1, - PyDoc_STR("(OSADebugCallFrameRef inCallFrame) -> (AERecord outState)")}, - {"OSADebuggerGetVariable", (PyCFunction)OSAObj_OSADebuggerGetVariable, 1, - PyDoc_STR("(OSADebugCallFrameRef inCallFrame, AEDesc inVariableName) -> (OSAID outVariable)")}, - {"OSADebuggerSetVariable", (PyCFunction)OSAObj_OSADebuggerSetVariable, 1, - PyDoc_STR("(OSADebugCallFrameRef inCallFrame, AEDesc inVariableName, OSAID inVariable) -> None")}, - {"OSADebuggerGetPreviousCallFrame", (PyCFunction)OSAObj_OSADebuggerGetPreviousCallFrame, 1, - PyDoc_STR("(OSADebugCallFrameRef inCurrentFrame) -> (OSADebugCallFrameRef outPrevFrame)")}, - {"OSADebuggerDisposeCallFrame", (PyCFunction)OSAObj_OSADebuggerDisposeCallFrame, 1, - PyDoc_STR("(OSADebugCallFrameRef inCallFrame) -> None")}, {NULL, NULL, 0} }; Modified: python/branches/py3k/PCbuild9/build_tkinter.py ============================================================================== --- python/branches/py3k/PCbuild9/build_tkinter.py (original) +++ python/branches/py3k/PCbuild9/build_tkinter.py Wed Dec 5 21:18:38 2007 @@ -12,12 +12,10 @@ here = os.path.abspath(os.path.dirname(__file__)) par = os.path.pardir -#TCL = "tcl8.4.16" -#TIX = "Tix8.4.2" -#TK = "tk8.4.16" -TCL = "tcl8.4.12" +TCL = "tcl8.4.16" +TK = "tk8.4.16" TIX = "Tix8.4.0" -TK = "tk8.4.12" +#TIX = "Tix8.4.2" ROOT = os.path.abspath(os.path.join(here, par, par)) NMAKE = "nmake /nologo " @@ -57,9 +55,9 @@ if True: os.chdir(os.path.join(ROOT, TIX, "win")) if clean: - system(NMAKE + "/f makefile.vc clean") - system(NMAKE + "/f makefile.vc MACHINE=%s" % machine) - system(NMAKE + "/f makefile.vc INSTALL_DIR=%s install" % dest) + system(NMAKE + "/f python9.mak clean") + system(NMAKE + "/f python9.mak MACHINE=%s" % machine) + system(NMAKE + "/f python9.mak install") def main(): Modified: python/branches/py3k/PCbuild9/readme.txt ============================================================================== --- python/branches/py3k/PCbuild9/readme.txt (original) +++ python/branches/py3k/PCbuild9/readme.txt Wed Dec 5 21:18:38 2007 @@ -83,10 +83,19 @@ svn export http://svn.python.org/projects/external/tk8.4.16 svn export http://svn.python.org/projects/external/tix-8.4.0 - Build Tcl first (done here w/ MSVC 7.1 on Windows XP) + Build with build_tkinter.py + --------------------------- + The PCbuild9 directory contains a Python script which automates all + steps. Run the script in a Visual Studio 2009 command prompt with + + python build_tkinter.py Win32 + + Use x64 instead of Win32 for the x64 platform. + + Build Tcl first --------------- - Use "Start -> All Programs -> Microsoft Visual Studio .NET 2003 - -> Visual Studio .NET Tools -> Visual Studio .NET 2003 Command Prompt" + Use "Start -> All Programs -> Microsoft Visual Studio 2008 + -> Visual Studio Tools -> Visual Studio 2008 Command Prompt" to get a shell window with the correct environment settings cd dist\tcl8.4.16\win nmake -f makefile.vc Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Wed Dec 5 21:18:38 2007 @@ -625,7 +625,7 @@ next opcode. A successful prediction saves a trip through the eval-loop including - its two unpredictable branches, the HASARG test and the switch-case. + its two unpredictable branches, the HAS_ARG test and the switch-case. If collecting opcode statistics, turn off prediction so that statistics are accurately maintained (the predictions bypass From python-3000-checkins at python.org Wed Dec 5 23:02:31 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 5 Dec 2007 23:02:31 +0100 (CET) Subject: [Python-3000-checkins] r59376 - in python/branches/py3k: Doc/ACKS.txt PCbuild9/bz2.vcproj PCbuild9/pgupdate.vsprops PCbuild9/pyexpat.vcproj PCbuild9/pyproject.vsprops PCbuild9/python.vcproj PCbuild9/pythoncore.vcproj PCbuild9/pythonw.vcproj PCbuild9/readme.txt PCbuild9/w9xpopen.vcproj PCbuild9/x64.vsprops Message-ID: <20071205220231.CDA661E400F@bag.python.org> Author: christian.heimes Date: Wed Dec 5 23:02:31 2007 New Revision: 59376 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/PCbuild9/bz2.vcproj python/branches/py3k/PCbuild9/pgupdate.vsprops python/branches/py3k/PCbuild9/pyexpat.vcproj python/branches/py3k/PCbuild9/pyproject.vsprops python/branches/py3k/PCbuild9/python.vcproj python/branches/py3k/PCbuild9/pythoncore.vcproj python/branches/py3k/PCbuild9/pythonw.vcproj python/branches/py3k/PCbuild9/readme.txt python/branches/py3k/PCbuild9/w9xpopen.vcproj python/branches/py3k/PCbuild9/x64.vsprops Log: Merged revisions 59371-59375 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59374 | georg.brandl | 2007-12-05 22:52:40 +0100 (Wed, 05 Dec 2007) | 2 lines Add Ross Light, a GHOP student, to ACKs. ........ r59375 | christian.heimes | 2007-12-05 22:57:25 +0100 (Wed, 05 Dec 2007) | 2 lines The macros _WIN32, _WIN64 and _M_X64 are defined by the compiler. The VS 2008 IDE doesn't know about (some) of the macros and can display wrong information. In my case a section #ifdef _WIN64 was grayed out although the platform was x64. I've added the macros to pyproject.vsprops and x64.vsprops. I've also added a paragraph about the property files to the readme and fixed the order of pyupdate > pyinstrument. ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Wed Dec 5 23:02:31 2007 @@ -109,6 +109,7 @@ * Glyph Lefkowitz * Robert Lehmann * Marc-Andr? Lemburg +* Ross Light * Ulf A. Lindgren * Everett Lipman * Mirko Liss Modified: python/branches/py3k/PCbuild9/bz2.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/bz2.vcproj (original) +++ python/branches/py3k/PCbuild9/bz2.vcproj Wed Dec 5 23:02:31 2007 @@ -402,7 +402,7 @@ @@ -465,7 +465,7 @@ Modified: python/branches/py3k/PCbuild9/pgupdate.vsprops ============================================================================== --- python/branches/py3k/PCbuild9/pgupdate.vsprops (original) +++ python/branches/py3k/PCbuild9/pgupdate.vsprops Wed Dec 5 23:02:31 2007 @@ -2,7 +2,7 @@ Modified: python/branches/py3k/PCbuild9/pyexpat.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/pyexpat.vcproj (original) +++ python/branches/py3k/PCbuild9/pyexpat.vcproj Wed Dec 5 23:02:31 2007 @@ -390,7 +390,7 @@ @@ -451,7 +451,7 @@ Modified: python/branches/py3k/PCbuild9/pyproject.vsprops ============================================================================== --- python/branches/py3k/PCbuild9/pyproject.vsprops (original) +++ python/branches/py3k/PCbuild9/pyproject.vsprops Wed Dec 5 23:02:31 2007 @@ -12,7 +12,7 @@ InlineFunctionExpansion="1" EnableIntrinsicFunctions="true" AdditionalIncludeDirectories="..\Include; ..\PC" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_WIN32" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" Modified: python/branches/py3k/PCbuild9/python.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/python.vcproj (original) +++ python/branches/py3k/PCbuild9/python.vcproj Wed Dec 5 23:02:31 2007 @@ -318,7 +318,7 @@ @@ -400,7 +400,7 @@ @@ -476,7 +476,7 @@ @@ -550,7 +550,7 @@ Modified: python/branches/py3k/PCbuild9/pythonw.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/pythonw.vcproj (original) +++ python/branches/py3k/PCbuild9/pythonw.vcproj Wed Dec 5 23:02:31 2007 @@ -305,7 +305,7 @@ @@ -377,7 +377,7 @@ @@ -450,7 +450,7 @@ @@ -522,7 +522,7 @@ Modified: python/branches/py3k/PCbuild9/readme.txt ============================================================================== --- python/branches/py3k/PCbuild9/readme.txt (original) +++ python/branches/py3k/PCbuild9/readme.txt Wed Dec 5 23:02:31 2007 @@ -293,6 +293,31 @@ change the "Runtime Library" from "Multi-threaded DLL (/MD)" to "Multi-threaded (/MT)". +Visual Studio properties +------------------------ + +The PCbuild9 solution makes heavy use of Visual Studio property files +(*.vsprops). The properties can be viewed and altered in the Property +Manager (View -> Other Windows -> Property Manager). + + * debug (debug macros) + * pginstrument (PGO) + * pgupdate (PGO) + +-- pginstrument + * pyd (python extension, release build) + +-- release + +-- pyproject + * pyd_d (python extension, debug build) + +-- debug + +-- pyproject + * pyproject (base settings for all projects) + * release (release macros) + * x64 (AMD64 / x64 platform specific settings) + +The pyproject propertyfile defines _WIN32 and x64 defines _WIN64 and _M_X64 +although the macros are set by the compiler, too. The GUI doesn't always know +about the macros and confuse the user with false information. + YOUR OWN EXTENSION DLLs ----------------------- If you want to create your own extension module DLL, there's an example Modified: python/branches/py3k/PCbuild9/w9xpopen.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/w9xpopen.vcproj (original) +++ python/branches/py3k/PCbuild9/w9xpopen.vcproj Wed Dec 5 23:02:31 2007 @@ -285,7 +285,7 @@ Author: guido.van.rossum Date: Thu Dec 6 02:04:26 2007 New Revision: 59379 Modified: python/branches/py3k/Lib/io.py python/branches/py3k/Lib/test/output/test_cProfile python/branches/py3k/Lib/test/output/test_profile python/branches/py3k/Lib/test/test_io.py Log: Fix the rest of issue 1400, by introducing a proper implementation of line buffering. The TextIOWrapper class no longer calls isatty() on every write() call. Modified: python/branches/py3k/Lib/io.py ============================================================================== --- python/branches/py3k/Lib/io.py (original) +++ python/branches/py3k/Lib/io.py Thu Dec 6 02:04:26 2007 @@ -151,8 +151,10 @@ closefd) if buffering is None: buffering = -1 - if buffering < 0 and raw.isatty(): - buffering = 1 + line_buffering = False + if buffering == 1 or buffering < 0 and raw.isatty(): + buffering = -1 + line_buffering = True if buffering < 0: buffering = DEFAULT_BUFFER_SIZE try: @@ -182,7 +184,7 @@ buffer.name = file buffer.mode = mode return buffer - text = TextIOWrapper(buffer, encoding, errors, newline) + text = TextIOWrapper(buffer, encoding, errors, newline, line_buffering) text.name = file text.mode = mode return text @@ -1133,7 +1135,8 @@ _CHUNK_SIZE = 128 - def __init__(self, buffer, encoding=None, errors=None, newline=None): + def __init__(self, buffer, encoding=None, errors=None, newline=None, + line_buffering=False): if newline not in (None, "", "\n", "\r", "\r\n"): raise ValueError("illegal newline value: %r" % (newline,)) if encoding is None: @@ -1160,6 +1163,7 @@ raise ValueError("invalid errors: %r" % errors) self.buffer = buffer + self._line_buffering = line_buffering self._encoding = encoding self._errors = errors self._readuniversal = not newline @@ -1180,6 +1184,10 @@ def errors(self): return self._errors + @property + def line_buffering(self): + return self._line_buffering + # A word about _snapshot. This attribute is either None, or a # tuple (decoder_state, readahead, pending) where decoder_state is # the second (integer) item of the decoder state, readahead is the @@ -1218,13 +1226,13 @@ raise TypeError("can't write %s to text stream" % s.__class__.__name__) length = len(s) - haslf = "\n" in s + haslf = (self._writetranslate or self._line_buffering) and "\n" in s if haslf and self._writetranslate and self._writenl != "\n": s = s.replace("\n", self._writenl) # XXX What if we were just reading? b = s.encode(self._encoding, self._errors) self.buffer.write(b) - if haslf and self.isatty(): + if self._line_buffering and (haslf or "\r" in s): self.flush() self._snapshot = None if self._decoder: Modified: python/branches/py3k/Lib/test/output/test_cProfile ============================================================================== --- python/branches/py3k/Lib/test/output/test_cProfile (original) +++ python/branches/py3k/Lib/test/output/test_cProfile Thu Dec 6 02:04:26 2007 @@ -5,10 +5,10 @@ ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.000 1.000 :1() - 2 0.000 0.000 0.000 0.000 io.py:1193(flush) - 1 0.000 0.000 0.000 0.000 io.py:257(flush) - 1 0.000 0.000 0.000 0.000 io.py:644(closed) - 1 0.000 0.000 0.000 0.000 io.py:862(flush) + 2 0.000 0.000 0.000 0.000 io.py:1201(flush) + 1 0.000 0.000 0.000 0.000 io.py:259(flush) + 1 0.000 0.000 0.000 0.000 io.py:646(closed) + 1 0.000 0.000 0.000 0.000 io.py:864(flush) 8 0.064 0.008 0.080 0.010 test_cProfile.py:103(subhelper) 28 0.028 0.001 0.028 0.001 test_cProfile.py:115(__getattr__) 1 0.270 0.270 1.000 1.000 test_cProfile.py:30(testfunc) @@ -30,11 +30,11 @@ Function called... ncalls tottime cumtime :1() -> 1 0.270 1.000 test_cProfile.py:30(testfunc) -io.py:1193(flush) -> 1 0.000 0.000 io.py:257(flush) - 1 0.000 0.000 io.py:862(flush) -io.py:257(flush) -> -io.py:644(closed) -> -io.py:862(flush) -> 1 0.000 0.000 io.py:644(closed) +io.py:1201(flush) -> 1 0.000 0.000 io.py:259(flush) + 1 0.000 0.000 io.py:864(flush) +io.py:259(flush) -> +io.py:646(closed) -> +io.py:864(flush) -> 1 0.000 0.000 io.py:646(closed) test_cProfile.py:103(subhelper) -> 16 0.016 0.016 test_cProfile.py:115(__getattr__) test_cProfile.py:115(__getattr__) -> test_cProfile.py:30(testfunc) -> 1 0.014 0.130 test_cProfile.py:40(factorial) @@ -53,7 +53,7 @@ test_cProfile.py:93(helper2) -> 8 0.064 0.080 test_cProfile.py:103(subhelper) 8 0.000 0.008 {hasattr} {exec} -> 1 0.000 1.000 :1() - 2 0.000 0.000 io.py:1193(flush) + 2 0.000 0.000 io.py:1201(flush) {hasattr} -> 12 0.012 0.012 test_cProfile.py:115(__getattr__) {method 'append' of 'list' objects} -> {method 'disable' of '_lsprof.Profiler' objects} -> @@ -65,10 +65,10 @@ Function was called by... ncalls tottime cumtime :1() <- 1 0.000 1.000 {exec} -io.py:1193(flush) <- 2 0.000 0.000 {exec} -io.py:257(flush) <- 1 0.000 0.000 io.py:1193(flush) -io.py:644(closed) <- 1 0.000 0.000 io.py:862(flush) -io.py:862(flush) <- 1 0.000 0.000 io.py:1193(flush) +io.py:1201(flush) <- 2 0.000 0.000 {exec} +io.py:259(flush) <- 1 0.000 0.000 io.py:1201(flush) +io.py:646(closed) <- 1 0.000 0.000 io.py:864(flush) +io.py:864(flush) <- 1 0.000 0.000 io.py:1201(flush) test_cProfile.py:103(subhelper) <- 8 0.064 0.080 test_cProfile.py:93(helper2) test_cProfile.py:115(__getattr__) <- 16 0.016 0.016 test_cProfile.py:103(subhelper) 12 0.012 0.012 {hasattr} Modified: python/branches/py3k/Lib/test/output/test_profile ============================================================================== --- python/branches/py3k/Lib/test/output/test_profile (original) +++ python/branches/py3k/Lib/test/output/test_profile Thu Dec 6 02:04:26 2007 @@ -10,10 +10,10 @@ 12 0.000 0.000 0.012 0.001 :0(hasattr) 1 0.000 0.000 0.000 0.000 :0(setprofile) 1 0.000 0.000 1.000 1.000 :1() - 2 0.000 0.000 0.000 0.000 io.py:1193(flush) - 1 0.000 0.000 0.000 0.000 io.py:257(flush) - 1 0.000 0.000 0.000 0.000 io.py:644(closed) - 1 0.000 0.000 0.000 0.000 io.py:862(flush) + 2 0.000 0.000 0.000 0.000 io.py:1201(flush) + 1 0.000 0.000 0.000 0.000 io.py:259(flush) + 1 0.000 0.000 0.000 0.000 io.py:646(closed) + 1 0.000 0.000 0.000 0.000 io.py:864(flush) 0 0.000 0.000 profile:0(profiler) 1 0.000 0.000 1.000 1.000 profile:0(testfunc()) 8 0.064 0.008 0.080 0.010 test_profile.py:103(subhelper) @@ -33,15 +33,15 @@ :0(append) -> :0(exc_info) -> :0(exec) -> :1()(1) 1.000 - io.py:1193(flush)(2) 0.000 + io.py:1201(flush)(2) 0.000 :0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028 :0(setprofile) -> :1() -> test_profile.py:30(testfunc)(1) 1.000 -io.py:1193(flush) -> io.py:257(flush)(1) 0.000 - io.py:862(flush)(1) 0.000 -io.py:257(flush) -> -io.py:644(closed) -> -io.py:862(flush) -> io.py:644(closed)(1) 0.000 +io.py:1201(flush) -> io.py:259(flush)(1) 0.000 + io.py:864(flush)(1) 0.000 +io.py:259(flush) -> +io.py:646(closed) -> +io.py:864(flush) -> io.py:646(closed)(1) 0.000 profile:0(profiler) -> profile:0(testfunc())(1) 1.000 profile:0(testfunc()) -> :0(exec)(1) 1.000 :0(setprofile)(1) 0.000 @@ -74,10 +74,10 @@ test_profile.py:93(helper2)(8) 0.400 :0(setprofile) <- profile:0(testfunc())(1) 1.000 :1() <- :0(exec)(1) 1.000 -io.py:1193(flush) <- :0(exec)(2) 1.000 -io.py:257(flush) <- io.py:1193(flush)(1) 0.000 -io.py:644(closed) <- io.py:862(flush)(1) 0.000 -io.py:862(flush) <- io.py:1193(flush)(1) 0.000 +io.py:1201(flush) <- :0(exec)(2) 1.000 +io.py:259(flush) <- io.py:1201(flush)(1) 0.000 +io.py:646(closed) <- io.py:864(flush)(1) 0.000 +io.py:864(flush) <- io.py:1201(flush)(1) 0.000 profile:0(profiler) <- profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400 Modified: python/branches/py3k/Lib/test/test_io.py ============================================================================== --- python/branches/py3k/Lib/test/test_io.py (original) +++ python/branches/py3k/Lib/test/test_io.py Thu Dec 6 02:04:26 2007 @@ -496,6 +496,17 @@ def tearDown(self): test_support.unlink(test_support.TESTFN) + def testLineBuffering(self): + r = io.BytesIO() + b = io.BufferedWriter(r, 1000) + t = io.TextIOWrapper(b, newline="\n", line_buffering=True) + t.write("X") + self.assertEquals(r.getvalue(), b"") # No flush happened + t.write("Y\nZ") + self.assertEquals(r.getvalue(), b"XY\nZ") # All got flushed + t.write("A\rB") + self.assertEquals(r.getvalue(), b"XY\nZA\rB") + def testEncodingErrorsReading(self): # (1) default b = io.BytesIO(b"abc\n\xff\n") @@ -525,13 +536,15 @@ self.assertRaises(UnicodeError, t.write, "\xff") # (3) ignore b = io.BytesIO() - t = io.TextIOWrapper(b, encoding="ascii", errors="ignore", newline="\n") + t = io.TextIOWrapper(b, encoding="ascii", errors="ignore", + newline="\n") t.write("abc\xffdef\n") t.flush() self.assertEquals(b.getvalue(), b"abcdef\n") # (4) replace b = io.BytesIO() - t = io.TextIOWrapper(b, encoding="ascii", errors="replace", newline="\n") + t = io.TextIOWrapper(b, encoding="ascii", errors="replace", + newline="\n") t.write("abc\xffdef\n") t.flush() self.assertEquals(b.getvalue(), b"abc?def\n") From python-3000-checkins at python.org Thu Dec 6 06:07:41 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 6 Dec 2007 06:07:41 +0100 (CET) Subject: [Python-3000-checkins] r59382 - in python/branches/py3k: Include/patchlevel.h Misc/NEWS README RELNOTES Message-ID: <20071206050741.D85111E4017@bag.python.org> Author: guido.van.rossum Date: Thu Dec 6 06:07:41 2007 New Revision: 59382 Modified: python/branches/py3k/Include/patchlevel.h python/branches/py3k/Misc/NEWS python/branches/py3k/README python/branches/py3k/RELNOTES Log: Get ready for releasing 3.0a2. (Next: update the whatsnew docs.) Modified: python/branches/py3k/Include/patchlevel.h ============================================================================== --- python/branches/py3k/Include/patchlevel.h (original) +++ python/branches/py3k/Include/patchlevel.h Thu Dec 6 06:07:41 2007 @@ -19,10 +19,10 @@ #define PY_MINOR_VERSION 0 #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_ALPHA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_SERIAL 2 /* Version as a string */ -#define PY_VERSION "3.0a1+" +#define PY_VERSION "3.0a2" /* Subversion Revision number of this file (not of the repository) */ #define PY_PATCHLEVEL_REVISION "$Revision$" Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Thu Dec 6 06:07:41 2007 @@ -6,7 +6,9 @@ What's New in Python 3.0a2? -*Unreleased* +*Release date: 07-Dec-2007* + +(Note: this list is incomplete.) Core and Builtins ----------------- Modified: python/branches/py3k/README ============================================================================== --- python/branches/py3k/README (original) +++ python/branches/py3k/README Thu Dec 6 06:07:41 2007 @@ -1,4 +1,4 @@ -This is Python version 3.0 alpha 1 +This is Python version 3.0 alpha 2 ================================== For notes specific to this release, see RELNOTES in this directory. @@ -11,8 +11,8 @@ finally been removed. This is an ongoing project; the cleanup isn't expected to be complete -until 2008. In particular there are plans to reorganize the standard -library namespace. +until some time in 2008. In particular there are plans to reorganize +the standard library namespace. Release Schedule @@ -55,6 +55,19 @@ "What's New in Python 3.0" document. Please help write it! +What's New Since 3.0a1 +---------------------- + +Undoubtedly the biggest change is in the bytes type: 'bytes' is now +immutable, and there is a new mutable bytes type 'bytearray'. These +two types are interoperable in every way. For more info on this +issue, read PEP 3137. + +For a more detailed change log, read Misc/NEWS (though this file, too, +is incomplete, and also doesn't list anything merged in from the 2.6 +release under development). + + Converting From Python 2.x to 3.0 --------------------------------- Modified: python/branches/py3k/RELNOTES ============================================================================== --- python/branches/py3k/RELNOTES (original) +++ python/branches/py3k/RELNOTES Thu Dec 6 06:07:41 2007 @@ -5,6 +5,15 @@ Please report bugs to http://bugs.python.org/. +Version 3.0a2 - Release Date 07-Dec-2007 +---------------------------------------- + +* SSL support is back! However, the SSL code appears to be leaking + quite a bit. + +* Otherwise, the 3.0a1 release notes still apply, except hashlib no + longer requires openssl. + Version 3.0a1 - Release Date 31-Aug-2007 ---------------------------------------- From python-3000-checkins at python.org Thu Dec 6 14:32:14 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 6 Dec 2007 14:32:14 +0100 (CET) Subject: [Python-3000-checkins] r59388 - python/branches/py3k/PCbuild9/pyproject.vsprops Message-ID: <20071206133214.7EFAA1E4005@bag.python.org> Author: christian.heimes Date: Thu Dec 6 14:32:14 2007 New Revision: 59388 Modified: python/branches/py3k/PCbuild9/pyproject.vsprops Log: Silence more warnings, _CRT_NONSTDC_NO_DEPRECATE is already defined in pyconfig.h but several projects don't include it. Modified: python/branches/py3k/PCbuild9/pyproject.vsprops ============================================================================== --- python/branches/py3k/PCbuild9/pyproject.vsprops (original) +++ python/branches/py3k/PCbuild9/pyproject.vsprops Thu Dec 6 14:32:14 2007 @@ -12,7 +12,7 @@ InlineFunctionExpansion="1" EnableIntrinsicFunctions="true" AdditionalIncludeDirectories="..\Include; ..\PC" - PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_WIN32" + PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_WIN32" StringPooling="true" ExceptionHandling="0" RuntimeLibrary="0" From python-3000-checkins at python.org Thu Dec 6 18:45:33 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 6 Dec 2007 18:45:33 +0100 (CET) Subject: [Python-3000-checkins] r59390 - python/branches/py3k/Lib/numbers.py Message-ID: <20071206174533.9C8171E4005@bag.python.org> Author: guido.van.rossum Date: Thu Dec 6 18:45:33 2007 New Revision: 59390 Modified: python/branches/py3k/Lib/numbers.py Log: Small set of updates (with Jeffrey's OK). Modified: python/branches/py3k/Lib/numbers.py ============================================================================== --- python/branches/py3k/Lib/numbers.py (original) +++ python/branches/py3k/Lib/numbers.py Thu Dec 6 18:45:33 2007 @@ -43,6 +43,7 @@ Inexact.register(complex) Inexact.register(float) +# Inexact.register(decimal.Decimal) class Complex(Number): @@ -97,7 +98,7 @@ def __pos__(self): """+self""" - return self + raise NotImplementedError def __sub__(self, other): """self - other""" @@ -119,7 +120,7 @@ @abstractmethod def __div__(self, other): - """self / other""" + """self / other; should promote to float or complex when necessary.""" raise NotImplementedError @abstractmethod @@ -129,7 +130,7 @@ @abstractmethod def __pow__(self, exponent): - """Like division, self**exponent should promote to complex when necessary.""" + """self**exponent; should promote to float or complex when necessary.""" raise NotImplementedError @abstractmethod @@ -152,9 +153,7 @@ """self == other""" raise NotImplementedError - def __ne__(self, other): - """self != other""" - return not (self == other) + # __ne__ is inherited from object and negates whatever __eq__ does. Complex.register(complex) @@ -180,8 +179,30 @@ """trunc(self): Truncates self to an Integral. Returns an Integral i such that: - * i>0 iff self>0 - * abs(i) <= abs(self). + * i>0 iff self>0; + * abs(i) <= abs(self); + * for any Integral j satisfying the first two conditions, + abs(i) >= abs(j) [i.e. i has "maximal" abs among those]. + i.e. "truncate towards 0". + """ + raise NotImplementedError + + @abstractmethod + def __floor__(self): + """Finds the greatest Integral <= self.""" + raise NotImplementedError + + @abstractmethod + def __ceil__(self): + """Finds the least Integral >= self.""" + raise NotImplementedError + + @abstractmethod + def __round__(self, ndigits:"Integral"=None): + """Rounds self to ndigits decimal places, defaulting to 0. + + If ndigits is omitted or None, returns an Integral, otherwise + returns a Real. Rounds half toward even. """ raise NotImplementedError @@ -241,7 +262,7 @@ @property def real(self): """Real numbers are their real component.""" - return self + return +self @property def imag(self): @@ -250,9 +271,10 @@ def conjugate(self): """Conjugate is a no-op for Reals.""" - return self + return +self Real.register(float) +# Real.register(decimal.Decimal) class Rational(Real, Exact): @@ -358,7 +380,7 @@ @property def numerator(self): """Integers are their own numerators.""" - return self + return +self @property def denominator(self): From python-3000-checkins at python.org Thu Dec 6 19:25:07 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 6 Dec 2007 19:25:07 +0100 (CET) Subject: [Python-3000-checkins] r59392 - python/branches/py3k/RELNOTES Message-ID: <20071206182507.9C95A1E4005@bag.python.org> Author: guido.van.rossum Date: Thu Dec 6 19:25:07 2007 New Revision: 59392 Modified: python/branches/py3k/RELNOTES Log: Some Windows notes by Christian. Modified: python/branches/py3k/RELNOTES ============================================================================== --- python/branches/py3k/RELNOTES (original) +++ python/branches/py3k/RELNOTES Thu Dec 6 19:25:07 2007 @@ -11,6 +11,13 @@ * SSL support is back! However, the SSL code appears to be leaking quite a bit. +* On Windows Python can't be run from a directory with non ASCII chars + in its path name (bug #1342). + +* The current releases of MinGW and Cygwin can't build Python extensions + since they don't support msvcr90.dll. The necessary bits and pieces are + already in Python and cygwin cvs. + * Otherwise, the 3.0a1 release notes still apply, except hashlib no longer requires openssl. From python-3000-checkins at python.org Thu Dec 6 19:37:53 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 6 Dec 2007 19:37:53 +0100 (CET) Subject: [Python-3000-checkins] r59393 - python/branches/py3k/Tools/scripts/combinerefs.py Message-ID: <20071206183753.96D731E4005@bag.python.org> Author: guido.van.rossum Date: Thu Dec 6 19:37:53 2007 New Revision: 59393 Modified: python/branches/py3k/Tools/scripts/combinerefs.py Log: Fix a last use of file() that should be open(). Modified: python/branches/py3k/Tools/scripts/combinerefs.py ============================================================================== --- python/branches/py3k/Tools/scripts/combinerefs.py (original) +++ python/branches/py3k/Tools/scripts/combinerefs.py Thu Dec 6 19:37:53 2007 @@ -86,7 +86,8 @@ break def combine(fname): - f = file(fname) + f = open(fname) + fi = iter(f) for line in read(fi, re.compile(r'^Remaining objects:$'), False): From python-3000-checkins at python.org Thu Dec 6 19:39:47 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 6 Dec 2007 19:39:47 +0100 (CET) Subject: [Python-3000-checkins] r59394 - in python/branches/py3k: Lib/ssl.py Modules/_ssl.c Message-ID: <20071206183947.30CD51E4005@bag.python.org> Author: guido.van.rossum Date: Thu Dec 6 19:39:46 2007 New Revision: 59394 Modified: python/branches/py3k/Lib/ssl.py python/branches/py3k/Modules/_ssl.c Log: Fix the leaks in test_ssl. Issue 1469. Patch by Christian Heimes: (a) added GC support to the PySSL object (b) move the call to _real_close() from __del__ methods in Python to PySSL_dealloc(). (c) remove those __del__ methods -- this makes SSL and socket objects GC'able. Modified: python/branches/py3k/Lib/ssl.py ============================================================================== --- python/branches/py3k/Lib/ssl.py (original) +++ python/branches/py3k/Lib/ssl.py Thu Dec 6 19:39:46 2007 @@ -148,6 +148,10 @@ self.do_handshake_on_connect = do_handshake_on_connect self.suppress_ragged_eofs = suppress_ragged_eofs + # See Modules/_ssl.c:PySSL_dealloc() + # def __del__(self): + # self._real_close() + def dup(self): raise NotImplemented("Can't dup() %s instances" % self.__class__.__name__) @@ -300,6 +304,7 @@ socket.shutdown(self, how) def _real_close(self): + # real close is called by Modules/_ssl.c:PySSL_dealloc() self._sslobj = None # self._closed = True if self._base: @@ -348,10 +353,6 @@ self.do_handshake_on_connect), addr) - - def __del__(self): - self._real_close() - def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, Modified: python/branches/py3k/Modules/_ssl.c ============================================================================== --- python/branches/py3k/Modules/_ssl.c (original) +++ python/branches/py3k/Modules/_ssl.c Thu Dec 6 19:39:46 2007 @@ -266,7 +266,7 @@ int ret; int verification_mode; - self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ + self = PyObject_GC_New(PySSLObject, &PySSL_Type); /* Create new object */ if (self == NULL) return NULL; self->peer_cert = NULL; @@ -385,6 +385,7 @@ self->Socket = Sock; Py_INCREF(self->Socket); + _PyObject_GC_TRACK(self); return self; fail: if (errstr) @@ -1050,16 +1051,41 @@ return NULL; } -static void PySSL_dealloc(PySSLObject *self) +/* GC support. */ +static int +PySSL_traverse(PySSLObject *self, visitproc visit, void *arg) { + Py_VISIT(self->Socket); + return 0; +} + +static int +PySSL_clear(PySSLObject *self) +{ + Py_CLEAR(self->Socket); + return 0; +} + +static void +PySSL_dealloc(PySSLObject *self) +{ + PyObject *o; + PyObject *exc_type, *exc_value, *exc_tb; + + PyErr_Fetch(&exc_type, &exc_value, &exc_tb); + o = PyObject_CallMethod((PyObject*)self, "_real_close", NULL); + Py_XDECREF(o); + PyErr_Restore(exc_type, exc_value, exc_tb); + + PyObject_GC_UnTrack(self); if (self->peer_cert) /* Possible not to have one? */ - X509_free (self->peer_cert); + X509_free(self->peer_cert); if (self->ssl) SSL_free(self->ssl); if (self->ctx) SSL_CTX_free(self->ctx); - Py_XDECREF(self->Socket); - PyObject_Del(self); + Py_CLEAR(self->Socket); + Py_Type(self)->tp_free((PyObject *)self); } /* If the socket has a timeout, do a select()/poll() on the socket. @@ -1359,20 +1385,15 @@ {NULL, NULL} }; -static PyObject *PySSL_getattr(PySSLObject *self, char *name) -{ - return Py_FindMethod(PySSLMethods, (PyObject *)self, name); -} - static PyTypeObject PySSL_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "ssl.SSLContext", /*tp_name*/ + "_ssl.SSLContext", /*tp_name*/ sizeof(PySSLObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)PySSL_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - (getattrfunc)PySSL_getattr, /*tp_getattr*/ + 0, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ @@ -1380,6 +1401,32 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_HAVE_GC, /* tp_flags */ + 0, /* tp_doc */ + (traverseproc)PySSL_traverse, /* tp_traverse */ + (inquiry)PySSL_clear, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + PySSLMethods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + PyType_GenericAlloc, /* tp_alloc */ + PyType_GenericNew, /* tp_new */ + PyObject_GC_Del, /* tp_free */ }; #ifdef HAVE_OPENSSL_RAND From python-3000-checkins at python.org Thu Dec 6 20:05:56 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 6 Dec 2007 20:05:56 +0100 (CET) Subject: [Python-3000-checkins] r59395 - in python/branches/py3k: Lib/ssl.py Modules/_ssl.c Message-ID: <20071206190556.304BD1E4017@bag.python.org> Author: guido.van.rossum Date: Thu Dec 6 20:05:55 2007 New Revision: 59395 Modified: python/branches/py3k/Lib/ssl.py python/branches/py3k/Modules/_ssl.c Log: Reverting revision 59394. We'll sort this out later. Modified: python/branches/py3k/Lib/ssl.py ============================================================================== --- python/branches/py3k/Lib/ssl.py (original) +++ python/branches/py3k/Lib/ssl.py Thu Dec 6 20:05:55 2007 @@ -148,10 +148,6 @@ self.do_handshake_on_connect = do_handshake_on_connect self.suppress_ragged_eofs = suppress_ragged_eofs - # See Modules/_ssl.c:PySSL_dealloc() - # def __del__(self): - # self._real_close() - def dup(self): raise NotImplemented("Can't dup() %s instances" % self.__class__.__name__) @@ -304,7 +300,6 @@ socket.shutdown(self, how) def _real_close(self): - # real close is called by Modules/_ssl.c:PySSL_dealloc() self._sslobj = None # self._closed = True if self._base: @@ -353,6 +348,10 @@ self.do_handshake_on_connect), addr) + + def __del__(self): + self._real_close() + def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, Modified: python/branches/py3k/Modules/_ssl.c ============================================================================== --- python/branches/py3k/Modules/_ssl.c (original) +++ python/branches/py3k/Modules/_ssl.c Thu Dec 6 20:05:55 2007 @@ -266,7 +266,7 @@ int ret; int verification_mode; - self = PyObject_GC_New(PySSLObject, &PySSL_Type); /* Create new object */ + self = PyObject_New(PySSLObject, &PySSL_Type); /* Create new object */ if (self == NULL) return NULL; self->peer_cert = NULL; @@ -385,7 +385,6 @@ self->Socket = Sock; Py_INCREF(self->Socket); - _PyObject_GC_TRACK(self); return self; fail: if (errstr) @@ -1051,41 +1050,16 @@ return NULL; } -/* GC support. */ -static int -PySSL_traverse(PySSLObject *self, visitproc visit, void *arg) +static void PySSL_dealloc(PySSLObject *self) { - Py_VISIT(self->Socket); - return 0; -} - -static int -PySSL_clear(PySSLObject *self) -{ - Py_CLEAR(self->Socket); - return 0; -} - -static void -PySSL_dealloc(PySSLObject *self) -{ - PyObject *o; - PyObject *exc_type, *exc_value, *exc_tb; - - PyErr_Fetch(&exc_type, &exc_value, &exc_tb); - o = PyObject_CallMethod((PyObject*)self, "_real_close", NULL); - Py_XDECREF(o); - PyErr_Restore(exc_type, exc_value, exc_tb); - - PyObject_GC_UnTrack(self); if (self->peer_cert) /* Possible not to have one? */ - X509_free(self->peer_cert); + X509_free (self->peer_cert); if (self->ssl) SSL_free(self->ssl); if (self->ctx) SSL_CTX_free(self->ctx); - Py_CLEAR(self->Socket); - Py_Type(self)->tp_free((PyObject *)self); + Py_XDECREF(self->Socket); + PyObject_Del(self); } /* If the socket has a timeout, do a select()/poll() on the socket. @@ -1385,15 +1359,20 @@ {NULL, NULL} }; +static PyObject *PySSL_getattr(PySSLObject *self, char *name) +{ + return Py_FindMethod(PySSLMethods, (PyObject *)self, name); +} + static PyTypeObject PySSL_Type = { PyVarObject_HEAD_INIT(NULL, 0) - "_ssl.SSLContext", /*tp_name*/ + "ssl.SSLContext", /*tp_name*/ sizeof(PySSLObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor)PySSL_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ - 0, /*tp_getattr*/ + (getattrfunc)PySSL_getattr, /*tp_getattr*/ 0, /*tp_setattr*/ 0, /*tp_compare*/ 0, /*tp_repr*/ @@ -1401,32 +1380,6 @@ 0, /*tp_as_sequence*/ 0, /*tp_as_mapping*/ 0, /*tp_hash*/ - 0, /* tp_call */ - 0, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_HAVE_GC, /* tp_flags */ - 0, /* tp_doc */ - (traverseproc)PySSL_traverse, /* tp_traverse */ - (inquiry)PySSL_clear, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - PySSLMethods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - PyType_GenericAlloc, /* tp_alloc */ - PyType_GenericNew, /* tp_new */ - PyObject_GC_Del, /* tp_free */ }; #ifdef HAVE_OPENSSL_RAND From python-3000-checkins at python.org Fri Dec 7 09:17:51 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 7 Dec 2007 09:17:51 +0100 (CET) Subject: [Python-3000-checkins] r59401 - python/branches/py3k/Doc/using/cmdline.rst Message-ID: <20071207081751.0D8B01E400A@bag.python.org> Author: georg.brandl Date: Fri Dec 7 09:17:50 2007 New Revision: 59401 Modified: python/branches/py3k/Doc/using/cmdline.rst Log: No -Q flag anymore in Py3k. Modified: python/branches/py3k/Doc/using/cmdline.rst ============================================================================== --- python/branches/py3k/Doc/using/cmdline.rst (original) +++ python/branches/py3k/Doc/using/cmdline.rst Fri Dec 7 09:17:50 2007 @@ -21,7 +21,7 @@ When invoking Python, you may specify any of these options:: - python [-dEiOQStuUvxX?] [-c command | -m module-name | script | - ] [args] + python [-dEiOStuUvxX?] [-c command | -m module-name | script | - ] [args] The most common use case is, of course, a simple invocation of a script:: @@ -171,27 +171,7 @@ Discard docstrings in addition to the :option:`-O` optimizations. -.. cmdoption:: -Q - Division control. The argument must be one of the following: - - ``new`` - new division semantics, i.e. division of int/int returns a float (*default*) - ``old`` - division of int/int returns an int - ``warn`` - old division semantics with a warning for int/int - ``warnall`` - old division semantics with a warning for all uses of the division operator - - .. seealso:: - :file:`Tools/scripts/fixdiv.py` - for a use of ``warnall`` - - :pep:`238` -- Changing the division operator - - -.. cmdoption:: -S Disable the import of the module :mod:`site` and the site-dependent manipulations of :data:`sys.path` that it entails. From python-3000-checkins at python.org Fri Dec 7 12:10:11 2007 From: python-3000-checkins at python.org (fred.drake) Date: Fri, 7 Dec 2007 12:10:11 +0100 (CET) Subject: [Python-3000-checkins] r59403 - python/branches/py3k/Lib/HTMLParser.py python/branches/py3k/Lib/_markupbase.py python/branches/py3k/Lib/markupbase.py python/branches/py3k/Lib/sgmllib.py Message-ID: <20071207111011.BE11E1E4023@bag.python.org> Author: fred.drake Date: Fri Dec 7 12:10:11 2007 New Revision: 59403 Added: python/branches/py3k/Lib/_markupbase.py - copied, changed from r59400, python/branches/py3k/Lib/markupbase.py Removed: python/branches/py3k/Lib/markupbase.py Modified: python/branches/py3k/Lib/HTMLParser.py python/branches/py3k/Lib/sgmllib.py Log: rename markupbase to _markupbase Modified: python/branches/py3k/Lib/HTMLParser.py ============================================================================== --- python/branches/py3k/Lib/HTMLParser.py (original) +++ python/branches/py3k/Lib/HTMLParser.py Fri Dec 7 12:10:11 2007 @@ -8,7 +8,7 @@ # and CDATA (character data -- only end tags are special). -import markupbase +import _markupbase import re # Regular expressions used for parsing @@ -64,7 +64,7 @@ return result -class HTMLParser(markupbase.ParserBase): +class HTMLParser(_markupbase.ParserBase): """Find tags and other markup and call handler functions. Usage: @@ -96,7 +96,7 @@ self.rawdata = '' self.lasttag = '???' self.interesting = interesting_normal - markupbase.ParserBase.reset(self) + _markupbase.ParserBase.reset(self) def feed(self, data): """Feed data to the parser. Copied: python/branches/py3k/Lib/_markupbase.py (from r59400, python/branches/py3k/Lib/markupbase.py) ============================================================================== --- python/branches/py3k/Lib/markupbase.py (original) +++ python/branches/py3k/Lib/_markupbase.py Fri Dec 7 12:10:11 2007 @@ -28,7 +28,7 @@ def __init__(self): if self.__class__ is ParserBase: raise RuntimeError( - "markupbase.ParserBase must be subclassed") + "_markupbase.ParserBase must be subclassed") def error(self, message): raise NotImplementedError( Deleted: /python/branches/py3k/Lib/markupbase.py ============================================================================== --- /python/branches/py3k/Lib/markupbase.py Fri Dec 7 12:10:11 2007 +++ (empty file) @@ -1,392 +0,0 @@ -"""Shared support for scanning document type declarations in HTML and XHTML. - -This module is used as a foundation for the HTMLParser and sgmllib -modules (indirectly, for htmllib as well). It has no documented -public API and should not be used directly. - -""" - -import re - -_declname_match = re.compile(r'[a-zA-Z][-_.a-zA-Z0-9]*\s*').match -_declstringlit_match = re.compile(r'(\'[^\']*\'|"[^"]*")\s*').match -_commentclose = re.compile(r'--\s*>') -_markedsectionclose = re.compile(r']\s*]\s*>') - -# An analysis of the MS-Word extensions is available at -# http://www.planetpublish.com/xmlarena/xap/Thursday/WordtoXML.pdf - -_msmarkedsectionclose = re.compile(r']\s*>') - -del re - - -class ParserBase: - """Parser base class which provides some common support methods used - by the SGML/HTML and XHTML parsers.""" - - def __init__(self): - if self.__class__ is ParserBase: - raise RuntimeError( - "markupbase.ParserBase must be subclassed") - - def error(self, message): - raise NotImplementedError( - "subclasses of ParserBase must override error()") - - def reset(self): - self.lineno = 1 - self.offset = 0 - - def getpos(self): - """Return current line number and offset.""" - return self.lineno, self.offset - - # Internal -- update line number and offset. This should be - # called for each piece of data exactly once, in order -- in other - # words the concatenation of all the input strings to this - # function should be exactly the entire input. - def updatepos(self, i, j): - if i >= j: - return j - rawdata = self.rawdata - nlines = rawdata.count("\n", i, j) - if nlines: - self.lineno = self.lineno + nlines - pos = rawdata.rindex("\n", i, j) # Should not fail - self.offset = j-(pos+1) - else: - self.offset = self.offset + j-i - return j - - _decl_otherchars = '' - - # Internal -- parse declaration (for use by subclasses). - def parse_declaration(self, i): - # This is some sort of declaration; in "HTML as - # deployed," this should only be the document type - # declaration (""). - # ISO 8879:1986, however, has more complex - # declaration syntax for elements in , including: - # --comment-- - # [marked section] - # name in the following list: ENTITY, DOCTYPE, ELEMENT, - # ATTLIST, NOTATION, SHORTREF, USEMAP, - # LINKTYPE, LINK, IDLINK, USELINK, SYSTEM - rawdata = self.rawdata - j = i + 2 - assert rawdata[i:j] == "": - # the empty comment - return j + 1 - if rawdata[j:j+1] in ("-", ""): - # Start of comment followed by buffer boundary, - # or just a buffer boundary. - return -1 - # A simple, practical version could look like: ((name|stringlit) S*) + '>' - n = len(rawdata) - if rawdata[j:j+2] == '--': #comment - # Locate --.*-- as the body of the comment - return self.parse_comment(i) - elif rawdata[j] == '[': #marked section - # Locate [statusWord [...arbitrary SGML...]] as the body of the marked section - # Where statusWord is one of TEMP, CDATA, IGNORE, INCLUDE, RCDATA - # Note that this is extended by Microsoft Office "Save as Web" function - # to include [if...] and [endif]. - return self.parse_marked_section(i) - else: #all other declaration elements - decltype, j = self._scan_name(j, i) - if j < 0: - return j - if decltype == "doctype": - self._decl_otherchars = '' - while j < n: - c = rawdata[j] - if c == ">": - # end of declaration syntax - data = rawdata[i+2:j] - if decltype == "doctype": - self.handle_decl(data) - else: - self.unknown_decl(data) - return j + 1 - if c in "\"'": - m = _declstringlit_match(rawdata, j) - if not m: - return -1 # incomplete - j = m.end() - elif c in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ": - name, j = self._scan_name(j, i) - elif c in self._decl_otherchars: - j = j + 1 - elif c == "[": - # this could be handled in a separate doctype parser - if decltype == "doctype": - j = self._parse_doctype_subset(j + 1, i) - elif decltype in ("attlist", "linktype", "link", "element"): - # must tolerate []'d groups in a content model in an element declaration - # also in data attribute specifications of attlist declaration - # also link type declaration subsets in linktype declarations - # also link attribute specification lists in link declarations - self.error("unsupported '[' char in %s declaration" % decltype) - else: - self.error("unexpected '[' char in declaration") - else: - self.error( - "unexpected %r char in declaration" % rawdata[j]) - if j < 0: - return j - return -1 # incomplete - - # Internal -- parse a marked section - # Override this to handle MS-word extension syntax content - def parse_marked_section(self, i, report=1): - rawdata= self.rawdata - assert rawdata[i:i+3] == ' ending - match= _markedsectionclose.search(rawdata, i+3) - elif sectName in ("if", "else", "endif"): - # look for MS Office ]> ending - match= _msmarkedsectionclose.search(rawdata, i+3) - else: - self.error('unknown status keyword %r in marked section' % rawdata[i+3:j]) - if not match: - return -1 - if report: - j = match.start(0) - self.unknown_decl(rawdata[i+3: j]) - return match.end(0) - - # Internal -- parse comment, return length or -1 if not terminated - def parse_comment(self, i, report=1): - rawdata = self.rawdata - if rawdata[i:i+4] != ' Modified: python/branches/py3k/PCbuild8/pythoncore/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PCbuild8/pythoncore/pythoncore.vcproj (original) +++ python/branches/py3k/PCbuild8/pythoncore/pythoncore.vcproj Tue Dec 11 02:06:40 2007 @@ -827,6 +827,10 @@ RelativePath="..\..\Objects\dictobject.c" > + Modified: python/branches/py3k/PCbuild9/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/pythoncore.vcproj (original) +++ python/branches/py3k/PCbuild9/pythoncore.vcproj Tue Dec 11 02:06:40 2007 @@ -1362,6 +1362,10 @@ RelativePath="..\Objects\dictobject.c" > + From lists at cheimes.de Tue Dec 11 03:57:06 2007 From: lists at cheimes.de (Christian Heimes) Date: Tue, 11 Dec 2007 03:57:06 +0100 Subject: [Python-3000-checkins] r59457 - in python/branches/py3k: Include/floatobject.h Lib/test/test_float.py Makefile.pre.in Misc/NEWS Objects/doubledigits.c Objects/floatobject.c PCbuild/pythoncore.vcproj PCbuild8/pythoncore/pythoncore.vcproj PCbuild9/pythoncore.vcproj In-Reply-To: <20071210231613.GA23671@arctrix.com> References: <20071210221918.600421E4002@bag.python.org> <20071210224511.471A495E25@klonk.arctrix.com> <475DC3DA.7000406@cheimes.de> <20071210231613.GA23671@arctrix.com> Message-ID: <475DFC82.2050005@cheimes.de> Neil Schemenauer wrote: > Basically, write a little C program that exits with 0 or 1 depending > on double endian-ness. Here is a medium sized C program. It can probably be coded in a fraction of the size but this way everybody can understand it. In the case it's too long for your taste just check if the first or last bit of an (unsigned int64*)&((double)-1) is 1. #define BIAS 1023 typedef struct { unsigned int sign : 1; unsigned int exp : 11; unsigned int m1 : 4; unsigned int m2 : 16; unsigned int m3 : 16; unsigned int m4 : 16; } be_ieee_dbl; typedef struct { unsigned int m4 : 16; unsigned int m3 : 16; unsigned int m2 : 16; unsigned int m1 : 4; unsigned int exp : 11; unsigned int sign : 1; } le_ieee_dbl; /* 1 = little endian IEEE double * 2 = big endian IEEE double * 0 = error */ int main(void) { double dbl = -9.; le_ieee_dbl *le = (le_ieee_dbl*)&dbl; be_ieee_dbl *be = (be_ieee_dbl*)&dbl; if (le->sign == 1 && le->exp-BIAS == 3 && le->m1 == 2 && le->m2 == 0 && le->m3 == 0 && le->m4 == 0) { return 1; } if (be->sign == 1 && be->exp-BIAS == 3 && be->m1 == 2 && be->m2 == 0 && be->m3 == 0 && be->m4 == 0) { return 2; } return 0; } From python-3000-checkins at python.org Tue Dec 11 10:00:02 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 11 Dec 2007 10:00:02 +0100 (CET) Subject: [Python-3000-checkins] r59466 - python/branches/py3k/Misc/NEWS Message-ID: <20071211090002.50EF61E4002@bag.python.org> Author: christian.heimes Date: Tue Dec 11 10:00:01 2007 New Revision: 59466 Modified: python/branches/py3k/Misc/NEWS Log: Added note about 1585 to Misc/NEWS Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Dec 11 10:00:01 2007 @@ -33,6 +33,8 @@ Library ------- +- Issue #1585: IDLE uses non-existent xrange() function + - Issue #1578: Problems in win_getpass From python-3000-checkins at python.org Tue Dec 11 20:56:41 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 11 Dec 2007 20:56:41 +0100 (CET) Subject: [Python-3000-checkins] r59469 - in python/branches/py3k: Doc/c-api/concrete.rst Include/classobject.h Misc/NEWS Objects/classobject.c Message-ID: <20071211195641.3A78F1E4003@bag.python.org> Author: christian.heimes Date: Tue Dec 11 20:56:40 2007 New Revision: 59469 Modified: python/branches/py3k/Doc/c-api/concrete.rst python/branches/py3k/Include/classobject.h python/branches/py3k/Misc/NEWS python/branches/py3k/Objects/classobject.c Log: Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API has gained a new type *PyInstanceMethod_Type* and the functions *PyInstanceMethod_Check(o)*, *PyInstanceMethod_New(func)* and *PyInstanceMethod_Function(im)*. Modified: python/branches/py3k/Doc/c-api/concrete.rst ============================================================================== --- python/branches/py3k/Doc/c-api/concrete.rst (original) +++ python/branches/py3k/Doc/c-api/concrete.rst Tue Dec 11 20:56:40 2007 @@ -2522,6 +2522,47 @@ Raises :exc:`SystemError` and returns ``-1`` on failure. +.. _instancemethod-objects: + +Instance Method Objects +----------------------- + +.. index:: object: instancemethod + +An instance method is a wrapper for a :cdata:`PyCFunction` and the new way +to bind a :cdata:`PyCFunction` to a class object. It replaces the former call +:cfunc:`PyMethod_New(func, NULL, class)`. + + +.. cvar:: PyTypeObject PyInstanceMethod_Type + + This instance of :ctype:`PyTypeObject` represents the Python instance + method type. It is not exposed to Python programs. + + +.. cfunction:: int PyInstanceMethod_Check(PyObject *o) + + Return true if *o* is an instance method object (has type + :cdata:`PyInstanceMethod_Type`). The parameter must not be *NULL*. + + +.. cfunction:: PyObject* PyInstanceMethod_New(PyObject *func) + + Return a new instance method object, with *func* being any callable object + *func* is is the function that will be called when the instance method is + called. + + +.. cfunction:: PyObject* PyInstanceMethod_Function(PyObject *im) + + Return the function object associated with the instance method *im*. + + +.. cfunction:: PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *im) + + Macro version of :cfunc:`PyInstanceMethod_Function` which avoids error checking. + + .. _method-objects: Method Objects Modified: python/branches/py3k/Include/classobject.h ============================================================================== --- python/branches/py3k/Include/classobject.h (original) +++ python/branches/py3k/Include/classobject.h Tue Dec 11 20:56:40 2007 @@ -31,6 +31,24 @@ #define PyMethod_GET_SELF(meth) \ (((PyMethodObject *)meth) -> im_self) + +typedef struct { + PyObject_HEAD + PyObject *func; +} PyInstanceMethodObject; + +PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; + +#define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type) + +PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyInstanceMethod_GET_FUNCTION(meth) \ + (((PyInstanceMethodObject *)meth) -> func) + #ifdef __cplusplus } #endif Modified: python/branches/py3k/Misc/NEWS ============================================================================== --- python/branches/py3k/Misc/NEWS (original) +++ python/branches/py3k/Misc/NEWS Tue Dec 11 20:56:40 2007 @@ -12,6 +12,11 @@ Core and Builtins ----------------- +- Issue #1587: Added instancemethod wrapper for PyCFunctions. The Python C API + has gained a new type *PyInstanceMethod_Type* and the functions + *PyInstanceMethod_Check(o)*, *PyInstanceMethod_New(func)* and + *PyInstanceMethod_Function(im)*. + - Constants gc.DEBUG_OBJECT and gc.DEBUG_INSTANCE have been removed from the gc module; gc.DEBUG_COLLECTABLE or gc.DEBUG_UNCOLLECTABLE are now enough to print the corresponding list of objects considered by the garbage collector. Modified: python/branches/py3k/Objects/classobject.c ============================================================================== --- python/branches/py3k/Objects/classobject.c (original) +++ python/branches/py3k/Objects/classobject.c Tue Dec 11 20:56:40 2007 @@ -5,7 +5,6 @@ #define TP_DESCR_GET(t) ((t)->tp_descr_get) - PyObject * PyMethod_Function(PyObject *im) { @@ -68,12 +67,12 @@ /* im_func and im_self are stored in the PyMethod object */ -#define OFF(x) offsetof(PyMethodObject, x) +#define MO_OFF(x) offsetof(PyMethodObject, x) static PyMemberDef method_memberlist[] = { - {"__func__", T_OBJECT, OFF(im_func), READONLY|RESTRICTED, + {"__func__", T_OBJECT, MO_OFF(im_func), READONLY|RESTRICTED, "the function (or other callable) implementing a method"}, - {"__self__", T_OBJECT, OFF(im_self), READONLY|RESTRICTED, + {"__self__", T_OBJECT, MO_OFF(im_self), READONLY|RESTRICTED, "the instance to which a method is bound"}, {NULL} /* Sentinel */ }; @@ -131,7 +130,7 @@ PyDoc_STRVAR(method_doc, "method(function, instance)\n\ \n\ -Create an instance method object."); +Create a bound instance method object."); static PyObject * method_new(PyTypeObject* type, PyObject* args, PyObject *kw) @@ -139,7 +138,7 @@ PyObject *func; PyObject *self; - if (!_PyArg_NoKeywords("instancemethod", kw)) + if (!_PyArg_NoKeywords("method", kw)) return NULL; if (!PyArg_UnpackTuple(args, "method", 2, 2, &func, &self)) @@ -351,7 +350,7 @@ (traverseproc)method_traverse, /* tp_traverse */ 0, /* tp_clear */ method_richcompare, /* tp_richcompare */ - offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ + offsetof(PyMethodObject, im_weakreflist), /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ 0, /* tp_methods */ @@ -378,3 +377,245 @@ PyObject_GC_Del(im); } } + +/* ------------------------------------------------------------------------ + * instance method + */ + +PyObject * +PyInstanceMethod_New(PyObject *func) { + PyInstanceMethodObject *method; + method = PyObject_GC_New(PyInstanceMethodObject, + &PyInstanceMethod_Type); + if (method == NULL) return NULL; + Py_INCREF(func); + method->func = func; + _PyObject_GC_TRACK(method); + return (PyObject *)method; +} + +PyObject * +PyInstanceMethod_Function(PyObject *im) +{ + if (!PyInstanceMethod_Check(im)) { + PyErr_BadInternalCall(); + return NULL; + } + return PyInstanceMethod_GET_FUNCTION(im); +} + +#define IMO_OFF(x) offsetof(PyInstanceMethodObject, x) + +static PyMemberDef instancemethod_memberlist[] = { + {"__func__", T_OBJECT, IMO_OFF(func), READONLY|RESTRICTED, + "the function (or other callable) implementing a method"}, + {NULL} /* Sentinel */ +}; + +static PyObject * +instancemethod_get_doc(PyObject *self, void *context) +{ + static PyObject *docstr; + if (docstr == NULL) { + docstr = PyUnicode_InternFromString("__doc__"); + if (docstr == NULL) + return NULL; + } + return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), docstr); +} + +static PyGetSetDef instancemethod_getset[] = { + {"__doc__", (getter)instancemethod_get_doc, NULL, NULL}, + {0} +}; + +static PyObject * +instancemethod_getattro(PyObject *self, PyObject *name) +{ + PyTypeObject *tp = self->ob_type; + PyObject *descr = NULL; + + if (tp->tp_dict == NULL) { + if (PyType_Ready(tp) < 0) + return NULL; + } + descr = _PyType_Lookup(tp, name); + + if (descr != NULL) { + descrgetfunc f = TP_DESCR_GET(descr->ob_type); + if (f != NULL) + return f(descr, self, (PyObject *)self->ob_type); + else { + Py_INCREF(descr); + return descr; + } + } + + return PyObject_GetAttr(PyInstanceMethod_GET_FUNCTION(self), name); +} + +static void +instancemethod_dealloc(PyObject *self) { + _PyObject_GC_UNTRACK(self); + Py_DECREF(PyInstanceMethod_GET_FUNCTION(self)); + PyObject_GC_Del(self); +} + +static int +instancemethod_traverse(PyObject *self, visitproc visit, void *arg) { + Py_VISIT(PyInstanceMethod_GET_FUNCTION(self)); + return 0; +} + +static PyObject * +instancemethod_call(PyObject *self, PyObject *arg, PyObject *kw) +{ + return PyObject_Call(PyMethod_GET_FUNCTION(self), arg, kw); +} + +static PyObject * +instancemethod_descr_get(PyObject *descr, PyObject *obj, PyObject *type) { + register PyObject *func = PyInstanceMethod_GET_FUNCTION(descr); + if (obj == NULL) + return func; + else + return PyMethod_New(func, obj); +} + +static PyObject * +instancemethod_richcompare(PyObject *self, PyObject *other, int op) +{ + PyInstanceMethodObject *a, *b; + PyObject *res; + int eq; + + if ((op != Py_EQ && op != Py_NE) || + !PyInstanceMethod_Check(self) || + !PyInstanceMethod_Check(other)) + { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } + a = (PyInstanceMethodObject *)self; + b = (PyInstanceMethodObject *)other; + eq = PyObject_RichCompareBool(a->func, b->func, Py_EQ); + if (eq < 0) + return NULL; + if (op == Py_EQ) + res = eq ? Py_True : Py_False; + else + res = eq ? Py_False : Py_True; + Py_INCREF(res); + return res; +} + +static PyObject * +instancemethod_repr(PyObject *self) +{ + PyObject *func = PyInstanceMethod_Function(self); + PyObject *funcname = NULL , *result = NULL; + char *defname = "?"; + + if (func == NULL) { + PyErr_BadInternalCall(); + return NULL; + } + + funcname = PyObject_GetAttrString(func, "__name__"); + if (funcname == NULL) { + if (!PyErr_ExceptionMatches(PyExc_AttributeError)) + return NULL; + PyErr_Clear(); + } + else if (!PyUnicode_Check(funcname)) { + Py_DECREF(funcname); + funcname = NULL; + } + + result = PyUnicode_FromFormat("", + funcname, defname, self); + + Py_XDECREF(funcname); + return result; +} + +/* +static long +instancemethod_hash(PyObject *self) +{ + long x, y; + x = (long)self; + y = PyObject_Hash(PyInstanceMethod_GET_FUNCTION(self)); + if (y == -1) + return -1; + x = x ^ y; + if (x == -1) + x = -2; + return x; +} +*/ + +PyDoc_STRVAR(instancemethod_doc, +"instancemethod(function)\n\ +\n\ +Bind a function to a class."); + +static PyObject * +instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw) +{ + PyObject *func; + + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; + if (!PyArg_UnpackTuple(args, "instancemethod", 1, 1, &func)) + return NULL; + if (!PyCallable_Check(func)) { + PyErr_SetString(PyExc_TypeError, + "first argument must be callable"); + return NULL; + } + + return PyInstanceMethod_New(func); +} + +PyTypeObject PyInstanceMethod_Type = { + PyVarObject_HEAD_INIT(&PyType_Type, 0) + "instancemethod", /* tp_name */ + sizeof(PyInstanceMethodObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + instancemethod_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + (reprfunc)instancemethod_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /*(hashfunc)instancemethod_hash, tp_hash */ + instancemethod_call, /* tp_call */ + 0, /* tp_str */ + instancemethod_getattro, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT + | Py_TPFLAGS_HAVE_GC, /* tp_flags */ + instancemethod_doc, /* tp_doc */ + instancemethod_traverse, /* tp_traverse */ + 0, /* tp_clear */ + instancemethod_richcompare, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + instancemethod_memberlist, /* tp_members */ + instancemethod_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + instancemethod_descr_get, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + instancemethod_new, /* tp_new */ +}; From python-3000-checkins at python.org Tue Dec 11 21:20:40 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Tue, 11 Dec 2007 21:20:40 +0100 (CET) Subject: [Python-3000-checkins] r59470 - python/branches/py3k/Python/bltinmodule.c Message-ID: <20071211202040.64DCA1E40B7@bag.python.org> Author: christian.heimes Date: Tue Dec 11 21:20:39 2007 New Revision: 59470 Modified: python/branches/py3k/Python/bltinmodule.c Log: Fixed #1593 spacing of the builtin_format function is inconsistent. Thanks to Joseph for the fix Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Tue Dec 11 21:20:39 2007 @@ -284,58 +284,58 @@ static PyObject * builtin_format(PyObject *self, PyObject *args) { - static PyObject * format_str = NULL; - PyObject *value; - PyObject *spec = NULL; - PyObject *meth; - PyObject *empty = NULL; - PyObject *result = NULL; - - /* Initialize cached value */ - if (format_str == NULL) { - /* Initialize static variable needed by _PyType_Lookup */ - format_str = PyUnicode_FromString("__format__"); - if (format_str == NULL) - goto done; - } - - if (!PyArg_ParseTuple(args, "O|U:format", &value, &spec)) - goto done; - - /* initialize the default value */ - if (spec == NULL) { - empty = PyUnicode_FromUnicode(NULL, 0); - spec = empty; - } - - /* Make sure the type is initialized. float gets initialized late */ - if (Py_Type(value)->tp_dict == NULL) - if (PyType_Ready(Py_Type(value)) < 0) - goto done; - - /* Find the (unbound!) __format__ method (a borrowed reference) */ - meth = _PyType_Lookup(Py_Type(value), format_str); - if (meth == NULL) { - PyErr_Format(PyExc_TypeError, - "Type %.100s doesn't define __format__", - Py_Type(value)->tp_name); - goto done; - } - - /* And call it, binding it to the value */ - result = PyObject_CallFunctionObjArgs(meth, value, spec, NULL); - - if (result && !PyUnicode_Check(result)) { - PyErr_SetString(PyExc_TypeError, - "__format__ method did not return string"); - Py_DECREF(result); - result = NULL; - goto done; - } + static PyObject * format_str = NULL; + PyObject *value; + PyObject *spec = NULL; + PyObject *meth; + PyObject *empty = NULL; + PyObject *result = NULL; + + /* Initialize cached value */ + if (format_str == NULL) { + /* Initialize static variable needed by _PyType_Lookup */ + format_str = PyUnicode_FromString("__format__"); + if (format_str == NULL) + goto done; + } + + if (!PyArg_ParseTuple(args, "O|U:format", &value, &spec)) + goto done; + + /* initialize the default value */ + if (spec == NULL) { + empty = PyUnicode_FromUnicode(NULL, 0); + spec = empty; + } + + /* Make sure the type is initialized. float gets initialized late */ + if (Py_Type(value)->tp_dict == NULL) + if (PyType_Ready(Py_Type(value)) < 0) + goto done; + + /* Find the (unbound!) __format__ method (a borrowed reference) */ + meth = _PyType_Lookup(Py_Type(value), format_str); + if (meth == NULL) { + PyErr_Format(PyExc_TypeError, + "Type %.100s doesn't define __format__", + Py_Type(value)->tp_name); + goto done; + } + + /* And call it, binding it to the value */ + result = PyObject_CallFunctionObjArgs(meth, value, spec, NULL); + + if (result && !PyUnicode_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "__format__ method did not return string"); + Py_DECREF(result); + result = NULL; + goto done; + } done: - Py_XDECREF(empty); - return result; + Py_XDECREF(empty); + return result; } PyDoc_STRVAR(format_doc, From python-3000-checkins at python.org Wed Dec 12 09:32:02 2007 From: python-3000-checkins at python.org (thomas.heller) Date: Wed, 12 Dec 2007 09:32:02 +0100 (CET) Subject: [Python-3000-checkins] r59472 - python/branches/py3k/Lib/ctypes/test/test_values.py Message-ID: <20071212083202.BAA731E4005@bag.python.org> Author: thomas.heller Date: Wed Dec 12 09:32:02 2007 New Revision: 59472 Modified: python/branches/py3k/Lib/ctypes/test/test_values.py Log: This test checks and modifies the value of an integer stored in a dll. Restore the original value after modifying it so that subsequent tests will not fail. Fixes the failure in issue 1597. Modified: python/branches/py3k/Lib/ctypes/test/test_values.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/test_values.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_values.py Wed Dec 12 09:32:02 2007 @@ -16,6 +16,8 @@ self.failUnlessEqual(x, ctdll.get_an_integer()) an_integer.value *= 2 self.failUnlessEqual(x*2, ctdll.get_an_integer()) + an_integer.value = x + self.failUnlessEqual(x, ctdll.get_an_integer()) def test_undefined(self): ctdll = CDLL(_ctypes_test.__file__) From eric+python-dev at trueblade.com Wed Dec 12 11:06:20 2007 From: eric+python-dev at trueblade.com (Eric Smith) Date: Wed, 12 Dec 2007 05:06:20 -0500 Subject: [Python-3000-checkins] r59472 - python/branches/py3k/Lib/ctypes/test/test_values.py In-Reply-To: <20071212083202.BAA731E4005@bag.python.org> References: <20071212083202.BAA731E4005@bag.python.org> Message-ID: <475FB29C.1000706@trueblade.com> I think a comment in the code here would be very helpful. If I ran across this code, I would have no idea that restoring the original value is an important part of what's going on. If I were testing that assigning 0 to 'value' worked (for example), there's every chance I'd put it at the end, after 'value' was restored to 'x'. Eric. thomas.heller wrote: > Author: thomas.heller > Date: Wed Dec 12 09:32:02 2007 > New Revision: 59472 > > Modified: > python/branches/py3k/Lib/ctypes/test/test_values.py > Log: > This test checks and modifies the value of an integer stored in a dll. > Restore the original value after modifying it so that subsequent tests > will not fail. Fixes the failure in issue 1597. > > > Modified: python/branches/py3k/Lib/ctypes/test/test_values.py > ============================================================================== > --- python/branches/py3k/Lib/ctypes/test/test_values.py (original) > +++ python/branches/py3k/Lib/ctypes/test/test_values.py Wed Dec 12 09:32:02 2007 > @@ -16,6 +16,8 @@ > self.failUnlessEqual(x, ctdll.get_an_integer()) > an_integer.value *= 2 > self.failUnlessEqual(x*2, ctdll.get_an_integer()) > + an_integer.value = x > + self.failUnlessEqual(x, ctdll.get_an_integer()) > > def test_undefined(self): > ctdll = CDLL(_ctypes_test.__file__) > _______________________________________________ > Python-3000-checkins mailing list > Python-3000-checkins at python.org > http://mail.python.org/mailman/listinfo/python-3000-checkins > From python-3000-checkins at python.org Wed Dec 12 18:15:06 2007 From: python-3000-checkins at python.org (kurt.kaiser) Date: Wed, 12 Dec 2007 18:15:06 +0100 (CET) Subject: [Python-3000-checkins] r59473 - python/branches/py3k/Lib/idlelib/idlever.py Message-ID: <20071212171506.5F41B1E4021@bag.python.org> Author: kurt.kaiser Date: Wed Dec 12 18:13:19 2007 New Revision: 59473 Modified: python/branches/py3k/Lib/idlelib/idlever.py Log: Bump version Modified: python/branches/py3k/Lib/idlelib/idlever.py ============================================================================== --- python/branches/py3k/Lib/idlelib/idlever.py (original) +++ python/branches/py3k/Lib/idlelib/idlever.py Wed Dec 12 18:13:19 2007 @@ -1 +1 @@ -IDLE_VERSION = "3.0a1" +IDLE_VERSION = "3.0a2" From python-3000-checkins at python.org Wed Dec 12 18:22:11 2007 From: python-3000-checkins at python.org (kurt.kaiser) Date: Wed, 12 Dec 2007 18:22:11 +0100 (CET) Subject: [Python-3000-checkins] r59474 - python/branches/py3k/Lib/idlelib/CodeContext.py Message-ID: <20071212172211.76A8D1E400F@bag.python.org> Author: kurt.kaiser Date: Wed Dec 12 18:22:06 2007 New Revision: 59474 Modified: python/branches/py3k/Lib/idlelib/CodeContext.py Log: maxint->maxsize. Wouldn't import. Modified: python/branches/py3k/Lib/idlelib/CodeContext.py ============================================================================== --- python/branches/py3k/Lib/idlelib/CodeContext.py (original) +++ python/branches/py3k/Lib/idlelib/CodeContext.py Wed Dec 12 18:22:06 2007 @@ -12,7 +12,7 @@ import Tkinter from Tkconstants import TOP, LEFT, X, W, SUNKEN import re -from sys import maxint as INFINITY +from sys import maxsize as INFINITY from idlelib.configHandler import idleConf BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for", From python-3000-checkins at python.org Wed Dec 12 21:01:44 2007 From: python-3000-checkins at python.org (thomas.heller) Date: Wed, 12 Dec 2007 21:01:44 +0100 (CET) Subject: [Python-3000-checkins] r59476 - python/branches/py3k/Lib/ctypes/test/test_values.py Message-ID: <20071212200144.85BD11E400A@bag.python.org> Author: thomas.heller Date: Wed Dec 12 21:01:44 2007 New Revision: 59476 Modified: python/branches/py3k/Lib/ctypes/test/test_values.py Log: Add a comment to explain why we have to restore the original value. Modified: python/branches/py3k/Lib/ctypes/test/test_values.py ============================================================================== --- python/branches/py3k/Lib/ctypes/test/test_values.py (original) +++ python/branches/py3k/Lib/ctypes/test/test_values.py Wed Dec 12 21:01:44 2007 @@ -10,12 +10,16 @@ class ValuesTestCase(unittest.TestCase): def test_an_integer(self): + # This test checks and changes an integer stored inside the + # _ctypes_test dll/shared lib. ctdll = CDLL(_ctypes_test.__file__) an_integer = c_int.in_dll(ctdll, "an_integer") x = an_integer.value self.failUnlessEqual(x, ctdll.get_an_integer()) an_integer.value *= 2 self.failUnlessEqual(x*2, ctdll.get_an_integer()) + # To avoid test failures when this test is repeated several + # times the original value must be restored an_integer.value = x self.failUnlessEqual(x, ctdll.get_an_integer()) From theller at ctypes.org Wed Dec 12 21:03:35 2007 From: theller at ctypes.org (Thomas Heller) Date: Wed, 12 Dec 2007 21:03:35 +0100 Subject: [Python-3000-checkins] r59472 - python/branches/py3k/Lib/ctypes/test/test_values.py In-Reply-To: <475FB29C.1000706@trueblade.com> References: <20071212083202.BAA731E4005@bag.python.org> <475FB29C.1000706@trueblade.com> Message-ID: <47603E97.3090101@ctypes.org> Eric Smith schrieb: > I think a comment in the code here would be very helpful. If I ran > across this code, I would have no idea that restoring the original value > is an important part of what's going on. If I were testing that > assigning 0 to 'value' worked (for example), there's every chance I'd > put it at the end, after 'value' was restored to 'x'. I've added a comment. Thanks, Thomas From python-3000-checkins at python.org Wed Dec 12 21:26:00 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Wed, 12 Dec 2007 21:26:00 +0100 (CET) Subject: [Python-3000-checkins] r59477 - python/branches/py3k/Lib/ctypes/util.py Message-ID: <20071212202600.9DEBE1E4010@bag.python.org> Author: guido.van.rossum Date: Wed Dec 12 21:26:00 2007 New Revision: 59477 Modified: python/branches/py3k/Lib/ctypes/util.py Log: Explicitly close pipes so test_ctypes won't appear to randomly leak +33 or -33 references. (See discussion in #1597.) Modified: python/branches/py3k/Lib/ctypes/util.py ============================================================================== --- python/branches/py3k/Lib/ctypes/util.py (original) +++ python/branches/py3k/Lib/ctypes/util.py Wed Dec 12 21:26:00 2007 @@ -50,8 +50,10 @@ '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name try: f = os.popen(cmd) - trace = f.read() - f.close() + try: + trace = f.read() + finally: + f.close() finally: try: os.unlink(ccout) @@ -70,7 +72,12 @@ if not f: return None cmd = "/usr/ccs/bin/dump -Lpv 2>/dev/null " + f - res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', os.popen(cmd).read()) + f = os.popen(cmd) + try: + data = f.read() + finally: + f.close() + res = re.search(r'\[.*\]\sSONAME\s+([^\s]+)', data) if not res: return None return res.group(1) @@ -80,7 +87,12 @@ if not f: return None cmd = "objdump -p -j .dynamic 2>/dev/null " + f - res = re.search(r'\sSONAME\s+([^\s]+)', os.popen(cmd).read()) + f = os.popen(cmd) + try: + data = f.read() + finally: + f.close() + res = re.search(r'\sSONAME\s+([^\s]+)', data) if not res: return None return res.group(1) @@ -103,8 +115,12 @@ def find_library(name): ename = re.escape(name) expr = r':-l%s\.\S+ => \S*/(lib%s\.\S+)' % (ename, ename) - res = re.findall(expr, - os.popen('/sbin/ldconfig -r 2>/dev/null').read()) + f = os.popen('/sbin/ldconfig -r 2>/dev/null') + try: + data = f.read() + finally: + f.close() + res = re.findall(expr, data) if not res: return _get_soname(_findLib_gcc(name)) res.sort(cmp= lambda x,y: cmp(_num_version(x), _num_version(y))) @@ -115,12 +131,21 @@ def _findLib_ldconfig(name): # XXX assuming GLIBC's ldconfig (with option -p) expr = r'/[^\(\)\s]*lib%s\.[^\(\)\s]*' % re.escape(name) - res = re.search(expr, - os.popen('/sbin/ldconfig -p 2>/dev/null').read()) + f = os.popen('/sbin/ldconfig -p 2>/dev/null') + try: + data = f.read() + finally: + f.close() + res = re.search(expr, data) if not res: # Hm, this works only for libs needed by the python executable. cmd = 'ldd %s 2>/dev/null' % sys.executable - res = re.search(expr, os.popen(cmd).read()) + f = os.popen(cmd) + try: + data = f.read() + finally: + f.close() + res = re.search(expr, data) if not res: return None return res.group(0) From python-3000-checkins at python.org Thu Dec 13 04:38:17 2007 From: python-3000-checkins at python.org (kurt.kaiser) Date: Thu, 13 Dec 2007 04:38:17 +0100 (CET) Subject: [Python-3000-checkins] r59479 - python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/PyShell.py Message-ID: <20071213033817.0A75E1E400A@bag.python.org> Author: kurt.kaiser Date: Thu Dec 13 04:38:16 2007 New Revision: 59479 Modified: python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/PyShell.py Log: Shell was not colorizing due to bug introduced at r57998, Bug 1586. Modified: python/branches/py3k/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/py3k/Lib/idlelib/NEWS.txt (original) +++ python/branches/py3k/Lib/idlelib/NEWS.txt Thu Dec 13 04:38:16 2007 @@ -1,7 +1,20 @@ +What's New in IDLE 3.0a3? +========================= + +*Release date: XX-XXX-200X* + +- CodeContext was not importing. + +- Corrected two 3.0 compatibility errors reported by Mark Summerfield: + http://mail.python.org/pipermail/python-3000/2007-December/011491.html + +- Shell was not colorizing due to bug introduced at r57998, Bug 1586. + + What's New in IDLE 3.0a2? ========================= -*Release date: XX-XXX-2007* +*Release date: 06-Dec-2007* - Windows EOL sequence not converted correctly, encoding error. Caused file save to fail. Bug 1130. @@ -28,7 +41,7 @@ What's New in IDLE 2.6a1? ========================= -*Release date: XX-XXX-200X* UNRELEASED, but merged into 3.0a1 +*Release date: XX-XXX-200X* UNRELEASED, but merged into 3.0 - tabpage.py updated: tabbedPages.py now supports multiple dynamic rows of tabs. Patch 1612746 Tal Einat. Modified: python/branches/py3k/Lib/idlelib/PyShell.py ============================================================================== --- python/branches/py3k/Lib/idlelib/PyShell.py (original) +++ python/branches/py3k/Lib/idlelib/PyShell.py Thu Dec 13 04:38:16 2007 @@ -811,6 +811,8 @@ text.bind("<>", self.open_stack_viewer) text.bind("<>", self.toggle_debugger) text.bind("<>", self.toggle_jit_stack_viewer) + self.color = color = self.ColorDelegator() + self.per.insertfilter(color) if use_subprocess: text.bind("<>", self.view_restart_mark) text.bind("<>", self.restart_shell) From python-3000-checkins at python.org Fri Dec 14 02:24:45 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 14 Dec 2007 02:24:45 +0100 (CET) Subject: [Python-3000-checkins] r59488 - in python/branches/py3k: Doc/ACKS.txt Doc/library/collections.rst Lib/collections.py Lib/distutils/sysconfig.py Lib/idlelib/tabbedpages.py Lib/idlelib/tabpage.py Lib/test/test_deque.py Lib/test/test_urlparse.py Lib/urlparse.py Misc/ACKS Modules/_collectionsmodule.c Modules/_sqlite/statement.c Modules/_sqlite/util.c Modules/xxmodule.c configure configure.in Message-ID: <20071214012445.B1BB21E400C@bag.python.org> Author: christian.heimes Date: Fri Dec 14 02:24:44 2007 New Revision: 59488 Removed: python/branches/py3k/Lib/idlelib/tabpage.py Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/distutils/sysconfig.py python/branches/py3k/Lib/idlelib/tabbedpages.py python/branches/py3k/Lib/test/test_deque.py python/branches/py3k/Lib/test/test_urlparse.py python/branches/py3k/Lib/urlparse.py python/branches/py3k/Misc/ACKS python/branches/py3k/Modules/_collectionsmodule.c python/branches/py3k/Modules/_sqlite/statement.c python/branches/py3k/Modules/_sqlite/util.c python/branches/py3k/Modules/xxmodule.c python/branches/py3k/configure python/branches/py3k/configure.in Log: Merged revisions 59465-59487 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59467 | georg.brandl | 2007-12-11 17:32:49 +0100 (Tue, 11 Dec 2007) | 2 lines Add another GHOP contributor. ........ r59468 | kurt.kaiser | 2007-12-11 20:35:12 +0100 (Tue, 11 Dec 2007) | 3 lines IDLE_tabbedpages.071101.patch Tal Einat Cosmetic changes, one bug. Remove tabpage.py, replaced by tabbedpages.py ........ r59471 | gerhard.haering | 2007-12-11 22:07:40 +0100 (Tue, 11 Dec 2007) | 9 lines Forward-port of commit 59184. - Backported a workaround for a bug in SQLite 3.2.x/3.3.x versions where a statement recompilation with no bound parameters lead to a segfault - Backported a fix necessary because of an SQLite API change in version 3.5. This prevents segfaults when executing empty queries, like our test suite does ........ r59475 | christian.heimes | 2007-12-12 19:09:06 +0100 (Wed, 12 Dec 2007) | 1 line Fixed a nasty problem in the xxmodule.c ........ r59478 | raymond.hettinger | 2007-12-13 01:08:37 +0100 (Thu, 13 Dec 2007) | 1 line Fix bug 1604. deque.__init__() did not clear existing contents like list.__init__. Not a backport candidate. ........ r59480 | alexandre.vassalotti | 2007-12-13 18:58:23 +0100 (Thu, 13 Dec 2007) | 2 lines Fix issue #1313119: urlparse "caches" parses regardless of encoding ........ r59482 | christian.heimes | 2007-12-13 20:23:16 +0100 (Thu, 13 Dec 2007) | 1 line Fixed bug #1613: Makefile's VPATH feature is broken ........ r59484 | guido.van.rossum | 2007-12-13 21:50:10 +0100 (Thu, 13 Dec 2007) | 3 lines Patch #1608. Someone with access to autoconf 2.61 or higher needs to run it and check in the resulting configure file. ........ r59485 | thomas.heller | 2007-12-13 22:20:29 +0100 (Thu, 13 Dec 2007) | 1 line Ran autoconf. ........ r59486 | raymond.hettinger | 2007-12-13 23:55:52 +0100 (Thu, 13 Dec 2007) | 1 line Simplify implementation of __replace__() ........ r59487 | raymond.hettinger | 2007-12-14 00:52:59 +0100 (Fri, 14 Dec 2007) | 1 line Small speedup ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Fri Dec 14 02:24:44 2007 @@ -136,6 +136,7 @@ * Tomas Oppelstrup * Denis S. Otkidach * Zooko O'Whielacronx + * Shriphani Palakodety * William Park * Joonas Paalasmaa * Harri Pasanen Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Fri Dec 14 02:24:44 2007 @@ -429,7 +429,7 @@ return dict(zip(('x', 'y'), self)) def __replace__(self, **kwds): 'Return a new Point object replacing specified fields with new values' - return Point(**dict(zip(('x', 'y'), self) + kwds.items())) + return Point(**dict(zip(('x', 'y'), self), **kwds)) x = property(itemgetter(0)) y = property(itemgetter(1)) Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Fri Dec 14 02:24:44 2007 @@ -2,6 +2,7 @@ from _collections import deque, defaultdict from operator import itemgetter as _itemgetter +from itertools import izip as _izip from keyword import iskeyword as _iskeyword import sys as _sys @@ -70,14 +71,14 @@ return dict(zip(%(field_names)r, self)) def __replace__(self, **kwds): 'Return a new %(typename)s object replacing specified fields with new values' - return %(typename)s(**dict(list(zip(%(field_names)r, self)) + list(kwds.items()))) \n''' % locals() + return %(typename)s(**dict(zip(%(field_names)r, self), **kwds)) \n''' % locals() for i, name in enumerate(field_names): template += ' %s = property(itemgetter(%d))\n' % (name, i) if verbose: print(template) # Execute the template string in a temporary namespace - namespace = dict(itemgetter=_itemgetter) + namespace = dict(itemgetter=_itemgetter, zip=_izip) try: exec(template, namespace) except SyntaxError as e: Modified: python/branches/py3k/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/sysconfig.py Fri Dec 14 02:24:44 2007 @@ -32,7 +32,7 @@ # building an extension with an un-installed Python, so we use # different (hard-wired) directories. python_build = os.path.isfile(os.path.join(project_base, "Modules", - "Setup.dist")) + "Setup.local")) def get_python_version(): """Return a string containing the major and minor Python version, Modified: python/branches/py3k/Lib/idlelib/tabbedpages.py ============================================================================== --- python/branches/py3k/Lib/idlelib/tabbedpages.py (original) +++ python/branches/py3k/Lib/idlelib/tabbedpages.py Fri Dec 14 02:24:44 2007 @@ -4,7 +4,7 @@ Classes exported: TabbedPageSet -- A Tkinter implementation of a tabbed-page widget. -TabBarSet -- A widget containing tabs (buttons) in one or more rows. +TabSet -- A widget containing tabs (buttons) in one or more rows. """ from Tkinter import * @@ -13,7 +13,7 @@ class AlreadyExistsError(Exception): pass -class TabBarSet(Frame): +class TabSet(Frame): """A widget containing tabs (buttons) in one or more rows. Only one tab may be selected at a time. @@ -30,11 +30,11 @@ tabs -- A list of strings, the names of the tabs. Should be specified in the desired tab order. The first tab will be the default and first - active tab. If tabs is None or empty, the TabBarSet will be initialized + active tab. If tabs is None or empty, the TabSet will be initialized empty. n_rows -- Number of rows of tabs to be shown. If n_rows <= 0 or is - None, then the number of rows will be decided by TabBarSet. See + None, then the number of rows will be decided by TabSet. See _arrange_tabs() for details. max_tabs_per_row -- Used for deciding how many rows of tabs are needed, @@ -76,15 +76,15 @@ self._arrange_tabs() def remove_tab(self, tab_name): - """Remove the tab with the name given in tab_name.""" + """Remove the tab named """ if not tab_name in self._tab_names: raise KeyError("No such Tab: '%s" % page_name) self._tab_names.remove(tab_name) self._arrange_tabs() - def select_tab(self, tab_name): - """Select the tab with the name given in tab_name.""" + def set_selected_tab(self, tab_name): + """Show the tab named as the selected one""" if tab_name == self._selected_tab: return if tab_name is not None and tab_name not in self._tabs: @@ -111,14 +111,11 @@ tab_row = Frame(self) tab_row.pack(side=TOP, fill=X, expand=0) - tab_row.tab_set = self self._tab_rows.append(tab_row) for tab_name in tab_names: - def tab_command(select_command=self.select_command, - tab_name=tab_name): - return select_command(tab_name) - tab = TabBarSet.TabButton(tab_row, tab_name, tab_command) + tab = TabSet.TabButton(tab_name, self.select_command, + tab_row, self) if expand_tabs: tab.pack(side=LEFT, fill=X, expand=True) else: @@ -126,6 +123,7 @@ self._tabs[tab_name] = tab self._tab2row[tab] = tab_row + # tab is the last one created in the above loop tab.is_last_in_row = True def _reset_tab_rows(self): @@ -158,8 +156,9 @@ # calculate the required number of rows n_rows = (len(self._tab_names) - 1) // self.max_tabs_per_row + 1 - i = 0 + # not expanding the tabs with more than one row is very ugly expand_tabs = self.expand_tabs or n_rows > 1 + i = 0 # index in self._tab_names for row_index in range(n_rows): # calculate required number of tabs in this row n_tabs = (len(self._tab_names) - i - 1) // (n_rows - row_index) + 1 @@ -169,47 +168,60 @@ # re-select selected tab so it is properly displayed selected = self._selected_tab - self.select_tab(None) + self.set_selected_tab(None) if selected in self._tab_names: - self.select_tab(selected) + self.set_selected_tab(selected) class TabButton(Frame): """A simple tab-like widget.""" bw = 2 # borderwidth - def __init__(self, tab_row, name, command): + def __init__(self, name, select_command, tab_row, tab_set): """Constructor arguments: name -- The tab's name, which will appear in its button. - command -- The command to be called upon selection of the tab. It - is called with the tab's name as an argument. + select_command -- The command to be called upon selection of the + tab. It is called with the tab's name as an argument. """ - Frame.__init__(self, tab_row, borderwidth=self.bw) - self.button = Radiobutton(self, text=name, command=command, + Frame.__init__(self, tab_row, borderwidth=self.bw, relief=RAISED) + + self.name = name + self.select_command = select_command + self.tab_set = tab_set + self.is_last_in_row = False + + self.button = Radiobutton( + self, text=name, command=self._select_event, padx=5, pady=1, takefocus=FALSE, indicatoron=FALSE, highlightthickness=0, selectcolor='', borderwidth=0) self.button.pack(side=LEFT, fill=X, expand=True) - self.tab_set = tab_row.tab_set - - self.is_last_in_row = False - self._init_masks() self.set_normal() + def _select_event(self, *args): + """Event handler for tab selection. + + With TabbedPageSet, this calls TabbedPageSet.change_page, so that + selecting a tab changes the page. + + Note that this does -not- call set_selected -- it will be called by + TabSet.set_selected_tab, which should be called when whatever the + tabs are related to changes. + + """ + self.select_command(self.name) + return + def set_selected(self): """Assume selected look""" - for widget in self, self.mskl.ml, self.mskr.mr: - widget.config(relief=RAISED) self._place_masks(selected=True) def set_normal(self): """Assume normal look""" - for widget in self, self.mskl.ml, self.mskr.mr: - widget.config(relief=RAISED) self._place_masks(selected=False) def _init_masks(self): @@ -351,8 +363,8 @@ and first active page. If page_names is None or empty, the TabbedPageSet will be initialized empty. - n_rows, max_tabs_per_row -- Parameters for the TabBarSet which will - manage the tabs. See TabBarSet's docs for details. + n_rows, max_tabs_per_row -- Parameters for the TabSet which will + manage the tabs. See TabSet's docs for details. page_class -- Pages can be shown/hidden using three mechanisms: @@ -372,7 +384,7 @@ TabbedPageSet to resize when the page is changed. """ - Frame.__init__(self, parent, kw) + Frame.__init__(self, parent, **kw) self.page_class = page_class self.pages = {} @@ -390,9 +402,9 @@ self.pages_frame.rowconfigure(0, weight=1) # the order of the following commands is important - self._tab_set = TabBarSet(self, self.change_page, n_rows=n_rows, - max_tabs_per_row=max_tabs_per_row, - expand_tabs=expand_tabs) + self._tab_set = TabSet(self, self.change_page, n_rows=n_rows, + max_tabs_per_row=max_tabs_per_row, + expand_tabs=expand_tabs) if page_names: for name in page_names: self.add_page(name) @@ -453,7 +465,7 @@ self._current_page = page_name self.pages[page_name]._show() - self._tab_set.select_tab(page_name) + self._tab_set.set_selected_tab(page_name) if __name__ == '__main__': # test dialog Deleted: /python/branches/py3k/Lib/idlelib/tabpage.py ============================================================================== --- /python/branches/py3k/Lib/idlelib/tabpage.py Fri Dec 14 02:24:44 2007 +++ (empty file) @@ -1,113 +0,0 @@ -""" -a couple of classes for implementing partial tabbed-page like behaviour -""" - -from Tkinter import * - -class InvalidTabPage(Exception): pass -class AlreadyExists(Exception): pass - -class PageTab(Frame): - """ - a 'page tab' like framed button - """ - def __init__(self,parent): - Frame.__init__(self, parent,borderwidth=2,relief=RIDGE) - self.button=Radiobutton(self,padx=5,pady=5,takefocus=FALSE, - indicatoron=FALSE,highlightthickness=0, - borderwidth=0,selectcolor=self.cget('bg')) - self.button.pack() - -class TabPageSet(Frame): - """ - a set of 'pages' with TabButtons for controlling their display - """ - def __init__(self,parent,pageNames=[],**kw): - """ - pageNames - a list of strings, each string will be the dictionary key - to a page's data, and the name displayed on the page's tab. Should be - specified in desired page order. The first page will be the default - and first active page. - """ - Frame.__init__(self, parent, kw) - self.grid_location(0,0) - self.columnconfigure(0,weight=1) - self.rowconfigure(1,weight=1) - self.tabBar=Frame(self) - self.tabBar.grid(row=0,column=0,sticky=EW) - self.activePage=StringVar(self) - self.defaultPage='' - self.pages={} - for name in pageNames: - self.AddPage(name) - - def ChangePage(self,pageName=None): - if pageName: - if pageName in self.pages: - self.activePage.set(pageName) - else: - raise InvalidTabPage('Invalid TabPage Name') - ## pop up the active 'tab' only - for page in self.pages: - self.pages[page]['tab'].config(relief=RIDGE) - self.pages[self.GetActivePage()]['tab'].config(relief=RAISED) - ## switch page - self.pages[self.GetActivePage()]['page'].lift() - - def GetActivePage(self): - return self.activePage.get() - - def AddPage(self,pageName): - if pageName in self.pages.keys(): - raise AlreadyExists('TabPage Name Already Exists') - self.pages[pageName]={'tab':PageTab(self.tabBar), - 'page':Frame(self,borderwidth=2,relief=RAISED)} - self.pages[pageName]['tab'].button.config(text=pageName, - command=self.ChangePage,variable=self.activePage, - value=pageName) - self.pages[pageName]['tab'].pack(side=LEFT) - self.pages[pageName]['page'].grid(row=1,column=0,sticky=NSEW) - if len(self.pages)==1: # adding first page - self.defaultPage=pageName - self.activePage.set(self.defaultPage) - self.ChangePage() - - def RemovePage(self,pageName): - if not pageName in self.pages: - raise InvalidTabPage('Invalid TabPage Name') - self.pages[pageName]['tab'].pack_forget() - self.pages[pageName]['page'].grid_forget() - self.pages[pageName]['tab'].destroy() - self.pages[pageName]['page'].destroy() - del(self.pages[pageName]) - # handle removing last remaining, or default, or active page - if not self.pages: # removed last remaining page - self.defaultPage='' - return - if pageName==self.defaultPage: # set a new default page - self.defaultPage=\ - self.tabBar.winfo_children()[0].button.cget('text') - if pageName==self.GetActivePage(): # set a new active page - self.activePage.set(self.defaultPage) - self.ChangePage() - -if __name__ == '__main__': - #test dialog - root=Tk() - tabPage=TabPageSet(root,pageNames=['Foobar','Baz']) - tabPage.pack(expand=TRUE,fill=BOTH) - Label(tabPage.pages['Foobar']['page'],text='Foo',pady=20).pack() - Label(tabPage.pages['Foobar']['page'],text='Bar',pady=20).pack() - Label(tabPage.pages['Baz']['page'],text='Baz').pack() - entryPgName=Entry(root) - buttonAdd=Button(root,text='Add Page', - command=lambda:tabPage.AddPage(entryPgName.get())) - buttonRemove=Button(root,text='Remove Page', - command=lambda:tabPage.RemovePage(entryPgName.get())) - labelPgName=Label(root,text='name of page to add/remove:') - buttonAdd.pack(padx=5,pady=5) - buttonRemove.pack(padx=5,pady=5) - labelPgName.pack(padx=5) - entryPgName.pack(padx=5) - tabPage.ChangePage() - root.mainloop() Modified: python/branches/py3k/Lib/test/test_deque.py ============================================================================== --- python/branches/py3k/Lib/test/test_deque.py (original) +++ python/branches/py3k/Lib/test/test_deque.py Fri Dec 14 02:24:44 2007 @@ -29,8 +29,8 @@ class TestBasic(unittest.TestCase): def test_basics(self): - d = deque(range(100)) - d.__init__(range(100, 200)) + d = deque(range(-5125, -5000)) + d.__init__(range(200)) for i in range(200, 400): d.append(i) for i in reversed(range(-200, 0)): @@ -433,8 +433,8 @@ class TestSubclass(unittest.TestCase): def test_basics(self): - d = Deque(range(100)) - d.__init__(range(100, 200)) + d = Deque(range(25)) + d.__init__(range(200)) for i in range(200, 400): d.append(i) for i in reversed(range(-200, 0)): Modified: python/branches/py3k/Lib/test/test_urlparse.py ============================================================================== --- python/branches/py3k/Lib/test/test_urlparse.py (original) +++ python/branches/py3k/Lib/test/test_urlparse.py Fri Dec 14 02:24:44 2007 @@ -287,7 +287,6 @@ self.assertEqual(p.port, None) self.assertEqual(p.geturl(), uri) - def test_main(): test_support.run_unittest(UrlParseTestCase) Modified: python/branches/py3k/Lib/urlparse.py ============================================================================== --- python/branches/py3k/Lib/urlparse.py (original) +++ python/branches/py3k/Lib/urlparse.py Fri Dec 14 02:24:44 2007 @@ -184,7 +184,7 @@ Note that we don't break the components up in smaller bits (e.g. netloc is a single string) and we don't expand % escapes.""" allow_fragments = bool(allow_fragments) - key = url, scheme, allow_fragments + key = url, scheme, allow_fragments, type(url), type(scheme) cached = _parse_cache.get(key, None) if cached: return cached Modified: python/branches/py3k/Misc/ACKS ============================================================================== --- python/branches/py3k/Misc/ACKS (original) +++ python/branches/py3k/Misc/ACKS Fri Dec 14 02:24:44 2007 @@ -168,6 +168,7 @@ Daniel Dittmar Walter D?rwald Jaromir Dolecek +Ismail Donmez Dima Dorfman Cesar Douady Dean Draayer Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Fri Dec 14 02:24:44 2007 @@ -784,6 +784,7 @@ } } deque->maxlen = maxlen; + deque_clear(deque); if (iterable != NULL) { PyObject *rv = deque_extend(deque, iterable); if (rv == NULL) Modified: python/branches/py3k/Modules/_sqlite/statement.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/statement.c (original) +++ python/branches/py3k/Modules/_sqlite/statement.c Fri Dec 14 02:24:44 2007 @@ -231,7 +231,11 @@ */ #ifdef SQLITE_VERSION_NUMBER #if SQLITE_VERSION_NUMBER >= 3002002 - (void)sqlite3_transfer_bindings(self->st, new_st); + /* The check for the number of parameters is necessary to not trigger a + * bug in certain SQLite versions (experienced in 3.2.8 and 3.3.4). */ + if (sqlite3_bind_parameter_count(self->st) > 0) { + (void)sqlite3_transfer_bindings(self->st, new_st); + } #endif #else statement_bind_parameters(self, params); Modified: python/branches/py3k/Modules/_sqlite/util.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/util.c (original) +++ python/branches/py3k/Modules/_sqlite/util.c Fri Dec 14 02:24:44 2007 @@ -28,9 +28,15 @@ { int rc; - Py_BEGIN_ALLOW_THREADS - rc = sqlite3_step(statement); - Py_END_ALLOW_THREADS + if (statement == NULL) { + /* this is a workaround for SQLite 3.5 and later. it now apparently + * returns NULL for "no-operation" statements */ + rc = SQLITE_OK; + } else { + Py_BEGIN_ALLOW_THREADS + rc = sqlite3_step(statement); + Py_END_ALLOW_THREADS + } return rc; } Modified: python/branches/py3k/Modules/xxmodule.c ============================================================================== --- python/branches/py3k/Modules/xxmodule.c (original) +++ python/branches/py3k/Modules/xxmodule.c Fri Dec 14 02:24:44 2007 @@ -349,7 +349,7 @@ Str_Type.tp_base = &PyUnicode_Type; /* Finalize the type object including setting type of the new type - * object; doing it here is required for portability, too. /* + * object; doing it here is required for portability, too. */ if (PyType_Ready(&Xxo_Type) < 0) return; Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Fri Dec 14 02:24:44 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 59247 . +# From configure.in Revision: 59484 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -4403,6 +4403,10 @@ if test "$CC" != 'g++' ; then STRICT_PROTO="-Wstrict-prototypes" fi + # For gcc 4.x we need to use -fwrapv so lets check if its supported + if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then + WRAP="-fwrapv" + fi case $ac_cv_prog_cc_g in yes) if test "$Py_DEBUG" = 'true' ; then @@ -4410,7 +4414,7 @@ # debug builds. OPT="-g -Wall $STRICT_PROTO" else - OPT="-g -O3 -Wall $STRICT_PROTO" + OPT="-g $WRAP -O3 -Wall $STRICT_PROTO" fi ;; *) Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Fri Dec 14 02:24:44 2007 @@ -732,6 +732,10 @@ if test "$CC" != 'g++' ; then STRICT_PROTO="-Wstrict-prototypes" fi + # For gcc 4.x we need to use -fwrapv so lets check if its supported + if "$CC" -v --help 2>/dev/null |grep -- -fwrapv > /dev/null; then + WRAP="-fwrapv" + fi case $ac_cv_prog_cc_g in yes) if test "$Py_DEBUG" = 'true' ; then @@ -739,7 +743,7 @@ # debug builds. OPT="-g -Wall $STRICT_PROTO" else - OPT="-g -O3 -Wall $STRICT_PROTO" + OPT="-g $WRAP -O3 -Wall $STRICT_PROTO" fi ;; *) From python-3000-checkins at python.org Fri Dec 14 11:07:44 2007 From: python-3000-checkins at python.org (mark.summerfield) Date: Fri, 14 Dec 2007 11:07:44 +0100 (CET) Subject: [Python-3000-checkins] r59499 - python/branches/py3k/Doc/library/functions.rst Message-ID: <20071214100744.D5BD41E4020@bag.python.org> Author: mark.summerfield Date: Fri Dec 14 11:07:44 2007 New Revision: 59499 Modified: python/branches/py3k/Doc/library/functions.rst Log: Updated open() to more accurately reflect io.open()'s documentation. Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Fri Dec 14 11:07:44 2007 @@ -705,31 +705,85 @@ :meth:`__index__` method that returns an integer. -.. function:: open(filename[, mode[, bufsize]]) +.. function:: open(filename[, mode='r'[, buffering=None[, encoding=None[, errors=None[, newline=None[, closefd=True]]]]]]) Open a file, returning an object of the :class:`file` type described in section :ref:`bltin-file-objects`. If the file cannot be opened, :exc:`IOError` is raised. When opening a file, it's preferable to use :func:`open` instead of invoking the :class:`file` constructor directly. + + *filename* is either a string giving the name (and the path if the + file isn't in the current working directory) of the file to be + opened; or an integer file descriptor of the file to be wrapped. (If + a file descriptor is given, it is closed when the returned I/O object + is closed, unless *closefd* is set to ``False``.) + + *mode* is an optional string that specifies the mode in which the file is + opened. It defaults to ``'r'`` which means open for reading in text mode. + Other common values are ``'w'`` for writing (truncating the file if + it already exists), and ``'a'`` for appending (which on *some* Unix + systems means that *all* writes append to the end of the file + regardless of the current seek position). In text mode, if *encoding* + is not specified the encoding is assumed to be UTF-8. (For reading + and writing raw bytes use binary mode and leave *encoding* + unspecified.) The available modes are: + + * 'r' open for reading (default) + * 'w' open for writing, truncating the file first + * 'a' open for writing, appending to the end if the file exists + * 'b' binary mode + * 't' text mode (default) + * '+' open the file for updating (implies both reading and writing) + * 'U' universal newline mode (for backwards compatibility; + unnecessary in new code) - The first two arguments are the same as for ``stdio``'s :cfunc:`fopen`: - *filename* is the file name to be opened, and *mode* is a string - indicating how the file is to be opened. - - The most commonly-used values of *mode* are ``'r'`` for reading, ``'w'`` - for writing (truncating the file if it already exists), and ``'a'`` for - appending (which on *some* Unix systems means that *all* writes append to - the end of the file regardless of the current seek position). If *mode* - is omitted, it defaults to ``'r'``. See below for more possible values - of *mode*. + Combine ``'b'`` with ``'r'``, ``'w'``, or ``'a'``, for binary + mode, e.g., ``'rb'`` to open a file for reading in binary mode. + Modes ``'r+'``, ``'w+'`` and ``'a+'`` open the file for updating (note + that ``'w+'`` truncates the file). Python distinguishes between files opened in binary and text modes, even when the underlying operating system doesn't. Files opened in binary - mode (appending ``'b'`` to the *mode* argument to :func:``open``) return - contents as bytes objects without any decoding. In text mode (the - default, or when ``'t'`` is appended to the *mode* argument) the contents - of the file are returned as strings, the bytes having been first decoded - using the encoding specified by :func:`sys.getfilesystemencoding`. + mode (appending ``'b'`` to the *mode* argument) return contents as + ``bytes`` objects without any decoding. In text mode (the default, + or when ``'t'`` is appended to the *mode* argument) the contents of + the file are returned as strings, the bytes having been first decoded + using the UTF-8 encoding or using the specified *encoding* if given. + + *buffering* is an optional integer used to set the buffering policy. By + default full buffering is on. Pass 0 to switch buffering off (only + allowed in binary mode), 1 to set line buffering, and an integer > 1 + for full buffering. + + *encoding* is an optional string that specifies the file's encoding when + reading or writing in text mode---this argument should not be used in + binary mode. The default encoding is UTF-8, but any encoding + supported by Python can be used. (See the :mod:`codecs` module for + the list of supported encodings.) + + *errors* is an optional string that specifies how encoding errors are to be + handled---this argument should not be used in binary mode. Pass + ``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding + error, or ``'ignore'`` to ignore errors. (Note that ignoring encoding + errors can lead to data loss.) See the documentation for + :func:`codecs.register` for a list of the permitted encoding error strings. + + *newline* is an optional string that specifies the newline character(s). + When reading, if *newline* is ``None``, universal newlines mode is enabled. + Lines read in univeral newlines mode can end in ``'\n'``, ``'\r'``, + or ``'\r\n'``, and these are translated into ``'\n'``. If *newline* + is ``''``, universal newline mode is enabled, but line endings are + not translated. If any other string is given, lines are assumed to be + terminated by that string, and no translating is done. When writing, + if *newline* is ``None``, any ``'\n'`` characters written are + translated to the system default line separator, :attr:`os.linesep`. + If *newline* is ``''``, no translation takes place. If *newline* is + any of the other standard values, any ``'\n'`` characters written are + translated to the given string. + + *closefd* is an optional Boolean which specifies whether to keep the + underlying file descriptor open. It must be ``True`` (the default) if + a filename is given. .. index:: single: line-buffered I/O @@ -740,27 +794,7 @@ single: text mode module: sys - The optional *bufsize* argument specifies the file's desired buffer size: - 0 means unbuffered, 1 means line buffered, any other positive value means - use a buffer of (approximately) that size. A negative *bufsize* means to - use the system default, which is usually line buffered for tty devices - and fully buffered for other files. If omitted, the system default is - used. [#]_ - - Modes ``'r+'``, ``'w+'`` and ``'a+'`` open the file for updating (note - that ``'w+'`` truncates the file). - - When a file is opened in text mode it is also opened in universal - newlines mode. Unlike earlier versions of Python it's no longer - necessary to add a ``'U'`` value to the *mode* argument to enable this - mode. Consequently, in files opened in text mode lines may be terminated - with ``'\n'``, ``'\r'``, or ``'\r\n'``. All three external - representations are seen as ``'\n'`` by the Python program. File objects - opened in text mode also have a :attr:`newlines` attribute which has a - value of ``None`` (if no newlines have been seen yet), ``'\n'``, - ``'\r'``, ``'\r\n'``, or a tuple containing all the newline types seen. - - Python provides many file handling modules including + See also the file handling modules, such as, :mod:`fileinput`, :mod:`os`, :mod:`os.path`, :mod:`tempfile`, and :mod:`shutil`. From python-3000-checkins at python.org Fri Dec 14 19:23:42 2007 From: python-3000-checkins at python.org (mark.summerfield) Date: Fri, 14 Dec 2007 19:23:42 +0100 (CET) Subject: [Python-3000-checkins] r59502 - python/branches/py3k/Doc/library/functions.rst Message-ID: <20071214182342.841801E4009@bag.python.org> Author: mark.summerfield Date: Fri Dec 14 19:23:42 2007 New Revision: 59502 Modified: python/branches/py3k/Doc/library/functions.rst Log: Couple of corrections to open() doc as per email from GvR. Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Fri Dec 14 19:23:42 2007 @@ -724,7 +724,7 @@ it already exists), and ``'a'`` for appending (which on *some* Unix systems means that *all* writes append to the end of the file regardless of the current seek position). In text mode, if *encoding* - is not specified the encoding is assumed to be UTF-8. (For reading + is not specified the encoding used is platform dependent. (For reading and writing raw bytes use binary mode and leave *encoding* unspecified.) The available modes are: @@ -748,7 +748,8 @@ ``bytes`` objects without any decoding. In text mode (the default, or when ``'t'`` is appended to the *mode* argument) the contents of the file are returned as strings, the bytes having been first decoded - using the UTF-8 encoding or using the specified *encoding* if given. + using a platform-dependent encoding or using the specified *encoding* + if given. *buffering* is an optional integer used to set the buffering policy. By default full buffering is on. Pass 0 to switch buffering off (only @@ -757,16 +758,17 @@ *encoding* is an optional string that specifies the file's encoding when reading or writing in text mode---this argument should not be used in - binary mode. The default encoding is UTF-8, but any encoding + binary mode. The default encoding is platform dependent, but any encoding supported by Python can be used. (See the :mod:`codecs` module for the list of supported encodings.) *errors* is an optional string that specifies how encoding errors are to be handled---this argument should not be used in binary mode. Pass ``'strict'`` to raise a :exc:`ValueError` exception if there is an encoding - error, or ``'ignore'`` to ignore errors. (Note that ignoring encoding - errors can lead to data loss.) See the documentation for - :func:`codecs.register` for a list of the permitted encoding error strings. + error (the default of ``None`` has the same effect), or pass ``'ignore'`` + to ignore errors. (Note that ignoring encoding errors can lead to + data loss.) See the documentation for :func:`codecs.register` for a + list of the permitted encoding error strings. *newline* is an optional string that specifies the newline character(s). When reading, if *newline* is ``None``, universal newlines mode is enabled. From python-3000-checkins at python.org Fri Dec 14 23:08:57 2007 From: python-3000-checkins at python.org (bill.janssen) Date: Fri, 14 Dec 2007 23:08:57 +0100 (CET) Subject: [Python-3000-checkins] r59506 - in python/branches/py3k: Lib/socket.py Lib/ssl.py Lib/test/test_ssl.py Modules/_ssl.c Message-ID: <20071214220857.8AF201E4009@bag.python.org> Author: bill.janssen Date: Fri Dec 14 23:08:56 2007 New Revision: 59506 Modified: python/branches/py3k/Lib/socket.py python/branches/py3k/Lib/ssl.py python/branches/py3k/Lib/test/test_ssl.py python/branches/py3k/Modules/_ssl.c Log: update to fix leak in SSL code Modified: python/branches/py3k/Lib/socket.py ============================================================================== --- python/branches/py3k/Lib/socket.py (original) +++ python/branches/py3k/Lib/socket.py Fri Dec 14 23:08:56 2007 @@ -174,11 +174,13 @@ if self._closed: self.close() + def _real_close(self): + _socket.socket.close(self) + def close(self): self._closed = True if self._io_refs <= 0: - _socket.socket.close(self) - + self._real_close() def fromfd(fd, family, type, proto=0): """ fromfd(fd, family, type[, proto]) -> socket object Modified: python/branches/py3k/Lib/ssl.py ============================================================================== --- python/branches/py3k/Lib/ssl.py (original) +++ python/branches/py3k/Lib/ssl.py Fri Dec 14 23:08:56 2007 @@ -80,6 +80,7 @@ from socket import error as socket_error from socket import dup as _dup import base64 # for DER-to-PEM translation +import traceback class SSLSocket(socket): @@ -94,16 +95,13 @@ family=AF_INET, type=SOCK_STREAM, proto=0, fileno=None, suppress_ragged_eofs=True): - self._base = None - if sock is not None: - # copied this code from socket.accept() - fd = sock.fileno() - nfd = _dup(fd) - socket.__init__(self, family=sock.family, type=sock.type, - proto=sock.proto, fileno=nfd) + socket.__init__(self, + family=sock.family, + type=sock.type, + proto=sock.proto, + fileno=_dup(sock.fileno())) sock.close() - sock = None elif fileno is not None: socket.__init__(self, fileno=fileno) else: @@ -136,10 +134,6 @@ self.close() raise x - if sock and (self.fileno() != sock.fileno()): - self._base = sock - else: - self._base = None self.keyfile = keyfile self.certfile = certfile self.cert_reqs = cert_reqs @@ -156,19 +150,23 @@ # raise an exception here if you wish to check for spurious closes pass - def read(self, len=None, buffer=None): + def read(self, len=0, buffer=None): """Read up to LEN bytes and return them. Return zero-length string on EOF.""" self._checkClosed() try: if buffer: - return self._sslobj.read(buffer, len) + v = self._sslobj.read(buffer, len) else: - return self._sslobj.read(len or 1024) + v = self._sslobj.read(len or 1024) + return v except SSLError as x: if x.args[0] == SSL_ERROR_EOF and self.suppress_ragged_eofs: - return b'' + if buffer: + return 0 + else: + return b'' else: raise @@ -269,7 +267,6 @@ while True: try: v = self.read(nbytes, buffer) - sys.stdout.flush() return v except SSLError as x: if x.args[0] == SSL_ERROR_WANT_READ: @@ -302,9 +299,7 @@ def _real_close(self): self._sslobj = None # self._closed = True - if self._base: - self._base.close() - socket.close(self) + socket._real_close(self) def do_handshake(self, block=False): """Perform a TLS/SSL handshake.""" @@ -329,8 +324,12 @@ self._sslobj = _ssl.sslwrap(self, False, self.keyfile, self.certfile, self.cert_reqs, self.ssl_version, self.ca_certs) - if self.do_handshake_on_connect: - self.do_handshake() + try: + if self.do_handshake_on_connect: + self.do_handshake() + except: + self._sslobj = None + raise def accept(self): """Accepts a new connection from a remote client, and returns @@ -348,10 +347,11 @@ self.do_handshake_on_connect), addr) - def __del__(self): + # sys.stderr.write("__del__ on %s\n" % repr(self)) self._real_close() + def wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version=PROTOCOL_SSLv23, ca_certs=None, Modified: python/branches/py3k/Lib/test/test_ssl.py ============================================================================== --- python/branches/py3k/Lib/test/test_ssl.py (original) +++ python/branches/py3k/Lib/test/test_ssl.py Fri Dec 14 23:08:56 2007 @@ -13,6 +13,7 @@ import urllib, urlparse import shutil import traceback +import asyncore from BaseHTTPServer import HTTPServer from SimpleHTTPServer import SimpleHTTPRequestHandler @@ -79,27 +80,6 @@ class NetworkedTests(unittest.TestCase): - def testFetchServerCert(self): - - pem = ssl.get_server_certificate(("svn.python.org", 443)) - if not pem: - raise test_support.TestFailed("No server certificate on svn.python.org:443!") - - try: - pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE) - except ssl.SSLError as x: - #should fail - if test_support.verbose: - sys.stdout.write("%s\n" % x) - else: - raise test_support.TestFailed("Got server certificate %s for svn.python.org!" % pem) - - pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT) - if not pem: - raise test_support.TestFailed("No server certificate on svn.python.org:443!") - if test_support.verbose: - sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem) - def testConnect(self): s = ssl.wrap_socket(socket.socket(socket.AF_INET), @@ -155,6 +135,29 @@ if test_support.verbose: sys.stdout.write("\nNeeded %d calls to do_handshake() to establish session.\n" % count) + def testFetchServerCert(self): + + pem = ssl.get_server_certificate(("svn.python.org", 443)) + if not pem: + raise test_support.TestFailed("No server certificate on svn.python.org:443!") + + return + + try: + pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=CERTFILE) + except ssl.SSLError as x: + #should fail + if test_support.verbose: + sys.stdout.write("%s\n" % x) + else: + raise test_support.TestFailed("Got server certificate %s for svn.python.org!" % pem) + + pem = ssl.get_server_certificate(("svn.python.org", 443), ca_certs=SVN_PYTHON_ORG_ROOT_CERT) + if not pem: + raise test_support.TestFailed("No server certificate on svn.python.org:443!") + if test_support.verbose: + sys.stdout.write("\nVerified certificate for svn.python.org:443 is\n%s\n" % pem) + try: import threading @@ -333,7 +336,9 @@ def stop (self): self.active = False - class AsyncoreHTTPSServer(threading.Thread): + class OurHTTPSServer(threading.Thread): + + # This one's based on HTTPServer, which is based on SocketServer class HTTPSServer(HTTPServer): @@ -463,6 +468,92 @@ self.server.server_close() + class AsyncoreEchoServer(threading.Thread): + + # this one's based on asyncore.dispatcher + + class EchoServer (asyncore.dispatcher): + + class ConnectionHandler (asyncore.dispatcher_with_send): + + def __init__(self, conn, certfile): + self.socket = ssl.wrap_socket(conn, server_side=True, + certfile=certfile, + do_handshake_on_connect=False) + asyncore.dispatcher_with_send.__init__(self, self.socket) + # now we have to do the handshake + # we'll just do it the easy way, and block the connection + # till it's finished. If we were doing it right, we'd + # do this in multiple calls to handle_read... + self.do_handshake(block=True) + + def readable(self): + if isinstance(self.socket, ssl.SSLSocket): + while self.socket.pending() > 0: + self.handle_read_event() + return True + + def handle_read(self): + data = self.recv(1024) + if test_support.verbose: + sys.stdout.write(" server: read %s from client\n" % repr(data)) + if not data: + self.close() + else: + self.send(str(data, 'ASCII', 'strict').lower().encode('ASCII', 'strict')) + + def handle_close(self): + if test_support.verbose: + sys.stdout.write(" server: closed connection %s\n" % self.socket) + + def handle_error(self): + raise + + def __init__(self, port, certfile): + self.port = port + self.certfile = certfile + asyncore.dispatcher.__init__(self) + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + self.bind(('', port)) + self.listen(5) + + def handle_accept(self): + sock_obj, addr = self.accept() + if test_support.verbose: + sys.stdout.write(" server: new connection from %s:%s\n" %addr) + self.ConnectionHandler(sock_obj, self.certfile) + + def handle_error(self): + raise + + def __init__(self, port, certfile): + self.flag = None + self.active = False + self.server = self.EchoServer(port, certfile) + threading.Thread.__init__(self) + self.setDaemon(True) + + def __str__(self): + return "<%s %s>" % (self.__class__.__name__, self.server) + + def start (self, flag=None): + self.flag = flag + threading.Thread.start(self) + + def run (self): + self.active = True + if self.flag: + self.flag.set() + while self.active: + try: + asyncore.loop(1) + except: + pass + + def stop (self): + self.active = False + self.server.close() + def badCertTest (certfile): server = ThreadedEchoServer(TESTPORT, CERTFILE, certreqs=ssl.CERT_REQUIRED, @@ -509,6 +600,7 @@ client_protocol = protocol try: s = ssl.wrap_socket(socket.socket(), + server_side=False, certfile=client_certfile, ca_certs=cacertsfile, cert_reqs=certreqs, @@ -811,11 +903,9 @@ server.stop() server.join() - class AsyncoreTests(unittest.TestCase): + def testSocketServer(self): - def testAsyncore(self): - - server = AsyncoreHTTPSServer(TESTPORT, CERTFILE) + server = OurHTTPSServer(TESTPORT, CERTFILE) flag = threading.Event() server.start(flag) # wait for it to start @@ -853,6 +943,47 @@ server.stop() server.join() + def testAsyncoreServer(self): + + if test_support.verbose: + sys.stdout.write("\n") + + indata="FOO\n" + server = AsyncoreEchoServer(TESTPORT, CERTFILE) + flag = threading.Event() + server.start(flag) + # wait for it to start + flag.wait() + # try to connect + try: + s = ssl.wrap_socket(socket.socket()) + s.connect(('127.0.0.1', TESTPORT)) + except ssl.SSLError as x: + raise test_support.TestFailed("Unexpected SSL error: " + str(x)) + except Exception as x: + raise test_support.TestFailed("Unexpected exception: " + str(x)) + else: + if test_support.verbose: + sys.stdout.write( + " client: sending %s...\n" % (repr(indata))) + s.sendall(indata.encode('ASCII', 'strict')) + outdata = s.recv() + if test_support.verbose: + sys.stdout.write(" client: read %s\n" % repr(outdata)) + outdata = str(outdata, 'ASCII', 'strict') + if outdata != indata.lower(): + raise test_support.TestFailed( + "bad data <<%s>> (%d) received; expected <<%s>> (%d)\n" + % (repr(outdata[:min(len(outdata),20)]), len(outdata), + repr(indata[:min(len(indata),20)].lower()), len(indata))) + s.write("over\n".encode("ASCII", "strict")) + if test_support.verbose: + sys.stdout.write(" client: closing connection.\n") + s.close() + finally: + server.stop() + server.join() + def findtestsocket(start, end): def testbind(i): @@ -900,7 +1031,6 @@ thread_info = test_support.threading_setup() if thread_info and test_support.is_resource_enabled('network'): tests.append(ThreadedTests) - tests.append(AsyncoreTests) test_support.run_unittest(*tests) Modified: python/branches/py3k/Modules/_ssl.c ============================================================================== --- python/branches/py3k/Modules/_ssl.c (original) +++ python/branches/py3k/Modules/_ssl.c Fri Dec 14 23:08:56 2007 @@ -46,6 +46,7 @@ PY_SSL_ERROR_WANT_CONNECT, /* start of non ssl.h errorcodes */ PY_SSL_ERROR_EOF, /* special case of SSL_ERROR_SYSCALL */ + PY_SSL_ERROR_NO_SOCKET, /* socket has been GC'd */ PY_SSL_ERROR_INVALID_ERROR_CODE }; @@ -111,7 +112,7 @@ typedef struct { PyObject_HEAD - PySocketSockObject *Socket; /* Socket on which we're layered */ + PyObject *Socket; /* weakref to socket on which we're layered */ SSL_CTX* ctx; SSL* ssl; X509* peer_cert; @@ -188,13 +189,15 @@ { unsigned long e = ERR_get_error(); if (e == 0) { - if (ret == 0 || !obj->Socket) { + PySocketSockObject *s + = (PySocketSockObject *) PyWeakref_GetObject(obj->Socket); + if (ret == 0 || (((PyObject *)s) == Py_None)) { p = PY_SSL_ERROR_EOF; errstr = "EOF occurred in violation of protocol"; } else if (ret == -1) { /* underlying BIO reported an I/O error */ - return obj->Socket->errorhandler(); + return s->errorhandler(); } else { /* possible? */ p = PY_SSL_ERROR_SYSCALL; errstr = "Some I/O error occurred"; @@ -383,8 +386,7 @@ SSL_set_accept_state(self->ssl); PySSL_END_ALLOW_THREADS - self->Socket = Sock; - Py_INCREF(self->Socket); + self->Socket = PyWeakref_NewRef((PyObject *) Sock, Py_None); return self; fail: if (errstr) @@ -442,6 +444,14 @@ /* XXX If SSL_do_handshake() returns 0, it's also a failure. */ sockstate = 0; do { + PySocketSockObject *sock + = (PySocketSockObject *) PyWeakref_GetObject(self->Socket); + if (((PyObject*)sock) == Py_None) { + _setSSLError("Underlying socket connection gone", + PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__); + return NULL; + } + PySSL_BEGIN_ALLOW_THREADS ret = SSL_do_handshake(self->ssl); err = SSL_get_error(self->ssl, ret); @@ -450,9 +460,9 @@ return NULL; } if (err == SSL_ERROR_WANT_READ) { - sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); + sockstate = check_socket_and_wait_for_timeout(sock, 0); } else if (err == SSL_ERROR_WANT_WRITE) { - sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); + sockstate = check_socket_and_wait_for_timeout(sock, 1); } else { sockstate = SOCKET_OPERATION_OK; } @@ -1140,16 +1150,24 @@ int sockstate; int err; int nonblocking; + PySocketSockObject *sock + = (PySocketSockObject *) PyWeakref_GetObject(self->Socket); + + if (((PyObject*)sock) == Py_None) { + _setSSLError("Underlying socket connection gone", + PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__); + return NULL; + } if (!PyArg_ParseTuple(args, "y#:write", &data, &count)) return NULL; /* just in case the blocking state of the socket has been changed */ - nonblocking = (self->Socket->sock_timeout >= 0.0); + nonblocking = (sock->sock_timeout >= 0.0); BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking); BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking); - sockstate = check_socket_and_wait_for_timeout(self->Socket, 1); + sockstate = check_socket_and_wait_for_timeout(sock, 1); if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The write operation timed out"); @@ -1174,10 +1192,10 @@ } if (err == SSL_ERROR_WANT_READ) { sockstate = - check_socket_and_wait_for_timeout(self->Socket, 0); + check_socket_and_wait_for_timeout(sock, 0); } else if (err == SSL_ERROR_WANT_WRITE) { sockstate = - check_socket_and_wait_for_timeout(self->Socket, 1); + check_socket_and_wait_for_timeout(sock, 1); } else { sockstate = SOCKET_OPERATION_OK; } @@ -1233,10 +1251,17 @@ int sockstate; int err; int nonblocking; + PySocketSockObject *sock + = (PySocketSockObject *) PyWeakref_GetObject(self->Socket); + + if (((PyObject*)sock) == Py_None) { + _setSSLError("Underlying socket connection gone", + PY_SSL_ERROR_NO_SOCKET, __FILE__, __LINE__); + return NULL; + } if (!PyArg_ParseTuple(args, "|Oi:read", &buf, &count)) return NULL; - if ((buf == NULL) || (buf == Py_None)) { if (!(buf = PyBytes_FromStringAndSize((char *) 0, len))) return NULL; @@ -1254,7 +1279,7 @@ } /* just in case the blocking state of the socket has been changed */ - nonblocking = (self->Socket->sock_timeout >= 0.0); + nonblocking = (sock->sock_timeout >= 0.0); BIO_set_nbio(SSL_get_rbio(self->ssl), nonblocking); BIO_set_nbio(SSL_get_wbio(self->ssl), nonblocking); @@ -1264,7 +1289,7 @@ PySSL_END_ALLOW_THREADS if (!count) { - sockstate = check_socket_and_wait_for_timeout(self->Socket, 0); + sockstate = check_socket_and_wait_for_timeout(sock, 0); if (sockstate == SOCKET_HAS_TIMED_OUT) { PyErr_SetString(PySSLErrorObject, "The read operation timed out"); @@ -1299,10 +1324,10 @@ } if (err == SSL_ERROR_WANT_READ) { sockstate = - check_socket_and_wait_for_timeout(self->Socket, 0); + check_socket_and_wait_for_timeout(sock, 0); } else if (err == SSL_ERROR_WANT_WRITE) { sockstate = - check_socket_and_wait_for_timeout(self->Socket, 1); + check_socket_and_wait_for_timeout(sock, 1); } else if ((err == SSL_ERROR_ZERO_RETURN) && (SSL_get_shutdown(self->ssl) == SSL_RECEIVED_SHUTDOWN)) From python-3000-checkins at python.org Sat Dec 15 02:27:16 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 15 Dec 2007 02:27:16 +0100 (CET) Subject: [Python-3000-checkins] r59517 - in python/branches/py3k: Doc/ACKS.txt Doc/howto/functional.rst Doc/library/collections.rst Doc/tutorial/datastructures.rst Doc/whatsnew/2.6.rst Lib/collections.py Lib/distutils/sysconfig.py Lib/distutils/tests/test_sysconfig.py Lib/test/test_collections.py Lib/test/test_property.py Modules/_ctypes/libffi/src/x86/ffi.c Modules/_ssl.c Modules/bsddb.h Modules/cjkcodecs/_codecs_iso2022.c Objects/descrobject.c Python/ceval.c Message-ID: <20071215012716.51EDF1E4009@bag.python.org> Author: christian.heimes Date: Sat Dec 15 02:27:15 2007 New Revision: 59517 Added: python/branches/py3k/Lib/test/test_property.py (contents, props changed) Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/ACKS.txt python/branches/py3k/Doc/howto/functional.rst python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/tutorial/datastructures.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/distutils/sysconfig.py python/branches/py3k/Lib/distutils/tests/test_sysconfig.py python/branches/py3k/Lib/test/test_collections.py python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi.c python/branches/py3k/Modules/_ssl.c python/branches/py3k/Modules/bsddb.h python/branches/py3k/Modules/cjkcodecs/_codecs_iso2022.c python/branches/py3k/Objects/descrobject.c python/branches/py3k/Python/ceval.c Log: Merged revisions 59488-59511 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line Silence a warning about an unsed variable in debug builds ........ r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines Fixed bug #1620: New @spam.getter property syntax modifies the property in place. I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property(). ........ r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line Cleaner method naming convention ........ r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments. ........ r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line Fixed warning in ssl module ........ r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line Add line spacing for readability ........ r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines Update method names for named tuples. ........ r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines Add a section about nested listcomps to the tutorial. Thanks to Ian Bruntlett and Robert Lehmann. ........ r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line Faster and simpler _replace() method ........ r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line Add usage note ........ r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line Remove warning about URL ........ r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line Bump the version number, and make a few small edits ........ r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines Fixed bug #1628 The detection now works on Unix with Makefile, Makefile with VPATH and on Windows. ........ Modified: python/branches/py3k/Doc/ACKS.txt ============================================================================== --- python/branches/py3k/Doc/ACKS.txt (original) +++ python/branches/py3k/Doc/ACKS.txt Sat Dec 15 02:27:15 2007 @@ -28,6 +28,7 @@ * Aaron Brancotti * Georg Brandl * Keith Briggs + * Ian Bruntlett * Lee Busby * Lorenzo M. Catucci * Carl Cerecke Modified: python/branches/py3k/Doc/howto/functional.rst ============================================================================== --- python/branches/py3k/Doc/howto/functional.rst (original) +++ python/branches/py3k/Doc/howto/functional.rst Sat Dec 15 02:27:15 2007 @@ -3,12 +3,10 @@ ******************************** :Author: \A. M. Kuchling -:Release: 0.30 +:Release: 0.31 (This is a first draft. Please send comments/error reports/suggestions to -amk at amk.ca. This URL is probably not going to be the final location of the -document, so be careful about linking to it -- you may want to add a -disclaimer.) +amk at amk.ca.) In this document, we'll take a tour of Python's features suitable for implementing programs in a functional style. After an introduction to the @@ -49,17 +47,19 @@ functional languages include the ML family (Standard ML, OCaml, and other variants) and Haskell. -The designers of some computer languages have chosen one approach to programming -that's emphasized. This often makes it difficult to write programs that use a -different approach. Other languages are multi-paradigm languages that support -several different approaches. Lisp, C++, and Python are multi-paradigm; you can -write programs or libraries that are largely procedural, object-oriented, or -functional in all of these languages. In a large program, different sections -might be written using different approaches; the GUI might be object-oriented -while the processing logic is procedural or functional, for example. +The designers of some computer languages choose to emphasize one +particular approach to programming. This often makes it difficult to +write programs that use a different approach. Other languages are +multi-paradigm languages that support several different approaches. +Lisp, C++, and Python are multi-paradigm; you can write programs or +libraries that are largely procedural, object-oriented, or functional +in all of these languages. In a large program, different sections +might be written using different approaches; the GUI might be +object-oriented while the processing logic is procedural or +functional, for example. In a functional program, input flows through a set of functions. Each function -operates on its input and produces some output. Functional style frowns upon +operates on its input and produces some output. Functional style discourages functions with side effects that modify internal state or make other changes that aren't visible in the function's return value. Functions that have no side effects at all are called **purely functional**. Avoiding side effects means @@ -616,7 +616,7 @@ Let's look in more detail at built-in functions often used with iterators. -Two Python's built-in functions, :func:`map` and :func:`filter`, are somewhat +Two of Python's built-in functions, :func:`map` and :func:`filter`, are somewhat obsolete; they duplicate the features of list comprehensions but return actual lists instead of iterators. @@ -842,8 +842,8 @@ 4) Convert the lambda to a def statement, using that name. 5) Remove the comment. -I really like these rules, but you're free to disagree that this lambda-free -style is better. +I really like these rules, but you're free to disagree +about whether this lambda-free style is better. The itertools module Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Sat Dec 15 02:27:15 2007 @@ -403,8 +403,8 @@ can be specified as a list of strings (such as ['x', 'y']). Any valid Python identifier may be used for a fieldname except for names - starting and ending with double underscores. Valid identifiers consist of - letters, digits, and underscores but do not start with a digit and cannot be + starting with an underscore. Valid identifiers consist of letters, digits, + and underscores but do not start with a digit or underscore and cannot be a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, *print*, or *raise*. @@ -418,18 +418,25 @@ >>> Point = namedtuple('Point', 'x y', verbose=True) class Point(tuple): 'Point(x, y)' + __slots__ = () - __fields__ = ('x', 'y') + + _fields = ('x', 'y') + def __new__(cls, x, y): return tuple.__new__(cls, (x, y)) + def __repr__(self): return 'Point(x=%r, y=%r)' % self - def __asdict__(self): - 'Return a new dict mapping field names to their values' + + def _asdict(self): + 'Return a new dict which maps field names to their values' return dict(zip(('x', 'y'), self)) - def __replace__(self, **kwds): + + def _replace(self, **kwds): 'Return a new Point object replacing specified fields with new values' - return Point(**dict(zip(('x', 'y'), self), **kwds)) + return Point(*map(kwds.get, ('x', 'y'), self)) + x = property(itemgetter(0)) y = property(itemgetter(1)) @@ -477,43 +484,51 @@ In addition to the methods inherited from tuples, named tuples support two additonal methods and a read-only attribute. -.. method:: somenamedtuple.__asdict__() +.. method:: somenamedtuple._asdict() Return a new dict which maps field names to their corresponding values: :: - >>> p.__asdict__() + >>> p._asdict() {'x': 11, 'y': 22} -.. method:: somenamedtuple.__replace__(kwargs) +.. method:: somenamedtuple._replace(kwargs) Return a new instance of the named tuple replacing specified fields with new values: :: >>> p = Point(x=11, y=22) - >>> p.__replace__(x=33) + >>> p._replace(x=33) Point(x=33, y=22) >>> for partnum, record in inventory.items(): - ... inventory[partnum] = record.__replace__(price=newprices[partnum], updated=time.now()) + ... inventory[partnum] = record._replace(price=newprices[partnum], updated=time.now()) -.. attribute:: somenamedtuple.__fields__ +.. attribute:: somenamedtuple._fields Return a tuple of strings listing the field names. This is useful for introspection and for creating new named tuple types from existing named tuples. :: - >>> p.__fields__ # view the field names + >>> p._fields # view the field names ('x', 'y') >>> Color = namedtuple('Color', 'red green blue') - >>> Pixel = namedtuple('Pixel', Point.__fields__ + Color.__fields__) + >>> Pixel = namedtuple('Pixel', Point._fields + Color._fields) >>> Pixel(11, 22, 128, 255, 0) Pixel(x=11, y=22, red=128, green=255, blue=0)' +To retrieve a field whose name is stored in a string, use the :func:`getattr` +function: + +:: + + >>> getattr(p, 'x') + 11 + Since a named tuple is a regular Python class, it is easy to add or change functionality. For example, the display format can be changed by overriding the :meth:`__repr__` method: @@ -522,17 +537,17 @@ >>> Point = namedtuple('Point', 'x y') >>> Point.__repr__ = lambda self: 'Point(%.3f, %.3f)' % self - >>> Point(x=10, y=20) - Point(10.000, 20.000) + >>> Point(x=11, y=22) + Point(11.000, 22.000) Default values can be implemented by starting with a prototype instance -and customizing it with :meth:`__replace__`: +and customizing it with :meth:`_replace`: :: >>> Account = namedtuple('Account', 'owner balance transaction_count') >>> model_account = Account('', 0.0, 0) - >>> johns_account = model_account.__replace__(owner='John') + >>> johns_account = model_account._replace(owner='John') .. rubric:: Footnotes Modified: python/branches/py3k/Doc/tutorial/datastructures.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/datastructures.rst (original) +++ python/branches/py3k/Doc/tutorial/datastructures.rst Sat Dec 15 02:27:15 2007 @@ -277,6 +277,48 @@ ['3.1', '3.14', '3.142', '3.1416', '3.14159'] +Nested List Comprehensions +-------------------------- + +If you've got the stomach for it, list comprehensions can be nested. They are a +powerful tool but -- like all powerful tools -- they need to be used carefully, +if at all. + +Consider the following example of a 3x3 matrix held as a list containing three +lists, one list per row:: + + >>> mat = [ + ... [1, 2, 3], + ... [4, 5, 6], + ... [7, 8, 9], + ... ] + +Now, if you wanted to swap rows and columns, you could use a list +comprehension:: + + >>> print [[row[i] for row in mat] for i in [0, 1, 2]] + [[1, 4, 7], [2, 5, 8], [3, 6, 9]] + +Special care has to be taken for the *nested* list comprehension: + + To avoid apprehension when nesting list comprehensions, read from right to + left. + +A more verbose version of this snippet shows the flow explicitly:: + + for i in [0, 1, 2]: + for row in mat: + print row[i], + print + +In real world, you should prefer builtin functions to complex flow statements. +The :func:`zip` function would do a great job for this use case:: + + >>> zip(*mat) + [(1, 4, 7), (2, 5, 8), (3, 6, 9)] + +See :ref:`tut-unpacking-arguments` for details on the asterisk in this line. + .. _tut-del: The :keyword:`del` statement Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Sat Dec 15 02:27:15 2007 @@ -528,7 +528,7 @@ ... 'id name type size') # Names are separated by spaces or commas. # 'id, name, type, size' would also work. - >>> var_type.__fields__ + >>> var_type._fields ('id', 'name', 'type', 'size') >>> var = var_type(1, 'frequency', 'int', 4) @@ -536,9 +536,9 @@ 1 1 >>> print var[2], var.type # Equivalent int int - >>> var.__asdict__() + >>> var._asdict() {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'} - >>> v2 = var.__replace__('name', 'amplitude') + >>> v2 = var._replace('name', 'amplitude') >>> v2 variable(id=1, name='amplitude', type='int', size=4) Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Sat Dec 15 02:27:15 2007 @@ -26,12 +26,12 @@ (11, 22) >>> p.x + p.y # fields also accessable by name 33 - >>> d = p.__asdict__() # convert to a dictionary + >>> d = p._asdict() # convert to a dictionary >>> d['x'] 11 >>> Point(**d) # convert from a dictionary Point(x=11, y=22) - >>> p.__replace__(x=100) # __replace__() is like str.replace() but targets named fields + >>> p._replace(x=100) # _replace() is like str.replace() but targets named fields Point(x=100, y=22) """ @@ -49,8 +49,8 @@ raise ValueError('Type names and field names cannot start with a number: %r' % name) seen_names = set() for name in field_names: - if name.startswith('__') and name.endswith('__') and len(name) > 3: - raise ValueError('Field names cannot start and end with double underscores: %r' % name) + if name.startswith('_'): + raise ValueError('Field names cannot start with an underscore: %r' % name) if name in seen_names: raise ValueError('Encountered duplicate field name: %r' % name) seen_names.add(name) @@ -59,19 +59,19 @@ argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes reprtxt = ', '.join('%s=%%r' % name for name in field_names) template = '''class %(typename)s(tuple): - '%(typename)s(%(argtxt)s)' - __slots__ = () - __fields__ = property(lambda self: %(field_names)r) + '%(typename)s(%(argtxt)s)' \n + __slots__ = () \n + _fields = property(lambda self: %(field_names)r) \n def __new__(cls, %(argtxt)s): - return tuple.__new__(cls, (%(argtxt)s)) + return tuple.__new__(cls, (%(argtxt)s)) \n def __repr__(self): - return '%(typename)s(%(reprtxt)s)' %% self - def __asdict__(self, dict=dict, zip=zip): - 'Return a new dict mapping field names to their values' - return dict(zip(%(field_names)r, self)) - def __replace__(self, **kwds): + return '%(typename)s(%(reprtxt)s)' %% self \n + def _asdict(self, dict=dict, zip=zip): + 'Return a new dict which maps field names to their values' + return dict(zip(%(field_names)r, self)) \n + def _replace(self, **kwds): 'Return a new %(typename)s object replacing specified fields with new values' - return %(typename)s(**dict(zip(%(field_names)r, self), **kwds)) \n''' % locals() + return %(typename)s(*map(kwds.get, %(field_names)r, self)) \n\n''' % locals() for i, name in enumerate(field_names): template += ' %s = property(itemgetter(%d))\n' % (name, i) if verbose: Modified: python/branches/py3k/Lib/distutils/sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/sysconfig.py Sat Dec 15 02:27:15 2007 @@ -31,8 +31,10 @@ # python_build: (Boolean) if true, we're either building Python or # building an extension with an un-installed Python, so we use # different (hard-wired) directories. -python_build = os.path.isfile(os.path.join(project_base, "Modules", - "Setup.local")) +# Setup.local is available for Makefile builds including VPATH builds, +# Setup.dist is available on Windows +python_build = any(os.path.isfile(os.path.join(project_base, "Modules", fn)) + for fn in ("Setup.dist", "Setup.local")) def get_python_version(): """Return a string containing the major and minor Python version, Modified: python/branches/py3k/Lib/distutils/tests/test_sysconfig.py ============================================================================== --- python/branches/py3k/Lib/distutils/tests/test_sysconfig.py (original) +++ python/branches/py3k/Lib/distutils/tests/test_sysconfig.py Sat Dec 15 02:27:15 2007 @@ -15,7 +15,7 @@ def test_get_python_lib(self): lib_dir = sysconfig.get_python_lib() - # XXX doesn't work on Inux when Python was never installed before + # XXX doesn't work on Linux when Python was never installed before #self.assert_(os.path.isdir(lib_dir), lib_dir) # test for pythonxx.lib? Modified: python/branches/py3k/Lib/test/test_collections.py ============================================================================== --- python/branches/py3k/Lib/test/test_collections.py (original) +++ python/branches/py3k/Lib/test/test_collections.py Sat Dec 15 02:27:15 2007 @@ -28,11 +28,11 @@ self.assertRaises(ValueError, namedtuple, 'abc', 'efg g%hi') # field with non-alpha char self.assertRaises(ValueError, namedtuple, 'abc', 'abc class') # field has keyword self.assertRaises(ValueError, namedtuple, 'abc', '8efg 9ghi') # field starts with digit - self.assertRaises(ValueError, namedtuple, 'abc', '__efg__ ghi') # field with double underscores + self.assertRaises(ValueError, namedtuple, 'abc', '_efg ghi') # field with leading underscore self.assertRaises(ValueError, namedtuple, 'abc', 'efg efg ghi') # duplicate field namedtuple('Point0', 'x1 y2') # Verify that numbers are allowed in names - namedtuple('_', '_ __ ___') # Verify that underscores are allowed + namedtuple('_', 'a b c') # Test leading underscores in a typename def test_instance(self): Point = namedtuple('Point', 'x y') @@ -49,17 +49,17 @@ self.assertEqual(repr(p), 'Point(x=11, y=22)') self.assert_('__dict__' not in dir(p)) # verify instance has no dict self.assert_('__weakref__' not in dir(p)) - self.assertEqual(p.__fields__, ('x', 'y')) # test __fields__ attribute - self.assertEqual(p.__replace__(x=1), (1, 22)) # test __replace__ method - self.assertEqual(p.__asdict__(), dict(x=11, y=22)) # test __dict__ method + self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute + self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method + self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method - # Verify that __fields__ is read-only + # Verify that _fields is read-only try: - p.__fields__ = ('F1' ,'F2') + p._fields = ('F1' ,'F2') except AttributeError: pass else: - self.fail('The __fields__ attribute needs to be read-only') + self.fail('The _fields attribute needs to be read-only') # verify that field string can have commas Point = namedtuple('Point', 'x, y') Added: python/branches/py3k/Lib/test/test_property.py ============================================================================== --- (empty file) +++ python/branches/py3k/Lib/test/test_property.py Sat Dec 15 02:27:15 2007 @@ -0,0 +1,98 @@ +# Test case for property +# more tests are in test_descr + +import unittest +from test.test_support import run_unittest + +class PropertyBase(Exception): + pass + +class PropertyGet(PropertyBase): + pass + +class PropertySet(PropertyBase): + pass + +class PropertyDel(PropertyBase): + pass + +class BaseClass(object): + def __init__(self): + self._spam = 5 + + @property + def spam(self): + """BaseClass.getter""" + return self._spam + + @spam.setter + def spam(self, value): + self._spam = value + + @spam.deleter + def spam(self): + del self._spam + +class SubClass(BaseClass): + + @BaseClass.spam.getter + def spam(self): + """SubClass.getter""" + raise PropertyGet(self._spam) + + @spam.setter + def spam(self, value): + raise PropertySet(self._spam) + + @spam.deleter + def spam(self): + raise PropertyDel(self._spam) + +class PropertyDocBase(object): + _spam = 1 + def _get_spam(self): + return self._spam + spam = property(_get_spam, doc="spam spam spam") + +class PropertyDocSub(PropertyDocBase): + @PropertyDocBase.spam.getter + def spam(self): + """The decorator does not use this doc string""" + return self._spam + +class PropertyTests(unittest.TestCase): + def test_property_decorator_baseclass(self): + # see #1620 + base = BaseClass() + self.assertEqual(base.spam, 5) + self.assertEqual(base._spam, 5) + base.spam = 10 + self.assertEqual(base.spam, 10) + self.assertEqual(base._spam, 10) + delattr(base, "spam") + self.assert_(not hasattr(base, "spam")) + self.assert_(not hasattr(base, "_spam")) + base.spam = 20 + self.assertEqual(base.spam, 20) + self.assertEqual(base._spam, 20) + self.assertEqual(base.__class__.spam.__doc__, "BaseClass.getter") + + def test_property_decorator_subclass(self): + # see #1620 + sub = SubClass() + self.assertRaises(PropertyGet, getattr, sub, "spam") + self.assertRaises(PropertySet, setattr, sub, "spam", None) + self.assertRaises(PropertyDel, delattr, sub, "spam") + self.assertEqual(sub.__class__.spam.__doc__, "SubClass.getter") + + def test_property_decorator_doc(self): + base = PropertyDocBase() + sub = PropertyDocSub() + self.assertEqual(base.__class__.spam.__doc__, "spam spam spam") + self.assertEqual(sub.__class__.spam.__doc__, "spam spam spam") + +def test_main(): + run_unittest(PropertyTests) + +if __name__ == '__main__': + test_main() Modified: python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi.c (original) +++ python/branches/py3k/Modules/_ctypes/libffi/src/x86/ffi.c Sat Dec 15 02:27:15 2007 @@ -256,7 +256,7 @@ void **respp; void *args; { - // our various things... + /* our various things... */ ffi_cif *cif; void **arg_area; Modified: python/branches/py3k/Modules/_ssl.c ============================================================================== --- python/branches/py3k/Modules/_ssl.c (original) +++ python/branches/py3k/Modules/_ssl.c Sat Dec 15 02:27:15 2007 @@ -656,7 +656,7 @@ char buf[2048]; char *vptr; int len; - unsigned char *p; + const unsigned char *p; if (certificate == NULL) return peer_alt_names; Modified: python/branches/py3k/Modules/bsddb.h ============================================================================== --- python/branches/py3k/Modules/bsddb.h (original) +++ python/branches/py3k/Modules/bsddb.h Sat Dec 15 02:27:15 2007 @@ -232,7 +232,7 @@ #define DBSequenceObject_Check(v) ((v)->ob_type == bsddb_api->dbsequence_type) #endif -#endif // COMPILING_BSDDB_C +#endif /* COMPILING_BSDDB_C */ -#endif // _BSDDB_H_ +#endif /* _BSDDB_H_ */ Modified: python/branches/py3k/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/branches/py3k/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/branches/py3k/Modules/cjkcodecs/_codecs_iso2022.c Sat Dec 15 02:27:15 2007 @@ -203,7 +203,7 @@ } else encoded = dsg->encoder(&c, &length); #else - encoded = dsg->encoder(*inbuf, &length); + encoded = dsg->encoder(&c, &length); #endif if (encoded != MAP_UNMAPPABLE) { insize = length; Modified: python/branches/py3k/Objects/descrobject.c ============================================================================== --- python/branches/py3k/Objects/descrobject.c (original) +++ python/branches/py3k/Objects/descrobject.c Sat Dec 15 02:27:15 2007 @@ -1065,8 +1065,12 @@ PyObject *prop_set; PyObject *prop_del; PyObject *prop_doc; + int getter_doc; } propertyobject; +static PyObject * property_copy(PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *); + static PyMemberDef property_members[] = { {"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY}, {"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY}, @@ -1075,53 +1079,37 @@ {0} }; + PyDoc_STRVAR(getter_doc, "Descriptor to change the getter on a property."); PyObject * property_getter(PyObject *self, PyObject *getter) { - Py_XDECREF(((propertyobject *)self)->prop_get); - if (getter == Py_None) - getter = NULL; - Py_XINCREF(getter); - ((propertyobject *)self)->prop_get = getter; - Py_INCREF(self); - return self; + return property_copy(self, getter, NULL, NULL, NULL); } + PyDoc_STRVAR(setter_doc, - "Descriptor to change the setter on a property.\n"); + "Descriptor to change the setter on a property."); PyObject * property_setter(PyObject *self, PyObject *setter) { - Py_XDECREF(((propertyobject *)self)->prop_set); - if (setter == Py_None) - setter = NULL; - Py_XINCREF(setter); - ((propertyobject *)self)->prop_set = setter; - Py_INCREF(self); - return self; + return property_copy(self, NULL, setter, NULL, NULL); } + PyDoc_STRVAR(deleter_doc, "Descriptor to change the deleter on a property."); PyObject * property_deleter(PyObject *self, PyObject *deleter) { - Py_XDECREF(((propertyobject *)self)->prop_del); - if (deleter == Py_None) - deleter = NULL; - Py_XINCREF(deleter); - ((propertyobject *)self)->prop_del = deleter; - Py_INCREF(self); - return self; + return property_copy(self, NULL, NULL, deleter, NULL); } - static PyMethodDef property_methods[] = { {"getter", property_getter, METH_O, getter_doc}, {"setter", property_setter, METH_O, setter_doc}, @@ -1186,15 +1174,62 @@ return 0; } +static PyObject * +property_copy(PyObject *old, PyObject *get, PyObject *set, PyObject *del, + PyObject *doc) +{ + propertyobject *pold = (propertyobject *)old; + propertyobject *pnew = NULL; + PyObject *new, *type; + + type = PyObject_Type(old); + if (type == NULL) + return NULL; + + if (get == NULL || get == Py_None) { + Py_XDECREF(get); + get = pold->prop_get ? pold->prop_get : Py_None; + } + if (set == NULL || set == Py_None) { + Py_XDECREF(set); + set = pold->prop_set ? pold->prop_set : Py_None; + } + if (del == NULL || del == Py_None) { + Py_XDECREF(del); + del = pold->prop_del ? pold->prop_del : Py_None; + } + if (doc == NULL || doc == Py_None) { + Py_XDECREF(doc); + doc = pold->prop_doc ? pold->prop_doc : Py_None; + } + + new = PyObject_CallFunction(type, "OOOO", get, set, del, doc); + if (new == NULL) + return NULL; + pnew = (propertyobject *)new; + + if (pold->getter_doc && get != Py_None) { + PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); + if (get_doc != NULL) { + Py_XDECREF(pnew->prop_doc); + pnew->prop_doc = get_doc; /* get_doc already INCREF'd by GetAttr */ + pnew->getter_doc = 1; + } else { + PyErr_Clear(); + } + } + return new; +} + static int property_init(PyObject *self, PyObject *args, PyObject *kwds) { PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL; static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0}; - propertyobject *gs = (propertyobject *)self; - + propertyobject *prop = (propertyobject *)self; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property", - kwlist, &get, &set, &del, &doc)) + kwlist, &get, &set, &del, &doc)) return -1; if (get == Py_None) @@ -1209,22 +1244,24 @@ Py_XINCREF(del); Py_XINCREF(doc); + prop->prop_get = get; + prop->prop_set = set; + prop->prop_del = del; + prop->prop_doc = doc; + prop->getter_doc = 0; + /* if no docstring given and the getter has one, use that one */ if ((doc == NULL || doc == Py_None) && get != NULL) { PyObject *get_doc = PyObject_GetAttrString(get, "__doc__"); if (get_doc != NULL) { - Py_XDECREF(doc); - doc = get_doc; /* get_doc already INCREF'd by GetAttr */ + Py_XDECREF(prop->prop_doc); + prop->prop_doc = get_doc; /* get_doc already INCREF'd by GetAttr */ + prop->getter_doc = 1; } else { PyErr_Clear(); } } - gs->prop_get = get; - gs->prop_set = set; - gs->prop_del = del; - gs->prop_doc = doc; - return 0; } Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Sat Dec 15 02:27:15 2007 @@ -668,8 +668,9 @@ #define STACKADJ(n) { (void)(BASIC_STACKADJ(n), \ lltrace && prtrace(TOP(), "stackadj")); \ assert(STACK_LEVEL() <= co->co_stacksize); } -#define EXT_POP(STACK_POINTER) (lltrace && prtrace((STACK_POINTER)[-1], \ - "ext_pop"), *--(STACK_POINTER)) +#define EXT_POP(STACK_POINTER) ((void)(lltrace && \ + prtrace((STACK_POINTER)[-1], "ext_pop")), \ + *--(STACK_POINTER)) #else #define PUSH(v) BASIC_PUSH(v) #define POP() BASIC_POP() From python-3000-checkins at python.org Sat Dec 15 02:28:04 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Sat, 15 Dec 2007 02:28:04 +0100 (CET) Subject: [Python-3000-checkins] r59518 - python/branches/py3k/Python/sysmodule.c Message-ID: <20071215012804.666121E4009@bag.python.org> Author: christian.heimes Date: Sat Dec 15 02:28:04 2007 New Revision: 59518 Modified: python/branches/py3k/Python/sysmodule.c Log: Fixed #1630 sys.maxint was still documented and sys.float_info an sys.subversion were missing Modified: python/branches/py3k/Python/sysmodule.c ============================================================================== --- python/branches/py3k/Python/sysmodule.c (original) +++ python/branches/py3k/Python/sysmodule.c Sat Dec 15 02:28:04 2007 @@ -865,10 +865,11 @@ "\n\ Static objects:\n\ \n\ -maxint -- the largest supported integer (the smallest is -maxint-1)\n\ +float_info -- a dict with information about the float implementation.\n\ maxsize -- the largest supported length of containers.\n\ maxunicode -- the largest supported character\n\ builtin_module_names -- tuple of module names built into this interpreter\n\ +subversion -- subversion information of the build as tuple\n\ version -- the version of this interpreter as a string\n\ version_info -- version information as a tuple\n\ hexversion -- version information encoded as a single integer\n\ From python-3000-checkins at python.org Sat Dec 15 10:55:35 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Sat, 15 Dec 2007 10:55:35 +0100 (CET) Subject: [Python-3000-checkins] r59523 - python/branches/py3k/Doc/library/sys.rst Message-ID: <20071215095535.F14F51E400E@bag.python.org> Author: georg.brandl Date: Sat Dec 15 10:55:35 2007 New Revision: 59523 Modified: python/branches/py3k/Doc/library/sys.rst Log: Fix sys.maxsize docs. Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Sat Dec 15 10:55:35 2007 @@ -367,10 +367,11 @@ .. data:: maxsize - An integer giving the size of ``Py_ssize_t``. It's usually 2**31-1 on a 32 - bit platform and 2**63-1 on a 64bit platform. + An integer giving the maximum value a variable of type :ctype:`Py_ssize_t` can + take. It's usually ``2**31 - 1`` on a 32-bit platform and ``2**63 - 1`` on a + 64-bit platform. - ..versionadded:: 3.0 + .. versionadded:: 3.0 .. data:: maxunicode From python-3000-checkins at python.org Mon Dec 17 21:04:14 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 17 Dec 2007 21:04:14 +0100 (CET) Subject: [Python-3000-checkins] r59543 - in python/branches/py3k: Doc/Makefile Doc/conf.py Doc/library/objects.rst Doc/library/othergui.rst Doc/library/stdtypes.rst Doc/library/turtle.rst Doc/using/windows.rst Doc/whatsnew/2.6.rst Lib/decimal.py Lib/test/output/test_pep277 Lib/test/test_pep277.py Objects/listobject.c configure configure.in Message-ID: <20071217200414.C3DED1E4013@bag.python.org> Author: christian.heimes Date: Mon Dec 17 21:04:13 2007 New Revision: 59543 Removed: python/branches/py3k/Lib/test/output/test_pep277 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/Makefile python/branches/py3k/Doc/conf.py python/branches/py3k/Doc/library/objects.rst python/branches/py3k/Doc/library/othergui.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/turtle.rst python/branches/py3k/Doc/using/windows.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/test/test_pep277.py python/branches/py3k/Objects/listobject.c python/branches/py3k/configure python/branches/py3k/configure.in Log: Merged revisions 59512-59540 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59513 | raymond.hettinger | 2007-12-15 01:07:25 +0100 (Sat, 15 Dec 2007) | 6 lines Optimize PyList_AsTuple(). Improve cache performance by doing the pointer copy and object increment in one pass. For small lists, save the overhead of the call to memcpy() -- this comes up in calls like f(*listcomp). ........ r59519 | christian.heimes | 2007-12-15 06:38:35 +0100 (Sat, 15 Dec 2007) | 2 lines Fixed #1624: Remove output comparison for test_pep277 I had to modify Brett's patch slightly. ........ r59520 | georg.brandl | 2007-12-15 10:34:59 +0100 (Sat, 15 Dec 2007) | 2 lines Add note about future import needed for with statement. ........ r59522 | georg.brandl | 2007-12-15 10:36:37 +0100 (Sat, 15 Dec 2007) | 2 lines Argh, wrong version. ........ r59524 | georg.brandl | 2007-12-16 12:06:09 +0100 (Sun, 16 Dec 2007) | 2 lines Dummy commit to investigate #1617. ........ r59525 | georg.brandl | 2007-12-16 12:21:48 +0100 (Sun, 16 Dec 2007) | 2 lines Revert dummy commit now that the build slave is building. ........ r59527 | georg.brandl | 2007-12-16 16:47:46 +0100 (Sun, 16 Dec 2007) | 2 lines Remove orphaned footnote reference. ........ r59528 | georg.brandl | 2007-12-16 16:53:49 +0100 (Sun, 16 Dec 2007) | 2 lines Remove gratuitous unicode character. ........ r59529 | georg.brandl | 2007-12-16 16:59:19 +0100 (Sun, 16 Dec 2007) | 2 lines Remove another unnecessary Unicode character. ........ r59530 | georg.brandl | 2007-12-16 17:00:36 +0100 (Sun, 16 Dec 2007) | 2 lines Remove curious space-like characters. ........ r59532 | georg.brandl | 2007-12-16 20:36:51 +0100 (Sun, 16 Dec 2007) | 2 lines Adapt conf.py to new option names. ........ r59533 | christian.heimes | 2007-12-16 22:39:43 +0100 (Sun, 16 Dec 2007) | 1 line Fixed #1638: %zd configure test fails on Linux ........ r59536 | georg.brandl | 2007-12-17 00:11:16 +0100 (Mon, 17 Dec 2007) | 2 lines Simplify. ........ r59537 | georg.brandl | 2007-12-17 00:13:29 +0100 (Mon, 17 Dec 2007) | 2 lines Use PEP 8. ........ r59539 | georg.brandl | 2007-12-17 00:15:07 +0100 (Mon, 17 Dec 2007) | 2 lines Don't use quotes for non-string code. ........ r59540 | facundo.batista | 2007-12-17 15:18:42 +0100 (Mon, 17 Dec 2007) | 4 lines Removed the private _rounding_decision: it was not needed, and the code is now simpler. Thanks Mark Dickinson. ........ Modified: python/branches/py3k/Doc/Makefile ============================================================================== --- python/branches/py3k/Doc/Makefile (original) +++ python/branches/py3k/Doc/Makefile Mon Dec 17 21:04:13 2007 @@ -7,16 +7,19 @@ PYTHON = python2.5 SVNROOT = http://svn.python.org/projects SPHINXOPTS = +PAPER = -ALLSPHINXOPTS = -b$(BUILDER) -dbuild/doctrees $(SPHINXOPTS) . build/$(BUILDER) +ALLSPHINXOPTS = -b $(BUILDER) -d build/doctrees -D latex_paper_size=$(PAPER) \ + $(SPHINXOPTS) . build/$(BUILDER) .PHONY: help checkout update build html web htmlhelp clean help: @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " web to make file usable by Sphinx.web" + @echo " html to make standalone HTML files" + @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" checkout: @if [ ! -d tools/sphinx ]; then \ @@ -60,6 +63,8 @@ latex: BUILDER = latex latex: build @echo "Build finished; the LaTeX files are in build/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." clean: -rm -rf build/* Modified: python/branches/py3k/Doc/conf.py ============================================================================== --- python/branches/py3k/Doc/conf.py (original) +++ python/branches/py3k/Doc/conf.py Mon Dec 17 21:04:13 2007 @@ -4,7 +4,9 @@ # # The contents of this file are pickled, so don't put values in the namespace # that aren't pickleable (module imports are okay, they're removed automatically). -# + +# General configuration +# --------------------- # The default replacements for |version| and |release|. # If 'auto', Sphinx looks for the Include/patchlevel.h file in the current Python @@ -23,9 +25,6 @@ # Else, today_fmt is used as the format for a strftime call. today_fmt = '%B %d, %Y' -# The base URL for download links. -download_base_url = 'http://docs.python.org/ftp/python/doc/' - # List of files that shouldn't be included in the build. unused_files = [ 'whatsnew/2.0.rst', @@ -40,17 +39,34 @@ 'library/xml.etree.rst', ] +# If true, '()' will be appended to :func: etc. cross-reference text. +add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +add_module_names = True + + +# Options for HTML output +# ----------------------- + +# The base URL for download links. +html_download_base_url = 'http://docs.python.org/ftp/python/doc/' + # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -last_updated_format = '%b %d, %Y' +html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -use_smartypants = True +html_use_smartypants = True -# If true, '()' will be appended to :func: etc. cross-reference text. -add_function_parentheses = True -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -add_module_names = True +# Options for LaTeX output +# ------------------------ + +# The paper size ("letter" or "a4"). +latex_paper_size = "a4" + +# The font size ("10pt", "11pt" or "12pt"). +latex_font_size = "10pt" Modified: python/branches/py3k/Doc/library/objects.rst ============================================================================== --- python/branches/py3k/Doc/library/objects.rst (original) +++ python/branches/py3k/Doc/library/objects.rst Mon Dec 17 21:04:13 2007 @@ -16,7 +16,7 @@ in a separate symbol table. This table is searched last when the interpreter looks up the meaning of a name, so local and global user-defined names can override built-in names. Built-in types are described together here for easy -reference. [#]_ +reference. The tables in this chapter document the priorities of operators by listing them in order of ascending priority (within a table) and grouping operators that have Modified: python/branches/py3k/Doc/library/othergui.rst ============================================================================== --- python/branches/py3k/Doc/library/othergui.rst (original) +++ python/branches/py3k/Doc/library/othergui.rst Mon Dec 17 21:04:13 2007 @@ -63,14 +63,14 @@ `wxPython `_ wxPython is a cross-platform GUI toolkit for Python that is built around the popular `wxWidgets `_ (formerly wxWindows) - C++ toolkit. ?It provides a native look and feel for applications on + C++ toolkit. It provides a native look and feel for applications on Windows, Mac OS X, and Unix systems by using each platform's native - widgets where ever possible, (GTK+ on Unix-like systems). ?In addition to + widgets where ever possible, (GTK+ on Unix-like systems). In addition to an extensive set of widgets, wxPython provides classes for online documentation and context sensitive help, printing, HTML viewing, low-level device context drawing, drag and drop, system clipboard access, an XML-based resource format and more, including an ever growing library - of user-contributed modules. ?wxPython has a book, `wxPython in Action + of user-contributed modules. wxPython has a book, `wxPython in Action `_, by Noel Rappin and Robin Dunn. Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Mon Dec 17 21:04:13 2007 @@ -608,7 +608,7 @@ (5) The slice of *s* from *i* to *j* with step *k* is defined as the sequence of - items with index ``x = i + n*k`` such that 0 ?n < (j-i)/(k). In other words, + items with index ``x = i + n*k`` such that ``0 <= n < (j-i)/k``. In other words, the indices are ``i``, ``i+k``, ``i+2*k``, ``i+3*k`` and so on, stopping when *j* is reached (but never including *j*). If *i* or *j* is greater than ``len(s)``, use ``len(s)``. If *i* or *j* are omitted or ``None``, they become Modified: python/branches/py3k/Doc/library/turtle.rst ============================================================================== --- python/branches/py3k/Doc/library/turtle.rst (original) +++ python/branches/py3k/Doc/library/turtle.rst Mon Dec 17 21:04:13 2007 @@ -285,5 +285,5 @@ .. method:: Turtle.degrees([fullcircle]) *fullcircle* is by default 360. This can cause the pen to have any angular units - whatever: give *fullcircle* 2\*$? for radians, or 400 for gradians. + whatever: give *fullcircle* ``2*pi`` for radians, or 400 for gradians. Modified: python/branches/py3k/Doc/using/windows.rst ============================================================================== --- python/branches/py3k/Doc/using/windows.rst (original) +++ python/branches/py3k/Doc/using/windows.rst Mon Dec 17 21:04:13 2007 @@ -276,9 +276,7 @@ +--------------------+--------------+-----------------------+ | Directory | MSVC version | Visual Studio version | +====================+==============+=======================+ -| :file:`PC/VC6/` | 5.0 | 97 | -| +--------------+-----------------------+ -| | 6.0 | 6.0 | +| :file:`PC/VC6/` | 6.0 | 97 | +--------------------+--------------+-----------------------+ | :file:`PCbuild/` | 7.1 | 2003 | +--------------------+--------------+-----------------------+ Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Mon Dec 17 21:04:13 2007 @@ -202,7 +202,7 @@ methods. * The context manager's :meth:`__enter__` method is called. The value returned - is assigned to *VAR*. If no ``'as VAR'`` clause is present, the value is simply + is assigned to *VAR*. If no ``as VAR`` clause is present, the value is simply discarded. * The code in *BLOCK* is executed. @@ -242,11 +242,11 @@ class DatabaseConnection: # Database interface - def cursor (self): + def cursor(self): "Returns a cursor object and starts a new transaction" - def commit (self): + def commit(self): "Commits current transaction" - def rollback (self): + def rollback(self): "Rolls back current transaction" The :meth:`__enter__` method is pretty easy, having only to start a new @@ -256,7 +256,7 @@ class DatabaseConnection: ... - def __enter__ (self): + def __enter__(self): # Code to start a new transaction cursor = self.cursor() return cursor @@ -273,7 +273,7 @@ class DatabaseConnection: ... - def __exit__ (self, type, value, tb): + def __exit__(self, type, value, tb): if tb is None: # No exception, so commit self.commit() @@ -306,7 +306,7 @@ from contextlib import contextmanager @contextmanager - def db_transaction (connection): + def db_transaction(connection): cursor = connection.cursor() try: yield cursor Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Mon Dec 17 21:04:13 2007 @@ -147,10 +147,6 @@ ROUND_HALF_DOWN = 'ROUND_HALF_DOWN' ROUND_05UP = 'ROUND_05UP' -# Rounding decision (not part of the public API) -NEVER_ROUND = 'NEVER_ROUND' # Round in division (non-divmod), sqrt ONLY -ALWAYS_ROUND = 'ALWAYS_ROUND' # Every operation rounds at end. - # Errors class DecimalException(ArithmeticError): @@ -932,9 +928,7 @@ if context is None: context = getcontext() - if context._rounding_decision == ALWAYS_ROUND: - return ans._fix(context) - return ans + return ans._fix(context) def __pos__(self, context=None): """Returns a copy, unless it is a sNaN. @@ -954,26 +948,23 @@ if context is None: context = getcontext() - if context._rounding_decision == ALWAYS_ROUND: - return ans._fix(context) - return ans + return ans._fix(context) - def __abs__(self, round=1, context=None): + def __abs__(self, round=True, context=None): """Returns the absolute value of self. - If the second argument is 0, do not round. + If the keyword argument 'round' is false, do not round. The + expression self.__abs__(round=False) is equivalent to + self.copy_abs(). """ + if not round: + return self.copy_abs() + if self._is_special: ans = self._check_nans(context=context) if ans: return ans - if not round: - if context is None: - context = getcontext() - context = context._shallow_copy() - context._set_rounding_decision(NEVER_ROUND) - if self._sign: ans = self.__neg__(context=context) else: @@ -1006,8 +997,6 @@ if other._isinfinity(): return Decimal(other) # Can't both be infinity here - shouldround = context._rounding_decision == ALWAYS_ROUND - exp = min(self._exp, other._exp) negativezero = 0 if context.rounding == ROUND_FLOOR and self._sign != other._sign: @@ -1019,33 +1008,29 @@ if negativezero: sign = 1 ans = _dec_from_triple(sign, '0', exp) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans if not self: exp = max(exp, other._exp - context.prec-1) ans = other._rescale(exp, context.rounding) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans if not other: exp = max(exp, self._exp - context.prec-1) ans = self._rescale(exp, context.rounding) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans op1 = _WorkRep(self) op2 = _WorkRep(other) - op1, op2 = _normalize(op1, op2, shouldround, context.prec) + op1, op2 = _normalize(op1, op2, context.prec) result = _WorkRep() if op1.sign != op2.sign: # Equal and opposite if op1.int == op2.int: ans = _dec_from_triple(negativezero, '0', exp) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans if op1.int < op2.int: op1, op2 = op2, op1 @@ -1070,8 +1055,7 @@ result.exp = op1.exp ans = Decimal(result) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans __radd__ = __add__ @@ -1128,34 +1112,29 @@ return Infsign[resultsign] resultexp = self._exp + other._exp - shouldround = context._rounding_decision == ALWAYS_ROUND # Special case for multiplying by zero if not self or not other: ans = _dec_from_triple(resultsign, '0', resultexp) - if shouldround: - # Fixing in case the exponent is out of bounds - ans = ans._fix(context) + # Fixing in case the exponent is out of bounds + ans = ans._fix(context) return ans # Special case for multiplying by power of 10 if self._int == '1': ans = _dec_from_triple(resultsign, other._int, resultexp) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans if other._int == '1': ans = _dec_from_triple(resultsign, self._int, resultexp) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans op1 = _WorkRep(self) op2 = _WorkRep(other) ans = _dec_from_triple(resultsign, str(op1.int * op2.int), resultexp) - if shouldround: - ans = ans._fix(context) + ans = ans._fix(context) return ans __rmul__ = __mul__ @@ -1292,8 +1271,7 @@ context._raise_error(InvalidOperation, 'x % 0')) quotient, remainder = self._divide(other, context) - if context._rounding_decision == ALWAYS_ROUND: - remainder = remainder._fix(context) + remainder = remainder._fix(context) return quotient, remainder def __rdivmod__(self, other, context=None): @@ -1327,8 +1305,7 @@ return context._raise_error(DivisionUndefined, '0 % 0') remainder = self._divide(other, context)[1] - if context._rounding_decision == ALWAYS_ROUND: - remainder = remainder._fix(context) + remainder = remainder._fix(context) return remainder def __rmod__(self, other, context=None): @@ -2498,9 +2475,7 @@ else: ans = self - if context._rounding_decision == ALWAYS_ROUND: - return ans._fix(context) - return ans + return ans._fix(context) def min(self, other, context=None): """Returns the smaller value. @@ -2534,9 +2509,7 @@ else: ans = other - if context._rounding_decision == ALWAYS_ROUND: - return ans._fix(context) - return ans + return ans._fix(context) def _isinteger(self): """Returns whether self is an integer""" @@ -3107,9 +3080,7 @@ else: ans = self - if context._rounding_decision == ALWAYS_ROUND: - return ans._fix(context) - return ans + return ans._fix(context) def min_mag(self, other, context=None): """Compares the values numerically with their sign ignored.""" @@ -3139,9 +3110,7 @@ else: ans = other - if context._rounding_decision == ALWAYS_ROUND: - return ans._fix(context) - return ans + return ans._fix(context) def next_minus(self, context=None): """Returns the largest representable number smaller than itself.""" @@ -3434,7 +3403,6 @@ Contains: prec - precision (for use in rounding, division, square roots..) rounding - rounding type (how you round) - _rounding_decision - ALWAYS_ROUND, NEVER_ROUND -- do you round? traps - If traps[exception] = 1, then the exception is raised when it is caused. Otherwise, a value is substituted in. @@ -3450,7 +3418,6 @@ def __init__(self, prec=None, rounding=None, traps=None, flags=None, - _rounding_decision=None, Emin=None, Emax=None, capitals=None, _clamp=0, _ignored_flags=None): @@ -3488,16 +3455,16 @@ def _shallow_copy(self): """Returns a shallow copy from self.""" - nc = Context(self.prec, self.rounding, self.traps, self.flags, - self._rounding_decision, self.Emin, self.Emax, - self.capitals, self._clamp, self._ignored_flags) + nc = Context(self.prec, self.rounding, self.traps, + self.flags, self.Emin, self.Emax, + self.capitals, self._clamp, self._ignored_flags) return nc def copy(self): """Returns a deep copy from self.""" nc = Context(self.prec, self.rounding, self.traps.copy(), - self.flags.copy(), self._rounding_decision, self.Emin, - self.Emax, self.capitals, self._clamp, self._ignored_flags) + self.flags.copy(), self.Emin, self.Emax, + self.capitals, self._clamp, self._ignored_flags) return nc __copy__ = copy @@ -3554,27 +3521,6 @@ """Returns maximum exponent (= Emax - prec + 1)""" return int(self.Emax - self.prec + 1) - def _set_rounding_decision(self, type): - """Sets the rounding decision. - - Sets the rounding decision, and returns the current (previous) - rounding decision. Often used like: - - context = context._shallow_copy() - # That so you don't change the calling context - # if an error occurs in the middle (say DivisionImpossible is raised). - - rounding = context._set_rounding_decision(NEVER_ROUND) - instance = instance / Decimal(2) - context._set_rounding_decision(rounding) - - This will make it not round for that operation. - """ - - rounding = self._rounding_decision - self._rounding_decision = type - return rounding - def _set_rounding(self, type): """Sets the rounding type. @@ -4762,7 +4708,7 @@ -def _normalize(op1, op2, shouldround = 0, prec = 0): +def _normalize(op1, op2, prec = 0): """Normalizes op1, op2 to have the same exp and length of coefficient. Done during addition. @@ -4779,13 +4725,12 @@ # as adding any positive quantity smaller than 10**exp; similarly # for subtraction. So if other is smaller than 10**exp we replace # it with 10**exp. This avoids tmp.exp - other.exp getting too large. - if shouldround: - tmp_len = len(str(tmp.int)) - other_len = len(str(other.int)) - exp = tmp.exp + min(-1, tmp_len - prec - 2) - if other_len + other.exp - 1 < exp: - other.int = 1 - other.exp = exp + tmp_len = len(str(tmp.int)) + other_len = len(str(other.int)) + exp = tmp.exp + min(-1, tmp_len - prec - 2) + if other_len + other.exp - 1 < exp: + other.int = 1 + other.exp = exp tmp.int *= 10 ** (tmp.exp - other.exp) tmp.exp = other.exp @@ -5153,7 +5098,6 @@ prec=28, rounding=ROUND_HALF_EVEN, traps=[DivisionByZero, Overflow, InvalidOperation], flags=[], - _rounding_decision=ALWAYS_ROUND, Emax=999999999, Emin=-999999999, capitals=1 Deleted: /python/branches/py3k/Lib/test/output/test_pep277 ============================================================================== --- /python/branches/py3k/Lib/test/output/test_pep277 Mon Dec 17 21:04:13 2007 +++ (empty file) @@ -1,3 +0,0 @@ -test_pep277 -'\xdf-\u66e8\u66e9\u66eb' -['Gr\xfc\xdf-Gott', 'abc', 'ascii', '\u0393\u03b5\u03b9\u03ac-\u03c3\u03b1\u03c2', '\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435', '\u05d4\u05e9\u05e7\u05e6\u05e5\u05e1', '\u306b\u307d\u3093', '\u66e8\u05e9\u3093\u0434\u0393\xdf', '\u66e8\u66e9\u66eb'] Modified: python/branches/py3k/Lib/test/test_pep277.py ============================================================================== --- python/branches/py3k/Lib/test/test_pep277.py (original) +++ python/branches/py3k/Lib/test/test_pep277.py Mon Dec 17 21:04:13 2007 @@ -78,12 +78,12 @@ def test_listdir(self): f1 = os.listdir(test_support.TESTFN) - # Printing f1 is not appropriate, as specific filenames - # returned depend on the local encoding f2 = os.listdir(str(test_support.TESTFN.encode("utf-8"), sys.getfilesystemencoding())) - f2.sort() - print(f2) + sf2 = set("\\".join((unicode(test_support.TESTFN), f)) + for f in f2) + self.failUnlessEqual(len(f1), len(self.files)) + self.failUnlessEqual(sf2, set(self.files)) def test_rename(self): for name in self.files: @@ -99,7 +99,6 @@ f = open(filename, 'wb') f.write((filename + '\n').encode("utf-8")) f.close() - print(repr(filename)) os.access(filename,os.R_OK) os.remove(filename) os.chdir(oldwd) Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Mon Dec 17 21:04:13 2007 @@ -2177,7 +2177,7 @@ PyList_AsTuple(PyObject *v) { PyObject *w; - PyObject **p; + PyObject **p, **q; Py_ssize_t n; if (v == NULL || !PyList_Check(v)) { PyErr_BadInternalCall(); @@ -2188,12 +2188,12 @@ if (w == NULL) return NULL; p = ((PyTupleObject *)w)->ob_item; - memcpy((void *)p, - (void *)((PyListObject *)v)->ob_item, - n*sizeof(PyObject *)); + q = ((PyListObject *)v)->ob_item; while (--n >= 0) { - Py_INCREF(*p); + Py_INCREF(*q); + *p = *q; p++; + q++; } return w; } Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Mon Dec 17 21:04:13 2007 @@ -23389,9 +23389,9 @@ #include #include -int main() -{ - char buffer[256]; +#ifdef HAVE_SYS_TYPES_H +#include +#endif #ifdef HAVE_SSIZE_T typedef ssize_t Py_ssize_t; @@ -23401,6 +23401,10 @@ typedef int Py_ssize_t; #endif +int main() +{ + char buffer[256]; + if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Mon Dec 17 21:04:13 2007 @@ -3429,9 +3429,9 @@ #include #include -int main() -{ - char buffer[256]; +#ifdef HAVE_SYS_TYPES_H +#include +#endif #ifdef HAVE_SSIZE_T typedef ssize_t Py_ssize_t; @@ -3441,6 +3441,10 @@ typedef int Py_ssize_t; #endif +int main() +{ + char buffer[256]; + if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; From python-3000-checkins at python.org Wed Dec 19 03:07:36 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 19 Dec 2007 03:07:36 +0100 (CET) Subject: [Python-3000-checkins] r59563 - in python/branches/py3k: Doc/c-api/utilities.rst Doc/library/collections.rst Doc/library/functions.rst Doc/library/stdtypes.rst Include/Python.h Include/dictobject.h Include/opcode.h Include/pyport.h Include/pystrcmp.h Lib/collections.py Lib/ctypes/test/test_delattr.py Lib/lib-tk/FixTk.py Lib/opcode.py Lib/test/test_collections.py Lib/test/test_dict.py Lib/test/test_float.py Makefile.pre.in Modules/_ctypes/_ctypes.c Modules/_ctypes/cfield.c Modules/socketmodule.c Objects/dictobject.c Objects/floatobject.c PC/pyconfig.h PCbuild/pythoncore.vcproj PCbuild8/pythoncore/pythoncore.vcproj PCbuild9/Uninstal.wse PCbuild9/_bsddb.rc PCbuild9/_tkinter.vcproj PCbuild9/build_tkinter.py PCbuild9/idle.bat PCbuild9/pyproject.vsprops PCbuild9/python.build PCbuild9/python.iss PCbuild9/python20.wse PCbuild9/pythoncore.vcproj Python/ceval.c Python/compile.c Python/import.c Python/pystrcmp.c configure configure.in pyconfig.h.in Message-ID: <20071219020736.DA43A1E4029@bag.python.org> Author: christian.heimes Date: Wed Dec 19 03:07:34 2007 New Revision: 59563 Added: python/branches/py3k/Include/pystrcmp.h - copied unchanged from r59561, python/trunk/Include/pystrcmp.h python/branches/py3k/Lib/ctypes/test/test_delattr.py (contents, props changed) python/branches/py3k/PCbuild9/idle.bat python/branches/py3k/Python/pystrcmp.c - copied unchanged from r59561, python/trunk/Python/pystrcmp.c Removed: python/branches/py3k/PCbuild9/Uninstal.wse python/branches/py3k/PCbuild9/_bsddb.rc python/branches/py3k/PCbuild9/python.build python/branches/py3k/PCbuild9/python.iss python/branches/py3k/PCbuild9/python20.wse Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/utilities.rst python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Include/Python.h python/branches/py3k/Include/dictobject.h python/branches/py3k/Include/opcode.h python/branches/py3k/Include/pyport.h python/branches/py3k/Lib/collections.py python/branches/py3k/Lib/lib-tk/FixTk.py python/branches/py3k/Lib/opcode.py python/branches/py3k/Lib/test/test_collections.py python/branches/py3k/Lib/test/test_dict.py python/branches/py3k/Lib/test/test_float.py python/branches/py3k/Makefile.pre.in python/branches/py3k/Modules/_ctypes/_ctypes.c python/branches/py3k/Modules/_ctypes/cfield.c python/branches/py3k/Modules/socketmodule.c python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/floatobject.c python/branches/py3k/PC/pyconfig.h python/branches/py3k/PCbuild/pythoncore.vcproj python/branches/py3k/PCbuild8/pythoncore/pythoncore.vcproj python/branches/py3k/PCbuild9/_tkinter.vcproj python/branches/py3k/PCbuild9/build_tkinter.py python/branches/py3k/PCbuild9/pyproject.vsprops python/branches/py3k/PCbuild9/pythoncore.vcproj python/branches/py3k/Python/ceval.c python/branches/py3k/Python/compile.c python/branches/py3k/Python/import.c python/branches/py3k/configure python/branches/py3k/configure.in python/branches/py3k/pyconfig.h.in Log: Merged revisions 59541-59561 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59544 | raymond.hettinger | 2007-12-18 01:13:45 +0100 (Tue, 18 Dec 2007) | 1 line Add more namedtuple() test cases. Neaten the code and comments. ........ r59545 | christian.heimes | 2007-12-18 04:38:03 +0100 (Tue, 18 Dec 2007) | 3 lines Fixed for #1601: IDLE not working correctly on Windows (Py30a2/IDLE30a1) Amaury's ideas works great. Should we build the Python core with WINVER=0x0500 and _WIN32_WINNT=0x0500, too? ........ r59546 | christian.heimes | 2007-12-18 10:00:13 +0100 (Tue, 18 Dec 2007) | 1 line Make it a bit easier to test Tcl/Tk and idle from a build dir. ........ r59547 | christian.heimes | 2007-12-18 10:12:10 +0100 (Tue, 18 Dec 2007) | 1 line Removed several unused files from the PCbuild9 directory. They are relics from the past. ........ r59548 | raymond.hettinger | 2007-12-18 19:26:18 +0100 (Tue, 18 Dec 2007) | 29 lines Speed-up dictionary constructor by about 10%. New opcode, STORE_MAP saves the compiler from awkward stack manipulations and specializes for dicts using PyDict_SetItem instead of PyObject_SetItem. Old disassembly: 0 BUILD_MAP 0 3 DUP_TOP 4 LOAD_CONST 1 (1) 7 ROT_TWO 8 LOAD_CONST 2 ('x') 11 STORE_SUBSCR 12 DUP_TOP 13 LOAD_CONST 3 (2) 16 ROT_TWO 17 LOAD_CONST 4 ('y') 20 STORE_SUBSCR New disassembly: 0 BUILD_MAP 0 3 LOAD_CONST 1 (1) 6 LOAD_CONST 2 ('x') 9 STORE_MAP 10 LOAD_CONST 3 (2) 13 LOAD_CONST 4 ('y') 16 STORE_MAP ........ r59549 | thomas.heller | 2007-12-18 20:00:34 +0100 (Tue, 18 Dec 2007) | 2 lines Issue #1642: Fix segfault in ctypes when trying to delete attributes. ........ r59551 | guido.van.rossum | 2007-12-18 21:10:42 +0100 (Tue, 18 Dec 2007) | 2 lines Issue #1645 by Alberto Bertogli. Fix a comment. ........ r59553 | raymond.hettinger | 2007-12-18 22:24:09 +0100 (Tue, 18 Dec 2007) | 12 lines Give meaning to the oparg for BUILD_MAP: estimated size of the dictionary. Allows dictionaries to be pre-sized (upto 255 elements) saving time lost to re-sizes with their attendant mallocs and re-insertions. Has zero effect on small dictionaries (5 elements or fewer), a slight benefit for dicts upto 22 elements (because they had to resize once anyway), and more benefit for dicts upto 255 elements (saving multiple resizes during the build-up and reducing the number of collisions on the first insertions). Beyond 255 elements, there is no addional benefit. ........ r59554 | christian.heimes | 2007-12-18 22:56:09 +0100 (Tue, 18 Dec 2007) | 1 line Fixed #1649: IDLE error: dictionary changed size during iteration ........ r59557 | raymond.hettinger | 2007-12-18 23:21:27 +0100 (Tue, 18 Dec 2007) | 1 line Simplify and speedup _asdict() for named tuples. ........ r59558 | christian.heimes | 2007-12-19 00:22:54 +0100 (Wed, 19 Dec 2007) | 3 lines Applied patch #1635: Float patch for inf and nan on Windows (and other platforms). The patch unifies float("inf") and repr(float("inf")) on all platforms. ........ r59559 | raymond.hettinger | 2007-12-19 00:51:15 +0100 (Wed, 19 Dec 2007) | 1 line Users demand iterable input for named tuples. The author capitulates. ........ r59560 | raymond.hettinger | 2007-12-19 01:21:06 +0100 (Wed, 19 Dec 2007) | 1 line Beef-up tests for dict literals ........ r59561 | raymond.hettinger | 2007-12-19 01:27:21 +0100 (Wed, 19 Dec 2007) | 1 line Zap a duplicate line ........ Modified: python/branches/py3k/Doc/c-api/utilities.rst ============================================================================== --- python/branches/py3k/Doc/c-api/utilities.rst (original) +++ python/branches/py3k/Doc/c-api/utilities.rst Wed Dec 19 03:07:34 2007 @@ -1047,6 +1047,22 @@ See the Unix man page :manpage:`atof(2)` for details. + +.. cfunction:: char * PyOS_stricmp(char *s1, char *s2) + + Case insensitive comparsion of strings. The functions works almost + identical to :cfunc:`strcmp` except that it ignores the case. + + .. versionadded:: 2.6 + + +.. cfunction:: char * PyOS_strnicmp(char *s1, char *s2, Py_ssize_t size) + + Case insensitive comparsion of strings. The functions works almost + identical to :cfunc:`strncmp` except that it ignores the case. + + .. versionadded:: 2.6 + .. _reflection: Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Wed Dec 19 03:07:34 2007 @@ -421,27 +421,31 @@ __slots__ = () - _fields = ('x', 'y') - def __new__(cls, x, y): return tuple.__new__(cls, (x, y)) + _cast = classmethod(tuple.__new__) + def __repr__(self): return 'Point(x=%r, y=%r)' % self - def _asdict(self): + def _asdict(t): 'Return a new dict which maps field names to their values' - return dict(zip(('x', 'y'), self)) + return {'x': t[0], 'y': t[1]} def _replace(self, **kwds): 'Return a new Point object replacing specified fields with new values' - return Point(*map(kwds.get, ('x', 'y'), self)) + return Point._cast(map(kwds.get, ('x', 'y'), self)) + + @property + def _fields(self): + return ('x', 'y') x = property(itemgetter(0)) y = property(itemgetter(1)) >>> p = Point(11, y=22) # instantiate with positional or keyword arguments - >>> p[0] + p[1] # indexable like the regular tuple (11, 22) + >>> p[0] + p[1] # indexable like the plain tuple (11, 22) 33 >>> x, y = p # unpack like a regular tuple >>> x, y @@ -456,33 +460,30 @@ EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade') - from itertools import starmap import csv - for record in starmap(EmployeeRecord, csv.reader(open("employees.csv", "rb"))): + for emp in map(EmployeeRecord._cast, csv.reader(open("employees.csv", "rb"))): print(emp.name, emp.title) import sqlite3 conn = sqlite3.connect('/companydata') cursor = conn.cursor() cursor.execute('SELECT name, age, title, department, paygrade FROM employees') - for emp in starmap(EmployeeRecord, cursor.fetchall()): + for emp in map(EmployeeRecord._cast, cursor.fetchall()): print emp.name, emp.title -When casting a single record to a named tuple, use the star-operator [#]_ to unpack -the values:: +In addition to the methods inherited from tuples, named tuples support +three additonal methods and a read-only attribute. - >>> t = [11, 22] - >>> Point(*t) # the star-operator unpacks any iterable object - Point(x=11, y=22) +.. method:: namedtuple._cast(iterable) -When casting a dictionary to a named tuple, use the double-star-operator:: + Class method returning a new instance taking the positional arguments from the *iterable*. + Useful for casting existing sequences and iterables to named tuples: - >>> d = {'x': 11, 'y': 22} - >>> Point(**d) - Point(x=11, y=22) +:: -In addition to the methods inherited from tuples, named tuples support -two additonal methods and a read-only attribute. + >>> t = [11, 22] + >>> Point._cast(t) + Point(x=11, y=22) .. method:: somenamedtuple._asdict() @@ -529,6 +530,12 @@ >>> getattr(p, 'x') 11 +When casting a dictionary to a named tuple, use the double-star-operator [#]_:: + + >>> d = {'x': 11, 'y': 22} + >>> Point(**d) + Point(x=11, y=22) + Since a named tuple is a regular Python class, it is easy to add or change functionality. For example, the display format can be changed by overriding the :meth:`__repr__` method: @@ -551,5 +558,5 @@ .. rubric:: Footnotes -.. [#] For information on the star-operator see +.. [#] For information on the double-star-operator see :ref:`tut-unpacking-arguments` and :ref:`calls`. Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Wed Dec 19 03:07:34 2007 @@ -435,7 +435,8 @@ Convert a string or a number to floating point. If the argument is a string, it must contain a possibly signed decimal or floating point number, possibly - embedded in whitespace. Otherwise, the argument may be an integer + embedded in whitespace. The argument may also be [+|-]nan or [+|-]inf. + Otherwise, the argument may be a plain integer or a floating point number, and a floating point number with the same value (within Python's floating point precision) is returned. If no argument is given, returns ``0.0``. @@ -447,9 +448,10 @@ single: Infinity When passing in a string, values for NaN and Infinity may be returned, depending - on the underlying C library. The specific set of strings accepted which cause - these values to be returned depends entirely on the C library and is known to - vary. + on the underlying C library. Float accepts the strings nan, inf and -inf for + NaN and positive or negative infinity. The case and a leading + are ignored as + well as a leading - is ignored for NaN. Float always represents NaN and infinity + as nan, inf or -inf. The float type is described in :ref:`typesnumeric`. Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Wed Dec 19 03:07:34 2007 @@ -285,7 +285,7 @@ +---------------------+---------------------------------+-------+--------------------+ | ``int(x)`` | *x* converted to integer | \(3) | :func:`int` | +---------------------+---------------------------------+-------+--------------------+ -| ``float(x)`` | *x* converted to floating point | | :func:`float` | +| ``float(x)`` | *x* converted to floating point | \(6) | :func:`float` | +---------------------+---------------------------------+-------+--------------------+ | ``complex(re, im)`` | a complex number with real part | | :func:`complex` | | | *re*, imaginary part *im*. | | | @@ -329,6 +329,13 @@ as in C; see functions :func:`floor` and :func:`ceil` in the :mod:`math` module for well-defined conversions. +(6) + float also accepts the strings "nan" and "inf" with an optional prefix "+" + or "-" for Not a Number (NaN) and positive or negative infinity. + + .. versionadded:: 2.6 + + .. % XXXJH exceptions: overflow (when? what operations?) zerodivision Modified: python/branches/py3k/Include/Python.h ============================================================================== --- python/branches/py3k/Include/Python.h (original) +++ python/branches/py3k/Include/Python.h Wed Dec 19 03:07:34 2007 @@ -114,6 +114,7 @@ #include "eval.h" #include "pystrtod.h" +#include "pystrcmp.h" /* _Py_Mangle is defined in compile.c */ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); Modified: python/branches/py3k/Include/dictobject.h ============================================================================== --- python/branches/py3k/Include/dictobject.h (original) +++ python/branches/py3k/Include/dictobject.h Wed Dec 19 03:07:34 2007 @@ -123,6 +123,7 @@ PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash); +PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); /* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); Modified: python/branches/py3k/Include/opcode.h ============================================================================== --- python/branches/py3k/Include/opcode.h (original) +++ python/branches/py3k/Include/opcode.h Wed Dec 19 03:07:34 2007 @@ -36,6 +36,7 @@ #define INPLACE_FLOOR_DIVIDE 28 #define INPLACE_TRUE_DIVIDE 29 +#define STORE_MAP 54 #define INPLACE_ADD 55 #define INPLACE_SUBTRACT 56 #define INPLACE_MULTIPLY 57 Modified: python/branches/py3k/Include/pyport.h ============================================================================== --- python/branches/py3k/Include/pyport.h (original) +++ python/branches/py3k/Include/pyport.h Wed Dec 19 03:07:34 2007 @@ -332,6 +332,17 @@ #define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) #endif +/* High precision defintion of pi and e (Euler) + * The values are taken from libc6's math.h. + */ +#ifndef Py_MATH_PI +#define Py_MATH_PI 3.1415926535897932384626433832795029L +#endif + +#ifndef Py_MATH_E +#define Py_MATH_E 2.7182818284590452353602874713526625L +#endif + /* Py_IS_NAN(X) * Return 1 if float or double arg is a NaN, else 0. * Caution: @@ -341,8 +352,12 @@ * a platform where it doesn't work. */ #ifndef Py_IS_NAN +#ifdef HAVE_ISNAN +#define Py_IS_NAN(X) isnan(X) +#else #define Py_IS_NAN(X) ((X) != (X)) #endif +#endif /* Py_IS_INFINITY(X) * Return 1 if float or double arg is an infinity, else 0. @@ -353,8 +368,12 @@ * Override in pyconfig.h if you have a better spelling on your platform. */ #ifndef Py_IS_INFINITY +#ifdef HAVE_ISINF +#define Py_IS_INFINITY(X) isinf(X) +#else #define Py_IS_INFINITY(X) ((X) && (X)*0.5 == (X)) #endif +#endif /* Py_IS_FINITE(X) * Return 1 if float or double arg is neither infinite nor NAN, else 0. @@ -362,8 +381,12 @@ * macro for this particular test is useful */ #ifndef Py_IS_FINITE +#ifdef HAVE_ISFINITE +#define Py_IS_FINITE(X) isfinite +#else #define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) #endif +#endif /* HUGE_VAL is supposed to expand to a positive double infinity. Python * uses Py_HUGE_VAL instead because some platforms are broken in this @@ -376,6 +399,15 @@ #define Py_HUGE_VAL HUGE_VAL #endif +/* Py_NAN + * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or + * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform + * doesn't support NaNs. + */ +#if !defined(Py_NAN) && !defined(Py_NO_NAN) +#define Py_NAN (Py_HUGE_VAL * 0.) +#endif + /* Py_OVERFLOWED(X) * Return 1 iff a libm function overflowed. Set errno to 0 before calling * a libm function, and invoke this macro after, passing the function Modified: python/branches/py3k/Lib/collections.py ============================================================================== --- python/branches/py3k/Lib/collections.py (original) +++ python/branches/py3k/Lib/collections.py Wed Dec 19 03:07:34 2007 @@ -1,17 +1,15 @@ __all__ = ['deque', 'defaultdict', 'namedtuple'] - -from _collections import deque, defaultdict -from operator import itemgetter as _itemgetter -from itertools import izip as _izip -from keyword import iskeyword as _iskeyword -import sys as _sys - # For bootstrapping reasons, the collection ABCs are defined in _abcoll.py. # They should however be considered an integral part of collections.py. from _abcoll import * import _abcoll __all__ += _abcoll.__all__ +from _collections import deque, defaultdict +from operator import itemgetter as _itemgetter +from keyword import iskeyword as _iskeyword +import sys as _sys + def namedtuple(typename, field_names, verbose=False): """Returns a new subclass of tuple with named fields. @@ -19,9 +17,9 @@ >>> Point.__doc__ # docstring for the new class 'Point(x, y)' >>> p = Point(11, y=22) # instantiate with positional args or keywords - >>> p[0] + p[1] # works just like the tuple (11, 22) + >>> p[0] + p[1] # indexable like a plain tuple 33 - >>> x, y = p # unpacks just like a tuple + >>> x, y = p # unpack like a regular tuple >>> x, y (11, 22) >>> p.x + p.y # fields also accessable by name @@ -58,31 +56,35 @@ # Create and fill-in the class template argtxt = repr(field_names).replace("'", "")[1:-1] # tuple repr without parens or quotes reprtxt = ', '.join('%s=%%r' % name for name in field_names) + dicttxt = ', '.join('%r: t[%d]' % (name, pos) for pos, name in enumerate(field_names)) template = '''class %(typename)s(tuple): '%(typename)s(%(argtxt)s)' \n __slots__ = () \n - _fields = property(lambda self: %(field_names)r) \n def __new__(cls, %(argtxt)s): return tuple.__new__(cls, (%(argtxt)s)) \n + _cast = classmethod(tuple.__new__) \n def __repr__(self): return '%(typename)s(%(reprtxt)s)' %% self \n - def _asdict(self, dict=dict, zip=zip): + def _asdict(t): 'Return a new dict which maps field names to their values' - return dict(zip(%(field_names)r, self)) \n + return {%(dicttxt)s} \n def _replace(self, **kwds): 'Return a new %(typename)s object replacing specified fields with new values' - return %(typename)s(*map(kwds.get, %(field_names)r, self)) \n\n''' % locals() + return %(typename)s._cast(map(kwds.get, %(field_names)r, self)) \n + @property + def _fields(self): + return %(field_names)r \n\n''' % locals() for i, name in enumerate(field_names): template += ' %s = property(itemgetter(%d))\n' % (name, i) if verbose: print(template) # Execute the template string in a temporary namespace - namespace = dict(itemgetter=_itemgetter, zip=_izip) + namespace = dict(itemgetter=_itemgetter) try: exec(template, namespace) except SyntaxError as e: - raise SyntaxError(e.message + ':\n' + template) + raise SyntaxError(e.msg + ':\n' + template) from e result = namespace[typename] # For pickling to work, the __module__ variable needs to be set to the frame Added: python/branches/py3k/Lib/ctypes/test/test_delattr.py ============================================================================== --- (empty file) +++ python/branches/py3k/Lib/ctypes/test/test_delattr.py Wed Dec 19 03:07:34 2007 @@ -0,0 +1,21 @@ +import unittest +from ctypes import * + +class X(Structure): + _fields_ = [("foo", c_int)] + +class TestCase(unittest.TestCase): + def test_simple(self): + self.assertRaises(TypeError, + delattr, c_int(42), "value") + + def test_chararray(self): + self.assertRaises(TypeError, + delattr, (c_char * 5)(), "value") + + def test_struct(self): + self.assertRaises(TypeError, + delattr, X(), "foo") + +if __name__ == "__main__": + unittest.main() Modified: python/branches/py3k/Lib/lib-tk/FixTk.py ============================================================================== --- python/branches/py3k/Lib/lib-tk/FixTk.py (original) +++ python/branches/py3k/Lib/lib-tk/FixTk.py Wed Dec 19 03:07:34 2007 @@ -11,6 +11,10 @@ # the real Tcl library will do. prefix = os.path.join(sys.prefix,"tcl") +if not os.path.exists(prefix): + # devdir/../tcltk/lib + prefix = os.path.join(sys.prefix, os.path.pardir, "tcltk", "lib") + prefix = os.path.abspath(prefix) # if this does not exist, no further search is needed if os.path.exists(prefix): if "TCL_LIBRARY" not in os.environ: Modified: python/branches/py3k/Lib/opcode.py ============================================================================== --- python/branches/py3k/Lib/opcode.py (original) +++ python/branches/py3k/Lib/opcode.py Wed Dec 19 03:07:34 2007 @@ -71,6 +71,7 @@ def_op('INPLACE_FLOOR_DIVIDE', 28) def_op('INPLACE_TRUE_DIVIDE', 29) +def_op('STORE_MAP', 54) def_op('INPLACE_ADD', 55) def_op('INPLACE_SUBTRACT', 56) def_op('INPLACE_MULTIPLY', 57) @@ -123,7 +124,7 @@ def_op('BUILD_TUPLE', 102) # Number of tuple items def_op('BUILD_LIST', 103) # Number of list items def_op('BUILD_SET', 104) # Number of set items -def_op('BUILD_MAP', 105) # Always zero for now +def_op('BUILD_MAP', 105) # Number of dict entries (upto 255) name_op('LOAD_ATTR', 106) # Index in name list def_op('COMPARE_OP', 107) # Comparison operator hascompare.append(107) Modified: python/branches/py3k/Lib/test/test_collections.py ============================================================================== --- python/branches/py3k/Lib/test/test_collections.py (original) +++ python/branches/py3k/Lib/test/test_collections.py Wed Dec 19 03:07:34 2007 @@ -49,6 +49,7 @@ self.assertEqual(repr(p), 'Point(x=11, y=22)') self.assert_('__dict__' not in dir(p)) # verify instance has no dict self.assert_('__weakref__' not in dir(p)) + self.assertEqual(p, Point._cast([11, 22])) # test _cast classmethod self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method @@ -93,9 +94,40 @@ def test_odd_sizes(self): Zero = namedtuple('Zero', '') self.assertEqual(Zero(), ()) + self.assertEqual(Zero._cast([]), ()) + self.assertEqual(repr(Zero()), 'Zero()') + self.assertEqual(Zero()._asdict(), {}) + self.assertEqual(Zero()._fields, ()) + Dot = namedtuple('Dot', 'd') self.assertEqual(Dot(1), (1,)) - + self.assertEqual(Dot._cast([1]), (1,)) + self.assertEqual(Dot(1).d, 1) + self.assertEqual(repr(Dot(1)), 'Dot(d=1)') + self.assertEqual(Dot(1)._asdict(), {'d':1}) + self.assertEqual(Dot(1)._replace(d=999), (999,)) + self.assertEqual(Dot(1)._fields, ('d',)) + + # n = 10000 + n = 254 # SyntaxError: more than 255 arguments: + import string, random + names = [''.join([random.choice(string.ascii_letters) for j in range(10)]) for i in range(n)] + Big = namedtuple('Big', names) + b = Big(*range(n)) + self.assertEqual(b, tuple(range(n))) + self.assertEqual(Big._cast(range(n)), tuple(range(n))) + for pos, name in enumerate(names): + self.assertEqual(getattr(b, name), pos) + repr(b) # make sure repr() doesn't blow-up + d = b._asdict() + d_expected = dict(zip(names, range(n))) + self.assertEqual(d, d_expected) + b2 = b._replace(**dict([(names[1], 999),(names[-5], 42)])) + b2_expected = list(range(n)) + b2_expected[1] = 999 + b2_expected[-5] = 42 + self.assertEqual(b2, tuple(b2_expected)) + self.assertEqual(b._fields, tuple(names)) class TestOneTrickPonyABCs(unittest.TestCase): Modified: python/branches/py3k/Lib/test/test_dict.py ============================================================================== --- python/branches/py3k/Lib/test/test_dict.py (original) +++ python/branches/py3k/Lib/test/test_dict.py Wed Dec 19 03:07:34 2007 @@ -1,7 +1,7 @@ import unittest from test import test_support -import sys, UserDict +import sys, UserDict, random, string class DictTest(unittest.TestCase): @@ -11,6 +11,15 @@ self.assertEqual(dict(), {}) self.assert_(dict() is not {}) + def test_literal_constructor(self): + # check literal constructor for different sized dicts (to exercise the BUILD_MAP oparg + items = [] + for n in range(400): + dictliteral = '{' + ', '.join('%r: %d' % item for item in items) + '}' + self.assertEqual(eval(dictliteral), dict(items)) + items.append((''.join([random.choice(string.ascii_letters) for j in range(8)]), n)) + random.shuffle(items) + def test_bool(self): self.assert_(not {}) self.assert_({1: 2}) Modified: python/branches/py3k/Lib/test/test_float.py ============================================================================== --- python/branches/py3k/Lib/test/test_float.py (original) +++ python/branches/py3k/Lib/test/test_float.py Wed Dec 19 03:07:34 2007 @@ -3,6 +3,12 @@ import os from test import test_support +def isinf(x): + return x * 0.5 == x + +def isnan(x): + return x != x + class FormatFunctionsTestCase(unittest.TestCase): def setUp(self): @@ -159,6 +165,70 @@ self.assertEqual(v, eval(repr(v))) floats_file.close() +# Beginning with Python 2.6 float has cross platform compatible +# ways to create and representate inf and nan +class InfNanTest(unittest.TestCase): + def test_inf_from_str(self): + self.assert_(isinf(float("inf"))) + self.assert_(isinf(float("+inf"))) + self.assert_(isinf(float("-inf"))) + + self.assertEqual(repr(float("inf")), "inf") + self.assertEqual(repr(float("+inf")), "inf") + self.assertEqual(repr(float("-inf")), "-inf") + + self.assertEqual(repr(float("INF")), "inf") + self.assertEqual(repr(float("+Inf")), "inf") + self.assertEqual(repr(float("-iNF")), "-inf") + + self.assertEqual(str(float("inf")), "inf") + self.assertEqual(str(float("+inf")), "inf") + self.assertEqual(str(float("-inf")), "-inf") + + self.assertRaises(ValueError, float, "info") + self.assertRaises(ValueError, float, "+info") + self.assertRaises(ValueError, float, "-info") + self.assertRaises(ValueError, float, "in") + self.assertRaises(ValueError, float, "+in") + self.assertRaises(ValueError, float, "-in") + + def test_inf_as_str(self): + self.assertEqual(repr(1e300 * 1e300), "inf") + self.assertEqual(repr(-1e300 * 1e300), "-inf") + + self.assertEqual(str(1e300 * 1e300), "inf") + self.assertEqual(str(-1e300 * 1e300), "-inf") + + def test_nan_from_str(self): + self.assert_(isnan(float("nan"))) + self.assert_(isnan(float("+nan"))) + self.assert_(isnan(float("-nan"))) + + self.assertEqual(repr(float("nan")), "nan") + self.assertEqual(repr(float("+nan")), "nan") + self.assertEqual(repr(float("-nan")), "nan") + + self.assertEqual(repr(float("NAN")), "nan") + self.assertEqual(repr(float("+NAn")), "nan") + self.assertEqual(repr(float("-NaN")), "nan") + + self.assertEqual(str(float("nan")), "nan") + self.assertEqual(str(float("+nan")), "nan") + self.assertEqual(str(float("-nan")), "nan") + + self.assertRaises(ValueError, float, "nana") + self.assertRaises(ValueError, float, "+nana") + self.assertRaises(ValueError, float, "-nana") + self.assertRaises(ValueError, float, "na") + self.assertRaises(ValueError, float, "+na") + self.assertRaises(ValueError, float, "-na") + + def test_nan_as_str(self): + self.assertEqual(repr(1e300 * 1e300 * 0), "nan") + self.assertEqual(repr(-1e300 * 1e300 * 0), "nan") + + self.assertEqual(str(1e300 * 1e300 * 0), "nan") + self.assertEqual(str(-1e300 * 1e300 * 0), "nan") def test_main(): test_support.run_unittest( @@ -166,7 +236,8 @@ UnknownFormatTestCase, IEEEFormatTestCase, FormatTestCase, - #ReprTestCase + ReprTestCase, + InfNanTest, ) if __name__ == '__main__': Modified: python/branches/py3k/Makefile.pre.in ============================================================================== --- python/branches/py3k/Makefile.pre.in (original) +++ python/branches/py3k/Makefile.pre.in Wed Dec 19 03:07:34 2007 @@ -275,6 +275,7 @@ Python/sysmodule.o \ Python/traceback.o \ Python/getopt.o \ + Python/pystrcmp.o \ Python/pystrtod.o \ Python/formatter_unicode.o \ Python/$(DYNLOADFILE) \ @@ -585,6 +586,8 @@ Include/pymem.h \ Include/pyport.h \ Include/pystate.h \ + Include/pystrtod.h \ + Include/pystrcmp.h \ Include/pythonrun.h \ Include/rangeobject.h \ Include/setobject.h \ Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Wed Dec 19 03:07:34 2007 @@ -783,6 +783,12 @@ char *ptr; Py_ssize_t size; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } + if (PyUnicode_Check(value)) { value = PyUnicode_AsEncodedString(value, conversion_mode_encoding, @@ -838,6 +844,11 @@ { Py_ssize_t result = 0; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, @@ -4022,6 +4033,11 @@ PyObject *result; StgDictObject *dict = PyObject_stgdict((PyObject *)self); + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } assert(dict); /* Cannot be NULL for CDataObject instances */ assert(dict->setfunc); result = dict->setfunc(self->b_ptr, value, dict->size); Modified: python/branches/py3k/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/cfield.c (original) +++ python/branches/py3k/Modules/_ctypes/cfield.c Wed Dec 19 03:07:34 2007 @@ -195,6 +195,11 @@ assert(CDataObject_Check(inst)); dst = (CDataObject *)inst; ptr = dst->b_ptr + self->offset; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } return CData_set(inst, self->proto, self->setfunc, value, self->index, self->size, ptr); } Modified: python/branches/py3k/Modules/socketmodule.c ============================================================================== --- python/branches/py3k/Modules/socketmodule.c (original) +++ python/branches/py3k/Modules/socketmodule.c Wed Dec 19 03:07:34 2007 @@ -2181,12 +2181,12 @@ /* - * This is the guts of the recv() and recv_into() methods, which reads into a - * char buffer. If you have any inc/def ref to do to the objects that contain - * the buffer, do it in the caller. This function returns the number of bytes - * succesfully read. If there was an error, it returns -1. Note that it is - * also possible that we return a number of bytes smaller than the request - * bytes. + * This is the guts of the recvfrom() and recvfrom_into() methods, which reads + * into a char buffer. If you have any inc/def ref to do to the objects that + * contain the buffer, do it in the caller. This function returns the number + * of bytes succesfully read. If there was an error, it returns -1. Note + * that it is also possible that we return a number of bytes smaller than the + * request bytes. * * 'addr' is a return value for the address object. Note that you must decref * it yourself. Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Wed Dec 19 03:07:34 2007 @@ -551,6 +551,23 @@ return 0; } +/* Create a new dictionary pre-sized to hold an estimated number of elements. + Underestimates are okay because the dictionary will resize as necessary. + Overestimates just mean the dictionary will be more sparse than usual. +*/ + +PyObject * +_PyDict_NewPresized(Py_ssize_t minused) +{ + PyObject *op = PyDict_New(); + + if (minused>5 && op != NULL && dictresize((PyDictObject *)op, minused) == -1) { + Py_DECREF(op); + return NULL; + } + return op; +} + /* Note that, for historical reasons, PyDict_GetItem() suppresses all errors * that may occur (originally dicts supported only string keys, and exceptions * weren't possible). So, while the original intent was that a NULL return Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Wed Dec 19 03:07:34 2007 @@ -114,7 +114,7 @@ PyObject * PyFloat_FromString(PyObject *v) { - const char *s, *last, *end; + const char *s, *last, *end, *sp; double x; char buffer[256]; /* for errors */ char *s_buffer = NULL; @@ -146,6 +146,7 @@ PyErr_SetString(PyExc_ValueError, "empty string for float()"); goto error; } + sp = s; /* We don't care about overflow or underflow. If the platform supports * them, infinities and signed zeroes (on underflow) are fine. * However, strtod can return 0 for denormalized numbers, where atof @@ -161,7 +162,26 @@ byte at the end of the string, when the input is inf(inity). */ if (end > last) end = last; + /* Check for inf and nan. This is done late because it rarely happens. */ if (end == s) { + char *p = (char*)sp; + int sign = 1; + + if (*p == '-') { + sign = -1; + p++; + } + if (*p == '+') { + p++; + } + if (PyOS_strnicmp(p, "inf", 4) == 0) { + return PyFloat_FromDouble(sign * Py_HUGE_VAL); + } +#ifdef Py_NAN + if(PyOS_strnicmp(p, "nan", 4) == 0) { + return PyFloat_FromDouble(Py_NAN); + } +#endif PyOS_snprintf(buffer, sizeof(buffer), "invalid literal for float(): %.200s", s); PyErr_SetString(PyExc_ValueError, buffer); @@ -250,7 +270,9 @@ { register char *cp; char format[32]; - /* Subroutine for float_repr, float_str, and others. + int i; + + /* Subroutine for float_repr, float_str and float_print. We want float numbers to be recognizable as such, i.e., they should contain a decimal point or an exponent. However, %g may print the number as an integer; @@ -271,7 +293,33 @@ *cp++ = '.'; *cp++ = '0'; *cp++ = '\0'; + return; } + /* Checking the next three chars should be more than enough to + * detect inf or nan, even on Windows. We check for inf or nan + * at last because they are rare cases. + */ + for (i=0; *cp != '\0' && i<3; cp++, i++) { + if (isdigit(Py_CHARMASK(*cp)) || *cp == '.') + continue; + /* found something that is neither a digit nor point + * it might be a NaN or INF + */ +#ifdef Py_NAN + if (Py_IS_NAN(ob_fval)) { + strcpy(buf, "nan"); + } + else +#endif + if (Py_IS_INFINITY(ob_fval)) { + cp = buf; + if (*cp == '-') + cp++; + strcpy(cp, "inf"); + } + break; + } + } static void Modified: python/branches/py3k/PC/pyconfig.h ============================================================================== --- python/branches/py3k/PC/pyconfig.h (original) +++ python/branches/py3k/PC/pyconfig.h Wed Dec 19 03:07:34 2007 @@ -386,6 +386,15 @@ /* Fairly standard from here! */ +/* Define to 1 if you have the `copysign' function. */ +/* #define HAVE_COPYSIGN 1*/ + +/* Define to 1 if you have the `isinf' function. */ +#define HAVE_ISINF 1 + +/* Define to 1 if you have the `isnan' function. */ +#define HAVE_ISNAN 1 + /* Define if on AIX 3. System headers sometimes define this. We just want to avoid a redefinition error message. */ Modified: python/branches/py3k/PCbuild/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PCbuild/pythoncore.vcproj (original) +++ python/branches/py3k/PCbuild/pythoncore.vcproj Wed Dec 19 03:07:34 2007 @@ -701,6 +701,10 @@ RelativePath="..\Python\pystate.c"> + + + + @@ -1214,6 +1218,10 @@ > + + Deleted: /python/branches/py3k/PCbuild9/Uninstal.wse ============================================================================== --- /python/branches/py3k/PCbuild9/Uninstal.wse Wed Dec 19 03:07:34 2007 +++ (empty file) @@ -1,514 +0,0 @@ -Document Type: WSE -item: Global - Version=8.14 - Flags=00000100 - Split=1420 - Languages=65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - Copy Default=1 - Japanese Font Name=MS Gothic - Japanese Font Size=10 - Start Gradient=0 0 255 - End Gradient=0 0 0 - Windows Flags=00000000000000000000101000001000 - Message Font=MS Sans Serif - Font Size=8 - Disk Label=GLBS - Disk Filename=INSTALL - Patch Flags=0000000000000001 - Patch Threshold=200 - Patch Memory=4096 - Per-User Version ID=1 - Crystal Format=10111100101100000010001001001001 - Step View=&Properties -end -item: Remark - Text=Note from Tim: This is a verbatim copy of Wise's Uninstal.wse, altered at the end to write -end -item: Remark - Text=uninstall info under HKCU instead of HKLM if our DOADMIN var is false. -end -item: Remark -end -item: Remark - Text= Install Support for uninstalling the application. -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%_LOGFILE_PATH_% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH%\UNWISE.EXE -end -item: Compiler Variable If - Variable=_EXE_OS_TYPE_ - Value=WIN32 -end -item: Install File - Source=%_WISE_%\UNWISE32.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable Else -end -item: Install File - Source=%_WISE_%\UNWISE.EXE - Destination=%UNINSTALL_PATH% - Flags=0000000000000010 -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install Support for multiple languages -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_PATH% - Flags=00000010 -end -item: Set Variable - Variable=UNINSTALL_LANG - Value=%UNINSTALL_LANG%\UNWISE.INI -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=C - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_C_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=D - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FRA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_D_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FRA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=E - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DEU - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_E_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DEU - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=F - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.PTG - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_F_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.PTG - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=G - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_G_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=H - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ESP - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_H_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ESP - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=I - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ITA - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_I_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ITA - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=J - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.DAN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_J_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.DAN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=K - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.FIN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_K_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.FIN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=L - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.ISL - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_L_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.ISL - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=M - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NLD - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_M_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NLD - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=N - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.NOR - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_N_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.NOR - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=O - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.SVE - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_O_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.SVE - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Compiler Variable If - Variable=_LANG_LIST_ - Value=P - Flags=00000010 -end -item: Compiler Variable If - Value=%_WISE_%\LANGUAGE\UNWISE.JPN - Flags=00000011 -end -item: If/While Statement - Variable=LANG - Value=%_LANG_P_NAME_% -end -item: Install File - Source=%_WISE_%\LANGUAGE\UNWISE.JPN - Destination=%UNINSTALL_LANG% - Flags=0000000000000010 -end -item: End Block -end -item: Compiler Variable End -end -item: Compiler Variable End -end -item: Remark -end -item: Remark - Text= Install the add/remove or uninstall icon -end -item: Remark -end -item: Set Variable - Variable=UNINSTALL_PATH - Value=%UNINSTALL_PATH% - Flags=00010100 -end -item: Set Variable - Variable=INST_LOG_PATH - Value=%_LOGFILE_PATH_% - Flags=00010100 -end -item: Check Configuration - Flags=10111011 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Remark - Text=Write uninstall info under HKLM. This if/else/end block added by Tim. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=2 -end -item: Else Statement -end -item: Remark - Text=The same, but write under HKCU instead. -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%APPTITLE% - Value Name=DisplayName - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%UNINSTALL_PATH% %INST_LOG_PATH% - New Value= - Value Name=UninstallString - Root=1 -end -item: End Block -end -item: Else Statement -end -item: Add ProgMan Icon - Group=%GROUP% - Icon Name=Uninstall %APPTITLE% - Command Line=%UNINSTALL_PATH% %INST_LOG_PATH% -end -item: End Block -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit Registry - Total Keys=2 - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%COMPANY% - Value Name=RegCompany - Root=2 - end - item: Key - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%NAME% - Value Name=RegOwner - Root=2 - end -end -item: End Block -end -item: End Block -end Deleted: /python/branches/py3k/PCbuild9/_bsddb.rc ============================================================================== --- /python/branches/py3k/PCbuild9/_bsddb.rc Wed Dec 19 03:07:34 2007 +++ (empty file) @@ -1,61 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 7, 1 -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - Modified: python/branches/py3k/PCbuild9/_tkinter.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/_tkinter.vcproj (original) +++ python/branches/py3k/PCbuild9/_tkinter.vcproj Wed Dec 19 03:07:34 2007 @@ -56,7 +56,7 @@ /> All or you may not see these! -end -item: Remark -end -item: Remark - Text=When the version of Tcl/Tk changes, the compiler vrbl -end -item: Remark - Text=_TCLDIR_ may also need to be changed. -end -item: Remark -end -item: Set Variable - Variable=APPTITLE - Value=Python %PYVER_STRING% -end -item: Remark - Text=PY_VERSION should be major.minor only; used to create the registry key; must match MS_DLL_ID in python_nt.rc -end -item: Set Variable - Variable=PY_VERSION - Value=%_PYMAJOR_%.%_PYMINOR_% -end -item: Remark - Text=GROUP is the Start menu group name; user can override. -end -item: Set Variable - Variable=GROUP - Value=Python %PY_VERSION% - Flags=10000000 -end -item: Remark - Text=MAINDIR is the app directory; user can override. -end -item: Set Variable - Variable=MAINDIR - Value=Python%_PYMAJOR_%%_PYMINOR_% -end -item: Remark -end -item: Set Variable - Variable=DOADMIN - Value=%_DOADMIN_% -end -item: Remark - Text=Give non-admin users a chance to abort. -end -item: Check Configuration - Flags=10011111 -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: Display Message - Title=Doing non-admin install - Text=The current login does not have Administrator Privileges on this machine. Python will install its registry information into the per-user area only for the current login, instead of into the per-machine area for every account on this machine. Some advanced uses of Python may not work as a result (for example, running a Python script as a service). - Text= - Text=If this is not what you want, please click Cancel to abort this installation, log on as an Administrator, and start the installation again. - Flags=00001000 -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=Note from Tim: the "stop" on the next line is actually "pause". -end -item: Open/Close INSTALL.LOG - Flags=00000001 -end -item: Remark - Text=If the destination system does not have a writable Windows\System directory, system files will be written to the Windows\ directory -end -item: Check if File/Dir Exists - Pathname=%SYS% - Flags=10000100 -end -item: Set Variable - Variable=SYS - Value=%WIN% -end -item: End Block -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=COMMON - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files\Common Files - Value Name=CommonFilesDir - Flags=00000100 -end -item: Get Registry Key Value - Variable=PROGRAM_FILES - Key=SOFTWARE\Microsoft\Windows\CurrentVersion - Default=C:\Program Files - Value Name=ProgramFilesDir - Flags=00000100 -end -item: Set Variable - Variable=EXPLORER - Value=1 -end -item: End Block -end -item: Remark - Text=Note from Tim: The Wizard hardcod "C:" at the start of the replacement text for MAINDIR. -end -item: Remark - Text=That's not appropriate if the system drive doesn't happen to be C:. -end -item: Remark - Text=I removed the "C:", and that did the right thing for two people who tested it on non-C: machines, -end -item: Remark - Text=but it's unclear whether it will always do the right thing. -end -item: Set Variable - Variable=MAINDIR - Value=\%MAINDIR% - Flags=00001100 -end -item: Remark - Text=BACKUP is the variable that holds the path that all backup files will be copied to when overwritten -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP - Flags=10000000 -end -item: Remark - Text=DOBACKUP determines if a backup will be performed. The possible values are A (do backup) or B (do not do backup) -end -item: Set Variable - Variable=DOBACKUP - Value=A -end -item: Remark - Text=BRANDING determines if the installation will be branded with a name and company. By default, this is written to the INST directory (installation media). -end -item: Set Variable - Variable=BRANDING - Value=0 -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: Read INI Value - Variable=NAME - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Name -end -item: Read INI Value - Variable=COMPANY - Pathname=%INST%\CUSTDATA.INI - Section=Registration - Item=Company -end -item: If/While Statement - Variable=NAME -end -item: Set Variable - Variable=DOBRAND - Value=1 -end -item: Get System Information - Variable=NAME - Flags=00000110 -end -item: Get System Information - Variable=COMPANY - Flags=00000111 -end -item: End Block -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: Remark - Text=Set vrbls for the "Advanced Options" subdialog of Components. -end -item: Set Variable - Variable=SELECT_ADMIN - Value=A -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=SELECT_ADMIN - Value=B -end -item: End Block -end -item: Remark -end -item: Remark - Text=TASKS values: -end -item: Remark - Text=A: Register file extensions -end -item: Remark - Text=B: Create Start Menu shortcuts -end -item: Set Variable - Variable=TASKS - Value=AB -end -item: Remark -end -item: Remark - Text=COMPONENTS values: -end -item: Remark - Text=A: interpreter and libraries -end -item: Remark - Text=B: Tcl/Tk -end -item: Remark - Text=C: docs -end -item: Remark - Text=D: tools -end -item: Remark - Text=E: test suite -end -item: Set Variable - Variable=COMPONENTS - Value=ABCDE -end -item: Remark -end -item: Remark - Text=March thru the user GUI. -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Dialog=Select Destination Directory - Dialog=Backup Replaced Files - Dialog=Select Components - Dialog=Select Program Manager Group - Variable= - Variable= - Variable= - Variable=TASKS - Value= - Value= - Value= - Value=B - Compare=0 - Compare=0 - Compare=0 - Compare=3 - Flags=00000011 -end -item: If/While Statement - Variable=DISPLAY - Value=Start Installation -end -item: Set Variable - Variable=SUMMARY - Value=Install directory: %MAINDIR%%CRLF% -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing admin install.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Doing non-admin install.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Make backups, into %BACKUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't make backups.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Components:%CRLF% - Flags=00000001 -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python interpreter and libraries%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tcl/Tk (Tkinter, IDLE, pydoc)%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python documentation%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Tool and utility scripts%CRLF% - Flags=00000001 -end -item: End Block -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value= Python test suite%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Register file extensions.%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Don't register file extensions.%CRLF% - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%Start Menu group: %GROUP%%CRLF% - Flags=00000001 -end -item: Else Statement -end -item: Set Variable - Variable=SUMMARY - Value=%CRLF%No Start Menu shortcuts.%CRLF% - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Custom Dialog Set - Name=Select Destination Directory - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 11 323 33 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Destination Directory - Text French=S?lectionner le r?pertoire de destination - Text German=Zielverzeichnis w?hlen - Text Spanish=Seleccione el directorio de destino - Text Italian=Selezionare Directory di destinazione - end - item: Listbox - Rectangle=108 58 321 219 - Variable=MAINDIR - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000010000000101000001 - Flags=0000110000001010 - Text=%MAINDIR% - Text= - end - item: Static - Rectangle=108 40 313 58 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Please select a directory for the %APPTITLE% files. - end - end - item: Dialog - Title=Select Destination Directory - Title French=S?lectionner le r?pertoire de destination - Title German=Zielverzeichnis w?hlen - Title Spanish=Seleccione el directorio de destino - Title Italian=Selezionare Directory di destinazione - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 6 204 186 - Variable=MAINDIR - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%MAINDIR% - Text French=%MAINDIR% - Text German=%MAINDIR% - Text Spanish=%MAINDIR% - Text Italian=%MAINDIR% - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Spanish=Aceptar - Text Italian=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=MAINDIR - Value=%MAINDIR_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Spanish=Cancelar - Text Italian=Annulla - end - end -end -item: Custom Dialog Set - Name=Backup Replaced Files - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Fichiers de Sauvegarde Remplac?s - Title German=Sicherungskopie von ersetzten Dateien erstellen - Title Portuguese=Ficheiros substitu?dos de seguran?a - Title Spanish=Copias de seguridad de los archivos reemplazados - Title Italian=Backup file sostituiti - Title Danish=Sikkerhedskopiering af erstattede filer - Title Dutch=Vervangen bestanden kopi?ren - Title Norwegian=Sikkerhetskopiere erstattede filer - Title Swedish=S?kerhetskopiera utbytta filer - Width=350 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 251 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suivant> - Text German=&Weiter> - Text Portuguese=&Pr?ximo> - Text Spanish=&Siguiente > - Text Italian=&Avanti > - Text Danish=&N?ste> - Text Dutch=&Volgende> - Text Norwegian=&Neste> - Text Swedish=&N?sta > - end - item: Push Button - Rectangle=131 234 188 251 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=<&Retour - Text German=<&Zur?ck - Text Portuguese=<&Retornar - Text Spanish=<&Retroceder - Text Italian=< &Indietro - Text Danish=<&Tilbage - Text Dutch=<&Terug - Text Norwegian=<&Tilbake - Text Swedish=< &Tillbaka - end - item: Push Button - Rectangle=278 234 330 251 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Annuller - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - item: Static - Rectangle=11 221 329 223 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 46 320 98 - Create Flags=01010000000000000000000000000000 - Text=This installation program can create backup copies of all files replaced during the installation. These files will be used when the software is uninstalled and a rollback is requested. If backup copies are not created, you will only be able to uninstall the software and not roll the system back to a previous state. - Text= - Text=Do you want to create backups of replaced files? - Text French=Le programme d'installation peut cr?er des copies de sauvegarde de tous les fichiers remplac?s pendant l'installation. Ces fichiers sont utilis?s au cas o? le logiciel est d?sinstall? et que l'on proc?de ? la reprise du syst?me. Si les copies de sauvegarde ne sont pas cr??es, on ne pourra que d?sinstaller le logiciel sans reprendre le syst?me ? un ?tat pr?c?dent. Voulez-vous cr?er une sauvegarde des fichiers remplac?s ? - Text German=Dieses Installationsprogramm kann Sicherungskopien von allen w?hrend der Installation ersetzten Dateien erstellen. Diese Dateien werden zur R?ckg?ngigmachung der Installation und bei Anforderung eines Rollbacks verwendet. Ohne Sicherungskopien ist nur eine R?ckg?ngigmachung der Installation m?glich, nicht aber ein Rollback des Systems. Sicherungskopien der ersetzten Dateien erstellen? - Text Portuguese=Este programa de instala??o pode criar c?pias de seguran?a de todos os ficheiros substitu?dos durante a instala??o. Estes ficheiros ser?o utilizados quando o programa for desinstalado e for requisitada uma retomada. Se as c?pias de seguran?a n?o forem criadas, s? poder? desinstalar o programa e n?o pode retomar um estado anterior do sistema. Deseja criar c?pias de seguran?a dos ficheiros substitu?dos? - Text Spanish=Este programa de instalaci?n puede crear copias de seguridad de todos los archivos reemplazados durante la instalaci?n. Estos archivos se utilizar?n cuando se desinstale el software y se solicite volver al estado anterior. Si no se crean copias de seguridad, ?nicamente podr? desinstalar el software y no podr? devolver el sistema al estado anterior. ?Desea crear archivos de seguridad de los archivos reemplazados? - Text Italian=Questo programma di installazione pu? creare copie di backup di tutti i file sostituiti durante l?installazione. Questi file saranno usati quando il software sar? disinstallato e sar? richiesto un ritorno allo stato precedente. Se non crei le copie di backup, potrai solo disinstallare il software, ma non potrai riportare il sistema allo stato precedente. Vuoi creare i file di backup dei file sostituiti? - Text Danish=Dette installationsprogram kan oprette sikkerhedskopier af alle filer, som erstattes under installationen. Disse filer benyttes, n?r softwaren fjernes, og den tidligere systemkonfiguration genetableres. Hvis der ikke oprettes sikkerhedskopier, kan du kun fjerne den installerede software og ikke genetablere den tidligere systemkonfiguration. Vil du oprette sikkerhedskopier af filer, som erstattes? - Text Dutch=Dit installatieprogramma kan kopie?n maken van alle bestanden die tijdens de installatie worden vervangen. Deze worden dan gebruikt als de software-installatie ongedaan wordt gemaakt en u het systeem wilt laten terugkeren naar de oorspronkelijke staat. Als er geen back-up kopie?n worden gemaakt, kunt u de software enkel verwijderen maar het systeem niet in de oorspronkelijke staat terugbrengen. Wilt u een back-up maken van de vervangen bestanden? - Text Norwegian=Dette installasjonsprogrammet kan lage sikkerhetskopier av alle filer som blir erstattet under installasjonen. Disse filene vil tas i bruk n?r programvaren er avinstallert og det er behov for tilbakestilling. Hvis det ikke er laget sikkerhetskopier, kan du kun avinstallere programvaren og ikke stille systemet tilbake til tidligere status. ?nsker du ? lage sikkerhetskopier av de filene som blir erstattet n?? - Text Swedish=Installationsprogrammet kan skapa s?kerhetskopior av alla filer som byts ut under installationen. Dessa filer kan sedan anv?ndas n?r programvaran avinstalleras och du beg?r rollback. Om du d? inte har n?gra s?kerhetskopior kan du bara avinstallera programvaran, inte ?terskapa systemet i dess tidigare skick. Vill du g?ra s?kerhetskopior av de ersatta filerna? - end - item: Radio Button - Rectangle=141 106 265 136 - Variable=DOBACKUP - Create Flags=01010000000000010000000000001001 - Text=&Yes, make backups - Text=N&o, do not make backups - Text= - Text French=&Oui - Text French=N&on - Text French= - Text German=&Ja - Text German=N&ein - Text German= - Text Portuguese=&Sim - Text Portuguese=N?&o - Text Portuguese= - Text Spanish=&S? - Text Spanish=N&o - Text Spanish= - Text Italian=&S? - Text Italian=N&o - Text Italian= - Text Danish=&Ja - Text Danish=&Nej - Text Danish= - Text Dutch=&Ja - Text Dutch=N&ee - Text Dutch= - Text Norwegian=&Ja - Text Norwegian=&Nei - Text Norwegian= - Text Swedish=&Ja - Text Swedish=N&ej - Text Swedish= - end - item: Static - Control Name=BACK2 - Rectangle=108 173 320 208 - Action=1 - Create Flags=01010000000000000000000000000111 - Text=Backup File Destination Directory - Text French=R?pertoire de destination des fichiers de sauvegarde - Text German=Zielverzeichnis f?r die Sicherungsdatei - Text Portuguese=Direct?rio de destino de ficheiro de seguran?a - Text Spanish=Directorio de Destino de los Archivos de Seguridad - Text Italian=Directory di destinazione dei file di backup - Text Danish=Destinationsbibliotek til sikkerhedskopier - Text Dutch=Doeldirectory backup-bestand - Text Norwegian=M?lkatalog for sikkerhetskopier - Text Swedish=Katalog f?r s?kerhetskopierade filer - end - item: Push Button - Control Name=BACK3 - Rectangle=265 185 318 203 - Variable=BACKUP_SAVE - Value=%BACKUP% - Destination Dialog=1 - Action=2 - Create Flags=01010000000000010000000000000000 - Text=B&rowse... - Text French=P&arcourir - Text German=B&l?ttern... - Text Portuguese=P&rocurar - Text Spanish=V&isualizar... - Text Italian=Sfoglia... - Text Danish=&Gennemse... - Text Dutch=B&laderen... - Text Norwegian=Bla igjennom - Text Swedish=&Bl?ddra - end - item: Static - Control Name=BACK4 - Rectangle=129 188 254 200 - Destination Dialog=2 - Create Flags=01010000000000000000000000000000 - Text=%BACKUP% - Text French=%BACKUP% - Text German=%BACKUP% - Text Portuguese=%BACKUP% - Text Spanish=%BACKUP% - Text Italian=%BACKUP% - Text Danish=%BACKUP% - Text Dutch=%BACKUP% - Text Norwegian=%BACKUP% - Text Swedish=%BACKUP% - end - item: Static - Rectangle=108 11 323 36 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Backup Replaced Files - Text French=S?lectionner les composants - Text German=Komponenten ausw?hlen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: If/While Statement - Variable=DOBACKUP - Value=B - end - item: Set Control Attribute - Control Name=BACK3 - Operation=1 - end - item: Set Control Attribute - Control Name=BACK4 - Operation=1 - end - item: Else Statement - end - item: Set Control Attribute - Control Name=BACK3 - end - item: Set Control Attribute - Control Name=BACK4 - end - item: End Block - end - end - item: Dialog - Title=Select Destination Directory - Title French=Choisissez le r?pertoire de destination - Title German=Zielverzeichnis w?hlen - Title Portuguese=Seleccionar Direct?rio de Destino - Title Spanish=Seleccione el Directorio de Destino - Title Italian=Seleziona Directory di destinazione - Title Danish=V?lg Destinationsbibliotek - Title Dutch=Kies Doeldirectory - Title Norwegian=Velg m?lkatalog - Title Swedish=V?lj destinationskalatog - Width=276 - Height=216 - Font Name=Helv - Font Size=8 - item: Listbox - Rectangle=6 3 200 186 - Variable=BACKUP - Create Flags=01010000100000010000000101000000 - Flags=0000110000100010 - Text=%BACKUP% - Text= - Text French=%BACKUP% - Text French= - Text German=%BACKUP% - Text German= - Text Portuguese=%BACKUP% - Text Portuguese= - Text Spanish=%BACKUP% - Text Spanish= - Text Italian=%BACKUP% - Text Italian= - Text Danish=%BACKUP% - Text Danish= - Text Dutch=%BACKUP% - Text Dutch= - Text Norwegian=%BACKUP% - Text Norwegian= - Text Swedish=%BACKUP% - Text Swedish= - end - item: Push Button - Rectangle=209 8 265 26 - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=OK - Text German=OK - Text Portuguese=OK - Text Spanish=ACEPTAR - Text Italian=OK - Text Danish=OK - Text Dutch=OK - Text Norwegian=OK - Text Swedish=OK - end - item: Push Button - Rectangle=209 31 265 50 - Variable=BACKUP - Value=%BACKUP_SAVE% - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=Cancel - Text French=Annuler - Text German=Abbrechen - Text Portuguese=Cancelar - Text Spanish=Cancelar - Text Italian=Annulla - Text Danish=Slet - Text Dutch=Annuleren - Text Norwegian=Avbryt - Text Swedish=Avbryt - end - end -end -item: Custom Dialog Set - Name=Select Components - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Checkbox - Rectangle=108 66 313 156 - Variable=COMPONENTS - Create Flags=01010000000000010000000000000011 - Flags=0000000000000110 - Text=Python interpreter and libraries - Text=Tcl/Tk (Tkinter, IDLE, pydoc) - Text=Python HTML docs - Text=Python utility scripts (Tools/) - Text=Python test suite (Lib/test/) - Text= - Text French=Python interpreter, library and IDLE - Text French=Python HTML docs - Text French=Python utility scripts (Tools/) - Text French=Python test suite (Lib/test/) - Text French= - Text German=Python interpreter, library and IDLE - Text German=Python HTML docs - Text German=Python utility scripts (Tools/) - Text German=Python test suite (Lib/test/) - Text German= - Text Spanish=Python interpreter, library and IDLE - Text Spanish=Python HTML docs - Text Spanish=Python utility scripts (Tools/) - Text Spanish=Python test suite (Lib/test/) - Text Spanish= - Text Italian=Python interpreter, library and IDLE - Text Italian=Python HTML docs - Text Italian=Python utility scripts (Tools/) - Text Italian=Python test suite (Lib/test/) - Text Italian= - end - item: Static - Rectangle=108 45 320 63 - Create Flags=01010000000000000000000000000000 - Text=Choose which components to install by checking the boxes below. - Text French=Choisissez les composants que vous voulez installer en cochant les cases ci-dessous. - Text German=W?hlen Sie die zu installierenden Komponenten, indem Sie in die entsprechenden K?stchen klicken. - Text Spanish=Elija los componentes que desee instalar marcando los cuadros de abajo. - Text Italian=Scegliere quali componenti installare selezionando le caselle sottostanti. - end - item: Push Button - Rectangle=188 203 269 220 - Destination Dialog=1 - Action=2 - Enabled Color=00000000000000000000000011111111 - Create Flags=01010000000000010000000000000000 - Text=Advanced Options ... - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 43 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Components - Text French=S?lectionner les composants - Text German=Komponenten ausw?hlen - Text Spanish=Seleccione componentes - Text Italian=Selezionare i componenti - end - item: Static - Rectangle=251 180 311 193 - Variable=COMPONENTS - Value=MAINDIR - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=251 168 311 179 - Variable=COMPONENTS - Create Flags=01010000000000000000000000000010 - end - item: Static - Rectangle=123 168 234 181 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Required: - Text French=Espace disque requis : - Text German=Notwendiger Speicherplatz: - Text Spanish=Espacio requerido en el disco: - Text Italian=Spazio su disco necessario: - end - item: Static - Rectangle=123 180 234 193 - Create Flags=01010000000000000000000000000000 - Text=Disk Space Remaining: - Text French=Espace disque disponible : - Text German=Verbleibender Speicherplatz: - Text Spanish=Espacio en disco disponible: - Text Italian=Spazio su disco disponibile: - end - item: Static - Rectangle=108 158 320 196 - Action=1 - Create Flags=01010000000000000000000000000111 - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=VERIFY - end - item: Remark - Text=If they're installing Tcl/Tk, Tools, or the test suite, doesn't make much sense unless they're installing Python too. - end - item: If/While Statement - Variable=COMPONENTS - Value=BDE - Flags=00001010 - end - item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000011 - end - item: Display Message - Title=Are you sure? - Text=Installing Tcl/Tk, Tools or the test suite doesn't make much sense unless you install the Python interpreter and libraries too. - Text= - Text=Click Yes if that's really what you want. - Flags=00101101 - end - item: Remark - Text=Nothing -- just proceed to the next dialog. - end - item: Else Statement - end - item: Remark - Text=Return to the dialog. - end - item: Set Variable - Variable=DLG_EVENT_TYPE - end - item: End Block - end - item: End Block - end - item: End Block - end - item: End Block - end - end - item: Dialog - Title=Advanced Options - Width=339 - Height=213 - Font Name=Helv - Font Size=8 - item: Radio Button - Control Name=ADMIN2 - Rectangle=11 46 90 76 - Variable=SELECT_ADMIN - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000001001 - Text=Admin install - Text=Non-Admin installl - Text= - end - item: Push Button - Rectangle=188 170 244 189 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=OK - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Static - Rectangle=5 3 326 83 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Static - Control Name=ADMIN1 - Rectangle=11 11 321 45 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=By default, the install records settings in the per-machine area of the registry (HKLM), and installs the Python and C runtime DLLs to %SYS32%. Choose "Non-Admin install" if you would prefer settings made in the per-user registry (HKCU), and DLLs installed in %MAINDIR%. - end - item: Static - Rectangle=5 90 326 157 - Action=1 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000111 - end - item: Checkbox - Rectangle=11 121 243 151 - Variable=TASKS - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000010000000000000011 - Text=Register file extensions (.py, .pyw, .pyc, .pyo) - Text=Create Start Menu shortcuts - Text= - end - item: Static - Rectangle=11 103 320 121 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Choose tasks to perform by checking the boxes below. - end - item: If/While Statement - Variable=DLG_EVENT_TYPE - Value=INIT - end - item: If/While Statement - Variable=DOADMIN - Value=1 - end - item: Set Control Attribute - Control Name=ADMIN2 - end - item: Else Statement - end - item: Set Control Text - Control Name=ADMIN1 - Control Text=This section is available only if logged in to an account with Administrator privileges. - end - item: Set Control Attribute - Control Name=ADMIN2 - Operation=1 - end - item: End Block - end - item: End Block - end - end -end -item: Custom Dialog Set - Name=Select Program Manager Group - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Flags=0000000000000001 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Select Start Menu Group - Text French=S?lectionner le groupe du Gestionnaire de programme - Text German=Bestimmung der Programm-Managergruppe - Text Spanish=Seleccione grupo del Administrador de programas - Text Italian=Selezionare il gruppo ProgMan - end - item: Static - Rectangle=108 35 320 65 - Create Flags=01010000000000000000000000000000 - Text=Enter the name of the Start Menu program group to which to add the %APPTITLE% icons: - Text French=Entrez le nom du groupe du Gestionnaire de programme dans lequel vous souhaitez ajouter les ic?nes de %APPTITLE% : - Text German=Geben Sie den Namen der Programmgruppe ein, der das Symbol %APPTITLE% hinzugef?gt werden soll: - Text Spanish=Escriba el nombre del grupo del Administrador de programas en el que desea agregar los iconos de %APPTITLE%: - Text Italian=Inserire il nome del gruppo Program Manager per aggiungere le icone %APPTITLE% a: - end - item: Combobox - Rectangle=108 56 320 219 - Variable=GROUP - Create Flags=01010000001000010000001100000001 - Flags=0000000000000001 - Text=%GROUP% - Text= - Text French=%GROUP% - Text German=%GROUP% - Text Spanish=%GROUP% - Text Italian=%GROUP% - end - end -end -item: Custom Dialog Set - Name=Start Installation - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Next > - Text French=&Suite > - Text German=&Weiter > - Text Spanish=&Siguiente > - Text Italian=&Avanti > - end - item: Push Button - Rectangle=131 234 188 253 - Variable=DIRECTION - Value=B - Create Flags=01010000000000010000000000000000 - Text=< &Back - Text French=< &Retour - Text German=< &Zur?ck - Text Spanish=< &Atr?s - Text Italian=< &Indietro - end - item: Push Button - Rectangle=264 234 320 253 - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=108 10 323 53 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Ready to Install! - Text French=Pr?t ? installer ! - Text German=Installationsbereit! - Text Spanish=?Preparado para la instalaci?n! - Text Italian=Pronto per l'installazione! - end - item: Static - Rectangle=108 40 320 62 - Create Flags=01010000000000000000000000000000 - Text=Click the Next button to install %APPTITLE%, or the Back button to change choices: - Text French=Vous ?tes maintenant pr?t ? installer les fichiers %APPTITLE%. - Text French= - Text French=Cliquez sur le bouton Suite pour commencer l'installation ou sur le bouton Retour pour entrer les informations d'installation ? nouveau. - Text German=Sie k?nnen %APPTITLE% nun installieren. - Text German= - Text German=Klicken Sie auf "Weiter", um mit der Installation zu beginnen. Klicken Sie auf "Zur?ck", um die Installationsinformationen neu einzugeben. - Text Spanish=Ya est? listo para instalar %APPTITLE%. - Text Spanish= - Text Spanish=Presione el bot?n Siguiente para comenzar la instalaci?n o presione Atr?s para volver a ingresar la informaci?n para la instalaci?n. - Text Italian=Ora ? possibile installare %APPTITLE%. - Text Italian= - Text Italian=Premere il pulsante Avanti per avviare l'installazione o il pulsante Indietro per reinserire le informazioni di installazione. - end - item: Editbox - Rectangle=108 66 324 219 - Help Context=16711681 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000100000000001100011000100 - Text=%SUMMARY% - end - end -end -item: Remark -end -item: If/While Statement - Variable=DISPLAY - Value=Select Destination Directory -end -item: Remark - Text=User may have changed MAINDIR, so reset BACKUP to match. -end -item: Set Variable - Variable=BACKUP - Value=%MAINDIR%\BACKUP -end -item: End Block -end -item: Remark -end -item: End Block -end -item: Remark -end -item: Remark - Text=BEGIN WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark - Text=When the BACKUP feature is enabled, the BACKUPDIR is initialized -end -item: If/While Statement - Variable=DOBACKUP - Value=A -end -item: Set Variable - Variable=BACKUPDIR - Value=%BACKUP% -end -item: End Block -end -item: Remark - Text=The BRANDING information is written to the INI file on the installation media. -end -item: If/While Statement - Variable=BRANDING - Value=1 -end -item: If/While Statement - Variable=DOBRAND - Value=1 -end -item: Edit INI File - Pathname=%INST%\CUSTDATA.INI - Settings=[Registration] - Settings=NAME=%NAME% - Settings=COMPANY=%COMPANY% - Settings= -end -item: End Block -end -item: End Block -end -item: Remark - Text=Begin writing to the INSTALL.LOG -end -item: Open/Close INSTALL.LOG -end -item: Remark - Text=Check free disk space calculates free disk space as well as component sizes. -end -item: Remark - Text=It should be located before all Install File actions. -end -item: Check Disk Space - Component=COMPONENTS -end -item: Remark - Text=This include script allows uninstall support -end -item: Remark - Text=Note from Tim: this is our own Uninstal.wse, a copy of Wise's except -end -item: Remark - Text=it writes to HKCU (instead of HKLM) if the user doesn't have admin privs. -end -item: Include Script - Pathname=.\Uninstal.wse -end -item: Remark - Text=Note from Tim: these seeming no-ops actually convert to short filenames. -end -item: Set Variable - Variable=COMMON - Value=%COMMON% - Flags=00010100 -end -item: Set Variable - Variable=MAINDIR - Value=%MAINDIR% - Flags=00010100 -end -item: Remark - Text=This IF/THEN/ELSE reads the correct registry entries for shortcut/icon placement -end -item: Check Configuration - Flags=10111011 -end -item: Get Registry Key Value - Variable=STARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs\StartUp - Value Name=StartUp - Flags=00000010 -end -item: Get Registry Key Value - Variable=DESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Desktop - Value Name=Desktop - Flags=00000010 -end -item: Get Registry Key Value - Variable=STARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu - Value Name=Start Menu - Flags=00000010 -end -item: Get Registry Key Value - Variable=GROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%WIN%\Start Menu\Programs - Value Name=Programs - Flags=00000010 -end -item: Get Registry Key Value - Variable=CSTARTUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTUPDIR% - Value Name=Common Startup - Flags=00000100 -end -item: Get Registry Key Value - Variable=CDESKTOPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%DESKTOPDIR% - Value Name=Common Desktop - Flags=00000100 -end -item: Get Registry Key Value - Variable=CSTARTMENUDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%STARTMENUDIR% - Value Name=Common Start Menu - Flags=00000100 -end -item: Get Registry Key Value - Variable=CGROUPDIR - Key=Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders - Default=%GROUPDIR% - Value Name=Common Programs - Flags=00000100 -end -item: Else Statement -end -item: Remark - Text=Note from Tim: the Wizard left this block empty! -end -item: Remark - Text=Perhaps it's only relevant on Windows 3.1. -end -item: End Block -end -item: Remark - Text=END WIZARD STUFF ----------------------------------------------------------------------------------------------------------------------------- -end -item: Remark -end -item: If/While Statement - Variable=SELECT_ADMIN - Value=B -end -item: Remark - Text=The user chose a non-admin install in "Advanced Options". -end -item: Remark - Text=This should come after the include of Uninstal.wse above, because -end -item: Remark - Text=writing uninstall info to HKCU is ineffective except under Win2K. -end -item: Set Variable - Variable=DOADMIN - Value=0 -end -item: End Block -end -item: Remark -end -item: Set Variable - Variable=CGROUP_SAVE - Value=%GROUP% -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=GROUP - Value=%CGROUPDIR%\%GROUP% -end -item: Else Statement -end -item: Set Variable - Variable=GROUP - Value=%GROUPDIR%\%GROUP% -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Long section to install files. -end -item: Remark -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Set Variable - Variable=DLLDEST - Value=%SYS32% -end -item: Else Statement -end -item: Set Variable - Variable=DLLDEST - Value=%MAINDIR% -end -item: End Block -end -item: Remark -end -item: Remark - Text=Install the license even if they deselect everything . -end -item: Install File - Source=..\license - Destination=%MAINDIR%\LICENSE.txt - Flags=0000000000000010 -end -item: Install File - Source=..\readme - Destination=%MAINDIR%\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\misc\news - Destination=%MAINDIR%\NEWS.txt - Flags=0000000000000010 -end -item: Remark - Text=Icons -- always install so that the uninstaller can use them for its own display. -end -item: Install File - Source=..\pc\pycon.ico - Destination=%MAINDIR%\pycon.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\pyc.ico - Destination=%MAINDIR%\pyc.ico - Flags=0000000010000010 -end -item: Install File - Source=..\pc\py.ico - Destination=%MAINDIR%\py.ico - Flags=0000000010000010 -end -item: Remark -end -item: Remark - Text=These arrange to (recursively!) delete all .pyc and .pyo files at uninstall time. -end -item: Remark - Text=This "does the right thing": any directories left empty at the end are removed. -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyc -end -item: Add Text to INSTALL.LOG - Text=File Tree: %MAINDIR%\*.pyo -end -item: Remark -end -item: Remark - Text=A: interpreter and libraries -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Remark - Text=Executables -end -item: Install File - Source=.\python.exe - Destination=%MAINDIR%\python.exe - Flags=0000000000000010 -end -item: Install File - Source=.\pythonw.exe - Destination=%MAINDIR%\pythonw.exe - Flags=0000000000000010 -end -item: Install File - Source=.\w9xpopen.exe - Destination=%MAINDIR%\w9xpopen.exe - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Extension module DLLs (.pyd); keep in synch with libs directory next -end -item: Install File - Source=.\_winreg.pyd - Destination=%MAINDIR%\DLLs\_winreg.pyd - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.pyd - Destination=%MAINDIR%\DLLs\_csv.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.pyd - Destination=%MAINDIR%\DLLs\_sre.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.pyd - Destination=%MAINDIR%\DLLs\_ssl.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.pyd - Destination=%MAINDIR%\DLLs\_symtable.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.pyd - Destination=%MAINDIR%\DLLs\_testcapi.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.pyd - Destination=%MAINDIR%\DLLs\_tkinter.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.pyd - Destination=%MAINDIR%\DLLs\_socket.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\_bsddb.pyd - Destination=%MAINDIR%\DLLs\_bsddb.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.pyd - Destination=%MAINDIR%\DLLs\bz2.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.pyd - Destination=%MAINDIR%\DLLs\datetime.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.pyd - Destination=%MAINDIR%\DLLs\mmap.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\parser.pyd - Destination=%MAINDIR%\DLLs\parser.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.pyd - Destination=%MAINDIR%\DLLs\pyexpat.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\select.pyd - Destination=%MAINDIR%\DLLs\select.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.pyd - Destination=%MAINDIR%\DLLs\unicodedata.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.pyd - Destination=%MAINDIR%\DLLs\winsound.pyd - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.pyd - Destination=%MAINDIR%\DLLs\zlib.pyd - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Link libraries (.lib); keep in synch with DLLs above, except that the Python lib lives here. -end -item: Install File - Source=.\_winreg.lib - Destination=%MAINDIR%\libs\_winreg.lib - Description=Link library files - Flags=0000000000000010 -end -item: Install File - Source=.\_csv.lib - Destination=%MAINDIR%\libs\_csv.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_sre.lib - Destination=%MAINDIR%\libs\_sre.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_ssl.lib - Destination=%MAINDIR%\libs\_ssl.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_symtable.lib - Destination=%MAINDIR%\libs\_symtable.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_testcapi.lib - Destination=%MAINDIR%\libs\_testcapi.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_tkinter.lib - Destination=%MAINDIR%\libs\_tkinter.lib - Description=Extension modules - Flags=0000000000000010 -end -item: Install File - Source=.\_socket.lib - Destination=%MAINDIR%\libs\_socket.lib - Flags=0000000000000010 -end -item: Install File - Source=.\_bsddb.lib - Destination=%MAINDIR%\libs\_bsddb.lib - Flags=0000000000000010 -end -item: Install File - Source=.\bz2.lib - Destination=%MAINDIR%\libs\bz2.lib - Flags=0000000000000010 -end -item: Install File - Source=.\datetime.lib - Destination=%MAINDIR%\libs\datetime.lib - Flags=0000000000000010 -end -item: Install File - Source=.\mmap.lib - Destination=%MAINDIR%\libs\mmap.lib - Flags=0000000000000010 -end -item: Install File - Source=.\parser.lib - Destination=%MAINDIR%\libs\parser.lib - Flags=0000000000000010 -end -item: Install File - Source=.\pyexpat.lib - Destination=%MAINDIR%\libs\pyexpat.lib - Flags=0000000000000010 -end -item: Install File - Source=.\select.lib - Destination=%MAINDIR%\libs\select.lib - Flags=0000000000000010 -end -item: Install File - Source=.\unicodedata.lib - Destination=%MAINDIR%\libs\unicodedata.lib - Flags=0000000000000010 -end -item: Install File - Source=.\winsound.lib - Destination=%MAINDIR%\libs\winsound.lib - Flags=0000000000000010 -end -item: Install File - Source=.\zlib.lib - Destination=%MAINDIR%\libs\zlib.lib - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.lib - Destination=%MAINDIR%\libs\python%_PYMAJOR_%%_PYMINOR_%.lib - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Main Python DLL -end -item: Remark - Text=Tell Wise it's OK to delete the Python DLL at uninstall time, -end -item: Remark - Text=despite that we (may) write it into a system directory. -end -item: Add Text to INSTALL.LOG - Text=Non-System File: -end -item: Install File - Source=.\python%_pymajor_%%_pyminor_%.dll - Destination=%DLLDEST%\python%_PYMAJOR_%%_PYMINOR_%.dll - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Libraries (Lib/) -end -item: Install File - Source=..\lib\*.py - Destination=%MAINDIR%\Lib - Description=Library Modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\bsddb\*.py - Destination=%MAINDIR%\Lib\bsddb - Description=Berkeley database package - Flags=0000000100000010 -end -item: Remark -end -item: Install File - Source=..\lib\compiler\*.py - Destination=%MAINDIR%\Lib\compiler - Description=Python compiler written in Python - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\distutils\*.py - Destination=%MAINDIR%\Lib\distutils - Description=Distribution utility modules - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\readme - Destination=%MAINDIR%\Lib\distutils\README.txt - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\*.py - Destination=%MAINDIR%\Lib\distutils\command - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\wininst.exe - Destination=%MAINDIR%\Lib\distutils\command\wininst.exe - Flags=0000000000000010 -end -item: Install File - Source=..\lib\distutils\command\command_template - Destination=%MAINDIR%\Lib\distutils\command\command_template - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\email\*.py - Destination=%MAINDIR%\Lib\email - Description=Library email package - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\*.py - Destination=%MAINDIR%\Lib\email\test - Description=email tests - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.txt - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.gif - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Install File - Source=..\lib\email\test\data\*.au - Destination=%MAINDIR%\Lib\email\test\data - Description=email test data - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\encodings\*.py - Destination=%MAINDIR%\Lib\encodings - Description=Unicode encoding tables - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\lib-old\*.py - Destination=%MAINDIR%\Lib\lib-old - Description=Obsolete modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\lib-tk\*.py - Destination=%MAINDIR%\Lib\lib-tk - Description=Tkinter related library modules - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\logging\*.py - Destination=%MAINDIR%\Lib\logging - Description=Logging package - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\site-packages\readme - Destination=%MAINDIR%\Lib\site-packages\README.txt - Description=Site packages - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\xml\*.py - Destination=%MAINDIR%\Lib\xml - Description=XML support packages - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\dom\*.py - Destination=%MAINDIR%\Lib\xml\dom - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\parsers\*.py - Destination=%MAINDIR%\Lib\xml\parsers - Flags=0000000000000010 -end -item: Install File - Source=..\lib\xml\sax\*.py - Destination=%MAINDIR%\Lib\xml\sax - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=C Include files -end -item: Install File - Source=..\include\*.h - Destination=%MAINDIR%\include - Description=Header files - Flags=0000000000000010 -end -item: Install File - Source=..\pc\pyconfig.h - Destination=%MAINDIR%\include\pyconfig.h - Description=Header files (pyconfig.h) - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Microsoft C runtime libraries -end -item: Install File - Source=%_SYS_%\MSVCIRT.DLL - Destination=%DLLDEST%\MSVCIRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: Install File - Source=%_SYS_%\MSVCRT.DLL - Destination=%DLLDEST%\MSVCRT.DLL - Description=Visual C++ Runtime DLLs - Flags=0000011000010011 -end -item: End Block -end -item: Remark -end -item: Remark - Text=B: Tcl/Tk (Tkinter, IDLE, pydoc) -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Remark - Text=Tcl/Tk -end -item: Install File - Source=..\..\%_tcldir_%\bin\*.dll - Destination=%MAINDIR%\DLLs - Description=Tcl/Tk binaries and libraries - Flags=0000000000000010 -end -item: Install File - Source=..\..\%_tcldir_%\lib\*.* - Destination=%MAINDIR%\tcl - Description=Tcl/Tk binaries and libraries - Flags=0000000100000010 -end -item: Remark -end -item: Remark - Text=IDLE -end -item: Install File - Source=..\Lib\idlelib\*.py - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.txt - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\*.def - Destination=%MAINDIR%\Lib\idlelib - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Lib\idlelib\Icons\* - Destination=%MAINDIR%\Lib\idlelib\Icons - Description=Integrated DeveLopment Environment for Python - Flags=0000000000000010 -end -item: Install File - Source=..\Tools\scripts\idle - Destination=%MAINDIR%\Lib\idlelib\idle.pyw - Description=IDLE bootstrap script - Flags=0000000000000010 -end -item: Remark -end -item: Remark - Text=Windows pydoc driver -end -item: Install File - Source=..\tools\scripts\*.pyw - Destination=%MAINDIR%\Tools\Scripts - Description=Windows pydoc driver - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=C: docs -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Install File - Source=%_DOC_%\*.* - Destination=%MAINDIR%\Doc - Description=Python Documentation (HTML) - Flags=0000000100000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=D: tools -end -item: If/While Statement - Variable=COMPONENTS - Value=D - Flags=00000010 -end -item: Install File - Source=..\tools\scripts\*.py - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\*.doc - Destination=%MAINDIR%\Tools\Scripts - Description=Utility Scripts - Flags=0000000000000010 -end -item: Install File - Source=..\tools\scripts\readme - Destination=%MAINDIR%\Tools\Scripts\README.txt - Description=Utility Scripts - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\webchecker\*.py - Destination=%MAINDIR%\Tools\webchecker - Description=Web checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\webchecker\readme - Destination=%MAINDIR%\Tools\webchecker\README.txt - Description=Web checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\versioncheck\*.py - Destination=%MAINDIR%\Tools\versioncheck - Description=Version checker tool - Flags=0000000000000010 -end -item: Install File - Source=..\tools\versioncheck\readme - Destination=%MAINDIR%\Tools\versioncheck\README.txt - Description=Version checker tool - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\tools\pynche\*.py - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\*.txt - Destination=%MAINDIR%\Tools\pynche - Description=pynche color editor - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\x\*.txt - Destination=%MAINDIR%\Tools\pynche\X - Description=pynche color editor - X files - Flags=0000000000000010 -end -item: Install File - Source=..\tools\pynche\readme - Destination=%MAINDIR%\Tools\pynche\README.txt - Description=pynche color editor - README - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche - Destination=%MAINDIR%\Tools\pynche\pynche.py - Description=pynche color editor - main - Flags=0000000100000010 -end -item: Install File - Source=..\tools\pynche\pynche.pyw - Destination=%MAINDIR%\Tools\pynche\pynche.pyw - Description=pynche color editor - noconsole main - Flags=0000000100000010 -end -item: Remark -end -item: Install File - Source=..\tools\i18n\*.py - Destination=%MAINDIR%\Tools\i18n - Description=Internationalization helpers - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=E: test suite -end -item: If/While Statement - Variable=COMPONENTS - Value=E - Flags=00000010 -end -item: Install File - Source=..\lib\test\audiotest.au - Destination=%MAINDIR%\Lib\test\audiotest.au - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.uue - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.py - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.xml - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.out - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.bz2 - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.tar - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.gz - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Install File - Source=..\lib\test\*.txt - Destination=%MAINDIR%\Lib\test - Description=Python Test files - Flags=0000000000000010 -end -item: Remark -end -item: Install File - Source=..\lib\test\output\*.* - Destination=%MAINDIR%\Lib\test\output - Description=Python Test output files - Flags=0000000000000010 -end -item: End Block -end -item: Remark -end -item: Remark - Text=DONE with file copying. -end -item: Remark - Text=The rest is registry and Start Menu fiddling. -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: If/While Statement - Variable=TASKS - Value=A - Flags=00000010 -end -item: Remark - Text=Register file extensions. As usual, Admin privs get in the way, but with a twist: -end -item: Remark - Text=You don't need admin privs to write to HKEY_CLASSES_ROOT *except* under Win2K. -end -item: Remark - Text=On Win2K, a user without Admin privs has to register extensions under HKCU\Software\CLASSES instead. -end -item: Remark - Text=But while you can *do* that under other flavors of Windows too, it has no useful effect except in Win2K. -end -item: Set Variable - Variable=USE_HKCR - Value=1 -end -item: Check Configuration - Flags=11110010 -end -item: If/While Statement - Variable=DOADMIN - Value=0 -end -item: Set Variable - Variable=USE_HKCR - Value=0 -end -item: End Block -end -item: End Block -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Python.File - New Value=Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile - New Value=Python File (no console) -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile - New Value=Compiled Python File -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* -end -item: Edit Registry - Total Keys=1 - Key=Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=Python.File -end -item: Edit Registry - Total Keys=1 - Key=.py - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=Python.NoConFile -end -item: Edit Registry - Total Keys=1 - Key=.pyw - New Value=text/plain - Value Name=Content Type -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=.pyc - New Value=Python.CompiledFile -end -item: Edit Registry - Total Keys=1 - Key=.pyo - New Value=Python.CompiledFile -end -item: Else Statement -end -item: Remark - Text=File types. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File - New Value=Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile - New Value=Python File (no console) - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\open\command - New Value=%MAINDIR%\pythonw.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\DefaultIcon - New Value=%MAINDIR%\Py.ico - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile - New Value=Compiled Python File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\shell\open\command - New Value=%MAINDIR%\python.exe "%%1" %%* - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.CompiledFile\DefaultIcon - New Value=%MAINDIR%\pyc.ico - Root=1 -end -item: Remark -end -item: Remark - Text=File extensions. -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=Python.File - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.py - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=Python.NoConFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyw - New Value=text/plain - Value Name=Content Type - Root=1 -end -item: Remark -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyc - New Value=Python.CompiledFile - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\.pyo - New Value=Python.CompiledFile - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=If we're installing IDLE, also set an Edit context menu action to use IDLE, for .py and .pyw files. -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: If/While Statement - Variable=USE_HKCR - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Edit Registry - Total Keys=1 - Key=Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.NoConFile\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\CLASSES\Python.File\shell\Edit with IDLE\command - New Value=%MAINDIR%\pythonw.exe %MAINDIR%\Lib\idlelib\idle.pyw -n -e "%%1" - Root=1 -end -item: End Block -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Register Python paths. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=130 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs;%MAINDIR%\Lib\lib-tk - New Value= - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\CurrentVersion - Root=129 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath - New Value=%MAINDIR% - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\InstallPath\InstallGroup - New Value=%CGROUP_SAVE% - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\PythonPath - New Value=%MAINDIR%\Lib;%MAINDIR%\DLLs;%MAINDIR%\Lib\lib-tk - New Value= - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Modules - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\App Paths\Python.exe - New Value=%MAINDIR%\Python.exe - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Registry fiddling for docs. -end -item: Remark - Text=Write to HKLM for admin, else HKCU. Keep these blocks otherwise identical! -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\index.html - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Python\PythonCore\%PY_VERSION%\Help\Main Python Documentation - New Value=%MAINDIR%\Doc\index.html - Root=1 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=Set the app publisher and URL entries for Win2K add/remove. -end -item: Remark - Text=It doesn't hurt on other systems. -end -item: Remark - Text=As usual, write to HKLM or HKCU depending on Admin privs. -end -item: Remark - Text=CAUTION: If you set this info on the "Windows 2000" page (step 6) of the -end -item: Remark - Text=Installation Expert, it only shows up in the "If" block below. Keep in synch! -end -item: If/While Statement - Variable=DOADMIN - Value=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=2 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=2 -end -item: Else Statement -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=HelpLink - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=PythonLabs at Zope Corporation - Value Name=Publisher - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=http://www.python.org/ - Value Name=URLInfoAbout - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%PYVER_STRING% - Value Name=DisplayVersion - Root=1 -end -item: Edit Registry - Total Keys=1 - Key=Software\Microsoft\Windows\CurrentVersion\Uninstall\%APPTITLE% - New Value=%MAINDIR%\py.ico,-0 - Value Name=DisplayIcon - Root=1 -end -item: End Block -end -item: Remark -end -item: Remark - Text=Populate Start Menu group -end -item: If/While Statement - Variable=TASKS - Value=B - Flags=00000010 -end -item: Remark - Text=Shortcut to installer no matter what. -end -item: Create Shortcut - Source=%MAINDIR%\unwise.exe - Destination=%GROUP%\Uninstall Python.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=A - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\python.exe - Destination=%GROUP%\Python (command line).lnk - Working Directory=%MAINDIR% - Icon Pathname=%MAINDIR%\pycon.ico - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=B - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\IDLE (Python GUI).lnk - Command Options="%MAINDIR%\Lib\idlelib\idle.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: Create Shortcut - Source=%MAINDIR%\pythonw.exe - Destination=%GROUP%\Module Docs.lnk - Command Options="%MAINDIR%\Tools\Scripts\pydocgui.pyw" - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: Remark -end -item: If/While Statement - Variable=COMPONENTS - Value=C - Flags=00000010 -end -item: Create Shortcut - Source=%MAINDIR%\Doc\index.html - Destination=%GROUP%\Python Manuals.lnk - Working Directory=%MAINDIR% - Key Type=1536 - Flags=00000001 -end -item: End Block -end -item: End Block -end -item: Remark -end -item: Remark - Text=I don't think we need this, but have always done it. -end -item: Self-Register OCXs/DLLs - Description=Updating System Configuration, Please Wait... -end -item: Remark -end -remarked item: Remark - Text=Don't enable "Delete in-use files". Here's what happens: -end -remarked item: Remark - Text=Install Python; uninstall Python; install Python again. Reboot the machine. -end -remarked item: Remark - Text=Now UNWISE.EXE is missing. I think this is a Wise bug, but so it goes. -end -remarked item: Add Text to INSTALL.LOG - Text=Delete in-use files: On -end -item: Remark -end -item: Wizard Block - Direction Variable=DIRECTION - Display Variable=DISPLAY - Bitmap Pathname=.\installer.bmp - X Position=9 - Y Position=10 - Filler Color=11173759 - Flags=00000011 -end -item: Custom Dialog Set - Name=Finished - Display Variable=DISPLAY - item: Dialog - Title=%APPTITLE% Installation - Title French=Installation de %APPTITLE% - Title German=Installation von %APPTITLE% - Title Spanish=Instalaci?n de %APPTITLE% - Title Italian=Installazione di %APPTITLE% - Width=339 - Height=280 - Font Name=Helv - Font Size=8 - item: Push Button - Rectangle=188 234 244 253 - Variable=DIRECTION - Value=N - Create Flags=01010000000000010000000000000001 - Text=&Finish - Text French=&Fin - Text German=&Weiter - Text Spanish=&Terminar - Text Italian=&Fine - end - item: Push Button - Rectangle=264 234 320 253 - Variable=DISABLED - Value=! - Action=3 - Create Flags=01010000000000010000000000000000 - Text=&Cancel - Text French=&Annuler - Text German=&Abbrechen - Text Spanish=&Cancelar - Text Italian=&Annulla - end - item: Static - Rectangle=108 10 323 48 - Create Flags=01010000000000000000000000000000 - Flags=0000000000000001 - Name=Times New Roman - Font Style=-24 0 0 0 700 255 0 0 0 3 2 1 18 - Text=Installation Completed! - Text French=Installation termin?e ! - Text German=Die Installation ist abgeschlossen! - Text Spanish=?Instalaci?n terminada! - Text Italian=Installazione completata! - end - item: Static - Rectangle=108 44 320 82 - Create Flags=01010000000000000000000000000000 - Text=%APPTITLE% has been successfully installed. - Text= - Text=Press the Finish button to exit this installation. - Text French=%APPTITLE% est maintenant install?. - Text French= - Text French=Cliquez sur le bouton Fin pour quitter l'installation. - Text German=%APPTITLE% wurde erfolgreich installiert. - Text German= - Text German=Klicken Sie auf "Weiter", um die Installation zu beenden. - Text Spanish=%APPTITLE% se ha instalado con ?xito. - Text Spanish= - Text Spanish=Presione el bot?n Terminar para salir de esta instalaci?n. - Text Italian=L'installazione %APPTITLE% ? stata portata a termine con successo. - Text Italian= - Text Italian=Premere il pulsante Fine per uscire dall'installazione. - end - item: Static - Rectangle=10 225 320 226 - Action=3 - Create Flags=01010000000000000000000000000111 - end - item: Static - Rectangle=106 105 312 210 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000000000 - Text=Special Windows thanks to: - Text= - Text=Wise Solutions, for the use of InstallMaster 8.1. - Text= http://www.wisesolutions.com/ - Text= - Text= - Text=LettError, Erik van Blokland, for the Python for Windows graphic. - Text= http://www.letterror.com/ - Text= - Text= - Text=Mark Hammond, without whose years of freely shared Windows expertise, Python for Windows would still be Python for DOS. - end - item: Static - Rectangle=106 95 312 96 - Action=3 - Enabled Color=00000000000000001111111111111111 - Create Flags=01010000000000000000000000001001 - end - end -end -item: End Block -end -item: New Event - Name=Cancel -end -item: Remark - Text=This include script supports a rollback to preinstallation state if the user chooses to cancel before the installation is complete. -end -item: Include Script - Pathname=%_WISE_%\INCLUDE\rollback.wse -end Modified: python/branches/py3k/PCbuild9/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PCbuild9/pythoncore.vcproj (original) +++ python/branches/py3k/PCbuild9/pythoncore.vcproj Wed Dec 19 03:07:34 2007 @@ -879,6 +879,10 @@ > + + @@ -1715,6 +1719,10 @@ > + + Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Wed Dec 19 03:07:34 2007 @@ -1787,11 +1787,23 @@ break; case BUILD_MAP: - x = PyDict_New(); + x = _PyDict_NewPresized((Py_ssize_t)oparg); PUSH(x); if (x != NULL) continue; break; + case STORE_MAP: + w = TOP(); /* key */ + u = SECOND(); /* value */ + v = THIRD(); /* dict */ + STACKADJ(-2); + assert (PyDict_CheckExact(v)); + err = PyDict_SetItem(v, w, u); /* v[w] = u */ + Py_DECREF(u); + Py_DECREF(w); + if (err == 0) continue; + break; + case LOAD_ATTR: w = GETITEM(names, oparg); v = TOP(); Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Wed Dec 19 03:07:34 2007 @@ -714,6 +714,8 @@ return -1; case STORE_SUBSCR: return -3; + case STORE_MAP: + return -2; case DELETE_SUBSCR: return -2; @@ -3169,19 +3171,14 @@ case IfExp_kind: return compiler_ifexp(c, e); case Dict_kind: - /* XXX get rid of arg? */ - ADDOP_I(c, BUILD_MAP, 0); n = asdl_seq_LEN(e->v.Dict.values); - /* We must arrange things just right for STORE_SUBSCR. - It wants the stack to look like (value) (dict) (key) */ + ADDOP_I(c, BUILD_MAP, (n>255 ? 255 : n)); for (i = 0; i < n; i++) { - ADDOP(c, DUP_TOP); VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.values, i)); - ADDOP(c, ROT_TWO); VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.keys, i)); - ADDOP(c, STORE_SUBSCR); + ADDOP(c, STORE_MAP); } break; case Set_kind: Modified: python/branches/py3k/Python/import.c ============================================================================== --- python/branches/py3k/Python/import.c (original) +++ python/branches/py3k/Python/import.c Wed Dec 19 03:07:34 2007 @@ -66,7 +66,7 @@ Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) - Python 2.6a0: 62141 (peephole optimizations) + Python 2.6a0: 62151 (peephole optimizations and STORE_MAP opcode) Python 3000: 3000 3010 (removed UNARY_CONVERT) 3020 (added BUILD_SET) @@ -77,9 +77,10 @@ 3070 (PEP 3109 raise changes) 3080 (PEP 3137 make __file__ and __name__ unicode) 3090 (kill str8 interning) + 3100 (merge from 2.6a0, see 62151) . */ -#define MAGIC (3090 | ((long)'\r'<<16) | ((long)'\n'<<24)) +#define MAGIC (3100 | ((long)'\r'<<16) | ((long)'\n'<<24)) /* Magic word as global; note that _PyImport_Init() can change the value of this global to accommodate for alterations of how the Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Wed Dec 19 03:07:34 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 59484 . +# From configure.in Revision: 59533 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -20581,6 +20581,9 @@ fi +# ************************************ +# * Check for mathematical functions * +# ************************************ # check for hypot() in math library LIBS_SAVE=$LIBS LIBS="$LIBS $LIBM" @@ -20686,6 +20689,105 @@ done + + + + + +for ac_func in copysign isfinite isnan isinf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + LIBS=$LIBS_SAVE # check for wchar.h Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Wed Dec 19 03:07:34 2007 @@ -2944,10 +2944,16 @@ fi], [AC_MSG_RESULT(default LIBC="$LIBC")]) +# ************************************ +# * Check for mathematical functions * +# ************************************ # check for hypot() in math library LIBS_SAVE=$LIBS LIBS="$LIBS $LIBM" AC_REPLACE_FUNCS(hypot) + +AC_CHECK_FUNCS(copysign isfinite isnan isinf) + LIBS=$LIBS_SAVE # check for wchar.h Modified: python/branches/py3k/pyconfig.h.in ============================================================================== --- python/branches/py3k/pyconfig.h.in (original) +++ python/branches/py3k/pyconfig.h.in Wed Dec 19 03:07:34 2007 @@ -82,6 +82,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_CONIO_H +/* Define to 1 if you have the `copysign' function. */ +#undef HAVE_COPYSIGN + /* Define to 1 if you have the `ctermid' function. */ #undef HAVE_CTERMID @@ -285,6 +288,15 @@ /* Define to 1 if you have the header file. */ #undef HAVE_IO_H +/* Define to 1 if you have the `isfinite' function. */ +#undef HAVE_ISFINITE + +/* Define to 1 if you have the `isinf' function. */ +#undef HAVE_ISINF + +/* Define to 1 if you have the `isnan' function. */ +#undef HAVE_ISNAN + /* Define to 1 if you have the `kill' function. */ #undef HAVE_KILL @@ -1034,3 +1046,4 @@ #endif /*Py_PYCONFIG_H*/ + From python-3000-checkins at python.org Wed Dec 19 03:45:51 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Wed, 19 Dec 2007 03:45:51 +0100 (CET) Subject: [Python-3000-checkins] r59565 - in python/branches/py3k: Doc/whatsnew/2.6.rst Include/abstract.h Include/boolobject.h Include/bytesobject.h Include/cStringIO.h Include/cellobject.h Include/cobject.h Include/code.h Include/complexobject.h Include/datetime.h Include/descrobject.h Include/dictobject.h Include/floatobject.h Include/frameobject.h Include/funcobject.h Include/genobject.h Include/iterobject.h Include/listobject.h Include/longobject.h Include/memoryobject.h Include/methodobject.h Include/moduleobject.h Include/object.h Include/objimpl.h Include/py_curses.h Include/rangeobject.h Include/setobject.h Include/sliceobject.h Include/stringobject.h Include/symtable.h Include/traceback.h Include/tupleobject.h Include/unicodeobject.h Include/weakrefobject.h Mac/Modules/MacOS.c Mac/Modules/ae/_AEmodule.c Mac/Modules/app/_Appmodule.c Mac/Modules/carbonevt/_CarbonEvtmodule.c Mac/Modules/cf/_CFmodule.c Mac/Modules/cg/_CGmodule.c Mac/Modules/cm/_Cmmodule.c Mac/Modules/ctl/_Ctlmodule.c Mac/Modules/dlg/_Dlgmodule.c Mac/Modules/drag/_Dragmodule.c Mac/Modules/file/_Filemodule.c Mac/Modules/ibcarbon/_IBCarbon.c Mac/Modules/list/_Listmodule.c Mac/Modules/menu/_Menumodule.c Mac/Modules/mlte/_Mltemodule.c Mac/Modules/osa/_OSAmodule.c Mac/Modules/qd/_Qdmodule.c Mac/Modules/qdoffs/_Qdoffsmodule.c Mac/Modules/qt/_Qtmodule.c Mac/Modules/res/_Resmodule.c Mac/Modules/scrap/_Scrapmodule.c Mac/Modules/snd/_Sndmodule.c Mac/Modules/te/_TEmodule.c Mac/Modules/win/_Winmodule.c Modules/_bsddb.c Modules/_collectionsmodule.c Modules/_csv.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/stgdict.c Modules/_curses_panel.c Modules/_cursesmodule.c Modules/_elementtree.c Modules/_fileio.c Modules/_functoolsmodule.c Modules/_hashopenssl.c Modules/_lsprof.c Modules/_randommodule.c Modules/_sqlite/cache.c Modules/_sqlite/connection.c Modules/_sqlite/cursor.c Modules/_sqlite/prepare_protocol.c Modules/_sqlite/row.c Modules/_sqlite/statement.c Modules/_sre.c Modules/_ssl.c Modules/_struct.c Modules/_testcapimodule.c Modules/_tkinter.c Modules/_weakref.c Modules/arraymodule.c Modules/bz2module.c Modules/cStringIO.c Modules/cjkcodecs/multibytecodec.c Modules/datetimemodule.c Modules/dbmmodule.c Modules/dlmodule.c Modules/gcmodule.c Modules/gdbmmodule.c Modules/itertoolsmodule.c Modules/mathmodule.c Modules/md5module.c Modules/mmapmodule.c Modules/parsermodule.c Modules/posixmodule.c Modules/pyexpat.c Modules/selectmodule.c Modules/sha1module.c Modules/sha256module.c Modules/sha512module.c Modules/socketmodule.c Modules/threadmodule.c Modules/timemodule.c Modules/unicodedata.c Modules/xxmodule.c Modules/zipimport.c Modules/zlibmodule.c Objects/abstract.c Objects/bytesobject.c Objects/classobject.c Objects/dictobject.c Objects/enumobject.c Objects/exceptions.c Objects/floatobject.c Objects/frameobject.c Objects/funcobject.c Objects/genobject.c Objects/iterobject.c Objects/listobject.c Objects/longobject.c Objects/moduleobject.c Objects/object.c Objects/setobject.c Objects/sliceobject.c Objects/stringlib/string_format.h Objects/stringobject.c Objects/structseq.c Objects/tupleobject.c Objects/typeobject.c Objects/unicodeobject.c Objects/weakrefobject.c PC/_subprocess.c PC/_winreg.c Parser/tokenizer.c Python/ast.c Python/bltinmodule.c Python/ceval.c Python/codecs.c Python/marshal.c Message-ID: <20071219024551.6583C1E4007@bag.python.org> Author: christian.heimes Date: Wed Dec 19 03:45:37 2007 New Revision: 59565 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Include/abstract.h python/branches/py3k/Include/boolobject.h python/branches/py3k/Include/bytesobject.h python/branches/py3k/Include/cStringIO.h python/branches/py3k/Include/cellobject.h python/branches/py3k/Include/cobject.h python/branches/py3k/Include/code.h python/branches/py3k/Include/complexobject.h python/branches/py3k/Include/datetime.h python/branches/py3k/Include/descrobject.h python/branches/py3k/Include/dictobject.h python/branches/py3k/Include/floatobject.h python/branches/py3k/Include/frameobject.h python/branches/py3k/Include/funcobject.h python/branches/py3k/Include/genobject.h python/branches/py3k/Include/iterobject.h python/branches/py3k/Include/listobject.h python/branches/py3k/Include/longobject.h python/branches/py3k/Include/memoryobject.h python/branches/py3k/Include/methodobject.h python/branches/py3k/Include/moduleobject.h python/branches/py3k/Include/object.h python/branches/py3k/Include/objimpl.h python/branches/py3k/Include/py_curses.h python/branches/py3k/Include/rangeobject.h python/branches/py3k/Include/setobject.h python/branches/py3k/Include/sliceobject.h python/branches/py3k/Include/stringobject.h python/branches/py3k/Include/symtable.h python/branches/py3k/Include/traceback.h python/branches/py3k/Include/tupleobject.h python/branches/py3k/Include/unicodeobject.h python/branches/py3k/Include/weakrefobject.h python/branches/py3k/Mac/Modules/MacOS.c python/branches/py3k/Mac/Modules/ae/_AEmodule.c python/branches/py3k/Mac/Modules/app/_Appmodule.c python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c python/branches/py3k/Mac/Modules/cf/_CFmodule.c python/branches/py3k/Mac/Modules/cg/_CGmodule.c python/branches/py3k/Mac/Modules/cm/_Cmmodule.c python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c python/branches/py3k/Mac/Modules/drag/_Dragmodule.c python/branches/py3k/Mac/Modules/file/_Filemodule.c python/branches/py3k/Mac/Modules/ibcarbon/_IBCarbon.c python/branches/py3k/Mac/Modules/list/_Listmodule.c python/branches/py3k/Mac/Modules/menu/_Menumodule.c python/branches/py3k/Mac/Modules/mlte/_Mltemodule.c python/branches/py3k/Mac/Modules/osa/_OSAmodule.c python/branches/py3k/Mac/Modules/qd/_Qdmodule.c python/branches/py3k/Mac/Modules/qdoffs/_Qdoffsmodule.c python/branches/py3k/Mac/Modules/qt/_Qtmodule.c python/branches/py3k/Mac/Modules/res/_Resmodule.c python/branches/py3k/Mac/Modules/scrap/_Scrapmodule.c python/branches/py3k/Mac/Modules/snd/_Sndmodule.c python/branches/py3k/Mac/Modules/te/_TEmodule.c python/branches/py3k/Mac/Modules/win/_Winmodule.c python/branches/py3k/Modules/_bsddb.c python/branches/py3k/Modules/_collectionsmodule.c python/branches/py3k/Modules/_csv.c python/branches/py3k/Modules/_ctypes/_ctypes.c python/branches/py3k/Modules/_ctypes/callproc.c python/branches/py3k/Modules/_ctypes/cfield.c python/branches/py3k/Modules/_ctypes/stgdict.c python/branches/py3k/Modules/_curses_panel.c python/branches/py3k/Modules/_cursesmodule.c python/branches/py3k/Modules/_elementtree.c python/branches/py3k/Modules/_fileio.c python/branches/py3k/Modules/_functoolsmodule.c python/branches/py3k/Modules/_hashopenssl.c python/branches/py3k/Modules/_lsprof.c python/branches/py3k/Modules/_randommodule.c python/branches/py3k/Modules/_sqlite/cache.c python/branches/py3k/Modules/_sqlite/connection.c python/branches/py3k/Modules/_sqlite/cursor.c python/branches/py3k/Modules/_sqlite/prepare_protocol.c python/branches/py3k/Modules/_sqlite/row.c python/branches/py3k/Modules/_sqlite/statement.c python/branches/py3k/Modules/_sre.c python/branches/py3k/Modules/_ssl.c python/branches/py3k/Modules/_struct.c python/branches/py3k/Modules/_testcapimodule.c python/branches/py3k/Modules/_tkinter.c python/branches/py3k/Modules/_weakref.c python/branches/py3k/Modules/arraymodule.c python/branches/py3k/Modules/bz2module.c python/branches/py3k/Modules/cStringIO.c python/branches/py3k/Modules/cjkcodecs/multibytecodec.c python/branches/py3k/Modules/datetimemodule.c python/branches/py3k/Modules/dbmmodule.c python/branches/py3k/Modules/dlmodule.c python/branches/py3k/Modules/gcmodule.c python/branches/py3k/Modules/gdbmmodule.c python/branches/py3k/Modules/itertoolsmodule.c python/branches/py3k/Modules/mathmodule.c python/branches/py3k/Modules/md5module.c python/branches/py3k/Modules/mmapmodule.c python/branches/py3k/Modules/parsermodule.c python/branches/py3k/Modules/posixmodule.c python/branches/py3k/Modules/pyexpat.c python/branches/py3k/Modules/selectmodule.c python/branches/py3k/Modules/sha1module.c python/branches/py3k/Modules/sha256module.c python/branches/py3k/Modules/sha512module.c python/branches/py3k/Modules/socketmodule.c python/branches/py3k/Modules/threadmodule.c python/branches/py3k/Modules/timemodule.c python/branches/py3k/Modules/unicodedata.c python/branches/py3k/Modules/xxmodule.c python/branches/py3k/Modules/zipimport.c python/branches/py3k/Modules/zlibmodule.c python/branches/py3k/Objects/abstract.c python/branches/py3k/Objects/bytesobject.c python/branches/py3k/Objects/classobject.c python/branches/py3k/Objects/dictobject.c python/branches/py3k/Objects/enumobject.c python/branches/py3k/Objects/exceptions.c python/branches/py3k/Objects/floatobject.c python/branches/py3k/Objects/frameobject.c python/branches/py3k/Objects/funcobject.c python/branches/py3k/Objects/genobject.c python/branches/py3k/Objects/iterobject.c python/branches/py3k/Objects/listobject.c python/branches/py3k/Objects/longobject.c python/branches/py3k/Objects/moduleobject.c python/branches/py3k/Objects/object.c python/branches/py3k/Objects/setobject.c python/branches/py3k/Objects/sliceobject.c python/branches/py3k/Objects/stringlib/string_format.h python/branches/py3k/Objects/stringobject.c python/branches/py3k/Objects/structseq.c python/branches/py3k/Objects/tupleobject.c python/branches/py3k/Objects/typeobject.c python/branches/py3k/Objects/unicodeobject.c python/branches/py3k/Objects/weakrefobject.c python/branches/py3k/PC/_subprocess.c python/branches/py3k/PC/_winreg.c python/branches/py3k/Parser/tokenizer.c python/branches/py3k/Python/ast.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/ceval.c python/branches/py3k/Python/codecs.c python/branches/py3k/Python/marshal.c Log: #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT. Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Wed Dec 19 03:45:37 2007 @@ -72,8 +72,6 @@ Python 3.0 ================ -.. % XXX add general comment about Python 3.0 features in 2.6 - The development cycle for Python 2.6 also saw the release of the first alphas of Python 3.0, and the development of 3.0 has influenced a number of features in 2.6. @@ -95,7 +93,9 @@ A new command-line switch, :option:`-3`, enables warnings about features that will be removed in Python 3.0. You can run code with this switch to see how much work will be necessary to port -code to 3.0. +code to 3.0. The value of this switch is available +to Python code as the boolean variable ``sys.py3kwarning``, +and to C extension code as :cdata:`Py_Py3kWarningFlag`. .. seealso:: @@ -103,6 +103,62 @@ Python 3.0 and various features that have been accepted, rejected, or are still under consideration. + +Development Changes +================================================== + +While 2.6 was being developed, the Python development process +underwent two significant changes: the developer group +switched from SourceForge's issue tracker to a customized +Roundup installation, and the documentation was converted from +LaTeX to reStructured Text. + + +New Issue Tracker: Roundup +-------------------------------------------------- + +XXX write this. + + +New Documentation Format: ReStructured Text +-------------------------------------------------- + +Python's documentation had been written using LaTeX since the +project's inception around 1989. At that time, most documentation was +printed out for later study, not viewed online. LaTeX was widely used +because it provided attractive printed output while +remaining straightforward to write, once the basic rules +of the markup have been learned. + +LaTeX is still used today for writing technical publications destined +for printing, but the landscape for programming tools has shifted. We +no longer print out reams of documentation; instead, we browse through +it online and HTML is the most important format to support. +Unfortunately, converting LaTeX to HTML is fairly complicated, and +Fred L. Drake Jr., the Python documentation editor for many years, +spent a lot of time wrestling the conversion process into shape. +Occasionally people would suggest converting the documentation into +SGML or, later, XML, but performing a good conversion is a major task +and no one pursued the task to completion. + +During the 2.6 development cycle, Georg Brandl put a substantial +effort into building a new toolchain called Sphinx +for processing the documentation. +The input format is reStructured Text, +a markup commonly used in the Python community that supports +custom extensions and directives. Sphinx concentrates +on its HTML output, producing attractively styled +and modern HTML. (XXX finish this -- mention new search feature) + +.. seealso:: + + `Docutils `__: The fundamental + reStructured Text parser and toolset. + + `Documenting Python `__: Describes how to write for + Python's documentation. + + PEP 343: The 'with' statement ============================= @@ -352,6 +408,24 @@ .. % ====================================================================== +.. _pep-0366: + +PEP 366: Explicit Relative Imports From a Main Module +============================================================ + +Python's :option:`-m` switch allows running a module as a script. +When you ran a module that was located inside a package, relative +imports didn't work correctly. + +The fix in Python 2.6 adds a :attr:`__package__` attribute to modules. +When present, relative imports will be relative to the value of this +attribute instead of the :attr:`__name__` attribute. PEP 302-style +importers can then set :attr:`__package__`. The :mod:`runpy` module +that implements the :option:`-m` switch now does this, so relative imports +can now be used in scripts running from inside a package. + +.. % ====================================================================== + .. _pep-3110: PEP 3110: Exception-Handling Changes @@ -414,7 +488,7 @@ :pep:`3119` - Introducing Abstract Base Classes PEP written by Guido van Rossum and Talin. Implemented by XXX. - Backported to 2.6 by Benjamin Aranguren (with Alex Martelli). + Backported to 2.6 by Benjamin Aranguren, with Alex Martelli. Other Language Changes ====================== @@ -443,6 +517,25 @@ .. % Revision 57619 +* Properties now have two attributes, + :attr:`setter` and :attr:`deleter`, that are useful shortcuts for + adding a setter or deleter function to an existing property. + You would use them like this:: + + class C(object): + @property + def x(self): + return self._x + + @x.setter + def x(self, value): + self._x = value + + @x.deleter + def x(self): + del self._x + + * C functions and methods that use :cfunc:`PyComplex_AsCComplex` will now accept arguments that have a :meth:`__complex__` method. In particular, the functions in the @@ -452,11 +545,26 @@ .. % Patch #1675423 + A numerical nicety: when creating a complex number from two floats + on systems that support signed zeros (-0 and +0), the + :func:`complex()` constructor will now preserve the sign + of the zero. + + .. % Patch 1507 + * Changes to the :class:`Exception` interface as dictated by :pep:`352` continue to be made. For 2.6, the :attr:`message` attribute is being deprecated in favor of the :attr:`args` attribute. +* The :exc:`GeneratorExit` exception now subclasses + :exc:`BaseException` instead of :exc:`Exception`. This means + that an exception handler that does ``except Exception:`` + will not inadvertently catch :exc:`GeneratorExit`. + (Contributed by Chad Austin.) + + .. % Patch #1537 + * The :func:`compile` built-in function now accepts keyword arguments as well as positional parameters. (Contributed by Thomas Wouters.) @@ -653,6 +761,20 @@ .. % Patch #1490190 +* The :mod:`new` module has been removed from Python 3.0. + Importing it therefore + triggers a warning message when Python is running in 3.0-warning + mode. + +* New functions in the :mod:`os` module include + ``fchmod(fd, mode)``, ``fchown(fd, uid, gid)``, + and ``lchmod(path, mode)``, on operating systems that support these + functions. :func:`fchmod` and :func:`fchown` let you change the mode + and ownership of an opened file, and :func:`lchmod` changes the mode + of a symlink. + + (Contributed by Georg Brandl and Christian Heimes.) + * The :func:`os.walk` function now has a ``followlinks`` parameter. If set to True, it will follow symlinks pointing to directories and visit the directory's contents. For backward compatibility, the @@ -703,6 +825,15 @@ changed and :const:`UF_APPEND` to indicate that data can only be appended to the file. (Contributed by M. Levinson.) +* The :mod:`random` module's :class:`Random` objects can + now be pickled on a 32-bit system and unpickled on a 64-bit + system, and vice versa. Unfortunately, this change also means + that Python 2.6's :class:`Random` objects can't be unpickled correctly + on earlier versions of Python. + (Contributed by Shawn Ligocki.) + + .. % Issue 1727780 + * The :mod:`rgbimg` module has been removed. * The :mod:`sets` module has been deprecated; it's better to @@ -725,6 +856,17 @@ .. % Patch #957003 +* A new variable in the :mod:`sys` module, + :attr:`float_info`, is a dictionary + containing information about the platform's floating-point support + derived from the :file:`float.h` file. Key/value pairs + in this dictionary include + ``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"`` + (smallest difference between 1.0 and the next largest value + representable), and several others. (Contributed by Christian Heimes.) + + .. % Patch 1534 + * The :mod:`tarfile` module now supports POSIX.1-2001 (pax) and POSIX.1-1988 (ustar) format tarfiles, in addition to the GNU tar format that was already supported. The default format @@ -883,6 +1025,17 @@ .. % Patch 1551895 +* Several functions return information about the platform's + floating-point support. :cfunc:`PyFloat_GetMax` returns + the maximum representable floating point value, + and :cfunc:`PyFloat_GetMin` returns the minimum + positive value. :cfunc:`PyFloat_GetInfo` returns a dictionary + containing more information from the :file:`float.h` file, such as + ``"mant_dig"`` (number of digits in the mantissa), ``"epsilon"`` + (smallest difference between 1.0 and the next largest value + representable), and several others. + + .. % Issue 1534 .. % ====================================================================== Modified: python/branches/py3k/Include/abstract.h ============================================================================== --- python/branches/py3k/Include/abstract.h (original) +++ python/branches/py3k/Include/abstract.h Wed Dec 19 03:45:37 2007 @@ -1070,7 +1070,7 @@ */ #define PySequence_ITEM(o, i)\ - ( Py_Type(o)->tp_as_sequence->sq_item(o, i) ) + ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) /* Assume tp_as_sequence and sq_item exist and that i does not need to be corrected for a negative index */ Modified: python/branches/py3k/Include/boolobject.h ============================================================================== --- python/branches/py3k/Include/boolobject.h (original) +++ python/branches/py3k/Include/boolobject.h Wed Dec 19 03:45:37 2007 @@ -9,7 +9,7 @@ PyAPI_DATA(PyTypeObject) PyBool_Type; -#define PyBool_Check(x) (Py_Type(x) == &PyBool_Type) +#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) /* Py_False and Py_True are the only two bools in existence. Don't forget to apply Py_INCREF() when returning either!!! */ Modified: python/branches/py3k/Include/bytesobject.h ============================================================================== --- python/branches/py3k/Include/bytesobject.h (original) +++ python/branches/py3k/Include/bytesobject.h Wed Dec 19 03:45:37 2007 @@ -33,7 +33,7 @@ /* Type check macros */ #define PyBytes_Check(self) PyObject_TypeCheck(self, &PyBytes_Type) -#define PyBytes_CheckExact(self) (Py_Type(self) == &PyBytes_Type) +#define PyBytes_CheckExact(self) (Py_TYPE(self) == &PyBytes_Type) /* Direct API functions */ PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *); @@ -45,7 +45,7 @@ /* Macros, trading safety for speed */ #define PyBytes_AS_STRING(self) (assert(PyBytes_Check(self)),((PyBytesObject *)(self))->ob_bytes) -#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_Size(self)) +#define PyBytes_GET_SIZE(self) (assert(PyBytes_Check(self)),Py_SIZE(self)) #ifdef __cplusplus } Modified: python/branches/py3k/Include/cStringIO.h ============================================================================== --- python/branches/py3k/Include/cStringIO.h (original) +++ python/branches/py3k/Include/cStringIO.h Wed Dec 19 03:45:37 2007 @@ -60,9 +60,9 @@ /* These can be used to test if you have one */ #define PycStringIO_InputCheck(O) \ - (Py_Type(O)==PycStringIO->InputType) + (Py_TYPE(O)==PycStringIO->InputType) #define PycStringIO_OutputCheck(O) \ - (Py_Type(O)==PycStringIO->OutputType) + (Py_TYPE(O)==PycStringIO->OutputType) #ifdef __cplusplus } Modified: python/branches/py3k/Include/cellobject.h ============================================================================== --- python/branches/py3k/Include/cellobject.h (original) +++ python/branches/py3k/Include/cellobject.h Wed Dec 19 03:45:37 2007 @@ -13,7 +13,7 @@ PyAPI_DATA(PyTypeObject) PyCell_Type; -#define PyCell_Check(op) (Py_Type(op) == &PyCell_Type) +#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); Modified: python/branches/py3k/Include/cobject.h ============================================================================== --- python/branches/py3k/Include/cobject.h (original) +++ python/branches/py3k/Include/cobject.h Wed Dec 19 03:45:37 2007 @@ -16,7 +16,7 @@ PyAPI_DATA(PyTypeObject) PyCObject_Type; -#define PyCObject_Check(op) (Py_Type(op) == &PyCObject_Type) +#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) /* Create a PyCObject from a pointer to a C object and an optional destructor function. If the second argument is non-null, then it Modified: python/branches/py3k/Include/code.h ============================================================================== --- python/branches/py3k/Include/code.h (original) +++ python/branches/py3k/Include/code.h Wed Dec 19 03:45:37 2007 @@ -59,7 +59,7 @@ PyAPI_DATA(PyTypeObject) PyCode_Type; -#define PyCode_Check(op) (Py_Type(op) == &PyCode_Type) +#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) #define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) /* Public interface */ @@ -72,7 +72,7 @@ /* for internal use only */ #define _PyCode_GETCODEPTR(co, pp) \ - ((*Py_Type((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ + ((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ ((co)->co_code, 0, (void **)(pp))) typedef struct _addr_pair { Modified: python/branches/py3k/Include/complexobject.h ============================================================================== --- python/branches/py3k/Include/complexobject.h (original) +++ python/branches/py3k/Include/complexobject.h Wed Dec 19 03:45:37 2007 @@ -43,7 +43,7 @@ PyAPI_DATA(PyTypeObject) PyComplex_Type; #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) -#define PyComplex_CheckExact(op) (Py_Type(op) == &PyComplex_Type) +#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); Modified: python/branches/py3k/Include/datetime.h ============================================================================== --- python/branches/py3k/Include/datetime.h (original) +++ python/branches/py3k/Include/datetime.h Wed Dec 19 03:45:37 2007 @@ -166,19 +166,19 @@ /* Macros for type checking when building the Python core. */ #define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) -#define PyDate_CheckExact(op) (Py_Type(op) == &PyDateTime_DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) #define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) -#define PyDateTime_CheckExact(op) (Py_Type(op) == &PyDateTime_DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType) #define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) -#define PyTime_CheckExact(op) (Py_Type(op) == &PyDateTime_TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType) #define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) -#define PyDelta_CheckExact(op) (Py_Type(op) == &PyDateTime_DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType) #define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) -#define PyTZInfo_CheckExact(op) (Py_Type(op) == &PyDateTime_TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType) #else @@ -198,19 +198,19 @@ /* Macros for type checking when not building the Python core. */ #define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) -#define PyDate_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType) #define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType) -#define PyDateTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType) #define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType) -#define PyTime_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType) #define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType) -#define PyDelta_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType) #define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType) -#define PyTZInfo_CheckExact(op) (Py_Type(op) == PyDateTimeAPI->TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType) /* Macros for accessing constructors in a simplified fashion. */ #define PyDate_FromDate(year, month, day) \ Modified: python/branches/py3k/Include/descrobject.h ============================================================================== --- python/branches/py3k/Include/descrobject.h (original) +++ python/branches/py3k/Include/descrobject.h Wed Dec 19 03:45:37 2007 @@ -82,7 +82,7 @@ struct PyGetSetDef *); PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, struct wrapperbase *, void *); -#define PyDescr_IsData(d) (Py_Type(d)->tp_descr_set != NULL) +#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); Modified: python/branches/py3k/Include/dictobject.h ============================================================================== --- python/branches/py3k/Include/dictobject.h (original) +++ python/branches/py3k/Include/dictobject.h Wed Dec 19 03:45:37 2007 @@ -97,11 +97,11 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type; #define PyDict_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_DICT_SUBCLASS) -#define PyDict_CheckExact(op) (Py_Type(op) == &PyDict_Type) -#define PyDictKeys_Check(op) (Py_Type(op) == &PyDictKeys_Type) -#define PyDictItems_Check(op) (Py_Type(op) == &PyDictItems_Type) -#define PyDictValues_Check(op) (Py_Type(op) == &PyDictValues_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) +#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) +#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type) +#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type) +#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) /* This excludes Values, since they are not sets. */ # define PyDictViewSet_Check(op) \ (PyDictKeys_Check(op) || PyDictItems_Check(op)) Modified: python/branches/py3k/Include/floatobject.h ============================================================================== --- python/branches/py3k/Include/floatobject.h (original) +++ python/branches/py3k/Include/floatobject.h Wed Dec 19 03:45:37 2007 @@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type; #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) -#define PyFloat_CheckExact(op) (Py_Type(op) == &PyFloat_Type) +#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type) PyAPI_FUNC(double) PyFloat_GetMax(void); PyAPI_FUNC(double) PyFloat_GetMin(void); Modified: python/branches/py3k/Include/frameobject.h ============================================================================== --- python/branches/py3k/Include/frameobject.h (original) +++ python/branches/py3k/Include/frameobject.h Wed Dec 19 03:45:37 2007 @@ -51,7 +51,7 @@ PyAPI_DATA(PyTypeObject) PyFrame_Type; -#define PyFrame_Check(op) (Py_Type(op) == &PyFrame_Type) +#define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type) PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, PyObject *, PyObject *); Modified: python/branches/py3k/Include/funcobject.h ============================================================================== --- python/branches/py3k/Include/funcobject.h (original) +++ python/branches/py3k/Include/funcobject.h Wed Dec 19 03:45:37 2007 @@ -41,7 +41,7 @@ PyAPI_DATA(PyTypeObject) PyFunction_Type; -#define PyFunction_Check(op) (Py_Type(op) == &PyFunction_Type) +#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); Modified: python/branches/py3k/Include/genobject.h ============================================================================== --- python/branches/py3k/Include/genobject.h (original) +++ python/branches/py3k/Include/genobject.h Wed Dec 19 03:45:37 2007 @@ -26,7 +26,7 @@ PyAPI_DATA(PyTypeObject) PyGen_Type; #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) -#define PyGen_CheckExact(op) (Py_Type(op) == &PyGen_Type) +#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); Modified: python/branches/py3k/Include/iterobject.h ============================================================================== --- python/branches/py3k/Include/iterobject.h (original) +++ python/branches/py3k/Include/iterobject.h Wed Dec 19 03:45:37 2007 @@ -10,12 +10,12 @@ PyAPI_DATA(PyTypeObject) PyZipIter_Type; PyAPI_DATA(PyTypeObject) PyCmpWrapper_Type; -#define PySeqIter_Check(op) (Py_Type(op) == &PySeqIter_Type) +#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type) PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); -#define PyCallIter_Check(op) (Py_Type(op) == &PyCallIter_Type) +#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type) PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); Modified: python/branches/py3k/Include/listobject.h ============================================================================== --- python/branches/py3k/Include/listobject.h (original) +++ python/branches/py3k/Include/listobject.h Wed Dec 19 03:45:37 2007 @@ -44,8 +44,8 @@ PyAPI_DATA(PyTypeObject) PySortWrapper_Type; #define PyList_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LIST_SUBCLASS) -#define PyList_CheckExact(op) (Py_Type(op) == &PyList_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) +#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type) PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); @@ -63,7 +63,7 @@ /* Macro, trading safety for speed */ #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) -#define PyList_GET_SIZE(op) Py_Size(op) +#define PyList_GET_SIZE(op) Py_SIZE(op) #ifdef __cplusplus } Modified: python/branches/py3k/Include/longobject.h ============================================================================== --- python/branches/py3k/Include/longobject.h (original) +++ python/branches/py3k/Include/longobject.h Wed Dec 19 03:45:37 2007 @@ -12,8 +12,8 @@ PyAPI_DATA(PyTypeObject) PyLong_Type; #define PyLong_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_LONG_SUBCLASS) -#define PyLong_CheckExact(op) (Py_Type(op) == &PyLong_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) +#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type) PyAPI_FUNC(PyObject *) PyLong_FromLong(long); PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); Modified: python/branches/py3k/Include/memoryobject.h ============================================================================== --- python/branches/py3k/Include/memoryobject.h (original) +++ python/branches/py3k/Include/memoryobject.h Wed Dec 19 03:45:37 2007 @@ -16,7 +16,7 @@ PyAPI_DATA(PyTypeObject) PyMemoryView_Type; -#define PyMemory_Check(op) (Py_Type(op) == &PyMemoryView_Type) +#define PyMemory_Check(op) (Py_TYPE(op) == &PyMemoryView_Type) #define PyMemoryView(op) (((PyMemoryViewObject *)(op))->view) #define Py_END_OF_MEMORY (-1) Modified: python/branches/py3k/Include/methodobject.h ============================================================================== --- python/branches/py3k/Include/methodobject.h (original) +++ python/branches/py3k/Include/methodobject.h Wed Dec 19 03:45:37 2007 @@ -13,7 +13,7 @@ PyAPI_DATA(PyTypeObject) PyCFunction_Type; -#define PyCFunction_Check(op) (Py_Type(op) == &PyCFunction_Type) +#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, Modified: python/branches/py3k/Include/moduleobject.h ============================================================================== --- python/branches/py3k/Include/moduleobject.h (original) +++ python/branches/py3k/Include/moduleobject.h Wed Dec 19 03:45:37 2007 @@ -10,7 +10,7 @@ PyAPI_DATA(PyTypeObject) PyModule_Type; #define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) -#define PyModule_CheckExact(op) (Py_Type(op) == &PyModule_Type) +#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) PyAPI_FUNC(PyObject *) PyModule_New(const char *); PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); Modified: python/branches/py3k/Include/object.h ============================================================================== --- python/branches/py3k/Include/object.h (original) +++ python/branches/py3k/Include/object.h Wed Dec 19 03:45:37 2007 @@ -109,9 +109,9 @@ Py_ssize_t ob_size; /* Number of items in variable part */ } PyVarObject; -#define Py_Refcnt(ob) (((PyObject*)(ob))->ob_refcnt) -#define Py_Type(ob) (((PyObject*)(ob))->ob_type) -#define Py_Size(ob) (((PyVarObject*)(ob))->ob_size) +#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) +#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) /* Type objects contain a string containing the type name (to help somewhat @@ -404,21 +404,21 @@ /* access macro to the members which are floating "behind" the object */ #define PyHeapType_GET_MEMBERS(etype) \ - ((PyMemberDef *)(((char *)etype) + Py_Type(etype)->tp_basicsize)) + ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) /* Generic type check */ PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); #define PyObject_TypeCheck(ob, tp) \ - (Py_Type(ob) == (tp) || PyType_IsSubtype(Py_Type(ob), (tp))) + (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ #define PyType_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TYPE_SUBCLASS) -#define PyType_CheckExact(op) (Py_Type(op) == &PyType_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS) +#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type) PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); @@ -612,9 +612,9 @@ #ifdef COUNT_ALLOCS PyAPI_FUNC(void) inc_count(PyTypeObject *); PyAPI_FUNC(void) dec_count(PyTypeObject *); -#define _Py_INC_TPALLOCS(OP) inc_count(Py_Type(OP)) -#define _Py_INC_TPFREES(OP) dec_count(Py_Type(OP)) -#define _Py_DEC_TPFREES(OP) Py_Type(OP)->tp_frees-- +#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP)) +#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP)) +#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees-- #define _Py_COUNT_ALLOCS_COMMA , #else #define _Py_INC_TPALLOCS(OP) @@ -639,13 +639,13 @@ #define _Py_NewReference(op) ( \ _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ - Py_Refcnt(op) = 1) + Py_REFCNT(op) = 1) #define _Py_ForgetReference(op) _Py_INC_TPFREES(op) #define _Py_Dealloc(op) ( \ _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \ - (*Py_Type(op)->tp_dealloc)((PyObject *)(op))) + (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op))) #endif /* !Py_TRACE_REFS */ #define Py_INCREF(op) ( \ Modified: python/branches/py3k/Include/objimpl.h ============================================================================== --- python/branches/py3k/Include/objimpl.h (original) +++ python/branches/py3k/Include/objimpl.h Wed Dec 19 03:45:37 2007 @@ -151,9 +151,9 @@ /* Macros trading binary compatibility for speed. See also pymem.h. Note that these macros expect non-NULL object pointers.*/ #define PyObject_INIT(op, typeobj) \ - ( Py_Type(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) + ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) #define PyObject_INIT_VAR(op, typeobj, size) \ - ( Py_Size(op) = (size), PyObject_INIT((op), (typeobj)) ) + ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) ) #define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) @@ -228,8 +228,8 @@ #define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) /* Test if an object has a GC head */ -#define PyObject_IS_GC(o) (PyType_IS_GC(Py_Type(o)) && \ - (Py_Type(o)->tp_is_gc == NULL || Py_Type(o)->tp_is_gc(o))) +#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ + (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t); #define PyObject_GC_Resize(type, op, n) \ @@ -323,7 +323,7 @@ #define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) #define PyObject_GET_WEAKREFS_LISTPTR(o) \ - ((PyObject **) (((char *) (o)) + Py_Type(o)->tp_weaklistoffset)) + ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) #ifdef __cplusplus } Modified: python/branches/py3k/Include/py_curses.h ============================================================================== --- python/branches/py3k/Include/py_curses.h (original) +++ python/branches/py3k/Include/py_curses.h Wed Dec 19 03:45:37 2007 @@ -73,7 +73,7 @@ WINDOW *win; } PyCursesWindowObject; -#define PyCursesWindow_Check(v) (Py_Type(v) == &PyCursesWindow_Type) +#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) #ifdef CURSES_MODULE /* This section is used when compiling _cursesmodule.c */ Modified: python/branches/py3k/Include/rangeobject.h ============================================================================== --- python/branches/py3k/Include/rangeobject.h (original) +++ python/branches/py3k/Include/rangeobject.h Wed Dec 19 03:45:37 2007 @@ -19,7 +19,7 @@ PyAPI_DATA(PyTypeObject) PyRangeIter_Type; PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type; -#define PyRange_Check(op) (Py_Type(op) == &PyRange_Type) +#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type) #ifdef __cplusplus } Modified: python/branches/py3k/Include/setobject.h ============================================================================== --- python/branches/py3k/Include/setobject.h (original) +++ python/branches/py3k/Include/setobject.h Wed Dec 19 03:45:37 2007 @@ -67,13 +67,13 @@ * hash is -1 */ -#define PyFrozenSet_CheckExact(ob) (Py_Type(ob) == &PyFrozenSet_Type) +#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) #define PyAnySet_CheckExact(ob) \ - (Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type) + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) #define PyAnySet_Check(ob) \ - (Py_Type(ob) == &PySet_Type || Py_Type(ob) == &PyFrozenSet_Type || \ - PyType_IsSubtype(Py_Type(ob), &PySet_Type) || \ - PyType_IsSubtype(Py_Type(ob), &PyFrozenSet_Type)) + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) PyAPI_FUNC(PyObject *) PySet_New(PyObject *); PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); Modified: python/branches/py3k/Include/sliceobject.h ============================================================================== --- python/branches/py3k/Include/sliceobject.h (original) +++ python/branches/py3k/Include/sliceobject.h Wed Dec 19 03:45:37 2007 @@ -26,7 +26,7 @@ PyAPI_DATA(PyTypeObject) PySlice_Type; -#define PySlice_Check(op) (Py_Type(op) == &PySlice_Type) +#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type) PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, PyObject* step); Modified: python/branches/py3k/Include/stringobject.h ============================================================================== --- python/branches/py3k/Include/stringobject.h (original) +++ python/branches/py3k/Include/stringobject.h Wed Dec 19 03:45:37 2007 @@ -43,8 +43,8 @@ PyAPI_DATA(PyTypeObject) PyStringIter_Type; #define PyString_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_STRING_SUBCLASS) -#define PyString_CheckExact(op) (Py_Type(op) == &PyString_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS) +#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type) PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t); PyAPI_FUNC(PyObject *) PyString_FromString(const char *); @@ -68,7 +68,7 @@ /* Macro, trading safety for speed */ #define PyString_AS_STRING(op) (assert(PyString_Check(op)), \ (((PyStringObject *)(op))->ob_sval)) -#define PyString_GET_SIZE(op) (assert(PyString_Check(op)),Py_Size(op)) +#define PyString_GET_SIZE(op) (assert(PyString_Check(op)),Py_SIZE(op)) /* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, x must be an iterable object. */ Modified: python/branches/py3k/Include/symtable.h ============================================================================== --- python/branches/py3k/Include/symtable.h (original) +++ python/branches/py3k/Include/symtable.h Wed Dec 19 03:45:37 2007 @@ -53,7 +53,7 @@ PyAPI_DATA(PyTypeObject) PySTEntry_Type; -#define PySTEntry_Check(op) (Py_Type(op) == &PySTEntry_Type) +#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); Modified: python/branches/py3k/Include/traceback.h ============================================================================== --- python/branches/py3k/Include/traceback.h (original) +++ python/branches/py3k/Include/traceback.h Wed Dec 19 03:45:37 2007 @@ -22,7 +22,7 @@ /* Reveal traceback type so we can typecheck traceback objects */ PyAPI_DATA(PyTypeObject) PyTraceBack_Type; -#define PyTraceBack_Check(v) (Py_Type(v) == &PyTraceBack_Type) +#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type) #ifdef __cplusplus } Modified: python/branches/py3k/Include/tupleobject.h ============================================================================== --- python/branches/py3k/Include/tupleobject.h (original) +++ python/branches/py3k/Include/tupleobject.h Wed Dec 19 03:45:37 2007 @@ -35,8 +35,8 @@ PyAPI_DATA(PyTypeObject) PyTupleIter_Type; #define PyTuple_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_TUPLE_SUBCLASS) -#define PyTuple_CheckExact(op) (Py_Type(op) == &PyTuple_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) +#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); @@ -48,7 +48,7 @@ /* Macro, trading safety for speed */ #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) -#define PyTuple_GET_SIZE(op) Py_Size(op) +#define PyTuple_GET_SIZE(op) Py_SIZE(op) /* Macro, *only* to be used to fill in brand new tuples */ #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) Modified: python/branches/py3k/Include/unicodeobject.h ============================================================================== --- python/branches/py3k/Include/unicodeobject.h (original) +++ python/branches/py3k/Include/unicodeobject.h Wed Dec 19 03:45:37 2007 @@ -424,8 +424,8 @@ #define SSTATE_INTERNED_IMMORTAL 2 #define PyUnicode_Check(op) \ - PyType_FastSubclass(Py_Type(op), Py_TPFLAGS_UNICODE_SUBCLASS) -#define PyUnicode_CheckExact(op) (Py_Type(op) == &PyUnicode_Type) + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) +#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) /* Fast access macros */ #define PyUnicode_GET_SIZE(op) \ Modified: python/branches/py3k/Include/weakrefobject.h ============================================================================== --- python/branches/py3k/Include/weakrefobject.h (original) +++ python/branches/py3k/Include/weakrefobject.h Wed Dec 19 03:45:37 2007 @@ -44,10 +44,10 @@ #define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) #define PyWeakref_CheckRefExact(op) \ - (Py_Type(op) == &_PyWeakref_RefType) + (Py_TYPE(op) == &_PyWeakref_RefType) #define PyWeakref_CheckProxy(op) \ - ((Py_Type(op) == &_PyWeakref_ProxyType) || \ - (Py_Type(op) == &_PyWeakref_CallableProxyType)) + ((Py_TYPE(op) == &_PyWeakref_ProxyType) || \ + (Py_TYPE(op) == &_PyWeakref_CallableProxyType)) /* This macro calls PyWeakref_CheckRef() last since that can involve a function call; this makes it more likely that the function call Modified: python/branches/py3k/Mac/Modules/MacOS.c ============================================================================== --- python/branches/py3k/Mac/Modules/MacOS.c (original) +++ python/branches/py3k/Mac/Modules/MacOS.c Wed Dec 19 03:45:37 2007 @@ -609,7 +609,7 @@ MacOS_Error = PyMac_GetOSErrException(); if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0) return; - Py_Type(&Rftype) = &PyType_Type; + Py_TYPE(&Rftype) = &PyType_Type; Py_INCREF(&Rftype); if (PyDict_SetItemString(d, "ResourceForkType", (PyObject *)&Rftype) != 0) return; Modified: python/branches/py3k/Mac/Modules/ae/_AEmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/ae/_AEmodule.c (original) +++ python/branches/py3k/Mac/Modules/ae/_AEmodule.c Wed Dec 19 03:45:37 2007 @@ -47,7 +47,7 @@ PyTypeObject AEDesc_Type; -#define AEDesc_Check(x) (Py_Type(x) == &AEDesc_Type || PyObject_TypeCheck((x), &AEDesc_Type)) +#define AEDesc_Check(x) (Py_TYPE(x) == &AEDesc_Type || PyObject_TypeCheck((x), &AEDesc_Type)) typedef struct AEDescObject { PyObject_HEAD @@ -79,7 +79,7 @@ static void AEDesc_dealloc(AEDescObject *self) { if (self->ob_owned) AEDisposeDesc(&self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *AEDesc_AECoerceDesc(AEDescObject *_self, PyObject *_args) @@ -1440,7 +1440,7 @@ if (AE_Error == NULL || PyDict_SetItemString(d, "Error", AE_Error) != 0) return; - Py_Type(&AEDesc_Type) = &PyType_Type; + Py_TYPE(&AEDesc_Type) = &PyType_Type; if (PyType_Ready(&AEDesc_Type) < 0) return; Py_INCREF(&AEDesc_Type); PyModule_AddObject(m, "AEDesc", (PyObject *)&AEDesc_Type); Modified: python/branches/py3k/Mac/Modules/app/_Appmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/app/_Appmodule.c (original) +++ python/branches/py3k/Mac/Modules/app/_Appmodule.c Wed Dec 19 03:45:37 2007 @@ -30,7 +30,7 @@ PyTypeObject ThemeDrawingState_Type; -#define ThemeDrawingStateObj_Check(x) (Py_Type(x) == &ThemeDrawingState_Type || PyObject_TypeCheck((x), &ThemeDrawingState_Type)) +#define ThemeDrawingStateObj_Check(x) (Py_TYPE(x) == &ThemeDrawingState_Type || PyObject_TypeCheck((x), &ThemeDrawingState_Type)) typedef struct ThemeDrawingStateObject { PyObject_HEAD @@ -60,7 +60,7 @@ static void ThemeDrawingStateObj_dealloc(ThemeDrawingStateObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *ThemeDrawingStateObj_SetThemeDrawingState(ThemeDrawingStateObject *_self, PyObject *_args) @@ -1807,7 +1807,7 @@ if (App_Error == NULL || PyDict_SetItemString(d, "Error", App_Error) != 0) return; - Py_Type(&ThemeDrawingState_Type) = &PyType_Type; + Py_TYPE(&ThemeDrawingState_Type) = &PyType_Type; if (PyType_Ready(&ThemeDrawingState_Type) < 0) return; Py_INCREF(&ThemeDrawingState_Type); PyModule_AddObject(m, "ThemeDrawingState", (PyObject *)&ThemeDrawingState_Type); Modified: python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c (original) +++ python/branches/py3k/Mac/Modules/carbonevt/_CarbonEvtmodule.c Wed Dec 19 03:45:37 2007 @@ -151,7 +151,7 @@ static void EventRef_dealloc(EventRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventRef_RetainEvent(EventRefObject *_self, PyObject *_args) @@ -495,7 +495,7 @@ static void EventQueueRef_dealloc(EventQueueRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventQueueRef_PostEventToQueue(EventQueueRefObject *_self, PyObject *_args) @@ -715,7 +715,7 @@ static void EventLoopRef_dealloc(EventLoopRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventLoopRef_QuitEventLoop(EventLoopRefObject *_self, PyObject *_args) @@ -844,7 +844,7 @@ static void EventLoopTimerRef_dealloc(EventLoopTimerRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventLoopTimerRef_RemoveEventLoopTimer(EventLoopTimerRefObject *_self, PyObject *_args) @@ -996,7 +996,7 @@ RemoveEventHandler(self->ob_itself); Py_DECREF(self->ob_callback); } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventHandlerRef_AddEventTypesToHandler(EventHandlerRefObject *_self, PyObject *_args) @@ -1183,7 +1183,7 @@ static void EventHandlerCallRef_dealloc(EventHandlerCallRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventHandlerCallRef_CallNextEventHandler(EventHandlerCallRefObject *_self, PyObject *_args) @@ -1315,7 +1315,7 @@ static void EventTargetRef_dealloc(EventTargetRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventTargetRef_InstallStandardEventHandler(EventTargetRefObject *_self, PyObject *_args) @@ -1469,7 +1469,7 @@ static void EventHotKeyRef_dealloc(EventHotKeyRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *EventHotKeyRef_UnregisterEventHotKey(EventHotKeyRefObject *_self, PyObject *_args) @@ -2152,56 +2152,56 @@ if (CarbonEvents_Error == NULL || PyDict_SetItemString(d, "Error", CarbonEvents_Error) != 0) return; - Py_Type(&EventRef_Type) = &PyType_Type; + Py_TYPE(&EventRef_Type) = &PyType_Type; if (PyType_Ready(&EventRef_Type) < 0) return; Py_INCREF(&EventRef_Type); PyModule_AddObject(m, "EventRef", (PyObject *)&EventRef_Type); /* Backward-compatible name */ Py_INCREF(&EventRef_Type); PyModule_AddObject(m, "EventRefType", (PyObject *)&EventRef_Type); - Py_Type(&EventQueueRef_Type) = &PyType_Type; + Py_TYPE(&EventQueueRef_Type) = &PyType_Type; if (PyType_Ready(&EventQueueRef_Type) < 0) return; Py_INCREF(&EventQueueRef_Type); PyModule_AddObject(m, "EventQueueRef", (PyObject *)&EventQueueRef_Type); /* Backward-compatible name */ Py_INCREF(&EventQueueRef_Type); PyModule_AddObject(m, "EventQueueRefType", (PyObject *)&EventQueueRef_Type); - Py_Type(&EventLoopRef_Type) = &PyType_Type; + Py_TYPE(&EventLoopRef_Type) = &PyType_Type; if (PyType_Ready(&EventLoopRef_Type) < 0) return; Py_INCREF(&EventLoopRef_Type); PyModule_AddObject(m, "EventLoopRef", (PyObject *)&EventLoopRef_Type); /* Backward-compatible name */ Py_INCREF(&EventLoopRef_Type); PyModule_AddObject(m, "EventLoopRefType", (PyObject *)&EventLoopRef_Type); - Py_Type(&EventLoopTimerRef_Type) = &PyType_Type; + Py_TYPE(&EventLoopTimerRef_Type) = &PyType_Type; if (PyType_Ready(&EventLoopTimerRef_Type) < 0) return; Py_INCREF(&EventLoopTimerRef_Type); PyModule_AddObject(m, "EventLoopTimerRef", (PyObject *)&EventLoopTimerRef_Type); /* Backward-compatible name */ Py_INCREF(&EventLoopTimerRef_Type); PyModule_AddObject(m, "EventLoopTimerRefType", (PyObject *)&EventLoopTimerRef_Type); - Py_Type(&EventHandlerRef_Type) = &PyType_Type; + Py_TYPE(&EventHandlerRef_Type) = &PyType_Type; if (PyType_Ready(&EventHandlerRef_Type) < 0) return; Py_INCREF(&EventHandlerRef_Type); PyModule_AddObject(m, "EventHandlerRef", (PyObject *)&EventHandlerRef_Type); /* Backward-compatible name */ Py_INCREF(&EventHandlerRef_Type); PyModule_AddObject(m, "EventHandlerRefType", (PyObject *)&EventHandlerRef_Type); - Py_Type(&EventHandlerCallRef_Type) = &PyType_Type; + Py_TYPE(&EventHandlerCallRef_Type) = &PyType_Type; if (PyType_Ready(&EventHandlerCallRef_Type) < 0) return; Py_INCREF(&EventHandlerCallRef_Type); PyModule_AddObject(m, "EventHandlerCallRef", (PyObject *)&EventHandlerCallRef_Type); /* Backward-compatible name */ Py_INCREF(&EventHandlerCallRef_Type); PyModule_AddObject(m, "EventHandlerCallRefType", (PyObject *)&EventHandlerCallRef_Type); - Py_Type(&EventTargetRef_Type) = &PyType_Type; + Py_TYPE(&EventTargetRef_Type) = &PyType_Type; if (PyType_Ready(&EventTargetRef_Type) < 0) return; Py_INCREF(&EventTargetRef_Type); PyModule_AddObject(m, "EventTargetRef", (PyObject *)&EventTargetRef_Type); /* Backward-compatible name */ Py_INCREF(&EventTargetRef_Type); PyModule_AddObject(m, "EventTargetRefType", (PyObject *)&EventTargetRef_Type); - Py_Type(&EventHotKeyRef_Type) = &PyType_Type; + Py_TYPE(&EventHotKeyRef_Type) = &PyType_Type; if (PyType_Ready(&EventHotKeyRef_Type) < 0) return; Py_INCREF(&EventHotKeyRef_Type); PyModule_AddObject(m, "EventHotKeyRef", (PyObject *)&EventHotKeyRef_Type); Modified: python/branches/py3k/Mac/Modules/cf/_CFmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/cf/_CFmodule.c (original) +++ python/branches/py3k/Mac/Modules/cf/_CFmodule.c Wed Dec 19 03:45:37 2007 @@ -116,7 +116,7 @@ PyTypeObject CFTypeRef_Type; -#define CFTypeRefObj_Check(x) (Py_Type(x) == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type)) +#define CFTypeRefObj_Check(x) (Py_TYPE(x) == &CFTypeRef_Type || PyObject_TypeCheck((x), &CFTypeRef_Type)) typedef struct CFTypeRefObject { PyObject_HEAD @@ -161,7 +161,7 @@ self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *CFTypeRefObj_CFGetTypeID(CFTypeRefObject *_self, PyObject *_args) @@ -477,7 +477,7 @@ PyTypeObject CFArrayRef_Type; -#define CFArrayRefObj_Check(x) (Py_Type(x) == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type)) +#define CFArrayRefObj_Check(x) (Py_TYPE(x) == &CFArrayRef_Type || PyObject_TypeCheck((x), &CFArrayRef_Type)) typedef struct CFArrayRefObject { PyObject_HEAD @@ -687,7 +687,7 @@ PyTypeObject CFMutableArrayRef_Type; -#define CFMutableArrayRefObj_Check(x) (Py_Type(x) == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type)) +#define CFMutableArrayRefObj_Check(x) (Py_TYPE(x) == &CFMutableArrayRef_Type || PyObject_TypeCheck((x), &CFMutableArrayRef_Type)) typedef struct CFMutableArrayRefObject { PyObject_HEAD @@ -926,7 +926,7 @@ PyTypeObject CFDictionaryRef_Type; -#define CFDictionaryRefObj_Check(x) (Py_Type(x) == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type)) +#define CFDictionaryRefObj_Check(x) (Py_TYPE(x) == &CFDictionaryRef_Type || PyObject_TypeCheck((x), &CFDictionaryRef_Type)) typedef struct CFDictionaryRefObject { PyObject_HEAD @@ -1118,7 +1118,7 @@ PyTypeObject CFMutableDictionaryRef_Type; -#define CFMutableDictionaryRefObj_Check(x) (Py_Type(x) == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type)) +#define CFMutableDictionaryRefObj_Check(x) (Py_TYPE(x) == &CFMutableDictionaryRef_Type || PyObject_TypeCheck((x), &CFMutableDictionaryRef_Type)) typedef struct CFMutableDictionaryRefObject { PyObject_HEAD @@ -1294,7 +1294,7 @@ PyTypeObject CFDataRef_Type; -#define CFDataRefObj_Check(x) (Py_Type(x) == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type)) +#define CFDataRefObj_Check(x) (Py_TYPE(x) == &CFDataRef_Type || PyObject_TypeCheck((x), &CFDataRef_Type)) typedef struct CFDataRefObject { PyObject_HEAD @@ -1524,7 +1524,7 @@ PyTypeObject CFMutableDataRef_Type; -#define CFMutableDataRefObj_Check(x) (Py_Type(x) == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type)) +#define CFMutableDataRefObj_Check(x) (Py_TYPE(x) == &CFMutableDataRef_Type || PyObject_TypeCheck((x), &CFMutableDataRef_Type)) typedef struct CFMutableDataRefObject { PyObject_HEAD @@ -1788,7 +1788,7 @@ PyTypeObject CFStringRef_Type; -#define CFStringRefObj_Check(x) (Py_Type(x) == &CFStringRef_Type || PyObject_TypeCheck((x), &CFStringRef_Type)) +#define CFStringRefObj_Check(x) (Py_TYPE(x) == &CFStringRef_Type || PyObject_TypeCheck((x), &CFStringRef_Type)) typedef struct CFStringRefObject { PyObject_HEAD @@ -2530,7 +2530,7 @@ PyTypeObject CFMutableStringRef_Type; -#define CFMutableStringRefObj_Check(x) (Py_Type(x) == &CFMutableStringRef_Type || PyObject_TypeCheck((x), &CFMutableStringRef_Type)) +#define CFMutableStringRefObj_Check(x) (Py_TYPE(x) == &CFMutableStringRef_Type || PyObject_TypeCheck((x), &CFMutableStringRef_Type)) typedef struct CFMutableStringRefObject { PyObject_HEAD @@ -2917,7 +2917,7 @@ PyTypeObject CFURLRef_Type; -#define CFURLRefObj_Check(x) (Py_Type(x) == &CFURLRef_Type || PyObject_TypeCheck((x), &CFURLRef_Type)) +#define CFURLRefObj_Check(x) (Py_TYPE(x) == &CFURLRef_Type || PyObject_TypeCheck((x), &CFURLRef_Type)) typedef struct CFURLRefObject { PyObject_HEAD @@ -4890,14 +4890,14 @@ if (CF_Error == NULL || PyDict_SetItemString(d, "Error", CF_Error) != 0) return; - Py_Type(&CFTypeRef_Type) = &PyType_Type; + Py_TYPE(&CFTypeRef_Type) = &PyType_Type; if (PyType_Ready(&CFTypeRef_Type) < 0) return; Py_INCREF(&CFTypeRef_Type); PyModule_AddObject(m, "CFTypeRef", (PyObject *)&CFTypeRef_Type); /* Backward-compatible name */ Py_INCREF(&CFTypeRef_Type); PyModule_AddObject(m, "CFTypeRefType", (PyObject *)&CFTypeRef_Type); - Py_Type(&CFArrayRef_Type) = &PyType_Type; + Py_TYPE(&CFArrayRef_Type) = &PyType_Type; CFArrayRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFArrayRef_Type) < 0) return; Py_INCREF(&CFArrayRef_Type); @@ -4905,7 +4905,7 @@ /* Backward-compatible name */ Py_INCREF(&CFArrayRef_Type); PyModule_AddObject(m, "CFArrayRefType", (PyObject *)&CFArrayRef_Type); - Py_Type(&CFMutableArrayRef_Type) = &PyType_Type; + Py_TYPE(&CFMutableArrayRef_Type) = &PyType_Type; CFMutableArrayRef_Type.tp_base = &CFArrayRef_Type; if (PyType_Ready(&CFMutableArrayRef_Type) < 0) return; Py_INCREF(&CFMutableArrayRef_Type); @@ -4913,7 +4913,7 @@ /* Backward-compatible name */ Py_INCREF(&CFMutableArrayRef_Type); PyModule_AddObject(m, "CFMutableArrayRefType", (PyObject *)&CFMutableArrayRef_Type); - Py_Type(&CFDictionaryRef_Type) = &PyType_Type; + Py_TYPE(&CFDictionaryRef_Type) = &PyType_Type; CFDictionaryRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFDictionaryRef_Type) < 0) return; Py_INCREF(&CFDictionaryRef_Type); @@ -4921,7 +4921,7 @@ /* Backward-compatible name */ Py_INCREF(&CFDictionaryRef_Type); PyModule_AddObject(m, "CFDictionaryRefType", (PyObject *)&CFDictionaryRef_Type); - Py_Type(&CFMutableDictionaryRef_Type) = &PyType_Type; + Py_TYPE(&CFMutableDictionaryRef_Type) = &PyType_Type; CFMutableDictionaryRef_Type.tp_base = &CFDictionaryRef_Type; if (PyType_Ready(&CFMutableDictionaryRef_Type) < 0) return; Py_INCREF(&CFMutableDictionaryRef_Type); @@ -4929,7 +4929,7 @@ /* Backward-compatible name */ Py_INCREF(&CFMutableDictionaryRef_Type); PyModule_AddObject(m, "CFMutableDictionaryRefType", (PyObject *)&CFMutableDictionaryRef_Type); - Py_Type(&CFDataRef_Type) = &PyType_Type; + Py_TYPE(&CFDataRef_Type) = &PyType_Type; CFDataRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFDataRef_Type) < 0) return; Py_INCREF(&CFDataRef_Type); @@ -4937,7 +4937,7 @@ /* Backward-compatible name */ Py_INCREF(&CFDataRef_Type); PyModule_AddObject(m, "CFDataRefType", (PyObject *)&CFDataRef_Type); - Py_Type(&CFMutableDataRef_Type) = &PyType_Type; + Py_TYPE(&CFMutableDataRef_Type) = &PyType_Type; CFMutableDataRef_Type.tp_base = &CFDataRef_Type; if (PyType_Ready(&CFMutableDataRef_Type) < 0) return; Py_INCREF(&CFMutableDataRef_Type); @@ -4945,7 +4945,7 @@ /* Backward-compatible name */ Py_INCREF(&CFMutableDataRef_Type); PyModule_AddObject(m, "CFMutableDataRefType", (PyObject *)&CFMutableDataRef_Type); - Py_Type(&CFStringRef_Type) = &PyType_Type; + Py_TYPE(&CFStringRef_Type) = &PyType_Type; CFStringRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFStringRef_Type) < 0) return; Py_INCREF(&CFStringRef_Type); @@ -4953,7 +4953,7 @@ /* Backward-compatible name */ Py_INCREF(&CFStringRef_Type); PyModule_AddObject(m, "CFStringRefType", (PyObject *)&CFStringRef_Type); - Py_Type(&CFMutableStringRef_Type) = &PyType_Type; + Py_TYPE(&CFMutableStringRef_Type) = &PyType_Type; CFMutableStringRef_Type.tp_base = &CFStringRef_Type; if (PyType_Ready(&CFMutableStringRef_Type) < 0) return; Py_INCREF(&CFMutableStringRef_Type); @@ -4961,7 +4961,7 @@ /* Backward-compatible name */ Py_INCREF(&CFMutableStringRef_Type); PyModule_AddObject(m, "CFMutableStringRefType", (PyObject *)&CFMutableStringRef_Type); - Py_Type(&CFURLRef_Type) = &PyType_Type; + Py_TYPE(&CFURLRef_Type) = &PyType_Type; CFURLRef_Type.tp_base = &CFTypeRef_Type; if (PyType_Ready(&CFURLRef_Type) < 0) return; Py_INCREF(&CFURLRef_Type); Modified: python/branches/py3k/Mac/Modules/cg/_CGmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/cg/_CGmodule.c (original) +++ python/branches/py3k/Mac/Modules/cg/_CGmodule.c Wed Dec 19 03:45:37 2007 @@ -95,7 +95,7 @@ PyTypeObject CGContextRef_Type; -#define CGContextRefObj_Check(x) (Py_Type(x) == &CGContextRef_Type || PyObject_TypeCheck((x), &CGContextRef_Type)) +#define CGContextRefObj_Check(x) (Py_TYPE(x) == &CGContextRef_Type || PyObject_TypeCheck((x), &CGContextRef_Type)) typedef struct CGContextRefObject { PyObject_HEAD @@ -125,7 +125,7 @@ static void CGContextRefObj_dealloc(CGContextRefObject *self) { CGContextRelease(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *CGContextRefObj_CGContextSaveGState(CGContextRefObject *_self, PyObject *_args) @@ -1294,7 +1294,7 @@ if (CG_Error == NULL || PyDict_SetItemString(d, "Error", CG_Error) != 0) return; - Py_Type(&CGContextRef_Type) = &PyType_Type; + Py_TYPE(&CGContextRef_Type) = &PyType_Type; if (PyType_Ready(&CGContextRef_Type) < 0) return; Py_INCREF(&CGContextRef_Type); PyModule_AddObject(m, "CGContextRef", (PyObject *)&CGContextRef_Type); Modified: python/branches/py3k/Mac/Modules/cm/_Cmmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/cm/_Cmmodule.c (original) +++ python/branches/py3k/Mac/Modules/cm/_Cmmodule.c Wed Dec 19 03:45:37 2007 @@ -60,7 +60,7 @@ PyTypeObject ComponentInstance_Type; -#define CmpInstObj_Check(x) (Py_Type(x) == &ComponentInstance_Type || PyObject_TypeCheck((x), &ComponentInstance_Type)) +#define CmpInstObj_Check(x) (Py_TYPE(x) == &ComponentInstance_Type || PyObject_TypeCheck((x), &ComponentInstance_Type)) typedef struct ComponentInstanceObject { PyObject_HEAD @@ -94,7 +94,7 @@ static void CmpInstObj_dealloc(ComponentInstanceObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *CmpInstObj_CloseComponent(ComponentInstanceObject *_self, PyObject *_args) @@ -326,7 +326,7 @@ PyTypeObject Component_Type; -#define CmpObj_Check(x) (Py_Type(x) == &Component_Type || PyObject_TypeCheck((x), &Component_Type)) +#define CmpObj_Check(x) (Py_TYPE(x) == &Component_Type || PyObject_TypeCheck((x), &Component_Type)) typedef struct ComponentObject { PyObject_HEAD @@ -365,7 +365,7 @@ static void CmpObj_dealloc(ComponentObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *CmpObj_UnregisterComponent(ComponentObject *_self, PyObject *_args) @@ -925,14 +925,14 @@ if (Cm_Error == NULL || PyDict_SetItemString(d, "Error", Cm_Error) != 0) return; - Py_Type(&ComponentInstance_Type) = &PyType_Type; + Py_TYPE(&ComponentInstance_Type) = &PyType_Type; if (PyType_Ready(&ComponentInstance_Type) < 0) return; Py_INCREF(&ComponentInstance_Type); PyModule_AddObject(m, "ComponentInstance", (PyObject *)&ComponentInstance_Type); /* Backward-compatible name */ Py_INCREF(&ComponentInstance_Type); PyModule_AddObject(m, "ComponentInstanceType", (PyObject *)&ComponentInstance_Type); - Py_Type(&Component_Type) = &PyType_Type; + Py_TYPE(&Component_Type) = &PyType_Type; if (PyType_Ready(&Component_Type) < 0) return; Py_INCREF(&Component_Type); PyModule_AddObject(m, "Component", (PyObject *)&Component_Type); Modified: python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c (original) +++ python/branches/py3k/Mac/Modules/ctl/_Ctlmodule.c Wed Dec 19 03:45:37 2007 @@ -135,7 +135,7 @@ PyTypeObject Control_Type; -#define CtlObj_Check(x) (Py_Type(x) == &Control_Type || PyObject_TypeCheck((x), &Control_Type)) +#define CtlObj_Check(x) (Py_TYPE(x) == &Control_Type || PyObject_TypeCheck((x), &Control_Type)) typedef struct ControlObject { PyObject_HEAD @@ -170,7 +170,7 @@ { Py_XDECREF(self->ob_callbackdict); if (self->ob_itself)SetControlReference(self->ob_itself, (long)0); /* Make it forget about us */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *CtlObj_HiliteControl(ControlObject *_self, PyObject *_args) @@ -5790,7 +5790,7 @@ if (Ctl_Error == NULL || PyDict_SetItemString(d, "Error", Ctl_Error) != 0) return; - Py_Type(&Control_Type) = &PyType_Type; + Py_TYPE(&Control_Type) = &PyType_Type; if (PyType_Ready(&Control_Type) < 0) return; Py_INCREF(&Control_Type); PyModule_AddObject(m, "Control", (PyObject *)&Control_Type); Modified: python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c (original) +++ python/branches/py3k/Mac/Modules/dlg/_Dlgmodule.c Wed Dec 19 03:45:37 2007 @@ -129,7 +129,7 @@ PyTypeObject Dialog_Type; -#define DlgObj_Check(x) (Py_Type(x) == &Dialog_Type || PyObject_TypeCheck((x), &Dialog_Type)) +#define DlgObj_Check(x) (Py_TYPE(x) == &Dialog_Type || PyObject_TypeCheck((x), &Dialog_Type)) typedef struct DialogObject { PyObject_HEAD @@ -164,7 +164,7 @@ static void DlgObj_dealloc(DialogObject *self) { DisposeDialog(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *DlgObj_DrawDialog(DialogObject *_self, PyObject *_args) @@ -1582,7 +1582,7 @@ if (Dlg_Error == NULL || PyDict_SetItemString(d, "Error", Dlg_Error) != 0) return; - Py_Type(&Dialog_Type) = &PyType_Type; + Py_TYPE(&Dialog_Type) = &PyType_Type; if (PyType_Ready(&Dialog_Type) < 0) return; Py_INCREF(&Dialog_Type); PyModule_AddObject(m, "Dialog", (PyObject *)&Dialog_Type); Modified: python/branches/py3k/Mac/Modules/drag/_Dragmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/drag/_Dragmodule.c (original) +++ python/branches/py3k/Mac/Modules/drag/_Dragmodule.c Wed Dec 19 03:45:37 2007 @@ -40,7 +40,7 @@ PyTypeObject DragObj_Type; -#define DragObj_Check(x) (Py_Type(x) == &DragObj_Type || PyObject_TypeCheck((x), &DragObj_Type)) +#define DragObj_Check(x) (Py_TYPE(x) == &DragObj_Type || PyObject_TypeCheck((x), &DragObj_Type)) typedef struct DragObjObject { PyObject_HEAD @@ -76,7 +76,7 @@ static void DragObj_dealloc(DragObjObject *self) { Py_XDECREF(self->sendproc); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *DragObj_DisposeDrag(DragObjObject *_self, PyObject *_args) @@ -1125,7 +1125,7 @@ if (Drag_Error == NULL || PyDict_SetItemString(d, "Error", Drag_Error) != 0) return; - Py_Type(&DragObj_Type) = &PyType_Type; + Py_TYPE(&DragObj_Type) = &PyType_Type; if (PyType_Ready(&DragObj_Type) < 0) return; Py_INCREF(&DragObj_Type); PyModule_AddObject(m, "DragObj", (PyObject *)&DragObj_Type); Modified: python/branches/py3k/Mac/Modules/file/_Filemodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/file/_Filemodule.c (original) +++ python/branches/py3k/Mac/Modules/file/_Filemodule.c Wed Dec 19 03:45:37 2007 @@ -143,7 +143,7 @@ static PyTypeObject FSCatalogInfo_Type; -#define FSCatalogInfo_Check(x) (Py_Type(x) == &FSCatalogInfo_Type || PyObject_TypeCheck((x), &FSCatalogInfo_Type)) +#define FSCatalogInfo_Check(x) (Py_TYPE(x) == &FSCatalogInfo_Type || PyObject_TypeCheck((x), &FSCatalogInfo_Type)) typedef struct FSCatalogInfoObject { PyObject_HEAD @@ -174,7 +174,7 @@ static void FSCatalogInfo_dealloc(FSCatalogInfoObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyMethodDef FSCatalogInfo_methods[] = { @@ -502,7 +502,7 @@ static PyTypeObject FInfo_Type; -#define FInfo_Check(x) (Py_Type(x) == &FInfo_Type || PyObject_TypeCheck((x), &FInfo_Type)) +#define FInfo_Check(x) (Py_TYPE(x) == &FInfo_Type || PyObject_TypeCheck((x), &FInfo_Type)) typedef struct FInfoObject { PyObject_HEAD @@ -533,7 +533,7 @@ static void FInfo_dealloc(FInfoObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyMethodDef FInfo_methods[] = { @@ -687,7 +687,7 @@ static PyTypeObject Alias_Type; -#define Alias_Check(x) (Py_Type(x) == &Alias_Type || PyObject_TypeCheck((x), &Alias_Type)) +#define Alias_Check(x) (Py_TYPE(x) == &Alias_Type || PyObject_TypeCheck((x), &Alias_Type)) typedef struct AliasObject { PyObject_HEAD @@ -724,7 +724,7 @@ self->ob_freeit(self->ob_itself); } self->ob_itself = NULL; - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *Alias_ResolveAlias(AliasObject *_self, PyObject *_args) @@ -1053,7 +1053,7 @@ static void FSSpec_dealloc(FSSpecObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *FSSpec_FSpOpenDF(FSSpecObject *_self, PyObject *_args) @@ -1386,7 +1386,7 @@ { char buf[512]; PyOS_snprintf(buf, sizeof(buf), "%s((%d, %ld, '%.*s'))", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, self->ob_itself.vRefNum, self->ob_itself.parID, self->ob_itself.name[0], self->ob_itself.name+1); @@ -1511,7 +1511,7 @@ static void FSRef_dealloc(FSRefObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *FSRef_FSMakeFSRefUnicode(FSRefObject *_self, PyObject *_args) @@ -3246,35 +3246,35 @@ if (File_Error == NULL || PyDict_SetItemString(d, "Error", File_Error) != 0) return; - Py_Type(&FSCatalogInfo_Type) = &PyType_Type; + Py_TYPE(&FSCatalogInfo_Type) = &PyType_Type; if (PyType_Ready(&FSCatalogInfo_Type) < 0) return; Py_INCREF(&FSCatalogInfo_Type); PyModule_AddObject(m, "FSCatalogInfo", (PyObject *)&FSCatalogInfo_Type); /* Backward-compatible name */ Py_INCREF(&FSCatalogInfo_Type); PyModule_AddObject(m, "FSCatalogInfoType", (PyObject *)&FSCatalogInfo_Type); - Py_Type(&FInfo_Type) = &PyType_Type; + Py_TYPE(&FInfo_Type) = &PyType_Type; if (PyType_Ready(&FInfo_Type) < 0) return; Py_INCREF(&FInfo_Type); PyModule_AddObject(m, "FInfo", (PyObject *)&FInfo_Type); /* Backward-compatible name */ Py_INCREF(&FInfo_Type); PyModule_AddObject(m, "FInfoType", (PyObject *)&FInfo_Type); - Py_Type(&Alias_Type) = &PyType_Type; + Py_TYPE(&Alias_Type) = &PyType_Type; if (PyType_Ready(&Alias_Type) < 0) return; Py_INCREF(&Alias_Type); PyModule_AddObject(m, "Alias", (PyObject *)&Alias_Type); /* Backward-compatible name */ Py_INCREF(&Alias_Type); PyModule_AddObject(m, "AliasType", (PyObject *)&Alias_Type); - Py_Type(&FSSpec_Type) = &PyType_Type; + Py_TYPE(&FSSpec_Type) = &PyType_Type; if (PyType_Ready(&FSSpec_Type) < 0) return; Py_INCREF(&FSSpec_Type); PyModule_AddObject(m, "FSSpec", (PyObject *)&FSSpec_Type); /* Backward-compatible name */ Py_INCREF(&FSSpec_Type); PyModule_AddObject(m, "FSSpecType", (PyObject *)&FSSpec_Type); - Py_Type(&FSRef_Type) = &PyType_Type; + Py_TYPE(&FSRef_Type) = &PyType_Type; if (PyType_Ready(&FSRef_Type) < 0) return; Py_INCREF(&FSRef_Type); PyModule_AddObject(m, "FSRef", (PyObject *)&FSRef_Type); Modified: python/branches/py3k/Mac/Modules/ibcarbon/_IBCarbon.c ============================================================================== --- python/branches/py3k/Mac/Modules/ibcarbon/_IBCarbon.c (original) +++ python/branches/py3k/Mac/Modules/ibcarbon/_IBCarbon.c Wed Dec 19 03:45:37 2007 @@ -19,7 +19,7 @@ PyTypeObject IBNibRef_Type; -#define IBNibRefObj_Check(x) (Py_Type(x) == &IBNibRef_Type || PyObject_TypeCheck((x), &IBNibRef_Type)) +#define IBNibRefObj_Check(x) (Py_TYPE(x) == &IBNibRef_Type || PyObject_TypeCheck((x), &IBNibRef_Type)) typedef struct IBNibRefObject { PyObject_HEAD @@ -49,7 +49,7 @@ static void IBNibRefObj_dealloc(IBNibRefObject *self) { DisposeNibReference(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *IBNibRefObj_CreateWindowFromNib(IBNibRefObject *_self, PyObject *_args) @@ -248,7 +248,7 @@ if (IBCarbon_Error == NULL || PyDict_SetItemString(d, "Error", IBCarbon_Error) != 0) return; - Py_Type(&IBNibRef_Type) = &PyType_Type; + Py_TYPE(&IBNibRef_Type) = &PyType_Type; if (PyType_Ready(&IBNibRef_Type) < 0) return; Py_INCREF(&IBNibRef_Type); PyModule_AddObject(m, "IBNibRef", (PyObject *)&IBNibRef_Type); Modified: python/branches/py3k/Mac/Modules/list/_Listmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/list/_Listmodule.c (original) +++ python/branches/py3k/Mac/Modules/list/_Listmodule.c Wed Dec 19 03:45:37 2007 @@ -37,7 +37,7 @@ PyTypeObject List_Type; -#define ListObj_Check(x) (Py_Type(x) == &List_Type || PyObject_TypeCheck((x), &List_Type)) +#define ListObj_Check(x) (Py_TYPE(x) == &List_Type || PyObject_TypeCheck((x), &List_Type)) typedef struct ListObject { PyObject_HEAD @@ -79,7 +79,7 @@ self->ob_ldef_func = NULL; SetListRefCon(self->ob_itself, (long)0); if (self->ob_must_be_disposed && self->ob_itself) LDispose(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *ListObj_LAddColumn(ListObject *_self, PyObject *_args) @@ -1116,7 +1116,7 @@ if (List_Error == NULL || PyDict_SetItemString(d, "Error", List_Error) != 0) return; - Py_Type(&List_Type) = &PyType_Type; + Py_TYPE(&List_Type) = &PyType_Type; if (PyType_Ready(&List_Type) < 0) return; Py_INCREF(&List_Type); PyModule_AddObject(m, "List", (PyObject *)&List_Type); Modified: python/branches/py3k/Mac/Modules/menu/_Menumodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/menu/_Menumodule.c (original) +++ python/branches/py3k/Mac/Modules/menu/_Menumodule.c Wed Dec 19 03:45:37 2007 @@ -57,7 +57,7 @@ PyTypeObject Menu_Type; -#define MenuObj_Check(x) (Py_Type(x) == &Menu_Type || PyObject_TypeCheck((x), &Menu_Type)) +#define MenuObj_Check(x) (Py_TYPE(x) == &Menu_Type || PyObject_TypeCheck((x), &Menu_Type)) typedef struct MenuObject { PyObject_HEAD @@ -87,7 +87,7 @@ static void MenuObj_dealloc(MenuObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *MenuObj_DisposeMenu(MenuObject *_self, PyObject *_args) @@ -3455,7 +3455,7 @@ if (Menu_Error == NULL || PyDict_SetItemString(d, "Error", Menu_Error) != 0) return; - Py_Type(&Menu_Type) = &PyType_Type; + Py_TYPE(&Menu_Type) = &PyType_Type; if (PyType_Ready(&Menu_Type) < 0) return; Py_INCREF(&Menu_Type); PyModule_AddObject(m, "Menu", (PyObject *)&Menu_Type); Modified: python/branches/py3k/Mac/Modules/mlte/_Mltemodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/mlte/_Mltemodule.c (original) +++ python/branches/py3k/Mac/Modules/mlte/_Mltemodule.c Wed Dec 19 03:45:37 2007 @@ -69,7 +69,7 @@ PyTypeObject TXNObject_Type; -#define TXNObj_Check(x) (Py_Type(x) == &TXNObject_Type || PyObject_TypeCheck((x), &TXNObject_Type)) +#define TXNObj_Check(x) (Py_TYPE(x) == &TXNObject_Type || PyObject_TypeCheck((x), &TXNObject_Type)) typedef struct TXNObjectObject { PyObject_HEAD @@ -100,7 +100,7 @@ static void TXNObj_dealloc(TXNObjectObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *TXNObj_TXNDeleteObject(TXNObjectObject *_self, PyObject *_args) @@ -1304,7 +1304,7 @@ PyTypeObject TXNFontMenuObject_Type; -#define TXNFontMenuObj_Check(x) (Py_Type(x) == &TXNFontMenuObject_Type || PyObject_TypeCheck((x), &TXNFontMenuObject_Type)) +#define TXNFontMenuObj_Check(x) (Py_TYPE(x) == &TXNFontMenuObject_Type || PyObject_TypeCheck((x), &TXNFontMenuObject_Type)) typedef struct TXNFontMenuObjectObject { PyObject_HEAD @@ -1335,7 +1335,7 @@ static void TXNFontMenuObj_dealloc(TXNFontMenuObjectObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *TXNFontMenuObj_TXNGetFontMenuHandle(TXNFontMenuObjectObject *_self, PyObject *_args) @@ -1659,14 +1659,14 @@ if (Mlte_Error == NULL || PyDict_SetItemString(d, "Error", Mlte_Error) != 0) return; - Py_Type(&TXNObject_Type) = &PyType_Type; + Py_TYPE(&TXNObject_Type) = &PyType_Type; if (PyType_Ready(&TXNObject_Type) < 0) return; Py_INCREF(&TXNObject_Type); PyModule_AddObject(m, "TXNObject", (PyObject *)&TXNObject_Type); /* Backward-compatible name */ Py_INCREF(&TXNObject_Type); PyModule_AddObject(m, "TXNObjectType", (PyObject *)&TXNObject_Type); - Py_Type(&TXNFontMenuObject_Type) = &PyType_Type; + Py_TYPE(&TXNFontMenuObject_Type) = &PyType_Type; if (PyType_Ready(&TXNFontMenuObject_Type) < 0) return; Py_INCREF(&TXNFontMenuObject_Type); PyModule_AddObject(m, "TXNFontMenuObject", (PyObject *)&TXNFontMenuObject_Type); Modified: python/branches/py3k/Mac/Modules/osa/_OSAmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/osa/_OSAmodule.c (original) +++ python/branches/py3k/Mac/Modules/osa/_OSAmodule.c Wed Dec 19 03:45:37 2007 @@ -34,7 +34,7 @@ PyTypeObject OSAComponentInstance_Type; -#define OSAObj_Check(x) (Py_Type(x) == &OSAComponentInstance_Type || PyObject_TypeCheck((x), &OSAComponentInstance_Type)) +#define OSAObj_Check(x) (Py_TYPE(x) == &OSAComponentInstance_Type || PyObject_TypeCheck((x), &OSAComponentInstance_Type)) typedef struct OSAComponentInstanceObject { PyObject_HEAD @@ -73,7 +73,7 @@ static void OSAObj_dealloc(OSAComponentInstanceObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *OSAObj_OSALoad(OSAComponentInstanceObject *_self, PyObject *_args) @@ -885,7 +885,7 @@ if (OSA_Error == NULL || PyDict_SetItemString(d, "Error", OSA_Error) != 0) return; - Py_Type(&OSAComponentInstance_Type) = &PyType_Type; + Py_TYPE(&OSAComponentInstance_Type) = &PyType_Type; if (PyType_Ready(&OSAComponentInstance_Type) < 0) return; Py_INCREF(&OSAComponentInstance_Type); PyModule_AddObject(m, "OSAComponentInstance", (PyObject *)&OSAComponentInstance_Type); Modified: python/branches/py3k/Mac/Modules/qd/_Qdmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/qd/_Qdmodule.c (original) +++ python/branches/py3k/Mac/Modules/qd/_Qdmodule.c Wed Dec 19 03:45:37 2007 @@ -73,7 +73,7 @@ PyTypeObject GrafPort_Type; -#define GrafObj_Check(x) (Py_Type(x) == &GrafPort_Type || PyObject_TypeCheck((x), &GrafPort_Type)) +#define GrafObj_Check(x) (Py_TYPE(x) == &GrafPort_Type || PyObject_TypeCheck((x), &GrafPort_Type)) typedef struct GrafPortObject { PyObject_HEAD @@ -125,7 +125,7 @@ static void GrafObj_dealloc(GrafPortObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *GrafObj_MacSetPort(GrafPortObject *_self, PyObject *_args) @@ -1407,7 +1407,7 @@ PyTypeObject BitMap_Type; -#define BMObj_Check(x) (Py_Type(x) == &BitMap_Type || PyObject_TypeCheck((x), &BitMap_Type)) +#define BMObj_Check(x) (Py_TYPE(x) == &BitMap_Type || PyObject_TypeCheck((x), &BitMap_Type)) typedef struct BitMapObject { PyObject_HEAD @@ -1443,7 +1443,7 @@ { Py_XDECREF(self->referred_object); if (self->referred_bitmap) free(self->referred_bitmap); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *BMObj_getdata(BitMapObject *_self, PyObject *_args) @@ -7122,14 +7122,14 @@ if (Qd_Error == NULL || PyDict_SetItemString(d, "Error", Qd_Error) != 0) return; - Py_Type(&GrafPort_Type) = &PyType_Type; + Py_TYPE(&GrafPort_Type) = &PyType_Type; if (PyType_Ready(&GrafPort_Type) < 0) return; Py_INCREF(&GrafPort_Type); PyModule_AddObject(m, "GrafPort", (PyObject *)&GrafPort_Type); /* Backward-compatible name */ Py_INCREF(&GrafPort_Type); PyModule_AddObject(m, "GrafPortType", (PyObject *)&GrafPort_Type); - Py_Type(&BitMap_Type) = &PyType_Type; + Py_TYPE(&BitMap_Type) = &PyType_Type; if (PyType_Ready(&BitMap_Type) < 0) return; Py_INCREF(&BitMap_Type); PyModule_AddObject(m, "BitMap", (PyObject *)&BitMap_Type); Modified: python/branches/py3k/Mac/Modules/qdoffs/_Qdoffsmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/qdoffs/_Qdoffsmodule.c (original) +++ python/branches/py3k/Mac/Modules/qdoffs/_Qdoffsmodule.c Wed Dec 19 03:45:37 2007 @@ -34,7 +34,7 @@ PyTypeObject GWorld_Type; -#define GWorldObj_Check(x) (Py_Type(x) == &GWorld_Type || PyObject_TypeCheck((x), &GWorld_Type)) +#define GWorldObj_Check(x) (Py_TYPE(x) == &GWorld_Type || PyObject_TypeCheck((x), &GWorld_Type)) typedef struct GWorldObject { PyObject_HEAD @@ -65,7 +65,7 @@ static void GWorldObj_dealloc(GWorldObject *self) { DisposeGWorld(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *GWorldObj_GetGWorldDevice(GWorldObject *_self, PyObject *_args) @@ -700,7 +700,7 @@ if (Qdoffs_Error == NULL || PyDict_SetItemString(d, "Error", Qdoffs_Error) != 0) return; - Py_Type(&GWorld_Type) = &PyType_Type; + Py_TYPE(&GWorld_Type) = &PyType_Type; if (PyType_Ready(&GWorld_Type) < 0) return; Py_INCREF(&GWorld_Type); PyModule_AddObject(m, "GWorld", (PyObject *)&GWorld_Type); Modified: python/branches/py3k/Mac/Modules/qt/_Qtmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/qt/_Qtmodule.c (original) +++ python/branches/py3k/Mac/Modules/qt/_Qtmodule.c Wed Dec 19 03:45:37 2007 @@ -97,7 +97,7 @@ PyTypeObject IdleManager_Type; -#define IdleManagerObj_Check(x) (Py_Type(x) == &IdleManager_Type || PyObject_TypeCheck((x), &IdleManager_Type)) +#define IdleManagerObj_Check(x) (Py_TYPE(x) == &IdleManager_Type || PyObject_TypeCheck((x), &IdleManager_Type)) typedef struct IdleManagerObject { PyObject_HEAD @@ -136,7 +136,7 @@ static void IdleManagerObj_dealloc(IdleManagerObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyMethodDef IdleManagerObj_methods[] = { @@ -220,7 +220,7 @@ PyTypeObject MovieController_Type; -#define MovieCtlObj_Check(x) (Py_Type(x) == &MovieController_Type || PyObject_TypeCheck((x), &MovieController_Type)) +#define MovieCtlObj_Check(x) (Py_TYPE(x) == &MovieController_Type || PyObject_TypeCheck((x), &MovieController_Type)) typedef struct MovieControllerObject { PyObject_HEAD @@ -259,7 +259,7 @@ static void MovieCtlObj_dealloc(MovieControllerObject *self) { if (self->ob_itself) DisposeMovieController(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *MovieCtlObj_MCSetMovie(MovieControllerObject *_self, PyObject *_args) @@ -1339,7 +1339,7 @@ PyTypeObject TimeBase_Type; -#define TimeBaseObj_Check(x) (Py_Type(x) == &TimeBase_Type || PyObject_TypeCheck((x), &TimeBase_Type)) +#define TimeBaseObj_Check(x) (Py_TYPE(x) == &TimeBase_Type || PyObject_TypeCheck((x), &TimeBase_Type)) typedef struct TimeBaseObject { PyObject_HEAD @@ -1378,7 +1378,7 @@ static void TimeBaseObj_dealloc(TimeBaseObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *TimeBaseObj_DisposeTimeBase(TimeBaseObject *_self, PyObject *_args) @@ -1832,7 +1832,7 @@ PyTypeObject UserData_Type; -#define UserDataObj_Check(x) (Py_Type(x) == &UserData_Type || PyObject_TypeCheck((x), &UserData_Type)) +#define UserDataObj_Check(x) (Py_TYPE(x) == &UserData_Type || PyObject_TypeCheck((x), &UserData_Type)) typedef struct UserDataObject { PyObject_HEAD @@ -1871,7 +1871,7 @@ static void UserDataObj_dealloc(UserDataObject *self) { if (self->ob_itself) DisposeUserData(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *UserDataObj_GetUserData(UserDataObject *_self, PyObject *_args) @@ -2202,7 +2202,7 @@ PyTypeObject Media_Type; -#define MediaObj_Check(x) (Py_Type(x) == &Media_Type || PyObject_TypeCheck((x), &Media_Type)) +#define MediaObj_Check(x) (Py_TYPE(x) == &Media_Type || PyObject_TypeCheck((x), &Media_Type)) typedef struct MediaObject { PyObject_HEAD @@ -2241,7 +2241,7 @@ static void MediaObj_dealloc(MediaObject *self) { if (self->ob_itself) DisposeTrackMedia(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *MediaObj_LoadMediaIntoRam(MediaObject *_self, PyObject *_args) @@ -3443,7 +3443,7 @@ PyTypeObject Track_Type; -#define TrackObj_Check(x) (Py_Type(x) == &Track_Type || PyObject_TypeCheck((x), &Track_Type)) +#define TrackObj_Check(x) (Py_TYPE(x) == &Track_Type || PyObject_TypeCheck((x), &Track_Type)) typedef struct TrackObject { PyObject_HEAD @@ -3482,7 +3482,7 @@ static void TrackObj_dealloc(TrackObject *self) { if (self->ob_itself) DisposeMovieTrack(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *TrackObj_LoadTrackIntoRam(TrackObject *_self, PyObject *_args) @@ -4790,7 +4790,7 @@ PyTypeObject Movie_Type; -#define MovieObj_Check(x) (Py_Type(x) == &Movie_Type || PyObject_TypeCheck((x), &Movie_Type)) +#define MovieObj_Check(x) (Py_TYPE(x) == &Movie_Type || PyObject_TypeCheck((x), &Movie_Type)) typedef struct MovieObject { PyObject_HEAD @@ -4829,7 +4829,7 @@ static void MovieObj_dealloc(MovieObject *self) { if (self->ob_itself) DisposeMovie(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *MovieObj_MoviesTask(MovieObject *_self, PyObject *_args) @@ -7342,7 +7342,7 @@ PyTypeObject SGOutput_Type; -#define SGOutputObj_Check(x) (Py_Type(x) == &SGOutput_Type || PyObject_TypeCheck((x), &SGOutput_Type)) +#define SGOutputObj_Check(x) (Py_TYPE(x) == &SGOutput_Type || PyObject_TypeCheck((x), &SGOutput_Type)) typedef struct SGOutputObject { PyObject_HEAD @@ -7381,7 +7381,7 @@ static void SGOutputObj_dealloc(SGOutputObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyMethodDef SGOutputObj_methods[] = { @@ -28013,56 +28013,56 @@ if (Qt_Error == NULL || PyDict_SetItemString(d, "Error", Qt_Error) != 0) return; - Py_Type(&IdleManager_Type) = &PyType_Type; + Py_TYPE(&IdleManager_Type) = &PyType_Type; if (PyType_Ready(&IdleManager_Type) < 0) return; Py_INCREF(&IdleManager_Type); PyModule_AddObject(m, "IdleManager", (PyObject *)&IdleManager_Type); /* Backward-compatible name */ Py_INCREF(&IdleManager_Type); PyModule_AddObject(m, "IdleManagerType", (PyObject *)&IdleManager_Type); - Py_Type(&MovieController_Type) = &PyType_Type; + Py_TYPE(&MovieController_Type) = &PyType_Type; if (PyType_Ready(&MovieController_Type) < 0) return; Py_INCREF(&MovieController_Type); PyModule_AddObject(m, "MovieController", (PyObject *)&MovieController_Type); /* Backward-compatible name */ Py_INCREF(&MovieController_Type); PyModule_AddObject(m, "MovieControllerType", (PyObject *)&MovieController_Type); - Py_Type(&TimeBase_Type) = &PyType_Type; + Py_TYPE(&TimeBase_Type) = &PyType_Type; if (PyType_Ready(&TimeBase_Type) < 0) return; Py_INCREF(&TimeBase_Type); PyModule_AddObject(m, "TimeBase", (PyObject *)&TimeBase_Type); /* Backward-compatible name */ Py_INCREF(&TimeBase_Type); PyModule_AddObject(m, "TimeBaseType", (PyObject *)&TimeBase_Type); - Py_Type(&UserData_Type) = &PyType_Type; + Py_TYPE(&UserData_Type) = &PyType_Type; if (PyType_Ready(&UserData_Type) < 0) return; Py_INCREF(&UserData_Type); PyModule_AddObject(m, "UserData", (PyObject *)&UserData_Type); /* Backward-compatible name */ Py_INCREF(&UserData_Type); PyModule_AddObject(m, "UserDataType", (PyObject *)&UserData_Type); - Py_Type(&Media_Type) = &PyType_Type; + Py_TYPE(&Media_Type) = &PyType_Type; if (PyType_Ready(&Media_Type) < 0) return; Py_INCREF(&Media_Type); PyModule_AddObject(m, "Media", (PyObject *)&Media_Type); /* Backward-compatible name */ Py_INCREF(&Media_Type); PyModule_AddObject(m, "MediaType", (PyObject *)&Media_Type); - Py_Type(&Track_Type) = &PyType_Type; + Py_TYPE(&Track_Type) = &PyType_Type; if (PyType_Ready(&Track_Type) < 0) return; Py_INCREF(&Track_Type); PyModule_AddObject(m, "Track", (PyObject *)&Track_Type); /* Backward-compatible name */ Py_INCREF(&Track_Type); PyModule_AddObject(m, "TrackType", (PyObject *)&Track_Type); - Py_Type(&Movie_Type) = &PyType_Type; + Py_TYPE(&Movie_Type) = &PyType_Type; if (PyType_Ready(&Movie_Type) < 0) return; Py_INCREF(&Movie_Type); PyModule_AddObject(m, "Movie", (PyObject *)&Movie_Type); /* Backward-compatible name */ Py_INCREF(&Movie_Type); PyModule_AddObject(m, "MovieType", (PyObject *)&Movie_Type); - Py_Type(&SGOutput_Type) = &PyType_Type; + Py_TYPE(&SGOutput_Type) = &PyType_Type; if (PyType_Ready(&SGOutput_Type) < 0) return; Py_INCREF(&SGOutput_Type); PyModule_AddObject(m, "SGOutput", (PyObject *)&SGOutput_Type); Modified: python/branches/py3k/Mac/Modules/res/_Resmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/res/_Resmodule.c (original) +++ python/branches/py3k/Mac/Modules/res/_Resmodule.c Wed Dec 19 03:45:37 2007 @@ -41,7 +41,7 @@ PyTypeObject Resource_Type; -#define ResObj_Check(x) (Py_Type(x) == &Resource_Type || PyObject_TypeCheck((x), &Resource_Type)) +#define ResObj_Check(x) (Py_TYPE(x) == &Resource_Type || PyObject_TypeCheck((x), &Resource_Type)) typedef struct ResourceObject { PyObject_HEAD @@ -89,7 +89,7 @@ self->ob_freeit(self->ob_itself); } self->ob_itself = NULL; - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *ResObj_HomeResFile(ResourceObject *_self, PyObject *_args) @@ -1730,7 +1730,7 @@ if (Res_Error == NULL || PyDict_SetItemString(d, "Error", Res_Error) != 0) return; - Py_Type(&Resource_Type) = &PyType_Type; + Py_TYPE(&Resource_Type) = &PyType_Type; if (PyType_Ready(&Resource_Type) < 0) return; Py_INCREF(&Resource_Type); PyModule_AddObject(m, "Resource", (PyObject *)&Resource_Type); Modified: python/branches/py3k/Mac/Modules/scrap/_Scrapmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/scrap/_Scrapmodule.c (original) +++ python/branches/py3k/Mac/Modules/scrap/_Scrapmodule.c Wed Dec 19 03:45:37 2007 @@ -23,7 +23,7 @@ PyTypeObject Scrap_Type; -#define ScrapObj_Check(x) (Py_Type(x) == &Scrap_Type || PyObject_TypeCheck((x), &Scrap_Type)) +#define ScrapObj_Check(x) (Py_TYPE(x) == &Scrap_Type || PyObject_TypeCheck((x), &Scrap_Type)) typedef struct ScrapObject { PyObject_HEAD @@ -52,7 +52,7 @@ static void ScrapObj_dealloc(ScrapObject *self) { /* Cleanup of self->ob_itself goes here */ - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *ScrapObj_GetScrapFlavorFlags(ScrapObject *_self, PyObject *_args) @@ -346,7 +346,7 @@ if (Scrap_Error == NULL || PyDict_SetItemString(d, "Error", Scrap_Error) != 0) return; - Py_Type(&Scrap_Type) = &PyType_Type; + Py_TYPE(&Scrap_Type) = &PyType_Type; Py_INCREF(&Scrap_Type); if (PyDict_SetItemString(d, "ScrapType", (PyObject *)&Scrap_Type) != 0) Py_FatalError("can't initialize ScrapType"); Modified: python/branches/py3k/Mac/Modules/snd/_Sndmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/snd/_Sndmodule.c (original) +++ python/branches/py3k/Mac/Modules/snd/_Sndmodule.c Wed Dec 19 03:45:37 2007 @@ -42,7 +42,7 @@ static PyTypeObject SndChannel_Type; -#define SndCh_Check(x) (Py_Type(x) == &SndChannel_Type || PyObject_TypeCheck((x), &SndChannel_Type)) +#define SndCh_Check(x) (Py_TYPE(x) == &SndChannel_Type || PyObject_TypeCheck((x), &SndChannel_Type)) typedef struct SndChannelObject { PyObject_HEAD @@ -256,7 +256,7 @@ static PyTypeObject SPB_Type; -#define SPBObj_Check(x) (Py_Type(x) == &SPB_Type || PyObject_TypeCheck((x), &SPB_Type)) +#define SPBObj_Check(x) (Py_TYPE(x) == &SPB_Type || PyObject_TypeCheck((x), &SPB_Type)) typedef struct SPBObject { PyObject_HEAD @@ -1129,14 +1129,14 @@ if (Snd_Error == NULL || PyDict_SetItemString(d, "Error", Snd_Error) != 0) return; - Py_Type(&SndChannel_Type) = &PyType_Type; + Py_TYPE(&SndChannel_Type) = &PyType_Type; if (PyType_Ready(&SndChannel_Type) < 0) return; Py_INCREF(&SndChannel_Type); PyModule_AddObject(m, "SndChannel", (PyObject *)&SndChannel_Type); /* Backward-compatible name */ Py_INCREF(&SndChannel_Type); PyModule_AddObject(m, "SndChannelType", (PyObject *)&SndChannel_Type); - Py_Type(&SPB_Type) = &PyType_Type; + Py_TYPE(&SPB_Type) = &PyType_Type; if (PyType_Ready(&SPB_Type) < 0) return; Py_INCREF(&SPB_Type); PyModule_AddObject(m, "SPB", (PyObject *)&SPB_Type); Modified: python/branches/py3k/Mac/Modules/te/_TEmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/te/_TEmodule.c (original) +++ python/branches/py3k/Mac/Modules/te/_TEmodule.c Wed Dec 19 03:45:37 2007 @@ -58,7 +58,7 @@ PyTypeObject TE_Type; -#define TEObj_Check(x) (Py_Type(x) == &TE_Type || PyObject_TypeCheck((x), &TE_Type)) +#define TEObj_Check(x) (Py_TYPE(x) == &TE_Type || PyObject_TypeCheck((x), &TE_Type)) typedef struct TEObject { PyObject_HEAD @@ -92,7 +92,7 @@ static void TEObj_dealloc(TEObject *self) { TEDispose(self->ob_itself); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *TEObj_TESetText(TEObject *_self, PyObject *_args) @@ -1317,7 +1317,7 @@ if (TE_Error == NULL || PyDict_SetItemString(d, "Error", TE_Error) != 0) return; - Py_Type(&TE_Type) = &PyType_Type; + Py_TYPE(&TE_Type) = &PyType_Type; if (PyType_Ready(&TE_Type) < 0) return; Py_INCREF(&TE_Type); PyModule_AddObject(m, "TE", (PyObject *)&TE_Type); Modified: python/branches/py3k/Mac/Modules/win/_Winmodule.c ============================================================================== --- python/branches/py3k/Mac/Modules/win/_Winmodule.c (original) +++ python/branches/py3k/Mac/Modules/win/_Winmodule.c Wed Dec 19 03:45:37 2007 @@ -45,7 +45,7 @@ PyTypeObject Window_Type; -#define WinObj_Check(x) (Py_Type(x) == &Window_Type || PyObject_TypeCheck((x), &Window_Type)) +#define WinObj_Check(x) (Py_TYPE(x) == &Window_Type || PyObject_TypeCheck((x), &Window_Type)) typedef struct WindowObject { PyObject_HEAD @@ -102,7 +102,7 @@ } self->ob_itself = NULL; self->ob_freeit = NULL; - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject *WinObj_GetWindowOwnerCount(WindowObject *_self, PyObject *_args) @@ -3244,7 +3244,7 @@ if (Win_Error == NULL || PyDict_SetItemString(d, "Error", Win_Error) != 0) return; - Py_Type(&Window_Type) = &PyType_Type; + Py_TYPE(&Window_Type) = &PyType_Type; if (PyType_Ready(&Window_Type) < 0) return; Py_INCREF(&Window_Type); PyModule_AddObject(m, "Window", (PyObject *)&Window_Type); Modified: python/branches/py3k/Modules/_bsddb.c ============================================================================== --- python/branches/py3k/Modules/_bsddb.c (original) +++ python/branches/py3k/Modules/_bsddb.c Wed Dec 19 03:45:37 2007 @@ -203,13 +203,13 @@ static PyTypeObject DB_Type, DBCursor_Type, DBEnv_Type, DBTxn_Type, DBLock_Type; -#define DBObject_Check(v) (Py_Type(v) == &DB_Type) -#define DBCursorObject_Check(v) (Py_Type(v) == &DBCursor_Type) -#define DBEnvObject_Check(v) (Py_Type(v) == &DBEnv_Type) -#define DBTxnObject_Check(v) (Py_Type(v) == &DBTxn_Type) -#define DBLockObject_Check(v) (Py_Type(v) == &DBLock_Type) +#define DBObject_Check(v) (Py_TYPE(v) == &DB_Type) +#define DBCursorObject_Check(v) (Py_TYPE(v) == &DBCursor_Type) +#define DBEnvObject_Check(v) (Py_TYPE(v) == &DBEnv_Type) +#define DBTxnObject_Check(v) (Py_TYPE(v) == &DBTxn_Type) +#define DBLockObject_Check(v) (Py_TYPE(v) == &DBLock_Type) #if (DBVER >= 43) -#define DBSequenceObject_Check(v) (Py_Type(v) == &DBSequence_Type) +#define DBSequenceObject_Check(v) (Py_TYPE(v) == &DBSequence_Type) #endif @@ -461,7 +461,7 @@ else { PyErr_Format(PyExc_TypeError, "buffer or int object expected for key, %s found", - Py_Type(keyobj)->tp_name); + Py_TYPE(keyobj)->tp_name); return 0; } @@ -611,7 +611,7 @@ static void makeTypeError(char* expected, PyObject* found) { PyErr_Format(PyExc_TypeError, "Expected %s argument, %s found.", - expected, Py_Type(found)->tp_name); + expected, Py_TYPE(found)->tp_name); } @@ -1176,7 +1176,7 @@ Py_ssize_t size; CLEAR_DBT(*secKey); - size = Py_Size(result); + size = Py_SIZE(result); if (PyBytes_Check(result)) data = PyBytes_AS_STRING(result); else @@ -5656,13 +5656,13 @@ /* Initialize the type of the new type objects here; doing it here is required for portability to Windows without requiring C++. */ - Py_Type(&DB_Type) = &PyType_Type; - Py_Type(&DBCursor_Type) = &PyType_Type; - Py_Type(&DBEnv_Type) = &PyType_Type; - Py_Type(&DBTxn_Type) = &PyType_Type; - Py_Type(&DBLock_Type) = &PyType_Type; + Py_TYPE(&DB_Type) = &PyType_Type; + Py_TYPE(&DBCursor_Type) = &PyType_Type; + Py_TYPE(&DBEnv_Type) = &PyType_Type; + Py_TYPE(&DBTxn_Type) = &PyType_Type; + Py_TYPE(&DBLock_Type) = &PyType_Type; #if (DBVER >= 43) - Py_Type(&DBSequence_Type) = &PyType_Type; + Py_TYPE(&DBSequence_Type) = &PyType_Type; #endif Modified: python/branches/py3k/Modules/_collectionsmodule.c ============================================================================== --- python/branches/py3k/Modules/_collectionsmodule.c (original) +++ python/branches/py3k/Modules/_collectionsmodule.c Wed Dec 19 03:45:37 2007 @@ -583,7 +583,7 @@ } deque->leftblock = NULL; deque->rightblock = NULL; - Py_Type(deque)->tp_free(deque); + Py_TYPE(deque)->tp_free(deque); } static int @@ -619,9 +619,9 @@ deque_copy(PyObject *deque) { if (((dequeobject *)deque)->maxlen == -1) - return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "O", deque, NULL); + return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "O", deque, NULL); else - return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "Oi", + return PyObject_CallFunction((PyObject *)(Py_TYPE(deque)), "Oi", deque, ((dequeobject *)deque)->maxlen, NULL); } @@ -642,14 +642,14 @@ } if (dict == NULL) { if (deque->maxlen == -1) - result = Py_BuildValue("O(O)", Py_Type(deque), aslist); + result = Py_BuildValue("O(O)", Py_TYPE(deque), aslist); else - result = Py_BuildValue("O(Oi)", Py_Type(deque), aslist, deque->maxlen); + result = Py_BuildValue("O(Oi)", Py_TYPE(deque), aslist, deque->maxlen); } else { if (deque->maxlen == -1) - result = Py_BuildValue("O(OO)O", Py_Type(deque), aslist, Py_None, dict); + result = Py_BuildValue("O(OO)O", Py_TYPE(deque), aslist, Py_None, dict); else - result = Py_BuildValue("O(Oi)O", Py_Type(deque), aslist, deque->maxlen, dict); + result = Py_BuildValue("O(Oi)O", Py_TYPE(deque), aslist, deque->maxlen, dict); } Py_XDECREF(dict); Py_DECREF(aslist); @@ -921,7 +921,7 @@ dequeiter_dealloc(dequeiterobject *dio) { Py_XDECREF(dio->deque); - Py_Type(dio)->tp_free(dio); + Py_TYPE(dio)->tp_free(dio); } static PyObject * @@ -1129,7 +1129,7 @@ whose class constructor has the same signature. Subclasses that define a different constructor signature must override copy(). */ - return PyObject_CallFunctionObjArgs((PyObject*)Py_Type(dd), + return PyObject_CallFunctionObjArgs((PyObject*)Py_TYPE(dd), dd->default_factory, dd, NULL); } @@ -1172,7 +1172,7 @@ Py_DECREF(args); return NULL; } - result = PyTuple_Pack(5, Py_Type(dd), args, + result = PyTuple_Pack(5, Py_TYPE(dd), args, Py_None, Py_None, items); Py_DECREF(items); Py_DECREF(args); Modified: python/branches/py3k/Modules/_csv.c ============================================================================== --- python/branches/py3k/Modules/_csv.c (original) +++ python/branches/py3k/Modules/_csv.c Wed Dec 19 03:45:37 2007 @@ -81,7 +81,7 @@ static PyTypeObject Reader_Type; -#define ReaderObject_Check(v) (Py_Type(v) == &Reader_Type) +#define ReaderObject_Check(v) (Py_TYPE(v) == &Reader_Type) typedef struct { PyObject_HEAD @@ -284,7 +284,7 @@ Dialect_dealloc(DialectObj *self) { Py_XDECREF(self->lineterminator); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static char *dialect_kws[] = { Modified: python/branches/py3k/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/_ctypes.c (original) +++ python/branches/py3k/Modules/_ctypes/_ctypes.c Wed Dec 19 03:45:37 2007 @@ -328,7 +328,7 @@ Py_INCREF(value); return value; } - ob_name = (ob) ? Py_Type(ob)->tp_name : "???"; + ob_name = (ob) ? Py_TYPE(ob)->tp_name : "???"; PyErr_Format(PyExc_TypeError, "expected %s instance instead of pointer to %s", ((PyTypeObject *)type)->tp_name, ob_name); @@ -344,7 +344,7 @@ PyErr_Format(PyExc_TypeError, "expected %s instance instead of %s", ((PyTypeObject *)type)->tp_name, - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return NULL; } @@ -798,7 +798,7 @@ } else if (!PyString_Check(value)) { PyErr_Format(PyExc_TypeError, "str/bytes expected instead of %s instance", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } else Py_INCREF(value); @@ -858,7 +858,7 @@ } else if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "unicode string expected instead of %s instance", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } else Py_INCREF(value); @@ -2075,7 +2075,7 @@ CData_dealloc(PyObject *self) { CData_clear((CDataObject *)self); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyMemberDef CData_members[] = { @@ -2334,7 +2334,7 @@ PyErr_Format(PyExc_TypeError, "expected %s instance, got %s", ((PyTypeObject *)type)->tp_name, - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return NULL; } } @@ -2365,7 +2365,7 @@ if (p1->proto != p2->proto) { PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", - Py_Type(value)->tp_name, + Py_TYPE(value)->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; } @@ -2384,7 +2384,7 @@ } PyErr_Format(PyExc_TypeError, "incompatible types, %s instance instead of %s instance", - Py_Type(value)->tp_name, + Py_TYPE(value)->tp_name, ((PyTypeObject *)type)->tp_name); return NULL; } @@ -2645,7 +2645,7 @@ Py_SAFE_DOWNCAST(index, Py_ssize_t, int), PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name : - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); return 0; } @@ -3430,7 +3430,7 @@ CFuncPtr_dealloc(CFuncPtrObject *self) { CFuncPtr_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * @@ -3440,11 +3440,11 @@ if (self->index) return PyUnicode_FromFormat("", self->index - 0x1000, - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, self); #endif return PyUnicode_FromFormat("<%s object at %p>", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, self); } @@ -4078,7 +4078,7 @@ static PyObject * Simple_from_outparm(PyObject *self, PyObject *args) { - if (IsSimpleSubType((PyObject *)Py_Type(self))) { + if (IsSimpleSubType((PyObject *)Py_TYPE(self))) { Py_INCREF(self); return self; } @@ -4116,9 +4116,9 @@ PyObject *val, *name, *args, *result; static PyObject *format; - if (Py_Type(self)->tp_base != &Simple_Type) { + if (Py_TYPE(self)->tp_base != &Simple_Type) { return PyUnicode_FromFormat("<%s object at %p>", - Py_Type(self)->tp_name, self); + Py_TYPE(self)->tp_name, self); } if (format == NULL) { @@ -4131,7 +4131,7 @@ if (val == NULL) return NULL; - name = PyUnicode_FromString(Py_Type(self)->tp_name); + name = PyUnicode_FromString(Py_TYPE(self)->tp_name); if (name == NULL) { Py_DECREF(val); return NULL; @@ -4302,7 +4302,7 @@ PyErr_Format(PyExc_TypeError, "expected %s instead of %s", ((PyTypeObject *)(stgdict->proto))->tp_name, - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } @@ -4588,7 +4588,7 @@ PyObject *a; int status; - if (!_PyArg_NoKeywords(Py_Type(self)->tp_name, kwds)) + if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) return -1; if (!PyArg_ParseTuple(args, "OOO:COMError", &hresult, &text, &details)) @@ -4703,7 +4703,7 @@ "cast() argument 2 must be a pointer type, not %s", PyType_Check(arg) ? ((PyTypeObject *)arg)->tp_name - : Py_Type(arg)->tp_name); + : Py_TYPE(arg)->tp_name); return 0; } @@ -4830,37 +4830,37 @@ if (PyType_Ready(&CData_Type) < 0) return; - Py_Type(&Struct_Type) = &StructType_Type; + Py_TYPE(&Struct_Type) = &StructType_Type; Struct_Type.tp_base = &CData_Type; if (PyType_Ready(&Struct_Type) < 0) return; PyModule_AddObject(m, "Structure", (PyObject *)&Struct_Type); - Py_Type(&Union_Type) = &UnionType_Type; + Py_TYPE(&Union_Type) = &UnionType_Type; Union_Type.tp_base = &CData_Type; if (PyType_Ready(&Union_Type) < 0) return; PyModule_AddObject(m, "Union", (PyObject *)&Union_Type); - Py_Type(&Pointer_Type) = &PointerType_Type; + Py_TYPE(&Pointer_Type) = &PointerType_Type; Pointer_Type.tp_base = &CData_Type; if (PyType_Ready(&Pointer_Type) < 0) return; PyModule_AddObject(m, "_Pointer", (PyObject *)&Pointer_Type); - Py_Type(&Array_Type) = &ArrayType_Type; + Py_TYPE(&Array_Type) = &ArrayType_Type; Array_Type.tp_base = &CData_Type; if (PyType_Ready(&Array_Type) < 0) return; PyModule_AddObject(m, "Array", (PyObject *)&Array_Type); - Py_Type(&Simple_Type) = &SimpleType_Type; + Py_TYPE(&Simple_Type) = &SimpleType_Type; Simple_Type.tp_base = &CData_Type; if (PyType_Ready(&Simple_Type) < 0) return; PyModule_AddObject(m, "_SimpleCData", (PyObject *)&Simple_Type); - Py_Type(&CFuncPtr_Type) = &CFuncPtrType_Type; + Py_TYPE(&CFuncPtr_Type) = &CFuncPtrType_Type; CFuncPtr_Type.tp_base = &CData_Type; if (PyType_Ready(&CFuncPtr_Type) < 0) return; Modified: python/branches/py3k/Modules/_ctypes/callproc.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/callproc.c (original) +++ python/branches/py3k/Modules/_ctypes/callproc.c Wed Dec 19 03:45:37 2007 @@ -1153,7 +1153,7 @@ if (!CDataObject_Check(pcom) || (pcom->b_size != sizeof(void *))) { PyErr_Format(PyExc_TypeError, "COM Pointer expected instead of %s instance", - Py_Type(pcom)->tp_name); + Py_TYPE(pcom)->tp_name); return NULL; } @@ -1393,7 +1393,7 @@ if (!CDataObject_Check(obj)) { PyErr_Format(PyExc_TypeError, "byref() argument must be a ctypes instance, not '%s'", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); return NULL; } Modified: python/branches/py3k/Modules/_ctypes/cfield.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/cfield.c (original) +++ python/branches/py3k/Modules/_ctypes/cfield.c Wed Dec 19 03:45:37 2007 @@ -1349,7 +1349,7 @@ data = PyString_AS_STRING(value); if (!data) return NULL; - size = strlen(data); /* XXX Why not Py_Size(value)? */ + size = strlen(data); /* XXX Why not Py_SIZE(value)? */ if (size < length) { /* This will copy the leading NUL character * if there is space for it. Modified: python/branches/py3k/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/py3k/Modules/_ctypes/stgdict.c (original) +++ python/branches/py3k/Modules/_ctypes/stgdict.c Wed Dec 19 03:45:37 2007 @@ -183,7 +183,7 @@ Py_DECREF(fieldlist); return -1; } - if (Py_Type(fdescr) != &CField_Type) { + if (Py_TYPE(fdescr) != &CField_Type) { PyErr_SetString(PyExc_TypeError, "unexpected type"); Py_DECREF(fdescr); Py_DECREF(fieldlist); @@ -206,7 +206,7 @@ Py_DECREF(fieldlist); return -1; } - assert(Py_Type(new_descr) == &CField_Type); + assert(Py_TYPE(new_descr) == &CField_Type); new_descr->size = fdescr->size; new_descr->offset = fdescr->offset + offset; new_descr->index = fdescr->index + index; @@ -254,7 +254,7 @@ Py_DECREF(anon_names); return -1; } - assert(Py_Type(descr) == &CField_Type); + assert(Py_TYPE(descr) == &CField_Type); descr->anonymous = 1; /* descr is in the field descriptor. */ Modified: python/branches/py3k/Modules/_curses_panel.c ============================================================================== --- python/branches/py3k/Modules/_curses_panel.c (original) +++ python/branches/py3k/Modules/_curses_panel.c Wed Dec 19 03:45:37 2007 @@ -56,7 +56,7 @@ PyTypeObject PyCursesPanel_Type; -#define PyCursesPanel_Check(v) (Py_Type(v) == &PyCursesPanel_Type) +#define PyCursesPanel_Check(v) (Py_TYPE(v) == &PyCursesPanel_Type) /* Some helper functions. The problem is that there's always a window associated with a panel. To ensure that Python's GC doesn't pull @@ -457,7 +457,7 @@ PyObject *m, *d, *v; /* Initialize object type */ - Py_Type(&PyCursesPanel_Type) = &PyType_Type; + Py_TYPE(&PyCursesPanel_Type) = &PyType_Type; import_curses(); Modified: python/branches/py3k/Modules/_cursesmodule.c ============================================================================== --- python/branches/py3k/Modules/_cursesmodule.c (original) +++ python/branches/py3k/Modules/_cursesmodule.c Wed Dec 19 03:45:37 2007 @@ -2709,7 +2709,7 @@ static void *PyCurses_API[PyCurses_API_pointers]; /* Initialize object type */ - Py_Type(&PyCursesWindow_Type) = &PyType_Type; + Py_TYPE(&PyCursesWindow_Type) = &PyType_Type; /* Initialize the C API pointer array */ PyCurses_API[0] = (void *)&PyCursesWindow_Type; Modified: python/branches/py3k/Modules/_elementtree.c ============================================================================== --- python/branches/py3k/Modules/_elementtree.c (original) +++ python/branches/py3k/Modules/_elementtree.c Wed Dec 19 03:45:37 2007 @@ -248,7 +248,7 @@ static PyTypeObject Element_Type; -#define Element_CheckExact(op) (Py_Type(op) == &Element_Type) +#define Element_CheckExact(op) (Py_TYPE(op) == &Element_Type) /* -------------------------------------------------------------------- */ /* element constructor and destructor */ @@ -1174,7 +1174,7 @@ /* FIXME: support arbitrary sequences? */ PyErr_Format( PyExc_TypeError, - "expected list, not \"%.200s\"", Py_Type(item)->tp_name + "expected list, not \"%.200s\"", Py_TYPE(item)->tp_name ); return -1; } @@ -1407,7 +1407,7 @@ static PyTypeObject TreeBuilder_Type; -#define TreeBuilder_CheckExact(op) (Py_Type(op) == &TreeBuilder_Type) +#define TreeBuilder_CheckExact(op) (Py_TYPE(op) == &TreeBuilder_Type) /* -------------------------------------------------------------------- */ /* constructor and destructor */ @@ -1574,7 +1574,7 @@ Py_INCREF(data); self->data = data; } else { /* more than one item; use a list to collect items */ - if (PyString_CheckExact(self->data) && Py_Refcnt(self->data) == 1 && + if (PyString_CheckExact(self->data) && Py_REFCNT(self->data) == 1 && PyString_CheckExact(data) && PyString_GET_SIZE(data) == 1) { /* expat often generates single character data sections; handle the most common case by resizing the existing string... */ @@ -2550,9 +2550,9 @@ #endif /* Patch object type */ - Py_Type(&Element_Type) = Py_Type(&TreeBuilder_Type) = &PyType_Type; + Py_TYPE(&Element_Type) = Py_TYPE(&TreeBuilder_Type) = &PyType_Type; #if defined(USE_EXPAT) - Py_Type(&XMLParser_Type) = &PyType_Type; + Py_TYPE(&XMLParser_Type) = &PyType_Type; #endif m = Py_InitModule("_elementtree", _functions); Modified: python/branches/py3k/Modules/_fileio.c ============================================================================== --- python/branches/py3k/Modules/_fileio.c (original) +++ python/branches/py3k/Modules/_fileio.c Wed Dec 19 03:45:37 2007 @@ -304,7 +304,7 @@ } } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * Modified: python/branches/py3k/Modules/_functoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/_functoolsmodule.c (original) +++ python/branches/py3k/Modules/_functoolsmodule.c Wed Dec 19 03:45:37 2007 @@ -81,7 +81,7 @@ Py_XDECREF(pto->args); Py_XDECREF(pto->kw); Py_XDECREF(pto->dict); - Py_Type(pto)->tp_free(pto); + Py_TYPE(pto)->tp_free(pto); } static PyObject * Modified: python/branches/py3k/Modules/_hashopenssl.c ============================================================================== --- python/branches/py3k/Modules/_hashopenssl.c (original) +++ python/branches/py3k/Modules/_hashopenssl.c Wed Dec 19 03:45:37 2007 @@ -510,7 +510,7 @@ * but having some be unsupported. Only init appropriate * constants. */ - Py_Type(&EVPtype) = &PyType_Type; + Py_TYPE(&EVPtype) = &PyType_Type; if (PyType_Ready(&EVPtype) < 0) return; Modified: python/branches/py3k/Modules/_lsprof.c ============================================================================== --- python/branches/py3k/Modules/_lsprof.c (original) +++ python/branches/py3k/Modules/_lsprof.c Wed Dec 19 03:45:37 2007 @@ -120,7 +120,7 @@ static PyTypeObject PyProfiler_Type; #define PyProfiler_Check(op) PyObject_TypeCheck(op, &PyProfiler_Type) -#define PyProfiler_CheckExact(op) (Py_Type(op) == &PyProfiler_Type) +#define PyProfiler_CheckExact(op) (Py_TYPE(op) == &PyProfiler_Type) /*** External Timers ***/ @@ -207,7 +207,7 @@ PyObject *self = fn->m_self; PyObject *name = PyUnicode_FromString(fn->m_ml->ml_name); if (name != NULL) { - PyObject *mo = _PyType_Lookup(Py_Type(self), name); + PyObject *mo = _PyType_Lookup(Py_TYPE(self), name); Py_XINCREF(mo); Py_DECREF(name); if (mo != NULL) { @@ -756,7 +756,7 @@ flush_unmatched(op); clearEntries(op); Py_XDECREF(op->externalTimer); - Py_Type(op)->tp_free(op); + Py_TYPE(op)->tp_free(op); } static int Modified: python/branches/py3k/Modules/_randommodule.c ============================================================================== --- python/branches/py3k/Modules/_randommodule.c (original) +++ python/branches/py3k/Modules/_randommodule.c Wed Dec 19 03:45:37 2007 @@ -84,7 +84,7 @@ static PyTypeObject Random_Type; -#define RandomObject_Check(v) (Py_Type(v) == &Random_Type) +#define RandomObject_Check(v) (Py_TYPE(v) == &Random_Type) /* Random methods */ @@ -405,7 +405,7 @@ if (!PyLong_Check(n)) { PyErr_Format(PyExc_TypeError, "jumpahead requires an " "integer, not '%s'", - Py_Type(n)->tp_name); + Py_TYPE(n)->tp_name); return NULL; } Modified: python/branches/py3k/Modules/_sqlite/cache.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/cache.c (original) +++ python/branches/py3k/Modules/_sqlite/cache.c Wed Dec 19 03:45:37 2007 @@ -51,7 +51,7 @@ Py_DECREF(self->key); Py_DECREF(self->data); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs) @@ -109,7 +109,7 @@ } Py_DECREF(self->mapping); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args) Modified: python/branches/py3k/Modules/_sqlite/connection.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/connection.c (original) +++ python/branches/py3k/Modules/_sqlite/connection.c Wed Dec 19 03:45:37 2007 @@ -205,7 +205,7 @@ Py_XDECREF(self->collations); Py_XDECREF(self->statements); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyObject* pysqlite_connection_cursor(pysqlite_Connection* self, PyObject* args, PyObject* kwargs) Modified: python/branches/py3k/Modules/_sqlite/cursor.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/cursor.c (original) +++ python/branches/py3k/Modules/_sqlite/cursor.c Wed Dec 19 03:45:37 2007 @@ -134,7 +134,7 @@ Py_XDECREF(self->row_factory); Py_XDECREF(self->next_row); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyObject* _pysqlite_get_converter(PyObject* key) Modified: python/branches/py3k/Modules/_sqlite/prepare_protocol.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/prepare_protocol.c (original) +++ python/branches/py3k/Modules/_sqlite/prepare_protocol.c Wed Dec 19 03:45:37 2007 @@ -30,7 +30,7 @@ void pysqlite_prepare_protocol_dealloc(pysqlite_PrepareProtocol* self) { - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } PyTypeObject pysqlite_PrepareProtocolType= { @@ -78,6 +78,6 @@ extern int pysqlite_prepare_protocol_setup_types(void) { pysqlite_PrepareProtocolType.tp_new = PyType_GenericNew; - Py_Type(&pysqlite_PrepareProtocolType)= &PyType_Type; + Py_TYPE(&pysqlite_PrepareProtocolType)= &PyType_Type; return PyType_Ready(&pysqlite_PrepareProtocolType); } Modified: python/branches/py3k/Modules/_sqlite/row.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/row.c (original) +++ python/branches/py3k/Modules/_sqlite/row.c Wed Dec 19 03:45:37 2007 @@ -30,7 +30,7 @@ Py_XDECREF(self->data); Py_XDECREF(self->description); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } int pysqlite_row_init(pysqlite_Row* self, PyObject* args, PyObject* kwargs) Modified: python/branches/py3k/Modules/_sqlite/statement.c ============================================================================== --- python/branches/py3k/Modules/_sqlite/statement.c (original) +++ python/branches/py3k/Modules/_sqlite/statement.c Wed Dec 19 03:45:37 2007 @@ -307,7 +307,7 @@ PyObject_ClearWeakRefs((PyObject*)self); } - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } /* Modified: python/branches/py3k/Modules/_sre.c ============================================================================== --- python/branches/py3k/Modules/_sre.c (original) +++ python/branches/py3k/Modules/_sre.c Wed Dec 19 03:45:37 2007 @@ -1685,7 +1685,7 @@ /* get pointer to string buffer */ view.len = -1; - buffer = Py_Type(string)->tp_as_buffer; + buffer = Py_TYPE(string)->tp_as_buffer; if (!buffer || !buffer->bf_getbuffer || (*buffer->bf_getbuffer)(string, &view, PyBUF_SIMPLE) < 0) { PyErr_SetString(PyExc_TypeError, "expected string or buffer"); Modified: python/branches/py3k/Modules/_ssl.c ============================================================================== --- python/branches/py3k/Modules/_ssl.c (original) +++ python/branches/py3k/Modules/_ssl.c Wed Dec 19 03:45:37 2007 @@ -127,7 +127,7 @@ static PyObject *PySSL_peercert(PySSLObject *self, PyObject *args); static PyObject *PySSL_cipher(PySSLObject *self); -#define PySSLObject_Check(v) (Py_Type(v) == &PySSL_Type) +#define PySSLObject_Check(v) (Py_TYPE(v) == &PySSL_Type) typedef enum { SOCKET_IS_NONBLOCKING, @@ -1451,7 +1451,7 @@ if (!PyUnicode_Check(arg)) return PyErr_Format(PyExc_TypeError, "RAND_egd() expected string, found %s", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); bytes = RAND_egd(PyUnicode_AsString(arg)); if (bytes == -1) { PyErr_SetString(PySSLErrorObject, @@ -1568,7 +1568,7 @@ { PyObject *m, *d; - Py_Type(&PySSL_Type) = &PyType_Type; + Py_TYPE(&PySSL_Type) = &PyType_Type; m = Py_InitModule3("_ssl", PySSL_methods, module_doc); if (m == NULL) Modified: python/branches/py3k/Modules/_struct.c ============================================================================== --- python/branches/py3k/Modules/_struct.c (original) +++ python/branches/py3k/Modules/_struct.c Wed Dec 19 03:45:37 2007 @@ -67,7 +67,7 @@ #define PyStruct_Check(op) PyObject_TypeCheck(op, &PyStructType) -#define PyStruct_CheckExact(op) (Py_Type(op) == &PyStructType) +#define PyStruct_CheckExact(op) (Py_TYPE(op) == &PyStructType) /* Exception */ @@ -126,7 +126,7 @@ Py_INCREF(v); return v; } - m = Py_Type(v)->tp_as_number; + m = Py_TYPE(v)->tp_as_number; if (m != NULL && m->nb_long != NULL) { v = m->nb_long(v); if (v == NULL) @@ -1485,7 +1485,7 @@ PyMem_FREE(s->s_codes); } Py_XDECREF(s->s_format); - Py_Type(s)->tp_free((PyObject *)s); + Py_TYPE(s)->tp_free((PyObject *)s); } static PyObject * @@ -1870,7 +1870,7 @@ if (m == NULL) return; - Py_Type(&PyStructType) = &PyType_Type; + Py_TYPE(&PyStructType) = &PyType_Type; if (PyType_Ready(&PyStructType) < 0) return; Modified: python/branches/py3k/Modules/_testcapimodule.c ============================================================================== --- python/branches/py3k/Modules/_testcapimodule.c (original) +++ python/branches/py3k/Modules/_testcapimodule.c Wed Dec 19 03:45:37 2007 @@ -1057,7 +1057,7 @@ if (m == NULL) return; - Py_Type(&test_structmembersType)=&PyType_Type; + Py_TYPE(&test_structmembersType)=&PyType_Type; Py_INCREF(&test_structmembersType); PyModule_AddObject(m, "test_structmembersType", (PyObject *)&test_structmembersType); Modified: python/branches/py3k/Modules/_tkinter.c ============================================================================== --- python/branches/py3k/Modules/_tkinter.c (original) +++ python/branches/py3k/Modules/_tkinter.c Wed Dec 19 03:45:37 2007 @@ -262,12 +262,12 @@ Tcl_ObjType *StringType; } TkappObject; -#define Tkapp_Check(v) (Py_Type(v) == &Tkapp_Type) +#define Tkapp_Check(v) (Py_TYPE(v) == &Tkapp_Type) #define Tkapp_Interp(v) (((TkappObject *) (v))->interp) #define Tkapp_Result(v) Tcl_GetStringResult(Tkapp_Interp(v)) #define DEBUG_REFCNT(v) (printf("DEBUG: id=%p, refcnt=%i\n", \ -(void *) v, Py_Refcnt(v))) +(void *) v, Py_REFCNT(v))) @@ -3016,7 +3016,7 @@ { PyObject *m, *d; - Py_Type(&Tkapp_Type) = &PyType_Type; + Py_TYPE(&Tkapp_Type) = &PyType_Type; #ifdef WITH_THREAD tcl_lock = PyThread_allocate_lock(); @@ -3044,10 +3044,10 @@ PyDict_SetItemString(d, "TkappType", (PyObject *)&Tkapp_Type); - Py_Type(&Tktt_Type) = &PyType_Type; + Py_TYPE(&Tktt_Type) = &PyType_Type; PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type); - Py_Type(&PyTclObject_Type) = &PyType_Type; + Py_TYPE(&PyTclObject_Type) = &PyType_Type; PyDict_SetItemString(d, "Tcl_Obj", (PyObject *)&PyTclObject_Type); #ifdef TK_AQUA Modified: python/branches/py3k/Modules/_weakref.c ============================================================================== --- python/branches/py3k/Modules/_weakref.c (original) +++ python/branches/py3k/Modules/_weakref.c Wed Dec 19 03:45:37 2007 @@ -14,7 +14,7 @@ { PyObject *result = NULL; - if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { + if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); result = PyLong_FromSsize_t(_PyWeakref_GetWeakrefCount(*list)); @@ -35,7 +35,7 @@ { PyObject *result = NULL; - if (PyType_SUPPORTS_WEAKREFS(Py_Type(object))) { + if (PyType_SUPPORTS_WEAKREFS(Py_TYPE(object))) { PyWeakReference **list = GET_WEAKREFS_LISTPTR(object); Py_ssize_t count = _PyWeakref_GetWeakrefCount(*list); Modified: python/branches/py3k/Modules/arraymodule.c ============================================================================== --- python/branches/py3k/Modules/arraymodule.c (original) +++ python/branches/py3k/Modules/arraymodule.c Wed Dec 19 03:45:37 2007 @@ -41,7 +41,7 @@ static PyTypeObject Arraytype; #define array_Check(op) PyObject_TypeCheck(op, &Arraytype) -#define array_CheckExact(op) (Py_Type(op) == &Arraytype) +#define array_CheckExact(op) (Py_TYPE(op) == &Arraytype) static int array_resize(arrayobject *self, Py_ssize_t newsize) @@ -55,9 +55,9 @@ */ if (self->allocated >= newsize && - Py_Size(self) < newsize + 16 && + Py_SIZE(self) < newsize + 16 && self->ob_item != NULL) { - Py_Size(self) = newsize; + Py_SIZE(self) = newsize; return 0; } @@ -79,7 +79,7 @@ * memory critical. */ - _new_size = (newsize >> 4) + (Py_Size(self) < 8 ? 3 : 7) + newsize; + _new_size = (newsize >> 4) + (Py_SIZE(self) < 8 ? 3 : 7) + newsize; items = self->ob_item; /* XXX The following multiplication and division does not optimize away like it does for lists since the size is not known at compile time */ @@ -92,7 +92,7 @@ return -1; } self->ob_item = items; - Py_Size(self) = newsize; + Py_SIZE(self) = newsize; self->allocated = _new_size; return 0; } @@ -421,7 +421,7 @@ if (op == NULL) { return NULL; } - Py_Size(op) = size; + Py_SIZE(op) = size; if (size <= 0) { op->ob_item = NULL; } @@ -445,7 +445,7 @@ register arrayobject *ap; assert(array_Check(op)); ap = (arrayobject *)op; - assert(i>=0 && i=0 && iob_descr->getitem)(ap, i); } @@ -453,7 +453,7 @@ ins1(arrayobject *self, Py_ssize_t where, PyObject *v) { char *items; - Py_ssize_t n = Py_Size(self); + Py_ssize_t n = Py_SIZE(self); if (v == NULL) { PyErr_BadInternalCall(); return -1; @@ -488,7 +488,7 @@ PyObject_ClearWeakRefs((PyObject *) op); if (op->ob_item != NULL) PyMem_DEL(op->ob_item); - Py_Type(op)->tp_free((PyObject *)op); + Py_TYPE(op)->tp_free((PyObject *)op); } static PyObject * @@ -508,7 +508,7 @@ va = (arrayobject *)v; wa = (arrayobject *)w; - if (Py_Size(va) != Py_Size(wa) && (op == Py_EQ || op == Py_NE)) { + if (Py_SIZE(va) != Py_SIZE(wa) && (op == Py_EQ || op == Py_NE)) { /* Shortcut: if the lengths differ, the arrays differ */ if (op == Py_EQ) res = Py_False; @@ -520,7 +520,7 @@ /* Search for the first index where items are different */ k = 1; - for (i = 0; i < Py_Size(va) && i < Py_Size(wa); i++) { + for (i = 0; i < Py_SIZE(va) && i < Py_SIZE(wa); i++) { vi = getarrayitem(v, i); wi = getarrayitem(w, i); if (vi == NULL || wi == NULL) { @@ -539,8 +539,8 @@ if (k) { /* No more items to compare -- compare sizes */ - Py_ssize_t vs = Py_Size(va); - Py_ssize_t ws = Py_Size(wa); + Py_ssize_t vs = Py_SIZE(va); + Py_ssize_t ws = Py_SIZE(wa); int cmp; switch (op) { case Py_LT: cmp = vs < ws; break; @@ -580,13 +580,13 @@ static Py_ssize_t array_length(arrayobject *a) { - return Py_Size(a); + return Py_SIZE(a); } static PyObject * array_item(arrayobject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "array index out of range"); return NULL; } @@ -599,14 +599,14 @@ arrayobject *np; if (ilow < 0) ilow = 0; - else if (ilow > Py_Size(a)) - ilow = Py_Size(a); + else if (ilow > Py_SIZE(a)) + ilow = Py_SIZE(a); if (ihigh < 0) ihigh = 0; if (ihigh < ilow) ihigh = ilow; - else if (ihigh > Py_Size(a)) - ihigh = Py_Size(a); + else if (ihigh > Py_SIZE(a)) + ihigh = Py_SIZE(a); np = (arrayobject *) newarrayobject(&Arraytype, ihigh - ilow, a->ob_descr); if (np == NULL) return NULL; @@ -618,7 +618,7 @@ static PyObject * array_copy(arrayobject *a, PyObject *unused) { - return array_slice(a, 0, Py_Size(a)); + return array_slice(a, 0, Py_SIZE(a)); } PyDoc_STRVAR(copy_doc, @@ -634,7 +634,7 @@ if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only append array (not \"%.200s\") to array", - Py_Type(bb)->tp_name); + Py_TYPE(bb)->tp_name); return NULL; } #define b ((arrayobject *)bb) @@ -642,14 +642,14 @@ PyErr_BadArgument(); return NULL; } - size = Py_Size(a) + Py_Size(b); + size = Py_SIZE(a) + Py_SIZE(b); np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) { return NULL; } - memcpy(np->ob_item, a->ob_item, Py_Size(a)*a->ob_descr->itemsize); - memcpy(np->ob_item + Py_Size(a)*a->ob_descr->itemsize, - b->ob_item, Py_Size(b)*b->ob_descr->itemsize); + memcpy(np->ob_item, a->ob_item, Py_SIZE(a)*a->ob_descr->itemsize); + memcpy(np->ob_item + Py_SIZE(a)*a->ob_descr->itemsize, + b->ob_item, Py_SIZE(b)*b->ob_descr->itemsize); return (PyObject *)np; #undef b } @@ -664,12 +664,12 @@ Py_ssize_t nbytes; if (n < 0) n = 0; - size = Py_Size(a) * n; + size = Py_SIZE(a) * n; np = (arrayobject *) newarrayobject(&Arraytype, size, a->ob_descr); if (np == NULL) return NULL; p = np->ob_item; - nbytes = Py_Size(a) * a->ob_descr->itemsize; + nbytes = Py_SIZE(a) * a->ob_descr->itemsize; for (i = 0; i < n; i++) { memcpy(p, a->ob_item, nbytes); p += nbytes; @@ -687,7 +687,7 @@ if (v == NULL) n = 0; else if (array_Check(v)) { - n = Py_Size(b); + n = Py_SIZE(b); if (a == b) { /* Special case "a[i:j] = a" -- copy b first */ int ret; @@ -706,44 +706,44 @@ else { PyErr_Format(PyExc_TypeError, "can only assign array (not \"%.200s\") to array slice", - Py_Type(v)->tp_name); + Py_TYPE(v)->tp_name); return -1; } if (ilow < 0) ilow = 0; - else if (ilow > Py_Size(a)) - ilow = Py_Size(a); + else if (ilow > Py_SIZE(a)) + ilow = Py_SIZE(a); if (ihigh < 0) ihigh = 0; if (ihigh < ilow) ihigh = ilow; - else if (ihigh > Py_Size(a)) - ihigh = Py_Size(a); + else if (ihigh > Py_SIZE(a)) + ihigh = Py_SIZE(a); item = a->ob_item; d = n - (ihigh-ilow); if (d < 0) { /* Delete -d items */ memmove(item + (ihigh+d)*a->ob_descr->itemsize, item + ihigh*a->ob_descr->itemsize, - (Py_Size(a)-ihigh)*a->ob_descr->itemsize); - Py_Size(a) += d; - PyMem_RESIZE(item, char, Py_Size(a)*a->ob_descr->itemsize); + (Py_SIZE(a)-ihigh)*a->ob_descr->itemsize); + Py_SIZE(a) += d; + PyMem_RESIZE(item, char, Py_SIZE(a)*a->ob_descr->itemsize); /* Can't fail */ a->ob_item = item; - a->allocated = Py_Size(a); + a->allocated = Py_SIZE(a); } else if (d > 0) { /* Insert d items */ PyMem_RESIZE(item, char, - (Py_Size(a) + d)*a->ob_descr->itemsize); + (Py_SIZE(a) + d)*a->ob_descr->itemsize); if (item == NULL) { PyErr_NoMemory(); return -1; } memmove(item + (ihigh+d)*a->ob_descr->itemsize, item + ihigh*a->ob_descr->itemsize, - (Py_Size(a)-ihigh)*a->ob_descr->itemsize); + (Py_SIZE(a)-ihigh)*a->ob_descr->itemsize); a->ob_item = item; - Py_Size(a) += d; - a->allocated = Py_Size(a); + Py_SIZE(a) += d; + a->allocated = Py_SIZE(a); } if (n > 0) memcpy(item + ilow*a->ob_descr->itemsize, b->ob_item, @@ -755,7 +755,7 @@ static int array_ass_item(arrayobject *a, Py_ssize_t i, PyObject *v) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; @@ -782,7 +782,7 @@ return -1; while ((v = PyIter_Next(it)) != NULL) { - if (ins1(self, (int) Py_Size(self), v) != 0) { + if (ins1(self, (int) Py_SIZE(self), v) != 0) { Py_DECREF(v); Py_DECREF(it); return -1; @@ -808,16 +808,16 @@ "can only extend with array of same kind"); return -1; } - size = Py_Size(self) + Py_Size(b); + size = Py_SIZE(self) + Py_SIZE(b); PyMem_RESIZE(self->ob_item, char, size*self->ob_descr->itemsize); if (self->ob_item == NULL) { PyObject_Del(self); PyErr_NoMemory(); return -1; } - memcpy(self->ob_item + Py_Size(self)*self->ob_descr->itemsize, - b->ob_item, Py_Size(b)*b->ob_descr->itemsize); - Py_Size(self) = size; + memcpy(self->ob_item + Py_SIZE(self)*self->ob_descr->itemsize, + b->ob_item, Py_SIZE(b)*b->ob_descr->itemsize); + Py_SIZE(self) = size; self->allocated = size; return 0; @@ -830,7 +830,7 @@ if (!array_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only extend array with array (not \"%.200s\")", - Py_Type(bb)->tp_name); + Py_TYPE(bb)->tp_name); return NULL; } if (array_do_extend(self, bb) == -1) @@ -845,15 +845,15 @@ char *items, *p; Py_ssize_t size, i; - if (Py_Size(self) > 0) { + if (Py_SIZE(self) > 0) { if (n < 0) n = 0; items = self->ob_item; - size = Py_Size(self) * self->ob_descr->itemsize; + size = Py_SIZE(self) * self->ob_descr->itemsize; if (n == 0) { PyMem_FREE(items); self->ob_item = NULL; - Py_Size(self) = 0; + Py_SIZE(self) = 0; self->allocated = 0; } else { @@ -866,8 +866,8 @@ memcpy(p, items, size); } self->ob_item = items; - Py_Size(self) *= n; - self->allocated = Py_Size(self); + Py_SIZE(self) *= n; + self->allocated = Py_SIZE(self); } } Py_INCREF(self); @@ -890,7 +890,7 @@ Py_ssize_t count = 0; Py_ssize_t i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -912,7 +912,7 @@ { Py_ssize_t i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -937,7 +937,7 @@ Py_ssize_t i; int cmp; - for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(self); i++) { + for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self, i); cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -950,7 +950,7 @@ { int i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *selfi = getarrayitem((PyObject *)self,i); int cmp = PyObject_RichCompareBool(selfi, v, Py_EQ); Py_DECREF(selfi); @@ -980,14 +980,14 @@ PyObject *v; if (!PyArg_ParseTuple(args, "|n:pop", &i)) return NULL; - if (Py_Size(self) == 0) { + if (Py_SIZE(self) == 0) { /* Special-case most common failure cause */ PyErr_SetString(PyExc_IndexError, "pop from empty array"); return NULL; } if (i < 0) - i += Py_Size(self); - if (i < 0 || i >= Py_Size(self)) { + i += Py_SIZE(self); + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } @@ -1043,7 +1043,7 @@ return NULL; PyTuple_SET_ITEM(retval, 0, PyLong_FromVoidPtr(self->ob_item)); - PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_Size(self)))); + PyTuple_SET_ITEM(retval, 1, PyLong_FromLong((long)(Py_SIZE(self)))); return retval; } @@ -1060,7 +1060,7 @@ static PyObject * array_append(arrayobject *self, PyObject *v) { - return ins(self, (int) Py_Size(self), v); + return ins(self, (int) Py_SIZE(self), v); } PyDoc_STRVAR(append_doc, @@ -1079,14 +1079,14 @@ case 1: break; case 2: - for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 2) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 2) { char p0 = p[0]; p[0] = p[1]; p[1] = p0; } break; case 4: - for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 4) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 4) { char p0 = p[0]; char p1 = p[1]; p[0] = p[3]; @@ -1096,7 +1096,7 @@ } break; case 8: - for (p = self->ob_item, i = Py_Size(self); --i >= 0; p += 8) { + for (p = self->ob_item, i = Py_SIZE(self); --i >= 0; p += 8) { char p0 = p[0]; char p1 = p[1]; char p2 = p[2]; @@ -1137,16 +1137,16 @@ dict = Py_None; Py_INCREF(dict); } - if (Py_Size(array) > 0) { + if (Py_SIZE(array) > 0) { result = Py_BuildValue("O(cy#)O", - Py_Type(array), + Py_TYPE(array), array->ob_descr->typecode, array->ob_item, - Py_Size(array) * array->ob_descr->itemsize, + Py_SIZE(array) * array->ob_descr->itemsize, dict); } else { result = Py_BuildValue("O(c)O", - Py_Type(array), + Py_TYPE(array), array->ob_descr->typecode, dict); } @@ -1165,9 +1165,9 @@ char tmp[256]; /* 8 is probably enough -- but why skimp */ assert((size_t)itemsize <= sizeof(tmp)); - if (Py_Size(self) > 1) { + if (Py_SIZE(self) > 1) { for (p = self->ob_item, - q = self->ob_item + (Py_Size(self) - 1)*itemsize; + q = self->ob_item + (Py_SIZE(self) - 1)*itemsize; p < q; p += itemsize, q -= itemsize) { /* memory areas guaranteed disjoint, so memcpy @@ -1247,14 +1247,14 @@ static PyObject * array_tofile(arrayobject *self, PyObject *f) { - Py_ssize_t nbytes = Py_Size(self) * self->ob_descr->itemsize; + Py_ssize_t nbytes = Py_SIZE(self) * self->ob_descr->itemsize; /* Write 64K blocks at a time */ /* XXX Make the block size settable */ int BLOCKSIZE = 64*1024; Py_ssize_t nblocks = (nbytes + BLOCKSIZE - 1) / BLOCKSIZE; Py_ssize_t i; - if (Py_Size(self) == 0) + if (Py_SIZE(self) == 0) goto done; for (i = 0; i < nblocks; i++) { @@ -1299,23 +1299,23 @@ if (n > 0) { char *item = self->ob_item; Py_ssize_t i; - PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize); + PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = item; - Py_Size(self) += n; - self->allocated = Py_Size(self); + Py_SIZE(self) += n; + self->allocated = Py_SIZE(self); for (i = 0; i < n; i++) { PyObject *v = PyList_GetItem(list, i); if ((*self->ob_descr->setitem)(self, - Py_Size(self) - n + i, v) != 0) { - Py_Size(self) -= n; + Py_SIZE(self) - n + i, v) != 0) { + Py_SIZE(self) -= n; PyMem_RESIZE(item, char, - Py_Size(self) * itemsize); + Py_SIZE(self) * itemsize); self->ob_item = item; - self->allocated = Py_Size(self); + self->allocated = Py_SIZE(self); return NULL; } } @@ -1332,12 +1332,12 @@ static PyObject * array_tolist(arrayobject *self, PyObject *unused) { - PyObject *list = PyList_New(Py_Size(self)); + PyObject *list = PyList_New(Py_SIZE(self)); Py_ssize_t i; if (list == NULL) return NULL; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { PyObject *v = getarrayitem((PyObject *)self, i); if (v == NULL) { Py_DECREF(list); @@ -1370,15 +1370,15 @@ n = n / itemsize; if (n > 0) { char *item = self->ob_item; - PyMem_RESIZE(item, char, (Py_Size(self) + n) * itemsize); + PyMem_RESIZE(item, char, (Py_SIZE(self) + n) * itemsize); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = item; - Py_Size(self) += n; - self->allocated = Py_Size(self); - memcpy(item + (Py_Size(self) - n) * itemsize, + Py_SIZE(self) += n; + self->allocated = Py_SIZE(self); + memcpy(item + (Py_SIZE(self) - n) * itemsize, str, itemsize*n); } Py_INCREF(Py_None); @@ -1396,7 +1396,7 @@ array_tostring(arrayobject *self, PyObject *unused) { return PyString_FromStringAndSize(self->ob_item, - Py_Size(self) * self->ob_descr->itemsize); + Py_SIZE(self) * self->ob_descr->itemsize); } PyDoc_STRVAR(tostring_doc, @@ -1425,15 +1425,15 @@ } if (n > 0) { Py_UNICODE *item = (Py_UNICODE *) self->ob_item; - PyMem_RESIZE(item, Py_UNICODE, Py_Size(self) + n); + PyMem_RESIZE(item, Py_UNICODE, Py_SIZE(self) + n); if (item == NULL) { PyErr_NoMemory(); return NULL; } self->ob_item = (char *) item; - Py_Size(self) += n; - self->allocated = Py_Size(self); - memcpy(item + Py_Size(self) - n, + Py_SIZE(self) += n; + self->allocated = Py_SIZE(self); + memcpy(item + Py_SIZE(self) - n, ustr, n * sizeof(Py_UNICODE)); } @@ -1460,7 +1460,7 @@ "tounicode() may only be called on unicode type arrays"); return NULL; } - return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_Size(self)); + return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_SIZE(self)); } PyDoc_STRVAR(tounicode_doc, @@ -1553,7 +1553,7 @@ PyObject *s, *v = NULL; Py_ssize_t len; - len = Py_Size(a); + len = Py_SIZE(a); typecode = a->ob_descr->typecode; if (len == 0) { return PyUnicode_FromFormat("array('%c')", typecode); @@ -1577,7 +1577,7 @@ return NULL; } if (i < 0) - i += Py_Size(self); + i += Py_SIZE(self); return array_item(self, i); } else if (PySlice_Check(item)) { @@ -1586,7 +1586,7 @@ arrayobject* ar; int itemsize = self->ob_descr->itemsize; - if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self), + if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return NULL; } @@ -1640,8 +1640,8 @@ if (i == -1 && PyErr_Occurred()) return -1; if (i < 0) - i += Py_Size(self); - if (i < 0 || i >= Py_Size(self)) { + i += Py_SIZE(self); + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "array assignment index out of range"); return -1; @@ -1658,7 +1658,7 @@ } else if (PySlice_Check(item)) { if (PySlice_GetIndicesEx((PySliceObject *)item, - Py_Size(self), &start, &stop, + Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return -1; } @@ -1674,7 +1674,7 @@ } else if (array_Check(value)) { other = (arrayobject *)value; - needed = Py_Size(other); + needed = Py_SIZE(other); if (self == other) { /* Special case "self[i:j] = self" -- copy self first */ int ret; @@ -1693,7 +1693,7 @@ else { PyErr_Format(PyExc_TypeError, "can only assign array (not \"%.200s\") to array slice", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } itemsize = self->ob_descr->itemsize; @@ -1705,18 +1705,18 @@ if (slicelength > needed) { memmove(self->ob_item + (start + needed) * itemsize, self->ob_item + stop * itemsize, - (Py_Size(self) - stop) * itemsize); - if (array_resize(self, Py_Size(self) + + (Py_SIZE(self) - stop) * itemsize); + if (array_resize(self, Py_SIZE(self) + needed - slicelength) < 0) return -1; } else if (slicelength < needed) { - if (array_resize(self, Py_Size(self) + + if (array_resize(self, Py_SIZE(self) + needed - slicelength) < 0) return -1; memmove(self->ob_item + (start + needed) * itemsize, self->ob_item + stop * itemsize, - (Py_Size(self) - start - needed) * itemsize); + (Py_SIZE(self) - start - needed) * itemsize); } if (needed > 0) memcpy(self->ob_item + start * itemsize, @@ -1736,19 +1736,19 @@ cur += step, i++) { Py_ssize_t lim = step - 1; - if (cur + step >= Py_Size(self)) - lim = Py_Size(self) - cur - 1; + if (cur + step >= Py_SIZE(self)) + lim = Py_SIZE(self) - cur - 1; memmove(self->ob_item + (cur - i) * itemsize, self->ob_item + (cur + 1) * itemsize, lim * itemsize); } cur = start + slicelength * step; - if (cur < Py_Size(self)) { + if (cur < Py_SIZE(self)) { memmove(self->ob_item + (cur-slicelength) * itemsize, self->ob_item + cur * itemsize, - (Py_Size(self) - cur) * itemsize); + (Py_SIZE(self) - cur) * itemsize); } - if (array_resize(self, Py_Size(self) - slicelength) < 0) + if (array_resize(self, Py_SIZE(self) - slicelength) < 0) return -1; return 0; } @@ -1794,14 +1794,14 @@ view->buf = (void *)self->ob_item; if (view->buf == NULL) view->buf = (void *)emptybuf; - view->len = (Py_Size(self)) * self->ob_descr->itemsize; + view->len = (Py_SIZE(self)) * self->ob_descr->itemsize; view->readonly = 0; view->ndim = 1; view->itemsize = self->ob_descr->itemsize; view->suboffsets = NULL; view->shape = NULL; if ((flags & PyBUF_ND)==PyBUF_ND) { - view->shape = &((Py_Size(self))); + view->shape = &((Py_SIZE(self))); } view->strides = NULL; if ((flags & PyBUF_STRIDES)==PyBUF_STRIDES) @@ -1935,9 +1935,9 @@ return NULL; } self->ob_item = item; - Py_Size(self) = n / sizeof(Py_UNICODE); + Py_SIZE(self) = n / sizeof(Py_UNICODE); memcpy(item, PyUnicode_AS_DATA(initial), n); - self->allocated = Py_Size(self); + self->allocated = Py_SIZE(self); } } if (it != NULL) { @@ -2108,7 +2108,7 @@ arrayiter_next(arrayiterobject *it) { assert(PyArrayIter_Check(it)); - if (it->index < Py_Size(it->ao)) + if (it->index < Py_SIZE(it->ao)) return (*it->getitem)(it->ao, it->index++); return NULL; } @@ -2180,7 +2180,7 @@ if (PyType_Ready(&Arraytype) < 0) return; - Py_Type(&PyArrayIter_Type) = &PyType_Type; + Py_TYPE(&PyArrayIter_Type) = &PyType_Type; m = Py_InitModule3("array", a_methods, module_doc); if (m == NULL) return; Modified: python/branches/py3k/Modules/bz2module.c ============================================================================== --- python/branches/py3k/Modules/bz2module.c (original) +++ python/branches/py3k/Modules/bz2module.c Wed Dec 19 03:45:37 2007 @@ -41,7 +41,7 @@ #define MODE_READ_EOF 2 #define MODE_WRITE 3 -#define BZ2FileObject_Check(v) (Py_Type(v) == &BZ2File_Type) +#define BZ2FileObject_Check(v) (Py_TYPE(v) == &BZ2File_Type) #ifdef BZ_CONFIG_ERROR @@ -1240,7 +1240,7 @@ Util_DropReadAhead(self); if (self->rawfp != NULL) fclose(self->rawfp); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } /* This is a hacked version of Python's fileobject.c:file_getiter(). */ @@ -1552,7 +1552,7 @@ PyThread_free_lock(self->lock); #endif BZ2_bzCompressEnd(&self->bzs); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } @@ -1777,7 +1777,7 @@ #endif Py_XDECREF(self->unused_data); BZ2_bzDecompressEnd(&self->bzs); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } @@ -2031,9 +2031,9 @@ { PyObject *m; - Py_Type(&BZ2File_Type) = &PyType_Type; - Py_Type(&BZ2Comp_Type) = &PyType_Type; - Py_Type(&BZ2Decomp_Type) = &PyType_Type; + Py_TYPE(&BZ2File_Type) = &PyType_Type; + Py_TYPE(&BZ2Comp_Type) = &PyType_Type; + Py_TYPE(&BZ2Decomp_Type) = &PyType_Type; m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); if (m == NULL) Modified: python/branches/py3k/Modules/cStringIO.c ============================================================================== --- python/branches/py3k/Modules/cStringIO.c (original) +++ python/branches/py3k/Modules/cStringIO.c Wed Dec 19 03:45:37 2007 @@ -738,8 +738,8 @@ d = PyModule_GetDict(m); /* Export C API */ - Py_Type(&Itype)=&PyType_Type; - Py_Type(&Otype)=&PyType_Type; + Py_TYPE(&Itype)=&PyType_Type; + Py_TYPE(&Otype)=&PyType_Type; if (PyType_Ready(&Otype) < 0) return; if (PyType_Ready(&Itype) < 0) return; PyDict_SetItemString(d,"cStringIO_CAPI", Modified: python/branches/py3k/Modules/cjkcodecs/multibytecodec.c ============================================================================== --- python/branches/py3k/Modules/cjkcodecs/multibytecodec.c (original) +++ python/branches/py3k/Modules/cjkcodecs/multibytecodec.c Wed Dec 19 03:45:37 2007 @@ -953,7 +953,7 @@ { PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyTypeObject MultibyteIncrementalEncoder_Type = { @@ -1153,7 +1153,7 @@ { PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyTypeObject MultibyteIncrementalDecoder_Type = { @@ -1479,7 +1479,7 @@ PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_DECREF(self->stream); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyTypeObject MultibyteStreamReader_Type = { @@ -1682,7 +1682,7 @@ PyObject_GC_UnTrack(self); ERROR_DECREF(self->errors); Py_DECREF(self->stream); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static struct PyMethodDef mbstreamwriter_methods[] = { Modified: python/branches/py3k/Modules/datetimemodule.c ============================================================================== --- python/branches/py3k/Modules/datetimemodule.c (original) +++ python/branches/py3k/Modules/datetimemodule.c Wed Dec 19 03:45:37 2007 @@ -764,7 +764,7 @@ PyErr_Format(PyExc_TypeError, "tzinfo argument must be None or of a tzinfo subclass, " "not type '%s'", - Py_Type(p)->tp_name); + Py_TYPE(p)->tp_name); return -1; } @@ -855,7 +855,7 @@ PyErr_Format(PyExc_TypeError, "tzinfo.%s() must return None or " "timedelta, not '%s'", - name, Py_Type(u)->tp_name); + name, Py_TYPE(u)->tp_name); } Py_DECREF(u); @@ -950,7 +950,7 @@ if (!PyUnicode_Check(result)) { PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must " "return None or a string, not '%s'", - Py_Type(result)->tp_name); + Py_TYPE(result)->tp_name); Py_DECREF(result); result = NULL; } @@ -1293,7 +1293,7 @@ assert(PyUnicode_Check(Zreplacement)); ptoappend = PyUnicode_AsStringAndSize(Zreplacement, &ntoappend); - ntoappend = Py_Size(Zreplacement); + ntoappend = Py_SIZE(Zreplacement); } else { /* percent followed by neither z nor Z */ @@ -1425,7 +1425,7 @@ { PyErr_Format(PyExc_TypeError, "can't compare %s to %s", - Py_Type(a)->tp_name, Py_Type(b)->tp_name); + Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name); return NULL; } @@ -1869,7 +1869,7 @@ PyErr_Format(PyExc_TypeError, "unsupported type for timedelta %s component: %s", - tag, Py_Type(num)->tp_name); + tag, Py_TYPE(num)->tp_name); return NULL; } @@ -1973,18 +1973,18 @@ { if (GET_TD_MICROSECONDS(self) != 0) return PyUnicode_FromFormat("%s(%d, %d, %d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_TD_DAYS(self), GET_TD_SECONDS(self), GET_TD_MICROSECONDS(self)); if (GET_TD_SECONDS(self) != 0) return PyUnicode_FromFormat("%s(%d, %d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_TD_DAYS(self), GET_TD_SECONDS(self)); return PyUnicode_FromFormat("%s(%d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_TD_DAYS(self)); } @@ -2031,7 +2031,7 @@ static PyObject * delta_reduce(PyDateTime_Delta* self) { - return Py_BuildValue("ON", Py_Type(self), delta_getstate(self)); + return Py_BuildValue("ON", Py_TYPE(self), delta_getstate(self)); } #define OFFSET(field) offsetof(PyDateTime_Delta, field) @@ -2385,7 +2385,7 @@ date_repr(PyDateTime_Date *self) { return PyUnicode_FromFormat("%s(%d, %d, %d)", - Py_Type(self)->tp_name, + Py_TYPE(self)->tp_name, GET_YEAR(self), GET_MONTH(self), GET_DAY(self)); } @@ -2522,7 +2522,7 @@ tuple = Py_BuildValue("iii", year, month, day); if (tuple == NULL) return NULL; - clone = date_new(Py_Type(self), tuple, NULL); + clone = date_new(Py_TYPE(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -2590,7 +2590,7 @@ static PyObject * date_reduce(PyDateTime_Date *self, PyObject *arg) { - return Py_BuildValue("(ON)", Py_Type(self), date_getstate(self)); + return Py_BuildValue("(ON)", Py_TYPE(self), date_getstate(self)); } static PyMethodDef date_methods[] = { @@ -2893,10 +2893,10 @@ if (state == Py_None) { Py_DECREF(state); - return Py_BuildValue("(ON)", Py_Type(self), args); + return Py_BuildValue("(ON)", Py_TYPE(self), args); } else - return Py_BuildValue("(ONN)", Py_Type(self), args, state); + return Py_BuildValue("(ONN)", Py_TYPE(self), args, state); } static PyMethodDef tzinfo_methods[] = { @@ -3089,7 +3089,7 @@ if (HASTZINFO(self)) { Py_XDECREF(self->tzinfo); } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } /* @@ -3122,7 +3122,7 @@ static PyObject * time_repr(PyDateTime_Time *self) { - const char *type_name = Py_Type(self)->tp_name; + const char *type_name = Py_TYPE(self)->tp_name; int h = TIME_GET_HOUR(self); int m = TIME_GET_MINUTE(self); int s = TIME_GET_SECOND(self); @@ -3346,7 +3346,7 @@ tuple = Py_BuildValue("iiiiO", hh, mm, ss, us, tzinfo); if (tuple == NULL) return NULL; - clone = time_new(Py_Type(self), tuple, NULL); + clone = time_new(Py_TYPE(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -3400,7 +3400,7 @@ static PyObject * time_reduce(PyDateTime_Time *self, PyObject *arg) { - return Py_BuildValue("(ON)", Py_Type(self), time_getstate(self)); + return Py_BuildValue("(ON)", Py_TYPE(self), time_getstate(self)); } static PyMethodDef time_methods[] = { @@ -3897,7 +3897,7 @@ if (HASTZINFO(self)) { Py_XDECREF(self->tzinfo); } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } /* @@ -4045,7 +4045,7 @@ static PyObject * datetime_repr(PyDateTime_DateTime *self) { - const char *type_name = Py_Type(self)->tp_name; + const char *type_name = Py_TYPE(self)->tp_name; PyObject *baserepr; if (DATE_GET_MICROSECOND(self)) { @@ -4262,7 +4262,7 @@ tuple = Py_BuildValue("iiiiiiiO", y, m, d, hh, mm, ss, us, tzinfo); if (tuple == NULL) return NULL; - clone = datetime_new(Py_Type(self), tuple, NULL); + clone = datetime_new(Py_TYPE(self), tuple, NULL); Py_DECREF(tuple); return clone; } @@ -4450,7 +4450,7 @@ static PyObject * datetime_reduce(PyDateTime_DateTime *self, PyObject *arg) { - return Py_BuildValue("(ON)", Py_Type(self), datetime_getstate(self)); + return Py_BuildValue("(ON)", Py_TYPE(self), datetime_getstate(self)); } static PyMethodDef datetime_methods[] = { Modified: python/branches/py3k/Modules/dbmmodule.c ============================================================================== --- python/branches/py3k/Modules/dbmmodule.c (original) +++ python/branches/py3k/Modules/dbmmodule.c Wed Dec 19 03:45:37 2007 @@ -36,7 +36,7 @@ static PyTypeObject Dbmtype; -#define is_dbmobject(v) (Py_Type(v) == &Dbmtype) +#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype) #define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ { PyErr_SetString(DbmError, "DBM object has already been closed"); \ return NULL; } Modified: python/branches/py3k/Modules/dlmodule.c ============================================================================== --- python/branches/py3k/Modules/dlmodule.c (original) +++ python/branches/py3k/Modules/dlmodule.c Wed Dec 19 03:45:37 2007 @@ -62,7 +62,7 @@ name = PyUnicode_AsString(args); } else { PyErr_Format(PyExc_TypeError, "expected string, found %.200s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return NULL; } func = dlsym(xp->dl_handle, name); @@ -238,7 +238,7 @@ PyObject *m, *d, *x; /* Initialize object type */ - Py_Type(&Dltype) = &PyType_Type; + Py_TYPE(&Dltype) = &PyType_Type; /* Create the module and add the functions */ m = Py_InitModule("dl", dl_methods); Modified: python/branches/py3k/Modules/gcmodule.c ============================================================================== --- python/branches/py3k/Modules/gcmodule.c (original) +++ python/branches/py3k/Modules/gcmodule.c Wed Dec 19 03:45:37 2007 @@ -235,7 +235,7 @@ PyGC_Head *gc = containers->gc.gc_next; for (; gc != containers; gc = gc->gc.gc_next) { assert(gc->gc.gc_refs == GC_REACHABLE); - gc->gc.gc_refs = Py_Refcnt(FROM_GC(gc)); + gc->gc.gc_refs = Py_REFCNT(FROM_GC(gc)); /* Python's cyclic gc should never see an incoming refcount * of 0: if something decref'ed to 0, it should have been * deallocated immediately at that time. @@ -287,7 +287,7 @@ traverseproc traverse; PyGC_Head *gc = containers->gc.gc_next; for (; gc != containers; gc=gc->gc.gc_next) { - traverse = Py_Type(FROM_GC(gc))->tp_traverse; + traverse = Py_TYPE(FROM_GC(gc))->tp_traverse; (void) traverse(FROM_GC(gc), (visitproc)visit_decref, NULL); @@ -372,7 +372,7 @@ * the next object to visit. */ PyObject *op = FROM_GC(gc); - traverseproc traverse = Py_Type(op)->tp_traverse; + traverseproc traverse = Py_TYPE(op)->tp_traverse; assert(gc->gc.gc_refs > 0); gc->gc.gc_refs = GC_REACHABLE; (void) traverse(op, @@ -456,7 +456,7 @@ PyGC_Head *gc = finalizers->gc.gc_next; for (; gc != finalizers; gc = gc->gc.gc_next) { /* Note that the finalizers list may grow during this. */ - traverse = Py_Type(FROM_GC(gc))->tp_traverse; + traverse = Py_TYPE(FROM_GC(gc))->tp_traverse; (void) traverse(FROM_GC(gc), (visitproc)visit_move, (void *)finalizers); @@ -501,7 +501,7 @@ assert(IS_TENTATIVELY_UNREACHABLE(op)); next = gc->gc.gc_next; - if (! PyType_SUPPORTS_WEAKREFS(Py_Type(op))) + if (! PyType_SUPPORTS_WEAKREFS(Py_TYPE(op))) continue; /* It supports weakrefs. Does it have any? */ @@ -620,7 +620,7 @@ debug_cycle(char *msg, PyObject *op) { PySys_WriteStderr("gc: %.100s <%.100s %p>\n", - msg, Py_Type(op)->tp_name, op); + msg, Py_TYPE(op)->tp_name, op); } /* Handle uncollectable garbage (cycles with finalizers, and stuff reachable @@ -673,7 +673,7 @@ PyList_Append(garbage, op); } else { - if ((clear = Py_Type(op)->tp_clear) != NULL) { + if ((clear = Py_TYPE(op)->tp_clear) != NULL) { Py_INCREF(op); clear(op); Py_DECREF(op); @@ -1042,7 +1042,7 @@ traverseproc traverse; for (gc = list->gc.gc_next; gc != list; gc = gc->gc.gc_next) { obj = FROM_GC(gc); - traverse = Py_Type(obj)->tp_traverse; + traverse = Py_TYPE(obj)->tp_traverse; if (obj == objs || obj == resultlist) continue; if (traverse(obj, (visitproc)referrersvisit, objs)) { @@ -1099,7 +1099,7 @@ if (! PyObject_IS_GC(obj)) continue; - traverse = Py_Type(obj)->tp_traverse; + traverse = Py_TYPE(obj)->tp_traverse; if (! traverse) continue; if (traverse(obj, (visitproc)referentsvisit, result)) { @@ -1320,13 +1320,13 @@ PyVarObject * _PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems) { - const size_t basicsize = _PyObject_VAR_SIZE(Py_Type(op), nitems); + const size_t basicsize = _PyObject_VAR_SIZE(Py_TYPE(op), nitems); PyGC_Head *g = AS_GC(op); g = (PyGC_Head *)PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize); if (g == NULL) return (PyVarObject *)PyErr_NoMemory(); op = (PyVarObject *) FROM_GC(g); - Py_Size(op) = nitems; + Py_SIZE(op) = nitems; return op; } Modified: python/branches/py3k/Modules/gdbmmodule.c ============================================================================== --- python/branches/py3k/Modules/gdbmmodule.c (original) +++ python/branches/py3k/Modules/gdbmmodule.c Wed Dec 19 03:45:37 2007 @@ -36,7 +36,7 @@ static PyTypeObject Dbmtype; -#define is_dbmobject(v) (Py_Type(v) == &Dbmtype) +#define is_dbmobject(v) (Py_TYPE(v) == &Dbmtype) #define check_dbmobject_open(v) if ((v)->di_dbm == NULL) \ { PyErr_SetString(DbmError, "GDBM object has already been closed"); \ return NULL; } Modified: python/branches/py3k/Modules/itertoolsmodule.c ============================================================================== --- python/branches/py3k/Modules/itertoolsmodule.c (original) +++ python/branches/py3k/Modules/itertoolsmodule.c Wed Dec 19 03:45:37 2007 @@ -59,7 +59,7 @@ Py_XDECREF(gbo->tgtkey); Py_XDECREF(gbo->currkey); Py_XDECREF(gbo->currvalue); - Py_Type(gbo)->tp_free(gbo); + Py_TYPE(gbo)->tp_free(gbo); } static int @@ -714,7 +714,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->saved); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -857,7 +857,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -877,7 +877,7 @@ PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -1000,7 +1000,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1022,7 +1022,7 @@ return NULL; assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) return NULL; @@ -1190,7 +1190,7 @@ { PyObject_GC_UnTrack(lz); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1209,7 +1209,7 @@ PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; while (lz->cnt < lz->next) { item = iternext(it); if (item == NULL) @@ -1333,7 +1333,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1352,7 +1352,7 @@ PyObject *it = lz->it; assert(PyIter_Check(it)); - args = (*Py_Type(it)->tp_iternext)(it); + args = (*Py_TYPE(it)->tp_iternext)(it); if (args == NULL) return NULL; if (!PyTuple_CheckExact(args)) { @@ -1478,7 +1478,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->iters); Py_XDECREF(lz->func); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1656,7 +1656,7 @@ { PyObject_GC_UnTrack(lz); Py_XDECREF(lz->ittuple); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1787,7 +1787,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1807,7 +1807,7 @@ PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -1931,7 +1931,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->func); Py_XDECREF(lz->it); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -1951,7 +1951,7 @@ PyObject *(*iternext)(PyObject *); assert(PyIter_Check(it)); - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; for (;;) { item = iternext(it); if (item == NULL) @@ -2253,7 +2253,7 @@ PyObject_GC_UnTrack(lz); Py_XDECREF(lz->ittuple); Py_XDECREF(lz->result); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -2276,12 +2276,12 @@ if (tuplesize == 0) return NULL; - if (Py_Refcnt(result) == 1) { + if (Py_REFCNT(result) == 1) { Py_INCREF(result); for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { Py_DECREF(result); return NULL; @@ -2297,7 +2297,7 @@ for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { Py_DECREF(result); return NULL; @@ -2403,7 +2403,7 @@ { PyObject_GC_UnTrack(ro); Py_XDECREF(ro->element); - Py_Type(ro)->tp_free(ro); + Py_TYPE(ro)->tp_free(ro); } static int @@ -2588,7 +2588,7 @@ Py_XDECREF(lz->ittuple); Py_XDECREF(lz->result); Py_XDECREF(lz->fillvalue); - Py_Type(lz)->tp_free(lz); + Py_TYPE(lz)->tp_free(lz); } static int @@ -2614,7 +2614,7 @@ return NULL; if (lz->numactive == 0) return NULL; - if (Py_Refcnt(result) == 1) { + if (Py_REFCNT(result) == 1) { Py_INCREF(result); for (i=0 ; i < tuplesize ; i++) { it = PyTuple_GET_ITEM(lz->ittuple, i); @@ -2623,7 +2623,7 @@ item = lz->fillvalue; } else { assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { lz->numactive -= 1; if (lz->numactive == 0) { @@ -2652,7 +2652,7 @@ item = lz->fillvalue; } else { assert(PyIter_Check(it)); - item = (*Py_Type(it)->tp_iternext)(it); + item = (*Py_TYPE(it)->tp_iternext)(it); if (item == NULL) { lz->numactive -= 1; if (lz->numactive == 0) { @@ -2783,7 +2783,7 @@ NULL }; - Py_Type(&teedataobject_type) = &PyType_Type; + Py_TYPE(&teedataobject_type) = &PyType_Type; m = Py_InitModule3("itertools", module_methods, module_doc); if (m == NULL) return; Modified: python/branches/py3k/Modules/mathmodule.c ============================================================================== --- python/branches/py3k/Modules/mathmodule.c (original) +++ python/branches/py3k/Modules/mathmodule.c Wed Dec 19 03:45:37 2007 @@ -118,7 +118,7 @@ return NULL; } - method = _PyType_Lookup(Py_Type(number), ceil_str); + method = _PyType_Lookup(Py_TYPE(number), ceil_str); if (method == NULL) return math_1(number, ceil); else @@ -148,7 +148,7 @@ return NULL; } - method = _PyType_Lookup(Py_Type(number), floor_str); + method = _PyType_Lookup(Py_TYPE(number), floor_str); if (method == NULL) return math_1(number, floor); else Modified: python/branches/py3k/Modules/md5module.c ============================================================================== --- python/branches/py3k/Modules/md5module.c (original) +++ python/branches/py3k/Modules/md5module.c Wed Dec 19 03:45:37 2007 @@ -340,7 +340,7 @@ { MD5object *newobj; - if (Py_Type(self) == &MD5type) { + if (Py_TYPE(self) == &MD5type) { if ( (newobj = newMD5object())==NULL) return NULL; } else { @@ -552,7 +552,7 @@ { PyObject *m; - Py_Type(&MD5type) = &PyType_Type; + Py_TYPE(&MD5type) = &PyType_Type; if (PyType_Ready(&MD5type) < 0) return; m = Py_InitModule("_md5", MD5_functions); Modified: python/branches/py3k/Modules/mmapmodule.c ============================================================================== --- python/branches/py3k/Modules/mmapmodule.c (original) +++ python/branches/py3k/Modules/mmapmodule.c Wed Dec 19 03:45:37 2007 @@ -1253,7 +1253,7 @@ PyObject *dict, *module; /* Patch the object type */ - Py_Type(&mmap_object_type) = &PyType_Type; + Py_TYPE(&mmap_object_type) = &PyType_Type; module = Py_InitModule("mmap", mmap_functions); if (module == NULL) Modified: python/branches/py3k/Modules/parsermodule.c ============================================================================== --- python/branches/py3k/Modules/parsermodule.c (original) +++ python/branches/py3k/Modules/parsermodule.c Wed Dec 19 03:45:37 2007 @@ -694,7 +694,7 @@ PyErr_Format(parser_error, "second item in terminal node must be a string," " found %s", - Py_Type(temp)->tp_name); + Py_TYPE(temp)->tp_name); Py_DECREF(temp); Py_DECREF(elem); return 0; @@ -708,7 +708,7 @@ PyErr_Format(parser_error, "third item in terminal node must be an" " integer, found %s", - Py_Type(temp)->tp_name); + Py_TYPE(temp)->tp_name); Py_DECREF(o); Py_DECREF(temp); Py_DECREF(elem); @@ -3056,7 +3056,7 @@ { PyObject *module, *copyreg; - Py_Type(&PyST_Type) = &PyType_Type; + Py_TYPE(&PyST_Type) = &PyType_Type; module = Py_InitModule("parser", parser_functions); if (module == NULL) return; Modified: python/branches/py3k/Modules/posixmodule.c ============================================================================== --- python/branches/py3k/Modules/posixmodule.c (original) +++ python/branches/py3k/Modules/posixmodule.c Wed Dec 19 03:45:37 2007 @@ -2706,7 +2706,7 @@ long intval; if (PyFloat_Check(t)) { double tval = PyFloat_AsDouble(t); - PyObject *intobj = Py_Type(t)->tp_as_number->nb_int(t); + PyObject *intobj = Py_TYPE(t)->tp_as_number->nb_int(t); if (!intobj) return -1; intval = PyLong_AsLong(intobj); Modified: python/branches/py3k/Modules/pyexpat.c ============================================================================== --- python/branches/py3k/Modules/pyexpat.c (original) +++ python/branches/py3k/Modules/pyexpat.c Wed Dec 19 03:45:37 2007 @@ -871,10 +871,10 @@ else { PyErr_Format(PyExc_TypeError, "read() did not return a bytes object (type=%.400s)", - Py_Type(str)->tp_name); + Py_TYPE(str)->tp_name); goto finally; } - len = Py_Size(str); + len = Py_SIZE(str); if (len > buf_size) { PyErr_Format(PyExc_ValueError, "read() returned too much data: " @@ -1738,7 +1738,7 @@ if (modelmod_name == NULL) return; - Py_Type(&Xmlparsetype) = &PyType_Type; + Py_TYPE(&Xmlparsetype) = &PyType_Type; /* Create the module and add the functions */ m = Py_InitModule3(MODULE_NAME, pyexpat_methods, Modified: python/branches/py3k/Modules/selectmodule.c ============================================================================== --- python/branches/py3k/Modules/selectmodule.c (original) +++ python/branches/py3k/Modules/selectmodule.c Wed Dec 19 03:45:37 2007 @@ -701,7 +701,7 @@ #else { #endif - Py_Type(&poll_Type) = &PyType_Type; + Py_TYPE(&poll_Type) = &PyType_Type; PyModule_AddIntConstant(m, "POLLIN", POLLIN); PyModule_AddIntConstant(m, "POLLPRI", POLLPRI); PyModule_AddIntConstant(m, "POLLOUT", POLLOUT); Modified: python/branches/py3k/Modules/sha1module.c ============================================================================== --- python/branches/py3k/Modules/sha1module.c (original) +++ python/branches/py3k/Modules/sha1module.c Wed Dec 19 03:45:37 2007 @@ -316,7 +316,7 @@ { SHA1object *newobj; - if (Py_Type(self) == &SHA1type) { + if (Py_TYPE(self) == &SHA1type) { if ( (newobj = newSHA1object())==NULL) return NULL; } else { @@ -528,7 +528,7 @@ { PyObject *m; - Py_Type(&SHA1type) = &PyType_Type; + Py_TYPE(&SHA1type) = &PyType_Type; if (PyType_Ready(&SHA1type) < 0) return; m = Py_InitModule("_sha1", SHA1_functions); Modified: python/branches/py3k/Modules/sha256module.c ============================================================================== --- python/branches/py3k/Modules/sha256module.c (original) +++ python/branches/py3k/Modules/sha256module.c Wed Dec 19 03:45:37 2007 @@ -409,7 +409,7 @@ { SHAobject *newobj; - if (Py_Type(self) == &SHA256type) { + if (Py_TYPE(self) == &SHA256type) { if ( (newobj = newSHA256object())==NULL) return NULL; } else { @@ -687,10 +687,10 @@ { PyObject *m; - Py_Type(&SHA224type) = &PyType_Type; + Py_TYPE(&SHA224type) = &PyType_Type; if (PyType_Ready(&SHA224type) < 0) return; - Py_Type(&SHA256type) = &PyType_Type; + Py_TYPE(&SHA256type) = &PyType_Type; if (PyType_Ready(&SHA256type) < 0) return; m = Py_InitModule("_sha256", SHA_functions); Modified: python/branches/py3k/Modules/sha512module.c ============================================================================== --- python/branches/py3k/Modules/sha512module.c (original) +++ python/branches/py3k/Modules/sha512module.c Wed Dec 19 03:45:37 2007 @@ -753,10 +753,10 @@ { PyObject *m; - Py_Type(&SHA384type) = &PyType_Type; + Py_TYPE(&SHA384type) = &PyType_Type; if (PyType_Ready(&SHA384type) < 0) return; - Py_Type(&SHA512type) = &PyType_Type; + Py_TYPE(&SHA512type) = &PyType_Type; if (PyType_Ready(&SHA512type) < 0) return; m = Py_InitModule("_sha512", SHA_functions); Modified: python/branches/py3k/Modules/socketmodule.c ============================================================================== --- python/branches/py3k/Modules/socketmodule.c (original) +++ python/branches/py3k/Modules/socketmodule.c Wed Dec 19 03:45:37 2007 @@ -1135,7 +1135,7 @@ PyExc_TypeError, "getsockaddrarg: " "AF_NETLINK address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "II:getsockaddrarg", &pid, &groups)) @@ -1158,7 +1158,7 @@ PyExc_TypeError, "getsockaddrarg: " "AF_INET address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "eti:getsockaddrarg", @@ -1188,7 +1188,7 @@ PyExc_TypeError, "getsockaddrarg: " "AF_INET6 address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "eti|ii", @@ -1310,7 +1310,7 @@ PyExc_TypeError, "getsockaddrarg: " "AF_PACKET address must be tuple, not %.500s", - Py_Type(args)->tp_name); + Py_TYPE(args)->tp_name); return 0; } if (!PyArg_ParseTuple(args, "si|iiy#", &interfaceName, @@ -2580,7 +2580,7 @@ { if (s->sock_fd != -1) (void) SOCKETCLOSE(s->sock_fd); - Py_Type(s)->tp_free((PyObject *)s); + Py_TYPE(s)->tp_free((PyObject *)s); } @@ -3275,7 +3275,7 @@ else return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); if (x == (unsigned long) -1 && PyErr_Occurred()) return NULL; return PyLong_FromUnsignedLong(ntohl(x)); @@ -3334,7 +3334,7 @@ else return PyErr_Format(PyExc_TypeError, "expected int/long, %s found", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); return PyLong_FromUnsignedLong(htonl((unsigned long)x)); } @@ -3962,7 +3962,7 @@ if (!os_init()) return; - Py_Type(&sock_type) = &PyType_Type; + Py_TYPE(&sock_type) = &PyType_Type; m = Py_InitModule3(PySocket_MODULE_NAME, socket_methods, socket_doc); Modified: python/branches/py3k/Modules/threadmodule.c ============================================================================== --- python/branches/py3k/Modules/threadmodule.c (original) +++ python/branches/py3k/Modules/threadmodule.c Wed Dec 19 03:45:37 2007 @@ -250,7 +250,7 @@ } local_clear(self); - Py_Type(self)->tp_free((PyObject*)self); + Py_TYPE(self)->tp_free((PyObject*)self); } static PyObject * @@ -282,8 +282,8 @@ Py_INCREF(ldict); self->dict = ldict; /* still borrowed */ - if (Py_Type(self)->tp_init != PyBaseObject_Type.tp_init && - Py_Type(self)->tp_init((PyObject*)self, + if (Py_TYPE(self)->tp_init != PyBaseObject_Type.tp_init && + Py_TYPE(self)->tp_init((PyObject*)self, self->args, self->kw) < 0) { /* we need to get rid of ldict from thread so we create a new one the next time we do an attr @@ -386,7 +386,7 @@ if (ldict == NULL) return NULL; - if (Py_Type(self) != &localtype) + if (Py_TYPE(self) != &localtype) /* use generic lookup for subtypes */ return PyObject_GenericGetAttr((PyObject *)self, name); Modified: python/branches/py3k/Modules/timemodule.c ============================================================================== --- python/branches/py3k/Modules/timemodule.c (original) +++ python/branches/py3k/Modules/timemodule.c Wed Dec 19 03:45:37 2007 @@ -365,7 +365,7 @@ t = args; Py_INCREF(t); } - else if (Py_Type(args) == &StructTimeType) { + else if (Py_TYPE(args) == &StructTimeType) { t = structtime_totuple(args); } else { Modified: python/branches/py3k/Modules/unicodedata.c ============================================================================== --- python/branches/py3k/Modules/unicodedata.c (original) +++ python/branches/py3k/Modules/unicodedata.c Wed Dec 19 03:45:37 2007 @@ -1187,7 +1187,7 @@ { PyObject *m, *v; - Py_Type(&UCD_Type) = &PyType_Type; + Py_TYPE(&UCD_Type) = &PyType_Type; m = Py_InitModule3( "unicodedata", unicodedata_functions, unicodedata_docstring); Modified: python/branches/py3k/Modules/xxmodule.c ============================================================================== --- python/branches/py3k/Modules/xxmodule.c (original) +++ python/branches/py3k/Modules/xxmodule.c Wed Dec 19 03:45:37 2007 @@ -25,7 +25,7 @@ static PyTypeObject Xxo_Type; -#define XxoObject_Check(v) (Py_Type(v) == &Xxo_Type) +#define XxoObject_Check(v) (Py_TYPE(v) == &Xxo_Type) static XxoObject * newXxoObject(PyObject *arg) Modified: python/branches/py3k/Modules/zipimport.c ============================================================================== --- python/branches/py3k/Modules/zipimport.c (original) +++ python/branches/py3k/Modules/zipimport.c Wed Dec 19 03:45:37 2007 @@ -171,7 +171,7 @@ Py_XDECREF(self->archive); Py_XDECREF(self->prefix); Py_XDECREF(self->files); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static PyObject * Modified: python/branches/py3k/Modules/zlibmodule.c ============================================================================== --- python/branches/py3k/Modules/zlibmodule.c (original) +++ python/branches/py3k/Modules/zlibmodule.c Wed Dec 19 03:45:37 2007 @@ -1012,8 +1012,8 @@ PyInit_zlib(void) { PyObject *m, *ver; - Py_Type(&Comptype) = &PyType_Type; - Py_Type(&Decomptype) = &PyType_Type; + Py_TYPE(&Comptype) = &PyType_Type; + Py_TYPE(&Decomptype) = &PyType_Type; m = Py_InitModule4("zlib", zlib_methods, zlib_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); Modified: python/branches/py3k/Objects/abstract.c ============================================================================== --- python/branches/py3k/Objects/abstract.c (original) +++ python/branches/py3k/Objects/abstract.c Wed Dec 19 03:45:37 2007 @@ -343,7 +343,7 @@ if (!PyObject_CheckBuffer(obj)) { PyErr_Format(PyExc_TypeError, "'%100s' does not have the buffer interface", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); return -1; } return (*(obj->ob_type->tp_as_buffer->bf_getbuffer))(obj, view, flags); Modified: python/branches/py3k/Objects/bytesobject.c ============================================================================== --- python/branches/py3k/Objects/bytesobject.c (original) +++ python/branches/py3k/Objects/bytesobject.c Wed Dec 19 03:45:37 2007 @@ -20,7 +20,7 @@ if (nullbytes == NULL) return 0; nullbytes->ob_bytes = NULL; - Py_Size(nullbytes) = nullbytes->ob_alloc = 0; + Py_SIZE(nullbytes) = nullbytes->ob_alloc = 0; nullbytes->ob_exports = 0; return 1; } @@ -62,7 +62,7 @@ ptr = ""; else ptr = obj->ob_bytes; - ret = PyBuffer_FillInfo(view, ptr, Py_Size(obj), 0, flags); + ret = PyBuffer_FillInfo(view, ptr, Py_SIZE(obj), 0, flags); if (ret >= 0) { obj->ob_exports++; } @@ -78,13 +78,13 @@ static Py_ssize_t _getbuffer(PyObject *obj, Py_buffer *view) { - PyBufferProcs *buffer = Py_Type(obj)->tp_as_buffer; + PyBufferProcs *buffer = Py_TYPE(obj)->tp_as_buffer; if (buffer == NULL || buffer->bf_getbuffer == NULL) { PyErr_Format(PyExc_TypeError, "Type %.100s doesn't support the buffer API", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); return -1; } @@ -129,7 +129,7 @@ memcpy(new->ob_bytes, bytes, size); new->ob_bytes[size] = '\0'; /* Trailing null byte */ } - Py_Size(new) = size; + Py_SIZE(new) = size; new->ob_alloc = alloc; new->ob_exports = 0; @@ -170,7 +170,7 @@ } else if (size < alloc) { /* Within allocated size; quick exit */ - Py_Size(self) = size; + Py_SIZE(self) = size; ((PyBytesObject *)self)->ob_bytes[size] = '\0'; /* Trailing null */ return 0; } @@ -200,7 +200,7 @@ } ((PyBytesObject *)self)->ob_bytes = sval; - Py_Size(self) = size; + Py_SIZE(self) = size; ((PyBytesObject *)self)->ob_alloc = alloc; ((PyBytesObject *)self)->ob_bytes[size] = '\0'; /* Trailing null byte */ @@ -219,7 +219,7 @@ if (_getbuffer(a, &va) < 0 || _getbuffer(b, &vb) < 0) { PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s", - Py_Type(a)->tp_name, Py_Type(b)->tp_name); + Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name); goto done; } @@ -248,7 +248,7 @@ static Py_ssize_t bytes_length(PyBytesObject *self) { - return Py_Size(self); + return Py_SIZE(self); } static PyObject * @@ -260,19 +260,19 @@ if (_getbuffer(other, &vo) < 0) { PyErr_Format(PyExc_TypeError, "can't concat bytes to %.100s", - Py_Type(self)->tp_name); + Py_TYPE(self)->tp_name); return NULL; } - mysize = Py_Size(self); + mysize = Py_SIZE(self); size = mysize + vo.len; if (size < 0) { PyObject_ReleaseBuffer(other, &vo); return PyErr_NoMemory(); } if (size < self->ob_alloc) { - Py_Size(self) = size; - self->ob_bytes[Py_Size(self)] = '\0'; /* Trailing null byte */ + Py_SIZE(self) = size; + self->ob_bytes[Py_SIZE(self)] = '\0'; /* Trailing null byte */ } else if (PyBytes_Resize((PyObject *)self, size) < 0) { PyObject_ReleaseBuffer(other, &vo); @@ -293,7 +293,7 @@ if (count < 0) count = 0; - mysize = Py_Size(self); + mysize = Py_SIZE(self); size = mysize * count; if (count != 0 && size / count != mysize) return PyErr_NoMemory(); @@ -318,13 +318,13 @@ if (count < 0) count = 0; - mysize = Py_Size(self); + mysize = Py_SIZE(self); size = mysize * count; if (count != 0 && size / count != mysize) return PyErr_NoMemory(); if (size < self->ob_alloc) { - Py_Size(self) = size; - self->ob_bytes[Py_Size(self)] = '\0'; /* Trailing null byte */ + Py_SIZE(self) = size; + self->ob_bytes[Py_SIZE(self)] = '\0'; /* Trailing null byte */ } else if (PyBytes_Resize((PyObject *)self, size) < 0) return NULL; @@ -345,8 +345,8 @@ bytes_getitem(PyBytesObject *self, Py_ssize_t i) { if (i < 0) - i += Py_Size(self); - if (i < 0 || i >= Py_Size(self)) { + i += Py_SIZE(self); + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; } @@ -365,7 +365,7 @@ if (i < 0) i += PyBytes_GET_SIZE(self); - if (i < 0 || i >= Py_Size(self)) { + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return NULL; } @@ -437,7 +437,7 @@ if (_getbuffer(values, &vbytes) < 0) { PyErr_Format(PyExc_TypeError, "can't set bytes slice from %.100s", - Py_Type(values)->tp_name); + Py_TYPE(values)->tp_name); return -1; } needed = vbytes.len; @@ -448,8 +448,8 @@ lo = 0; if (hi < lo) hi = lo; - if (hi > Py_Size(self)) - hi = Py_Size(self); + if (hi > Py_SIZE(self)) + hi = Py_SIZE(self); avail = hi - lo; if (avail < 0) @@ -464,11 +464,11 @@ 0 lo new_hi new_size */ memmove(self->ob_bytes + lo + needed, self->ob_bytes + hi, - Py_Size(self) - hi); + Py_SIZE(self) - hi); } /* XXX(nnorwitz): need to verify this can't overflow! */ if (PyBytes_Resize((PyObject *)self, - Py_Size(self) + needed - avail) < 0) { + Py_SIZE(self) + needed - avail) < 0) { res = -1; goto finish; } @@ -480,7 +480,7 @@ 0 lo new_hi new_size */ memmove(self->ob_bytes + lo + needed, self->ob_bytes + hi, - Py_Size(self) - lo - needed); + Py_SIZE(self) - lo - needed); } } @@ -500,9 +500,9 @@ Py_ssize_t ival; if (i < 0) - i += Py_Size(self); + i += Py_SIZE(self); - if (i < 0 || i >= Py_Size(self)) { + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return -1; } @@ -538,7 +538,7 @@ if (i < 0) i += PyBytes_GET_SIZE(self); - if (i < 0 || i >= Py_Size(self)) { + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "bytearray index out of range"); return -1; } @@ -592,7 +592,7 @@ else { assert(PyBytes_Check(values)); bytes = ((PyBytesObject *)values)->ob_bytes; - needed = Py_Size(values); + needed = Py_SIZE(values); } /* Make sure b[5:2] = ... inserts before 5, not before 2. */ if ((step < 0 && start < stop) || @@ -608,10 +608,10 @@ 0 lo new_hi new_size */ memmove(self->ob_bytes + start + needed, self->ob_bytes + stop, - Py_Size(self) - stop); + Py_SIZE(self) - stop); } if (PyBytes_Resize((PyObject *)self, - Py_Size(self) + needed - slicelen) < 0) + Py_SIZE(self) + needed - slicelen) < 0) return -1; if (slicelen < needed) { /* @@ -621,7 +621,7 @@ 0 lo new_hi new_size */ memmove(self->ob_bytes + start + needed, self->ob_bytes + stop, - Py_Size(self) - start - needed); + Py_SIZE(self) - start - needed); } } @@ -692,7 +692,7 @@ PyObject *it; PyObject *(*iternext)(PyObject *); - if (Py_Size(self) != 0) { + if (Py_SIZE(self) != 0) { /* Empty previous contents (yes, do this first of all!) */ if (PyBytes_Resize((PyObject *)self, 0) < 0) return -1; @@ -780,7 +780,7 @@ it = PyObject_GetIter(arg); if (it == NULL) return -1; - iternext = *Py_Type(it)->tp_iternext; + iternext = *Py_TYPE(it)->tp_iternext; /* Run the iterator to exhaustion */ for (;;) { @@ -812,11 +812,11 @@ } /* Append the byte */ - if (Py_Size(self) < self->ob_alloc) - Py_Size(self)++; - else if (PyBytes_Resize((PyObject *)self, Py_Size(self)+1) < 0) + if (Py_SIZE(self) < self->ob_alloc) + Py_SIZE(self)++; + else if (PyBytes_Resize((PyObject *)self, Py_SIZE(self)+1) < 0) goto error; - self->ob_bytes[Py_Size(self)-1] = value; + self->ob_bytes[Py_SIZE(self)-1] = value; } /* Clean up and return success */ @@ -837,7 +837,7 @@ static const char *hexdigits = "0123456789abcdef"; const char *quote_prefix = "bytearray(b"; const char *quote_postfix = ")"; - Py_ssize_t length = Py_Size(self); + Py_ssize_t length = Py_SIZE(self); /* 14 == strlen(quote_prefix) + 2 + strlen(quote_postfix) */ size_t newsize = 14 + 4 * length; PyObject *v; @@ -1008,7 +1008,7 @@ if (self->ob_bytes != 0) { PyMem_Free(self->ob_bytes); } - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } @@ -1196,7 +1196,7 @@ PyErr_Clear(); if (_getbuffer(arg, &varg) < 0) return -1; - pos = stringlib_find(PyBytes_AS_STRING(self), Py_Size(self), + pos = stringlib_find(PyBytes_AS_STRING(self), Py_SIZE(self), varg.buf, varg.len, 0); PyObject_ReleaseBuffer(arg, &varg); return pos >= 0; @@ -1206,7 +1206,7 @@ return -1; } - return memchr(PyBytes_AS_STRING(self), ival, Py_Size(self)) != NULL; + return memchr(PyBytes_AS_STRING(self), ival, Py_SIZE(self)) != NULL; } @@ -2109,7 +2109,7 @@ count++; } /* Always force the list to the expected size. */ -#define FIX_PREALLOC_SIZE(list) Py_Size(list) = count +#define FIX_PREALLOC_SIZE(list) Py_SIZE(list) = count Py_LOCAL_INLINE(PyObject *) @@ -2495,7 +2495,7 @@ bytes_reverse(PyBytesObject *self, PyObject *unused) { char swap, *head, *tail; - Py_ssize_t i, j, n = Py_Size(self); + Py_ssize_t i, j, n = Py_SIZE(self); j = n / 2; head = self->ob_bytes; @@ -2517,7 +2517,7 @@ bytes_insert(PyBytesObject *self, PyObject *args) { int value; - Py_ssize_t where, n = Py_Size(self); + Py_ssize_t where, n = Py_SIZE(self); if (!PyArg_ParseTuple(args, "ni:insert", &where, &value)) return NULL; @@ -2556,7 +2556,7 @@ bytes_append(PyBytesObject *self, PyObject *arg) { int value; - Py_ssize_t n = Py_Size(self); + Py_ssize_t n = Py_SIZE(self); if (! _getbytevalue(arg, &value)) return NULL; @@ -2588,7 +2588,7 @@ /* bytes_setslice code only accepts something supporting PEP 3118. */ if (PyObject_CheckBuffer(arg)) { - if (bytes_setslice(self, Py_Size(self), Py_Size(self), arg) == -1) + if (bytes_setslice(self, Py_SIZE(self), Py_SIZE(self), arg) == -1) return NULL; Py_RETURN_NONE; @@ -2642,7 +2642,7 @@ bytes_pop(PyBytesObject *self, PyObject *args) { int value; - Py_ssize_t where = -1, n = Py_Size(self); + Py_ssize_t where = -1, n = Py_SIZE(self); if (!PyArg_ParseTuple(args, "|n:pop", &where)) return NULL; @@ -2653,8 +2653,8 @@ return NULL; } if (where < 0) - where += Py_Size(self); - if (where < 0 || where >= Py_Size(self)) { + where += Py_SIZE(self); + if (where < 0 || where >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } @@ -2675,7 +2675,7 @@ bytes_remove(PyBytesObject *self, PyObject *arg) { int value; - Py_ssize_t where, n = Py_Size(self); + Py_ssize_t where, n = Py_SIZE(self); if (! _getbytevalue(arg, &value)) return NULL; @@ -2743,7 +2743,7 @@ argsize = varg.len; } myptr = self->ob_bytes; - mysize = Py_Size(self); + mysize = Py_SIZE(self); left = lstrip_helper(myptr, mysize, argptr, argsize); if (left == mysize) right = left; @@ -2779,7 +2779,7 @@ argsize = varg.len; } myptr = self->ob_bytes; - mysize = Py_Size(self); + mysize = Py_SIZE(self); left = lstrip_helper(myptr, mysize, argptr, argsize); right = mysize; if (arg != Py_None) @@ -2812,7 +2812,7 @@ argsize = varg.len; } myptr = self->ob_bytes; - mysize = Py_Size(self); + mysize = Py_SIZE(self); left = 0; right = rstrip_helper(myptr, mysize, argptr, argsize); if (arg != Py_None) @@ -2863,7 +2863,7 @@ bytes_join(PyBytesObject *self, PyObject *it) { PyObject *seq; - Py_ssize_t mysize = Py_Size(self); + Py_ssize_t mysize = Py_SIZE(self); Py_ssize_t i; Py_ssize_t n; PyObject **items; @@ -2886,12 +2886,12 @@ "can only join an iterable of bytes " "(item %ld has type '%.100s')", /* XXX %ld isn't right on Win64 */ - (long)i, Py_Type(obj)->tp_name); + (long)i, Py_TYPE(obj)->tp_name); goto error; } if (i > 0) totalsize += mysize; - totalsize += Py_Size(obj); + totalsize += Py_SIZE(obj); if (totalsize < 0) { PyErr_NoMemory(); goto error; @@ -2905,7 +2905,7 @@ dest = PyBytes_AS_STRING(result); for (i = 0; i < n; i++) { PyObject *obj = items[i]; - Py_ssize_t size = Py_Size(obj); + Py_ssize_t size = Py_SIZE(obj); char *buf; if (PyBytes_Check(obj)) buf = PyBytes_AS_STRING(obj); @@ -3004,7 +3004,7 @@ PyObject *latin1, *dict; if (self->ob_bytes) latin1 = PyUnicode_DecodeLatin1(self->ob_bytes, - Py_Size(self), NULL); + Py_SIZE(self), NULL); else latin1 = PyUnicode_FromString(""); @@ -3015,7 +3015,7 @@ Py_INCREF(dict); } - return Py_BuildValue("(O(Ns)N)", Py_Type(self), latin1, "latin-1", dict); + return Py_BuildValue("(O(Ns)N)", Py_TYPE(self), latin1, "latin-1", dict); } static PySequenceMethods bytes_as_sequence = { Modified: python/branches/py3k/Objects/classobject.c ============================================================================== --- python/branches/py3k/Objects/classobject.c (original) +++ python/branches/py3k/Objects/classobject.c Wed Dec 19 03:45:37 2007 @@ -208,7 +208,7 @@ { PyObject *self = a->im_self; PyObject *func = a->im_func; - PyObject *klass = (PyObject*)Py_Type(self); + PyObject *klass = (PyObject*)Py_TYPE(self); PyObject *funcname = NULL ,*klassname = NULL, *result = NULL; char *defname = "?"; Modified: python/branches/py3k/Objects/dictobject.c ============================================================================== --- python/branches/py3k/Objects/dictobject.c (original) +++ python/branches/py3k/Objects/dictobject.c Wed Dec 19 03:45:37 2007 @@ -203,7 +203,7 @@ if (num_free_dicts) { mp = free_dicts[--num_free_dicts]; assert (mp != NULL); - assert (Py_Type(mp) == &PyDict_Type); + assert (Py_TYPE(mp) == &PyDict_Type); _Py_NewReference((PyObject *)mp); if (mp->ma_fill) { EMPTY_TO_MINSIZE(mp); @@ -897,10 +897,10 @@ } if (mp->ma_table != mp->ma_smalltable) PyMem_DEL(mp->ma_table); - if (num_free_dicts < MAXFREEDICTS && Py_Type(mp) == &PyDict_Type) + if (num_free_dicts < MAXFREEDICTS && Py_TYPE(mp) == &PyDict_Type) free_dicts[num_free_dicts++] = mp; else - Py_Type(mp)->tp_free((PyObject *)mp); + Py_TYPE(mp)->tp_free((PyObject *)mp); Py_TRASHCAN_SAFE_END(mp) } @@ -1014,7 +1014,7 @@ if (missing_str == NULL) missing_str = PyUnicode_InternFromString("__missing__"); - missing = _PyType_Lookup(Py_Type(mp), missing_str); + missing = _PyType_Lookup(Py_TYPE(mp), missing_str); if (missing != NULL) return PyObject_CallFunctionObjArgs(missing, (PyObject *)mp, key, NULL); Modified: python/branches/py3k/Objects/enumobject.c ============================================================================== --- python/branches/py3k/Objects/enumobject.c (original) +++ python/branches/py3k/Objects/enumobject.c Wed Dec 19 03:45:37 2007 @@ -46,7 +46,7 @@ Py_XDECREF(en->en_sit); Py_XDECREF(en->en_result); Py_XDECREF(en->en_longindex); - Py_Type(en)->tp_free(en); + Py_TYPE(en)->tp_free(en); } static int @@ -108,7 +108,7 @@ PyObject *result = en->en_result; PyObject *it = en->en_sit; - next_item = (*Py_Type(it)->tp_iternext)(it); + next_item = (*Py_TYPE(it)->tp_iternext)(it); if (next_item == NULL) return NULL; @@ -237,7 +237,7 @@ { PyObject_GC_UnTrack(ro); Py_XDECREF(ro->seq); - Py_Type(ro)->tp_free(ro); + Py_TYPE(ro)->tp_free(ro); } static int Modified: python/branches/py3k/Objects/exceptions.c ============================================================================== --- python/branches/py3k/Objects/exceptions.c (original) +++ python/branches/py3k/Objects/exceptions.c Wed Dec 19 03:45:37 2007 @@ -42,7 +42,7 @@ static int BaseException_init(PyBaseExceptionObject *self, PyObject *args, PyObject *kwds) { - if (!_PyArg_NoKeywords(Py_Type(self)->tp_name, kwds)) + if (!_PyArg_NoKeywords(Py_TYPE(self)->tp_name, kwds)) return -1; Py_DECREF(self->args); @@ -68,7 +68,7 @@ { _PyObject_GC_UNTRACK(self); BaseException_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static int @@ -101,7 +101,7 @@ char *name; char *dot; - name = (char *)Py_Type(self)->tp_name; + name = (char *)Py_TYPE(self)->tp_name; dot = strrchr(name, '.'); if (dot != NULL) name = dot+1; @@ -113,9 +113,9 @@ BaseException_reduce(PyBaseExceptionObject *self) { if (self->args && self->dict) - return PyTuple_Pack(3, Py_Type(self), self->args, self->dict); + return PyTuple_Pack(3, Py_TYPE(self), self->args, self->dict); else - return PyTuple_Pack(2, Py_Type(self), self->args); + return PyTuple_Pack(2, Py_TYPE(self), self->args); } /* @@ -465,7 +465,7 @@ { _PyObject_GC_UNTRACK(self); SystemExit_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static int @@ -570,7 +570,7 @@ { _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static int @@ -636,9 +636,9 @@ Py_INCREF(args); if (self->dict) - res = PyTuple_Pack(3, Py_Type(self), args, self->dict); + res = PyTuple_Pack(3, Py_TYPE(self), args, self->dict); else - res = PyTuple_Pack(2, Py_Type(self), args); + res = PyTuple_Pack(2, Py_TYPE(self), args); Py_DECREF(args); return res; } @@ -691,7 +691,7 @@ { _PyObject_GC_UNTRACK(self); WindowsError_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static int @@ -889,7 +889,7 @@ { _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static int @@ -1316,7 +1316,7 @@ { _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); - Py_Type(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } static int Modified: python/branches/py3k/Objects/floatobject.c ============================================================================== --- python/branches/py3k/Objects/floatobject.c (original) +++ python/branches/py3k/Objects/floatobject.c Wed Dec 19 03:45:37 2007 @@ -44,8 +44,8 @@ p = &((PyFloatBlock *)p)->objects[0]; q = p + N_FLOATOBJECTS; while (--q > p) - Py_Type(q) = (struct _typeobject *)(q-1); - Py_Type(q) = NULL; + Py_TYPE(q) = (struct _typeobject *)(q-1); + Py_TYPE(q) = NULL; return p + N_FLOATOBJECTS - 1; } @@ -105,7 +105,7 @@ } /* Inline PyObject_New */ op = free_list; - free_list = (PyFloatObject *)Py_Type(op); + free_list = (PyFloatObject *)Py_TYPE(op); PyObject_INIT(op, &PyFloat_Type); op->ob_fval = fval; return (PyObject *) op; @@ -221,11 +221,11 @@ float_dealloc(PyFloatObject *op) { if (PyFloat_CheckExact(op)) { - Py_Type(op) = (struct _typeobject *)free_list; + Py_TYPE(op) = (struct _typeobject *)free_list; free_list = op; } else - Py_Type(op)->tp_free((PyObject *)op); + Py_TYPE(op)->tp_free((PyObject *)op); } double @@ -243,7 +243,7 @@ return -1; } - if ((nb = Py_Type(op)->tp_as_number) == NULL || nb->nb_float == NULL) { + if ((nb = Py_TYPE(op)->tp_as_number) == NULL || nb->nb_float == NULL) { PyErr_SetString(PyExc_TypeError, "a float is required"); return -1; } @@ -1088,7 +1088,7 @@ if (!PyUnicode_Check(arg)) { PyErr_Format(PyExc_TypeError, "__getformat__() argument must be string, not %.500s", - Py_Type(arg)->tp_name); + Py_TYPE(arg)->tp_name); return NULL; } s = PyUnicode_AsString(arg); @@ -1412,7 +1412,7 @@ for (i = 0, p = &list->objects[0]; i < N_FLOATOBJECTS; i++, p++) { - if (PyFloat_CheckExact(p) && Py_Refcnt(p) != 0) + if (PyFloat_CheckExact(p) && Py_REFCNT(p) != 0) frem++; } next = list->next; @@ -1423,8 +1423,8 @@ i < N_FLOATOBJECTS; i++, p++) { if (!PyFloat_CheckExact(p) || - Py_Refcnt(p) == 0) { - Py_Type(p) = (struct _typeobject *) + Py_REFCNT(p) == 0) { + Py_TYPE(p) = (struct _typeobject *) free_list; free_list = p; } @@ -1456,7 +1456,7 @@ i < N_FLOATOBJECTS; i++, p++) { if (PyFloat_CheckExact(p) && - Py_Refcnt(p) != 0) { + Py_REFCNT(p) != 0) { char buf[100]; format_float(buf, sizeof(buf), p, PREC_STR); /* XXX(twouters) cast refcount to @@ -1465,7 +1465,7 @@ */ fprintf(stderr, "# \n", - p, (long)Py_Refcnt(p), buf); + p, (long)Py_REFCNT(p), buf); } } list = list->next; Modified: python/branches/py3k/Objects/frameobject.c ============================================================================== --- python/branches/py3k/Objects/frameobject.c (original) +++ python/branches/py3k/Objects/frameobject.c Wed Dec 19 03:45:37 2007 @@ -630,7 +630,7 @@ --numfree; f = free_list; free_list = free_list->f_back; - if (Py_Size(f) < extras) { + if (Py_SIZE(f) < extras) { f = PyObject_GC_Resize(PyFrameObject, f, extras); if (f == NULL) { Py_DECREF(builtins); Modified: python/branches/py3k/Objects/funcobject.c ============================================================================== --- python/branches/py3k/Objects/funcobject.c (original) +++ python/branches/py3k/Objects/funcobject.c Wed Dec 19 03:45:37 2007 @@ -721,7 +721,7 @@ { _PyObject_GC_UNTRACK((PyObject *)cm); Py_XDECREF(cm->cm_callable); - Py_Type(cm)->tp_free((PyObject *)cm); + Py_TYPE(cm)->tp_free((PyObject *)cm); } static int @@ -750,7 +750,7 @@ return NULL; } if (type == NULL) - type = (PyObject *)(Py_Type(obj)); + type = (PyObject *)(Py_TYPE(obj)); return PyMethod_New(cm->cm_callable, type); } @@ -877,7 +877,7 @@ { _PyObject_GC_UNTRACK((PyObject *)sm); Py_XDECREF(sm->sm_callable); - Py_Type(sm)->tp_free((PyObject *)sm); + Py_TYPE(sm)->tp_free((PyObject *)sm); } static int Modified: python/branches/py3k/Objects/genobject.c ============================================================================== --- python/branches/py3k/Objects/genobject.c (original) +++ python/branches/py3k/Objects/genobject.c Wed Dec 19 03:45:37 2007 @@ -28,7 +28,7 @@ if (gen->gi_frame != NULL && gen->gi_frame->f_stacktop != NULL) { /* Generator is paused, so we need to close */ - Py_Type(gen)->tp_del(self); + Py_TYPE(gen)->tp_del(self); if (self->ob_refcnt > 0) return; /* resurrected. :( */ } Modified: python/branches/py3k/Objects/iterobject.c ============================================================================== --- python/branches/py3k/Objects/iterobject.c (original) +++ python/branches/py3k/Objects/iterobject.c Wed Dec 19 03:45:37 2007 @@ -253,7 +253,7 @@ assert(PyTuple_Check(args)); - if (Py_Type(&PyZipIter_Type) == NULL) { + if (Py_TYPE(&PyZipIter_Type) == NULL) { if (PyType_Ready(&PyZipIter_Type) < 0) return NULL; } Modified: python/branches/py3k/Objects/listobject.c ============================================================================== --- python/branches/py3k/Objects/listobject.c (original) +++ python/branches/py3k/Objects/listobject.c Wed Dec 19 03:45:37 2007 @@ -34,7 +34,7 @@ */ if (allocated >= newsize && newsize >= (allocated >> 1)) { assert(self->ob_item != NULL || newsize == 0); - Py_Size(self) = newsize; + Py_SIZE(self) = newsize; return 0; } @@ -58,7 +58,7 @@ return -1; } self->ob_item = items; - Py_Size(self) = newsize; + Py_SIZE(self) = newsize; self->allocated = new_allocated; return 0; } @@ -114,7 +114,7 @@ } memset(op->ob_item, 0, nbytes); } - Py_Size(op) = size; + Py_SIZE(op) = size; op->allocated = size; _PyObject_GC_TRACK(op); return (PyObject *) op; @@ -128,7 +128,7 @@ return -1; } else - return Py_Size(op); + return Py_SIZE(op); } static PyObject *indexerr = NULL; @@ -140,7 +140,7 @@ PyErr_BadInternalCall(); return NULL; } - if (i < 0 || i >= Py_Size(op)) { + if (i < 0 || i >= Py_SIZE(op)) { if (indexerr == NULL) indexerr = PyUnicode_FromString( "list index out of range"); @@ -161,7 +161,7 @@ PyErr_BadInternalCall(); return -1; } - if (i < 0 || i >= Py_Size(op)) { + if (i < 0 || i >= Py_SIZE(op)) { Py_XDECREF(newitem); PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -177,7 +177,7 @@ static int ins1(PyListObject *self, Py_ssize_t where, PyObject *v) { - Py_ssize_t i, n = Py_Size(self); + Py_ssize_t i, n = Py_SIZE(self); PyObject **items; if (v == NULL) { PyErr_BadInternalCall(); @@ -259,7 +259,7 @@ There's a simple test case where somehow this reduces thrashing when a *very* large list is created and immediately deleted. */ - i = Py_Size(op); + i = Py_SIZE(op); while (--i >= 0) { Py_XDECREF(op->ob_item[i]); } @@ -268,7 +268,7 @@ if (num_free_lists < MAXFREELISTS && PyList_CheckExact(op)) free_lists[num_free_lists++] = op; else - Py_Type(op)->tp_free((PyObject *)op); + Py_TYPE(op)->tp_free((PyObject *)op); Py_TRASHCAN_SAFE_END(op) } @@ -284,7 +284,7 @@ return i > 0 ? PyUnicode_FromString("[...]") : NULL; } - if (Py_Size(v) == 0) { + if (Py_SIZE(v) == 0) { result = PyUnicode_FromString("[]"); goto Done; } @@ -295,7 +295,7 @@ /* Do repr() on each element. Note that this may mutate the list, so must refetch the list size on each iteration. */ - for (i = 0; i < Py_Size(v); ++i) { + for (i = 0; i < Py_SIZE(v); ++i) { int status; if (Py_EnterRecursiveCall(" while getting the repr of a list")) goto Done; @@ -345,7 +345,7 @@ static Py_ssize_t list_length(PyListObject *a) { - return Py_Size(a); + return Py_SIZE(a); } static int @@ -354,7 +354,7 @@ Py_ssize_t i; int cmp; - for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(a); ++i) + for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i) cmp = PyObject_RichCompareBool(el, PyList_GET_ITEM(a, i), Py_EQ); return cmp; @@ -363,7 +363,7 @@ static PyObject * list_item(PyListObject *a, Py_ssize_t i) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { if (indexerr == NULL) indexerr = PyUnicode_FromString( "list index out of range"); @@ -382,12 +382,12 @@ Py_ssize_t i, len; if (ilow < 0) ilow = 0; - else if (ilow > Py_Size(a)) - ilow = Py_Size(a); + else if (ilow > Py_SIZE(a)) + ilow = Py_SIZE(a); if (ihigh < ilow) ihigh = ilow; - else if (ihigh > Py_Size(a)) - ihigh = Py_Size(a); + else if (ihigh > Py_SIZE(a)) + ihigh = Py_SIZE(a); len = ihigh - ilow; np = (PyListObject *) PyList_New(len); if (np == NULL) @@ -427,7 +427,7 @@ return NULL; } #define b ((PyListObject *)bb) - size = Py_Size(a) + Py_Size(b); + size = Py_SIZE(a) + Py_SIZE(b); if (size < 0) return PyErr_NoMemory(); np = (PyListObject *) PyList_New(size); @@ -436,14 +436,14 @@ } src = a->ob_item; dest = np->ob_item; - for (i = 0; i < Py_Size(a); i++) { + for (i = 0; i < Py_SIZE(a); i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; } src = b->ob_item; - dest = np->ob_item + Py_Size(a); - for (i = 0; i < Py_Size(b); i++) { + dest = np->ob_item + Py_SIZE(a); + for (i = 0; i < Py_SIZE(b); i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; @@ -462,8 +462,8 @@ PyObject *elem; if (n < 0) n = 0; - size = Py_Size(a) * n; - if (n && size/n != Py_Size(a)) + size = Py_SIZE(a) * n; + if (n && size/n != Py_SIZE(a)) return PyErr_NoMemory(); if (size == 0) return PyList_New(0); @@ -472,7 +472,7 @@ return NULL; items = np->ob_item; - if (Py_Size(a) == 1) { + if (Py_SIZE(a) == 1) { elem = a->ob_item[0]; for (i = 0; i < n; i++) { items[i] = elem; @@ -483,7 +483,7 @@ p = np->ob_item; items = a->ob_item; for (i = 0; i < n; i++) { - for (j = 0; j < Py_Size(a); j++) { + for (j = 0; j < Py_SIZE(a); j++) { *p = items[j]; Py_INCREF(*p); p++; @@ -500,8 +500,8 @@ if (item != NULL) { /* Because XDECREF can recursively invoke operations on this list, we make it empty first. */ - i = Py_Size(a); - Py_Size(a) = 0; + i = Py_SIZE(a); + Py_SIZE(a) = 0; a->ob_item = NULL; a->allocated = 0; while (--i >= 0) { @@ -547,7 +547,7 @@ else { if (a == b) { /* Special case "a[i:j] = a" -- copy b first */ - v = list_slice(b, 0, Py_Size(b)); + v = list_slice(b, 0, Py_SIZE(b)); if (v == NULL) return result; result = list_ass_slice(a, ilow, ihigh, v); @@ -562,18 +562,18 @@ } if (ilow < 0) ilow = 0; - else if (ilow > Py_Size(a)) - ilow = Py_Size(a); + else if (ilow > Py_SIZE(a)) + ilow = Py_SIZE(a); if (ihigh < ilow) ihigh = ilow; - else if (ihigh > Py_Size(a)) - ihigh = Py_Size(a); + else if (ihigh > Py_SIZE(a)) + ihigh = Py_SIZE(a); norig = ihigh - ilow; assert(norig >= 0); d = n - norig; - if (Py_Size(a) + d == 0) { + if (Py_SIZE(a) + d == 0) { Py_XDECREF(v_as_SF); return list_clear(a); } @@ -591,12 +591,12 @@ if (d < 0) { /* Delete -d items */ memmove(&item[ihigh+d], &item[ihigh], - (Py_Size(a) - ihigh)*sizeof(PyObject *)); - list_resize(a, Py_Size(a) + d); + (Py_SIZE(a) - ihigh)*sizeof(PyObject *)); + list_resize(a, Py_SIZE(a) + d); item = a->ob_item; } else if (d > 0) { /* Insert d items */ - k = Py_Size(a); + k = Py_SIZE(a); if (list_resize(a, k+d) < 0) goto Error; item = a->ob_item; @@ -671,7 +671,7 @@ list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) { PyObject *old_value; - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); return -1; @@ -730,7 +730,7 @@ Py_DECREF(b); Py_RETURN_NONE; } - m = Py_Size(self); + m = Py_SIZE(self); if (list_resize(self, m + n) == -1) { Py_DECREF(b); return NULL; @@ -759,14 +759,14 @@ /* Guess a result list size. */ n = _PyObject_LengthHint(b, 8); - m = Py_Size(self); + m = Py_SIZE(self); mn = m + n; if (mn >= m) { /* Make room. */ if (list_resize(self, mn) == -1) goto error; /* Make the list sane again. */ - Py_Size(self) = m; + Py_SIZE(self) = m; } /* Else m + n overflowed; on the chance that n lied, and there really * is enough room, ignore it. If n was telling the truth, we'll @@ -785,10 +785,10 @@ } break; } - if (Py_Size(self) < self->allocated) { + if (Py_SIZE(self) < self->allocated) { /* steals ref */ - PyList_SET_ITEM(self, Py_Size(self), item); - ++Py_Size(self); + PyList_SET_ITEM(self, Py_SIZE(self), item); + ++Py_SIZE(self); } else { int status = app1(self, item); @@ -799,8 +799,8 @@ } /* Cut back result list if initial guess was too large. */ - if (Py_Size(self) < self->allocated) - list_resize(self, Py_Size(self)); /* shrinking can't fail */ + if (Py_SIZE(self) < self->allocated) + list_resize(self, Py_SIZE(self)); /* shrinking can't fail */ Py_DECREF(it); Py_RETURN_NONE; @@ -839,20 +839,20 @@ if (!PyArg_ParseTuple(args, "|n:pop", &i)) return NULL; - if (Py_Size(self) == 0) { + if (Py_SIZE(self) == 0) { /* Special-case most common failure cause */ PyErr_SetString(PyExc_IndexError, "pop from empty list"); return NULL; } if (i < 0) - i += Py_Size(self); - if (i < 0 || i >= Py_Size(self)) { + i += Py_SIZE(self); + if (i < 0 || i >= Py_SIZE(self)) { PyErr_SetString(PyExc_IndexError, "pop index out of range"); return NULL; } v = self->ob_item[i]; - if (i == Py_Size(self) - 1) { - status = list_resize(self, Py_Size(self) - 1); + if (i == Py_SIZE(self) - 1) { + status = list_resize(self, Py_SIZE(self) - 1); assert(status >= 0); return v; /* and v now owns the reference the list had */ } @@ -2009,10 +2009,10 @@ * sorting (allowing mutations during sorting is a core-dump * factory, since ob_item may change). */ - saved_ob_size = Py_Size(self); + saved_ob_size = Py_SIZE(self); saved_ob_item = self->ob_item; saved_allocated = self->allocated; - Py_Size(self) = 0; + Py_SIZE(self) = 0; self->ob_item = NULL; self->allocated = -1; /* any operation will reset it to >= 0 */ @@ -2118,8 +2118,8 @@ dsu_fail: final_ob_item = self->ob_item; - i = Py_Size(self); - Py_Size(self) = saved_ob_size; + i = Py_SIZE(self); + Py_SIZE(self) = saved_ob_size; self->ob_item = saved_ob_item; self->allocated = saved_allocated; if (final_ob_item != NULL) { @@ -2154,8 +2154,8 @@ static PyObject * listreverse(PyListObject *self) { - if (Py_Size(self) > 1) - reverse_slice(self->ob_item, self->ob_item + Py_Size(self)); + if (Py_SIZE(self) > 1) + reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self)); Py_RETURN_NONE; } @@ -2168,8 +2168,8 @@ PyErr_BadInternalCall(); return -1; } - if (Py_Size(self) > 1) - reverse_slice(self->ob_item, self->ob_item + Py_Size(self)); + if (Py_SIZE(self) > 1) + reverse_slice(self->ob_item, self->ob_item + Py_SIZE(self)); return 0; } @@ -2183,7 +2183,7 @@ PyErr_BadInternalCall(); return NULL; } - n = Py_Size(v); + n = Py_SIZE(v); w = PyTuple_New(n); if (w == NULL) return NULL; @@ -2201,7 +2201,7 @@ static PyObject * listindex(PyListObject *self, PyObject *args) { - Py_ssize_t i, start=0, stop=Py_Size(self); + Py_ssize_t i, start=0, stop=Py_SIZE(self); PyObject *v; if (!PyArg_ParseTuple(args, "O|O&O&:index", &v, @@ -2209,16 +2209,16 @@ _PyEval_SliceIndex, &stop)) return NULL; if (start < 0) { - start += Py_Size(self); + start += Py_SIZE(self); if (start < 0) start = 0; } if (stop < 0) { - stop += Py_Size(self); + stop += Py_SIZE(self); if (stop < 0) stop = 0; } - for (i = start; i < stop && i < Py_Size(self); i++) { + for (i = start; i < stop && i < Py_SIZE(self); i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) return PyLong_FromSsize_t(i); @@ -2235,7 +2235,7 @@ Py_ssize_t count = 0; Py_ssize_t i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) count++; @@ -2250,7 +2250,7 @@ { Py_ssize_t i; - for (i = 0; i < Py_Size(self); i++) { + for (i = 0; i < Py_SIZE(self); i++) { int cmp = PyObject_RichCompareBool(self->ob_item[i], v, Py_EQ); if (cmp > 0) { if (list_ass_slice(self, i, i+1, @@ -2270,7 +2270,7 @@ { Py_ssize_t i; - for (i = Py_Size(o); --i >= 0; ) + for (i = Py_SIZE(o); --i >= 0; ) Py_VISIT(o->ob_item[i]); return 0; } @@ -2289,7 +2289,7 @@ vl = (PyListObject *)v; wl = (PyListObject *)w; - if (Py_Size(vl) != Py_Size(wl) && (op == Py_EQ || op == Py_NE)) { + if (Py_SIZE(vl) != Py_SIZE(wl) && (op == Py_EQ || op == Py_NE)) { /* Shortcut: if the lengths differ, the lists differ */ PyObject *res; if (op == Py_EQ) @@ -2301,7 +2301,7 @@ } /* Search for the first index where items are different */ - for (i = 0; i < Py_Size(vl) && i < Py_Size(wl); i++) { + for (i = 0; i < Py_SIZE(vl) && i < Py_SIZE(wl); i++) { int k = PyObject_RichCompareBool(vl->ob_item[i], wl->ob_item[i], Py_EQ); if (k < 0) @@ -2310,10 +2310,10 @@ break; } - if (i >= Py_Size(vl) || i >= Py_Size(wl)) { + if (i >= Py_SIZE(vl) || i >= Py_SIZE(wl)) { /* No more items to compare -- compare sizes */ - Py_ssize_t vs = Py_Size(vl); - Py_ssize_t ws = Py_Size(wl); + Py_ssize_t vs = Py_SIZE(vl); + Py_ssize_t ws = Py_SIZE(wl); int cmp; PyObject *res; switch (op) { @@ -2357,8 +2357,8 @@ return -1; /* Verify list invariants established by PyType_GenericAlloc() */ - assert(0 <= Py_Size(self)); - assert(Py_Size(self) <= self->allocated || self->allocated == -1); + assert(0 <= Py_SIZE(self)); + assert(Py_SIZE(self) <= self->allocated || self->allocated == -1); assert(self->ob_item != NULL || self->allocated == 0 || self->allocated == -1); @@ -2454,7 +2454,7 @@ PyObject* it; PyObject **src, **dest; - if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self), + if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return NULL; } @@ -2503,7 +2503,7 @@ else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; - if (PySlice_GetIndicesEx((PySliceObject*)item, Py_Size(self), + if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self), &start, &stop, &step, &slicelength) < 0) { return -1; } @@ -2551,8 +2551,8 @@ garbage[i] = PyList_GET_ITEM(self, cur); - if (cur + step >= Py_Size(self)) { - lim = Py_Size(self) - cur - 1; + if (cur + step >= Py_SIZE(self)) { + lim = Py_SIZE(self) - cur - 1; } memmove(self->ob_item + cur - i, @@ -2560,15 +2560,15 @@ lim * sizeof(PyObject *)); } cur = start + slicelength*step; - if (cur < Py_Size(self)) { + if (cur < Py_SIZE(self)) { memmove(self->ob_item + cur - slicelength, self->ob_item + cur, - (Py_Size(self) - cur) * + (Py_SIZE(self) - cur) * sizeof(PyObject *)); } - Py_Size(self) -= slicelength; - list_resize(self, Py_Size(self)); + Py_SIZE(self) -= slicelength; + list_resize(self, Py_SIZE(self)); for (i = 0; i < slicelength; i++) { Py_DECREF(garbage[i]); Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Wed Dec 19 03:45:37 2007 @@ -48,11 +48,11 @@ #define CHECK_SMALL_INT(ival) #endif -#define MEDIUM_VALUE(x) (Py_Size(x) < 0 ? -(x)->ob_digit[0] : (Py_Size(x) == 0 ? 0 : (x)->ob_digit[0])) +#define MEDIUM_VALUE(x) (Py_SIZE(x) < 0 ? -(x)->ob_digit[0] : (Py_SIZE(x) == 0 ? 0 : (x)->ob_digit[0])) /* If a freshly-allocated long is already shared, it must be a small integer, so negating it must go to PyLong_FromLong */ #define NEGATE(x) \ - do if (Py_Refcnt(x) == 1) Py_Size(x) = -Py_Size(x); \ + do if (Py_REFCNT(x) == 1) Py_SIZE(x) = -Py_SIZE(x); \ else { PyObject* tmp=PyLong_FromLong(-MEDIUM_VALUE(x)); \ Py_DECREF(x); (x) = (PyLongObject*)tmp; } \ while(0) @@ -96,13 +96,13 @@ static PyLongObject * long_normalize(register PyLongObject *v) { - Py_ssize_t j = ABS(Py_Size(v)); + Py_ssize_t j = ABS(Py_SIZE(v)); Py_ssize_t i = j; while (i > 0 && v->ob_digit[i-1] == 0) --i; if (i != j) - Py_Size(v) = (Py_Size(v) < 0) ? -(i) : i; + Py_SIZE(v) = (Py_SIZE(v) < 0) ? -(i) : i; return v; } @@ -136,18 +136,18 @@ Py_ssize_t i; assert(src != NULL); - i = Py_Size(src); + i = Py_SIZE(src); if (i < 0) i = -(i); if (i < 2) { int ival = src->ob_digit[0]; - if (Py_Size(src) < 0) + if (Py_SIZE(src) < 0) ival = -ival; CHECK_SMALL_INT(ival); } result = _PyLong_New(i); if (result != NULL) { - Py_Size(result) = Py_Size(src); + Py_SIZE(result) = Py_SIZE(src); while (--i >= 0) result->ob_digit[i] = src->ob_digit[i]; } @@ -175,7 +175,7 @@ if (!(ival>>PyLong_SHIFT)) { v = _PyLong_New(1); if (v) { - Py_Size(v) = sign; + Py_SIZE(v) = sign; v->ob_digit[0] = ival; } return (PyObject*)v; @@ -185,7 +185,7 @@ if (!(ival >> 2*PyLong_SHIFT)) { v = _PyLong_New(2); if (v) { - Py_Size(v) = 2*sign; + Py_SIZE(v) = 2*sign; v->ob_digit[0] = (digit)ival & PyLong_MASK; v->ob_digit[1] = ival >> PyLong_SHIFT; } @@ -201,7 +201,7 @@ v = _PyLong_New(ndigits); if (v != NULL) { digit *p = v->ob_digit; - Py_Size(v) = ndigits*sign; + Py_SIZE(v) = ndigits*sign; t = (unsigned long)ival; while (t) { *p++ = (digit)(t & PyLong_MASK); @@ -231,7 +231,7 @@ v = _PyLong_New(ndigits); if (v != NULL) { digit *p = v->ob_digit; - Py_Size(v) = ndigits; + Py_SIZE(v) = ndigits; while (ival) { *p++ = (digit)(ival & PyLong_MASK); ival >>= PyLong_SHIFT; @@ -273,7 +273,7 @@ frac = ldexp(frac, PyLong_SHIFT); } if (neg) - Py_Size(v) = -(Py_Size(v)); + Py_SIZE(v) = -(Py_SIZE(v)); return (PyObject *)v; } @@ -330,7 +330,7 @@ res = -1; v = (PyLongObject *)vv; - i = Py_Size(v); + i = Py_SIZE(v); switch (i) { case -1: @@ -353,7 +353,7 @@ prev = x; x = (x << PyLong_SHIFT) + v->ob_digit[i]; if ((x >> PyLong_SHIFT) != prev) { - *overflow = Py_Size(v) > 0 ? 1 : -1; + *overflow = Py_SIZE(v) > 0 ? 1 : -1; goto exit; } } @@ -367,7 +367,7 @@ res = LONG_MIN; } else { - *overflow = Py_Size(v) > 0 ? 1 : -1; + *overflow = Py_SIZE(v) > 0 ? 1 : -1; /* res is already set to -1 */ } } @@ -401,7 +401,7 @@ return 0; } /* conservative estimate */ - size = Py_Size(vv); + size = Py_SIZE(vv); return -2 <= size && size <= 2; } @@ -420,7 +420,7 @@ return -1; } v = (PyLongObject *)vv; - i = Py_Size(v); + i = Py_SIZE(v); switch (i) { case -1: return -v->ob_digit[0]; case 0: return 0; @@ -470,7 +470,7 @@ return (unsigned long) -1; } v = (PyLongObject *)vv; - i = Py_Size(v); + i = Py_SIZE(v); x = 0; if (i < 0) { PyErr_SetString(PyExc_OverflowError, @@ -508,7 +508,7 @@ return (unsigned long) -1; } v = (PyLongObject *)vv; - i = Py_Size(v); + i = Py_SIZE(v); x = 0; if (i < 0) { PyErr_SetString(PyExc_OverflowError, @@ -547,7 +547,7 @@ return (unsigned long) -1; } v = (PyLongObject *)vv; - i = Py_Size(v); + i = Py_SIZE(v); switch (i) { case 0: return 0; case 1: return v->ob_digit[0]; @@ -607,7 +607,7 @@ assert(v != NULL); assert(PyLong_Check(v)); - return Py_Size(v) == 0 ? 0 : (Py_Size(v) < 0 ? -1 : 1); + return Py_SIZE(v) == 0 ? 0 : (Py_SIZE(v) < 0 ? -1 : 1); } size_t @@ -619,7 +619,7 @@ assert(v != NULL); assert(PyLong_Check(v)); - ndigits = ABS(Py_Size(v)); + ndigits = ABS(Py_SIZE(v)); assert(ndigits == 0 || v->ob_digit[ndigits - 1] != 0); if (ndigits > 0) { digit msd = v->ob_digit[ndigits - 1]; @@ -745,7 +745,7 @@ } } - Py_Size(v) = is_signed ? -idigit : idigit; + Py_SIZE(v) = is_signed ? -idigit : idigit; return (PyObject *)long_normalize(v); } @@ -766,8 +766,8 @@ assert(v != NULL && PyLong_Check(v)); - if (Py_Size(v) < 0) { - ndigits = -(Py_Size(v)); + if (Py_SIZE(v) < 0) { + ndigits = -(Py_SIZE(v)); if (!is_signed) { PyErr_SetString(PyExc_TypeError, "can't convert negative int to unsigned"); @@ -776,7 +776,7 @@ do_twos_comp = 1; } else { - ndigits = Py_Size(v); + ndigits = Py_SIZE(v); do_twos_comp = 0; } @@ -912,7 +912,7 @@ return -1; } v = (PyLongObject *)vv; - i = Py_Size(v); + i = Py_SIZE(v); sign = 1; if (i < 0) { sign = -1; @@ -1063,7 +1063,7 @@ v = _PyLong_New(ndigits); if (v != NULL) { digit *p = v->ob_digit; - Py_Size(v) = negative ? -ndigits : ndigits; + Py_SIZE(v) = negative ? -ndigits : ndigits; t = (unsigned PY_LONG_LONG)ival; while (t) { *p++ = (digit)(t & PyLong_MASK); @@ -1093,7 +1093,7 @@ v = _PyLong_New(ndigits); if (v != NULL) { digit *p = v->ob_digit; - Py_Size(v) = ndigits; + Py_SIZE(v) = ndigits; while (ival) { *p++ = (digit)(ival & PyLong_MASK); ival >>= PyLong_SHIFT; @@ -1167,7 +1167,7 @@ } v = (PyLongObject*)vv; - switch(Py_Size(v)) { + switch(Py_SIZE(v)) { case -1: return -v->ob_digit[0]; case 0: return 0; case 1: return v->ob_digit[0]; @@ -1200,7 +1200,7 @@ } v = (PyLongObject*)vv; - switch(Py_Size(v)) { + switch(Py_SIZE(v)) { case 0: return 0; case 1: return v->ob_digit[0]; } @@ -1232,11 +1232,11 @@ return (unsigned long) -1; } v = (PyLongObject *)vv; - switch(Py_Size(v)) { + switch(Py_SIZE(v)) { case 0: return 0; case 1: return v->ob_digit[0]; } - i = Py_Size(v); + i = Py_SIZE(v); sign = 1; x = 0; if (i < 0) { @@ -1358,7 +1358,7 @@ static PyLongObject * muladd1(PyLongObject *a, wdigit n, wdigit extra) { - Py_ssize_t size_a = ABS(Py_Size(a)); + Py_ssize_t size_a = ABS(Py_SIZE(a)); PyLongObject *z = _PyLong_New(size_a+1); twodigits carry = extra; Py_ssize_t i; @@ -1404,7 +1404,7 @@ static PyLongObject * divrem1(PyLongObject *a, digit n, digit *prem) { - const Py_ssize_t size = ABS(Py_Size(a)); + const Py_ssize_t size = ABS(Py_SIZE(a)); PyLongObject *z; assert(n > 0 && n <= PyLong_MASK); @@ -1435,7 +1435,7 @@ return NULL; } assert(base >= 2 && base <= 36); - size_a = ABS(Py_Size(a)); + size_a = ABS(Py_SIZE(a)); /* Compute a rough upper bound for the length of the string */ i = base; @@ -1457,10 +1457,10 @@ return NULL; p = PyUnicode_AS_UNICODE(str) + sz; *p = '\0'; - if (Py_Size(a) < 0) + if (Py_SIZE(a) < 0) sign = '-'; - if (Py_Size(a) == 0) { + if (Py_SIZE(a) == 0) { *--p = '0'; } else if ((base & (base - 1)) == 0) { @@ -1853,7 +1853,7 @@ z = _PyLong_New(size_z); if (z == NULL) return NULL; - Py_Size(z) = 0; + Py_SIZE(z) = 0; /* `convwidth` consecutive input digits are treated as a single * digit in base `convmultmax`. @@ -1883,7 +1883,7 @@ /* Multiply z by convmult, and add c. */ pz = z->ob_digit; - pzstop = pz + Py_Size(z); + pzstop = pz + Py_SIZE(z); for (; pz < pzstop; ++pz) { c += (twodigits)*pz * convmult; *pz = (digit)(c & PyLong_MASK); @@ -1892,14 +1892,14 @@ /* carry off the current end? */ if (c) { assert(c < PyLong_BASE); - if (Py_Size(z) < size_z) { + if (Py_SIZE(z) < size_z) { *pz = (digit)c; - ++Py_Size(z); + ++Py_SIZE(z); } else { PyLongObject *tmp; /* Extremely rare. Get more space. */ - assert(Py_Size(z) == size_z); + assert(Py_SIZE(z) == size_z); tmp = _PyLong_New(size_z + 1); if (tmp == NULL) { Py_DECREF(z); @@ -1922,7 +1922,7 @@ /* reset the base to 0, else the exception message doesn't make too much sense */ base = 0; - if (Py_Size(z) != 0) + if (Py_SIZE(z) != 0) goto onError; /* there might still be other problems, therefore base remains zero here for the same reason */ @@ -1930,7 +1930,7 @@ if (str == start) goto onError; if (sign < 0) - Py_Size(z) = -(Py_Size(z)); + Py_SIZE(z) = -(Py_SIZE(z)); if (*str == 'L' || *str == 'l') str++; while (*str && isspace(Py_CHARMASK(*str))) @@ -1985,7 +1985,7 @@ long_divrem(PyLongObject *a, PyLongObject *b, PyLongObject **pdiv, PyLongObject **prem) { - Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b)); + Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b)); PyLongObject *z; if (size_b == 0) { @@ -2024,9 +2024,9 @@ The quotient z has the sign of a*b; the remainder r has the sign of a, so a = b*z + r. */ - if ((Py_Size(a) < 0) != (Py_Size(b) < 0)) + if ((Py_SIZE(a) < 0) != (Py_SIZE(b) < 0)) NEGATE(z); - if (Py_Size(a) < 0 && Py_Size(*prem) != 0) + if (Py_SIZE(a) < 0 && Py_SIZE(*prem) != 0) NEGATE(*prem); *pdiv = z; return 0; @@ -2037,7 +2037,7 @@ static PyLongObject * x_divrem(PyLongObject *v1, PyLongObject *w1, PyLongObject **prem) { - Py_ssize_t size_v = ABS(Py_Size(v1)), size_w = ABS(Py_Size(w1)); + Py_ssize_t size_v = ABS(Py_SIZE(v1)), size_w = ABS(Py_SIZE(w1)); digit d = (digit) ((twodigits)PyLong_BASE / (w1->ob_digit[size_w-1] + 1)); PyLongObject *v = mul1(v1, d); PyLongObject *w = mul1(w1, d); @@ -2051,10 +2051,10 @@ } assert(size_v >= size_w && size_w > 1); /* Assert checks by div() */ - assert(Py_Refcnt(v) == 1); /* Since v will be used as accumulator! */ - assert(size_w == ABS(Py_Size(w))); /* That's how d was calculated */ + assert(Py_REFCNT(v) == 1); /* Since v will be used as accumulator! */ + assert(size_w == ABS(Py_SIZE(w))); /* That's how d was calculated */ - size_v = ABS(Py_Size(v)); + size_v = ABS(Py_SIZE(v)); k = size_v - size_w; a = _PyLong_New(k + 1); @@ -2137,7 +2137,7 @@ static void long_dealloc(PyObject *v) { - Py_Type(v)->tp_free(v); + Py_TYPE(v)->tp_free(v); } static PyObject * @@ -2151,21 +2151,21 @@ { Py_ssize_t sign; - if (Py_Size(a) != Py_Size(b)) { - if (ABS(Py_Size(a)) == 0 && ABS(Py_Size(b)) == 0) + if (Py_SIZE(a) != Py_SIZE(b)) { + if (ABS(Py_SIZE(a)) == 0 && ABS(Py_SIZE(b)) == 0) sign = 0; else - sign = Py_Size(a) - Py_Size(b); + sign = Py_SIZE(a) - Py_SIZE(b); } else { - Py_ssize_t i = ABS(Py_Size(a)); + Py_ssize_t i = ABS(Py_SIZE(a)); while (--i >= 0 && a->ob_digit[i] == b->ob_digit[i]) ; if (i < 0) sign = 0; else { sign = (int)a->ob_digit[i] - (int)b->ob_digit[i]; - if (Py_Size(a) < 0) + if (Py_SIZE(a) < 0) sign = -sign; } } @@ -2192,7 +2192,7 @@ /* This is designed so that Python ints and longs with the same value hash to the same value, otherwise comparisons of mapping keys will turn out weird */ - i = Py_Size(v); + i = Py_SIZE(v); switch(i) { case -1: return v->ob_digit[0]==1 ? -2 : -v->ob_digit[0]; case 0: return 0; @@ -2231,7 +2231,7 @@ static PyLongObject * x_add(PyLongObject *a, PyLongObject *b) { - Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b)); + Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b)); PyLongObject *z; int i; digit carry = 0; @@ -2265,7 +2265,7 @@ static PyLongObject * x_sub(PyLongObject *a, PyLongObject *b) { - Py_ssize_t size_a = ABS(Py_Size(a)), size_b = ABS(Py_Size(b)); + Py_ssize_t size_a = ABS(Py_SIZE(a)), size_b = ABS(Py_SIZE(b)); PyLongObject *z; Py_ssize_t i; int sign = 1; @@ -2322,22 +2322,22 @@ CHECK_BINOP(a, b); - if (ABS(Py_Size(a)) <= 1 && ABS(Py_Size(b)) <= 1) { + if (ABS(Py_SIZE(a)) <= 1 && ABS(Py_SIZE(b)) <= 1) { PyObject *result = PyLong_FromLong(MEDIUM_VALUE(a) + MEDIUM_VALUE(b)); return result; } - if (Py_Size(a) < 0) { - if (Py_Size(b) < 0) { + if (Py_SIZE(a) < 0) { + if (Py_SIZE(b) < 0) { z = x_add(a, b); - if (z != NULL && Py_Size(z) != 0) - Py_Size(z) = -(Py_Size(z)); + if (z != NULL && Py_SIZE(z) != 0) + Py_SIZE(z) = -(Py_SIZE(z)); } else z = x_sub(b, a); } else { - if (Py_Size(b) < 0) + if (Py_SIZE(b) < 0) z = x_sub(a, b); else z = x_add(a, b); @@ -2352,21 +2352,21 @@ CHECK_BINOP(a, b); - if (ABS(Py_Size(a)) <= 1 && ABS(Py_Size(b)) <= 1) { + if (ABS(Py_SIZE(a)) <= 1 && ABS(Py_SIZE(b)) <= 1) { PyObject* r; r = PyLong_FromLong(MEDIUM_VALUE(a)-MEDIUM_VALUE(b)); return r; } - if (Py_Size(a) < 0) { - if (Py_Size(b) < 0) + if (Py_SIZE(a) < 0) { + if (Py_SIZE(b) < 0) z = x_sub(a, b); else z = x_add(a, b); - if (z != NULL && Py_Size(z) != 0) - Py_Size(z) = -(Py_Size(z)); + if (z != NULL && Py_SIZE(z) != 0) + Py_SIZE(z) = -(Py_SIZE(z)); } else { - if (Py_Size(b) < 0) + if (Py_SIZE(b) < 0) z = x_add(a, b); else z = x_sub(a, b); @@ -2381,15 +2381,15 @@ x_mul(PyLongObject *a, PyLongObject *b) { PyLongObject *z; - Py_ssize_t size_a = ABS(Py_Size(a)); - Py_ssize_t size_b = ABS(Py_Size(b)); + Py_ssize_t size_a = ABS(Py_SIZE(a)); + Py_ssize_t size_b = ABS(Py_SIZE(b)); Py_ssize_t i; z = _PyLong_New(size_a + size_b); if (z == NULL) return NULL; - memset(z->ob_digit, 0, Py_Size(z) * sizeof(digit)); + memset(z->ob_digit, 0, Py_SIZE(z) * sizeof(digit)); if (a == b) { /* Efficient squaring per HAC, Algorithm 14.16: * http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf @@ -2473,7 +2473,7 @@ { PyLongObject *hi, *lo; Py_ssize_t size_lo, size_hi; - const Py_ssize_t size_n = ABS(Py_Size(n)); + const Py_ssize_t size_n = ABS(Py_SIZE(n)); size_lo = MIN(size_n, size); size_hi = size_n - size_lo; @@ -2502,8 +2502,8 @@ static PyLongObject * k_mul(PyLongObject *a, PyLongObject *b) { - Py_ssize_t asize = ABS(Py_Size(a)); - Py_ssize_t bsize = ABS(Py_Size(b)); + Py_ssize_t asize = ABS(Py_SIZE(a)); + Py_ssize_t bsize = ABS(Py_SIZE(b)); PyLongObject *ah = NULL; PyLongObject *al = NULL; PyLongObject *bh = NULL; @@ -2555,7 +2555,7 @@ /* Split a & b into hi & lo pieces. */ shift = bsize >> 1; if (kmul_split(a, shift, &ah, &al) < 0) goto fail; - assert(Py_Size(ah) > 0); /* the split isn't degenerate */ + assert(Py_SIZE(ah) > 0); /* the split isn't degenerate */ if (a == b) { bh = ah; @@ -2586,20 +2586,20 @@ if (ret == NULL) goto fail; #ifdef Py_DEBUG /* Fill with trash, to catch reference to uninitialized digits. */ - memset(ret->ob_digit, 0xDF, Py_Size(ret) * sizeof(digit)); + memset(ret->ob_digit, 0xDF, Py_SIZE(ret) * sizeof(digit)); #endif /* 2. t1 <- ah*bh, and copy into high digits of result. */ if ((t1 = k_mul(ah, bh)) == NULL) goto fail; - assert(Py_Size(t1) >= 0); - assert(2*shift + Py_Size(t1) <= Py_Size(ret)); + assert(Py_SIZE(t1) >= 0); + assert(2*shift + Py_SIZE(t1) <= Py_SIZE(ret)); memcpy(ret->ob_digit + 2*shift, t1->ob_digit, - Py_Size(t1) * sizeof(digit)); + Py_SIZE(t1) * sizeof(digit)); /* Zero-out the digits higher than the ah*bh copy. */ - i = Py_Size(ret) - 2*shift - Py_Size(t1); + i = Py_SIZE(ret) - 2*shift - Py_SIZE(t1); if (i) - memset(ret->ob_digit + 2*shift + Py_Size(t1), 0, + memset(ret->ob_digit + 2*shift + Py_SIZE(t1), 0, i * sizeof(digit)); /* 3. t2 <- al*bl, and copy into the low digits. */ @@ -2607,23 +2607,23 @@ Py_DECREF(t1); goto fail; } - assert(Py_Size(t2) >= 0); - assert(Py_Size(t2) <= 2*shift); /* no overlap with high digits */ - memcpy(ret->ob_digit, t2->ob_digit, Py_Size(t2) * sizeof(digit)); + assert(Py_SIZE(t2) >= 0); + assert(Py_SIZE(t2) <= 2*shift); /* no overlap with high digits */ + memcpy(ret->ob_digit, t2->ob_digit, Py_SIZE(t2) * sizeof(digit)); /* Zero out remaining digits. */ - i = 2*shift - Py_Size(t2); /* number of uninitialized digits */ + i = 2*shift - Py_SIZE(t2); /* number of uninitialized digits */ if (i) - memset(ret->ob_digit + Py_Size(t2), 0, i * sizeof(digit)); + memset(ret->ob_digit + Py_SIZE(t2), 0, i * sizeof(digit)); /* 4 & 5. Subtract ah*bh (t1) and al*bl (t2). We do al*bl first * because it's fresher in cache. */ - i = Py_Size(ret) - shift; /* # digits after shift */ - (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_Size(t2)); + i = Py_SIZE(ret) - shift; /* # digits after shift */ + (void)v_isub(ret->ob_digit + shift, i, t2->ob_digit, Py_SIZE(t2)); Py_DECREF(t2); - (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_Size(t1)); + (void)v_isub(ret->ob_digit + shift, i, t1->ob_digit, Py_SIZE(t1)); Py_DECREF(t1); /* 6. t3 <- (ah+al)(bh+bl), and add into result. */ @@ -2648,12 +2648,12 @@ Py_DECREF(t1); Py_DECREF(t2); if (t3 == NULL) goto fail; - assert(Py_Size(t3) >= 0); + assert(Py_SIZE(t3) >= 0); /* Add t3. It's not obvious why we can't run out of room here. * See the (*) comment after this function. */ - (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_Size(t3)); + (void)v_iadd(ret->ob_digit + shift, i, t3->ob_digit, Py_SIZE(t3)); Py_DECREF(t3); return long_normalize(ret); @@ -2723,8 +2723,8 @@ static PyLongObject * k_lopsided_mul(PyLongObject *a, PyLongObject *b) { - const Py_ssize_t asize = ABS(Py_Size(a)); - Py_ssize_t bsize = ABS(Py_Size(b)); + const Py_ssize_t asize = ABS(Py_SIZE(a)); + Py_ssize_t bsize = ABS(Py_SIZE(b)); Py_ssize_t nbdone; /* # of b digits already multiplied */ PyLongObject *ret; PyLongObject *bslice = NULL; @@ -2736,7 +2736,7 @@ ret = _PyLong_New(asize + bsize); if (ret == NULL) return NULL; - memset(ret->ob_digit, 0, Py_Size(ret) * sizeof(digit)); + memset(ret->ob_digit, 0, Py_SIZE(ret) * sizeof(digit)); /* Successive slices of b are copied into bslice. */ bslice = _PyLong_New(asize); @@ -2751,14 +2751,14 @@ /* Multiply the next slice of b by a. */ memcpy(bslice->ob_digit, b->ob_digit + nbdone, nbtouse * sizeof(digit)); - Py_Size(bslice) = nbtouse; + Py_SIZE(bslice) = nbtouse; product = k_mul(a, bslice); if (product == NULL) goto fail; /* Add into result. */ - (void)v_iadd(ret->ob_digit + nbdone, Py_Size(ret) - nbdone, - product->ob_digit, Py_Size(product)); + (void)v_iadd(ret->ob_digit + nbdone, Py_SIZE(ret) - nbdone, + product->ob_digit, Py_SIZE(product)); Py_DECREF(product); bsize -= nbtouse; @@ -2781,7 +2781,7 @@ CHECK_BINOP(a, b); - if (ABS(Py_Size(a)) <= 1 && ABS(Py_Size(b)) <= 1) { + if (ABS(Py_SIZE(a)) <= 1 && ABS(Py_SIZE(b)) <= 1) { PyObject *r; r = PyLong_FromLong(MEDIUM_VALUE(a)*MEDIUM_VALUE(b)); return r; @@ -2789,7 +2789,7 @@ z = k_mul(a, b); /* Negate if exactly one of the inputs is negative. */ - if (((Py_Size(a) ^ Py_Size(b)) < 0) && z) + if (((Py_SIZE(a) ^ Py_SIZE(b)) < 0) && z) NEGATE(z); return (PyObject *)z; } @@ -2823,8 +2823,8 @@ if (long_divrem(v, w, &div, &mod) < 0) return -1; - if ((Py_Size(mod) < 0 && Py_Size(w) > 0) || - (Py_Size(mod) > 0 && Py_Size(w) < 0)) { + if ((Py_SIZE(mod) < 0 && Py_SIZE(w) > 0) || + (Py_SIZE(mod) > 0 && Py_SIZE(w) < 0)) { PyLongObject *temp; PyLongObject *one; temp = (PyLongObject *) long_add(mod, w); @@ -2982,7 +2982,7 @@ return Py_NotImplemented; } - if (Py_Size(b) < 0) { /* if exponent is negative */ + if (Py_SIZE(b) < 0) { /* if exponent is negative */ if (c) { PyErr_SetString(PyExc_TypeError, "pow() 2nd argument " "cannot be negative when 3rd argument specified"); @@ -3001,7 +3001,7 @@ if (c) { /* if modulus == 0: raise ValueError() */ - if (Py_Size(c) == 0) { + if (Py_SIZE(c) == 0) { PyErr_SetString(PyExc_ValueError, "pow() 3rd argument cannot be 0"); goto Error; @@ -3010,7 +3010,7 @@ /* if modulus < 0: negativeOutput = True modulus = -modulus */ - if (Py_Size(c) < 0) { + if (Py_SIZE(c) < 0) { negativeOutput = 1; temp = (PyLongObject *)_PyLong_Copy(c); if (temp == NULL) @@ -3023,7 +3023,7 @@ /* if modulus == 1: return 0 */ - if ((Py_Size(c) == 1) && (c->ob_digit[0] == 1)) { + if ((Py_SIZE(c) == 1) && (c->ob_digit[0] == 1)) { z = (PyLongObject *)PyLong_FromLong(0L); goto Done; } @@ -3031,7 +3031,7 @@ /* if base < 0: base = base % modulus Having the base positive just makes things easier. */ - if (Py_Size(a) < 0) { + if (Py_SIZE(a) < 0) { if (l_divmod(a, c, NULL, &temp) < 0) goto Error; Py_DECREF(a); @@ -3072,10 +3072,10 @@ REDUCE(result) \ } - if (Py_Size(b) <= FIVEARY_CUTOFF) { + if (Py_SIZE(b) <= FIVEARY_CUTOFF) { /* Left-to-right binary exponentiation (HAC Algorithm 14.79) */ /* http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf */ - for (i = Py_Size(b) - 1; i >= 0; --i) { + for (i = Py_SIZE(b) - 1; i >= 0; --i) { digit bi = b->ob_digit[i]; for (j = 1 << (PyLong_SHIFT-1); j != 0; j >>= 1) { @@ -3092,7 +3092,7 @@ for (i = 1; i < 32; ++i) MULT(table[i-1], a, table[i]) - for (i = Py_Size(b) - 1; i >= 0; --i) { + for (i = Py_SIZE(b) - 1; i >= 0; --i) { const digit bi = b->ob_digit[i]; for (j = PyLong_SHIFT - 5; j >= 0; j -= 5) { @@ -3105,7 +3105,7 @@ } } - if (negativeOutput && (Py_Size(z) != 0)) { + if (negativeOutput && (Py_SIZE(z) != 0)) { temp = (PyLongObject *)long_sub(z, c); if (temp == NULL) goto Error; @@ -3122,7 +3122,7 @@ } /* fall through */ Done: - if (Py_Size(b) > FIVEARY_CUTOFF) { + if (Py_SIZE(b) > FIVEARY_CUTOFF) { for (i = 0; i < 32; ++i) Py_XDECREF(table[i]); } @@ -3139,7 +3139,7 @@ /* Implement ~x as -(x+1) */ PyLongObject *x; PyLongObject *w; - if (ABS(Py_Size(v)) <=1) + if (ABS(Py_SIZE(v)) <=1) return PyLong_FromLong(-(MEDIUM_VALUE(v)+1)); w = (PyLongObject *)PyLong_FromLong(1L); if (w == NULL) @@ -3148,7 +3148,7 @@ Py_DECREF(w); if (x == NULL) return NULL; - Py_Size(x) = -(Py_Size(x)); + Py_SIZE(x) = -(Py_SIZE(x)); return (PyObject *)x; } @@ -3156,18 +3156,18 @@ long_neg(PyLongObject *v) { PyLongObject *z; - if (ABS(Py_Size(v)) <= 1) + if (ABS(Py_SIZE(v)) <= 1) return PyLong_FromLong(-MEDIUM_VALUE(v)); z = (PyLongObject *)_PyLong_Copy(v); if (z != NULL) - Py_Size(z) = -(Py_Size(v)); + Py_SIZE(z) = -(Py_SIZE(v)); return (PyObject *)z; } static PyObject * long_abs(PyLongObject *v) { - if (Py_Size(v) < 0) + if (Py_SIZE(v) < 0) return long_neg(v); else return long_long((PyObject *)v); @@ -3176,7 +3176,7 @@ static int long_bool(PyLongObject *v) { - return ABS(Py_Size(v)) != 0; + return ABS(Py_SIZE(v)) != 0; } static PyObject * @@ -3189,7 +3189,7 @@ CHECK_BINOP(a, b); - if (Py_Size(a) < 0) { + if (Py_SIZE(a) < 0) { /* Right shifting negative numbers is harder */ PyLongObject *a1, *a2; a1 = (PyLongObject *) long_invert(a); @@ -3213,7 +3213,7 @@ goto rshift_error; } wordshift = shiftby / PyLong_SHIFT; - newsize = ABS(Py_Size(a)) - wordshift; + newsize = ABS(Py_SIZE(a)) - wordshift; if (newsize <= 0) { z = _PyLong_New(0); return (PyObject *)z; @@ -3225,8 +3225,8 @@ z = _PyLong_New(newsize); if (z == NULL) goto rshift_error; - if (Py_Size(a) < 0) - Py_Size(z) = -(Py_Size(z)); + if (Py_SIZE(a) < 0) + Py_SIZE(z) = -(Py_SIZE(z)); for (i = 0, j = wordshift; i < newsize; i++, j++) { z->ob_digit[i] = (a->ob_digit[j] >> loshift) & lomask; if (i+1 < newsize) @@ -3269,14 +3269,14 @@ wordshift = (int)shiftby / PyLong_SHIFT; remshift = (int)shiftby - wordshift * PyLong_SHIFT; - oldsize = ABS(Py_Size(a)); + oldsize = ABS(Py_SIZE(a)); newsize = oldsize + wordshift; if (remshift) ++newsize; z = _PyLong_New(newsize); if (z == NULL) goto lshift_error; - if (Py_Size(a) < 0) + if (Py_SIZE(a) < 0) NEGATE(z); for (i = 0; i < wordshift; i++) z->ob_digit[i] = 0; @@ -3311,7 +3311,7 @@ digit diga, digb; PyObject *v; - if (Py_Size(a) < 0) { + if (Py_SIZE(a) < 0) { a = (PyLongObject *) long_invert(a); if (a == NULL) return NULL; @@ -3321,7 +3321,7 @@ Py_INCREF(a); maska = 0; } - if (Py_Size(b) < 0) { + if (Py_SIZE(b) < 0) { b = (PyLongObject *) long_invert(b); if (b == NULL) { Py_DECREF(a); @@ -3370,8 +3370,8 @@ whose length should be ignored. */ - size_a = Py_Size(a); - size_b = Py_Size(b); + size_a = Py_SIZE(a); + size_b = Py_SIZE(b); size_z = op == '&' ? (maska ? size_b @@ -3478,7 +3478,7 @@ /* Since PyLong_FromString doesn't have a length parameter, * check here for possible NULs in the string. */ char *string; - int size = Py_Size(x); + int size = Py_SIZE(x); if (PyBytes_Check(x)) string = PyBytes_AS_STRING(x); else @@ -3516,7 +3516,7 @@ if (tmp == NULL) return NULL; assert(PyLong_CheckExact(tmp)); - n = Py_Size(tmp); + n = Py_SIZE(tmp); if (n < 0) n = -n; newobj = (PyLongObject *)type->tp_alloc(type, n); @@ -3525,7 +3525,7 @@ return NULL; } assert(PyLong_Check(newobj)); - Py_Size(newobj) = Py_Size(tmp); + Py_SIZE(newobj) = Py_SIZE(tmp); for (i = 0; i < n; i++) newobj->ob_digit[i] = tmp->ob_digit[i]; Py_DECREF(tmp); @@ -3719,12 +3719,12 @@ PyLongObject *v = small_ints; for (ival = -NSMALLNEGINTS; ival < 0; ival++, v++) { PyObject_INIT(v, &PyLong_Type); - Py_Size(v) = -1; + Py_SIZE(v) = -1; v->ob_digit[0] = -ival; } for (; ival < NSMALLPOSINTS; ival++, v++) { PyObject_INIT(v, &PyLong_Type); - Py_Size(v) = ival ? 1 : 0; + Py_SIZE(v) = ival ? 1 : 0; v->ob_digit[0] = ival; } #endif Modified: python/branches/py3k/Objects/moduleobject.c ============================================================================== --- python/branches/py3k/Objects/moduleobject.c (original) +++ python/branches/py3k/Objects/moduleobject.c Wed Dec 19 03:45:37 2007 @@ -178,7 +178,7 @@ _PyModule_Clear((PyObject *)m); Py_DECREF(m->md_dict); } - Py_Type(m)->tp_free((PyObject *)m); + Py_TYPE(m)->tp_free((PyObject *)m); } static PyObject * Modified: python/branches/py3k/Objects/object.c ============================================================================== --- python/branches/py3k/Objects/object.c (original) +++ python/branches/py3k/Objects/object.c Wed Dec 19 03:45:37 2007 @@ -214,7 +214,7 @@ if (op == NULL) return PyErr_NoMemory(); /* Any changes should be reflected in PyObject_INIT (objimpl.h) */ - Py_Type(op) = tp; + Py_TYPE(op) = tp; _Py_NewReference(op); return op; } @@ -226,7 +226,7 @@ return (PyVarObject *) PyErr_NoMemory(); /* Any changes should be reflected in PyObject_INIT_VAR */ op->ob_size = size; - Py_Type(op) = tp; + Py_TYPE(op) = tp; _Py_NewReference((PyObject *)op); return op; } @@ -352,7 +352,7 @@ "type : %s\n" "refcount: %ld\n" "address : %p\n", - Py_Type(op)==NULL ? "NULL" : Py_Type(op)->tp_name, + Py_TYPE(op)==NULL ? "NULL" : Py_TYPE(op)->tp_name, (long)op->ob_refcnt, op); } @@ -372,7 +372,7 @@ #endif if (v == NULL) return PyUnicode_FromString(""); - if (Py_Type(v)->tp_repr == NULL) + if (Py_TYPE(v)->tp_repr == NULL) return PyUnicode_FromFormat("<%s object at %p>", v->ob_type->tp_name, v); res = (*v->ob_type->tp_repr)(v); @@ -404,21 +404,21 @@ Py_INCREF(v); return v; } - if (Py_Type(v)->tp_str == NULL) + if (Py_TYPE(v)->tp_str == NULL) return PyObject_Repr(v); /* It is possible for a type to have a tp_str representation that loops infinitely. */ if (Py_EnterRecursiveCall(" while getting the str of an object")) return NULL; - res = (*Py_Type(v)->tp_str)(v); + res = (*Py_TYPE(v)->tp_str)(v); Py_LeaveRecursiveCall(); if (res == NULL) return NULL; if (!PyUnicode_Check(res)) { PyErr_Format(PyExc_TypeError, "__str__ returned non-string (type %.200s)", - Py_Type(res)->tp_name); + Py_TYPE(res)->tp_name); Py_DECREF(res); return NULL; } @@ -772,8 +772,8 @@ { PyObject *w, *res; - if (Py_Type(v)->tp_getattr != NULL) - return (*Py_Type(v)->tp_getattr)(v, (char*)name); + if (Py_TYPE(v)->tp_getattr != NULL) + return (*Py_TYPE(v)->tp_getattr)(v, (char*)name); w = PyUnicode_InternFromString(name); if (w == NULL) return NULL; @@ -800,8 +800,8 @@ PyObject *s; int res; - if (Py_Type(v)->tp_setattr != NULL) - return (*Py_Type(v)->tp_setattr)(v, (char*)name, w); + if (Py_TYPE(v)->tp_setattr != NULL) + return (*Py_TYPE(v)->tp_setattr)(v, (char*)name, w); s = PyUnicode_InternFromString(name); if (s == NULL) return -1; @@ -813,7 +813,7 @@ PyObject * PyObject_GetAttr(PyObject *v, PyObject *name) { - PyTypeObject *tp = Py_Type(v); + PyTypeObject *tp = Py_TYPE(v); if (!PyUnicode_Check(name)) { PyErr_Format(PyExc_TypeError, @@ -846,7 +846,7 @@ int PyObject_SetAttr(PyObject *v, PyObject *name, PyObject *value) { - PyTypeObject *tp = Py_Type(v); + PyTypeObject *tp = Py_TYPE(v); int err; if (!PyUnicode_Check(name)) { @@ -893,7 +893,7 @@ _PyObject_GetDictPtr(PyObject *obj) { Py_ssize_t dictoffset; - PyTypeObject *tp = Py_Type(obj); + PyTypeObject *tp = Py_TYPE(obj); dictoffset = tp->tp_dictoffset; if (dictoffset == 0) @@ -926,7 +926,7 @@ PyObject * PyObject_GenericGetAttr(PyObject *obj, PyObject *name) { - PyTypeObject *tp = Py_Type(obj); + PyTypeObject *tp = Py_TYPE(obj); PyObject *descr = NULL; PyObject *res = NULL; descrgetfunc f; @@ -1010,7 +1010,7 @@ } if (f != NULL) { - res = f(descr, obj, (PyObject *)Py_Type(obj)); + res = f(descr, obj, (PyObject *)Py_TYPE(obj)); Py_DECREF(descr); goto done; } @@ -1032,7 +1032,7 @@ int PyObject_GenericSetAttr(PyObject *obj, PyObject *name, PyObject *value) { - PyTypeObject *tp = Py_Type(obj); + PyTypeObject *tp = Py_TYPE(obj); PyObject *descr; descrsetfunc f; PyObject **dictptr; @@ -1232,7 +1232,7 @@ if (!PyList_Check(names)) { PyErr_Format(PyExc_TypeError, "dir(): expected keys() of locals to be a list, " - "not '%.200s'", Py_Type(names)->tp_name); + "not '%.200s'", Py_TYPE(names)->tp_name); Py_DECREF(names); return NULL; } @@ -1360,7 +1360,7 @@ if (!PyList_Check(result)) { PyErr_Format(PyExc_TypeError, "__dir__() must return a list, not %.200s", - Py_Type(result)->tp_name); + Py_TYPE(result)->tp_name); Py_DECREF(result); result = NULL; } @@ -1558,7 +1558,7 @@ void _Py_Dealloc(PyObject *op) { - destructor dealloc = Py_Type(op)->tp_dealloc; + destructor dealloc = Py_TYPE(op)->tp_dealloc; _Py_ForgetReference(op); (*dealloc)(op); } @@ -1589,7 +1589,7 @@ fprintf(fp, "Remaining object addresses:\n"); for (op = refchain._ob_next; op != &refchain; op = op->_ob_next) fprintf(fp, "%p [%" PY_FORMAT_SIZE_T "d] %s\n", op, - op->ob_refcnt, Py_Type(op)->tp_name); + op->ob_refcnt, Py_TYPE(op)->tp_name); } PyObject * @@ -1607,7 +1607,7 @@ return NULL; for (i = 0; (n == 0 || i < n) && op != &refchain; i++) { while (op == self || op == args || op == res || op == t || - (t != NULL && Py_Type(op) != (PyTypeObject *) t)) { + (t != NULL && Py_TYPE(op) != (PyTypeObject *) t)) { op = op->_ob_next; if (op == &refchain) return res; @@ -1750,7 +1750,7 @@ { while (_PyTrash_delete_later) { PyObject *op = _PyTrash_delete_later; - destructor dealloc = Py_Type(op)->tp_dealloc; + destructor dealloc = Py_TYPE(op)->tp_dealloc; _PyTrash_delete_later = (PyObject*) _Py_AS_GC(op)->gc.gc_prev; Modified: python/branches/py3k/Objects/setobject.c ============================================================================== --- python/branches/py3k/Objects/setobject.c (original) +++ python/branches/py3k/Objects/setobject.c Wed Dec 19 03:45:37 2007 @@ -564,7 +564,7 @@ if (num_free_sets < MAXFREESETS && PyAnySet_CheckExact(so)) free_sets[num_free_sets++] = so; else - Py_Type(so)->tp_free(so); + Py_TYPE(so)->tp_free(so); Py_TRASHCAN_SAFE_END(so) } @@ -580,13 +580,13 @@ if (status != 0) { if (status < 0) return NULL; - return PyUnicode_FromFormat("%s(...)", Py_Type(so)->tp_name); + return PyUnicode_FromFormat("%s(...)", Py_TYPE(so)->tp_name); } /* shortcut for the empty set */ if (!so->used) { Py_ReprLeave((PyObject*)so); - return PyUnicode_FromFormat("%s()", Py_Type(so)->tp_name); + return PyUnicode_FromFormat("%s()", Py_TYPE(so)->tp_name); } keys = PySequence_List((PyObject *)so); @@ -611,9 +611,9 @@ *u++ = '}'; } Py_DECREF(listrepr); - if (Py_Type(so) != &PySet_Type) { + if (Py_TYPE(so) != &PySet_Type) { PyObject *tmp = PyUnicode_FromFormat("%s(%U)", - Py_Type(so)->tp_name, + Py_TYPE(so)->tp_name, result); Py_DECREF(result); result = tmp; @@ -979,7 +979,7 @@ (type == &PySet_Type || type == &PyFrozenSet_Type)) { so = free_sets[--num_free_sets]; assert (so != NULL && PyAnySet_CheckExact(so)); - Py_Type(so) = type; + Py_TYPE(so) = type; _Py_NewReference((PyObject *)so); EMPTY_TO_MINSIZE(so); PyObject_GC_Track(so); @@ -1105,8 +1105,8 @@ memcpy(b->smalltable, tab, sizeof(tab)); } - if (PyType_IsSubtype(Py_Type(a), &PyFrozenSet_Type) && - PyType_IsSubtype(Py_Type(b), &PyFrozenSet_Type)) { + if (PyType_IsSubtype(Py_TYPE(a), &PyFrozenSet_Type) && + PyType_IsSubtype(Py_TYPE(b), &PyFrozenSet_Type)) { h = a->hash; a->hash = b->hash; b->hash = h; } else { a->hash = -1; @@ -1117,7 +1117,7 @@ static PyObject * set_copy(PySetObject *so) { - return make_new_set(Py_Type(so), (PyObject *)so); + return make_new_set(Py_TYPE(so), (PyObject *)so); } static PyObject * @@ -1195,7 +1195,7 @@ if ((PyObject *)so == other) return set_copy(so); - result = (PySetObject *)make_new_set(Py_Type(so), NULL); + result = (PySetObject *)make_new_set(Py_TYPE(so), NULL); if (result == NULL) return NULL; @@ -1449,7 +1449,7 @@ return NULL; } - result = make_new_set(Py_Type(so), NULL); + result = make_new_set(Py_TYPE(so), NULL); if (result == NULL) return NULL; @@ -1550,7 +1550,7 @@ Py_INCREF(other); otherset = (PySetObject *)other; } else { - otherset = (PySetObject *)make_new_set(Py_Type(so), other); + otherset = (PySetObject *)make_new_set(Py_TYPE(so), other); if (otherset == NULL) return NULL; } @@ -1581,7 +1581,7 @@ PyObject *rv; PySetObject *otherset; - otherset = (PySetObject *)make_new_set(Py_Type(so), other); + otherset = (PySetObject *)make_new_set(Py_TYPE(so), other); if (otherset == NULL) return NULL; rv = set_symmetric_difference_update(otherset, (PyObject *)so); @@ -1844,7 +1844,7 @@ dict = Py_None; Py_INCREF(dict); } - result = PyTuple_Pack(3, Py_Type(so), args, dict); + result = PyTuple_Pack(3, Py_TYPE(so), args, dict); done: Py_XDECREF(args); Py_XDECREF(keys); @@ -1861,7 +1861,7 @@ if (!PyAnySet_Check(self)) return -1; - if (!PyArg_UnpackTuple(args, Py_Type(self)->tp_name, 0, 1, &iterable)) + if (!PyArg_UnpackTuple(args, Py_TYPE(self)->tp_name, 0, 1, &iterable)) return -1; set_clear_internal(self); self->hash = -1; @@ -2153,7 +2153,7 @@ int PySet_Clear(PyObject *set) { - if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) { + if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) { PyErr_BadInternalCall(); return -1; } @@ -2173,7 +2173,7 @@ int PySet_Discard(PyObject *set, PyObject *key) { - if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) { + if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) { PyErr_BadInternalCall(); return -1; } @@ -2183,7 +2183,7 @@ int PySet_Add(PyObject *set, PyObject *key) { - if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) { + if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) { PyErr_BadInternalCall(); return -1; } @@ -2224,7 +2224,7 @@ PyObject * PySet_Pop(PyObject *set) { - if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) { + if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) { PyErr_BadInternalCall(); return NULL; } @@ -2234,7 +2234,7 @@ int _PySet_Update(PyObject *set, PyObject *iterable) { - if (!PyType_IsSubtype(Py_Type(set), &PySet_Type)) { + if (!PyType_IsSubtype(Py_TYPE(set), &PySet_Type)) { PyErr_BadInternalCall(); return -1; } Modified: python/branches/py3k/Objects/sliceobject.c ============================================================================== --- python/branches/py3k/Objects/sliceobject.c (original) +++ python/branches/py3k/Objects/sliceobject.c Wed Dec 19 03:45:37 2007 @@ -266,7 +266,7 @@ static PyObject * slice_reduce(PySliceObject* self) { - return Py_BuildValue("O(OOO)", Py_Type(self), self->start, self->stop, self->step); + return Py_BuildValue("O(OOO)", Py_TYPE(self), self->start, self->stop, self->step); } PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); Modified: python/branches/py3k/Objects/stringlib/string_format.h ============================================================================== --- python/branches/py3k/Objects/stringlib/string_format.h (original) +++ python/branches/py3k/Objects/stringlib/string_format.h Wed Dec 19 03:45:37 2007 @@ -492,8 +492,8 @@ } /* Make sure the type is initialized. float gets initialized late */ - if (Py_Type(fieldobj)->tp_dict == NULL) - if (PyType_Ready(Py_Type(fieldobj)) < 0) + if (Py_TYPE(fieldobj)->tp_dict == NULL) + if (PyType_Ready(Py_TYPE(fieldobj)) < 0) return NULL; /* we need to create an object out of the pointers we have */ @@ -502,11 +502,11 @@ goto done; /* Find the (unbound!) __format__ method (a borrowed reference) */ - meth = _PyType_Lookup(Py_Type(fieldobj), format_str); + meth = _PyType_Lookup(Py_TYPE(fieldobj), format_str); if (meth == NULL) { PyErr_Format(PyExc_TypeError, "Type %.100s doesn't define __format__", - Py_Type(fieldobj)->tp_name); + Py_TYPE(fieldobj)->tp_name); goto done; } Modified: python/branches/py3k/Objects/stringobject.c ============================================================================== --- python/branches/py3k/Objects/stringobject.c (original) +++ python/branches/py3k/Objects/stringobject.c Wed Dec 19 03:45:37 2007 @@ -12,13 +12,13 @@ static Py_ssize_t _getbuffer(PyObject *obj, Py_buffer *view) { - PyBufferProcs *buffer = Py_Type(obj)->tp_as_buffer; + PyBufferProcs *buffer = Py_TYPE(obj)->tp_as_buffer; if (buffer == NULL || buffer->bf_getbuffer == NULL) { PyErr_Format(PyExc_TypeError, "Type %.100s doesn't support the buffer API", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); return -1; } @@ -351,7 +351,7 @@ static void string_dealloc(PyObject *op) { - Py_Type(op)->tp_free(op); + Py_TYPE(op)->tp_free(op); } /* Unescape a backslash-escaped string. If unicode is non-zero, @@ -509,7 +509,7 @@ { if (!PyString_Check(op)) return string_getsize(op); - return Py_Size(op); + return Py_SIZE(op); } /*const*/ char * @@ -517,7 +517,7 @@ { if (!PyString_Check(op)) { PyErr_Format(PyExc_TypeError, - "expected bytes, %.200s found", Py_Type(op)->tp_name); + "expected bytes, %.200s found", Py_TYPE(op)->tp_name); return NULL; } return ((PyStringObject *)op) -> ob_sval; @@ -535,7 +535,7 @@ if (!PyString_Check(obj)) { PyErr_Format(PyExc_TypeError, - "expected bytes, %.200s found", Py_Type(obj)->tp_name); + "expected bytes, %.200s found", Py_TYPE(obj)->tp_name); return -1; } @@ -579,7 +579,7 @@ { static const char *hexdigits = "0123456789abcdef"; register PyStringObject* op = (PyStringObject*) obj; - Py_ssize_t length = Py_Size(op); + Py_ssize_t length = Py_SIZE(op); size_t newsize = 3 + 4 * length; PyObject *v; if (newsize > PY_SSIZE_T_MAX || (newsize-3) / 4 != length) { @@ -668,7 +668,7 @@ static Py_ssize_t string_length(PyStringObject *a) { - return Py_Size(a); + return Py_SIZE(a); } /* This is also used by PyString_Concat() */ @@ -684,7 +684,7 @@ if (_getbuffer(a, &va) < 0 || _getbuffer(b, &vb) < 0) { PyErr_Format(PyExc_TypeError, "can't concat %.100s to %.100s", - Py_Type(a)->tp_name, Py_Type(b)->tp_name); + Py_TYPE(a)->tp_name, Py_TYPE(b)->tp_name); goto done; } @@ -733,13 +733,13 @@ /* watch out for overflows: the size can overflow int, * and the # of bytes needed can overflow size_t */ - size = Py_Size(a) * n; - if (n && size / n != Py_Size(a)) { + size = Py_SIZE(a) * n; + if (n && size / n != Py_SIZE(a)) { PyErr_SetString(PyExc_OverflowError, "repeated string is too long"); return NULL; } - if (size == Py_Size(a) && PyString_CheckExact(a)) { + if (size == Py_SIZE(a) && PyString_CheckExact(a)) { Py_INCREF(a); return (PyObject *)a; } @@ -756,14 +756,14 @@ PyObject_INIT_VAR(op, &PyString_Type, size); op->ob_shash = -1; op->ob_sval[size] = '\0'; - if (Py_Size(a) == 1 && n > 0) { + if (Py_SIZE(a) == 1 && n > 0) { memset(op->ob_sval, a->ob_sval[0] , n); return (PyObject *) op; } i = 0; if (i < size) { - Py_MEMCPY(op->ob_sval, a->ob_sval, Py_Size(a)); - i = Py_Size(a); + Py_MEMCPY(op->ob_sval, a->ob_sval, Py_SIZE(a)); + i = Py_SIZE(a); } while (i < size) { j = (i <= size-i) ? i : size-i; @@ -783,7 +783,7 @@ PyErr_Clear(); if (_getbuffer(arg, &varg) < 0) return -1; - pos = stringlib_find(PyString_AS_STRING(self), Py_Size(self), + pos = stringlib_find(PyString_AS_STRING(self), Py_SIZE(self), varg.buf, varg.len, 0); PyObject_ReleaseBuffer(arg, &varg); return pos >= 0; @@ -793,13 +793,13 @@ return -1; } - return memchr(PyString_AS_STRING(self), ival, Py_Size(self)) != NULL; + return memchr(PyString_AS_STRING(self), ival, Py_SIZE(self)) != NULL; } static PyObject * string_item(PyStringObject *a, register Py_ssize_t i) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "string index out of range"); return NULL; } @@ -841,16 +841,16 @@ if (op == Py_EQ) { /* Supporting Py_NE here as well does not save much time, since Py_NE is rarely used. */ - if (Py_Size(a) == Py_Size(b) + if (Py_SIZE(a) == Py_SIZE(b) && (a->ob_sval[0] == b->ob_sval[0] - && memcmp(a->ob_sval, b->ob_sval, Py_Size(a)) == 0)) { + && memcmp(a->ob_sval, b->ob_sval, Py_SIZE(a)) == 0)) { result = Py_True; } else { result = Py_False; } goto out; } - len_a = Py_Size(a); len_b = Py_Size(b); + len_a = Py_SIZE(a); len_b = Py_SIZE(b); min_len = (len_a < len_b) ? len_a : len_b; if (min_len > 0) { c = Py_CHARMASK(*a->ob_sval) - Py_CHARMASK(*b->ob_sval); @@ -886,12 +886,12 @@ if (a->ob_shash != -1) return a->ob_shash; - len = Py_Size(a); + len = Py_SIZE(a); p = (unsigned char *) a->ob_sval; x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; - x ^= Py_Size(a); + x ^= Py_SIZE(a); if (x == -1) x = -2; a->ob_shash = x; @@ -960,7 +960,7 @@ else { PyErr_Format(PyExc_TypeError, "string indices must be integers, not %.200s", - Py_Type(item)->tp_name); + Py_TYPE(item)->tp_name); return NULL; } } @@ -968,7 +968,7 @@ static int string_buffer_getbuffer(PyStringObject *self, Py_buffer *view, int flags) { - return PyBuffer_FillInfo(view, (void *)self->ob_sval, Py_Size(self), + return PyBuffer_FillInfo(view, (void *)self->ob_sval, Py_SIZE(self), 0, flags); } @@ -1043,7 +1043,7 @@ count++; } /* Always force the list to the expected size. */ -#define FIX_PREALLOC_SIZE(list) Py_Size(list) = count +#define FIX_PREALLOC_SIZE(list) Py_SIZE(list) = count #define SKIP_SPACE(s, i, len) { while (itp_name); + i, Py_TYPE(item)->tp_name); Py_DECREF(seq); return NULL; } - sz += Py_Size(item); + sz += Py_SIZE(item); if (i != 0) sz += seplen; if (sz < old_sz || sz > PY_SSIZE_T_MAX) { @@ -1508,7 +1508,7 @@ p += seplen; } item = PySequence_Fast_GET_ITEM(seq, i); - n = Py_Size(item); + n = Py_SIZE(item); if (PyString_Check(item)) q = PyString_AS_STRING(item); else @@ -2792,7 +2792,7 @@ static PyObject * string_getnewargs(PyStringObject *v) { - return Py_BuildValue("(s#)", v->ob_sval, Py_Size(v)); + return Py_BuildValue("(s#)", v->ob_sval, Py_SIZE(v)); } @@ -3132,7 +3132,7 @@ register PyObject *v; register PyStringObject *sv; v = *pv; - if (!PyString_Check(v) || Py_Refcnt(v) != 1 || newsize < 0) { + if (!PyString_Check(v) || Py_REFCNT(v) != 1 || newsize < 0) { *pv = 0; Py_DECREF(v); PyErr_BadInternalCall(); @@ -3150,7 +3150,7 @@ } _Py_NewReference(*pv); sv = (PyStringObject *) *pv; - Py_Size(sv) = newsize; + Py_SIZE(sv) = newsize; sv->ob_sval[newsize] = '\0'; sv->ob_shash = -1; /* invalidate cached hash value */ return 0; @@ -3204,7 +3204,7 @@ if (PyBool_Check(val)) result = PyNumber_ToBase(val, 10); else - result = Py_Type(val)->tp_str(val); + result = Py_TYPE(val)->tp_str(val); break; case 'o': numnondigits = 2; @@ -3228,7 +3228,7 @@ } /* To modify the string in-place, there can only be one reference. */ - if (Py_Refcnt(result) != 1) { + if (Py_REFCNT(result) != 1) { PyErr_BadInternalCall(); return NULL; } Modified: python/branches/py3k/Objects/structseq.c ============================================================================== --- python/branches/py3k/Objects/structseq.c (original) +++ python/branches/py3k/Objects/structseq.c Wed Dec 19 03:45:37 2007 @@ -13,17 +13,17 @@ They are only allowed for indices < n_visible_fields. */ char *PyStructSequence_UnnamedField = "unnamed field"; -#define VISIBLE_SIZE(op) Py_Size(op) +#define VISIBLE_SIZE(op) Py_SIZE(op) #define VISIBLE_SIZE_TP(tp) PyLong_AsLong( \ PyDict_GetItemString((tp)->tp_dict, visible_length_key)) #define REAL_SIZE_TP(tp) PyLong_AsLong( \ PyDict_GetItemString((tp)->tp_dict, real_length_key)) -#define REAL_SIZE(op) REAL_SIZE_TP(Py_Type(op)) +#define REAL_SIZE(op) REAL_SIZE_TP(Py_TYPE(op)) #define UNNAMED_FIELDS_TP(tp) PyLong_AsLong( \ PyDict_GetItemString((tp)->tp_dict, unnamed_fields_key)) -#define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_Type(op)) +#define UNNAMED_FIELDS(op) UNNAMED_FIELDS_TP(Py_TYPE(op)) PyObject * @@ -32,7 +32,7 @@ PyStructSequence *obj; obj = PyObject_New(PyStructSequence, type); - Py_Size(obj) = VISIBLE_SIZE_TP(type); + Py_SIZE(obj) = VISIBLE_SIZE_TP(type); return (PyObject*) obj; } @@ -322,12 +322,12 @@ } for (; i < n_fields; i++) { - char *n = Py_Type(self)->tp_members[i-n_unnamed_fields].name; + char *n = Py_TYPE(self)->tp_members[i-n_unnamed_fields].name; PyDict_SetItemString(dict, n, self->ob_item[i]); } - result = Py_BuildValue("(O(OO))", Py_Type(self), tup, dict); + result = Py_BuildValue("(O(OO))", Py_TYPE(self), tup, dict); Py_DECREF(tup); Py_DECREF(dict); Modified: python/branches/py3k/Objects/tupleobject.c ============================================================================== --- python/branches/py3k/Objects/tupleobject.c (original) +++ python/branches/py3k/Objects/tupleobject.c Wed Dec 19 03:45:37 2007 @@ -49,8 +49,8 @@ #endif /* Inline PyObject_InitVar */ #ifdef Py_TRACE_REFS - Py_Size(op) = size; - Py_Type(op) = &PyTuple_Type; + Py_SIZE(op) = size; + Py_TYPE(op) = &PyTuple_Type; #endif _Py_NewReference((PyObject *)op); } @@ -90,7 +90,7 @@ return -1; } else - return Py_Size(op); + return Py_SIZE(op); } PyObject * @@ -100,7 +100,7 @@ PyErr_BadInternalCall(); return NULL; } - if (i < 0 || i >= Py_Size(op)) { + if (i < 0 || i >= Py_SIZE(op)) { PyErr_SetString(PyExc_IndexError, "tuple index out of range"); return NULL; } @@ -117,7 +117,7 @@ PyErr_BadInternalCall(); return -1; } - if (i < 0 || i >= Py_Size(op)) { + if (i < 0 || i >= Py_SIZE(op)) { Py_XDECREF(newitem); PyErr_SetString(PyExc_IndexError, "tuple assignment index out of range"); @@ -160,7 +160,7 @@ tupledealloc(register PyTupleObject *op) { register Py_ssize_t i; - register Py_ssize_t len = Py_Size(op); + register Py_ssize_t len = Py_SIZE(op); PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) if (len > 0) { @@ -170,7 +170,7 @@ #if MAXSAVESIZE > 0 if (len < MAXSAVESIZE && num_free_tuples[len] < MAXSAVEDTUPLES && - Py_Type(op) == &PyTuple_Type) + Py_TYPE(op) == &PyTuple_Type) { op->ob_item[0] = (PyObject *) free_tuples[len]; num_free_tuples[len]++; @@ -179,7 +179,7 @@ } #endif } - Py_Type(op)->tp_free((PyObject *)op); + Py_TYPE(op)->tp_free((PyObject *)op); done: Py_TRASHCAN_SAFE_END(op) } @@ -191,7 +191,7 @@ PyObject *s, *temp; PyObject *pieces, *result = NULL; - n = Py_Size(v); + n = Py_SIZE(v); if (n == 0) return PyUnicode_FromString("()"); @@ -264,7 +264,7 @@ tuplehash(PyTupleObject *v) { register long x, y; - register Py_ssize_t len = Py_Size(v); + register Py_ssize_t len = Py_SIZE(v); register PyObject **p; long mult = 1000003L; x = 0x345678L; @@ -286,7 +286,7 @@ static Py_ssize_t tuplelength(PyTupleObject *a) { - return Py_Size(a); + return Py_SIZE(a); } static int @@ -295,7 +295,7 @@ Py_ssize_t i; int cmp; - for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(a); ++i) + for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i) cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i), Py_EQ); return cmp; @@ -304,7 +304,7 @@ static PyObject * tupleitem(register PyTupleObject *a, register Py_ssize_t i) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "tuple index out of range"); return NULL; } @@ -322,11 +322,11 @@ Py_ssize_t len; if (ilow < 0) ilow = 0; - if (ihigh > Py_Size(a)) - ihigh = Py_Size(a); + if (ihigh > Py_SIZE(a)) + ihigh = Py_SIZE(a); if (ihigh < ilow) ihigh = ilow; - if (ilow == 0 && ihigh == Py_Size(a) && PyTuple_CheckExact(a)) { + if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) { Py_INCREF(a); return (PyObject *)a; } @@ -364,11 +364,11 @@ if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only concatenate tuple (not \"%.200s\") to tuple", - Py_Type(bb)->tp_name); + Py_TYPE(bb)->tp_name); return NULL; } #define b ((PyTupleObject *)bb) - size = Py_Size(a) + Py_Size(b); + size = Py_SIZE(a) + Py_SIZE(b); if (size < 0) return PyErr_NoMemory(); np = (PyTupleObject *) PyTuple_New(size); @@ -377,14 +377,14 @@ } src = a->ob_item; dest = np->ob_item; - for (i = 0; i < Py_Size(a); i++) { + for (i = 0; i < Py_SIZE(a); i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; } src = b->ob_item; - dest = np->ob_item + Py_Size(a); - for (i = 0; i < Py_Size(b); i++) { + dest = np->ob_item + Py_SIZE(a); + for (i = 0; i < Py_SIZE(b); i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; @@ -402,18 +402,18 @@ PyObject **p, **items; if (n < 0) n = 0; - if (Py_Size(a) == 0 || n == 1) { + if (Py_SIZE(a) == 0 || n == 1) { if (PyTuple_CheckExact(a)) { /* Since tuples are immutable, we can return a shared copy in this case */ Py_INCREF(a); return (PyObject *)a; } - if (Py_Size(a) == 0) + if (Py_SIZE(a) == 0) return PyTuple_New(0); } - size = Py_Size(a) * n; - if (size/Py_Size(a) != n) + size = Py_SIZE(a) * n; + if (size/Py_SIZE(a) != n) return PyErr_NoMemory(); np = (PyTupleObject *) PyTuple_New(size); if (np == NULL) @@ -421,7 +421,7 @@ p = np->ob_item; items = a->ob_item; for (i = 0; i < n; i++) { - for (j = 0; j < Py_Size(a); j++) { + for (j = 0; j < Py_SIZE(a); j++) { *p = items[j]; Py_INCREF(*p); p++; @@ -435,7 +435,7 @@ { Py_ssize_t i; - for (i = Py_Size(o); --i >= 0; ) + for (i = Py_SIZE(o); --i >= 0; ) Py_VISIT(o->ob_item[i]); return 0; } @@ -455,8 +455,8 @@ vt = (PyTupleObject *)v; wt = (PyTupleObject *)w; - vlen = Py_Size(vt); - wlen = Py_Size(wt); + vlen = Py_SIZE(vt); + wlen = Py_SIZE(wt); /* Note: the corresponding code for lists has an "early out" test * here when op is EQ or NE and the lengths differ. That pays there, @@ -624,7 +624,7 @@ else { PyErr_Format(PyExc_TypeError, "tuple indices must be integers, not %.200s", - Py_Type(item)->tp_name); + Py_TYPE(item)->tp_name); return NULL; } } @@ -632,7 +632,7 @@ static PyObject * tuple_getnewargs(PyTupleObject *v) { - return Py_BuildValue("(N)", tupleslice(v, 0, Py_Size(v))); + return Py_BuildValue("(N)", tupleslice(v, 0, Py_SIZE(v))); } @@ -708,14 +708,14 @@ Py_ssize_t oldsize; v = (PyTupleObject *) *pv; - if (v == NULL || Py_Type(v) != &PyTuple_Type || - (Py_Size(v) != 0 && Py_Refcnt(v) != 1)) { + if (v == NULL || Py_TYPE(v) != &PyTuple_Type || + (Py_SIZE(v) != 0 && Py_REFCNT(v) != 1)) { *pv = 0; Py_XDECREF(v); PyErr_BadInternalCall(); return -1; } - oldsize = Py_Size(v); + oldsize = Py_SIZE(v); if (oldsize == newsize) return 0; Modified: python/branches/py3k/Objects/typeobject.c ============================================================================== --- python/branches/py3k/Objects/typeobject.c (original) +++ python/branches/py3k/Objects/typeobject.c Wed Dec 19 03:45:37 2007 @@ -60,7 +60,7 @@ if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, "can only assign string to %s.__name__, not '%s'", - type->tp_name, Py_Type(value)->tp_name); + type->tp_name, Py_TYPE(value)->tp_name); return -1; } @@ -216,7 +216,7 @@ if (!PyTuple_Check(value)) { PyErr_Format(PyExc_TypeError, "can only assign tuple to %s.__bases__, not %s", - type->tp_name, Py_Type(value)->tp_name); + type->tp_name, Py_TYPE(value)->tp_name); return -1; } if (PyTuple_GET_SIZE(value) == 0) { @@ -231,7 +231,7 @@ PyErr_Format( PyExc_TypeError, "%s.__bases__ must be tuple of old- or new-style classes, not '%s'", - type->tp_name, Py_Type(ob)->tp_name); + type->tp_name, Py_TYPE(ob)->tp_name); return -1; } if (PyType_Check(ob)) { @@ -356,8 +356,8 @@ result = Py_None; Py_INCREF(result); } - else if (Py_Type(result)->tp_descr_get) { - result = Py_Type(result)->tp_descr_get(result, NULL, + else if (Py_TYPE(result)->tp_descr_get) { + result = Py_TYPE(result)->tp_descr_get(result, NULL, (PyObject *)type); } else { @@ -430,9 +430,9 @@ return obj; /* If the returned object is not an instance of type, it won't be initialized. */ - if (!PyType_IsSubtype(Py_Type(obj), type)) + if (!PyType_IsSubtype(Py_TYPE(obj), type)) return obj; - type = Py_Type(obj); + type = Py_TYPE(obj); if (type->tp_init != NULL && type->tp_init(obj, args, kwds) < 0) { Py_DECREF(obj); @@ -486,7 +486,7 @@ Py_ssize_t i, n; PyMemberDef *mp; - n = Py_Size(type); + n = Py_SIZE(type); mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type); for (i = 0; i < n; i++, mp++) { if (mp->type == T_OBJECT_EX) { @@ -510,10 +510,10 @@ /* Find the nearest base with a different tp_traverse, and traverse slots while we're at it */ - type = Py_Type(self); + type = Py_TYPE(self); base = type; while ((basetraverse = base->tp_traverse) == subtype_traverse) { - if (Py_Size(base)) { + if (Py_SIZE(base)) { int err = traverse_slots(base, self, visit, arg); if (err) return err; @@ -545,7 +545,7 @@ Py_ssize_t i, n; PyMemberDef *mp; - n = Py_Size(type); + n = Py_SIZE(type); mp = PyHeapType_GET_MEMBERS((PyHeapTypeObject *)type); for (i = 0; i < n; i++, mp++) { if (mp->type == T_OBJECT_EX && !(mp->flags & READONLY)) { @@ -567,10 +567,10 @@ /* Find the nearest base with a different tp_clear and clear slots while we're at it */ - type = Py_Type(self); + type = Py_TYPE(self); base = type; while ((baseclear = base->tp_clear) == subtype_clear) { - if (Py_Size(base)) + if (Py_SIZE(base)) clear_slots(base, self); base = base->tp_base; assert(base); @@ -591,7 +591,7 @@ destructor basedealloc; /* Extract the type; we expect it to be a heap type */ - type = Py_Type(self); + type = Py_TYPE(self); assert(type->tp_flags & Py_TPFLAGS_HEAPTYPE); /* Test whether the type has GC exactly once */ @@ -613,7 +613,7 @@ /* Find the nearest base with a different tp_dealloc */ base = type; while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { - assert(Py_Size(base) == 0); + assert(Py_SIZE(base) == 0); base = base->tp_base; assert(base); } @@ -681,7 +681,7 @@ /* Clear slots up to the nearest base with a different tp_dealloc */ base = type; while ((basedealloc = base->tp_dealloc) == subtype_dealloc) { - if (Py_Size(base)) + if (Py_SIZE(base)) clear_slots(base, self); base = base->tp_base; assert(base); @@ -872,13 +872,13 @@ if (*attrobj == NULL) return NULL; } - res = _PyType_Lookup(Py_Type(self), *attrobj); + res = _PyType_Lookup(Py_TYPE(self), *attrobj); if (res != NULL) { descrgetfunc f; - if ((f = Py_Type(res)->tp_descr_get) == NULL) + if ((f = Py_TYPE(res)->tp_descr_get) == NULL) Py_INCREF(res); else - res = f(res, self, (PyObject *)(Py_Type(self))); + res = f(res, self, (PyObject *)(Py_TYPE(self))); } return res; } @@ -1251,7 +1251,7 @@ PyObject *mro, *result, *tuple; int checkit = 0; - if (Py_Type(type) == &PyType_Type) { + if (Py_TYPE(type) == &PyType_Type) { result = mro_implementation(type); } else { @@ -1284,7 +1284,7 @@ if (!PyType_Check(cls)) { PyErr_Format(PyExc_TypeError, "mro() returned a non-class ('%.500s')", - Py_Type(cls)->tp_name); + Py_TYPE(cls)->tp_name); Py_DECREF(tuple); return -1; } @@ -1440,7 +1440,7 @@ { PyErr_Format(PyExc_TypeError, "this __dict__ descriptor does not support " - "'%.200s' objects", Py_Type(obj)->tp_name); + "'%.200s' objects", Py_TYPE(obj)->tp_name); } static PyObject * @@ -1450,7 +1450,7 @@ PyObject *dict; PyTypeObject *base; - base = get_builtin_base_with_dict(Py_Type(obj)); + base = get_builtin_base_with_dict(Py_TYPE(obj)); if (base != NULL) { descrgetfunc func; PyObject *descr = get_dict_descriptor(base); @@ -1458,12 +1458,12 @@ raise_dict_descr_error(obj); return NULL; } - func = Py_Type(descr)->tp_descr_get; + func = Py_TYPE(descr)->tp_descr_get; if (func == NULL) { raise_dict_descr_error(obj); return NULL; } - return func(descr, obj, (PyObject *)(Py_Type(obj))); + return func(descr, obj, (PyObject *)(Py_TYPE(obj))); } dictptr = _PyObject_GetDictPtr(obj); @@ -1486,7 +1486,7 @@ PyObject *dict; PyTypeObject *base; - base = get_builtin_base_with_dict(Py_Type(obj)); + base = get_builtin_base_with_dict(Py_TYPE(obj)); if (base != NULL) { descrsetfunc func; PyObject *descr = get_dict_descriptor(base); @@ -1494,7 +1494,7 @@ raise_dict_descr_error(obj); return -1; } - func = Py_Type(descr)->tp_descr_set; + func = Py_TYPE(descr)->tp_descr_set; if (func == NULL) { raise_dict_descr_error(obj); return -1; @@ -1511,7 +1511,7 @@ if (value != NULL && !PyDict_Check(value)) { PyErr_Format(PyExc_TypeError, "__dict__ must be set to a dictionary, " - "not a '%.200s'", Py_Type(value)->tp_name); + "not a '%.200s'", Py_TYPE(value)->tp_name); return -1; } dict = *dictptr; @@ -1527,16 +1527,16 @@ PyObject **weaklistptr; PyObject *result; - if (Py_Type(obj)->tp_weaklistoffset == 0) { + if (Py_TYPE(obj)->tp_weaklistoffset == 0) { PyErr_SetString(PyExc_AttributeError, "This object has no __weakref__"); return NULL; } - assert(Py_Type(obj)->tp_weaklistoffset > 0); - assert(Py_Type(obj)->tp_weaklistoffset + sizeof(PyObject *) <= - (size_t)(Py_Type(obj)->tp_basicsize)); + assert(Py_TYPE(obj)->tp_weaklistoffset > 0); + assert(Py_TYPE(obj)->tp_weaklistoffset + sizeof(PyObject *) <= + (size_t)(Py_TYPE(obj)->tp_basicsize)); weaklistptr = (PyObject **) - ((char *)obj + Py_Type(obj)->tp_weaklistoffset); + ((char *)obj + Py_TYPE(obj)->tp_weaklistoffset); if (*weaklistptr == NULL) result = Py_None; else @@ -1573,7 +1573,7 @@ if (!PyUnicode_Check(s)) { PyErr_Format(PyExc_TypeError, "__slots__ items must be strings, not '%.200s'", - Py_Type(s)->tp_name); + Py_TYPE(s)->tp_name); return 0; } if (!PyUnicode_IsIdentifier(s)) { @@ -1639,8 +1639,8 @@ if (PyType_CheckExact(metatype) && nargs == 1 && nkwds == 0) { PyObject *x = PyTuple_GET_ITEM(args, 0); - Py_INCREF(Py_Type(x)); - return (PyObject *) Py_Type(x); + Py_INCREF(Py_TYPE(x)); + return (PyObject *) Py_TYPE(x); } /* SF bug 475327 -- if that didn't trigger, we need 3 @@ -1668,7 +1668,7 @@ winner = metatype; for (i = 0; i < nbases; i++) { tmp = PyTuple_GET_ITEM(bases, i); - tmptype = Py_Type(tmp); + tmptype = Py_TYPE(tmp); if (PyType_IsSubtype(winner, tmptype)) continue; if (PyType_IsSubtype(tmptype, winner)) { @@ -2055,7 +2055,7 @@ static PyObject * type_getattro(PyTypeObject *type, PyObject *name) { - PyTypeObject *metatype = Py_Type(type); + PyTypeObject *metatype = Py_TYPE(type); PyObject *meta_attribute, *attribute; descrgetfunc meta_get; @@ -2072,7 +2072,7 @@ meta_attribute = _PyType_Lookup(metatype, name); if (meta_attribute != NULL) { - meta_get = Py_Type(meta_attribute)->tp_descr_get; + meta_get = Py_TYPE(meta_attribute)->tp_descr_get; if (meta_get != NULL && PyDescr_IsData(meta_attribute)) { /* Data descriptors implement tp_descr_set to intercept @@ -2090,7 +2090,7 @@ attribute = _PyType_Lookup(type, name); if (attribute != NULL) { /* Implement descriptor functionality, if any */ - descrgetfunc local_get = Py_Type(attribute)->tp_descr_get; + descrgetfunc local_get = Py_TYPE(attribute)->tp_descr_get; Py_XDECREF(meta_attribute); @@ -2168,7 +2168,7 @@ PyObject_Free((char *)type->tp_doc); Py_XDECREF(et->ht_name); Py_XDECREF(et->ht_slots); - Py_Type(type)->tp_free((PyObject *)type); + Py_TYPE(type)->tp_free((PyObject *)type); } static PyObject * @@ -2388,7 +2388,7 @@ { int err = 0; if (excess_args(args, kwds)) { - PyTypeObject *type = Py_Type(self); + PyTypeObject *type = Py_TYPE(self); if (type->tp_init != object_init && type->tp_new != object_new) { @@ -2435,7 +2435,7 @@ static void object_dealloc(PyObject *self) { - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyObject * @@ -2444,7 +2444,7 @@ PyTypeObject *type; PyObject *mod, *name, *rtn; - type = Py_Type(self); + type = Py_TYPE(self); mod = type_module(type, NULL); if (mod == NULL) PyErr_Clear(); @@ -2470,7 +2470,7 @@ { unaryfunc f; - f = Py_Type(self)->tp_repr; + f = Py_TYPE(self)->tp_repr; if (f == NULL) f = object_repr; return f(self); @@ -2519,8 +2519,8 @@ static PyObject * object_get_class(PyObject *self, void *closure) { - Py_INCREF(Py_Type(self)); - return (PyObject *)(Py_Type(self)); + Py_INCREF(Py_TYPE(self)); + return (PyObject *)(Py_TYPE(self)); } static int @@ -2605,7 +2605,7 @@ static int object_set_class(PyObject *self, PyObject *value, void *closure) { - PyTypeObject *oldto = Py_Type(self); + PyTypeObject *oldto = Py_TYPE(self); PyTypeObject *newto; if (value == NULL) { @@ -2616,7 +2616,7 @@ if (!PyType_Check(value)) { PyErr_Format(PyExc_TypeError, "__class__ must be set to new-style class, not '%s' object", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); return -1; } newto = (PyTypeObject *)value; @@ -2629,7 +2629,7 @@ } if (compatible_for_assignment(newto, oldto, "__class__")) { Py_INCREF(newto); - Py_Type(self) = newto; + Py_TYPE(self) = newto; Py_DECREF(oldto); return 0; } @@ -2725,7 +2725,7 @@ if (args != NULL && !PyTuple_Check(args)) { PyErr_Format(PyExc_TypeError, "__getnewargs__ should return a tuple, " - "not '%.200s'", Py_Type(args)->tp_name); + "not '%.200s'", Py_TYPE(args)->tp_name); goto end; } } @@ -3403,8 +3403,8 @@ NULL when type is &PyBaseObject_Type, and we know its ob_type is not NULL (it's initialized to &PyType_Type). But coverity doesn't know that. */ - if (Py_Type(type) == NULL && base != NULL) - Py_Type(type) = Py_Type(base); + if (Py_TYPE(type) == NULL && base != NULL) + Py_TYPE(type) = Py_TYPE(base); /* Initialize tp_bases */ bases = type->tp_bases; @@ -3673,7 +3673,7 @@ if (!check_num_args(args, 1)) return NULL; other = PyTuple_GET_ITEM(args, 0); - if (!PyType_IsSubtype(Py_Type(other), Py_Type(self))) { + if (!PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } @@ -3742,7 +3742,7 @@ if (i == -1 && PyErr_Occurred()) return -1; if (i < 0) { - PySequenceMethods *sq = Py_Type(self)->tp_as_sequence; + PySequenceMethods *sq = Py_TYPE(self)->tp_as_sequence; if (sq && sq->sq_length) { Py_ssize_t n = (*sq->sq_length)(self); if (n < 0) @@ -3874,14 +3874,14 @@ if (!check_num_args(args, 1)) return NULL; other = PyTuple_GET_ITEM(args, 0); - if (Py_Type(other)->tp_compare != func && - !PyType_IsSubtype(Py_Type(other), Py_Type(self))) { + if (Py_TYPE(other)->tp_compare != func && + !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) { PyErr_Format( PyExc_TypeError, "%s.__cmp__(x,y) requires y to be a '%s', not a '%s'", - Py_Type(self)->tp_name, - Py_Type(self)->tp_name, - Py_Type(other)->tp_name); + Py_TYPE(self)->tp_name, + Py_TYPE(self)->tp_name, + Py_TYPE(other)->tp_name); return NULL; } res = (*func)(self, other); @@ -3895,7 +3895,7 @@ static int hackcheck(PyObject *self, setattrofunc func, char *what) { - PyTypeObject *type = Py_Type(self); + PyTypeObject *type = Py_TYPE(self); while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE) type = type->tp_base; /* If type is NULL now, this is a really weird type. @@ -4095,7 +4095,7 @@ PyErr_Format(PyExc_TypeError, "%s.__new__(X): X is not a type object (%s)", type->tp_name, - Py_Type(arg0)->tp_name); + Py_TYPE(arg0)->tp_name); return NULL; } subtype = (PyTypeObject *)arg0; @@ -4186,14 +4186,14 @@ PyObject *a, *b; int ok; - b = PyObject_GetAttrString((PyObject *)(Py_Type(right)), name); + b = PyObject_GetAttrString((PyObject *)(Py_TYPE(right)), name); if (b == NULL) { PyErr_Clear(); /* If right doesn't have it, it's not overloaded */ return 0; } - a = PyObject_GetAttrString((PyObject *)(Py_Type(left)), name); + a = PyObject_GetAttrString((PyObject *)(Py_TYPE(left)), name); if (a == NULL) { PyErr_Clear(); Py_DECREF(b); @@ -4218,14 +4218,14 @@ FUNCNAME(PyObject *self, PyObject *other) \ { \ static PyObject *cache_str, *rcache_str; \ - int do_other = Py_Type(self) != Py_Type(other) && \ - Py_Type(other)->tp_as_number != NULL && \ - Py_Type(other)->tp_as_number->SLOTNAME == TESTFUNC; \ - if (Py_Type(self)->tp_as_number != NULL && \ - Py_Type(self)->tp_as_number->SLOTNAME == TESTFUNC) { \ + int do_other = Py_TYPE(self) != Py_TYPE(other) && \ + Py_TYPE(other)->tp_as_number != NULL && \ + Py_TYPE(other)->tp_as_number->SLOTNAME == TESTFUNC; \ + if (Py_TYPE(self)->tp_as_number != NULL && \ + Py_TYPE(self)->tp_as_number->SLOTNAME == TESTFUNC) { \ PyObject *r; \ if (do_other && \ - PyType_IsSubtype(Py_Type(other), Py_Type(self)) && \ + PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self)) && \ method_is_overloaded(self, other, ROPSTR)) { \ r = call_maybe( \ other, ROPSTR, &rcache_str, "(O)", self); \ @@ -4237,7 +4237,7 @@ r = call_maybe( \ self, OPSTR, &cache_str, "(O)", other); \ if (r != Py_NotImplemented || \ - Py_Type(other) == Py_Type(self)) \ + Py_TYPE(other) == Py_TYPE(self)) \ return r; \ Py_DECREF(r); \ } \ @@ -4295,12 +4295,12 @@ if (getitem_str == NULL) return NULL; } - func = _PyType_Lookup(Py_Type(self), getitem_str); + func = _PyType_Lookup(Py_TYPE(self), getitem_str); if (func != NULL) { - if ((f = Py_Type(func)->tp_descr_get) == NULL) + if ((f = Py_TYPE(func)->tp_descr_get) == NULL) Py_INCREF(func); else { - func = f(func, self, (PyObject *)(Py_Type(self))); + func = f(func, self, (PyObject *)(Py_TYPE(self))); if (func == NULL) { return NULL; } @@ -4418,8 +4418,8 @@ /* Three-arg power doesn't use __rpow__. But ternary_op can call this when the second argument's type uses slot_nb_power, so check before calling self.__pow__. */ - if (Py_Type(self)->tp_as_number != NULL && - Py_Type(self)->tp_as_number->nb_power == slot_nb_power) { + if (Py_TYPE(self)->tp_as_number != NULL && + Py_TYPE(self)->tp_as_number->nb_power == slot_nb_power) { return call_method(self, "__pow__", &pow_str, "(OO)", other, modulus); } @@ -4464,7 +4464,7 @@ PyErr_Format(PyExc_TypeError, "__bool__ should return " "bool, returned %s", - Py_Type(temp)->tp_name); + Py_TYPE(temp)->tp_name); result = -1; } Py_DECREF(temp); @@ -4555,12 +4555,12 @@ { int c; - if (Py_Type(self)->tp_compare == _PyObject_SlotCompare) { + if (Py_TYPE(self)->tp_compare == _PyObject_SlotCompare) { c = half_compare(self, other); if (c <= 1) return c; } - if (Py_Type(other)->tp_compare == _PyObject_SlotCompare) { + if (Py_TYPE(other)->tp_compare == _PyObject_SlotCompare) { c = half_compare(other, self); if (c < -1) return -2; @@ -4585,7 +4585,7 @@ } PyErr_Clear(); return PyUnicode_FromFormat("<%s object at %p>", - Py_Type(self)->tp_name, self); + Py_TYPE(self)->tp_name, self); } static PyObject * @@ -4628,7 +4628,7 @@ if (func == NULL) { PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'", - Py_Type(self)->tp_name); + Py_TYPE(self)->tp_name); return -1; } @@ -4684,7 +4684,7 @@ static PyObject * slot_tp_getattr_hook(PyObject *self, PyObject *name) { - PyTypeObject *tp = Py_Type(self); + PyTypeObject *tp = Py_TYPE(self); PyObject *getattr, *getattribute, *res; static PyObject *getattribute_str = NULL; static PyObject *getattr_str = NULL; @@ -4708,7 +4708,7 @@ } getattribute = _PyType_Lookup(tp, getattribute_str); if (getattribute == NULL || - (Py_Type(getattribute) == &PyWrapperDescr_Type && + (Py_TYPE(getattribute) == &PyWrapperDescr_Type && ((PyWrapperDescrObject *)getattribute)->d_wrapped == (void *)PyObject_GenericGetAttr)) res = PyObject_GenericGetAttr(self, name); @@ -4767,13 +4767,13 @@ { PyObject *res; - if (Py_Type(self)->tp_richcompare == slot_tp_richcompare) { + if (Py_TYPE(self)->tp_richcompare == slot_tp_richcompare) { res = half_richcompare(self, other, op); if (res != Py_NotImplemented) return res; Py_DECREF(res); } - if (Py_Type(other)->tp_richcompare == slot_tp_richcompare) { + if (Py_TYPE(other)->tp_richcompare == slot_tp_richcompare) { res = half_richcompare(other, self, _Py_SwappedOp[op]); if (res != Py_NotImplemented) { return res; @@ -4806,7 +4806,7 @@ if (func == NULL) { PyErr_Format(PyExc_TypeError, "'%.200s' object is not iterable", - Py_Type(self)->tp_name); + Py_TYPE(self)->tp_name); return NULL; } Py_DECREF(func); @@ -4823,7 +4823,7 @@ static PyObject * slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type) { - PyTypeObject *tp = Py_Type(self); + PyTypeObject *tp = Py_TYPE(self); PyObject *get; static PyObject *get_str = NULL; @@ -4881,7 +4881,7 @@ if (res != Py_None) { PyErr_Format(PyExc_TypeError, "__init__() should return None, not '%.200s'", - Py_Type(res)->tp_name); + Py_TYPE(res)->tp_name); Py_DECREF(res); return -1; } @@ -4966,7 +4966,7 @@ _Py_NewReference(self); self->ob_refcnt = refcnt; } - assert(!PyType_IS_GC(Py_Type(self)) || + assert(!PyType_IS_GC(Py_TYPE(self)) || _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED); /* If Py_REF_DEBUG, _Py_NewReference bumped _Py_RefTotal, so * we need to undo that. */ @@ -4978,8 +4978,8 @@ * undone. */ #ifdef COUNT_ALLOCS - --Py_Type(self)->tp_frees; - --Py_Type(self)->tp_allocs; + --Py_TYPE(self)->tp_frees; + --Py_TYPE(self)->tp_allocs; #endif } @@ -5314,7 +5314,7 @@ descr = _PyType_Lookup(type, p->name_strobj); if (descr == NULL) continue; - if (Py_Type(descr) == &PyWrapperDescr_Type) { + if (Py_TYPE(descr) == &PyWrapperDescr_Type) { void **tptr = resolve_slotdups(type, p->name_strobj); if (tptr == NULL || tptr == ptr) generic = p->function; @@ -5329,7 +5329,7 @@ use_generic = 1; } } - else if (Py_Type(descr) == &PyCFunction_Type && + else if (Py_TYPE(descr) == &PyCFunction_Type && PyCFunction_GET_FUNCTION(descr) == (PyCFunction)tp_new_wrapper && strcmp(p->name, "__new__") == 0) @@ -5600,7 +5600,7 @@ Py_XDECREF(su->obj); Py_XDECREF(su->type); Py_XDECREF(su->obj_type); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } static PyObject * @@ -5663,7 +5663,7 @@ res = PyDict_GetItem(dict, name); if (res != NULL) { Py_INCREF(res); - f = Py_Type(res)->tp_descr_get; + f = Py_TYPE(res)->tp_descr_get; if (f != NULL) { tmp = f(res, /* Only pass 'obj' param if @@ -5699,7 +5699,7 @@ the normal case; the return value is obj.__class__. But... when obj is an instance, we want to allow for the case where - Py_Type(obj) is not a subclass of type, but obj.__class__ is! + Py_TYPE(obj) is not a subclass of type, but obj.__class__ is! This will allow using super() with a proxy for obj. */ @@ -5710,9 +5710,9 @@ } /* Normal case */ - if (PyType_IsSubtype(Py_Type(obj), type)) { - Py_INCREF(Py_Type(obj)); - return Py_Type(obj); + if (PyType_IsSubtype(Py_TYPE(obj), type)) { + Py_INCREF(Py_TYPE(obj)); + return Py_TYPE(obj); } else { /* Try the slow way */ @@ -5729,7 +5729,7 @@ if (class_attr != NULL && PyType_Check(class_attr) && - (PyTypeObject *)class_attr != Py_Type(obj)) + (PyTypeObject *)class_attr != Py_TYPE(obj)) { int ok = PyType_IsSubtype( (PyTypeObject *)class_attr, type); @@ -5760,10 +5760,10 @@ Py_INCREF(self); return self; } - if (Py_Type(su) != &PySuper_Type) + if (Py_TYPE(su) != &PySuper_Type) /* If su is an instance of a (strict) subclass of super, call its type */ - return PyObject_CallFunctionObjArgs((PyObject *)Py_Type(su), + return PyObject_CallFunctionObjArgs((PyObject *)Py_TYPE(su), su->type, obj, NULL); else { /* Inline the common case */ @@ -5845,7 +5845,7 @@ if (!PyType_Check(type)) { PyErr_Format(PyExc_SystemError, "super(): __class__ is not a type (%s)", - Py_Type(type)->tp_name); + Py_TYPE(type)->tp_name); return -1; } break; Modified: python/branches/py3k/Objects/unicodeobject.c ============================================================================== --- python/branches/py3k/Objects/unicodeobject.c (original) +++ python/branches/py3k/Objects/unicodeobject.c Wed Dec 19 03:45:37 2007 @@ -313,7 +313,7 @@ case SSTATE_INTERNED_MORTAL: /* revive dead object temporarily for DelItem */ - Py_Refcnt(unicode) = 3; + Py_REFCNT(unicode) = 3; if (PyDict_DelItem(interned, (PyObject *)unicode) != 0) Py_FatalError( "deletion of interned unicode string failed"); @@ -346,7 +346,7 @@ else { PyMem_DEL(unicode->str); Py_XDECREF(unicode->defenc); - Py_Type(unicode)->tp_free((PyObject *)unicode); + Py_TYPE(unicode)->tp_free((PyObject *)unicode); } } @@ -360,7 +360,7 @@ return -1; } v = (PyUnicodeObject *)*unicode; - if (v == NULL || !PyUnicode_Check(v) || Py_Refcnt(v) != 1 || length < 0) { + if (v == NULL || !PyUnicode_Check(v) || Py_REFCNT(v) != 1 || length < 0) { PyErr_BadInternalCall(); return -1; } @@ -1000,7 +1000,7 @@ } PyErr_Format(PyExc_TypeError, "Can't convert '%.100s' object to str implicitly", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); return NULL; } @@ -1035,7 +1035,7 @@ PyErr_Format(PyExc_TypeError, "coercing to Unicode: need string or buffer, " "%.80s found", - Py_Type(obj)->tp_name); + Py_TYPE(obj)->tp_name); goto onError; } @@ -1115,7 +1115,7 @@ if (!PyUnicode_Check(unicode)) { PyErr_Format(PyExc_TypeError, "decoder did not return an unicode object (type=%.400s)", - Py_Type(unicode)->tp_name); + Py_TYPE(unicode)->tp_name); Py_DECREF(unicode); goto onError; } @@ -2351,7 +2351,7 @@ } done: - result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_Size(v)); + result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_SIZE(v)); Py_DECREF(v); return result; #undef STORECHAR @@ -2615,7 +2615,7 @@ } done: - result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_Size(v)); + result = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_SIZE(v)); Py_DECREF(v); return result; #undef STORECHAR @@ -4367,7 +4367,7 @@ char *outstart; Py_ssize_t outsize = PyString_GET_SIZE(*outobj); - if (Py_Type(mapping) == &EncodingMapType) { + if (Py_TYPE(mapping) == &EncodingMapType) { int res = encoding_map_lookup(c, mapping); Py_ssize_t requiredsize = *outpos+1; if (res == -1) @@ -4439,7 +4439,7 @@ /* find all unencodable characters */ while (collendpos < size) { PyObject *rep; - if (Py_Type(mapping) == &EncodingMapType) { + if (Py_TYPE(mapping) == &EncodingMapType) { int res = encoding_map_lookup(p[collendpos], mapping); if (res != -1) break; @@ -5482,7 +5482,7 @@ PyErr_Format(PyExc_TypeError, "sequence item %zd: expected str instance," " %.80s found", - i, Py_Type(item)->tp_name); + i, Py_TYPE(item)->tp_name); goto onError; } item = PyUnicode_FromObject(item); @@ -6505,7 +6505,7 @@ PyErr_Format(PyExc_TypeError, "encoder did not return a bytes object " "(type=%.400s)", - Py_Type(v)->tp_name); + Py_TYPE(v)->tp_name); Py_DECREF(v); return NULL; } @@ -6647,12 +6647,12 @@ if (self->hash != -1) return self->hash; - len = Py_Size(self); + len = Py_SIZE(self); p = self->str; x = *p << 7; while (--len >= 0) x = (1000003*x) ^ *p++; - x ^= Py_Size(self); + x ^= Py_SIZE(self); if (x == -1) x = -2; self->hash = x; @@ -8514,7 +8514,7 @@ arglen = -1; argidx = -2; } - if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) && + if (Py_TYPE(args)->tp_as_mapping && !PyTuple_Check(args) && !PyUnicode_Check(args)) dict = args; @@ -9120,7 +9120,7 @@ PyThreadState_GET()->recursion_critical = 0; /* The two references in interned are not counted by refcnt. The deallocator will take care of this */ - Py_Refcnt(s) -= 2; + Py_REFCNT(s) -= 2; PyUnicode_CHECK_INTERNED(s) = SSTATE_INTERNED_MORTAL; } @@ -9174,11 +9174,11 @@ /* XXX Shouldn't happen */ break; case SSTATE_INTERNED_IMMORTAL: - Py_Refcnt(s) += 1; + Py_REFCNT(s) += 1; immortal_size += s->length; break; case SSTATE_INTERNED_MORTAL: - Py_Refcnt(s) += 2; + Py_REFCNT(s) += 2; mortal_size += s->length; break; default: Modified: python/branches/py3k/Objects/weakrefobject.c ============================================================================== --- python/branches/py3k/Objects/weakrefobject.c (original) +++ python/branches/py3k/Objects/weakrefobject.c Wed Dec 19 03:45:37 2007 @@ -105,7 +105,7 @@ { PyObject_GC_UnTrack(self); clear_weakref((PyWeakReference *) self); - Py_Type(self)->tp_free(self); + Py_TYPE(self)->tp_free(self); } @@ -172,7 +172,7 @@ name ? "" : "", self, - Py_Type(PyWeakref_GET_OBJECT(self))->tp_name, + Py_TYPE(PyWeakref_GET_OBJECT(self))->tp_name, PyWeakref_GET_OBJECT(self), name); Py_XDECREF(nameobj); @@ -276,10 +276,10 @@ PyWeakReference *ref, *proxy; PyWeakReference **list; - if (!PyType_SUPPORTS_WEAKREFS(Py_Type(ob))) { + if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) { PyErr_Format(PyExc_TypeError, "cannot create weak reference to '%s' object", - Py_Type(ob)->tp_name); + Py_TYPE(ob)->tp_name); return NULL; } if (callback == Py_None) @@ -448,7 +448,7 @@ char buf[160]; PyOS_snprintf(buf, sizeof(buf), "", proxy, - Py_Type(PyWeakref_GET_OBJECT(proxy))->tp_name, + Py_TYPE(PyWeakref_GET_OBJECT(proxy))->tp_name, PyWeakref_GET_OBJECT(proxy)); return PyUnicode_FromString(buf); } @@ -699,10 +699,10 @@ PyWeakReference **list; PyWeakReference *ref, *proxy; - if (!PyType_SUPPORTS_WEAKREFS(Py_Type(ob))) { + if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) { PyErr_Format(PyExc_TypeError, "cannot create weak reference to '%s' object", - Py_Type(ob)->tp_name); + Py_TYPE(ob)->tp_name); return NULL; } list = GET_WEAKREFS_LISTPTR(ob); @@ -758,10 +758,10 @@ PyWeakReference **list; PyWeakReference *ref, *proxy; - if (!PyType_SUPPORTS_WEAKREFS(Py_Type(ob))) { + if (!PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob))) { PyErr_Format(PyExc_TypeError, "cannot create weak reference to '%s' object", - Py_Type(ob)->tp_name); + Py_TYPE(ob)->tp_name); return NULL; } list = GET_WEAKREFS_LISTPTR(ob); @@ -784,9 +784,9 @@ PyWeakReference *prev; if (PyCallable_Check(ob)) - Py_Type(result) = &_PyWeakref_CallableProxyType; + Py_TYPE(result) = &_PyWeakref_CallableProxyType; else - Py_Type(result) = &_PyWeakref_ProxyType; + Py_TYPE(result) = &_PyWeakref_ProxyType; get_basic_refs(*list, &ref, &proxy); if (callback == NULL) { if (proxy != NULL) { @@ -851,7 +851,7 @@ PyWeakReference **list; if (object == NULL - || !PyType_SUPPORTS_WEAKREFS(Py_Type(object)) + || !PyType_SUPPORTS_WEAKREFS(Py_TYPE(object)) || object->ob_refcnt != 0) { PyErr_BadInternalCall(); return; Modified: python/branches/py3k/PC/_subprocess.c ============================================================================== --- python/branches/py3k/PC/_subprocess.c (original) +++ python/branches/py3k/PC/_subprocess.c Wed Dec 19 03:45:37 2007 @@ -269,7 +269,7 @@ PyErr_Clear(); /* FIXME: propagate error? */ return NULL; } - if (Py_Type(value) != &sp_handle_type) + if (Py_TYPE(value) != &sp_handle_type) ret = NULL; else ret = value->handle; @@ -552,7 +552,7 @@ PyObject *m; /* patch up object descriptors */ - Py_Type(&sp_handle_type) = &PyType_Type; + Py_TYPE(&sp_handle_type) = &PyType_Type; sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int; m = Py_InitModule("_subprocess", sp_functions); Modified: python/branches/py3k/PC/_winreg.c ============================================================================== --- python/branches/py3k/PC/_winreg.c (original) +++ python/branches/py3k/PC/_winreg.c Wed Dec 19 03:45:37 2007 @@ -522,7 +522,7 @@ return PyLong_FromVoidPtr(((PyHKEYObject *)self)->hkey); PyErr_Format(PyExc_AttributeError, "'%.50s' object has no attribute '%.400s'", - Py_Type(self)->tp_name, name); + Py_TYPE(self)->tp_name, name); return NULL; } @@ -1388,7 +1388,7 @@ if (m == NULL) return; d = PyModule_GetDict(m); - Py_Type(&PyHKEY_Type) = &PyType_Type; + Py_TYPE(&PyHKEY_Type) = &PyType_Type; PyHKEY_Type.tp_doc = PyHKEY_doc; Py_INCREF(&PyHKEY_Type); if (PyDict_SetItemString(d, "HKEYType", Modified: python/branches/py3k/Parser/tokenizer.c ============================================================================== --- python/branches/py3k/Parser/tokenizer.c (original) +++ python/branches/py3k/Parser/tokenizer.c Wed Dec 19 03:45:37 2007 @@ -1600,7 +1600,7 @@ tok->buf, *offset-1); if (offsetobj) { - *offset = 1 + Py_Size(offsetobj); + *offset = 1 + Py_SIZE(offsetobj); Py_DECREF(offsetobj); } } Modified: python/branches/py3k/Python/ast.c ============================================================================== --- python/branches/py3k/Python/ast.c (original) +++ python/branches/py3k/Python/ast.c Wed Dec 19 03:45:37 2007 @@ -3156,7 +3156,7 @@ return NULL; } r = PyString_AS_STRING(w); - rn = Py_Size(w); + rn = Py_SIZE(w); assert(rn % 2 == 0); for (i = 0; i < rn; i += 2) { sprintf(p, "\\u%02x%02x", Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Wed Dec 19 03:45:37 2007 @@ -309,16 +309,16 @@ } /* Make sure the type is initialized. float gets initialized late */ - if (Py_Type(value)->tp_dict == NULL) - if (PyType_Ready(Py_Type(value)) < 0) + if (Py_TYPE(value)->tp_dict == NULL) + if (PyType_Ready(Py_TYPE(value)) < 0) goto done; /* Find the (unbound!) __format__ method (a borrowed reference) */ - meth = _PyType_Lookup(Py_Type(value), format_str); + meth = _PyType_Lookup(Py_TYPE(value), format_str); if (meth == NULL) { PyErr_Format(PyExc_TypeError, "Type %.100s doesn't define __format__", - Py_Type(value)->tp_name); + Py_TYPE(value)->tp_name); goto done; } @@ -1433,8 +1433,8 @@ kwlist, &number, &ndigits)) return NULL; - if (Py_Type(number)->tp_dict == NULL) { - if (PyType_Ready(Py_Type(number)) < 0) + if (Py_TYPE(number)->tp_dict == NULL) { + if (PyType_Ready(Py_TYPE(number)) < 0) return NULL; } @@ -1444,11 +1444,11 @@ return NULL; } - round = _PyType_Lookup(Py_Type(number), round_str); + round = _PyType_Lookup(Py_TYPE(number), round_str); if (round == NULL) { PyErr_Format(PyExc_TypeError, "type %.100s doesn't define __round__ method", - Py_Type(number)->tp_name); + Py_TYPE(number)->tp_name); return NULL; } @@ -1552,8 +1552,8 @@ static PyObject *trunc_str = NULL; PyObject *trunc; - if (Py_Type(number)->tp_dict == NULL) { - if (PyType_Ready(Py_Type(number)) < 0) + if (Py_TYPE(number)->tp_dict == NULL) { + if (PyType_Ready(Py_TYPE(number)) < 0) return NULL; } @@ -1563,11 +1563,11 @@ return NULL; } - trunc = _PyType_Lookup(Py_Type(number), trunc_str); + trunc = _PyType_Lookup(Py_TYPE(number), trunc_str); if (trunc == NULL) { PyErr_Format(PyExc_TypeError, "type %.100s doesn't define __trunc__ method", - Py_Type(number)->tp_name); + Py_TYPE(number)->tp_name); return NULL; } return PyObject_CallFunction(trunc, "O", number); Modified: python/branches/py3k/Python/ceval.c ============================================================================== --- python/branches/py3k/Python/ceval.c (original) +++ python/branches/py3k/Python/ceval.c Wed Dec 19 03:45:37 2007 @@ -3006,7 +3006,7 @@ *--sp = PyList_GET_ITEM(l, ll - j); } /* Resize the list. */ - Py_Size(l) = ll - argcntafter; + Py_SIZE(l) = ll - argcntafter; Py_DECREF(it); return 1; @@ -3496,7 +3496,7 @@ } if (argdefs != NULL) { d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_Size(argdefs); + nd = Py_SIZE(argdefs); } return PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, (*pp_stack)-n, na, Modified: python/branches/py3k/Python/codecs.c ============================================================================== --- python/branches/py3k/Python/codecs.c (original) +++ python/branches/py3k/Python/codecs.c Wed Dec 19 03:45:37 2007 @@ -354,7 +354,7 @@ v = NULL; goto onError; } - v = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_Size(v)); + v = PyString_FromStringAndSize(PyBytes_AS_STRING(v), Py_SIZE(v)); } else if (PyString_Check(v)) Py_INCREF(v); Modified: python/branches/py3k/Python/marshal.c ============================================================================== --- python/branches/py3k/Python/marshal.c (original) +++ python/branches/py3k/Python/marshal.c Wed Dec 19 03:45:37 2007 @@ -153,7 +153,7 @@ PyLongObject *ob = (PyLongObject *)v; PyErr_Clear(); w_byte(TYPE_LONG, p); - n = Py_Size(ob); + n = Py_SIZE(ob); w_long((long)n, p); if (n < 0) n = -n; @@ -557,7 +557,7 @@ retval = NULL; break; } - Py_Size(ob) = n; + Py_SIZE(ob) = n; for (i = 0; i < size; i++) { int digit = r_short(p); if (digit < 0) { From python-3000-checkins at python.org Thu Dec 20 14:16:07 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 20 Dec 2007 14:16:07 +0100 (CET) Subject: [Python-3000-checkins] r59579 - python/branches/py3k/Lib/test/test_import.py Message-ID: <20071220131607.6E34D1E4009@bag.python.org> Author: christian.heimes Date: Thu Dec 20 14:16:07 2007 New Revision: 59579 Modified: python/branches/py3k/Lib/test/test_import.py Log: Removed test from test_import. It will never work on all systems, see #1377 Modified: python/branches/py3k/Lib/test/test_import.py ============================================================================== --- python/branches/py3k/Lib/test/test_import.py (original) +++ python/branches/py3k/Lib/test/test_import.py Thu Dec 20 14:16:07 2007 @@ -173,23 +173,6 @@ shutil.rmtree(self.path) sys.path = self.syspath - def XXX_test_sys_path_with_unicode(self): - for i, subpath in enumerate(self.SAMPLES): - path = os.path.join(self.path, subpath) - os.mkdir(path) - self.failUnless(os.path.exists(path), os.listdir(self.path)) - f = open(os.path.join(path, 'testimport%i.py' % i), 'w') - f.write("testdata = 'unicode path %i'\n" % i) - f.close() - sys.path.append(path) - try: - mod = __import__("testimport%i" % i) - except ImportError: - print(path, file=sys.stderr) - raise - self.assertEqual(mod.testdata, 'unicode path %i' % i) - unload("testimport%i" % i) - # http://bugs.python.org/issue1293 def test_trailing_slash(self): f = open(os.path.join(self.path, 'test_trailing_slash.py'), 'w') From python-3000-checkins at python.org Thu Dec 20 15:44:41 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Thu, 20 Dec 2007 15:44:41 +0100 (CET) Subject: [Python-3000-checkins] r59580 - python/branches/py3k/Lib/test/test_pep277.py Message-ID: <20071220144441.C4DB31E400C@bag.python.org> Author: christian.heimes Date: Thu Dec 20 15:44:41 2007 New Revision: 59580 Modified: python/branches/py3k/Lib/test/test_pep277.py Log: Fixed #1673. I hope it works. I don't have access to a Windows box right now. Modified: python/branches/py3k/Lib/test/test_pep277.py ============================================================================== --- python/branches/py3k/Lib/test/test_pep277.py (original) +++ python/branches/py3k/Lib/test/test_pep277.py Thu Dec 20 15:44:41 2007 @@ -80,7 +80,7 @@ f1 = os.listdir(test_support.TESTFN) f2 = os.listdir(str(test_support.TESTFN.encode("utf-8"), sys.getfilesystemencoding())) - sf2 = set("\\".join((unicode(test_support.TESTFN), f)) + sf2 = set("\\".join((str(test_support.TESTFN), f)) for f in f2) self.failUnlessEqual(len(f1), len(self.files)) self.failUnlessEqual(sf2, set(self.files)) From python-3000-checkins at python.org Thu Dec 20 16:55:58 2007 From: python-3000-checkins at python.org (barry.warsaw) Date: Thu, 20 Dec 2007 16:55:58 +0100 (CET) Subject: [Python-3000-checkins] r59581 - python/branches/py3k/Tools/world/world Message-ID: <20071220155558.C10391E400E@bag.python.org> Author: barry.warsaw Date: Thu Dec 20 16:55:58 2007 New Revision: 59581 Modified: python/branches/py3k/Tools/world/world Log: Update to the world tool for Python 3. Provided by quentin.gallet-gilles via tracker issue 1671: http://bugs.python.org/issue1671 In addition to updating the code for Py3k, this updates ccTLDs to their 10-Oct-2006 revision. (Minor stylistic additions and whitespace normalization by Barry.) Modified: python/branches/py3k/Tools/world/world ============================================================================== --- python/branches/py3k/Tools/world/world (original) +++ python/branches/py3k/Tools/world/world Thu Dec 20 16:55:58 2007 @@ -42,7 +42,7 @@ The latest known change to this information was: - Friday, 5 April 2002, 12.00 CET 2002 + Monday, 10 October 2006, 17:59:51 UTC 2006 This script also knows about non-geographic top-level domains, and the additional ccTLDs reserved by IANA. @@ -91,9 +91,9 @@ def usage(code, msg=''): - print __doc__ % globals() + print(__doc__ % globals()) if msg: - print msg + print(msg) sys.exit(code) @@ -104,11 +104,11 @@ # no top level domain found, bounce it to the next step return rawaddr addr = parts[-1] - if nameorgs.has_key(addr): - print rawaddr, 'is in the', nameorgs[addr], 'top level domain' + if addr in nameorgs: + print(rawaddr, 'is in the', nameorgs[addr], 'top level domain') return None - elif countries.has_key(addr): - print rawaddr, 'originated from', countries[addr] + elif addr in countries: + print(rawaddr, 'originated from', countries[addr]) return None else: # Not resolved, bounce it to the next step @@ -129,11 +129,11 @@ return regexp if len(matches) == 1: code = matches[0] - print regexp, "matches code `%s', %s" % (code, all[code]) + print(regexp, "matches code `%s', %s" % (code, all[code])) else: - print regexp, 'matches %d countries:' % len(matches) + print(regexp, 'matches %d countries:' % len(matches)) for code in matches: - print " %s: %s" % (code, all[code]) + print(" %s: %s" % (code, all[code])) return None @@ -141,14 +141,16 @@ def parse(file, normalize): try: fp = open(file) - except IOError, (err, msg): - print msg, ':', file + except IOError as err: + errno, msg = err.args + print(msg, ':', file) + return cre = re.compile('(.*?)[ \t]+([A-Z]{2})[ \t]+[A-Z]{3}[ \t]+[0-9]{3}') scanning = 0 if normalize: - print 'countries = {' + print('countries = {') while 1: line = fp.readline() @@ -163,7 +165,7 @@ elif line[0] == '-': break else: - print 'Could not parse line:', line + print('Could not parse line:', line) continue country, code = mo.group(1, 2) if normalize: @@ -173,30 +175,30 @@ # XXX special cases if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'): words[i] = w.lower() - elif w == 'THE' and i <> 1: + elif w == 'THE' and i != 1: words[i] = w.lower() elif len(w) > 3 and w[1] == "'": words[i] = w[0:3].upper() + w[3:].lower() elif w in ('(U.S.)', 'U.S.'): pass - elif w[0] == '(' and w <> '(local': + elif w[0] == '(' and w != '(local': words[i] = '(' + w[1:].capitalize() - elif w.find('-') <> -1: + elif w.find('-') != -1: words[i] = '-'.join( [s.capitalize() for s in w.split('-')]) else: words[i] = w.capitalize() code = code.lower() country = ' '.join(words) - print ' "%s": "%s",' % (code, country) + print(' "%s": "%s",' % (code, country)) else: - print code, country - + print(code, country) + elif line[0] == '-': scanning = 1 if normalize: - print ' }' + print(' }') def main(): @@ -212,7 +214,7 @@ sys.argv[1:], 'p:rohd', ['parse=', 'reverse', 'outputdict', 'help', 'dump']) - except getopt.error, msg: + except getopt.error as msg: usage(1, msg) for opt, arg in opts: @@ -231,17 +233,15 @@ usage(status) if dump: - print 'Non-geographic domains:' - codes = nameorgs.keys() - codes.sort() + print('Official country coded domains:') + codes = sorted(countries) for code in codes: - print ' %4s:' % code, nameorgs[code] + print(' %2s:' % code, countries[code]) - print '\nCountry coded domains:' - codes = countries.keys() - codes.sort() + print('\nOther top-level domains:') + codes = sorted(nameorgs) for code in codes: - print ' %2s:' % code, countries[code] + print(' %6s:' % code, nameorgs[code]) elif parsefile: parse(parsefile, normalize) else: @@ -249,7 +249,7 @@ args = filter(None, map(resolve, args)) args = filter(None, map(reverse, args)) for arg in args: - print 'Where in the world is %s?' % arg + print('Where in the world is %s?' % arg) @@ -258,26 +258,30 @@ # New top level domains as described by ICANN # http://www.icann.org/tlds/ "aero": "air-transport industry", + "asia": "from Asia/for Asia", "arpa": "Arpanet", "biz": "business", + "cat": "Catalan community", "com": "commercial", "coop": "cooperatives", "edu": "educational", "gov": "government", "info": "unrestricted `info'", "int": "international", + "jobs": "employment-related", "mil": "military", + "mobi": "mobile specific", "museum": "museums", "name": "`name' (for registration by individuals)", "net": "networking", "org": "non-commercial", "pro": "professionals", + "tel": "business telecommunications", + "travel": "travel and tourism", # These additional ccTLDs are included here even though they are not part - # of ISO 3166. IANA has 5 reserved ccTLDs as described here: - # - # http://www.iso.org/iso/en/prods-services/iso3166ma/04background-on-iso-3166/iso3166-1-and-ccTLDs.html + # of ISO 3166. IANA has a decoding table listing all reserved ccTLDs: # - # but I can't find an official list anywhere. + # http://www.iso.org/iso/iso-3166-1_decoding_table # # Note that `uk' is the common practice country code for the United # Kingdom. AFAICT, the official `gb' code is routinely ignored! @@ -292,9 +296,13 @@ # # Also, `su', while obsolete is still in limited use. "ac": "Ascension Island", - "gg": "Guernsey", - "im": "Isle of Man", - "je": "Jersey", + "cp": "Clipperton Island", + "dg": "Diego Garcia", + "ea": "Ceuta, Melilla", + "eu": "European Union", + "fx": "Metropolitan France", + "ic": "Canary Islands", + "ta": "Tristan da Cunha", "uk": "United Kingdom (common practice)", "su": "Soviet Union (still in limited use)", } @@ -303,6 +311,7 @@ countries = { "af": "Afghanistan", + "ax": "Aland Islands", "al": "Albania", "dz": "Algeria", "as": "American Samoa", @@ -328,7 +337,7 @@ "bm": "Bermuda", "bt": "Bhutan", "bo": "Bolivia", - "ba": "Bosnia and Herzegowina", + "ba": "Bosnia and Herzegovina", "bw": "Botswana", "bv": "Bouvet Island", "br": "Brazil", @@ -363,7 +372,6 @@ "dj": "Djibouti", "dm": "Dominica", "do": "Dominican Republic", - "tp": "East Timor", "ec": "Ecuador", "eg": "Egypt", "sv": "El Salvador", @@ -391,6 +399,7 @@ "gp": "Guadeloupe", "gu": "Guam", "gt": "Guatemala", + "gg": "Guernsey", "gn": "Guinea", "gw": "Guinea-Bissau", "gy": "Guyana", @@ -403,15 +412,17 @@ "is": "Iceland", "in": "India", "id": "Indonesia", - "ir": "Iran, Islamic Republic of", + "ir": "Iran (Islamic Republic of)", "iq": "Iraq", "ie": "Ireland", + "im": "Isle of Man", "il": "Israel", "it": "Italy", "jm": "Jamaica", "jp": "Japan", + "je": "Jersey", "jo": "Jordan", - "kz": "Kazakstan", + "kz": "Kazakhstan", "ke": "Kenya", "ki": "Kiribati", "kp": "Korea, Democratic People's Republic of", @@ -427,7 +438,7 @@ "li": "Liechtenstein", "lt": "Lithuania", "lu": "Luxembourg", - "mo": "Macau", + "mo": "Macao", "mk": "Macedonia, The Former Yugoslav Republic of", "mg": "Madagascar", "mw": "Malawi", @@ -445,6 +456,7 @@ "md": "Moldova, Republic of", "mc": "Monaco", "mn": "Mongolia", + "me": "Montenegro", "ms": "Montserrat", "ma": "Morocco", "mz": "Mozambique", @@ -491,6 +503,7 @@ "st": "Sao Tome and Principe", "sa": "Saudi Arabia", "sn": "Senegal", + "rs": "Serbia", "sc": "Seychelles", "sl": "Sierra Leone", "sg": "Singapore", @@ -505,6 +518,8 @@ "sd": "Sudan", "sr": "Suriname", "sj": "Svalbard and Jan Mayen", + "sh": "St. Helena", + "pm": "St. Pierre and Miquelon", "sz": "Swaziland", "se": "Sweden", "ch": "Switzerland", @@ -513,6 +528,7 @@ "tj": "Tajikistan", "tz": "Tanzania, United Republic of", "th": "Thailand", + "tl": "Timor-Leste", "tg": "Togo", "tk": "Tokelau", "to": "Tonga", @@ -531,10 +547,11 @@ "uy": "Uruguay", "uz": "Uzbekistan", "vu": "Vanuatu", + "va": "Vatican City State (Holy See)", "ve": "Venezuela", "vn": "Viet Nam", - "vg": "Virgin Islands, British", - "vi": "Virgin Islands, U.S.", + "vg": "Virgin Islands (British)", + "vi": "Virgin Islands (U.S.)", "wf": "Wallis and Futuna", "eh": "Western Sahara", "ye": "Yemen", From python-3000-checkins at python.org Thu Dec 20 19:42:56 2007 From: python-3000-checkins at python.org (guido.van.rossum) Date: Thu, 20 Dec 2007 19:42:56 +0100 (CET) Subject: [Python-3000-checkins] r59583 - python/branches/py3k/Lib/site.py Message-ID: <20071220184256.ACDD51E4026@bag.python.org> Author: guido.van.rossum Date: Thu Dec 20 19:42:56 2007 New Revision: 59583 Modified: python/branches/py3k/Lib/site.py Log: Fix issue #1667. The _Printer() class was using sys.stdin.readline() instead of input() to read the user's input (since at some point in the past raw_input() was removed), but the code used to decode the input wasn't changed. Fixed it by going back to input(), which has since been added back with the same semantics as the old raw_input(). Modified: python/branches/py3k/Lib/site.py ============================================================================== --- python/branches/py3k/Lib/site.py (original) +++ python/branches/py3k/Lib/site.py Thu Dec 20 19:42:56 2007 @@ -310,9 +310,7 @@ lineno += self.MAXLINES key = None while key is None: - sys.stdout.write(prompt) - sys.stdout.flush() - key = sys.stdin.readline() + key = input(prompt) if key not in ('', 'q'): key = None if key == 'q': From python-3000-checkins at python.org Thu Dec 20 23:57:24 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Thu, 20 Dec 2007 23:57:24 +0100 (CET) Subject: [Python-3000-checkins] r59585 - in python/branches/py3k: Include/longobject.h Objects/longobject.c Objects/rangeobject.c Message-ID: <20071220225724.1F9E11E400D@bag.python.org> Author: martin.v.loewis Date: Thu Dec 20 23:57:23 2007 New Revision: 59585 Modified: python/branches/py3k/Include/longobject.h python/branches/py3k/Objects/longobject.c python/branches/py3k/Objects/rangeobject.c Log: Drop _PyLong_FitsInLong. Fixes #1666. Modified: python/branches/py3k/Include/longobject.h ============================================================================== --- python/branches/py3k/Include/longobject.h (original) +++ python/branches/py3k/Include/longobject.h Thu Dec 20 23:57:23 2007 @@ -50,7 +50,6 @@ be multiplied by SHIFT! There may not be enough room in an int to store e*SHIFT directly. */ PyAPI_FUNC(double) _PyLong_AsScaledDouble(PyObject *vv, int *e); - PyAPI_FUNC(int) _PyLong_FitsInLong(PyObject* vv); PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); Modified: python/branches/py3k/Objects/longobject.c ============================================================================== --- python/branches/py3k/Objects/longobject.c (original) +++ python/branches/py3k/Objects/longobject.c Thu Dec 20 23:57:23 2007 @@ -392,19 +392,6 @@ return result; } -int -_PyLong_FitsInLong(PyObject *vv) -{ - int size; - if (!PyLong_CheckExact(vv)) { - PyErr_BadInternalCall(); - return 0; - } - /* conservative estimate */ - size = Py_SIZE(vv); - return -2 <= size && size <= 2; -} - /* Get a Py_ssize_t from a long int object. Returns -1 and sets an error condition if overflow occurs. */ Modified: python/branches/py3k/Objects/rangeobject.c ============================================================================== --- python/branches/py3k/Objects/rangeobject.c (original) +++ python/branches/py3k/Objects/rangeobject.c Thu Dec 20 23:57:23 2007 @@ -558,14 +558,23 @@ rangeobject *r = (rangeobject *)seq; longrangeiterobject *it; PyObject *tmp, *len; + long lstart, lstop, lstep; assert(PyRange_Check(seq)); - if (_PyLong_FitsInLong(r->start) && - _PyLong_FitsInLong(r->stop) && - _PyLong_FitsInLong(r->step)) - return int_range_iter(PyLong_AsLong(r->start), - PyLong_AsLong(r->stop), - PyLong_AsLong(r->step)); + + /* If all three fields convert to long, use the int version */ + lstart = PyLong_AsLong(r->start); + if (lstart != -1 || !PyErr_Occurred()) { + lstop = PyLong_AsLong(r->stop); + if (lstop != -1 || !PyErr_Occurred()) { + lstep = PyLong_AsLong(r->step); + if (lstep != -1 || !PyErr_Occurred()) + return int_range_iter(lstart, lstop, lstep); + } + } + /* Some conversion failed, so there is an error set. Clear it, + and try again with a long range. */ + PyErr_Clear(); it = PyObject_New(longrangeiterobject, &PyLongRangeIter_Type); if (it == NULL) @@ -605,27 +614,33 @@ rangeobject *range = (rangeobject*) seq; longrangeiterobject *it; PyObject *one, *sum, *diff, *len = NULL, *product; + long lstart, lstop, lstep; /* XXX(nnorwitz): do the calc for the new start/stop first, then if they fit, call the proper iter()? */ assert(PyRange_Check(seq)); - if (_PyLong_FitsInLong(range->start) && - _PyLong_FitsInLong(range->stop) && - _PyLong_FitsInLong(range->step)) { - long start = PyLong_AsLong(range->start); - long step = PyLong_AsLong(range->step); - long stop = PyLong_AsLong(range->stop); - /* XXX(nnorwitz): need to check for overflow and simplify. */ - long len = get_len_of_range(start, stop, step); - long new_start = start + (len - 1) * step; - long new_stop = start; - if (step > 0) - new_stop -= 1; - else - new_stop += 1; - return int_range_iter(new_start, new_stop, -step); + + /* If all three fields convert to long, use the int version */ + lstart = PyLong_AsLong(range->start); + if (lstart != -1 || !PyErr_Occurred()) { + lstop = PyLong_AsLong(range->stop); + if (lstop != -1 || !PyErr_Occurred()) { + lstep = PyLong_AsLong(range->step); + if (lstep != -1 || !PyErr_Occurred()) { + /* XXX(nnorwitz): need to check for overflow and simplify. */ + long len = get_len_of_range(lstart, lstop, lstep); + long new_start = lstart + (len - 1) * lstep; + long new_stop = lstart; + if (lstep > 0) + new_stop -= 1; + else + new_stop += 1; + return int_range_iter(new_start, new_stop, -lstep); + } + } } + PyErr_Clear(); it = PyObject_New(longrangeiterobject, &PyLongRangeIter_Type); if (it == NULL) From python-3000-checkins at python.org Fri Dec 21 08:31:17 2007 From: python-3000-checkins at python.org (nick.coghlan) Date: Fri, 21 Dec 2007 08:31:17 +0100 (CET) Subject: [Python-3000-checkins] r59587 - python/branches/py3k/Python/sysmodule.c Message-ID: <20071221073118.0157B1E400E@bag.python.org> Author: nick.coghlan Date: Fri Dec 21 08:31:17 2007 New Revision: 59587 Modified: python/branches/py3k/Python/sysmodule.c Log: Fix thoroughly misleading comment Modified: python/branches/py3k/Python/sysmodule.c ============================================================================== --- python/branches/py3k/Python/sysmodule.c (original) +++ python/branches/py3k/Python/sysmodule.c Fri Dec 21 08:31:17 2007 @@ -1025,7 +1025,7 @@ } } - /* stdin/stdout/stderr are now set by site.py. */ + /* stdin/stdout/stderr are now set by pythonrun.c */ PyDict_SetItemString(sysdict, "__displayhook__", PyDict_GetItemString(sysdict, "displayhook")); From python-3000-checkins at python.org Fri Dec 21 09:15:02 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 21 Dec 2007 09:15:02 +0100 (CET) Subject: [Python-3000-checkins] r59588 - python/branches/py3k/Doc/c-api/concrete.rst Message-ID: <20071221081502.AD8601E400E@bag.python.org> Author: georg.brandl Date: Fri Dec 21 09:15:02 2007 New Revision: 59588 Modified: python/branches/py3k/Doc/c-api/concrete.rst Log: Fix role usage. Modified: python/branches/py3k/Doc/c-api/concrete.rst ============================================================================== --- python/branches/py3k/Doc/c-api/concrete.rst (original) +++ python/branches/py3k/Doc/c-api/concrete.rst Fri Dec 21 09:15:02 2007 @@ -2531,7 +2531,7 @@ An instance method is a wrapper for a :cdata:`PyCFunction` and the new way to bind a :cdata:`PyCFunction` to a class object. It replaces the former call -:cfunc:`PyMethod_New(func, NULL, class)`. +``PyMethod_New(func, NULL, class)``. .. cvar:: PyTypeObject PyInstanceMethod_Type From python-3000-checkins at python.org Fri Dec 21 09:16:55 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 21 Dec 2007 09:16:55 +0100 (CET) Subject: [Python-3000-checkins] r59589 - python/branches/py3k/Lib/types.py Message-ID: <20071221081655.4DE2E1E4027@bag.python.org> Author: georg.brandl Date: Fri Dec 21 09:16:54 2007 New Revision: 59589 Modified: python/branches/py3k/Lib/types.py Log: Fix docstring of types.py. Modified: python/branches/py3k/Lib/types.py ============================================================================== --- python/branches/py3k/Lib/types.py (original) +++ python/branches/py3k/Lib/types.py Fri Dec 21 09:16:54 2007 @@ -1,6 +1,5 @@ -"""Define names for all type symbols known in the standard interpreter. - -Types that are part of optional modules (e.g. array) are not listed. +""" +Define names for built-in types that aren't directly accessible as a builtin. """ import sys From python-3000-checkins at python.org Fri Dec 21 09:45:43 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Fri, 21 Dec 2007 09:45:43 +0100 (CET) Subject: [Python-3000-checkins] r59590 - python/branches/py3k/Doc/library/os.rst Message-ID: <20071221084543.15A4A1E4354@bag.python.org> Author: georg.brandl Date: Fri Dec 21 09:45:42 2007 New Revision: 59590 Modified: python/branches/py3k/Doc/library/os.rst Log: Document os.device_encoding. Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Fri Dec 21 09:45:42 2007 @@ -401,6 +401,12 @@ :func:`fdopen`, use its :meth:`close` method. +.. function:: device_encoding(fd) + + Return a string describing the encoding of the device associated with *fd* + if it is connected to a terminal; else return :const:`None`. + + .. function:: dup(fd) Return a duplicate of file descriptor *fd*. Availability: Macintosh, Unix, From python-3000-checkins at python.org Mon Dec 24 09:52:32 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 24 Dec 2007 09:52:32 +0100 (CET) Subject: [Python-3000-checkins] r59595 - in python/branches/py3k: Doc/c-api/exceptions.rst Doc/library/signal.rst Doc/whatsnew/2.6.rst Include/pyerrors.h Lib/decimal.py Lib/re.py Lib/test/test_re.py Lib/test/test_richcmp.py Lib/test/test_signal.py Lib/test/test_subprocess.py Lib/test/test_warnings.py Modules/signalmodule.c Python/bltinmodule.c Python/compile.c Message-ID: <20071224085232.F3DB61E4007@bag.python.org> Author: christian.heimes Date: Mon Dec 24 09:52:31 2007 New Revision: 59595 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/c-api/exceptions.rst python/branches/py3k/Doc/library/signal.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Include/pyerrors.h python/branches/py3k/Lib/decimal.py python/branches/py3k/Lib/re.py python/branches/py3k/Lib/test/test_re.py python/branches/py3k/Lib/test/test_richcmp.py python/branches/py3k/Lib/test/test_signal.py python/branches/py3k/Lib/test/test_subprocess.py python/branches/py3k/Lib/test/test_warnings.py python/branches/py3k/Modules/signalmodule.c python/branches/py3k/Python/bltinmodule.c python/branches/py3k/Python/compile.c Log: Merged revisions 59565-59594 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59568 | facundo.batista | 2007-12-19 13:53:01 +0100 (Wed, 19 Dec 2007) | 3 lines Some minor cleanups. Thanks Mark Dickinson. ........ r59573 | raymond.hettinger | 2007-12-19 19:13:31 +0100 (Wed, 19 Dec 2007) | 1 line Fix issue 1661: Flags argument silently ignored in re functions with compiled regexes. ........ r59574 | guido.van.rossum | 2007-12-19 20:41:06 +0100 (Wed, 19 Dec 2007) | 7 lines Patch #1583 by Adam Olsen. This adds signal.set_wakeup_fd(fd) which sets a file descriptor to which a zero byte will be written whenever a C exception handler runs. I added a simple C API as well, PySignal_SetWakeupFd(fd). ........ r59575 | raymond.hettinger | 2007-12-19 23:14:34 +0100 (Wed, 19 Dec 2007) | 1 line Bigger range for non-extended opargs. ........ r59576 | guido.van.rossum | 2007-12-19 23:51:13 +0100 (Wed, 19 Dec 2007) | 5 lines Patch #1549 by Thomas Herve. This changes the rules for when __hash__ is inherited slightly, by allowing it to be inherited when one or more of __lt__, __le__, __gt__, __ge__ are overridden, as long as __eq__ and __ne__ aren't. ........ r59577 | raymond.hettinger | 2007-12-20 02:25:05 +0100 (Thu, 20 Dec 2007) | 1 line Add comments ........ r59578 | brett.cannon | 2007-12-20 11:09:52 +0100 (Thu, 20 Dec 2007) | 3 lines Add tests for the warnings module; specifically formatwarning and showwarning. Still need tests for warn_explicit and simplefilter. ........ r59582 | guido.van.rossum | 2007-12-20 18:28:10 +0100 (Thu, 20 Dec 2007) | 2 lines Patch #1672 by Joseph Armbruster. Use tempdir() to get a temporary directory. ........ r59584 | georg.brandl | 2007-12-20 22:03:02 +0100 (Thu, 20 Dec 2007) | 2 lines Fix refleak introduced in r59576. ........ r59586 | guido.van.rossum | 2007-12-21 00:48:28 +0100 (Fri, 21 Dec 2007) | 4 lines Improve performance of built-in any()/all() by avoiding PyIter_Next() -- using a trick found in ifilter(). Feel free to backport to 2.5. ........ r59591 | andrew.kuchling | 2007-12-22 18:27:02 +0100 (Sat, 22 Dec 2007) | 1 line Add item ........ Modified: python/branches/py3k/Doc/c-api/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/c-api/exceptions.rst (original) +++ python/branches/py3k/Doc/c-api/exceptions.rst Mon Dec 24 09:52:31 2007 @@ -355,6 +355,16 @@ .. % thread.interrupt_main() (used from IDLE), so it's still needed. +.. cfunction:: int PySignal_SetWakeupFd(int fd) + + This utility function specifies a file descriptor to which a ``'\0'`` byte will + be written whenever a signal is received. It returns the previous such file + descriptor. The value ``-1`` disables the feature; this is the initial state. + This is equivalent to :func:`signal.set_wakeup_fd` in Python, but without any + error checking. *fd* should be a valid file descriptor. The function should + only be called from the main thread. + + .. cfunction:: PyObject* PyErr_NewException(char *name, PyObject *base, PyObject *dict) This utility function creates and returns a new exception object. The *name* Modified: python/branches/py3k/Doc/library/signal.rst ============================================================================== --- python/branches/py3k/Doc/library/signal.rst (original) +++ python/branches/py3k/Doc/library/signal.rst Mon Dec 24 09:52:31 2007 @@ -110,6 +110,20 @@ :manpage:`signal(2)`.) +.. function:: set_wakeup_fd(fd) + + Set the wakeup fd to *fd*. When a signal is received, a ``'\0'`` byte is + written to the fd. This can be used by a library to wakeup a poll or select + call, allowing the signal to be fully processed. + + The old wakeup fd is returned. *fd* must be non-blocking. It is up to the + library to remove any bytes before calling poll or select again. + + When threads are enabled, this function can only be called from the main thread; + attempting to call it from other threads will cause a :exc:`ValueError` + exception to be raised. + + .. function:: signal(signalnum, handler) Set the handler for signal *signalnum* to the function *handler*. *handler* can Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Mon Dec 24 09:52:31 2007 @@ -147,15 +147,16 @@ The input format is reStructured Text, a markup commonly used in the Python community that supports custom extensions and directives. Sphinx concentrates -on its HTML output, producing attractively styled -and modern HTML. (XXX finish this -- mention new search feature) +on HTML output, producing attractively styled +and modern HTML, but printed output is still supported through +conversion to LaTeX as an output format. .. seealso:: `Docutils `__: The fundamental reStructured Text parser and toolset. - `Documenting Python `__: Describes how to write for + `Documenting Python `__: Describes how to write for Python's documentation. @@ -839,6 +840,27 @@ * The :mod:`sets` module has been deprecated; it's better to use the built-in :class:`set` and :class:`frozenset` types. +* Integrating signal handling with GUI handling event loops + like those used by Tkinter or GTk+ has long been a problem; most + software ends up polling, waking up every fraction of a second. Thi + The :mod:`signal` module can now make this more efficient. + Calling ``signal.set_wakeup_fd(fd)`` sets a file descriptor + to be used; when a signal is received, a byte is written to that + file descriptor. There's also a C-level function, + :cfunc:`PySignal_SetWakeupFd`, for setting the descriptor. + + Event loops will use this by opening a pipe to create two descriptors, + one for reading and one for writing. The writeable descriptor + will be passed to :func:`set_wakeup_fd`, and the readable descriptor + will be added to the list of descriptors monitored by the event loop via + :cfunc:`select` or :cfunc:`poll`. + On receiving a signal, a byte will be written and the main event loop + will be woken up, without the need to poll. + + Contributed by Adam Olsen. + + .. % Patch 1583 + * The :mod:`smtplib` module now supports SMTP over SSL thanks to the addition of the :class:`SMTP_SSL` class. This class supports an interface identical to the existing :class:`SMTP` class. Both Modified: python/branches/py3k/Include/pyerrors.h ============================================================================== --- python/branches/py3k/Include/pyerrors.h (original) +++ python/branches/py3k/Include/pyerrors.h Mon Dec 24 09:52:31 2007 @@ -227,6 +227,9 @@ PyAPI_FUNC(int) PyErr_CheckSignals(void); PyAPI_FUNC(void) PyErr_SetInterrupt(void); +/* In signalmodule.c */ +int PySignal_SetWakeupFd(int fd); + /* Support for adding program text to SyntaxErrors */ PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int); PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int); Modified: python/branches/py3k/Lib/decimal.py ============================================================================== --- python/branches/py3k/Lib/decimal.py (original) +++ python/branches/py3k/Lib/decimal.py Mon Dec 24 09:52:31 2007 @@ -184,7 +184,6 @@ number of zero digits are appended to the coefficient ("fold-down"). """ - class InvalidOperation(DecimalException): """An invalid operation was performed. @@ -210,14 +209,10 @@ """ def handle(self, context, *args): if args: - if args[0] == 1: # sNaN, must drop 's' but keep diagnostics - ans = _dec_from_triple(args[1]._sign, args[1]._int, 'n', True) - return ans._fix_nan(context) - elif args[0] == 2: - return _dec_from_triple(args[1], args[2], 'n', True) + ans = _dec_from_triple(args[0]._sign, args[0]._int, 'n', True) + return ans._fix_nan(context) return NaN - class ConversionSyntax(InvalidOperation): """Trying to convert badly formed string. @@ -277,7 +272,6 @@ The inexact signal may be tested (or trapped) to determine if a given operation (or sequence of operations) was inexact. """ - pass class InvalidContext(InvalidOperation): """Invalid context. Unknown rounding, for example. @@ -304,7 +298,6 @@ The rounded signal may be tested (or trapped) to determine if a given operation (or sequence of operations) caused a loss of precision. """ - pass class Subnormal(DecimalException): """Exponent < Emin before rounding. @@ -316,7 +309,6 @@ The subnormal signal may be tested (or trapped) to determine if a given or operation (or sequence of operations) yielded a subnormal result. """ - pass class Overflow(Inexact, Rounded): """Numerical overflow. @@ -338,7 +330,7 @@ the result is the same as for round-down if the sign of the intermediate result is 0, or is [1,inf] otherwise. In all cases, Inexact and Rounded will also be raised. - """ + """ def handle(self, context, sign, *args): if context.rounding in (ROUND_HALF_UP, ROUND_HALF_EVEN, @@ -662,7 +654,7 @@ """Returns whether the number is not actually one. 0 if a number - 1 if NaN (it could be a normal quiet NaN or a phantom one) + 1 if NaN 2 if sNaN """ if self._is_special: @@ -708,10 +700,10 @@ if self_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, self) + self) if other_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, other) + other) if self_is_nan: return self._fix_nan(context) @@ -922,7 +914,7 @@ if not self: # -Decimal('0') is Decimal('0'), not Decimal('-0') - ans = self.copy_sign(Dec_0) + ans = self.copy_abs() else: ans = self.copy_negate() @@ -942,7 +934,7 @@ if not self: # + (-0) = 0 - ans = self.copy_sign(Dec_0) + ans = self.copy_abs() else: ans = Decimal(self) @@ -1465,9 +1457,6 @@ context - context used. """ - if context is None: - context = getcontext() - if self._is_special: if self._isnan(): # decapitate payload if necessary @@ -1631,11 +1620,9 @@ if context is None: context = getcontext() if self._exp == 'N': - return context._raise_error(InvalidOperation, 'sNaN', - 1, self) + return context._raise_error(InvalidOperation, 'sNaN', self) if other._exp == 'N': - return context._raise_error(InvalidOperation, 'sNaN', - 1, other) + return context._raise_error(InvalidOperation, 'sNaN', other) if self._exp == 'n': product = self elif other._exp == 'n': @@ -1678,13 +1665,13 @@ if self_is_nan or other_is_nan or modulo_is_nan: if self_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, self) + self) if other_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, other) + other) if modulo_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, modulo) + modulo) if self_is_nan: return self._fix_nan(context) if other_is_nan: @@ -2555,16 +2542,16 @@ other_is_nan = other._isnan() if self_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, self) + self) if other_is_nan == 2: return context._raise_error(InvalidOperation, 'sNaN', - 1, other) + other) if self_is_nan: return context._raise_error(InvalidOperation, 'NaN in compare_signal', - 1, self) + self) if other_is_nan: return context._raise_error(InvalidOperation, 'NaN in compare_signal', - 1, other) + other) return self.compare(other, context=context) def compare_total(self, other): @@ -3208,8 +3195,8 @@ """Returns an indication of the class of self. The class is one of the following strings: - -sNaN - -NaN + sNaN + NaN -Infinity -Normal -Subnormal @@ -5173,8 +5160,6 @@ Dec_0 = Decimal(0) Dec_p1 = Decimal(1) Dec_n1 = Decimal(-1) -Dec_p2 = Decimal(2) -Dec_n2 = Decimal(-2) # Infsign[sign] is infinity w/ that sign Infsign = (Inf, negInf) Modified: python/branches/py3k/Lib/re.py ============================================================================== --- python/branches/py3k/Lib/re.py (original) +++ python/branches/py3k/Lib/re.py Mon Dec 24 09:52:31 2007 @@ -224,6 +224,8 @@ return p pattern, flags = key if isinstance(pattern, _pattern_type): + if flags: + raise ValueError('Cannot process flags argument with a compiled pattern') return pattern if not sre_compile.isstring(pattern): raise TypeError("first argument must be string or compiled pattern") Modified: python/branches/py3k/Lib/test/test_re.py ============================================================================== --- python/branches/py3k/Lib/test/test_re.py (original) +++ python/branches/py3k/Lib/test/test_re.py Mon Dec 24 09:52:31 2007 @@ -111,6 +111,14 @@ # self.assertEqual(z, y) # self.assertEqual(type(z), type(y)) + def test_bug_1661(self): + # Verify that flags do not get silently ignored with compiled patterns + pattern = re.compile('.') + self.assertRaises(ValueError, re.match, pattern, 'A', re.I) + self.assertRaises(ValueError, re.search, pattern, 'A', re.I) + self.assertRaises(ValueError, re.findall, pattern, 'A', re.I) + self.assertRaises(ValueError, re.compile, pattern, re.I) + def test_sub_template_numeric_escape(self): # bug 776311 and friends self.assertEqual(re.sub('x', r'\0', 'x'), '\0') Modified: python/branches/py3k/Lib/test/test_richcmp.py ============================================================================== --- python/branches/py3k/Lib/test/test_richcmp.py (original) +++ python/branches/py3k/Lib/test/test_richcmp.py Mon Dec 24 09:52:31 2007 @@ -85,6 +85,35 @@ raise ValueError("Cannot compare vectors of different length") return other + +class SimpleOrder(object): + """ + A simple class that defines order but not full comparison. + """ + + def __init__(self, value): + self.value = value + + def __lt__(self, other): + if not isinstance(other, SimpleOrder): + return True + return self.value < other.value + + def __gt__(self, other): + if not isinstance(other, SimpleOrder): + return False + return self.value > other.value + + +class DumbEqualityWithoutHash(object): + """ + A class that define __eq__, but no __hash__: it shouldn't be hashable. + """ + + def __eq__(self, other): + return False + + opmap = { "lt": (lambda a,b: a< b, operator.lt, operator.__lt__), "le": (lambda a,b: a<=b, operator.le, operator.__le__), @@ -330,8 +359,39 @@ for op in opmap["lt"]: self.assertIs(op(x, y), True) + +class HashableTest(unittest.TestCase): + """ + Test hashability of classes with rich operators defined. + """ + + def test_simpleOrderHashable(self): + """ + A class that only defines __gt__ and/or __lt__ should be hashable. + """ + a = SimpleOrder(1) + b = SimpleOrder(2) + self.assert_(a < b) + self.assert_(b > a) + self.assert_(a.__hash__ is not None) + + def test_notHashableException(self): + """ + If a class is not hashable, it should raise a TypeError with an + understandable message. + """ + a = DumbEqualityWithoutHash() + try: + hash(a) + except TypeError as e: + self.assertEquals(str(e), + "unhashable type: 'DumbEqualityWithoutHash'") + else: + raise test_support.TestFailed("Should not be here") + + def test_main(): - test_support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest) + test_support.run_unittest(VectorTest, NumberTest, MiscTest, DictTest, ListTest, HashableTest) if __name__ == "__main__": test_main() Modified: python/branches/py3k/Lib/test/test_signal.py ============================================================================== --- python/branches/py3k/Lib/test/test_signal.py (original) +++ python/branches/py3k/Lib/test/test_signal.py Mon Dec 24 09:52:31 2007 @@ -166,12 +166,59 @@ self.assertRaises(TypeError, signal.signal, signal.SIGUSR1, None) +class WakeupSignalTests(unittest.TestCase): + TIMEOUT_FULL = 10 + TIMEOUT_HALF = 5 + + def test_wakeup_fd_early(self): + import select + + signal.alarm(1) + before_time = time.time() + # We attempt to get a signal during the sleep, + # before select is called + time.sleep(self.TIMEOUT_FULL) + mid_time = time.time() + self.assert_(mid_time - before_time < self.TIMEOUT_HALF) + select.select([self.read], [], [], self.TIMEOUT_FULL) + after_time = time.time() + self.assert_(after_time - mid_time < self.TIMEOUT_HALF) + + def test_wakeup_fd_during(self): + import select + + signal.alarm(1) + before_time = time.time() + # We attempt to get a signal during the select call + self.assertRaises(select.error, select.select, + [self.read], [], [], self.TIMEOUT_FULL) + after_time = time.time() + self.assert_(after_time - before_time < self.TIMEOUT_HALF) + + def setUp(self): + import fcntl + + self.alrm = signal.signal(signal.SIGALRM, lambda x,y:None) + self.read, self.write = os.pipe() + flags = fcntl.fcntl(self.write, fcntl.F_GETFL, 0) + flags = flags | os.O_NONBLOCK + fcntl.fcntl(self.write, fcntl.F_SETFL, flags) + self.old_wakeup = signal.set_wakeup_fd(self.write) + + def tearDown(self): + signal.set_wakeup_fd(self.old_wakeup) + os.close(self.read) + os.close(self.write) + signal.signal(signal.SIGALRM, self.alrm) + + def test_main(): if sys.platform[:3] in ('win', 'os2'): raise test_support.TestSkipped("Can't test signal on %s" % \ sys.platform) - test_support.run_unittest(BasicSignalTests, InterProcessSignalTests) + test_support.run_unittest(BasicSignalTests, InterProcessSignalTests, + WakeupSignalTests) if __name__ == "__main__": Modified: python/branches/py3k/Lib/test/test_subprocess.py ============================================================================== --- python/branches/py3k/Lib/test/test_subprocess.py (original) +++ python/branches/py3k/Lib/test/test_subprocess.py Mon Dec 24 09:52:31 2007 @@ -242,7 +242,7 @@ self.assertEquals(rc, 2) def test_cwd(self): - tmpdir = os.getenv("TEMP", "/tmp") + tmpdir = tempfile.gettempdir() # We cannot use os.path.realpath to canonicalize the path, # since it doesn't expand Tru64 {memb} strings. See bug 1063571. cwd = os.getcwd() Modified: python/branches/py3k/Lib/test/test_warnings.py ============================================================================== --- python/branches/py3k/Lib/test/test_warnings.py (original) +++ python/branches/py3k/Lib/test/test_warnings.py Mon Dec 24 09:52:31 2007 @@ -1,5 +1,7 @@ import warnings +import linecache import os +from io import StringIO import sys import unittest from test import test_support @@ -36,6 +38,8 @@ self.assert_(w.category is category) def test_filtering(self): + # Test filterwarnings(). + # Implicitly also tests resetwarnings(). with test_support.catch_warning() as w: warnings.filterwarnings("error", "", Warning, "", 0) self.assertRaises(UserWarning, warnings.warn, 'convert to error') @@ -97,6 +101,33 @@ self.assertEqual(os.path.basename(w.filename), "sys") +class WarningsDisplayTests(unittest.TestCase): + + def test_formatwarning(self): + message = "msg" + category = Warning + file_name = os.path.splitext(warning_tests.__file__)[0] + '.py' + line_num = 3 + file_line = linecache.getline(file_name, line_num).strip() + expect = "%s:%s: %s: %s\n %s\n" % (file_name, line_num, category.__name__, + message, file_line) + self.failUnlessEqual(warnings.formatwarning(message, category, + file_name, line_num), + expect) + + def test_showwarning(self): + file_name = os.path.splitext(warning_tests.__file__)[0] + '.py' + line_num = 3 + expected_file_line = linecache.getline(file_name, line_num).strip() + message = 'msg' + category = Warning + file_object = StringIO() + expect = warnings.formatwarning(message, category, file_name, line_num) + warnings.showwarning(message, category, file_name, line_num, + file_object) + self.failUnlessEqual(file_object.getvalue(), expect) + + def test_main(verbose=None): # Obscure hack so that this test passes after reloads or repeated calls # to test_main (regrtest -R). @@ -106,7 +137,7 @@ del warning_tests.__warningregistry__ if hasattr(sys, '__warningregistry__'): del sys.__warningregistry__ - test_support.run_unittest(TestModule) + test_support.run_unittest(TestModule, WarningsDisplayTests) if __name__ == "__main__": test_main(verbose=True) Modified: python/branches/py3k/Modules/signalmodule.c ============================================================================== --- python/branches/py3k/Modules/signalmodule.c (original) +++ python/branches/py3k/Modules/signalmodule.c Mon Dec 24 09:52:31 2007 @@ -12,6 +12,8 @@ #include +#include + #ifndef SIG_ERR #define SIG_ERR ((PyOS_sighandler_t)(-1)) #endif @@ -75,6 +77,8 @@ PyObject *func; } Handlers[NSIG]; +static sig_atomic_t wakeup_fd = -1; + /* Speed up sigcheck() when none tripped */ static volatile sig_atomic_t is_tripped = 0; @@ -128,6 +132,8 @@ cleared in PyErr_CheckSignals() before .tripped. */ is_tripped = 1; Py_AddPendingCall(checksignals_witharg, NULL); + if (wakeup_fd != -1) + write(wakeup_fd, "\0", 1); #ifdef WITH_THREAD } #endif @@ -267,6 +273,50 @@ anything else -- the callable Python object used as a handler"); +static PyObject * +signal_set_wakeup_fd(PyObject *self, PyObject *args) +{ + struct stat buf; + int fd, old_fd; + if (!PyArg_ParseTuple(args, "i:set_wakeup_fd", &fd)) + return NULL; +#ifdef WITH_THREAD + if (PyThread_get_thread_ident() != main_thread) { + PyErr_SetString(PyExc_ValueError, + "set_wakeup_fd only works in main thread"); + return NULL; + } +#endif + if (fd != -1 && fstat(fd, &buf) != 0) { + PyErr_SetString(PyExc_ValueError, "invalid fd"); + return NULL; + } + old_fd = wakeup_fd; + wakeup_fd = fd; + return PyLong_FromLong(old_fd); +} + +PyDoc_STRVAR(set_wakeup_fd_doc, +"set_wakeup_fd(fd) -> fd\n\ +\n\ +Sets the fd to be written to (with '\\0') when a signal\n\ +comes in. A library can use this to wakeup select or poll.\n\ +The previous fd is returned.\n\ +\n\ +The fd must be non-blocking."); + +/* C API for the same, without all the error checking */ +int +PySignal_SetWakeupFd(int fd) +{ + int old_fd = wakeup_fd; + if (fd < 0) + fd = -1; + wakeup_fd = fd; + return old_fd; +} + + /* List of functions defined in the module */ static PyMethodDef signal_methods[] = { #ifdef HAVE_ALARM @@ -274,11 +324,12 @@ #endif {"signal", signal_signal, METH_VARARGS, signal_doc}, {"getsignal", signal_getsignal, METH_VARARGS, getsignal_doc}, + {"set_wakeup_fd", signal_set_wakeup_fd, METH_VARARGS, set_wakeup_fd_doc}, #ifdef HAVE_PAUSE {"pause", (PyCFunction)signal_pause, METH_NOARGS,pause_doc}, #endif - {"default_int_handler", signal_default_int_handler, + {"default_int_handler", signal_default_int_handler, METH_VARARGS, default_int_handler_doc}, {NULL, NULL} /* sentinel */ }; Modified: python/branches/py3k/Python/bltinmodule.c ============================================================================== --- python/branches/py3k/Python/bltinmodule.c (original) +++ python/branches/py3k/Python/bltinmodule.c Mon Dec 24 09:52:31 2007 @@ -184,13 +184,19 @@ builtin_all(PyObject *self, PyObject *v) { PyObject *it, *item; + PyObject *(*iternext)(PyObject *); + int cmp; it = PyObject_GetIter(v); if (it == NULL) return NULL; + iternext = *Py_TYPE(it)->tp_iternext; - while ((item = PyIter_Next(it)) != NULL) { - int cmp = PyObject_IsTrue(item); + for (;;) { + item = iternext(it); + if (item == NULL) + break; + cmp = PyObject_IsTrue(item); Py_DECREF(item); if (cmp < 0) { Py_DECREF(it); @@ -202,8 +208,12 @@ } } Py_DECREF(it); - if (PyErr_Occurred()) - return NULL; + if (PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_StopIteration)) + PyErr_Clear(); + else + return NULL; + } Py_RETURN_TRUE; } @@ -216,13 +226,19 @@ builtin_any(PyObject *self, PyObject *v) { PyObject *it, *item; + PyObject *(*iternext)(PyObject *); + int cmp; it = PyObject_GetIter(v); if (it == NULL) return NULL; + iternext = *Py_TYPE(it)->tp_iternext; - while ((item = PyIter_Next(it)) != NULL) { - int cmp = PyObject_IsTrue(item); + for (;;) { + item = iternext(it); + if (item == NULL) + break; + cmp = PyObject_IsTrue(item); Py_DECREF(item); if (cmp < 0) { Py_DECREF(it); @@ -234,8 +250,12 @@ } } Py_DECREF(it); - if (PyErr_Occurred()) - return NULL; + if (PyErr_Occurred()) { + if (PyErr_ExceptionMatches(PyExc_StopIteration)) + PyErr_Clear(); + else + return NULL; + } Py_RETURN_FALSE; } Modified: python/branches/py3k/Python/compile.c ============================================================================== --- python/branches/py3k/Python/compile.c (original) +++ python/branches/py3k/Python/compile.c Mon Dec 24 09:52:31 2007 @@ -3172,7 +3172,7 @@ return compiler_ifexp(c, e); case Dict_kind: n = asdl_seq_LEN(e->v.Dict.values); - ADDOP_I(c, BUILD_MAP, (n>255 ? 255 : n)); + ADDOP_I(c, BUILD_MAP, (n>0xFFFF ? 0xFFFF : n)); for (i = 0; i < n; i++) { VISIT(c, expr, (expr_ty)asdl_seq_GET(e->v.Dict.values, i)); @@ -3648,10 +3648,10 @@ instrsize(struct instr *instr) { if (!instr->i_hasarg) - return 1; + return 1; /* 1 byte for the opcode*/ if (instr->i_oparg > 0xffff) - return 6; - return 3; + return 6; /* 1 (opcode) + 1 (EXTENDED_ARG opcode) + 2 (oparg) + 2(oparg extended) */ + return 3; /* 1 (opcode) + 2 (oparg) */ } static int From python-3000-checkins at python.org Fri Dec 28 02:24:23 2007 From: python-3000-checkins at python.org (alexandre.vassalotti) Date: Fri, 28 Dec 2007 02:24:23 +0100 (CET) Subject: [Python-3000-checkins] r59602 - python/branches/py3k/Lib/io.py Message-ID: <20071228012423.0FEE31E4015@bag.python.org> Author: alexandre.vassalotti Date: Fri Dec 28 02:24:22 2007 New Revision: 59602 Modified: python/branches/py3k/Lib/io.py Log: Fix the reset() method of IncrementalNewlineDecoder to also reset self.seennl. Modified: python/branches/py3k/Lib/io.py ============================================================================== --- python/branches/py3k/Lib/io.py (original) +++ python/branches/py3k/Lib/io.py Fri Dec 28 02:24:22 2007 @@ -1116,6 +1116,7 @@ self.decoder.setstate((buf, flag)) def reset(self): + self.seennl = 0 self.buffer = b'' self.decoder.reset() From python-3000-checkins at python.org Fri Dec 28 04:57:56 2007 From: python-3000-checkins at python.org (kurt.kaiser) Date: Fri, 28 Dec 2007 04:57:56 +0100 (CET) Subject: [Python-3000-checkins] r59603 - python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/PyShell.py python/branches/py3k/Lib/idlelib/run.py Message-ID: <20071228035756.6DCA01E4015@bag.python.org> Author: kurt.kaiser Date: Fri Dec 28 04:57:56 2007 New Revision: 59603 Modified: python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/PyShell.py python/branches/py3k/Lib/idlelib/run.py Log: help() was not paging to the shell. Issue1650. Modified: python/branches/py3k/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/py3k/Lib/idlelib/NEWS.txt (original) +++ python/branches/py3k/Lib/idlelib/NEWS.txt Fri Dec 28 04:57:56 2007 @@ -1,7 +1,9 @@ What's New in IDLE 3.0a3? ========================= -*Release date: XX-XXX-200X* +*Release date: XX-XXX-2008* + +- help() was not paging to the shell. Issue1650. - CodeContext was not importing. Modified: python/branches/py3k/Lib/idlelib/PyShell.py ============================================================================== --- python/branches/py3k/Lib/idlelib/PyShell.py (original) +++ python/branches/py3k/Lib/idlelib/PyShell.py Fri Dec 28 04:57:56 2007 @@ -828,6 +828,14 @@ sys.stdout = self.stdout sys.stderr = self.stderr sys.stdin = self + try: + # page help() text to shell. + import pydoc # import must be done here to capture i/o rebinding. + # XXX KBK 27Dec07 use a textView someday, but must work w/o subproc + pydoc.pager = pydoc.plainpager + except: + sys.stderr = sys.__stderr__ + raise # self.history = self.History(self.text) # Modified: python/branches/py3k/Lib/idlelib/run.py ============================================================================== --- python/branches/py3k/Lib/idlelib/run.py (original) +++ python/branches/py3k/Lib/idlelib/run.py Fri Dec 28 04:57:56 2007 @@ -247,6 +247,9 @@ sys.stdin = self.console = self.get_remote_proxy("stdin") sys.stdout = self.get_remote_proxy("stdout") sys.stderr = self.get_remote_proxy("stderr") + # page help() text to shell. + import pydoc # import must be done here to capture i/o binding + pydoc.pager = pydoc.plainpager from idlelib import IOBinding sys.stdin.encoding = sys.stdout.encoding = \ sys.stderr.encoding = IOBinding.encoding From python-3000-checkins at python.org Fri Dec 28 15:08:14 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Fri, 28 Dec 2007 15:08:14 +0100 (CET) Subject: [Python-3000-checkins] r59605 - in python/branches/py3k: Lib/idlelib/NEWS.txt Lib/idlelib/configDialog.py Lib/test/test_descr.py Misc/Vim/vimrc Modules/timemodule.c Message-ID: <20071228140814.6EE861E4015@bag.python.org> Author: christian.heimes Date: Fri Dec 28 15:08:13 2007 New Revision: 59605 Modified: python/branches/py3k/ (props changed) python/branches/py3k/Lib/idlelib/NEWS.txt python/branches/py3k/Lib/idlelib/configDialog.py python/branches/py3k/Lib/test/test_descr.py python/branches/py3k/Misc/Vim/vimrc python/branches/py3k/Modules/timemodule.c Log: Merged revisions 59595-59604 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59596 | brett.cannon | 2007-12-24 20:58:25 +0100 (Mon, 24 Dec 2007) | 4 lines Fix the docstrings of time.localtime() and gmtime() for the tm_mday field. Will backport. ........ r59598 | brett.cannon | 2007-12-25 00:43:30 +0100 (Tue, 25 Dec 2007) | 3 lines Make trailing whitespace explicit (including when it is an all-whitespace line). ........ r59599 | brett.cannon | 2007-12-25 01:14:34 +0100 (Tue, 25 Dec 2007) | 7 lines Actually execute the tests for the getter/setter/deleter tests on properties. Also fix the test by having the test classes inherit from object. Are the getter/setter/deleter attributes supposed to be able to chain? As of right now they can't as the property tries to call what the property returns, which is another property when they are chained. ........ r59600 | brett.cannon | 2007-12-25 07:44:59 +0100 (Tue, 25 Dec 2007) | 2 lines Remove a straggling debugging print line. ........ r59604 | kurt.kaiser | 2007-12-28 05:18:01 +0100 (Fri, 28 Dec 2007) | 2 lines Configure Dialog: improved layout for keybinding. Patch 1457 Tal Einat. ........ Modified: python/branches/py3k/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/py3k/Lib/idlelib/NEWS.txt (original) +++ python/branches/py3k/Lib/idlelib/NEWS.txt Fri Dec 28 15:08:13 2007 @@ -45,6 +45,8 @@ *Release date: XX-XXX-200X* UNRELEASED, but merged into 3.0 +- Configure Dialog: improved layout for keybinding. Patch 1457 Tal Einat. + - tabpage.py updated: tabbedPages.py now supports multiple dynamic rows of tabs. Patch 1612746 Tal Einat. Modified: python/branches/py3k/Lib/idlelib/configDialog.py ============================================================================== --- python/branches/py3k/Lib/idlelib/configDialog.py (original) +++ python/branches/py3k/Lib/idlelib/configDialog.py Fri Dec 28 15:08:13 2007 @@ -90,7 +90,7 @@ self.buttonApply.pack(side=LEFT,padx=5) self.buttonCancel.pack(side=LEFT,padx=5) frameActionButtons.pack(side=BOTTOM) - Frame(self, border=0).pack(side=BOTTOM,pady=2) + Frame(self, height=2, borderwidth=0).pack(side=BOTTOM) self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH) def CreatePageFontTab(self): @@ -274,26 +274,26 @@ self.listBindings.config(xscrollcommand=scrollTargetX.set) self.buttonNewKeys=Button(frameCustom,text='Get New Keys for Selection', command=self.GetNewKeys,state=DISABLED) - buttonSaveCustomKeys=Button(frameCustom, - text='Save as New Custom Key Set',command=self.SaveAsNewKeySet) #frameKeySets - labelTypeTitle=Label(frameKeySets,text='Select : ') - self.radioKeysBuiltin=Radiobutton(frameKeySets,variable=self.keysAreBuiltin, - value=1,command=self.SetKeysType,text='a Built-in Key Set') - self.radioKeysCustom=Radiobutton(frameKeySets,variable=self.keysAreBuiltin, - value=0,command=self.SetKeysType,text='a Custom Key Set') - self.optMenuKeysBuiltin=DynOptionMenu(frameKeySets, + frames = [Frame(frameKeySets, padx=2, pady=2, borderwidth=0) + for i in range(2)] + self.radioKeysBuiltin=Radiobutton(frames[0],variable=self.keysAreBuiltin, + value=1,command=self.SetKeysType,text='Use a Built-in Key Set') + self.radioKeysCustom=Radiobutton(frames[0],variable=self.keysAreBuiltin, + value=0,command=self.SetKeysType,text='Use a Custom Key Set') + self.optMenuKeysBuiltin=DynOptionMenu(frames[0], self.builtinKeys,None,command=None) - self.optMenuKeysCustom=DynOptionMenu(frameKeySets, + self.optMenuKeysCustom=DynOptionMenu(frames[0], self.customKeys,None,command=None) - self.buttonDeleteCustomKeys=Button(frameKeySets,text='Delete Custom Key Set', + self.buttonDeleteCustomKeys=Button(frames[1],text='Delete Custom Key Set', command=self.DeleteCustomKeys) + buttonSaveCustomKeys=Button(frames[1], + text='Save as New Custom Key Set',command=self.SaveAsNewKeySet) ##widget packing #body - frameCustom.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) - frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y) + frameCustom.pack(side=BOTTOM,padx=5,pady=5,expand=TRUE,fill=BOTH) + frameKeySets.pack(side=BOTTOM,padx=5,pady=5,fill=BOTH) #frameCustom - buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5) self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5) frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH) #frame target @@ -304,12 +304,14 @@ scrollTargetY.grid(row=1,column=1,sticky=NS) scrollTargetX.grid(row=2,column=0,sticky=EW) #frameKeySets - labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5) - self.radioKeysBuiltin.pack(side=TOP,anchor=W,padx=5) - self.radioKeysCustom.pack(side=TOP,anchor=W,padx=5,pady=2) - self.optMenuKeysBuiltin.pack(side=TOP,fill=X,padx=5,pady=5) - self.optMenuKeysCustom.pack(side=TOP,fill=X,anchor=W,padx=5,pady=5) - self.buttonDeleteCustomKeys.pack(side=TOP,fill=X,padx=5,pady=5) + self.radioKeysBuiltin.grid(row=0, column=0, sticky=W+NS) + self.radioKeysCustom.grid(row=1, column=0, sticky=W+NS) + self.optMenuKeysBuiltin.grid(row=0, column=1, sticky=NSEW) + self.optMenuKeysCustom.grid(row=1, column=1, sticky=NSEW) + self.buttonDeleteCustomKeys.pack(side=LEFT,fill=X,expand=True,padx=2) + buttonSaveCustomKeys.pack(side=LEFT,fill=X,expand=True,padx=2) + frames[0].pack(side=TOP, fill=BOTH, expand=True) + frames[1].pack(side=TOP, fill=X, expand=True, pady=2) return frame def CreatePageGeneral(self): Modified: python/branches/py3k/Lib/test/test_descr.py ============================================================================== --- python/branches/py3k/Lib/test/test_descr.py (original) +++ python/branches/py3k/Lib/test/test_descr.py Fri Dec 28 15:08:13 2007 @@ -1976,7 +1976,7 @@ def properties_plus(): - class C: + class C(object): foo = property(doc="hello") @foo.getter def foo(self): @@ -1991,8 +1991,11 @@ assert C.foo.__doc__ == "hello" assert not hasattr(c, "foo") c.foo = -42 + assert hasattr(c, '_foo') + assert c._foo == 42 assert c.foo == 42 del c.foo + assert not hasattr(c, '_foo') assert not hasattr(c, "foo") class D(C): @@ -2008,20 +2011,20 @@ del d.foo del d.foo - class E: + class E(object): @property def foo(self): return self._foo @foo.setter - def foo (self, value): + def foo(self, value): raise RuntimeError @foo.setter + def foo(self, value): + self._foo = abs(value) @foo.deleter def foo(self, value=None): - if value is None: - del self._foo - else: - self._foo = abs(value) + del self._foo + e = E() e.foo = -42 assert e.foo == 42 @@ -4223,6 +4226,7 @@ recursions() weakrefs() properties() + properties_plus() supers() inherits() keywords() Modified: python/branches/py3k/Misc/Vim/vimrc ============================================================================== --- python/branches/py3k/Misc/Vim/vimrc (original) +++ python/branches/py3k/Misc/Vim/vimrc Fri Dec 28 15:08:13 2007 @@ -41,10 +41,12 @@ " 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 +" Display tabs at the beginning of a line in Python mode as bad. " Should be done for C code, but not until all code has been moved to 4-space " indents. 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 @@ -86,12 +88,3 @@ " Keep indentation level from previous line: ``set autoindent`` " Folding based on indentation: ``set foldmethod=indent`` - -" Make trailing whitespace explicit (left off since this will automatically -" insert the highlight or characters *as you type*, which can get annoying): -"``match BadWhitespace /\s\+$/`` -" -" or, for a non-colored, character-based solution: -" -"``set list listchars=trail:-`` - Modified: python/branches/py3k/Modules/timemodule.c ============================================================================== --- python/branches/py3k/Modules/timemodule.c (original) +++ python/branches/py3k/Modules/timemodule.c Fri Dec 28 15:08:13 2007 @@ -332,7 +332,7 @@ } PyDoc_STRVAR(gmtime_doc, -"gmtime([seconds]) -> (tm_year, tm_mon, tm_day, tm_hour, tm_min,\n\ +"gmtime([seconds]) -> (tm_year, tm_mon, tm_mday, tm_hour, tm_min,\n\ tm_sec, tm_wday, tm_yday, tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing UTC (a.k.a.\n\ @@ -348,7 +348,8 @@ } PyDoc_STRVAR(localtime_doc, -"localtime([seconds]) -> (tm_year,tm_mon,tm_day,tm_hour,tm_min,tm_sec,tm_wday,tm_yday,tm_isdst)\n\ +"localtime([seconds]) -> (tm_year,tm_mon,tm_mday,tm_hour,tm_min,\n\ + tm_sec,tm_wday,tm_yday,tm_isdst)\n\ \n\ Convert seconds since the Epoch to a time tuple expressing local time.\n\ When 'seconds' is not passed in, convert the current time instead."); From python-3000-checkins at python.org Sat Dec 29 11:57:11 2007 From: python-3000-checkins at python.org (georg.brandl) Date: Sat, 29 Dec 2007 11:57:11 +0100 (CET) Subject: [Python-3000-checkins] r59607 - in python/branches/py3k/Doc: library/constants.rst reference/simple_stmts.rst Message-ID: <20071229105711.E6DC11E4016@bag.python.org> Author: georg.brandl Date: Sat Dec 29 11:57:11 2007 New Revision: 59607 Modified: python/branches/py3k/Doc/library/constants.rst python/branches/py3k/Doc/reference/simple_stmts.rst Log: Two nits. Modified: python/branches/py3k/Doc/library/constants.rst ============================================================================== --- python/branches/py3k/Doc/library/constants.rst (original) +++ python/branches/py3k/Doc/library/constants.rst Sat Dec 29 11:57:11 2007 @@ -8,7 +8,8 @@ .. note:: :data:`None`, :data:`False`, :data:`True` and :data:`__debug__` cannot be - reassigned, so they can be considered "true" constants. + reassigned (assignments to them raise :exc:`SyntaxError`), so they can be + considered "true" constants. .. XXX False, True, None are keywords too Modified: python/branches/py3k/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/simple_stmts.rst (original) +++ python/branches/py3k/Doc/reference/simple_stmts.rst Sat Dec 29 11:57:11 2007 @@ -290,7 +290,7 @@ The extended form, ``assert expression1, expression2``, is equivalent to :: if __debug__: - if not expression1: raise AssertionError, expression2 + if not expression1: raise AssertionError(expression2) .. index:: single: __debug__ From python-3000-checkins at python.org Sat Dec 29 19:38:41 2007 From: python-3000-checkins at python.org (martin.v.loewis) Date: Sat, 29 Dec 2007 19:38:41 +0100 (CET) Subject: [Python-3000-checkins] r59609 - python/branches/py3k/Lib/htmlentitydefs.py Message-ID: <20071229183841.AB7D51E4021@bag.python.org> Author: martin.v.loewis Date: Sat Dec 29 19:38:41 2007 New Revision: 59609 Modified: python/branches/py3k/Lib/htmlentitydefs.py Log: Use strings for all entity values, as that is now possible with a Unicode string type. Modified: python/branches/py3k/Lib/htmlentitydefs.py ============================================================================== --- python/branches/py3k/Lib/htmlentitydefs.py (original) +++ python/branches/py3k/Lib/htmlentitydefs.py Sat Dec 29 19:38:41 2007 @@ -265,9 +265,6 @@ for (name, codepoint) in name2codepoint.items(): codepoint2name[codepoint] = name - if codepoint <= 0xff: - entitydefs[name] = chr(codepoint) - else: - entitydefs[name] = '&#%d;' % codepoint + entitydefs[name] = chr(codepoint) del name, codepoint From python-3000-checkins at python.org Mon Dec 31 04:07:24 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 31 Dec 2007 04:07:24 +0100 (CET) Subject: [Python-3000-checkins] r59614 - python/branches/py3k/Lib/site.py Message-ID: <20071231030724.686A01E400A@bag.python.org> Author: christian.heimes Date: Mon Dec 31 04:07:24 2007 New Revision: 59614 Modified: python/branches/py3k/Lib/site.py Log: Don't close sys.stdin with quit() if sys.stdin wraps fd 0. Otherwise it will raise a warning: Lib/io.py:1221: RuntimeWarning: Trying to close unclosable fd Modified: python/branches/py3k/Lib/site.py ============================================================================== --- python/branches/py3k/Lib/site.py (original) +++ python/branches/py3k/Lib/site.py Mon Dec 31 04:07:24 2007 @@ -247,7 +247,12 @@ # Shells like IDLE catch the SystemExit, but listen when their # stdin wrapper is closed. try: - sys.stdin.close() + fd = -1 + if hasattr(sys.stdin, "fileno"): + fd = sys.stdin.fileno() + if fd != 0: + # Don't close stdin if it wraps fd 0 + sys.stdin.close() except: pass raise SystemExit(code) From python-3000-checkins at python.org Mon Dec 31 17:14:37 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 31 Dec 2007 17:14:37 +0100 (CET) Subject: [Python-3000-checkins] r59625 - in python/branches/py3k: Doc/Makefile Doc/README.txt Doc/c-api/exceptions.rst Doc/c-api/init.rst Doc/c-api/intro.rst Doc/c-api/newtypes.rst Doc/distutils/setupscript.rst Doc/documenting/fromlatex.rst Doc/documenting/markup.rst Doc/documenting/sphinx.rst Doc/extending/embedding.rst Doc/extending/extending.rst Doc/extending/newtypes.rst Doc/extending/windows.rst Doc/howto/advocacy.rst Doc/howto/doanddont.rst Doc/howto/regex.rst Doc/install/index.rst Doc/library/aepack.rst Doc/library/aetools.rst Doc/library/aetypes.rst Doc/library/asyncore.rst Doc/library/audioop.rst Doc/library/bisect.rst Doc/library/cgi.rst Doc/library/codeop.rst Doc/library/collections.rst Doc/library/configparser.rst Doc/library/constants.rst Doc/library/copy.rst Doc/library/ctypes.rst Doc/library/curses.rst Doc/library/datetime.rst Doc/library/decimal.rst Doc/library/difflib.rst Doc/library/dis.rst Doc/library/dl.rst Doc/library/doctest.rst Doc/library/email.rst Doc/library/exceptions.rst Doc/library/functions.rst Doc/library/gensuitemodule.rst Doc/library/getopt.rst Doc/library/getpass.rst Doc/library/heapq.rst Doc/library/idle.rst Doc/library/imaplib.rst Doc/library/itertools.rst Doc/library/logging.rst Doc/library/mhlib.rst Doc/library/nntplib.rst Doc/library/optparse.rst Doc/library/os.rst Doc/library/ossaudiodev.rst Doc/library/othergui.rst Doc/library/parser.rst Doc/library/pickle.rst Doc/library/platform.rst Doc/library/poplib.rst Doc/library/pprint.rst Doc/library/profile.rst Doc/library/py_compile.rst Doc/library/pyclbr.rst Doc/library/pyexpat.rst Doc/library/re.rst Doc/library/sched.rst Doc/library/select.rst Doc/library/shutil.rst Doc/library/sndhdr.rst Doc/library/socket.rst Doc/library/socketserver.rst Doc/library/sqlite3.rst Doc/library/statvfs.rst Doc/library/stdtypes.rst Doc/library/struct.rst Doc/library/sys.rst Doc/library/tabnanny.rst Doc/library/tarfile.rst Doc/library/test.rst Doc/library/thread.rst Doc/library/tix.rst Doc/library/tk.rst Doc/library/tkinter.rst Doc/library/undoc.rst Doc/library/wave.rst Doc/library/weakref.rst Doc/library/wsgiref.rst Doc/library/xml.dom.minidom.rst Doc/library/xml.dom.rst Doc/library/xml.etree.rst Doc/library/xml.sax.handler.rst Doc/library/xml.sax.reader.rst Doc/library/xmlrpclib.rst Doc/library/zipfile.rst Doc/library/zlib.rst Doc/reference/compound_stmts.rst Doc/reference/datamodel.rst Doc/reference/expressions.rst Doc/reference/lexical_analysis.rst Doc/reference/simple_stmts.rst Doc/tutorial/appetite.rst Doc/tutorial/classes.rst Doc/tutorial/controlflow.rst Doc/tutorial/datastructures.rst Doc/tutorial/inputoutput.rst Doc/tutorial/interpreter.rst Doc/tutorial/introduction.rst Doc/tutorial/modules.rst Doc/tutorial/whatnow.rst Doc/using/windows.rst Doc/whatsnew/2.0.rst Doc/whatsnew/2.1.rst Doc/whatsnew/2.2.rst Doc/whatsnew/2.3.rst Doc/whatsnew/2.4.rst Doc/whatsnew/2.5.rst Doc/whatsnew/2.6.rst Lib/distutils/command/bdist_wininst.py Lib/distutils/command/wininst-6.0.exe Lib/distutils/command/wininst-6.exe Lib/distutils/command/wininst-8.0.exe Lib/distutils/command/wininst-8.exe Lib/distutils/command/wininst-9.0.exe Lib/test/output/test_cProfile Lib/test/output/test_profile PC/VS7.1 PCbuild PCbuild/_bsddb.vcproj PCbuild/_ctypes.vcproj PCbuild/_ctypes_test.vcproj PCbuild/_elementtree.vcproj PCbuild/_msi.vcproj PCbuild/_socket.vcproj PCbuild/_sqlite3.vcproj PCbuild/_ssl.vcproj PCbuild/_testcapi.vcproj PCbuild/_tkinter.vcproj PCbuild/build.bat PCbuild/build_env.bat PCbuild/build_ssl.bat PCbuild/build_ssl.py PCbuild/bz2.vcproj PCbuild/env.bat PCbuild/field3.py PCbuild/installer.bmp PCbuild/make_buildinfo.c PCbuild/make_buildinfo.vcproj PCbuild/make_versioninfo.vcproj PCbuild/pcbuild.sln PCbuild/pyexpat.vcproj PCbuild/python.vcproj PCbuild/pythoncore.vcproj PCbuild/pythonw.vcproj PCbuild/readme.txt PCbuild/rmpyc.py PCbuild/rt.bat PCbuild/select.vcproj PCbuild/unicodedata.vcproj PCbuild/w9xpopen.vcproj PCbuild/winsound.vcproj PCbuild9 Tools/buildbot/build-amd64.bat Tools/buildbot/build.bat Tools/buildbot/buildmsi.bat Tools/buildbot/clean-amd64.bat Tools/buildbot/clean.bat Tools/buildbot/kill_python.c Tools/buildbot/test-amd64.bat Tools/buildbot/test.bat Tools/msi/msi.py configure configure.in Message-ID: <20071231161437.C398A1E400D@bag.python.org> Author: christian.heimes Date: Mon Dec 31 17:14:33 2007 New Revision: 59625 Added: python/branches/py3k/Lib/distutils/command/wininst-6.0.exe - copied unchanged from r59624, python/trunk/Lib/distutils/command/wininst-6.0.exe python/branches/py3k/Lib/distutils/command/wininst-8.0.exe - copied unchanged from r59624, python/trunk/Lib/distutils/command/wininst-8.0.exe python/branches/py3k/Lib/distutils/command/wininst-9.0.exe - copied unchanged from r59624, python/trunk/Lib/distutils/command/wininst-9.0.exe python/branches/py3k/PC/VS7.1/ (props changed) - copied from r59624, python/trunk/PC/VS7.1/ python/branches/py3k/PCbuild/ - copied from r59624, python/trunk/PCbuild/ python/branches/py3k/PCbuild/_bsddb.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_bsddb.vcproj python/branches/py3k/PCbuild/_ctypes.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_ctypes.vcproj python/branches/py3k/PCbuild/_ctypes_test.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_ctypes_test.vcproj python/branches/py3k/PCbuild/_elementtree.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_elementtree.vcproj python/branches/py3k/PCbuild/_msi.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_msi.vcproj python/branches/py3k/PCbuild/_socket.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_socket.vcproj python/branches/py3k/PCbuild/_sqlite3.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_sqlite3.vcproj python/branches/py3k/PCbuild/_ssl.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_ssl.vcproj python/branches/py3k/PCbuild/_testcapi.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_testcapi.vcproj python/branches/py3k/PCbuild/_tkinter.vcproj - copied unchanged from r59624, python/trunk/PCbuild/_tkinter.vcproj python/branches/py3k/PCbuild/build.bat - copied unchanged from r59624, python/trunk/PCbuild/build.bat python/branches/py3k/PCbuild/build_env.bat - copied unchanged from r59624, python/trunk/PCbuild/build_env.bat python/branches/py3k/PCbuild/build_ssl.bat - copied unchanged from r59624, python/trunk/PCbuild/build_ssl.bat python/branches/py3k/PCbuild/build_ssl.py - copied unchanged from r59624, python/trunk/PCbuild/build_ssl.py python/branches/py3k/PCbuild/bz2.vcproj - copied unchanged from r59624, python/trunk/PCbuild/bz2.vcproj python/branches/py3k/PCbuild/env.bat - copied unchanged from r59624, python/trunk/PCbuild/env.bat python/branches/py3k/PCbuild/field3.py - copied unchanged from r59624, python/trunk/PCbuild/field3.py python/branches/py3k/PCbuild/installer.bmp - copied unchanged from r59624, python/trunk/PCbuild/installer.bmp python/branches/py3k/PCbuild/make_buildinfo.c - copied unchanged from r59624, python/trunk/PCbuild/make_buildinfo.c python/branches/py3k/PCbuild/make_buildinfo.vcproj - copied unchanged from r59624, python/trunk/PCbuild/make_buildinfo.vcproj python/branches/py3k/PCbuild/make_versioninfo.vcproj - copied unchanged from r59624, python/trunk/PCbuild/make_versioninfo.vcproj python/branches/py3k/PCbuild/pcbuild.sln - copied unchanged from r59624, python/trunk/PCbuild/pcbuild.sln python/branches/py3k/PCbuild/pyexpat.vcproj - copied unchanged from r59624, python/trunk/PCbuild/pyexpat.vcproj python/branches/py3k/PCbuild/python.vcproj - copied unchanged from r59624, python/trunk/PCbuild/python.vcproj python/branches/py3k/PCbuild/pythoncore.vcproj - copied unchanged from r59624, python/trunk/PCbuild/pythoncore.vcproj python/branches/py3k/PCbuild/pythonw.vcproj - copied unchanged from r59624, python/trunk/PCbuild/pythonw.vcproj python/branches/py3k/PCbuild/readme.txt - copied unchanged from r59624, python/trunk/PCbuild/readme.txt python/branches/py3k/PCbuild/rmpyc.py - copied unchanged from r59624, python/trunk/PCbuild/rmpyc.py python/branches/py3k/PCbuild/rt.bat - copied unchanged from r59624, python/trunk/PCbuild/rt.bat python/branches/py3k/PCbuild/select.vcproj - copied unchanged from r59624, python/trunk/PCbuild/select.vcproj python/branches/py3k/PCbuild/unicodedata.vcproj - copied unchanged from r59624, python/trunk/PCbuild/unicodedata.vcproj python/branches/py3k/PCbuild/w9xpopen.vcproj - copied unchanged from r59624, python/trunk/PCbuild/w9xpopen.vcproj python/branches/py3k/PCbuild/winsound.vcproj - copied unchanged from r59624, python/trunk/PCbuild/winsound.vcproj Removed: python/branches/py3k/Lib/distutils/command/wininst-6.exe python/branches/py3k/Lib/distutils/command/wininst-8.exe python/branches/py3k/PCbuild9/ Modified: python/branches/py3k/ (props changed) python/branches/py3k/Doc/Makefile python/branches/py3k/Doc/README.txt python/branches/py3k/Doc/c-api/exceptions.rst python/branches/py3k/Doc/c-api/init.rst python/branches/py3k/Doc/c-api/intro.rst python/branches/py3k/Doc/c-api/newtypes.rst python/branches/py3k/Doc/distutils/setupscript.rst python/branches/py3k/Doc/documenting/fromlatex.rst python/branches/py3k/Doc/documenting/markup.rst python/branches/py3k/Doc/documenting/sphinx.rst python/branches/py3k/Doc/extending/embedding.rst python/branches/py3k/Doc/extending/extending.rst python/branches/py3k/Doc/extending/newtypes.rst python/branches/py3k/Doc/extending/windows.rst python/branches/py3k/Doc/howto/advocacy.rst python/branches/py3k/Doc/howto/doanddont.rst python/branches/py3k/Doc/howto/regex.rst python/branches/py3k/Doc/install/index.rst python/branches/py3k/Doc/library/aepack.rst python/branches/py3k/Doc/library/aetools.rst python/branches/py3k/Doc/library/aetypes.rst python/branches/py3k/Doc/library/asyncore.rst python/branches/py3k/Doc/library/audioop.rst python/branches/py3k/Doc/library/bisect.rst python/branches/py3k/Doc/library/cgi.rst python/branches/py3k/Doc/library/codeop.rst python/branches/py3k/Doc/library/collections.rst python/branches/py3k/Doc/library/configparser.rst python/branches/py3k/Doc/library/constants.rst python/branches/py3k/Doc/library/copy.rst python/branches/py3k/Doc/library/ctypes.rst python/branches/py3k/Doc/library/curses.rst python/branches/py3k/Doc/library/datetime.rst python/branches/py3k/Doc/library/decimal.rst python/branches/py3k/Doc/library/difflib.rst python/branches/py3k/Doc/library/dis.rst python/branches/py3k/Doc/library/dl.rst python/branches/py3k/Doc/library/doctest.rst python/branches/py3k/Doc/library/email.rst python/branches/py3k/Doc/library/exceptions.rst python/branches/py3k/Doc/library/functions.rst python/branches/py3k/Doc/library/gensuitemodule.rst python/branches/py3k/Doc/library/getopt.rst python/branches/py3k/Doc/library/getpass.rst python/branches/py3k/Doc/library/heapq.rst python/branches/py3k/Doc/library/idle.rst python/branches/py3k/Doc/library/imaplib.rst python/branches/py3k/Doc/library/itertools.rst python/branches/py3k/Doc/library/logging.rst python/branches/py3k/Doc/library/mhlib.rst python/branches/py3k/Doc/library/nntplib.rst python/branches/py3k/Doc/library/optparse.rst python/branches/py3k/Doc/library/os.rst python/branches/py3k/Doc/library/ossaudiodev.rst python/branches/py3k/Doc/library/othergui.rst python/branches/py3k/Doc/library/parser.rst python/branches/py3k/Doc/library/pickle.rst python/branches/py3k/Doc/library/platform.rst python/branches/py3k/Doc/library/poplib.rst python/branches/py3k/Doc/library/pprint.rst python/branches/py3k/Doc/library/profile.rst python/branches/py3k/Doc/library/py_compile.rst python/branches/py3k/Doc/library/pyclbr.rst python/branches/py3k/Doc/library/pyexpat.rst python/branches/py3k/Doc/library/re.rst python/branches/py3k/Doc/library/sched.rst python/branches/py3k/Doc/library/select.rst python/branches/py3k/Doc/library/shutil.rst python/branches/py3k/Doc/library/sndhdr.rst python/branches/py3k/Doc/library/socket.rst python/branches/py3k/Doc/library/socketserver.rst python/branches/py3k/Doc/library/sqlite3.rst python/branches/py3k/Doc/library/statvfs.rst python/branches/py3k/Doc/library/stdtypes.rst python/branches/py3k/Doc/library/struct.rst python/branches/py3k/Doc/library/sys.rst python/branches/py3k/Doc/library/tabnanny.rst python/branches/py3k/Doc/library/tarfile.rst python/branches/py3k/Doc/library/test.rst python/branches/py3k/Doc/library/thread.rst python/branches/py3k/Doc/library/tix.rst python/branches/py3k/Doc/library/tk.rst python/branches/py3k/Doc/library/tkinter.rst python/branches/py3k/Doc/library/undoc.rst python/branches/py3k/Doc/library/wave.rst python/branches/py3k/Doc/library/weakref.rst python/branches/py3k/Doc/library/wsgiref.rst python/branches/py3k/Doc/library/xml.dom.minidom.rst python/branches/py3k/Doc/library/xml.dom.rst python/branches/py3k/Doc/library/xml.etree.rst python/branches/py3k/Doc/library/xml.sax.handler.rst python/branches/py3k/Doc/library/xml.sax.reader.rst python/branches/py3k/Doc/library/xmlrpclib.rst python/branches/py3k/Doc/library/zipfile.rst python/branches/py3k/Doc/library/zlib.rst python/branches/py3k/Doc/reference/compound_stmts.rst python/branches/py3k/Doc/reference/datamodel.rst python/branches/py3k/Doc/reference/expressions.rst python/branches/py3k/Doc/reference/lexical_analysis.rst python/branches/py3k/Doc/reference/simple_stmts.rst python/branches/py3k/Doc/tutorial/appetite.rst python/branches/py3k/Doc/tutorial/classes.rst python/branches/py3k/Doc/tutorial/controlflow.rst python/branches/py3k/Doc/tutorial/datastructures.rst python/branches/py3k/Doc/tutorial/inputoutput.rst python/branches/py3k/Doc/tutorial/interpreter.rst python/branches/py3k/Doc/tutorial/introduction.rst python/branches/py3k/Doc/tutorial/modules.rst python/branches/py3k/Doc/tutorial/whatnow.rst python/branches/py3k/Doc/using/windows.rst python/branches/py3k/Doc/whatsnew/2.0.rst python/branches/py3k/Doc/whatsnew/2.1.rst python/branches/py3k/Doc/whatsnew/2.2.rst python/branches/py3k/Doc/whatsnew/2.3.rst python/branches/py3k/Doc/whatsnew/2.4.rst python/branches/py3k/Doc/whatsnew/2.5.rst python/branches/py3k/Doc/whatsnew/2.6.rst python/branches/py3k/Lib/distutils/command/bdist_wininst.py python/branches/py3k/Lib/test/output/test_cProfile python/branches/py3k/Lib/test/output/test_profile python/branches/py3k/Tools/buildbot/build-amd64.bat python/branches/py3k/Tools/buildbot/build.bat python/branches/py3k/Tools/buildbot/buildmsi.bat python/branches/py3k/Tools/buildbot/clean-amd64.bat python/branches/py3k/Tools/buildbot/clean.bat python/branches/py3k/Tools/buildbot/kill_python.c python/branches/py3k/Tools/buildbot/test-amd64.bat python/branches/py3k/Tools/buildbot/test.bat python/branches/py3k/Tools/msi/msi.py python/branches/py3k/configure python/branches/py3k/configure.in Log: Merged revisions 59605-59624 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59606 | georg.brandl | 2007-12-29 11:57:00 +0100 (Sat, 29 Dec 2007) | 2 lines Some cleanup in the docs. ........ r59611 | martin.v.loewis | 2007-12-29 19:49:21 +0100 (Sat, 29 Dec 2007) | 2 lines Bug #1699: Define _BSD_SOURCE only on OpenBSD. ........ r59612 | raymond.hettinger | 2007-12-29 23:09:34 +0100 (Sat, 29 Dec 2007) | 1 line Simpler documentation for itertools.tee(). Should be backported. ........ r59613 | raymond.hettinger | 2007-12-29 23:16:24 +0100 (Sat, 29 Dec 2007) | 1 line Improve docs for itertools.groupby(). The use of xrange(0) to create a unique object is less obvious than object(). ........ r59620 | christian.heimes | 2007-12-31 15:47:07 +0100 (Mon, 31 Dec 2007) | 3 lines Added wininst-9.0.exe executable for VS 2008 Integrated bdist_wininst into PCBuild9 directory ........ r59621 | christian.heimes | 2007-12-31 15:51:18 +0100 (Mon, 31 Dec 2007) | 1 line Moved PCbuild directory to PC/VS7.1 ........ r59622 | christian.heimes | 2007-12-31 15:59:26 +0100 (Mon, 31 Dec 2007) | 1 line Fix paths for build bot ........ r59623 | christian.heimes | 2007-12-31 16:02:41 +0100 (Mon, 31 Dec 2007) | 1 line Fix paths for build bot, part 2 ........ r59624 | christian.heimes | 2007-12-31 16:18:55 +0100 (Mon, 31 Dec 2007) | 1 line Renamed PCBuild9 directory to PCBuild ........ Modified: python/branches/py3k/Doc/Makefile ============================================================================== --- python/branches/py3k/Doc/Makefile (original) +++ python/branches/py3k/Doc/Makefile Mon Dec 31 17:14:33 2007 @@ -16,10 +16,11 @@ help: @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " web to make file usable by Sphinx.web" + @echo " html to make standalone HTML files" + @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 " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " changes to make an overview over all changed/added/deprecated items" checkout: @if [ ! -d tools/sphinx ]; then \ @@ -66,6 +67,10 @@ @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ "run these through (pdf)latex." +changes: BUILDER = changes +changes: build + @echo "The overview file is in build/changes." + clean: -rm -rf build/* -rm -rf tools/sphinx Modified: python/branches/py3k/Doc/README.txt ============================================================================== --- python/branches/py3k/Doc/README.txt (original) +++ python/branches/py3k/Doc/README.txt Mon Dec 31 17:14:33 2007 @@ -56,6 +56,10 @@ * "latex", which builds LaTeX source files that can be run with "pdflatex" to produce PDF documents. + * "changes", which builds an overview over all versionadded/versionchanged/ + deprecated items in the current version. This is meant as a help for the + writer of the "What's New" document. + A "make update" updates the Subversion checkouts in `tools/`. Modified: python/branches/py3k/Doc/c-api/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/c-api/exceptions.rst (original) +++ python/branches/py3k/Doc/c-api/exceptions.rst Mon Dec 31 17:14:33 2007 @@ -31,8 +31,8 @@ of ``sys.exc_info()``. API functions exist to interact with the error indicator in various ways. There is a separate error indicator for each thread. -.. % XXX Order of these should be more thoughtful. -.. % Either alphabetical or some kind of structure. +.. XXX Order of these should be more thoughtful. + Either alphabetical or some kind of structure. .. cfunction:: void PyErr_Print() Modified: python/branches/py3k/Doc/c-api/init.rst ============================================================================== --- python/branches/py3k/Doc/c-api/init.rst (original) +++ python/branches/py3k/Doc/c-api/init.rst Mon Dec 31 17:14:33 2007 @@ -264,7 +264,7 @@ as the list ``sys.path``, which may be modified to change the future search path for loaded modules. - .. % XXX should give the exact rules + .. XXX should give the exact rules .. cfunction:: const char* Py_GetVersion() @@ -357,8 +357,8 @@ to initialize ``sys.argv``, a fatal condition is signalled using :cfunc:`Py_FatalError`. - .. % XXX impl. doesn't seem consistent in allowing 0/NULL for the params; - .. % check w/ Guido. + .. XXX impl. doesn't seem consistent in allowing 0/NULL for the params; + check w/ Guido. .. _threads: Modified: python/branches/py3k/Doc/c-api/intro.rst ============================================================================== --- python/branches/py3k/Doc/c-api/intro.rst (original) +++ python/branches/py3k/Doc/c-api/intro.rst Mon Dec 31 17:14:33 2007 @@ -484,7 +484,7 @@ single: PyErr_Clear() single: Py_XDECREF() -This example represents an endorsed use of the :keyword:`goto` statement in C! +This example represents an endorsed use of the ``goto`` statement in C! It illustrates the use of :cfunc:`PyErr_ExceptionMatches` and :cfunc:`PyErr_Clear` to handle specific exceptions, and the use of :cfunc:`Py_XDECREF` to dispose of owned references that may be *NULL* (note the Modified: python/branches/py3k/Doc/c-api/newtypes.rst ============================================================================== --- python/branches/py3k/Doc/c-api/newtypes.rst (original) +++ python/branches/py3k/Doc/c-api/newtypes.rst Mon Dec 31 17:14:33 2007 @@ -459,7 +459,7 @@ declare the instance struct) and this in turn includes the :attr:`_ob_prev` and :attr:`_ob_next` fields if they are present. This means that the only correct way to get an initializer for the :attr:`tp_basicsize` is to use the - :keyword:`sizeof` operator on the struct used to declare the instance layout. + ``sizeof`` operator on the struct used to declare the instance layout. The basic size does not include the GC header size (this is new in Python 2.2; in 2.1 and 2.0, the GC header size was included in :attr:`tp_basicsize`). @@ -1145,7 +1145,7 @@ PyObject * tp_descr_get(PyObject *self, PyObject *obj, PyObject *type); - XXX more + XXX explain. This field is inherited by subtypes. @@ -1160,7 +1160,7 @@ This field is inherited by subtypes. - XXX more + XXX explain. .. cmember:: long PyTypeObject.tp_dictoffset @@ -1683,10 +1683,9 @@ and :exc:`SystemError` should be raised when *segment* specifies a segment that doesn't exist. - .. % Why doesn't it raise ValueError for this one? - .. % GJS: because you shouldn't be calling it with an invalid - .. % segment. That indicates a blatant programming error in the C - .. % code. + .. Why doesn't it raise ValueError for this one? + GJS: because you shouldn't be calling it with an invalid + segment. That indicates a blatant programming error in the C code. .. ctype:: Py_ssize_t (*segcountproc) (PyObject *self, Py_ssize_t *lenp) Modified: python/branches/py3k/Doc/distutils/setupscript.rst ============================================================================== --- python/branches/py3k/Doc/distutils/setupscript.rst (original) +++ python/branches/py3k/Doc/distutils/setupscript.rst Mon Dec 31 17:14:33 2007 @@ -137,7 +137,7 @@ extension name, source file(s), and any compile/link requirements (include directories, libraries to link with, etc.). -.. % XXX read over this section +.. XXX read over this section All of this is done through another keyword argument to :func:`setup`, the :option:`ext_modules` option. :option:`ext_modules` is just a list of Modified: python/branches/py3k/Doc/documenting/fromlatex.rst ============================================================================== --- python/branches/py3k/Doc/documenting/fromlatex.rst (original) +++ python/branches/py3k/Doc/documenting/fromlatex.rst Mon Dec 31 17:14:33 2007 @@ -154,25 +154,35 @@ Description. -* **New information unit** +* **New information units** - There is a new generic information unit called "describe" which can be used - to document things that are not covered by the other units:: + There are new generic information units: One is called "describe" and can be + used to document things that are not covered by the other units:: .. describe:: a == b The equals operator. + The others are:: + + .. cmdoption:: -O + + Describes a command-line option. + + .. envvar:: PYTHONINSPECT + + Describes an environment variable. + Structure --------- -The LaTeX docs were split in several toplevel manuals. Now, all files -are part of the same documentation tree, as indicated by the *toctree* -directives in the sources. Every *toctree* directive embeds other files -as subdocuments of the current file (this structure is not necessarily -mirrored in the filesystem layout). The toplevel file is -:file:`contents.rst`. +The LaTeX docs were split in several toplevel manuals. Now, all files are part +of the same documentation tree, as indicated by the *toctree* directives in the +sources (though individual output formats may choose to split them up into parts +again). Every *toctree* directive embeds other files as subdocuments of the +current file (this structure is not necessarily mirrored in the filesystem +layout). The toplevel file is :file:`contents.rst`. However, most of the old directory structure has been kept, with the directories renamed as follows: @@ -184,7 +194,7 @@ * :file:`inst` -> :file:`installing` * :file:`lib` -> :file:`library` * :file:`mac` -> merged into :file:`library`, with :file:`mac/using.tex` - moved to :file:`howto/pythonmac.rst` + moved to :file:`using/mac.rst` * :file:`ref` -> :file:`reference` * :file:`tut` -> :file:`tutorial`, with the single TeX file split up Modified: python/branches/py3k/Doc/documenting/markup.rst ============================================================================== --- python/branches/py3k/Doc/documenting/markup.rst (original) +++ python/branches/py3k/Doc/documenting/markup.rst Mon Dec 31 17:14:33 2007 @@ -455,7 +455,7 @@ .. describe:: keyword - The name of a keyword in a programming language. + The name of a keyword in Python. .. describe:: mailheader Modified: python/branches/py3k/Doc/documenting/sphinx.rst ============================================================================== --- python/branches/py3k/Doc/documenting/sphinx.rst (original) +++ python/branches/py3k/Doc/documenting/sphinx.rst Mon Dec 31 17:14:33 2007 @@ -47,14 +47,30 @@ could be docs for temporarily disabled modules or documentation that's not yet ready for public consumption. -last_updated_format : string +add_function_parentheses : bool + If true, ``()`` will be appended to the content of ``:func:``, ``:meth:`` and + ``:cfunc:`` cross-references. + +add_module_names : bool + If true, the current module name will be prepended to all description unit + titles (such as ``.. function::``). + +Builder-specific variables +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +html_download_base_url : string + The base URL for download links on the download page. + +html_last_updated_fmt : string If this is not an empty string, it will be given to ``time.strftime()`` and written to each generated output file after "last updated on:". -use_smartypants : bool +html_use_smartypants : bool If true, use SmartyPants to convert quotes and dashes to the typographically correct entities. -add_function_parentheses : bool - If true, ``()`` will be appended to the content of ``:func:``, ``:meth:`` and - ``:cfunc:`` cross-references. \ No newline at end of file +latex_paper_size : "letter" or "a4" + The paper size option for the LaTeX document class. + +latex_font_size : "10pt", "11pt" or "12pt" + The font size option for the LaTeX document class. \ No newline at end of file Modified: python/branches/py3k/Doc/extending/embedding.rst ============================================================================== --- python/branches/py3k/Doc/extending/embedding.rst (original) +++ python/branches/py3k/Doc/extending/embedding.rst Mon Dec 31 17:14:33 2007 @@ -155,11 +155,7 @@ Although the program is quite large for its functionality, most of the code is for data conversion between Python and C, and for error reporting. The -interesting part with respect to embedding Python starts with - -.. % $ - -:: +interesting part with respect to embedding Python starts with :: Py_Initialize(); pName = PyString_FromString(argv[1]); @@ -239,15 +235,8 @@ In a real application, the methods will expose an API of the application to Python. -.. % \section{For the future} -.. % -.. % You don't happen to have a nice library to get textual -.. % equivalents of numeric values do you :-) ? -.. % Callbacks here ? (I may be using information from that section -.. % ?!) -.. % threads -.. % code examples do not really behave well if errors happen -.. % (what to watch out for) +.. TODO: threads, code examples do not really behave well if errors happen + (what to watch out for) .. _embeddingincplusplus: Modified: python/branches/py3k/Doc/extending/extending.rst ============================================================================== --- python/branches/py3k/Doc/extending/extending.rst (original) +++ python/branches/py3k/Doc/extending/extending.rst Mon Dec 31 17:14:33 2007 @@ -306,7 +306,7 @@ The method table must be passed to the interpreter in the module's initialization function. The initialization function must be named :cfunc:`initname`, where *name* is the name of the module, and should be the -only non-\ :keyword:`static` item defined in the module file:: +only non-\ ``static`` item defined in the module file:: PyMODINIT_FUNC initspam(void) @@ -660,11 +660,7 @@ .. index:: single: Philbrick, Geoff Here is an example module which uses keywords, based on an example by Geoff -Philbrick (philbrick at hks.com): - -.. % - -:: +Philbrick (philbrick at hks.com):: #include "Python.h" @@ -762,8 +758,8 @@ In languages like C or C++, the programmer is responsible for dynamic allocation and deallocation of memory on the heap. In C, this is done using the functions -:cfunc:`malloc` and :cfunc:`free`. In C++, the operators :keyword:`new` and -:keyword:`delete` are used with essentially the same meaning and we'll restrict +:cfunc:`malloc` and :cfunc:`free`. In C++, the operators ``new`` and +``delete`` are used with essentially the same meaning and we'll restrict the following discussion to the C case. Every block of memory allocated with :cfunc:`malloc` should eventually be @@ -1036,11 +1032,10 @@ It is a severe error to ever let a *NULL* pointer "escape" to the Python user. -.. % Frank Stajano: -.. % A pedagogically buggy example, along the lines of the previous listing, -.. % would be helpful here -- showing in more concrete terms what sort of -.. % actions could cause the problem. I can't very well imagine it from the -.. % description. +.. Frank Stajano: + A pedagogically buggy example, along the lines of the previous listing, would + be helpful here -- showing in more concrete terms what sort of actions could + cause the problem. I can't very well imagine it from the description. .. _cplusplus: @@ -1076,7 +1071,7 @@ manipulation from other extension modules. At first sight this seems easy: just write the functions (without declaring them -:keyword:`static`, of course), provide an appropriate header file, and document +``static``, of course), provide an appropriate header file, and document the C API. And in fact this would work if all extension modules were always linked statically with the Python interpreter. When modules are used as shared libraries, however, the symbols defined in one module may not be visible to @@ -1089,7 +1084,7 @@ Portability therefore requires not to make any assumptions about symbol visibility. This means that all symbols in extension modules should be declared -:keyword:`static`, except for the module's initialization function, in order to +``static``, except for the module's initialization function, in order to avoid name clashes with other extension modules (as discussed in section :ref:`methodtable`). And it means that symbols that *should* be accessible from other extension modules must be exported in a different way. @@ -1124,7 +1119,7 @@ :cfunc:`PySpam_System` is also exported to other extension modules. The function :cfunc:`PySpam_System` is a plain C function, declared -:keyword:`static` like everything else:: +``static`` like everything else:: static int PySpam_System(const char *command) @@ -1180,7 +1175,7 @@ PyModule_AddObject(m, "_C_API", c_api_object); } -Note that ``PySpam_API`` is declared :keyword:`static`; otherwise the pointer +Note that ``PySpam_API`` is declared ``static``; otherwise the pointer array would disappear when :func:`initspam` terminates! The bulk of the work is in the header file :file:`spammodule.h`, which looks Modified: python/branches/py3k/Doc/extending/newtypes.rst ============================================================================== --- python/branches/py3k/Doc/extending/newtypes.rst (original) +++ python/branches/py3k/Doc/extending/newtypes.rst Mon Dec 31 17:14:33 2007 @@ -1196,16 +1196,14 @@ As with the :attr:`tp_methods` table, a sentinel entry with a :attr:`name` value of *NULL* is required. -.. % XXX Descriptors need to be explained in more detail somewhere, but -.. % not here. -.. % -.. % Descriptor objects have two handler functions which correspond to -.. % the \member{tp_getattro} and \member{tp_setattro} handlers. The -.. % \method{__get__()} handler is a function which is passed the -.. % descriptor, instance, and type objects, and returns the value of the -.. % attribute, or it returns \NULL{} and sets an exception. The -.. % \method{__set__()} handler is passed the descriptor, instance, type, -.. % and new value; +.. XXX Descriptors need to be explained in more detail somewhere, but not here. + + Descriptor objects have two handler functions which correspond to the + \member{tp_getattro} and \member{tp_setattro} handlers. The + \method{__get__()} handler is a function which is passed the descriptor, + instance, and type objects, and returns the value of the attribute, or it + returns \NULL{} and sets an exception. The \method{__set__()} handler is + passed the descriptor, instance, type, and new value; Type-specific Attribute Management Modified: python/branches/py3k/Doc/extending/windows.rst ============================================================================== --- python/branches/py3k/Doc/extending/windows.rst (original) +++ python/branches/py3k/Doc/extending/windows.rst Mon Dec 31 17:14:33 2007 @@ -7,8 +7,6 @@ Building C and C++ Extensions on Windows **************************************** -.. % - This chapter briefly explains how to create a Windows extension module for Python using Microsoft Visual C++, and follows with more detailed background information on how it works. The explanatory material is useful for both the Modified: python/branches/py3k/Doc/howto/advocacy.rst ============================================================================== --- python/branches/py3k/Doc/howto/advocacy.rst (original) +++ python/branches/py3k/Doc/howto/advocacy.rst Mon Dec 31 17:14:33 2007 @@ -302,11 +302,11 @@ The Python Success Stories are a collection of stories from successful users of Python, with the emphasis on business and corporate users. -.. % \term{\url{http://www.fsbassociates.com/books/pythonchpt1.htm}} -.. % The first chapter of \emph{Internet Programming with Python} also -.. % examines some of the reasons for using Python. The book is well worth -.. % buying, but the publishers have made the first chapter available on -.. % the Web. +.. http://www.fsbassociates.com/books/pythonchpt1.htm + The first chapter of \emph{Internet Programming with Python} also + examines some of the reasons for using Python. The book is well worth + buying, but the publishers have made the first chapter available on + the Web. http://home.pacbell.net/ouster/scripting.html John Ousterhout's white paper on scripting is a good argument for the utility of @@ -333,9 +333,9 @@ to show that choosing Python didn't introduce any difficulties into a company's development process, and provided some substantial benefits. -.. % \term{\url{http://www.python.org/psa/Commercial.html}} -.. % Robin Friedrich wrote this document on how to support Python's use in -.. % commercial projects. +.. http://www.python.org/psa/Commercial.html + Robin Friedrich wrote this document on how to support Python's use in + commercial projects. http://www.python.org/workshops/1997-10/proceedings/stein.ps For the 6th Python conference, Greg Stein presented a paper that traced Python's Modified: python/branches/py3k/Doc/howto/doanddont.rst ============================================================================== --- python/branches/py3k/Doc/howto/doanddont.rst (original) +++ python/branches/py3k/Doc/howto/doanddont.rst Mon Dec 31 17:14:33 2007 @@ -291,7 +291,7 @@ calculate_number(10, 20) != forbulate(500, 360): pass -You should realize that this is dangerous: a stray space after the ``XXX`` would +You should realize that this is dangerous: a stray space after the ``\`` would make this line wrong, and stray spaces are notoriously hard to see in editors. In this case, at least it would be a syntax error, but if the code was:: Modified: python/branches/py3k/Doc/howto/regex.rst ============================================================================== --- python/branches/py3k/Doc/howto/regex.rst (original) +++ python/branches/py3k/Doc/howto/regex.rst Mon Dec 31 17:14:33 2007 @@ -5,11 +5,11 @@ :Author: A.M. Kuchling :Release: 0.05 -.. % TODO: -.. % Document lookbehind assertions -.. % Better way of displaying a RE, a string, and what it matches -.. % Mention optional argument to match.groups() -.. % Unicode (at least a reference) +.. TODO: + Document lookbehind assertions + Better way of displaying a RE, a string, and what it matches + Mention optional argument to match.groups() + Unicode (at least a reference) .. topic:: Abstract @@ -91,8 +91,6 @@ characters. If you wanted to match only lowercase letters, your RE would be ``[a-z]``. -.. % $ - Metacharacters are not active inside classes. For example, ``[akm$]`` will match any of the characters ``'a'``, ``'k'``, ``'m'``, or ``'$'``; ``'$'`` is usually a metacharacter, but inside a character class it's stripped of its @@ -679,8 +677,8 @@ >>> print(re.search('^From', 'Reciting From Memory')) None - .. % To match a literal \character{\^}, use \regexp{\e\^} or enclose it - .. % inside a character class, as in \regexp{[{\e}\^]}. + .. To match a literal \character{\^}, use \regexp{\e\^} or enclose it + .. inside a character class, as in \regexp{[{\e}\^]}. ``$`` Matches at the end of a line, which is defined as either the end of the string, @@ -696,8 +694,6 @@ To match a literal ``'$'``, use ``\$`` or enclose it inside a character class, as in ``[$]``. - .. % $ - ``\A`` Matches only at the start of the string. When not in :const:`MULTILINE` mode, ``\A`` and ``^`` are effectively the same. In :const:`MULTILINE` mode, they're @@ -980,12 +976,8 @@ that the first character of the extension is not a ``b``. This is wrong, because the pattern also doesn't match ``foo.bar``. -.. % $ - ``.*[.]([^b]..|.[^a].|..[^t])$`` -.. % Messes up the HTML without the curly braces around \^ - The expression gets messier when you try to patch up the first solution by requiring one of the following cases to match: the first character of the extension isn't ``b``; the second character isn't ``a``; or the third character @@ -1013,16 +1005,12 @@ that something like ``sample.batch``, where the extension only starts with ``bat``, will be allowed. -.. % $ - Excluding another filename extension is now easy; simply add it as an alternative inside the assertion. The following pattern excludes filenames that end in either ``bat`` or ``exe``: ``.*[.](?!bat$|exe$).*$`` -.. % $ - Modifying Strings ================= @@ -1343,16 +1331,10 @@ \s*$ # Trailing whitespace to end-of-line """, re.VERBOSE) -This is far more readable than: - -.. % $ - -:: +This is far more readable than:: pat = re.compile(r"\s*(?P
[^:]+)\s*:(?P.*?)\s*$") -.. % $ - Feedback ======== Modified: python/branches/py3k/Doc/install/index.rst ============================================================================== --- python/branches/py3k/Doc/install/index.rst (original) +++ python/branches/py3k/Doc/install/index.rst Mon Dec 31 17:14:33 2007 @@ -10,18 +10,17 @@ :Release: |version| :Date: |today| -.. % TODO: -.. % Fill in XXX comments +.. TODO: Fill in XXX comments -.. % The audience for this document includes people who don't know anything -.. % about Python and aren't about to learn the language just in order to -.. % install and maintain it for their users, i.e. system administrators. -.. % Thus, I have to be sure to explain the basics at some point: -.. % sys.path and PYTHONPATH at least. Should probably give pointers to -.. % other docs on "import site", PYTHONSTARTUP, PYTHONHOME, etc. -.. % -.. % Finally, it might be useful to include all the material from my "Care -.. % and Feeding of a Python Installation" talk in here somewhere. Yow! +.. The audience for this document includes people who don't know anything + about Python and aren't about to learn the language just in order to + install and maintain it for their users, i.e. system administrators. + Thus, I have to be sure to explain the basics at some point: + sys.path and PYTHONPATH at least. Should probably give pointers to + other docs on "import site", PYTHONSTARTUP, PYTHONHOME, etc. + + Finally, it might be useful to include all the material from my "Care + and Feeding of a Python Installation" talk in here somewhere. Yow! .. topic:: Abstract @@ -565,11 +564,11 @@ the Distutils are the only ones you can use.) See section :ref:`inst-config-files` for details. -.. % XXX need some Windows examples---when would custom -.. % installation schemes be needed on those platforms? +.. XXX need some Windows examples---when would custom installation schemes be + needed on those platforms? -.. % XXX I'm not sure where this section should go. +.. XXX I'm not sure where this section should go. .. _inst-search-path: @@ -881,8 +880,8 @@ reason you have to convert Python's library :file:`python25.lib` into the Borland format. You can do this as follows: -.. % Should we mention that users have to create cfg-files for the compiler? -.. % see also http://community.borland.com/article/0,1410,21205,00.html +.. Should we mention that users have to create cfg-files for the compiler? +.. see also http://community.borland.com/article/0,1410,21205,00.html :: @@ -940,8 +939,8 @@ http://starship.python.net/crew/kernr/mingw32/Notes.html, see at PExports 0.42h there.) -.. % I don't understand what the next line means. --amk -.. % (inclusive the references on data structures.) +.. I don't understand what the next line means. --amk +.. (inclusive the references on data structures.) :: Modified: python/branches/py3k/Doc/library/aepack.rst ============================================================================== --- python/branches/py3k/Doc/library/aepack.rst (original) +++ python/branches/py3k/Doc/library/aepack.rst Mon Dec 31 17:14:33 2007 @@ -6,9 +6,7 @@ :platform: Mac :synopsis: Conversion between Python variables and AppleEvent data containers. .. sectionauthor:: Vincent Marchetti - - -.. % \moduleauthor{Jack Jansen?}{email} +.. moduleauthor:: Jack Jansen The :mod:`aepack` module defines functions for converting (packing) Python variables to AppleEvent descriptors and back (unpacking). Within Python the Modified: python/branches/py3k/Doc/library/aetools.rst ============================================================================== --- python/branches/py3k/Doc/library/aetools.rst (original) +++ python/branches/py3k/Doc/library/aetools.rst Mon Dec 31 17:14:33 2007 @@ -6,9 +6,7 @@ :platform: Mac :synopsis: Basic support for sending Apple Events .. sectionauthor:: Jack Jansen - - -.. % \moduleauthor{Jack Jansen?}{email} +.. moduleauthor:: Jack Jansen The :mod:`aetools` module contains the basic functionality on which Python AppleScript client support is built. It also imports and re-exports the core Modified: python/branches/py3k/Doc/library/aetypes.rst ============================================================================== --- python/branches/py3k/Doc/library/aetypes.rst (original) +++ python/branches/py3k/Doc/library/aetypes.rst Mon Dec 31 17:14:33 2007 @@ -6,9 +6,7 @@ :platform: Mac :synopsis: Python representation of the Apple Event Object Model. .. sectionauthor:: Vincent Marchetti - - -.. % \moduleauthor{Jack Jansen?}{email} +.. moduleauthor:: Jack Jansen The :mod:`aetypes` defines classes used to represent Apple Event data descriptors and Apple Event object specifiers. Modified: python/branches/py3k/Doc/library/asyncore.rst ============================================================================== --- python/branches/py3k/Doc/library/asyncore.rst (original) +++ python/branches/py3k/Doc/library/asyncore.rst Mon Dec 31 17:14:33 2007 @@ -8,13 +8,12 @@ .. moduleauthor:: Sam Rushing .. sectionauthor:: Christopher Petrilli .. sectionauthor:: Steve Holden +.. heavily adapted from original documentation by Sam Rushing This module provides the basic infrastructure for writing asynchronous socket service clients and servers. -.. % Heavily adapted from original documentation by Sam Rushing. - There are only two ways to have a program on a single processor do "more than one thing at a time." Multi-threaded programming is the simplest and most popular way to do it, but there is another very different technique, that lets Modified: python/branches/py3k/Doc/library/audioop.rst ============================================================================== --- python/branches/py3k/Doc/library/audioop.rst (original) +++ python/branches/py3k/Doc/library/audioop.rst Mon Dec 31 17:14:33 2007 @@ -19,7 +19,7 @@ This module provides support for a-LAW, u-LAW and Intel/DVI ADPCM encodings. -.. % This para is mostly here to provide an excuse for the index entries... +.. This para is mostly here to provide an excuse for the index entries... A few of the more complicated operations only take 16-bit samples, otherwise the sample size (in bytes) is always a parameter of the operation. Modified: python/branches/py3k/Doc/library/bisect.rst ============================================================================== --- python/branches/py3k/Doc/library/bisect.rst (original) +++ python/branches/py3k/Doc/library/bisect.rst Mon Dec 31 17:14:33 2007 @@ -5,11 +5,7 @@ .. module:: bisect :synopsis: Array bisection algorithms for binary searching. .. sectionauthor:: Fred L. Drake, Jr. - - -.. % LaTeX produced by Fred L. Drake, Jr. , with an -.. % example based on the PyModules FAQ entry by Aaron Watters -.. % . +.. example based on the PyModules FAQ entry by Aaron Watters This module provides support for maintaining a list in sorted order without having to sort the list after each insertion. For long lists of items with Modified: python/branches/py3k/Doc/library/cgi.rst ============================================================================== --- python/branches/py3k/Doc/library/cgi.rst (original) +++ python/branches/py3k/Doc/library/cgi.rst Mon Dec 31 17:14:33 2007 @@ -176,7 +176,7 @@ sections obsolete --- they are still useful to process file uploads efficiently, for example. -.. % XXX: Is this true ? +.. XXX: Is this true ? The interface consists of two simple methods. Using the methods you can process form data in a generic way, without the need to worry whether only one or more Modified: python/branches/py3k/Doc/library/codeop.rst ============================================================================== --- python/branches/py3k/Doc/library/codeop.rst (original) +++ python/branches/py3k/Doc/library/codeop.rst Mon Dec 31 17:14:33 2007 @@ -7,9 +7,6 @@ .. sectionauthor:: Moshe Zadka .. sectionauthor:: Michael Hudson - -.. % LaTeXed from excellent doc-string. - The :mod:`codeop` module provides utilities upon which the Python read-eval-print loop can be emulated, as is done in the :mod:`code` module. As a result, you probably don't want to use the module directly; if you want to @@ -29,7 +26,6 @@ To do just the former: - .. function:: compile_command(source[, filename[, symbol]]) Tries to compile *source*, which should be a string of Python code and return a Modified: python/branches/py3k/Doc/library/collections.rst ============================================================================== --- python/branches/py3k/Doc/library/collections.rst (original) +++ python/branches/py3k/Doc/library/collections.rst Mon Dec 31 17:14:33 2007 @@ -100,7 +100,7 @@ where only the most recent activity is of interest. .. versionchanged:: 2.6 - Added *maxlen* + Added *maxlen* parameter. Deque objects support the following methods: Modified: python/branches/py3k/Doc/library/configparser.rst ============================================================================== --- python/branches/py3k/Doc/library/configparser.rst (original) +++ python/branches/py3k/Doc/library/configparser.rst Mon Dec 31 17:14:33 2007 @@ -87,7 +87,7 @@ well. New applications should prefer this version if they don't need to be compatible with older versions of Python. - .. % XXX Need to explain what's safer/more predictable about it. + .. XXX Need to explain what's safer/more predictable about it. .. exception:: NoSectionError Modified: python/branches/py3k/Doc/library/constants.rst ============================================================================== --- python/branches/py3k/Doc/library/constants.rst (original) +++ python/branches/py3k/Doc/library/constants.rst Mon Dec 31 17:14:33 2007 @@ -15,19 +15,21 @@ .. data:: False - The false value of the :class:`bool` type. + The false value of the :class:`bool` type. Assignments to ``False`` + are illegal and raise a :exc:`SyntaxError`. .. data:: True - The true value of the :class:`bool` type. + The true value of the :class:`bool` type. Assignments to ``True`` + are illegal and raise a :exc:`SyntaxError`. .. data:: None The sole value of :attr:`types.NoneType`. ``None`` is frequently used to represent the absence of a value, as when default arguments are not passed to a - function. + function. Assignments to ``None`` are illegal and raise a :exc:`SyntaxError`. .. data:: NotImplemented @@ -42,11 +44,11 @@ The same as ``...``. Special value used mostly in conjunction with extended slicing syntax for user-defined container data types, as in :: - val = container[1:5, 7:10, ...] + .. XXX Someone who understands extended slicing should fill in here. .. data:: __debug__ - A boolean value that is :data:`True` if Python was not started with the - ``-O`` command line option. Its value is used indirectly by the - :keyword:`assert` statement, but it can also be used directly in code. + This constant is true if Python was not started with an :option:`-O` option. + Assignments to :const:`__debug__` are illegal and raise a :exc:`SyntaxError`. + See also the :keyword:`assert` statement. Modified: python/branches/py3k/Doc/library/copy.rst ============================================================================== --- python/branches/py3k/Doc/library/copy.rst (original) +++ python/branches/py3k/Doc/library/copy.rst Mon Dec 31 17:14:33 2007 @@ -21,8 +21,6 @@ For module specific errors, :exc:`copy.error` is raised. -.. % - The difference between shallow and deep copying is only relevant for compound objects (objects that contain other objects, like lists or class instances): Modified: python/branches/py3k/Doc/library/ctypes.rst ============================================================================== --- python/branches/py3k/Doc/library/ctypes.rst (original) +++ python/branches/py3k/Doc/library/ctypes.rst Mon Dec 31 17:14:33 2007 @@ -69,7 +69,7 @@ >>> -.. % XXX Add section for Mac OS X. +.. XXX Add section for Mac OS X. .. _ctypes-accessing-functions-from-loaded-dlls: @@ -1256,10 +1256,6 @@ ``long double`` is not implemented. -.. % Local Variables: -.. % compile-command: "make.bat" -.. % End: - .. _ctypes-ctypes-reference: Modified: python/branches/py3k/Doc/library/curses.rst ============================================================================== --- python/branches/py3k/Doc/library/curses.rst (original) +++ python/branches/py3k/Doc/library/curses.rst Mon Dec 31 17:14:33 2007 @@ -1167,7 +1167,7 @@ Keys are referred to by integer constants with names starting with ``KEY_``. The exact keycaps available are system dependent. -.. % XXX should this table be alphabetized? +.. XXX this table is far too large! should it be alphabetized? +-------------------+--------------------------------------------+ | Key constant | Key | Modified: python/branches/py3k/Doc/library/datetime.rst ============================================================================== --- python/branches/py3k/Doc/library/datetime.rst (original) +++ python/branches/py3k/Doc/library/datetime.rst Mon Dec 31 17:14:33 2007 @@ -1,6 +1,3 @@ -.. % XXX what order should the types be discussed in? - - :mod:`datetime` --- Basic date and time types ============================================= @@ -10,6 +7,7 @@ .. sectionauthor:: Tim Peters .. sectionauthor:: A.M. Kuchling +.. XXX what order should the types be discussed in? The :mod:`datetime` module supplies classes for manipulating dates and times in both simple and complex ways. While date and time arithmetic is supported, the @@ -202,7 +200,7 @@ Supported operations: -.. % XXX this table is too wide! +.. XXX this table is too wide! +--------------------------------+-----------------------------------------------+ | Operation | Result | Modified: python/branches/py3k/Doc/library/decimal.rst ============================================================================== --- python/branches/py3k/Doc/library/decimal.rst (original) +++ python/branches/py3k/Doc/library/decimal.rst Mon Dec 31 17:14:33 2007 @@ -88,7 +88,7 @@ * IEEE standard 854-1987, `Unofficial IEEE 854 Text `_. -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-tutorial: @@ -263,7 +263,7 @@ the program manipulates the data no differently than with other Python numeric types. -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-decimal: @@ -274,7 +274,7 @@ .. class:: Decimal([value [, context]]) - Constructs a new :class:`Decimal` object based from *value*. + Construct a new :class:`Decimal` object based from *value*. *value* can be an integer, string, tuple, or another :class:`Decimal` object. If no *value* is given, returns ``Decimal("0")``. If *value* is a string, it @@ -512,7 +512,7 @@ correctly rounded using the :const:`ROUND_HALF_EVEN` rounding mode. -.. method: Decimal.logb([context]) +.. method:: Decimal.logb([context]) For a nonzero number, return the adjusted exponent of its operand as a :class:`Decimal` instance. If the operand is a zero then @@ -624,7 +624,7 @@ .. method:: Decimal.quantize(exp[, rounding[, context[, watchexp]]]) - Returns a value equal to the first operand after rounding and + Return a value equal to the first operand after rounding and having the exponent of the second operand. >>> Decimal("1.41421356").quantize(Decimal("1.000")) @@ -645,8 +645,8 @@ the given ``context`` argument; if neither argument is given the rounding mode of the current thread's context is used. - If watchexp is set (default), then an error is returned whenever - the resulting exponent is greater than Emax or less than Etiny. + If *watchexp* is set (default), then an error is returned whenever the + resulting exponent is greater than :attr:`Emax` or less than :attr:`Etiny`. .. method:: Decimal.radix() @@ -657,7 +657,7 @@ .. method:: Decimal.remainder_near(other[, context]) - Computes the modulo as either a positive or negative value depending on which is + Compute the modulo as either a positive or negative value depending on which is closest to zero. For instance, ``Decimal(10).remainder_near(6)`` returns ``Decimal("-2")`` which is closer to zero than ``Decimal("4")``. @@ -720,7 +720,7 @@ .. method:: Decimal.to_integral_exact([rounding[, context]]) - Round the argument to the nearest integer, signaling + Round to the nearest integer, signaling :const:`Inexact` or :const:`Rounded` as appropriate if rounding occurs. The rounding mode is determined by the ``rounding`` parameter if given, else by the given ``context``. If neither @@ -730,14 +730,14 @@ .. method:: Decimal.to_integral_value([rounding[, context]]) - Rounds to the nearest integer without signaling :const:`Inexact` or + Round to the nearest integer without signaling :const:`Inexact` or :const:`Rounded`. If given, applies *rounding*; otherwise, uses the rounding method in either the supplied *context* or the current context. .. method:: Decimal.trim() - Returns its argument with *insignificant* trailing zeros removed. + Return the decimal with *insignificant* trailing zeros removed. Here, a trailing zero is considered insignificant either if it follows the decimal point, or if the exponent of the argument (that is, the last element of the :meth:`as_tuple` representation) is @@ -755,7 +755,7 @@ exponent and sign are both zero, and whose digits are all either :const:`0` or :const:`1`. -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-context: @@ -1023,7 +1023,7 @@ Converts a number to a string using scientific notation. -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-signals: @@ -1144,7 +1144,7 @@ Rounded Subnormal -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-notes: @@ -1241,7 +1241,7 @@ >>> 1 / Decimal('Infinity') Decimal("0E-1000000026") -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-threads: @@ -1279,7 +1279,7 @@ t3.start() . . . -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-recipes: @@ -1435,7 +1435,7 @@ return +s -.. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +.. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. _decimal-faq: Modified: python/branches/py3k/Doc/library/difflib.rst ============================================================================== --- python/branches/py3k/Doc/library/difflib.rst (original) +++ python/branches/py3k/Doc/library/difflib.rst Mon Dec 31 17:14:33 2007 @@ -6,9 +6,9 @@ :synopsis: Helpers for computing differences between objects. .. moduleauthor:: Tim Peters .. sectionauthor:: Tim Peters +.. Markup by Fred L. Drake, Jr. -.. % LaTeXification by Fred L. Drake, Jr. . This module provides classes and functions for comparing sequences. It can be used for example, for comparing files, and can produce difference @@ -378,6 +378,12 @@ then ``i+n != i'`` or ``j+n != j'``; in other words, adjacent triples always describe non-adjacent equal blocks. + .. XXX Explain why a dummy is used! + + .. versionchanged:: 2.5 + The guarantee that adjacent triples always describe non-adjacent blocks was + implemented. + :: >>> s = SequenceMatcher(None, "abxcd", "abcd") Modified: python/branches/py3k/Doc/library/dis.rst ============================================================================== --- python/branches/py3k/Doc/library/dis.rst (original) +++ python/branches/py3k/Doc/library/dis.rst Mon Dec 31 17:14:33 2007 @@ -452,13 +452,6 @@ Unpacks TOS into *count* individual values, which are put onto the stack right-to-left. -.. % \begin{opcodedesc}{UNPACK_LIST}{count} -.. % This opcode is obsolete. -.. % \end{opcodedesc} -.. % \begin{opcodedesc}{UNPACK_ARG}{count} -.. % This opcode is obsolete. -.. % \end{opcodedesc} - .. opcode:: DUP_TOPX (count) @@ -486,10 +479,6 @@ Works as ``DELETE_NAME``, but deletes a global name. -.. % \begin{opcodedesc}{UNPACK_VARARG}{argc} -.. % This opcode is obsolete. -.. % \end{opcodedesc} - .. opcode:: LOAD_CONST (consti) @@ -577,22 +566,11 @@ the iterator indicates it is exhausted ``TOS`` is popped, and the byte code counter is incremented by *delta*. -.. % \begin{opcodedesc}{FOR_LOOP}{delta} -.. % This opcode is obsolete. -.. % \end{opcodedesc} -.. % \begin{opcodedesc}{LOAD_LOCAL}{namei} -.. % This opcode is obsolete. -.. % \end{opcodedesc} - .. opcode:: LOAD_GLOBAL (namei) Loads the global named ``co_names[namei]`` onto the stack. -.. % \begin{opcodedesc}{SET_FUNC_ARGS}{argc} -.. % This opcode is obsolete. -.. % \end{opcodedesc} - .. opcode:: SETUP_LOOP (delta) @@ -690,7 +668,7 @@ Pushes a slice object on the stack. *argc* must be 2 or 3. If it is 2, ``slice(TOS1, TOS)`` is pushed; if it is 3, ``slice(TOS2, TOS1, TOS)`` is - pushed. See the ``slice()`` built-in function for more information. + pushed. See the :func:`slice` built-in function for more information. .. opcode:: EXTENDED_ARG (ext) Modified: python/branches/py3k/Doc/library/dl.rst ============================================================================== --- python/branches/py3k/Doc/library/dl.rst (original) +++ python/branches/py3k/Doc/library/dl.rst Mon Dec 31 17:14:33 2007 @@ -7,9 +7,6 @@ :synopsis: Call C functions in shared objects. .. sectionauthor:: Moshe Zadka - -.. % ?????????? Anyone???????????? - The :mod:`dl` module defines an interface to the :cfunc:`dlopen` function, which is the most common interface on Unix platforms for handling dynamically linked libraries. It allows the program to call arbitrary functions in such a library. Modified: python/branches/py3k/Doc/library/doctest.rst ============================================================================== --- python/branches/py3k/Doc/library/doctest.rst (original) +++ python/branches/py3k/Doc/library/doctest.rst Mon Dec 31 17:14:33 2007 @@ -691,12 +691,7 @@ surprise you a few times, as you learn exactly what Python does and doesn't guarantee about output. For example, when printing a dict, Python doesn't guarantee that the key-value pairs will be printed in any particular order, so a -test like - -.. % Hey! What happened to Monty Python examples? -.. % Tim: ask Guido -- it's his example! - -:: +test like :: >>> foo() {"Hermione": "hippogryph", "Harry": "broomstick"} Modified: python/branches/py3k/Doc/library/email.rst ============================================================================== --- python/branches/py3k/Doc/library/email.rst (original) +++ python/branches/py3k/Doc/library/email.rst Mon Dec 31 17:14:33 2007 @@ -1,7 +1,3 @@ -.. % Copyright (C) 2001-2007 Python Software Foundation -.. % Author: barry at python.org (Barry Warsaw) - - :mod:`email` --- An email and MIME handling package =================================================== @@ -10,6 +6,7 @@ including MIME documents. .. moduleauthor:: Barry A. Warsaw .. sectionauthor:: Barry A. Warsaw +.. Copyright (C) 2001-2007 Python Software Foundation The :mod:`email` package is a library for managing email messages, including Modified: python/branches/py3k/Doc/library/exceptions.rst ============================================================================== --- python/branches/py3k/Doc/library/exceptions.rst (original) +++ python/branches/py3k/Doc/library/exceptions.rst Mon Dec 31 17:14:33 2007 @@ -111,16 +111,15 @@ .. exception:: AttributeError - Raised when an attribute reference or assignment fails. (When an object does - not support attribute references or attribute assignments at all, - :exc:`TypeError` is raised.) - - .. % xref to attribute reference? + Raised when an attribute reference (see :ref:`attribute-references`) or + assignment fails. (When an object does not support attribute references or + attribute assignments at all, :exc:`TypeError` is raised.) .. exception:: EOFError - Raised when attempting to read beyond the end of a file. (N.B.: the + Raised when one of the built-in functions (:func:`input` or :func:`raw_input`) + hits an end-of-file condition (EOF) without reading any data. (N.B.: the :meth:`file.read` and :meth:`file.readline` methods return an empty string when they hit EOF.) @@ -162,14 +161,14 @@ truncated to fall in the allowed range; if an index is not a plain integer, :exc:`TypeError` is raised.) - .. % XXXJH xref to sequences + .. XXX xref to sequences .. exception:: KeyError Raised when a mapping (dictionary) key is not found in the set of existing keys. - .. % XXXJH xref to mapping objects? + .. XXX xref to mapping objects? .. exception:: KeyboardInterrupt Modified: python/branches/py3k/Doc/library/functions.rst ============================================================================== --- python/branches/py3k/Doc/library/functions.rst (original) +++ python/branches/py3k/Doc/library/functions.rst Mon Dec 31 17:14:33 2007 @@ -28,7 +28,7 @@ :func:`__import__` function. For example, the statement ``import spam`` results in the following call: - ``__import__('spam',`` ``globals(),`` ``locals(), [], -1)``; the statement + ``__import__('spam', globals(), locals(), [], -1)``; the statement ``from spam.ham import eggs`` results in ``__import__('spam.ham', globals(), locals(), ['eggs'], -1)``. Note that even though ``locals()`` and ``['eggs']`` are passed in as arguments, the :func:`__import__` function does not set the @@ -359,7 +359,7 @@ access to the standard :mod:`builtins` module and restricted environments are propagated. If the *locals* dictionary is omitted it defaults to the *globals* dictionary. If both dictionaries are omitted, the expression is executed in the - environment where :keyword:`eval` is called. The return value is the result of + environment where :func:`eval` is called. The return value is the result of the evaluated expression. Syntax errors are reported as exceptions. Example:: >>> x = 1 @@ -632,7 +632,7 @@ The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. - Free variables are returned by *locals* when it is called in a function block. + Free variables are returned by :func:`locals` when it is called in a function block. Modifications of free variables may not affect the values used by the interpreter. Free variables are not returned in class blocks. Modified: python/branches/py3k/Doc/library/gensuitemodule.rst ============================================================================== --- python/branches/py3k/Doc/library/gensuitemodule.rst (original) +++ python/branches/py3k/Doc/library/gensuitemodule.rst Mon Dec 31 17:14:33 2007 @@ -6,9 +6,7 @@ :platform: Mac :synopsis: Create a stub package from an OSA dictionary .. sectionauthor:: Jack Jansen - - -.. % \moduleauthor{Jack Jansen?}{email} +.. moduleauthor:: Jack Jansen The :mod:`gensuitemodule` module creates a Python package implementing stub code for the AppleScript suites that are implemented by a specific application, Modified: python/branches/py3k/Doc/library/getopt.rst ============================================================================== --- python/branches/py3k/Doc/library/getopt.rst (original) +++ python/branches/py3k/Doc/library/getopt.rst Mon Dec 31 17:14:33 2007 @@ -9,7 +9,7 @@ This module helps scripts to parse the command line arguments in ``sys.argv``. It supports the same conventions as the Unix :cfunc:`getopt` function (including -the special meanings of arguments of the form '``-``' and '``--``'). Long +the special meanings of arguments of the form '``-``' and '``--``'). Long options similar to those supported by GNU software may be used as well via an optional third argument. This module provides a single function and an exception: Modified: python/branches/py3k/Doc/library/getpass.rst ============================================================================== --- python/branches/py3k/Doc/library/getpass.rst (original) +++ python/branches/py3k/Doc/library/getpass.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`getpass` --- Portable password input ========================================== @@ -6,9 +5,7 @@ :synopsis: Portable reading of passwords and retrieval of the userid. .. moduleauthor:: Piers Lauder .. sectionauthor:: Fred L. Drake, Jr. - - -.. % Windows (& Mac?) support by Guido van Rossum. +.. Windows (& Mac?) support by Guido van Rossum. The :mod:`getpass` module provides two functions: Modified: python/branches/py3k/Doc/library/heapq.rst ============================================================================== --- python/branches/py3k/Doc/library/heapq.rst (original) +++ python/branches/py3k/Doc/library/heapq.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`heapq` --- Heap queue algorithm ===================================== @@ -8,9 +7,6 @@ .. sectionauthor:: Guido van Rossum .. sectionauthor:: Fran?ois Pinard - -.. % Theoretical explanation: - This module provides an implementation of the heap queue algorithm, also known as the priority queue algorithm. Modified: python/branches/py3k/Doc/library/idle.rst ============================================================================== --- python/branches/py3k/Doc/library/idle.rst (original) +++ python/branches/py3k/Doc/library/idle.rst Mon Dec 31 17:14:33 2007 @@ -1,20 +1,16 @@ .. _idle: -Idle +IDLE ==== .. moduleauthor:: Guido van Rossum - -.. % \declaremodule{standard}{idle} -.. % \modulesynopsis{A Python Integrated Development Environment} - .. index:: - single: Idle + single: IDLE single: Python Editor single: Integrated Development Environment -Idle is the Python IDE built with the :mod:`Tkinter` GUI toolkit. +IDLE is the Python IDE built with the :mod:`Tkinter` GUI toolkit. IDLE has the following features: Modified: python/branches/py3k/Doc/library/imaplib.rst ============================================================================== --- python/branches/py3k/Doc/library/imaplib.rst (original) +++ python/branches/py3k/Doc/library/imaplib.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`imaplib` --- IMAP4 protocol client ======================================== @@ -6,6 +5,10 @@ :synopsis: IMAP4 protocol client (requires sockets). .. moduleauthor:: Piers Lauder .. sectionauthor:: Piers Lauder +.. revised by ESR, January 2000 +.. changes for IMAP4_SSL by Tino Lange , March 2002 +.. changes for IMAP4_stream by Piers Lauder , + November 2002 .. index:: @@ -13,14 +16,6 @@ pair: IMAP4_SSL; protocol pair: IMAP4_stream; protocol -.. % Based on HTML documentation by Piers Lauder -.. % ; -.. % converted by Fred L. Drake, Jr. . -.. % Revised by ESR, January 2000. -.. % Changes for IMAP4_SSL by Tino Lange , March 2002 -.. % Changes for IMAP4_stream by Piers Lauder -.. % , November 2002 - This module defines three classes, :class:`IMAP4`, :class:`IMAP4_SSL` and :class:`IMAP4_stream`, which encapsulate a connection to an IMAP4 server and implement a large subset of the IMAP4rev1 client protocol as defined in Modified: python/branches/py3k/Doc/library/itertools.rst ============================================================================== --- python/branches/py3k/Doc/library/itertools.rst (original) +++ python/branches/py3k/Doc/library/itertools.rst Mon Dec 31 17:14:33 2007 @@ -157,7 +157,7 @@ key = lambda x: x self.keyfunc = key self.it = iter(iterable) - self.tgtkey = self.currkey = self.currvalue = [] + self.tgtkey = self.currkey = self.currvalue = object() def __iter__(self): return self def __next__(self): @@ -350,14 +350,13 @@ is equivalent to:: def tee(iterable): - def gen(next, data={}, cnt=[0]): + def gen(next, data={}): for i in count(): - if i == cnt[0]: - item = data[i] = next() - cnt[0] += 1 + if i in data: + yield data.pop(i) else: - item = data.pop(i) - yield item + data[i] = next() + yield data[i] it = iter(iterable) return (gen(it.__next__), gen(it.__next__)) Modified: python/branches/py3k/Doc/library/logging.rst ============================================================================== --- python/branches/py3k/Doc/library/logging.rst (original) +++ python/branches/py3k/Doc/library/logging.rst Mon Dec 31 17:14:33 2007 @@ -2019,8 +2019,6 @@ Configuration functions ^^^^^^^^^^^^^^^^^^^^^^^ -.. % - The following functions configure the logging module. They are located in the :mod:`logging.config` module. Their use is optional --- you can configure the logging module using these functions or by making calls to the main API (defined @@ -2204,13 +2202,12 @@ class=logging.Formatter The ``format`` entry is the overall format string, and the ``datefmt`` entry is -the :func:`strftime`\ -compatible date/time format string. If empty, the package -substitutes ISO8601 format date/times, which is almost equivalent to specifying -the date format string "The ISO8601 format also specifies milliseconds, which -are appended to the result of using the above format string, with a comma -separator. An example time in ISO8601 format is ``2003-01-23 00:29:50,411``. - -.. % Y-%m-%d %H:%M:%S". +the :func:`strftime`\ -compatible date/time format string. If empty, the +package substitutes ISO8601 format date/times, which is almost equivalent to +specifying the date format string ``"%Y-%m-%d %H:%M:%S"``. The ISO8601 format +also specifies milliseconds, which are appended to the result of using the above +format string, with a comma separator. An example time in ISO8601 format is +``2003-01-23 00:29:50,411``. The ``class`` entry is optional. It indicates the name of the formatter's class (as a dotted module and class name.) This option is useful for instantiating a Modified: python/branches/py3k/Doc/library/mhlib.rst ============================================================================== --- python/branches/py3k/Doc/library/mhlib.rst (original) +++ python/branches/py3k/Doc/library/mhlib.rst Mon Dec 31 17:14:33 2007 @@ -1,13 +1,9 @@ - :mod:`mhlib` --- Access to MH mailboxes ======================================= .. module:: mhlib :synopsis: Manipulate MH mailboxes from Python. - - -.. % LaTeX'ized from the comments in the module by Skip Montanaro -.. % . +.. sectionauthor:: Skip Montanaro The :mod:`mhlib` module provides a Python interface to MH folders and their contents. Modified: python/branches/py3k/Doc/library/nntplib.rst ============================================================================== --- python/branches/py3k/Doc/library/nntplib.rst (original) +++ python/branches/py3k/Doc/library/nntplib.rst Mon Dec 31 17:14:33 2007 @@ -309,8 +309,6 @@ is supplied, then the returned *list* is an empty list. This is an optional NNTP extension, and may not be supported by all servers. - .. % XXX huh? Should that be (name, description)? - RFC2980 says "It is suggested that this extension be deprecated". Use :meth:`descriptions` or :meth:`description` instead. Modified: python/branches/py3k/Doc/library/optparse.rst ============================================================================== --- python/branches/py3k/Doc/library/optparse.rst (original) +++ python/branches/py3k/Doc/library/optparse.rst Mon Dec 31 17:14:33 2007 @@ -1,7 +1,3 @@ -.. % THIS FILE IS AUTO-GENERATED! DO NOT EDIT! -.. % (Your changes will be lost the next time it is generated.) - - :mod:`optparse` --- More powerful command line option parser ============================================================ @@ -18,9 +14,6 @@ to specify options in the conventional GNU/POSIX syntax, and additionally generates usage and help messages for you. -.. % An intro blurb used only when generating LaTeX docs for the Python -.. % manual (based on README.txt). - Here's an example of using ``optparse`` in a simple script:: from optparse import OptionParser @@ -70,8 +63,6 @@ where the value of *yourscript* is determined at runtime (normally from ``sys.argv[0]``). -.. % $Id: intro.txt 413 2004-09-28 00:59:13Z greg $ - .. _optparse-background: @@ -233,8 +224,6 @@ implementation becomes. Too much flexibility has drawbacks as well, of course; too many options can overwhelm users and make your code much harder to maintain. -.. % $Id: tao.txt 413 2004-09-28 00:59:13Z greg $ - .. _optparse-tutorial: @@ -652,8 +641,6 @@ if __name__ == "__main__": main() -.. % $Id: tutorial.txt 515 2006-06-10 15:37:45Z gward $ - .. _optparse-reference-guide: @@ -1329,8 +1316,6 @@ parser.add_option("--novice", action="store_const", dest="mode", const="novice") -.. % $Id: reference.txt 519 2006-06-11 14:39:11Z gward $ - .. _optparse-option-callbacks: @@ -1626,8 +1611,6 @@ (probably causing an error), rather than as arguments to ``"-c"``. Fixing this is left as an exercise for the reader. -.. % $Id: callbacks.txt 415 2004-09-30 02:26:17Z greg $ - .. _optparse-extending-optparse: @@ -1818,6 +1801,3 @@ about setting a default value for the option destinations in question; they can just leave the default as None and :meth:`ensure_value` will take care of getting it right when it's needed. - -.. % $Id: extending.txt 517 2006-06-10 16:18:11Z gward $ - Modified: python/branches/py3k/Doc/library/os.rst ============================================================================== --- python/branches/py3k/Doc/library/os.rst (original) +++ python/branches/py3k/Doc/library/os.rst Mon Dec 31 17:14:33 2007 @@ -291,9 +291,8 @@ Set the current process' user id. Availability: Unix. -.. % placed in this section since it relates to errno.... a little weak - +.. placed in this section since it relates to errno.... a little weak .. function:: strerror(code) Return the error message corresponding to the error code in *code*. Modified: python/branches/py3k/Doc/library/ossaudiodev.rst ============================================================================== --- python/branches/py3k/Doc/library/ossaudiodev.rst (original) +++ python/branches/py3k/Doc/library/ossaudiodev.rst Mon Dec 31 17:14:33 2007 @@ -11,33 +11,33 @@ OSS is available for a wide range of open-source and commercial Unices, and is the standard audio interface for Linux and recent versions of FreeBSD. -.. % Things will get more complicated for future Linux versions, since -.. % ALSA is in the standard kernel as of 2.5.x. Presumably if you -.. % use ALSA, you'll have to make sure its OSS compatibility layer -.. % is active to use ossaudiodev, but you're gonna need it for the vast -.. % majority of Linux audio apps anyways. -.. % -.. % Sounds like things are also complicated for other BSDs. In response -.. % to my python-dev query, Thomas Wouters said: -.. % -.. % > Likewise, googling shows OpenBSD also uses OSS/Free -- the commercial -.. % > OSS installation manual tells you to remove references to OSS/Free from the -.. % > kernel :) -.. % -.. % but Aleksander Piotrowsk actually has an OpenBSD box, and he quotes -.. % from its : -.. % > * WARNING! WARNING! -.. % > * This is an OSS (Linux) audio emulator. -.. % > * Use the Native NetBSD API for developing new code, and this -.. % > * only for compiling Linux programs. -.. % -.. % There's also an ossaudio manpage on OpenBSD that explains things -.. % further. Presumably NetBSD and OpenBSD have a different standard -.. % audio interface. That's the great thing about standards, there are so -.. % many to choose from ... ;-) -.. % -.. % This probably all warrants a footnote or two, but I don't understand -.. % things well enough right now to write it! --GPW +.. Things will get more complicated for future Linux versions, since + ALSA is in the standard kernel as of 2.5.x. Presumably if you + use ALSA, you'll have to make sure its OSS compatibility layer + is active to use ossaudiodev, but you're gonna need it for the vast + majority of Linux audio apps anyways. + + Sounds like things are also complicated for other BSDs. In response + to my python-dev query, Thomas Wouters said: + + > Likewise, googling shows OpenBSD also uses OSS/Free -- the commercial + > OSS installation manual tells you to remove references to OSS/Free from the + > kernel :) + + but Aleksander Piotrowsk actually has an OpenBSD box, and he quotes + from its : + > * WARNING! WARNING! + > * This is an OSS (Linux) audio emulator. + > * Use the Native NetBSD API for developing new code, and this + > * only for compiling Linux programs. + + There's also an ossaudio manpage on OpenBSD that explains things + further. Presumably NetBSD and OpenBSD have a different standard + audio interface. That's the great thing about standards, there are so + many to choose from ... ;-) + + This probably all warrants a footnote or two, but I don't understand + things well enough right now to write it! --GPW .. seealso:: @@ -87,6 +87,10 @@ second is required. This is a historical artifact for compatibility with the older :mod:`linuxaudiodev` module which :mod:`ossaudiodev` supersedes. + .. XXX it might also be motivated + by my unfounded-but-still-possibly-true belief that the default + audio device varies unpredictably across operating systems. -GW + .. function:: openmixer([device]) Modified: python/branches/py3k/Doc/library/othergui.rst ============================================================================== --- python/branches/py3k/Doc/library/othergui.rst (original) +++ python/branches/py3k/Doc/library/othergui.rst Mon Dec 31 17:14:33 2007 @@ -5,7 +5,6 @@ There are an number of extension widget sets to :mod:`Tkinter`. - .. seealso:: `Python megawidgets `_ @@ -29,12 +28,10 @@ since they can operate directly on Python data structures, without having to transfer data through the Tk/Tcl layer. - .. % The major cross-platform (Windows, Mac OS X, Unix-like) GUI toolkits that are also available for Python: - .. seealso:: `PyGTK `_ Modified: python/branches/py3k/Doc/library/parser.rst ============================================================================== --- python/branches/py3k/Doc/library/parser.rst (original) +++ python/branches/py3k/Doc/library/parser.rst Mon Dec 31 17:14:33 2007 @@ -8,13 +8,12 @@ .. sectionauthor:: Fred L. Drake, Jr. -.. % Copyright 1995 Virginia Polytechnic Institute and State University -.. % and Fred L. Drake, Jr. This copyright notice must be distributed on -.. % all copies, but this document otherwise may be distributed as part -.. % of the Python distribution. No fee may be charged for this document -.. % in any representation, either on paper or electronically. This -.. % restriction does not affect other elements in a distributed package -.. % in any way. +.. Copyright 1995 Virginia Polytechnic Institute and State University and Fred + L. Drake, Jr. This copyright notice must be distributed on all copies, but + this document otherwise may be distributed as part of the Python + distribution. No fee may be charged for this document in any representation, + either on paper or electronically. This restriction does not affect other + elements in a distributed package in any way. .. index:: single: parsing; Python source code Modified: python/branches/py3k/Doc/library/pickle.rst ============================================================================== --- python/branches/py3k/Doc/library/pickle.rst (original) +++ python/branches/py3k/Doc/library/pickle.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`pickle` --- Python object serialization ============================================= @@ -12,10 +11,8 @@ .. module:: pickle :synopsis: Convert Python objects to streams of bytes and back. - - -.. % Substantial improvements by Jim Kerr . -.. % Rewritten by Barry Warsaw +.. sectionauthor:: Jim Kerr . +.. sectionauthor:: Barry Warsaw The :mod:`pickle` module implements a fundamental, but powerful algorithm for serializing and de-serializing a Python object structure. "Pickling" is the @@ -607,10 +604,10 @@ [#]_ Setting :attr:`persistent_load` to a list is usually used in conjunction with the :meth:`noload` method on the Unpickler. -.. % BAW: Both pickle and cPickle support something called -.. % inst_persistent_id() which appears to give unknown types a second -.. % shot at producing a persistent id. Since Jim Fulton can't remember -.. % why it was added or what it's for, I'm leaving it undocumented. +.. BAW: Both pickle and cPickle support something called inst_persistent_id() + which appears to give unknown types a second shot at producing a persistent + id. Since Jim Fulton can't remember why it was added or what it's for, I'm + leaving it undocumented. .. _pickle-sub: Modified: python/branches/py3k/Doc/library/platform.rst ============================================================================== --- python/branches/py3k/Doc/library/platform.rst (original) +++ python/branches/py3k/Doc/library/platform.rst Mon Dec 31 17:14:33 2007 @@ -194,16 +194,12 @@ Win95/98 specific ^^^^^^^^^^^^^^^^^ - .. function:: popen(cmd, mode='r', bufsize=None) Portable :func:`popen` interface. Find a working popen implementation preferring :func:`win32pipe.popen`. On Windows NT, :func:`win32pipe.popen` should work; on Windows 9x it hangs due to bugs in the MS C library. - .. % This KnowledgeBase article appears to be missing... - .. % See also \ulink{MS KnowledgeBase article Q150956}{}. - Mac OS Platform --------------- @@ -231,7 +227,7 @@ Tries to determine the name of the OS distribution name Returns a tuple ``(distname, version, id)`` which defaults to the args given as parameters. -.. % Document linux_distribution()? +.. XXX Document linux_distribution()? .. function:: libc_ver(executable=sys.executable, lib='', version='', chunksize=2048) Modified: python/branches/py3k/Doc/library/poplib.rst ============================================================================== --- python/branches/py3k/Doc/library/poplib.rst (original) +++ python/branches/py3k/Doc/library/poplib.rst Mon Dec 31 17:14:33 2007 @@ -4,16 +4,11 @@ .. module:: poplib :synopsis: POP3 protocol client (requires sockets). - +.. sectionauthor:: Andrew T. Csillag +.. revised by ESR, January 2000 .. index:: pair: POP3; protocol -.. % By Andrew T. Csillag -.. % Even though I put it into LaTeX, I cannot really claim that I wrote -.. % it since I just stole most of it from the poplib.py source code and -.. % the imaplib ``chapter''. -.. % Revised by ESR, January 2000 - This module defines a class, :class:`POP3`, which encapsulates a connection to a POP3 server and implements the protocol as defined in :rfc:`1725`. The :class:`POP3` class supports both the minimal and optional command sets. Modified: python/branches/py3k/Doc/library/pprint.rst ============================================================================== --- python/branches/py3k/Doc/library/pprint.rst (original) +++ python/branches/py3k/Doc/library/pprint.rst Mon Dec 31 17:14:33 2007 @@ -24,7 +24,7 @@ The :mod:`pprint` module defines one class: -.. % First the implementation class: +.. First the implementation class: .. class:: PrettyPrinter(...) @@ -65,8 +65,7 @@ The :class:`PrettyPrinter` class supports several derivative functions: -.. % Now the derivative functions: - +.. Now the derivative functions: .. function:: pformat(object[, indent[, width[, depth]]]) @@ -123,9 +122,6 @@ recursive reference will be represented as ````. The representation is not otherwise formatted. -.. % This example is outside the {funcdesc} to keep it from running over -.. % the right margin. - :: >>> pprint.saferepr(stuff) Modified: python/branches/py3k/Doc/library/profile.rst ============================================================================== --- python/branches/py3k/Doc/library/profile.rst (original) +++ python/branches/py3k/Doc/library/profile.rst Mon Dec 31 17:14:33 2007 @@ -72,47 +72,47 @@ :mod:`cProfile` is really a compatibility layer on top of the internal :mod:`_lsprof` module. -.. % \section{How Is This Profiler Different From The Old Profiler?} -.. % \nodename{Profiler Changes} -.. % -.. % (This section is of historical importance only; the old profiler -.. % discussed here was last seen in Python 1.1.) -.. % -.. % The big changes from old profiling module are that you get more -.. % information, and you pay less CPU time. It's not a trade-off, it's a -.. % trade-up. -.. % -.. % To be specific: -.. % -.. % \begin{description} -.. % -.. % \item[Bugs removed:] -.. % Local stack frame is no longer molested, execution time is now charged -.. % to correct functions. -.. % -.. % \item[Accuracy increased:] -.. % Profiler execution time is no longer charged to user's code, -.. % calibration for platform is supported, file reads are not done \emph{by} -.. % profiler \emph{during} profiling (and charged to user's code!). -.. % -.. % \item[Speed increased:] -.. % Overhead CPU cost was reduced by more than a factor of two (perhaps a -.. % factor of five), lightweight profiler module is all that must be -.. % loaded, and the report generating module (\module{pstats}) is not needed -.. % during profiling. -.. % -.. % \item[Recursive functions support:] -.. % Cumulative times in recursive functions are correctly calculated; -.. % recursive entries are counted. -.. % -.. % \item[Large growth in report generating UI:] -.. % Distinct profiles runs can be added together forming a comprehensive -.. % report; functions that import statistics take arbitrary lists of -.. % files; sorting criteria is now based on keywords (instead of 4 integer -.. % options); reports shows what functions were profiled as well as what -.. % profile file was referenced; output format has been improved. -.. % -.. % \end{description} +.. \section{How Is This Profiler Different From The Old Profiler?} + \nodename{Profiler Changes} + + (This section is of historical importance only; the old profiler + discussed here was last seen in Python 1.1.) + + The big changes from old profiling module are that you get more + information, and you pay less CPU time. It's not a trade-off, it's a + trade-up. + + To be specific: + + \begin{description} + + \item[Bugs removed:] + Local stack frame is no longer molested, execution time is now charged + to correct functions. + + \item[Accuracy increased:] + Profiler execution time is no longer charged to user's code, + calibration for platform is supported, file reads are not done \emph{by} + profiler \emph{during} profiling (and charged to user's code!). + + \item[Speed increased:] + Overhead CPU cost was reduced by more than a factor of two (perhaps a + factor of five), lightweight profiler module is all that must be + loaded, and the report generating module (\module{pstats}) is not needed + during profiling. + + \item[Recursive functions support:] + Cumulative times in recursive functions are correctly calculated; + recursive entries are counted. + + \item[Large growth in report generating UI:] + Distinct profiles runs can be added together forming a comprehensive + report; functions that import statistics take arbitrary lists of + files; sorting criteria is now based on keywords (instead of 4 integer + options); reports shows what functions were profiled as well as what + profile file was referenced; output format has been improved. + + \end{description} .. _profile-instant: @@ -172,7 +172,7 @@ string that is printed. The third method printed out all the statistics. You might try the following sort calls: -.. % (this is to comply with the semantics of the old profiler). +.. (this is to comply with the semantics of the old profiler). :: @@ -363,6 +363,8 @@ a single report. If additional files need to be combined with data in an existing :class:`Stats` object, the :meth:`add` method can be used. + .. (such as the old system profiler). + .. _profile-stats: @@ -457,7 +459,7 @@ (numeric) is used, only one sort key (the numeric key) will be used, and additional arguments will be silently ignored. - .. % For compatibility with the old profiler, + .. For compatibility with the old profiler, .. method:: Stats.reverse_order() @@ -466,8 +468,7 @@ within the object. Note that by default ascending vs descending order is properly selected based on the sort key of choice. - .. % This method is provided primarily for - .. % compatibility with the old profiler. + .. This method is provided primarily for compatibility with the old profiler. .. method:: Stats.print_stats([restriction, ...]) Modified: python/branches/py3k/Doc/library/py_compile.rst ============================================================================== --- python/branches/py3k/Doc/library/py_compile.rst (original) +++ python/branches/py3k/Doc/library/py_compile.rst Mon Dec 31 17:14:33 2007 @@ -3,11 +3,8 @@ .. module:: py_compile :synopsis: Generate byte-code files from Python source files. - -.. % Documentation based on module docstrings, by Fred L. Drake, Jr. -.. % - - +.. sectionauthor:: Fred L. Drake, Jr. +.. documentation based on module docstrings .. index:: pair: file; byte-code Modified: python/branches/py3k/Doc/library/pyclbr.rst ============================================================================== --- python/branches/py3k/Doc/library/pyclbr.rst (original) +++ python/branches/py3k/Doc/library/pyclbr.rst Mon Dec 31 17:14:33 2007 @@ -24,7 +24,7 @@ be a sequence, and is used to augment the value of ``sys.path``, which is used to locate module source code. - .. % The 'inpackage' parameter appears to be for internal use only.... + .. The 'inpackage' parameter appears to be for internal use only.... .. function:: readmodule_ex(module[, path]) @@ -35,7 +35,7 @@ the key ``'__path__'`` in the returned dictionary has as its value a list which contains the package search path. - .. % The 'inpackage' parameter appears to be for internal use only.... + .. The 'inpackage' parameter appears to be for internal use only.... .. _pyclbr-class-objects: Modified: python/branches/py3k/Doc/library/pyexpat.rst ============================================================================== --- python/branches/py3k/Doc/library/pyexpat.rst (original) +++ python/branches/py3k/Doc/library/pyexpat.rst Mon Dec 31 17:14:33 2007 @@ -7,14 +7,13 @@ .. moduleauthor:: Paul Prescod -.. % Markup notes: -.. % -.. % Many of the attributes of the XMLParser objects are callbacks. -.. % Since signature information must be presented, these are described -.. % using the methoddesc environment. Since they are attributes which -.. % are set by client code, in-text references to these attributes -.. % should be marked using the \member macro and should not include the -.. % parentheses used when marking functions and methods. +.. Markup notes: + + Many of the attributes of the XMLParser objects are callbacks. Since + signature information must be presented, these are described using the method + directive. Since they are attributes which are set by client code, in-text + references to these attributes should be marked using the :member: role. + .. index:: single: Expat Modified: python/branches/py3k/Doc/library/re.rst ============================================================================== --- python/branches/py3k/Doc/library/re.rst (original) +++ python/branches/py3k/Doc/library/re.rst Mon Dec 31 17:14:33 2007 @@ -84,8 +84,6 @@ The special characters are: -.. % - ``'.'`` (Dot.) In the default mode, this matches any character except a newline. If the :const:`DOTALL` flag has been specified, this matches any character @@ -297,8 +295,6 @@ If the ordinary character is not on the list, then the resulting RE will match the second character. For example, ``\$`` matches the character ``'$'``. -.. % - ``\number`` Matches the contents of the group of the same number. Groups are numbered starting from 1. For example, ``(.+) \1`` matches ``'the the'`` or ``'55 55'``, @@ -384,9 +380,6 @@ a group reference. As for string literals, octal escapes are always at most three digits in length. -.. % Note the lack of a period in the section title; it causes problems -.. % with readers of the GNU info version. See http://www.python.org/sf/581414. - .. _matching-searching: @@ -406,15 +399,11 @@ :const:`MULTILINE` mode also immediately following a newline. The "match" operation succeeds only if the pattern matches at the start of the string regardless of mode, or at the starting position given by the optional *pos* -argument regardless of whether a newline precedes it. - -.. % Examples from Tim Peters: - -:: +argument regardless of whether a newline precedes it. :: >>> re.match("c", "abcdef") # No match >>> re.search("c", "abcdef") - <_sre.SRE_Match object at 0x827e9c0> # Match + <_sre.SRE_Match object at 0x827e9c0> # Match .. _contents-of-module-re: @@ -450,10 +439,9 @@ but the version using :func:`compile` is more efficient when the expression will be used several times in a single program. - .. % (The compiled version of the last pattern passed to - .. % \function{re.match()} or \function{re.search()} is cached, so - .. % programs that use only a single regular expression at a time needn't - .. % worry about compiling regular expressions.) + .. (The compiled version of the last pattern passed to :func:`re.match` or + :func:`re.search` is cached, so programs that use only a single regular + expression at a time needn't worry about compiling regular expressions.) .. data:: I Modified: python/branches/py3k/Doc/library/sched.rst ============================================================================== --- python/branches/py3k/Doc/library/sched.rst (original) +++ python/branches/py3k/Doc/library/sched.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`sched` --- Event scheduler ================================ @@ -6,9 +5,6 @@ :synopsis: General purpose event scheduler. .. sectionauthor:: Moshe Zadka - -.. % LaTeXed and enhanced from comments in file - .. index:: single: event scheduling The :mod:`sched` module defines a class which implements a general purpose event Modified: python/branches/py3k/Doc/library/select.rst ============================================================================== --- python/branches/py3k/Doc/library/select.rst (original) +++ python/branches/py3k/Doc/library/select.rst Mon Dec 31 17:14:33 2007 @@ -58,8 +58,6 @@ class yourself, as long as it has an appropriate :meth:`fileno` method (that really returns a file descriptor, not just a random integer). - .. % - .. note:: .. index:: single: WinSock Modified: python/branches/py3k/Doc/library/shutil.rst ============================================================================== --- python/branches/py3k/Doc/library/shutil.rst (original) +++ python/branches/py3k/Doc/library/shutil.rst Mon Dec 31 17:14:33 2007 @@ -5,9 +5,7 @@ .. module:: shutil :synopsis: High-level file operations, including copying. .. sectionauthor:: Fred L. Drake, Jr. - - -.. % partly based on the docstrings +.. partly based on the docstrings .. index:: single: file; copying Modified: python/branches/py3k/Doc/library/sndhdr.rst ============================================================================== --- python/branches/py3k/Doc/library/sndhdr.rst (original) +++ python/branches/py3k/Doc/library/sndhdr.rst Mon Dec 31 17:14:33 2007 @@ -5,9 +5,7 @@ .. module:: sndhdr :synopsis: Determine type of a sound file. .. sectionauthor:: Fred L. Drake, Jr. - - -.. % Based on comments in the module source file. +.. Based on comments in the module source file. .. index:: single: A-LAW Modified: python/branches/py3k/Doc/library/socket.rst ============================================================================== --- python/branches/py3k/Doc/library/socket.rst (original) +++ python/branches/py3k/Doc/library/socket.rst Mon Dec 31 17:14:33 2007 @@ -542,7 +542,7 @@ file object and socket object may be closed or garbage-collected independently. The socket must be in blocking mode (it can not have a timeout). The optional *mode* and *bufsize* arguments are interpreted the same way as by the built-in - :func:`file` function; see :ref:`built-in-funcs` for more information. + :func:`file` function. .. method:: socket.recv(bufsize[, flags]) Modified: python/branches/py3k/Doc/library/socketserver.rst ============================================================================== --- python/branches/py3k/Doc/library/socketserver.rst (original) +++ python/branches/py3k/Doc/library/socketserver.rst Mon Dec 31 17:14:33 2007 @@ -115,9 +115,8 @@ important for stream services where each client can potentially be connected for a long time (if threads or subprocesses cannot be used). -.. % XXX should data and methods be intermingled, or separate? -.. % how should the distinction between class and instance variables be -.. % drawn? +.. XXX should data and methods be intermingled, or separate? + how should the distinction between class and instance variables be drawn? Server Objects @@ -171,8 +170,7 @@ The server classes support the following class variables: -.. % XXX should class variables be covered before instance variables, or -.. % vice versa? +.. XXX should class variables be covered before instance variables, or vice versa? .. data:: allow_reuse_address @@ -199,8 +197,8 @@ server classes like :class:`TCPServer`; these methods aren't useful to external users of the server object. -.. % should the default implementations of these be documented, or should -.. % it be assumed that the user will look at SocketServer.py? +.. XXX should the default implementations of these be documented, or should + it be assumed that the user will look at SocketServer.py? .. function:: finish_request() @@ -230,9 +228,9 @@ or thread to handle the request; the :class:`ForkingMixIn` and :class:`ThreadingMixIn` classes do this. -.. % Is there any point in documenting the following two functions? -.. % What would the purpose of overriding them be: initializing server -.. % instance variables, adding new network families? +.. Is there any point in documenting the following two functions? + What would the purpose of overriding them be: initializing server + instance variables, adding new network families? .. function:: server_activate() Modified: python/branches/py3k/Doc/library/sqlite3.rst ============================================================================== --- python/branches/py3k/Doc/library/sqlite3.rst (original) +++ python/branches/py3k/Doc/library/sqlite3.rst Mon Dec 31 17:14:33 2007 @@ -349,7 +349,7 @@ memory overhead. It will probably be better than your own custom dictionary-based approach or even a db_row based solution. - .. % XXX what's a db_row-based solution? + .. XXX what's a db_row-based solution? .. attribute:: Connection.text_factory Modified: python/branches/py3k/Doc/library/statvfs.rst ============================================================================== --- python/branches/py3k/Doc/library/statvfs.rst (original) +++ python/branches/py3k/Doc/library/statvfs.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`statvfs` --- Constants used with :func:`os.statvfs` ========================================================= @@ -7,8 +6,6 @@ .. sectionauthor:: Moshe Zadka -.. % LaTeX'ed from comments in module - The :mod:`statvfs` module defines constants so interpreting the result if :func:`os.statvfs`, which returns a tuple, can be made without remembering "magic numbers." Each of the constants defined in this module is the *index* of Modified: python/branches/py3k/Doc/library/stdtypes.rst ============================================================================== --- python/branches/py3k/Doc/library/stdtypes.rst (original) +++ python/branches/py3k/Doc/library/stdtypes.rst Mon Dec 31 17:14:33 2007 @@ -162,6 +162,24 @@ +------------+-------------------------+-------+ .. index:: + pair: operator; comparison + operator: == + operator: < + operator: <= + operator: > + operator: >= + operator: != + operator: is + operator: is not + +Notes: + +(1) + ``!=`` can also be written ``<>``, but this is an obsolete usage + kept for backwards compatibility only. New code should always use + ``!=``. + +.. index:: pair: object; numeric pair: objects; comparing @@ -335,8 +353,8 @@ .. versionadded:: 2.6 - -.. % XXXJH exceptions: overflow (when? what operations?) zerodivision + +.. XXXJH exceptions: overflow (when? what operations?) zerodivision .. _bitstring-ops: @@ -1154,6 +1172,8 @@ Since Python strings have an explicit length, ``%s`` conversions do not assume that ``'\0'`` is the end of the string. +.. XXX Examples? + For safety reasons, floating point precisions are clipped to 50; ``%f`` conversions for numbers whose absolute value is over 1e25 are replaced by ``%g`` conversions. [#]_ All other errors raise exceptions. @@ -1845,8 +1865,7 @@ .. XXX this is quite out of date, must be updated with "io" module File objects are implemented using C's ``stdio`` package and can be -created with the built-in :func:`file` and (more usually) :func:`open` -constructors described in the :ref:`built-in-funcs` section. [#]_ File +created with the built-in :func:`open` function. File objects are also returned by some other built-in functions and methods, such as :func:`os.popen` and :func:`os.fdopen` and the :meth:`makefile` method of socket objects. Temporary files can be created using the @@ -1870,7 +1889,7 @@ As of Python 2.5, you can avoid having to call this method explicitly if you use the :keyword:`with` statement. For example, the following code will - automatically close ``f`` when the :keyword:`with` block is exited:: + automatically close *f* when the :keyword:`with` block is exited:: from __future__ import with_statement @@ -1998,6 +2017,9 @@ Note that not all file objects are seekable. + .. versionchanged:: 2.6 + Passing float values as offset has been deprecated. + .. method:: file.tell() @@ -2407,9 +2429,6 @@ strings of meaningless digits without hampering correct use and without having to know the exact precision of floating point values on a particular machine. -.. [#] :func:`file` is new in Python 2.2. The older built-in :func:`open` is an alias - for :func:`file`. - .. [#] The advantage of leaving the newline on is that returning an empty string is then an unambiguous EOF indication. It is also possible (in cases where it might matter, for example, if you want to make an exact copy of a file while Modified: python/branches/py3k/Doc/library/struct.rst ============================================================================== --- python/branches/py3k/Doc/library/struct.rst (original) +++ python/branches/py3k/Doc/library/struct.rst Mon Dec 31 17:14:33 2007 @@ -175,7 +175,7 @@ processors are little-endian. Native size and alignment are determined using the C compiler's -:keyword:`sizeof` expression. This is always combined with native byte order. +``sizeof`` expression. This is always combined with native byte order. Standard size and alignment are as follows: no alignment is required for any type (so you have to use pad bytes); :ctype:`short` is 2 bytes; :ctype:`int` and Modified: python/branches/py3k/Doc/library/sys.rst ============================================================================== --- python/branches/py3k/Doc/library/sys.rst (original) +++ python/branches/py3k/Doc/library/sys.rst Mon Dec 31 17:14:33 2007 @@ -458,9 +458,8 @@ implementation and, where needed, by :mod:`sitecustomize`. Once used by the :mod:`site` module, it is removed from the :mod:`sys` module's namespace. - .. % Note that \refmodule{site} is not imported if - .. % the \programopt{-S} option is passed to the interpreter, in which - .. % case this function will remain available. + .. Note that :mod:`site` is not imported if the :option:`-S` option is passed + to the interpreter, in which case this function will remain available. .. function:: setdlopenflags(n) Modified: python/branches/py3k/Doc/library/tabnanny.rst ============================================================================== --- python/branches/py3k/Doc/library/tabnanny.rst (original) +++ python/branches/py3k/Doc/library/tabnanny.rst Mon Dec 31 17:14:33 2007 @@ -8,9 +8,7 @@ .. moduleauthor:: Tim Peters .. sectionauthor:: Peter Funk - -.. % rudimentary documentation based on module comments, by Peter Funk -.. % +.. rudimentary documentation based on module comments For the time being this module is intended to be called as a script. However it is possible to import it into an IDE and use the function :func:`check` @@ -55,14 +53,11 @@ This function is used by :func:`check` as a callback parameter to the function :func:`tokenize.tokenize`. -.. % XXX FIXME: Document \function{errprint}, -.. % \function{format_witnesses} \class{Whitespace} -.. % check_equal, indents -.. % \function{reset_globals} +.. XXX document errprint, format_witnesses, Whitespace, check_equal, indents, + reset_globals .. seealso:: Module :mod:`tokenize` Lexical scanner for Python source code. - Modified: python/branches/py3k/Doc/library/tarfile.rst ============================================================================== --- python/branches/py3k/Doc/library/tarfile.rst (original) +++ python/branches/py3k/Doc/library/tarfile.rst Mon Dec 31 17:14:33 2007 @@ -205,10 +205,6 @@ `GNU tar manual, Basic Tar Format `_ Documentation for tar archive files, including GNU tar extensions. -.. % ----------------- -.. % TarFile Objects -.. % ----------------- - .. _tarfile-objects: @@ -421,10 +417,6 @@ A dictionary containing key-value pairs of pax global headers. -.. % ----------------- -.. % TarInfo Objects -.. % ----------------- - .. _tarinfo-objects: @@ -574,10 +566,6 @@ Return :const:`True` if it is one of character device, block device or FIFO. -.. % ------------------------ -.. % Examples -.. % ------------------------ - .. _tar-examples: @@ -635,10 +623,6 @@ tar.extract(tarinfo) tar.close() -.. % ------------ -.. % Tar format -.. % ------------ - .. _tar-formats: @@ -679,11 +663,6 @@ * The SunOS tar extended format. This format is a variant of the POSIX.1-2001 pax format, but is not compatible. -.. % ---------------- -.. % Unicode issues -.. % ---------------- - - .. _tar-unicode: Unicode issues Modified: python/branches/py3k/Doc/library/test.rst ============================================================================== --- python/branches/py3k/Doc/library/test.rst (original) +++ python/branches/py3k/Doc/library/test.rst Mon Dec 31 17:14:33 2007 @@ -33,8 +33,6 @@ Writing Unit Tests for the :mod:`test` package ---------------------------------------------- -.. % - It is preferred that tests that use the :mod:`unittest` module follow a few guidelines. One is to name the test module by starting it with ``test_`` and end it with the name of the module being tested. The test methods in the test module Modified: python/branches/py3k/Doc/library/thread.rst ============================================================================== --- python/branches/py3k/Doc/library/thread.rst (original) +++ python/branches/py3k/Doc/library/thread.rst Mon Dec 31 17:14:33 2007 @@ -63,12 +63,13 @@ Raise the :exc:`SystemExit` exception. When not caught, this will cause the thread to exit silently. -.. % \begin{funcdesc}{exit_prog}{status} -.. % Exit all threads and report the value of the integer argument -.. % \var{status} as the exit status of the entire program. -.. % \strong{Caveat:} code in pending \keyword{finally} clauses, in this thread -.. % or in other threads, is not executed. -.. % \end{funcdesc} +.. + function:: exit_prog(status) + + Exit all threads and report the value of the integer argument + *status* as the exit status of the entire program. + **Caveat:** code in pending :keyword:`finally` clauses, in this thread + or in other threads, is not executed. .. function:: allocate_lock() Modified: python/branches/py3k/Doc/library/tix.rst ============================================================================== --- python/branches/py3k/Doc/library/tix.rst (original) +++ python/branches/py3k/Doc/library/tix.rst Mon Dec 31 17:14:33 2007 @@ -88,7 +88,7 @@ demo of all the :mod:`Tix` widgets in the :file:`Demo/tix` directory of the standard distribution. -.. % The Python sample code is still being added to Python, hence commented out +.. The Python sample code is still being added to Python, hence commented out Basic Widgets @@ -103,8 +103,8 @@ widget to which a Balloon widget has been bound, a small pop-up window with a descriptive message will be shown on the screen. -.. % Python Demo of: -.. % \ulink{Balloon}{http://tix.sourceforge.net/dist/current/demos/samples/Balloon.tcl} +.. Python Demo of: +.. \ulink{Balloon}{http://tix.sourceforge.net/dist/current/demos/samples/Balloon.tcl} .. class:: ButtonBox() @@ -113,8 +113,8 @@ `_ widget creates a box of buttons, such as is commonly used for ``Ok Cancel``. -.. % Python Demo of: -.. % \ulink{ButtonBox}{http://tix.sourceforge.net/dist/current/demos/samples/BtnBox.tcl} +.. Python Demo of: +.. \ulink{ButtonBox}{http://tix.sourceforge.net/dist/current/demos/samples/BtnBox.tcl} .. class:: ComboBox() @@ -125,8 +125,8 @@ choice by either typing in the entry subwdget or selecting from the listbox subwidget. -.. % Python Demo of: -.. % \ulink{ComboBox}{http://tix.sourceforge.net/dist/current/demos/samples/ComboBox.tcl} +.. Python Demo of: +.. \ulink{ComboBox}{http://tix.sourceforge.net/dist/current/demos/samples/ComboBox.tcl} .. class:: Control() @@ -138,8 +138,8 @@ the entry. The new value will be checked against the user-defined upper and lower limits. -.. % Python Demo of: -.. % \ulink{Control}{http://tix.sourceforge.net/dist/current/demos/samples/Control.tcl} +.. Python Demo of: +.. \ulink{Control}{http://tix.sourceforge.net/dist/current/demos/samples/Control.tcl} .. class:: LabelEntry() @@ -149,8 +149,8 @@ widget packages an entry widget and a label into one mega widget. It can be used be used to simplify the creation of "entry-form" type of interface. -.. % Python Demo of: -.. % \ulink{LabelEntry}{http://tix.sourceforge.net/dist/current/demos/samples/LabEntry.tcl} +.. Python Demo of: +.. \ulink{LabelEntry}{http://tix.sourceforge.net/dist/current/demos/samples/LabEntry.tcl} .. class:: LabelFrame() @@ -161,8 +161,8 @@ widgets inside a LabelFrame widget, one creates the new widgets relative to the :attr:`frame` subwidget and manage them inside the :attr:`frame` subwidget. -.. % Python Demo of: -.. % \ulink{LabelFrame}{http://tix.sourceforge.net/dist/current/demos/samples/LabFrame.tcl} +.. Python Demo of: +.. \ulink{LabelFrame}{http://tix.sourceforge.net/dist/current/demos/samples/LabFrame.tcl} .. class:: Meter() @@ -172,8 +172,8 @@ can be used to show the progress of a background job which may take a long time to execute. -.. % Python Demo of: -.. % \ulink{Meter}{http://tix.sourceforge.net/dist/current/demos/samples/Meter.tcl} +.. Python Demo of: +.. \ulink{Meter}{http://tix.sourceforge.net/dist/current/demos/samples/Meter.tcl} .. class:: OptionMenu() @@ -182,8 +182,8 @@ `_ creates a menu button of options. -.. % Python Demo of: -.. % \ulink{OptionMenu}{http://tix.sourceforge.net/dist/current/demos/samples/OptMenu.tcl} +.. Python Demo of: +.. \ulink{OptionMenu}{http://tix.sourceforge.net/dist/current/demos/samples/OptMenu.tcl} .. class:: PopupMenu() @@ -194,8 +194,8 @@ of the :mod:`Tix` :class:`PopupMenu` widget is it requires less application code to manipulate. -.. % Python Demo of: -.. % \ulink{PopupMenu}{http://tix.sourceforge.net/dist/current/demos/samples/PopMenu.tcl} +.. Python Demo of: +.. \ulink{PopupMenu}{http://tix.sourceforge.net/dist/current/demos/samples/PopMenu.tcl} .. class:: Select() @@ -205,8 +205,8 @@ is a container of button subwidgets. It can be used to provide radio-box or check-box style of selection options for the user. -.. % Python Demo of: -.. % \ulink{Select}{http://tix.sourceforge.net/dist/current/demos/samples/Select.tcl} +.. Python Demo of: +.. \ulink{Select}{http://tix.sourceforge.net/dist/current/demos/samples/Select.tcl} .. class:: StdButtonBox() @@ -215,8 +215,8 @@ `_ widget is a group of standard buttons for Motif-like dialog boxes. -.. % Python Demo of: -.. % \ulink{StdButtonBox}{http://tix.sourceforge.net/dist/current/demos/samples/StdBBox.tcl} +.. Python Demo of: +.. \ulink{StdButtonBox}{http://tix.sourceforge.net/dist/current/demos/samples/StdBBox.tcl} File Selectors @@ -231,8 +231,8 @@ sub-directories. The user can choose one of the directories displayed in the list or change to another directory. -.. % Python Demo of: -.. % \ulink{DirList}{http://tix.sourceforge.net/dist/current/demos/samples/DirList.tcl} +.. Python Demo of: +.. \ulink{DirList}{http://tix.sourceforge.net/dist/current/demos/samples/DirList.tcl} .. class:: DirTree() @@ -243,8 +243,8 @@ sub-directories. The user can choose one of the directories displayed in the list or change to another directory. -.. % Python Demo of: -.. % \ulink{DirTree}{http://tix.sourceforge.net/dist/current/demos/samples/DirTree.tcl} +.. Python Demo of: +.. \ulink{DirTree}{http://tix.sourceforge.net/dist/current/demos/samples/DirTree.tcl} .. class:: DirSelectDialog() @@ -255,8 +255,8 @@ can use this dialog window to navigate through the file system to select the desired directory. -.. % Python Demo of: -.. % \ulink{DirSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/DirDlg.tcl} +.. Python Demo of: +.. \ulink{DirSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/DirDlg.tcl} .. class:: DirSelectBox() @@ -276,8 +276,8 @@ :class:`ExFileSelectBox` widget is very similar to the standard file dialog on MS Windows 3.1. -.. % Python Demo of: -.. % \ulink{ExFileSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/EFileDlg.tcl} +.. Python Demo of: +.. \ulink{ExFileSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/EFileDlg.tcl} .. class:: FileSelectBox() @@ -289,8 +289,8 @@ selected into a :class:`ComboBox` widget so that they can be quickly selected again. -.. % Python Demo of: -.. % \ulink{FileSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/FileDlg.tcl} +.. Python Demo of: +.. \ulink{FileSelectDialog}{http://tix.sourceforge.net/dist/current/demos/samples/FileDlg.tcl} .. class:: FileEntry() @@ -301,8 +301,8 @@ manually. Alternatively, the user can press the button widget that sits next to the entry, which will bring up a file selection dialog. -.. % Python Demo of: -.. % \ulink{FileEntry}{http://tix.sourceforge.net/dist/current/demos/samples/FileEnt.tcl} +.. Python Demo of: +.. \ulink{FileEntry}{http://tix.sourceforge.net/dist/current/demos/samples/FileEnt.tcl} Hierachical ListBox @@ -317,8 +317,8 @@ file system directory trees. The list entries are indented and connected by branch lines according to their places in the hierarchy. -.. % Python Demo of: -.. % \ulink{HList}{http://tix.sourceforge.net/dist/current/demos/samples/HList1.tcl} +.. Python Demo of: +.. \ulink{HList}{http://tix.sourceforge.net/dist/current/demos/samples/HList1.tcl} .. class:: CheckList() @@ -329,12 +329,12 @@ similarly to the Tk checkbutton or radiobutton widgets, except it is capable of handling many more items than checkbuttons or radiobuttons. -.. % Python Demo of: -.. % \ulink{ CheckList}{http://tix.sourceforge.net/dist/current/demos/samples/ChkList.tcl} -.. % Python Demo of: -.. % \ulink{ScrolledHList (1)}{http://tix.sourceforge.net/dist/current/demos/samples/SHList.tcl} -.. % Python Demo of: -.. % \ulink{ScrolledHList (2)}{http://tix.sourceforge.net/dist/current/demos/samples/SHList2.tcl} +.. Python Demo of: +.. \ulink{ CheckList}{http://tix.sourceforge.net/dist/current/demos/samples/ChkList.tcl} +.. Python Demo of: +.. \ulink{ScrolledHList (1)}{http://tix.sourceforge.net/dist/current/demos/samples/SHList.tcl} +.. Python Demo of: +.. \ulink{ScrolledHList (2)}{http://tix.sourceforge.net/dist/current/demos/samples/SHList2.tcl} .. class:: Tree() @@ -344,10 +344,10 @@ can be used to display hierarchical data in a tree form. The user can adjust the view of the tree by opening or closing parts of the tree. -.. % Python Demo of: -.. % \ulink{Tree}{http://tix.sourceforge.net/dist/current/demos/samples/Tree.tcl} -.. % Python Demo of: -.. % \ulink{Tree (Dynamic)}{http://tix.sourceforge.net/dist/current/demos/samples/DynTree.tcl} +.. Python Demo of: +.. \ulink{Tree}{http://tix.sourceforge.net/dist/current/demos/samples/Tree.tcl} +.. Python Demo of: +.. \ulink{Tree (Dynamic)}{http://tix.sourceforge.net/dist/current/demos/samples/DynTree.tcl} Tabular ListBox @@ -364,18 +364,18 @@ in a two dimensional format and (2) you can use graphical images as well as multiple colors and fonts for the list entries. -.. % Python Demo of: -.. % \ulink{ScrolledTList (1)}{http://tix.sourceforge.net/dist/current/demos/samples/STList1.tcl} -.. % Python Demo of: -.. % \ulink{ScrolledTList (2)}{http://tix.sourceforge.net/dist/current/demos/samples/STList2.tcl} -.. % Grid has yet to be added to Python -.. % \subsubsection{Grid Widget} -.. % Python Demo of: -.. % \ulink{Simple Grid}{http://tix.sourceforge.net/dist/current/demos/samples/SGrid0.tcl} -.. % Python Demo of: -.. % \ulink{ScrolledGrid}{http://tix.sourceforge.net/dist/current/demos/samples/SGrid1.tcl} -.. % Python Demo of: -.. % \ulink{Editable Grid}{http://tix.sourceforge.net/dist/current/demos/samples/EditGrid.tcl} +.. Python Demo of: +.. \ulink{ScrolledTList (1)}{http://tix.sourceforge.net/dist/current/demos/samples/STList1.tcl} +.. Python Demo of: +.. \ulink{ScrolledTList (2)}{http://tix.sourceforge.net/dist/current/demos/samples/STList2.tcl} +.. Grid has yet to be added to Python +.. \subsubsection{Grid Widget} +.. Python Demo of: +.. \ulink{Simple Grid}{http://tix.sourceforge.net/dist/current/demos/samples/SGrid0.tcl} +.. Python Demo of: +.. \ulink{ScrolledGrid}{http://tix.sourceforge.net/dist/current/demos/samples/SGrid1.tcl} +.. Python Demo of: +.. \ulink{Editable Grid}{http://tix.sourceforge.net/dist/current/demos/samples/EditGrid.tcl} Manager Widgets @@ -390,8 +390,8 @@ The panes can be arranged either vertically or horizontally. The user changes the sizes of the panes by dragging the resize handle between two panes. -.. % Python Demo of: -.. % \ulink{PanedWindow}{http://tix.sourceforge.net/dist/current/demos/samples/PanedWin.tcl} +.. Python Demo of: +.. \ulink{PanedWindow}{http://tix.sourceforge.net/dist/current/demos/samples/PanedWin.tcl} .. class:: ListNoteBook() @@ -404,8 +404,8 @@ can be shown. The user can navigate through these pages by choosing the name of the desired page in the :attr:`hlist` subwidget. -.. % Python Demo of: -.. % \ulink{ListNoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/ListNBK.tcl} +.. Python Demo of: +.. \ulink{ListNoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/ListNBK.tcl} .. class:: NoteBook() @@ -417,18 +417,18 @@ these pages can be shown. The user can navigate through these pages by choosing the visual "tabs" at the top of the NoteBook widget. -.. % Python Demo of: -.. % \ulink{NoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/NoteBook.tcl} +.. Python Demo of: +.. \ulink{NoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/NoteBook.tcl} -.. % \subsubsection{Scrolled Widgets} -.. % Python Demo of: -.. % \ulink{ScrolledListBox}{http://tix.sourceforge.net/dist/current/demos/samples/SListBox.tcl} -.. % Python Demo of: -.. % \ulink{ScrolledText}{http://tix.sourceforge.net/dist/current/demos/samples/SText.tcl} -.. % Python Demo of: -.. % \ulink{ScrolledWindow}{http://tix.sourceforge.net/dist/current/demos/samples/SWindow.tcl} -.. % Python Demo of: -.. % \ulink{Canvas Object View}{http://tix.sourceforge.net/dist/current/demos/samples/CObjView.tcl} +.. \subsubsection{Scrolled Widgets} +.. Python Demo of: +.. \ulink{ScrolledListBox}{http://tix.sourceforge.net/dist/current/demos/samples/SListBox.tcl} +.. Python Demo of: +.. \ulink{ScrolledText}{http://tix.sourceforge.net/dist/current/demos/samples/SText.tcl} +.. Python Demo of: +.. \ulink{ScrolledWindow}{http://tix.sourceforge.net/dist/current/demos/samples/SWindow.tcl} +.. Python Demo of: +.. \ulink{Canvas Object View}{http://tix.sourceforge.net/dist/current/demos/samples/CObjView.tcl} Image Types @@ -440,10 +440,10 @@ capabilities to all :mod:`Tix` and :mod:`Tkinter` widgets to create color images from XPM files. - .. % Python Demo of: - .. % \ulink{XPM Image In Button}{http://tix.sourceforge.net/dist/current/demos/samples/Xpm.tcl} - .. % Python Demo of: - .. % \ulink{XPM Image In Menu}{http://tix.sourceforge.net/dist/current/demos/samples/Xpm1.tcl} + .. Python Demo of: + .. \ulink{XPM Image In Button}{http://tix.sourceforge.net/dist/current/demos/samples/Xpm.tcl} + .. Python Demo of: + .. \ulink{XPM Image In Menu}{http://tix.sourceforge.net/dist/current/demos/samples/Xpm1.tcl} * `Compound `_ image @@ -453,14 +453,14 @@ display a bitmap and a text string simultaneously in a Tk :class:`Button` widget. - .. % Python Demo of: - .. % \ulink{Compound Image In Buttons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg.tcl} - .. % Python Demo of: - .. % \ulink{Compound Image In NoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg2.tcl} - .. % Python Demo of: - .. % \ulink{Compound Image Notebook Color Tabs}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg4.tcl} - .. % Python Demo of: - .. % \ulink{Compound Image Icons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg3.tcl} + .. Python Demo of: + .. \ulink{Compound Image In Buttons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg.tcl} + .. Python Demo of: + .. \ulink{Compound Image In NoteBook}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg2.tcl} + .. Python Demo of: + .. \ulink{Compound Image Notebook Color Tabs}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg4.tcl} + .. Python Demo of: + .. \ulink{Compound Image Icons}{http://tix.sourceforge.net/dist/current/demos/samples/CmpImg3.tcl} Miscellaneous Widgets Modified: python/branches/py3k/Doc/library/tk.rst ============================================================================== --- python/branches/py3k/Doc/library/tk.rst (original) +++ python/branches/py3k/Doc/library/tk.rst Mon Dec 31 17:14:33 2007 @@ -36,8 +36,8 @@ idle.rst othergui.rst -.. % Other sections I have in mind are -.. % Tkinter internals -.. % Freezing Tkinter applications +.. Other sections I have in mind are + Tkinter internals + Freezing Tkinter applications Modified: python/branches/py3k/Doc/library/tkinter.rst ============================================================================== --- python/branches/py3k/Doc/library/tkinter.rst (original) +++ python/branches/py3k/Doc/library/tkinter.rst Mon Dec 31 17:14:33 2007 @@ -59,7 +59,7 @@ widget of Tk which usually is the main window of an application. Each instance has its own associated Tcl interpreter. - .. % FIXME: The following keyword arguments are currently recognized: + .. FIXME: The following keyword arguments are currently recognized: .. function:: Tcl(screenName=None, baseName=None, className='Tk', useTk=0) @@ -114,8 +114,6 @@ Tkinter. Rather, it is intended as a stop gap, providing some introductory orientation on the system. -.. % Converted to LaTeX by Mike Clarkson. - Credits: * Tkinter was written by Steen Lumholt and Guido van Rossum. @@ -218,8 +216,6 @@ programmers almost always refer to the classes at the very bottom of the hierarchy. -.. % BriefTclTk.html - Notes: * These classes are provided for the purposes of organizing certain functions @@ -334,13 +330,6 @@ How Tk and Tkinter are Related ------------------------------ -.. % Relationship.html - -.. note:: - - This was derived from a graphical image; the image will be used more directly in - a subsequent version of this document. - From the top down: Your App Here (Python) @@ -453,8 +442,6 @@ .. index:: single: packing (widgets) -.. % Packer.html - The packer is one of Tk's geometry-management mechanisms. Geometry managers are used to specify the relative positioning of the positioning of widgets within their container - their mutual *master*. In contrast to the more @@ -463,8 +450,6 @@ *filling*, etc - and works everything out to determine the exact placement coordinates for you. -.. % See also \citetitle[classes/ClassPacker.html]{the Packer class interface}. - The size of any *master* widget is determined by the size of the "slave widgets" inside. The packer is used to control where slave widgets appear inside the master into which they are packed. You can pack widgets into frames, and frames @@ -521,8 +506,6 @@ ``value``. This connection works both ways: if the variable changes for any reason, the widget it's connected to will be updated to reflect the new value. -.. % VarCouplings.html - Unfortunately, in the current implementation of :mod:`Tkinter` it is not possible to hand over an arbitrary Python variable to a widget through a ``variable`` or ``textvariable`` option. The only kinds of variables for which @@ -569,8 +552,6 @@ .. index:: single: window manager (widgets) -.. % WindowMgr.html - In Tk, there is a utility command, ``wm``, for interacting with the window manager. Options to the ``wm`` command allow you to control things like titles, placement, icon bitmaps, and the like. In :mod:`Tkinter`, these commands have @@ -585,8 +566,6 @@ This method begins with an underscore to denote the fact that this function is part of the implementation, and not an interface to Tk functionality. -.. % See also \citetitle[classes/ClassWm.html]{the Wm class interface}. - Here are some examples of typical usage:: from Tkinter import * @@ -614,8 +593,6 @@ .. index:: single: Tk Option Data Types -.. % OptionTypes.html - anchor Legal values are points of the compass: ``"n"``, ``"ne"``, ``"e"``, ``"se"``, ``"s"``, ``"sw"``, ``"w"``, ``"nw"``, and also ``"center"``. @@ -695,8 +672,6 @@ single: bind (widgets) single: events (widgets) -.. % Bindings.html - The bind method from the widget command allows you to watch for certain events and to have a callback function trigger when that event type occurs. The form of the bind method is:: @@ -752,8 +727,6 @@ point at a specific place in a Text widget, or to particular characters in an Entry widget, or to particular menu items in a Menu widget. -.. % Index.html - Entry widget indexes (index, view index, etc.) Entry widgets have options that refer to character positions in the text being displayed. You can use these :mod:`Tkinter` functions to access these special Modified: python/branches/py3k/Doc/library/undoc.rst ============================================================================== --- python/branches/py3k/Doc/library/undoc.rst (original) +++ python/branches/py3k/Doc/library/undoc.rst Mon Dec 31 17:14:33 2007 @@ -169,3 +169,27 @@ in the build tree and either rebuilding Python if the modules are statically linked, or building and installing the shared object if using dynamically-loaded extensions. + +.. (lib-old is empty as of Python 2.5) + + Those which are written in Python will be installed into the directory + \file{lib-old/} installed as part of the standard library. To use + these, the directory must be added to \code{sys.path}, possibly using + \envvar{PYTHONPATH}. + +:mod:`timing` + --- Measure time intervals to high resolution (use :func:`time.clock` instead). + + +SGI-specific Extension modules +============================== + +The following are SGI specific, and may be out of touch with the current version +of reality. + +:mod:`cl` + --- Interface to the SGI compression library. + +:mod:`sv` + --- Interface to the "simple video" board on SGI Indigo (obsolete hardware). + Modified: python/branches/py3k/Doc/library/wave.rst ============================================================================== --- python/branches/py3k/Doc/library/wave.rst (original) +++ python/branches/py3k/Doc/library/wave.rst Mon Dec 31 17:14:33 2007 @@ -1,13 +1,10 @@ -.. % Documentations stolen and LaTeX'ed from comments in file. - - :mod:`wave` --- Read and write WAV files ======================================== .. module:: wave :synopsis: Provide an interface to the WAV sound format. .. sectionauthor:: Moshe Zadka - +.. Documentations stolen from comments in file. The :mod:`wave` module provides a convenient interface to the WAV sound format. It does not support compression/decompression, but it does support mono/stereo. Modified: python/branches/py3k/Doc/library/weakref.rst ============================================================================== --- python/branches/py3k/Doc/library/weakref.rst (original) +++ python/branches/py3k/Doc/library/weakref.rst Mon Dec 31 17:14:33 2007 @@ -13,8 +13,8 @@ The :mod:`weakref` module allows the Python programmer to create :dfn:`weak references` to objects. -.. % When making changes to the examples in this file, be sure to update -.. % Lib/test/test_weakref.py::libreftest too! +.. When making changes to the examples in this file, be sure to update + Lib/test/test_weakref.py::libreftest too! In the following, the term :dfn:`referent` means the object which is referred to by a weak reference. @@ -306,7 +306,7 @@ other data structures without forcing the objects to remain alive, but the objects can still be retrieved by ID if they do. -.. % Example contributed by Tim Peters. +.. Example contributed by Tim Peters. :: Modified: python/branches/py3k/Doc/library/wsgiref.rst ============================================================================== --- python/branches/py3k/Doc/library/wsgiref.rst (original) +++ python/branches/py3k/Doc/library/wsgiref.rst Mon Dec 31 17:14:33 2007 @@ -27,7 +27,7 @@ See http://www.wsgi.org for more information about WSGI, and links to tutorials and other resources. -.. % XXX If you're just trying to write a web application... +.. XXX If you're just trying to write a web application... :mod:`wsgiref.util` -- WSGI environment utilities Modified: python/branches/py3k/Doc/library/xml.dom.minidom.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.dom.minidom.rst (original) +++ python/branches/py3k/Doc/library/xml.dom.minidom.rst Mon Dec 31 17:14:33 2007 @@ -201,11 +201,11 @@ * Operations are used as methods. Since the DOM uses only :keyword:`in` parameters, the arguments are passed in normal order (from left to right). - There are no optional arguments. :keyword:`void` operations return ``None``. + There are no optional arguments. ``void`` operations return ``None``. * IDL attributes map to instance attributes. For compatibility with the OMG IDL language mapping for Python, an attribute ``foo`` can also be accessed through - accessor methods :meth:`_get_foo` and :meth:`_set_foo`. :keyword:`readonly` + accessor methods :meth:`_get_foo` and :meth:`_set_foo`. ``readonly`` attributes must not be changed; this is not enforced at runtime. * The types ``short int``, ``unsigned int``, ``unsigned long long``, and @@ -216,7 +216,7 @@ Values of type ``DOMString`` may also be ``None`` where allowed to have the IDL ``null`` value by the DOM specification from the W3C. -* :keyword:`const` declarations map to variables in their respective scope (e.g. +* ``const`` declarations map to variables in their respective scope (e.g. ``xml.dom.minidom.Node.PROCESSING_INSTRUCTION_NODE``); they must not be changed. * ``DOMException`` is currently not supported in :mod:`xml.dom.minidom`. Modified: python/branches/py3k/Doc/library/xml.dom.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.dom.rst (original) +++ python/branches/py3k/Doc/library/xml.dom.rst Mon Dec 31 17:14:33 2007 @@ -38,13 +38,13 @@ package `_. Refer to the documentation bundled with that package for information on the current state of DOM Level 3 support. -.. % What if your needs are somewhere between SAX and the DOM? Perhaps -.. % you cannot afford to load the entire tree in memory but you find the -.. % SAX model somewhat cumbersome and low-level. There is also a module -.. % called xml.dom.pulldom that allows you to build trees of only the -.. % parts of a document that you need structured access to. It also has -.. % features that allow you to find your way around the DOM. -.. % See http://www.prescod.net/python/pulldom +.. What if your needs are somewhere between SAX and the DOM? Perhaps + you cannot afford to load the entire tree in memory but you find the + SAX model somewhat cumbersome and low-level. There is also a module + called xml.dom.pulldom that allows you to build trees of only the + parts of a document that you need structured access to. It also has + features that allow you to find your way around the DOM. + See http://www.prescod.net/python/pulldom DOM applications typically start by parsing some XML into a DOM. How this is accomplished is not covered at all by DOM Level 1, and Level 2 provides only @@ -148,7 +148,7 @@ within the class rather than at the module level to conform with the DOM specifications. -.. % Should the Node documentation go here? +.. Should the Node documentation go here? .. _dom-objects: @@ -893,7 +893,7 @@ This is raised if data is specified for a node which does not support data. - .. % XXX a better explanation is needed! + .. XXX a better explanation is needed! .. exception:: NoModificationAllowedErr @@ -906,7 +906,7 @@ Raised when an invalid or illegal string is specified. - .. % XXX how is this different from InvalidCharacterErr ??? + .. XXX how is this different from InvalidCharacterErr? .. exception:: WrongDocumentErr @@ -988,8 +988,8 @@ a Python string or Unicode string. Applications should be able to handle Unicode whenever a string is returned from the DOM. -The IDL :keyword:`null` value is mapped to ``None``, which may be accepted or -provided by the implementation whenever :keyword:`null` is allowed by the API. +The IDL ``null`` value is mapped to ``None``, which may be accepted or +provided by the implementation whenever ``null`` is allowed by the API. .. _dom-accessor-methods: @@ -998,7 +998,7 @@ ^^^^^^^^^^^^^^^^ The mapping from OMG IDL to Python defines accessor functions for IDL -:keyword:`attribute` declarations in much the way the Java mapping does. +``attribute`` declarations in much the way the Java mapping does. Mapping the IDL declarations :: readonly attribute string someValue; @@ -1017,13 +1017,13 @@ objects are accessed via CORBA. While this does require some additional consideration for CORBA DOM clients, the implementers with experience using DOM over CORBA from Python do not consider this a problem. Attributes that are -declared :keyword:`readonly` may not restrict write access in all DOM +declared ``readonly`` may not restrict write access in all DOM implementations. In the Python DOM API, accessor functions are not required. If provided, they should take the form defined by the Python IDL mapping, but these methods are considered unnecessary since the attributes are accessible directly from Python. -"Set" accessors should never be provided for :keyword:`readonly` attributes. +"Set" accessors should never be provided for ``readonly`` attributes. The IDL definitions do not fully embody the requirements of the W3C DOM API, such as the notion of certain objects, such as the return value of Modified: python/branches/py3k/Doc/library/xml.etree.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.etree.rst (original) +++ python/branches/py3k/Doc/library/xml.etree.rst Mon Dec 31 17:14:33 2007 @@ -12,7 +12,7 @@ this package contains the :mod:`ElementTree`, :mod:`ElementPath`, and :mod:`ElementInclude` modules from the full ElementTree distribution. -.. % XXX To be continued! +.. XXX To be continued! .. seealso:: Modified: python/branches/py3k/Doc/library/xml.sax.handler.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.sax.handler.rst (original) +++ python/branches/py3k/Doc/library/xml.sax.handler.rst Mon Dec 31 17:14:33 2007 @@ -205,7 +205,7 @@ information to the application to expand prefixes in those contexts itself, if necessary. - .. % XXX This is not really the default, is it? MvL + .. XXX This is not really the default, is it? MvL Note that :meth:`startPrefixMapping` and :meth:`endPrefixMapping` events are not guaranteed to be properly nested relative to each-other: all Modified: python/branches/py3k/Doc/library/xml.sax.reader.rst ============================================================================== --- python/branches/py3k/Doc/library/xml.sax.reader.rst (original) +++ python/branches/py3k/Doc/library/xml.sax.reader.rst Mon Dec 31 17:14:33 2007 @@ -348,8 +348,8 @@ Return the value of attribute *name*. -.. % getValueByQName, getNameByQName, getQNameByName, getQNames available -.. % here already, but documented only for derived class. +.. getValueByQName, getNameByQName, getQNameByName, getQNames available +.. here already, but documented only for derived class. .. _attributes-ns-objects: Modified: python/branches/py3k/Doc/library/xmlrpclib.rst ============================================================================== --- python/branches/py3k/Doc/library/xmlrpclib.rst (original) +++ python/branches/py3k/Doc/library/xmlrpclib.rst Mon Dec 31 17:14:33 2007 @@ -1,4 +1,3 @@ - :mod:`xmlrpclib` --- XML-RPC client access ========================================== @@ -8,8 +7,8 @@ .. sectionauthor:: Eric S. Raymond -.. % Not everything is documented yet. It might be good to describe -.. % Marshaller, Unmarshaller, getparser, dumps, loads, and Transport. +.. XXX Not everything is documented yet. It might be good to describe + Marshaller, Unmarshaller, getparser, dumps, loads, and Transport. XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a transport. With it, a client can call methods with parameters on a remote @@ -529,11 +528,9 @@ print("ERROR", v) To access an XML-RPC server through a proxy, you need to define a custom -transport. The following example, written by NoboNobo, shows how: - -.. % fill in original author's name if we ever learn it +transport. The following example shows how: -.. % Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html +.. Example taken from http://lowlife.jp/nobonobo/wiki/xmlrpcwithproxy.html :: Modified: python/branches/py3k/Doc/library/zipfile.rst ============================================================================== --- python/branches/py3k/Doc/library/zipfile.rst (original) +++ python/branches/py3k/Doc/library/zipfile.rst Mon Dec 31 17:14:33 2007 @@ -7,9 +7,6 @@ .. moduleauthor:: James C. Ahlstrom .. sectionauthor:: James C. Ahlstrom - -.. % LaTeX markup by Fred L. Drake, Jr. - The ZIP file format is a common archive and compression standard. This module provides tools to create, read, write, append, and list a ZIP file. Any advanced use of this module will require an understanding of the format, as Modified: python/branches/py3k/Doc/library/zlib.rst ============================================================================== --- python/branches/py3k/Doc/library/zlib.rst (original) +++ python/branches/py3k/Doc/library/zlib.rst Mon Dec 31 17:14:33 2007 @@ -74,8 +74,6 @@ the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. - .. % - .. function:: decompress(string[, wbits[, bufsize]]) Modified: python/branches/py3k/Doc/reference/compound_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/compound_stmts.rst (original) +++ python/branches/py3k/Doc/reference/compound_stmts.rst Mon Dec 31 17:14:33 2007 @@ -72,6 +72,8 @@ .. _if: +.. _elif: +.. _else: The :keyword:`if` statement =========================== @@ -200,6 +202,8 @@ .. _try: +.. _except: +.. _finally: The :keyword:`try` statement ============================ @@ -326,6 +330,7 @@ .. _with: +.. _as: The :keyword:`with` statement ============================= @@ -382,6 +387,7 @@ .. _function: +.. _def: Function definitions ==================== Modified: python/branches/py3k/Doc/reference/datamodel.rst ============================================================================== --- python/branches/py3k/Doc/reference/datamodel.rst (original) +++ python/branches/py3k/Doc/reference/datamodel.rst Mon Dec 31 17:14:33 2007 @@ -202,8 +202,6 @@ operation except left shift, if it yields a result in the plain integer domain without causing overflow, will yield the same result when using mixed operands. - .. % Integers - Floating point numbers .. index:: object: floating point @@ -229,8 +227,6 @@ The real and imaginary parts of a complex number ``z`` can be retrieved through the read-only attributes ``z.real`` and ``z.imag``. - .. % Numbers - Sequences .. index:: builtin: len @@ -302,8 +298,6 @@ parentheses must be usable for grouping of expressions). An empty tuple can be formed by an empty pair of parentheses. - .. % Immutable sequences - Mutable sequences .. index:: object: mutable sequence @@ -341,10 +335,6 @@ The extension module :mod:`array` provides an additional example of a mutable sequence type. - .. % Mutable sequences - - .. % Sequences - Set types .. index:: builtin: len @@ -379,8 +369,6 @@ :term:`hashable`, it can be used again as an element of another set, or as a dictionary key. - .. % Set types - Mappings .. index:: builtin: len @@ -418,8 +406,6 @@ The extension modules :mod:`dbm`, :mod:`gdbm`, and :mod:`bsddb` provide additional examples of mapping types. - .. % Mapping types - Callable types .. index:: object: callable @@ -652,8 +638,6 @@ object used to initialize the module (since it isn't needed once the initialization is done). - .. % - Attribute assignment updates the module's namespace dictionary, e.g., ``m.x = 1`` is equivalent to ``m.__dict__["x"] = 1``. @@ -992,12 +976,53 @@ described above, under "User-defined methods". Class method objects are created by the built-in :func:`classmethod` constructor. - .. % Internal types - -.. % ========================================================================= .. _newstyle: +New-style and classic classes +============================= + +Classes and instances come in two flavors: old-style or classic, and new-style. + +Up to Python 2.1, old-style classes were the only flavour available to the user. +The concept of (old-style) class is unrelated to the concept of type: if *x* is +an instance of an old-style class, then ``x.__class__`` designates the class of +*x*, but ``type(x)`` is always ````. This reflects the fact +that all old-style instances, independently of their class, are implemented with +a single built-in type, called ``instance``. + +New-style classes were introduced in Python 2.2 to unify classes and types. A +new-style class neither more nor less than a user-defined type. If *x* is an +instance of a new-style class, then ``type(x)`` is the same as ``x.__class__``. + +The major motivation for introducing new-style classes is to provide a unified +object model with a full meta-model. It also has a number of immediate +benefits, like the ability to subclass most built-in types, or the introduction +of "descriptors", which enable computed properties. + +For compatibility reasons, classes are still old-style by default. New-style +classes are created by specifying another new-style class (i.e. a type) as a +parent class, or the "top-level type" :class:`object` if no other parent is +needed. The behaviour of new-style classes differs from that of old-style +classes in a number of important details in addition to what :func:`type` +returns. Some of these changes are fundamental to the new object model, like +the way special methods are invoked. Others are "fixes" that could not be +implemented before for compatibility concerns, like the method resolution order +in case of multiple inheritance. + +This manual is not up-to-date with respect to new-style classes. For now, +please see http://www.python.org/doc/newstyle.html for more information. + +.. index:: + single: class + single: class + single: class + +The plan is to eventually drop old-style classes, leaving only the semantics of +new-style classes. This change will probably only be feasible in Python 3.0. +new-style classic old-style + + .. _specialnames: Special method names Modified: python/branches/py3k/Doc/reference/expressions.rst ============================================================================== --- python/branches/py3k/Doc/reference/expressions.rst (original) +++ python/branches/py3k/Doc/reference/expressions.rst Mon Dec 31 17:14:33 2007 @@ -937,6 +937,10 @@ .. _comparisons: +.. _is: +.. _isnot: +.. _in: +.. _notin: Comparisons =========== @@ -1058,6 +1062,9 @@ .. _booleans: +.. _and: +.. _or: +.. _not: Boolean operations ================== Modified: python/branches/py3k/Doc/reference/lexical_analysis.rst ============================================================================== --- python/branches/py3k/Doc/reference/lexical_analysis.rst (original) +++ python/branches/py3k/Doc/reference/lexical_analysis.rst Mon Dec 31 17:14:33 2007 @@ -100,8 +100,7 @@ encoding is used for all lexical analysis, including string literals, comments and identifiers. The encoding declaration must appear on a line of its own. -A list of standard encodings can be found in the section -:ref:`standard-encodings`. +.. XXX there should be a list of supported encodings. .. _explicit-joining: Modified: python/branches/py3k/Doc/reference/simple_stmts.rst ============================================================================== --- python/branches/py3k/Doc/reference/simple_stmts.rst (original) +++ python/branches/py3k/Doc/reference/simple_stmts.rst Mon Dec 31 17:14:33 2007 @@ -143,6 +143,19 @@ count for the object previously bound to the name to reach zero, causing the object to be deallocated and its destructor (if it has one) to be called. + .. index:: single: destructor + + The name is rebound if it was already bound. This may cause the reference count + for the object previously bound to the name to reach zero, causing the object to + be deallocated and its destructor (if it has one) to be called. + +* If the target is a target list enclosed in parentheses or in square brackets: + The object must be a sequence with the same number of items as there are targets + in the target list, and its items are assigned, from left to right, to the + corresponding targets. + + .. index:: pair: attribute; assignment + * If the target is an attribute reference: The primary expression in the reference is evaluated. It should yield an object with assignable attributes; if this is not the case, :exc:`TypeError` is raised. That object is then @@ -296,16 +309,16 @@ single: __debug__ exception: AssertionError -These equivalences assume that ``__debug__`` and :exc:`AssertionError` refer to +These equivalences assume that :const:`__debug__` and :exc:`AssertionError` refer to the built-in variables with those names. In the current implementation, the -built-in variable ``__debug__`` is ``True`` under normal circumstances, +built-in variable :const:`__debug__` is ``True`` under normal circumstances, ``False`` when optimization is requested (command line option -O). The current code generator emits no code for an assert statement when optimization is requested at compile time. Note that it is unnecessary to include the source code for the expression that failed in the error message; it will be displayed as part of the stack trace. -Assignments to ``__debug__`` are illegal. The value for the built-in variable +Assignments to :const:`__debug__` are illegal. The value for the built-in variable is determined when the interpreter starts. @@ -512,6 +525,7 @@ .. _import: +.. _from: The :keyword:`import` statement =============================== Modified: python/branches/py3k/Doc/tutorial/appetite.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/appetite.rst (original) +++ python/branches/py3k/Doc/tutorial/appetite.rst Mon Dec 31 17:14:33 2007 @@ -75,8 +75,6 @@ more detail. Since the best way to learn a language is to use it, the tutorial invites you to play with the Python interpreter as you read. -.. % \section{Where From Here \label{where}} - In the next chapter, the mechanics of using the interpreter are explained. This is rather mundane information, but essential for trying out the examples shown later. Modified: python/branches/py3k/Doc/tutorial/classes.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/classes.rst (original) +++ python/branches/py3k/Doc/tutorial/classes.rst Mon Dec 31 17:14:33 2007 @@ -390,7 +390,7 @@ Random Remarks ============== -.. % [These should perhaps be placed more carefully...] +.. These should perhaps be placed more carefully... Data attributes override method attributes with the same name; to avoid accidental name conflicts, which may cause hard-to-find bugs in large programs, @@ -506,7 +506,7 @@ have no special privileges when calling other methods of the same object, a method of a base class that calls another method defined in the same base class may end up calling a method of a derived class that overrides it. (For C++ -programmers: all methods in Python are effectively :keyword:`virtual`.) +programmers: all methods in Python are effectively ``virtual``.) An overriding method in a derived class may in fact want to extend rather than simply replace the base class method of the same name. There is a simple way to @@ -617,12 +617,10 @@ can define a class with methods :meth:`read` and :meth:`readline` that get the data from a string buffer instead, and pass it as an argument. -.. % (Unfortunately, this -.. % technique has its limitations: a class can't define operations that -.. % are accessed by special syntax such as sequence subscripting or -.. % arithmetic operators, and assigning such a ``pseudo-file'' to -.. % \code{sys.stdin} will not cause the interpreter to read further input -.. % from it.) +.. (Unfortunately, this technique has its limitations: a class can't define + operations that are accessed by special syntax such as sequence subscripting + or arithmetic operators, and assigning such a "pseudo-file" to sys.stdin will + not cause the interpreter to read further input from it.) Instance method objects have attributes, too: ``m.__self__`` is the instance object with the method :meth:`m`, and ``m.__func__`` is the function object Modified: python/branches/py3k/Doc/tutorial/controlflow.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/controlflow.rst (original) +++ python/branches/py3k/Doc/tutorial/controlflow.rst Mon Dec 31 17:14:33 2007 @@ -31,11 +31,8 @@ There can be zero or more :keyword:`elif` parts, and the :keyword:`else` part is optional. The keyword ':keyword:`elif`' is short for 'else if', and is useful to avoid excessive indentation. An :keyword:`if` ... :keyword:`elif` ... -:keyword:`elif` ... sequence is a substitute for the :keyword:`switch` or -:keyword:`case` statements found in other languages. - -.. % Weird spacings happen here if the wrapping of the source text -.. % gets changed in the wrong way. +:keyword:`elif` ... sequence is a substitute for the ``switch`` or +``case`` statements found in other languages. .. _tut-for: @@ -53,8 +50,8 @@ iterates over the items of any sequence (a list or a string), in the order that they appear in the sequence. For example (no pun intended): -.. % One suggestion was to give a real C example here, but that may only -.. % serve to confuse non-C programmers. +.. One suggestion was to give a real C example here, but that may only serve to + confuse non-C programmers. :: Modified: python/branches/py3k/Doc/tutorial/datastructures.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/datastructures.rst (original) +++ python/branches/py3k/Doc/tutorial/datastructures.rst Mon Dec 31 17:14:33 2007 @@ -350,6 +350,70 @@ +Tuples and Sequences +==================== + +We saw that lists and strings have many common properties, such as indexing and +slicing operations. They are two examples of *sequence* data types (see +:ref:`typesseq`). Since Python is an evolving language, other sequence data +types may be added. There is also another standard sequence data type: the +*tuple*. + +A tuple consists of a number of values separated by commas, for instance:: + + >>> t = 12345, 54321, 'hello!' + >>> t[0] + 12345 + >>> t + (12345, 54321, 'hello!') + >>> # Tuples may be nested: + ... u = t, (1, 2, 3, 4, 5) + >>> u + ((12345, 54321, 'hello!'), (1, 2, 3, 4, 5)) + +As you see, on output tuples are always enclosed in parentheses, so that nested +tuples are interpreted correctly; they may be input with or without surrounding +parentheses, although often parentheses are necessary anyway (if the tuple is +part of a larger expression). + +Tuples have many uses. For example: (x, y) coordinate pairs, employee records +from a database, etc. Tuples, like strings, are immutable: it is not possible +to assign to the individual items of a tuple (you can simulate much of the same +effect with slicing and concatenation, though). It is also possible to create +tuples which contain mutable objects, such as lists. + +A special problem is the construction of tuples containing 0 or 1 items: the +syntax has some extra quirks to accommodate these. Empty tuples are constructed +by an empty pair of parentheses; a tuple with one item is constructed by +following a value with a comma (it is not sufficient to enclose a single value +in parentheses). Ugly, but effective. For example:: + + >>> empty = () + >>> singleton = 'hello', # <-- note trailing comma + >>> len(empty) + 0 + >>> len(singleton) + 1 + >>> singleton + ('hello',) + +The statement ``t = 12345, 54321, 'hello!'`` is an example of *tuple packing*: +the values ``12345``, ``54321`` and ``'hello!'`` are packed together in a tuple. +The reverse operation is also possible:: + + >>> x, y, z = t + +This is called, appropriately enough, *sequence unpacking*. Sequence unpacking +requires the list of variables on the left to have the same number of elements +as the length of the sequence. Note that multiple assignment is really just a +combination of tuple packing and sequence unpacking! + +There is a small bit of asymmetry here: packing multiple values always creates +a tuple, and unpacking works for any sequence. + +.. XXX Add a bit on the difference between tuples and lists. + + .. _tut-sets: Sets Modified: python/branches/py3k/Doc/tutorial/inputoutput.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/inputoutput.rst (original) +++ python/branches/py3k/Doc/tutorial/inputoutput.rst Mon Dec 31 17:14:33 2007 @@ -180,11 +180,9 @@ :func:`open` returns a file object, and is most commonly used with two arguments: ``open(filename, mode)``. -.. % Opening files - :: - >>> f=open('/tmp/workfile', 'w') + >>> f = open('/tmp/workfile', 'w') >>> print(f) Modified: python/branches/py3k/Doc/tutorial/interpreter.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/interpreter.rst (original) +++ python/branches/py3k/Doc/tutorial/interpreter.rst Mon Dec 31 17:14:33 2007 @@ -212,8 +212,8 @@ file containing your start-up commands. This is similar to the :file:`.profile` feature of the Unix shells. -.. % XXX This should probably be dumped in an appendix, since most people -.. % don't use Python interactively in non-trivial ways. +.. XXX This should probably be dumped in an appendix, since most people + don't use Python interactively in non-trivial ways. This file is only read in interactive sessions, not when Python reads commands from a script, and not when :file:`/dev/tty` is given as the explicit source of Modified: python/branches/py3k/Doc/tutorial/introduction.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/introduction.rst (original) +++ python/branches/py3k/Doc/tutorial/introduction.rst Mon Dec 31 17:14:33 2007 @@ -13,9 +13,9 @@ Many of the examples in this manual, even those entered at the interactive prompt, include comments. Comments in Python start with the hash character, -``'#'``, and extend to the end of the physical line. A comment may appear at +``#``, and extend to the end of the physical line. A comment may appear at the start of a line or following whitespace or code, but not within a string -literal. A hash character within a string literal is just a hash character. +literal. A hash character within a string literal is just a hash character. Some examples:: @@ -608,5 +608,3 @@ Note that nothing appeared after the loop ended, until we printed a newline. - - Modified: python/branches/py3k/Doc/tutorial/modules.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/modules.rst (original) +++ python/branches/py3k/Doc/tutorial/modules.rst Mon Dec 31 17:14:33 2007 @@ -223,11 +223,6 @@ * The module :mod:`compileall` can create :file:`.pyc` files (or :file:`.pyo` files when :option:`-O` is used) for all modules in a directory. -* If using Python in a parallel processing system with a shared file system, - you need to patch Python to disable the creation of the compiled files - because otherwise the multiple Python interpreters will encounter race - conditions in creating them. - .. _tut-standardmodules: @@ -246,11 +241,7 @@ provided on Windows systems. One particular module deserves some attention: :mod:`sys`, which is built into every Python interpreter. The variables ``sys.ps1`` and ``sys.ps2`` define the strings used as primary and secondary -prompts: - -.. % - -:: +prompts:: >>> import sys >>> sys.ps1 @@ -455,8 +446,6 @@ file names with a capitalized first letter.) The DOS 8+3 filename restriction adds another interesting problem for long module names. -.. % The \code{__all__} Attribute - The only solution is for the package author to provide an explicit index of the package. The import statement uses the following convention: if a package's :file:`__init__.py` code defines a list named ``__all__``, it is taken to be the Modified: python/branches/py3k/Doc/tutorial/whatnow.rst ============================================================================== --- python/branches/py3k/Doc/tutorial/whatnow.rst (original) +++ python/branches/py3k/Doc/tutorial/whatnow.rst Mon Dec 31 17:14:33 2007 @@ -66,8 +66,8 @@ many of the questions that come up again and again, and may already contain the solution for your problem. -.. % Postings figure based on average of last six months activity as -.. % reported by www.egroups.com; Jan. 2000 - June 2000: 21272 msgs / 182 -.. % days = 116.9 msgs / day and steadily increasing. +.. Postings figure based on average of last six months activity as + reported by www.egroups.com; Jan. 2000 - June 2000: 21272 msgs / 182 + days = 116.9 msgs / day and steadily increasing. (XXX up to date figures?) Modified: python/branches/py3k/Doc/using/windows.rst ============================================================================== --- python/branches/py3k/Doc/using/windows.rst (original) +++ python/branches/py3k/Doc/using/windows.rst Mon Dec 31 17:14:33 2007 @@ -158,8 +158,7 @@ :file:`C:\\Python\\Lib\\` and third-party modules should be stored in :file:`C:\\Python\\Lib\\site-packages\\`. -.. % `` this fixes syntax highlighting errors in some editors - due to the \\ hackery +.. `` this fixes syntax highlighting errors in some editors due to the \\ hackery You can add folders to your search path to make Python's import mechanism search in these directories as well. Use :envvar:`PYTHONPATH`, as described in @@ -167,7 +166,7 @@ separated by semicolons, though, to distinguish them from drive identifiers (:file:`C:\\` etc.). -.. % `` +.. `` Modifying the module search path can also be done through the Windows registry: Edit Modified: python/branches/py3k/Doc/whatsnew/2.0.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.0.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.0.rst Mon Dec 31 17:14:33 2007 @@ -6,7 +6,7 @@ .. |release| replace:: 1.02 -.. % $Id: whatsnew20.tex 51211 2006-08-11 14:57:12Z thomas.wouters $ +.. $Id: whatsnew20.tex 50964 2006-07-30 03:03:43Z fred.drake $ Introduction @@ -26,7 +26,7 @@ paid to spend their days fixing bugs, and also due to the improved communication resulting from moving to SourceForge. -.. % ====================================================================== +.. ====================================================================== What About Python 1.6? @@ -50,7 +50,7 @@ features described in this document are only in 2.0, because a lot of work was done between May and September. -.. % ====================================================================== +.. ====================================================================== New Development Process @@ -134,7 +134,7 @@ from PEP 201, "Lockstep Iteration", to PEP 225, "Elementwise/Objectwise Operators". -.. % ====================================================================== +.. ====================================================================== Unicode @@ -255,7 +255,7 @@ used in testing and future-proofing your Python code, since some future version of Python may drop support for 8-bit strings and provide only Unicode strings. -.. % ====================================================================== +.. ====================================================================== List Comprehensions @@ -342,7 +342,7 @@ was then discussed for a seemingly endless time on the python-dev mailing list and kept up-to-date by Skip Montanaro. -.. % ====================================================================== +.. ====================================================================== Augmented Assignment @@ -360,7 +360,7 @@ :class:`Number` class stores a number and supports using += to create a new instance with an incremented value. -.. % The empty groups below prevent conversion to guillemets. +.. The empty groups below prevent conversion to guillemets. :: @@ -383,7 +383,7 @@ and PHP also support them. The augmented assignment patch was implemented by Thomas Wouters. -.. % ====================================================================== +.. ====================================================================== String Methods @@ -426,7 +426,7 @@ module, with the arguments reversed. In other words, ``s.join(seq)`` is equivalent to the old ``string.join(seq, s)``. -.. % ====================================================================== +.. ====================================================================== Garbage Collection of Cycles @@ -488,7 +488,7 @@ the relevant discussion, especially in the threads titled "Reference cycle collection for Python" and "Finalization again". -.. % ====================================================================== +.. ====================================================================== Other Core Changes @@ -565,8 +565,8 @@ :meth:`__cmp__` method encountered an error, since the resulting exception would simply be silently swallowed. -.. % Starting URL: -.. % http://www.python.org/pipermail/python-dev/2000-April/004834.html +.. Starting URL: +.. http://www.python.org/pipermail/python-dev/2000-April/004834.html Work has been done on porting Python to 64-bit Windows on the Itanium processor, mostly by Trent Mick of ActiveState. (Confusingly, ``sys.platform`` is still @@ -641,7 +641,7 @@ value for a given platform can be found by running a new script, :file:`Misc/find_recursionlimit.py`. -.. % ====================================================================== +.. ====================================================================== Porting to 2.0 @@ -728,13 +728,13 @@ exceptions was translated from Python to a built-in C module, written by Barry Warsaw and Fredrik Lundh. -.. % Commented out for now -- I don't think anyone will care. -.. % The pattern and match objects provided by SRE are C types, not Python -.. % class instances as in 1.5. This means you can no longer inherit from -.. % \class{RegexObject} or \class{MatchObject}, but that shouldn't be much -.. % of a problem since no one should have been doing that in the first -.. % place. -.. % ====================================================================== +.. Commented out for now -- I don't think anyone will care. + The pattern and match objects provided by SRE are C types, not Python + class instances as in 1.5. This means you can no longer inherit from + \class{RegexObject} or \class{MatchObject}, but that shouldn't be much + of a problem since no one should have been doing that in the first + place. +.. ====================================================================== Extending/Embedding Changes @@ -805,7 +805,7 @@ A wrapper API was added for Unix-style signal handlers. :func:`PyOS_getsig` gets a signal handler and :func:`PyOS_setsig` will set a new handler. -.. % ====================================================================== +.. ====================================================================== Distutils: Making Modules Easy to Install @@ -875,7 +875,7 @@ All this is documented in a new manual, *Distributing Python Modules*, that joins the basic set of Python documentation. -.. % ====================================================================== +.. ====================================================================== XML Modules @@ -1024,7 +1024,7 @@ * The :mod:`sgmlop` parser accelerator module, written by Fredrik Lundh. -.. % ====================================================================== +.. ====================================================================== Module changes @@ -1069,7 +1069,7 @@ partially funded by Hewlett Packard, supports matching against both 8-bit strings and Unicode strings. -.. % ====================================================================== +.. ====================================================================== New modules @@ -1145,7 +1145,7 @@ import hooks, in comparison to the existing :mod:`ihooks` module. (Implemented by Greg Stein, with much discussion on python-dev along the way.) -.. % ====================================================================== +.. ====================================================================== IDLE Improvements @@ -1179,7 +1179,7 @@ * Three new keystroke commands: Check module (Alt-F5), Import module (F5) and Run script (Ctrl-F5). -.. % ====================================================================== +.. ====================================================================== Deleted and Deprecated Modules Modified: python/branches/py3k/Doc/whatsnew/2.1.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.1.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.1.rst Mon Dec 31 17:14:33 2007 @@ -6,7 +6,7 @@ .. |release| replace:: 1.01 -.. % $Id: whatsnew21.tex 51211 2006-08-11 14:57:12Z thomas.wouters $ +.. $Id: whatsnew21.tex 50964 2006-07-30 03:03:43Z fred.drake $ Introduction @@ -29,7 +29,7 @@ The final release of Python 2.1 was made on April 17, 2001. -.. % ====================================================================== +.. ====================================================================== PEP 227: Nested Scopes @@ -123,7 +123,7 @@ :pep:`227` - Statically Nested Scopes Written and implemented by Jeremy Hylton. -.. % ====================================================================== +.. ====================================================================== PEP 236: __future__ Directives @@ -153,7 +153,7 @@ :pep:`236` - Back to the :mod:`__future__` Written by Tim Peters, and primarily implemented by Jeremy Hylton. -.. % ====================================================================== +.. ====================================================================== PEP 207: Rich Comparisons @@ -223,7 +223,7 @@ Written by Guido van Rossum, heavily based on earlier work by David Ascher, and implemented by Guido van Rossum. -.. % ====================================================================== +.. ====================================================================== PEP 230: Warning Framework @@ -295,7 +295,7 @@ :pep:`230` - Warning Framework Written and implemented by Guido van Rossum. -.. % ====================================================================== +.. ====================================================================== PEP 229: New Build System @@ -335,7 +335,7 @@ :pep:`229` - Using Distutils to Build Python Written and implemented by A.M. Kuchling. -.. % ====================================================================== +.. ====================================================================== PEP 205: Weak References @@ -416,7 +416,7 @@ :pep:`205` - Weak References Written and implemented by Fred L. Drake, Jr. -.. % ====================================================================== +.. ====================================================================== PEP 232: Function Attributes @@ -454,7 +454,7 @@ :pep:`232` - Function Attributes Written and implemented by Barry Warsaw. -.. % ====================================================================== +.. ====================================================================== PEP 235: Importing Modules on Case-Insensitive Platforms @@ -472,7 +472,7 @@ insensitive matching can be requested by setting the :envvar:`PYTHONCASEOK` environment variable before starting the Python interpreter. -.. % ====================================================================== +.. ====================================================================== PEP 217: Interactive Display Hook @@ -502,7 +502,7 @@ :pep:`217` - Display Hook for Interactive Use Written and implemented by Moshe Zadka. -.. % ====================================================================== +.. ====================================================================== PEP 208: New Coercion Model @@ -534,7 +534,7 @@ Marc-Andr? Lemburg. Read this to understand the fine points of how numeric operations will now be processed at the C level. -.. % ====================================================================== +.. ====================================================================== PEP 241: Metadata in Python Packages @@ -574,7 +574,7 @@ Written by Sean Reifschneider, this draft PEP describes a proposed mechanism for uploading Python packages to a central server. -.. % ====================================================================== +.. ====================================================================== New and Improved Modules @@ -677,7 +677,7 @@ implementation. Use it for debugging, and resist the temptation to put it into production code. -.. % ====================================================================== +.. ====================================================================== Other Changes and Fixes @@ -782,7 +782,7 @@ edits, and other tweaks, too lengthy to be worth itemizing; see the CVS logs for the full details if you want them. -.. % ====================================================================== +.. ====================================================================== Acknowledgements Modified: python/branches/py3k/Doc/whatsnew/2.2.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.2.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.2.rst Mon Dec 31 17:14:33 2007 @@ -6,7 +6,7 @@ .. |release| replace:: 1.02 -.. % $Id: whatsnew22.tex 37315 2004-09-10 19:33:00Z akuchling $ +.. $Id: whatsnew22.tex 37315 2004-09-10 19:33:00Z akuchling $ Introduction @@ -36,7 +36,7 @@ "What's So Special About Python 2.2?" is also about the new 2.2 features, and was written by Cameron Laird and Kathryn Soraiz. -.. % ====================================================================== +.. ====================================================================== PEPs 252 and 253: Type and Class Changes @@ -414,7 +414,7 @@ resort to it after all other avenues have been exhausted, including posting a question to python-list or python-dev. -.. % ====================================================================== +.. ====================================================================== PEP 234: Iterators @@ -535,7 +535,7 @@ Written by Ka-Ping Yee and GvR; implemented by the Python Labs crew, mostly by GvR and Tim Peters. -.. % ====================================================================== +.. ====================================================================== PEP 255: Simple Generators @@ -662,7 +662,7 @@ Written by Neil Schemenauer, Tim Peters, Magnus Lie Hetland. Implemented mostly by Neil Schemenauer and Tim Peters, with other fixes from the Python Labs crew. -.. % ====================================================================== +.. ====================================================================== PEP 237: Unifying Long Integers and Integers @@ -702,7 +702,7 @@ Written by Moshe Zadka and Guido van Rossum. Implemented mostly by Guido van Rossum. -.. % ====================================================================== +.. ====================================================================== PEP 238: Changing the Division Operator @@ -770,7 +770,7 @@ :pep:`238` - Changing the Division Operator Written by Moshe Zadka and Guido van Rossum. Implemented by Guido van Rossum.. -.. % ====================================================================== +.. ====================================================================== Unicode Changes @@ -832,7 +832,7 @@ :pep:`261` - Support for 'wide' Unicode characters Written by Paul Prescod. -.. % ====================================================================== +.. ====================================================================== PEP 227: Nested Scopes @@ -927,7 +927,7 @@ :pep:`227` - Statically Nested Scopes Written and implemented by Jeremy Hylton. -.. % ====================================================================== +.. ====================================================================== New and Improved Modules @@ -1042,7 +1042,7 @@ scheduling an activity to happen at some future time. (Contributed by Itamar Shtull-Trauring.) -.. % ====================================================================== +.. ====================================================================== Interpreter Changes and Fixes @@ -1122,7 +1122,7 @@ takes 2 parameters instead of 3. The third argument was never used, and can simply be discarded when porting code from earlier versions to Python 2.2. -.. % ====================================================================== +.. ====================================================================== Other Changes and Fixes @@ -1155,23 +1155,23 @@ left commented out in :file:`setup.py`. People who want to experiment with these modules can uncomment them manually. - .. % Jack's original comments: - .. % The main change is the possibility to build Python as a - .. % framework. This installs a self-contained Python installation plus the - .. % OSX framework "glue" into /Library/Frameworks/Python.framework (or - .. % another location of choice). For now there is little immedeate added - .. % benefit to this (actually, there is the disadvantage that you have to - .. % change your PATH to be able to find Python), but it is the basis for - .. % creating a fullblown Python application, porting the MacPython IDE, - .. % possibly using Python as a standard OSA scripting language and much - .. % more. You enable this with "configure --enable-framework". - .. % The other change is that most MacPython toolbox modules, which - .. % interface to all the MacOS APIs such as windowing, quicktime, - .. % scripting, etc. have been ported. Again, most of these are not of - .. % immedeate use, as they need a full application to be really useful, so - .. % they have been commented out in setup.py. People wanting to experiment - .. % can uncomment them. Gestalt and Internet Config modules are enabled by - .. % default. + .. Jack's original comments: + The main change is the possibility to build Python as a + framework. This installs a self-contained Python installation plus the + OSX framework "glue" into /Library/Frameworks/Python.framework (or + another location of choice). For now there is little immedeate added + benefit to this (actually, there is the disadvantage that you have to + change your PATH to be able to find Python), but it is the basis for + creating a fullblown Python application, porting the MacPython IDE, + possibly using Python as a standard OSA scripting language and much + more. You enable this with "configure --enable-framework". + The other change is that most MacPython toolbox modules, which + interface to all the MacOS APIs such as windowing, quicktime, + scripting, etc. have been ported. Again, most of these are not of + immedeate use, as they need a full application to be really useful, so + they have been commented out in setup.py. People wanting to experiment + can uncomment them. Gestalt and Internet Config modules are enabled by + default. * Keyword arguments passed to builtin functions that don't take them now cause a :exc:`TypeError` exception to be raised, with the message "*function* takes no @@ -1253,7 +1253,7 @@ unpredictably depending on the platform. A call such as ``pow(2.0, 8.0, 7.0)`` will now raise a :exc:`TypeError` exception. -.. % ====================================================================== +.. ====================================================================== Acknowledgements Modified: python/branches/py3k/Doc/whatsnew/2.3.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.3.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.3.rst Mon Dec 31 17:14:33 2007 @@ -6,7 +6,7 @@ .. |release| replace:: 1.01 -.. % $Id: whatsnew23.tex 55005 2007-04-27 19:54:29Z guido.van.rossum $ +.. $Id: whatsnew23.tex 54631 2007-03-31 11:58:36Z georg.brandl $ This article explains the new features in Python 2.3. Python 2.3 was released on July 29, 2003. @@ -34,7 +34,7 @@ complete implementation and design rationale, refer to the PEP for a particular new feature. -.. % ====================================================================== +.. ====================================================================== PEP 218: A Standard Set Datatype @@ -117,7 +117,7 @@ PEP written by Greg V. Wilson. Implemented by Greg V. Wilson, Alex Martelli, and GvR. -.. % ====================================================================== +.. ====================================================================== .. _section-generators: @@ -248,7 +248,7 @@ Written by Neil Schemenauer, Tim Peters, Magnus Lie Hetland. Implemented mostly by Neil Schemenauer and Tim Peters, with other fixes from the Python Labs crew. -.. % ====================================================================== +.. ====================================================================== .. _section-encodings: @@ -282,7 +282,7 @@ Written by Marc-Andr? Lemburg and Martin von L?wis; implemented by Suzuki Hisao and Martin von L?wis. -.. % ====================================================================== +.. ====================================================================== PEP 273: Importing Modules from ZIP Archives @@ -329,7 +329,7 @@ Just van Rossum that uses the import hooks described in :pep:`302`. See section :ref:`section-pep302` for a description of the new import hooks. -.. % ====================================================================== +.. ====================================================================== PEP 277: Unicode file name support for Windows NT @@ -363,7 +363,7 @@ Written by Neil Hodgson; implemented by Neil Hodgson, Martin von L?wis, and Mark Hammond. -.. % ====================================================================== +.. ====================================================================== PEP 278: Universal Newline Support @@ -398,7 +398,7 @@ :pep:`278` - Universal Newline Support Written and implemented by Jack Jansen. -.. % ====================================================================== +.. ====================================================================== .. _section-enumerate: @@ -430,7 +430,7 @@ :pep:`279` - The enumerate() built-in function Written and implemented by Raymond D. Hettinger. -.. % ====================================================================== +.. ====================================================================== PEP 282: The logging Package @@ -536,7 +536,7 @@ :pep:`282` - A Logging System Written by Vinay Sajip and Trent Mick; implemented by Vinay Sajip. -.. % ====================================================================== +.. ====================================================================== .. _section-bool: @@ -608,7 +608,7 @@ :pep:`285` - Adding a bool type Written and implemented by GvR. -.. % ====================================================================== +.. ====================================================================== PEP 293: Codec Error Handling Callbacks @@ -640,7 +640,7 @@ :pep:`293` - Codec Error Handling Callbacks Written and implemented by Walter D?rwald. -.. % ====================================================================== +.. ====================================================================== .. _section-pep301: @@ -689,7 +689,7 @@ :pep:`301` - Package Index and Metadata for Distutils Written and implemented by Richard Jones. -.. % ====================================================================== +.. ====================================================================== .. _section-pep302: @@ -755,7 +755,7 @@ :pep:`302` - New Import Hooks Written by Just van Rossum and Paul Moore. Implemented by Just van Rossum. -.. % ====================================================================== +.. ====================================================================== .. _section-pep305: @@ -801,7 +801,7 @@ Written and implemented by Kevin Altis, Dave Cole, Andrew McNamara, Skip Montanaro, Cliff Wells. -.. % ====================================================================== +.. ====================================================================== .. _section-pep307: @@ -844,7 +844,7 @@ :pep:`307` - Extensions to the pickle protocol Written and implemented by Guido van Rossum and Tim Peters. -.. % ====================================================================== +.. ====================================================================== .. _section-slices: @@ -954,7 +954,7 @@ consistent with Python 2.2, where :class:`int`, :class:`str`, etc., underwent the same change. -.. % ====================================================================== +.. ====================================================================== Other Language Changes @@ -1042,8 +1042,6 @@ objects available in the :mod:`types` module.) For example, you can create a new module object with the following code: - .. % XXX should new.py use PendingDeprecationWarning? - :: >>> import types @@ -1115,7 +1113,7 @@ assigned to :attr:`__bases__` along the lines of those relating to assigning to an instance's :attr:`__class__` attribute. -.. % ====================================================================== +.. ====================================================================== String Changes @@ -1179,7 +1177,7 @@ the usual way when the only reference to them is from the internal dictionary of interned strings. (Implemented by Oren Tirosh.) -.. % ====================================================================== +.. ====================================================================== Optimizations @@ -1211,7 +1209,7 @@ The net result of the 2.3 optimizations is that Python 2.3 runs the pystone benchmark around 25% faster than Python 2.2. -.. % ====================================================================== +.. ====================================================================== New, Improved, and Deprecated Modules @@ -1566,8 +1564,6 @@ http://mail.python.org/pipermail/python-dev/2002-December/031107.html for a more detailed explanation of this change. (Implemented by Martin von L?wis.) - .. % - * Calling Tcl methods through :mod:`_tkinter` no longer returns only strings. Instead, if Tcl returns other objects those objects are converted to their Python equivalent, if one exists, or wrapped with a :class:`_tkinter.Tcl_Obj` @@ -1671,7 +1667,7 @@ To implement this change, the :mod:`stringprep` module, the ``mkstringprep`` tool and the ``punycode`` encoding have been added. -.. % ====================================================================== +.. ====================================================================== Date/Time Type @@ -1726,7 +1722,7 @@ For more information, refer to the module's reference documentation. (Contributed by Tim Peters.) -.. % ====================================================================== +.. ====================================================================== The optparse Module @@ -1791,7 +1787,7 @@ Optik was written by Greg Ward, with suggestions from the readers of the Getopt SIG. -.. % ====================================================================== +.. ====================================================================== .. _section-pymalloc: @@ -1864,7 +1860,7 @@ of the file :file:`Objects/obmalloc.c` in the Python source code. The above link points to the file within the SourceForge CVS browser. -.. % ====================================================================== +.. ====================================================================== Build and C API Changes @@ -1926,7 +1922,7 @@ the type name leading up to the final period will no longer have the desired effect. For more detail, read the API reference documentation or the source. -.. % ====================================================================== +.. ====================================================================== Port-Specific Changes @@ -1952,7 +1948,7 @@ Other new platforms now supported by Python include AtheOS (http://www.atheos.cx/), GNU/Hurd, and OpenVMS. -.. % ====================================================================== +.. ====================================================================== .. _section-other: @@ -2003,7 +1999,7 @@ executed next. A ``jump`` command has been added to the :mod:`pdb` debugger taking advantage of this new feature. (Implemented by Richie Hindle.) -.. % ====================================================================== +.. ====================================================================== Porting to Python 2.3 @@ -2042,8 +2038,6 @@ desired upper bits. For example, to clear just the top bit (bit 31), you could write ``0xffffffffL &~(1L<<31)``. - .. % The empty groups below prevent conversion to guillemets. - * You can no longer disable assertions by assigning to ``__debug__``. * The Distutils :func:`setup` function has gained various new keyword arguments @@ -2065,7 +2059,7 @@ * Names of extension types defined by the modules included with Python now contain the module and a ``'.'`` in front of the type name. -.. % ====================================================================== +.. ====================================================================== .. _acks: Modified: python/branches/py3k/Doc/whatsnew/2.4.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.4.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.4.rst Mon Dec 31 17:14:33 2007 @@ -6,10 +6,10 @@ .. |release| replace:: 1.02 -.. % $Id: whatsnew24.tex 55005 2007-04-27 19:54:29Z guido.van.rossum $ -.. % Don't write extensive text for new sections; I'll do that. -.. % Feel free to add commented-out reminders of things that need -.. % to be covered. --amk +.. $Id: whatsnew24.tex 54632 2007-03-31 11:59:54Z georg.brandl $ +.. Don't write extensive text for new sections; I'll do that. +.. Feel free to add commented-out reminders of things that need +.. to be covered. --amk This article explains the new features in Python 2.4.1, released on March 30, 2005. @@ -29,7 +29,7 @@ referred to the PEP for a particular new feature for explanations of the implementation and design rationale. -.. % ====================================================================== +.. ====================================================================== PEP 218: Built-In Set Objects @@ -83,7 +83,7 @@ Originally proposed by Greg Wilson and ultimately implemented by Raymond Hettinger. -.. % ====================================================================== +.. ====================================================================== PEP 237: Unifying Long Integers and Integers @@ -108,7 +108,7 @@ Original PEP written by Moshe Zadka and GvR. The changes for 2.4 were implemented by Kalle Svensson. -.. % ====================================================================== +.. ====================================================================== PEP 289: Generator Expressions @@ -165,7 +165,7 @@ Proposed by Raymond Hettinger and implemented by Jiwon Seo with early efforts steered by Hye-Shik Chang. -.. % ====================================================================== +.. ====================================================================== PEP 292: Simpler String Substitutions @@ -199,25 +199,19 @@ If a key is missing from the dictionary, the :meth:`substitute` method will raise a :exc:`KeyError`. There's also a :meth:`safe_substitute` method that -ignores missing keys: - -.. % $ Terminate $-mode for Emacs - -:: +ignores missing keys:: >>> t = string.Template('$page: $title') >>> t.safe_substitute({'page':3}) '3: $title' -.. % $ Terminate math-mode for Emacs - .. seealso:: :pep:`292` - Simpler String Substitutions Written and implemented by Barry Warsaw. -.. % ====================================================================== +.. ====================================================================== PEP 318: Decorators for Functions and Methods @@ -346,7 +340,7 @@ http://www.python.org/moin/PythonDecoratorLibrary This Wiki page contains several examples of decorators. -.. % ====================================================================== +.. ====================================================================== PEP 322: Reverse Iteration @@ -382,7 +376,7 @@ :pep:`322` - Reverse Iteration Written and implemented by Raymond Hettinger. -.. % ====================================================================== +.. ====================================================================== PEP 324: New subprocess Module @@ -468,7 +462,7 @@ Written and implemented by Peter ?strand, with assistance from Fredrik Lundh and others. -.. % ====================================================================== +.. ====================================================================== PEP 327: Decimal Data Type @@ -698,7 +692,7 @@ proposed as a standard, and underlies the new Python decimal type. Much of this material was written by Mike Cowlishaw, designer of the Rexx language. -.. % ====================================================================== +.. ====================================================================== PEP 328: Multi-line Imports @@ -734,7 +728,7 @@ :pep:`328` - Imports: Multi-Line and Absolute/Relative Written by Aahz. Multi-line imports were implemented by Dima Dorfman. -.. % ====================================================================== +.. ====================================================================== PEP 331: Locale-Independent Float/String Conversions @@ -773,7 +767,7 @@ :pep:`331` - Locale-Independent Float/String Conversions Written by Christian R. Reis, and implemented by Gustavo Carneiro. -.. % ====================================================================== +.. ====================================================================== Other Language Changes @@ -932,7 +926,7 @@ * :const:`None` is now a constant; code that binds a new value to the name ``None`` is now a syntax error. (Contributed by Raymond Hettinger.) -.. % ====================================================================== +.. ====================================================================== Optimizations @@ -983,15 +977,13 @@ measurement of Python's performance. Your own applications may show greater or smaller benefits from Python 2.4.) -.. % pystone is almost useless for comparing different versions of Python; -.. % instead, it excels at predicting relative Python performance on -.. % different machines. -.. % So, this section would be more informative if it used other tools -.. % such as pybench and parrotbench. For a more application oriented -.. % benchmark, try comparing the timings of test_decimal.py under 2.3 -.. % and 2.4. +.. pystone is almost useless for comparing different versions of Python; + instead, it excels at predicting relative Python performance on different + machines. So, this section would be more informative if it used other tools + such as pybench and parrotbench. For a more application oriented benchmark, + try comparing the timings of test_decimal.py under 2.3 and 2.4. -.. % ====================================================================== +.. ====================================================================== New, Improved, and Deprecated Modules @@ -1322,9 +1314,9 @@ * The :mod:`mpz`, :mod:`rotor`, and :mod:`xreadlines` modules have been removed. -.. % ====================================================================== -.. % whole new modules get described in subsections here -.. % ===================== +.. ====================================================================== +.. whole new modules get described in subsections here +.. ===================== cookielib @@ -1348,7 +1340,7 @@ This module was contributed by John J. Lee. -.. % ================== +.. ================== doctest @@ -1447,7 +1439,7 @@ +rather ********************************************************************** -.. % ====================================================================== +.. ====================================================================== Build and C API Changes @@ -1500,7 +1492,7 @@ * The :ctype:`tracebackobject` type has been renamed to :ctype:`PyTracebackObject`. -.. % ====================================================================== +.. ====================================================================== Port-Specific Changes @@ -1509,7 +1501,7 @@ * The Windows port now builds under MSVC++ 7.1 as well as version 6. (Contributed by Martin von L?wis.) -.. % ====================================================================== +.. ====================================================================== Porting to Python 2.4 @@ -1556,7 +1548,7 @@ for certain illegal values; previously these errors would pass silently. For example, you can no longer set a handler on the :const:`SIGKILL` signal. -.. % ====================================================================== +.. ====================================================================== .. _acks: Modified: python/branches/py3k/Doc/whatsnew/2.5.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.5.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.5.rst Mon Dec 31 17:14:33 2007 @@ -6,8 +6,8 @@ .. |release| replace:: 1.01 -.. % $Id: whatsnew25.tex 56611 2007-07-29 08:26:10Z georg.brandl $ -.. % Fix XXX comments +.. $Id: whatsnew25.tex 56611 2007-07-29 08:26:10Z georg.brandl $ +.. Fix XXX comments This article explains the new features in Python 2.5. The final release of Python 2.5 is scheduled for August 2006; :pep:`356` describes the planned @@ -45,7 +45,7 @@ Comments, suggestions, and error reports for this document are welcome; please e-mail them to the author or open a bug in the Python bug tracker. -.. % ====================================================================== +.. ====================================================================== .. _pep-308: @@ -123,7 +123,7 @@ PEP written by Guido van Rossum and Raymond D. Hettinger; implemented by Thomas Wouters. -.. % ====================================================================== +.. ====================================================================== .. _pep-309: @@ -201,7 +201,7 @@ PEP proposed and written by Peter Harris; implemented by Hye-Shik Chang and Nick Coghlan, with adaptations by Raymond Hettinger. -.. % ====================================================================== +.. ====================================================================== .. _pep-314: @@ -248,7 +248,7 @@ PEP proposed and written by A.M. Kuchling, Richard Jones, and Fred Drake; implemented by Richard Jones and Fred Drake. -.. % ====================================================================== +.. ====================================================================== .. _pep-328: @@ -333,7 +333,7 @@ http://codespeak.net/py/current/doc/index.html The py library by Holger Krekel, which contains the :mod:`py.std` package. -.. % ====================================================================== +.. ====================================================================== .. _pep-338: @@ -359,7 +359,7 @@ :pep:`338` - Executing modules as scripts PEP written and implemented by Nick Coghlan. -.. % ====================================================================== +.. ====================================================================== .. _pep-341: @@ -407,7 +407,7 @@ :pep:`341` - Unifying try-except and try-finally PEP written by Georg Brandl; implementation by Thomas Lee. -.. % ====================================================================== +.. ====================================================================== .. _pep-342: @@ -553,7 +553,7 @@ http://www.sidhe.org/~dan/blog/archives/000178.html An explanation of coroutines from a Perl point of view, written by Dan Sugalski. -.. % ====================================================================== +.. ====================================================================== .. _pep-343: @@ -803,7 +803,7 @@ The documentation for the :mod:`contextlib` module. -.. % ====================================================================== +.. ====================================================================== .. _pep-352: @@ -862,7 +862,7 @@ :pep:`352` - Required Superclass for Exceptions PEP written by Brett Cannon and Guido van Rossum; implemented by Brett Cannon. -.. % ====================================================================== +.. ====================================================================== .. _pep-353: @@ -921,7 +921,7 @@ :pep:`353` - Using ssize_t as the index type PEP written and implemented by Martin von L?wis. -.. % ====================================================================== +.. ====================================================================== .. _pep-357: @@ -964,7 +964,7 @@ :pep:`357` - Allowing Any Object to be Used for Slicing PEP written and implemented by Travis Oliphant. -.. % ====================================================================== +.. ====================================================================== .. _other-lang: @@ -1024,7 +1024,7 @@ (Implemented by Georg Brandl following a suggestion by Tom Lynn.) - .. % RFE #1491485 + .. RFE #1491485 * The :func:`min` and :func:`max` built-in functions gained a ``key`` keyword parameter analogous to the ``key`` argument for :meth:`sort`. This parameter @@ -1055,7 +1055,7 @@ return non-negative numbers, and users often seem to use ``id(self)`` in :meth:`__hash__` methods (though this is discouraged). - .. % Bug #1536021 + .. Bug #1536021 * ASCII is now the default encoding for modules. It's now a syntax error if a module contains string literals with 8-bit characters but doesn't have an @@ -1106,7 +1106,7 @@ (Implemented by Brett Cannon.) -.. % ====================================================================== +.. ====================================================================== .. _interactive: @@ -1129,7 +1129,7 @@ and :option:`--version`; on Windows, it also accepts the :option:`/?` option for displaying a help message. (Implemented by Georg Brandl.) -.. % ====================================================================== +.. ====================================================================== .. _opts: @@ -1155,14 +1155,14 @@ Andrew Dalke at the NeedForSpeed sprint. Character maps were improved by Walter D?rwald and Martin von L?wis.) - .. % Patch 1313939, 1359618 + .. Patch 1313939, 1359618 * The :func:`long(str, base)` function is now faster on long digit strings because fewer intermediate results are calculated. The peak is for strings of around 800--1000 digits where the function is 6 times faster. (Contributed by Alan McIntyre and committed at the NeedForSpeed sprint.) - .. % Patch 1442927 + .. Patch 1442927 * It's now illegal to mix iterating over a file with ``for line in file`` and calling the file object's :meth:`read`/:meth:`readline`/:meth:`readlines` @@ -1172,7 +1172,7 @@ methods will now trigger a :exc:`ValueError` from the :meth:`read\*` method. (Implemented by Thomas Wouters.) - .. % Patch 1397960 + .. Patch 1397960 * The :mod:`struct` module now compiles structure format strings into an internal representation and caches this representation, yielding a 20% speedup. @@ -1194,8 +1194,8 @@ sprint.) Frame objects are also slightly smaller, which may improve cache locality and reduce memory usage a bit. (Contributed by Neal Norwitz.) - .. % Patch 876206 - .. % Patch 1337051 + .. Patch 876206 + .. Patch 1337051 * Python's built-in exceptions are now new-style classes, a change that speeds up instantiation considerably. Exception handling in Python 2.5 is therefore @@ -1206,9 +1206,9 @@ that the interpreter makes fewer :cfunc:`open` and :cfunc:`stat` calls on startup. (Contributed by Martin von L?wis and Georg Brandl.) - .. % Patch 921466 + .. Patch 921466 -.. % ====================================================================== +.. ====================================================================== .. _modules: @@ -1234,7 +1234,7 @@ entire input was fed to the non-incremental codec. See the :mod:`codecs` module documentation for details. (Designed and implemented by Walter D?rwald.) - .. % Patch 1436130 + .. Patch 1436130 * The :mod:`collections` module gained a new type, :class:`defaultdict`, that subclasses the standard :class:`dict` type. The new type mostly behaves like a @@ -1331,12 +1331,12 @@ easier to use non-ASCII characters in tests contained within a docstring. (Contributed by Bjorn Tillenius.) - .. % Patch 1080727 + .. Patch 1080727 * The :mod:`email` package has been updated to version 4.0. (Contributed by Barry Warsaw.) - .. % XXX need to provide some more detail here + .. XXX need to provide some more detail here * The :mod:`fileinput` module was made more flexible. Unicode filenames are now supported, and a *mode* parameter that defaults to ``"r"`` was added to the @@ -1394,7 +1394,7 @@ (Contributed by Georg Brandl.) - .. % Patch 1180296 + .. Patch 1180296 * The :mod:`mailbox` module underwent a massive rewrite to add the capability to modify mailboxes in addition to reading them. A new set of classes that include @@ -1462,7 +1462,7 @@ :attr:`st_birthtime`. The :attr:`st_flags` member is also available, if the platform supports it. (Contributed by Antti Louko and Diego Petten?.) - .. % (Patch 1180695, 1212117) + .. (Patch 1180695, 1212117) * The Python debugger provided by the :mod:`pdb` module can now store lists of commands to execute when a breakpoint is reached and execution stops. Once @@ -1471,7 +1471,7 @@ include commands that resume execution, such as ``continue`` or ``next``. (Contributed by Gr?goire Dooms.) - .. % Patch 790710 + .. Patch 790710 * The :mod:`pickle` and :mod:`cPickle` modules no longer accept a return value of ``None`` from the :meth:`__reduce__` method; the method must return a tuple @@ -1512,14 +1512,14 @@ :mod:`readline` module and therefore now works on non-Unix platforms. (Patch from Robert Kiendl.) - .. % Patch #1472854 + .. Patch #1472854 * The :mod:`SimpleXMLRPCServer` and :mod:`DocXMLRPCServer` classes now have a :attr:`rpc_paths` attribute that constrains XML-RPC operations to a limited set of URL paths; the default is to allow only ``'/'`` and ``'/RPC2'``. Setting :attr:`rpc_paths` to ``None`` or an empty tuple disables this path checking. - .. % Bug #1473048 + .. Bug #1473048 * The :mod:`socket` module now supports :const:`AF_NETLINK` sockets on Linux, thanks to a patch from Philippe Biondi. Netlink sockets are a Linux-specific @@ -1585,7 +1585,7 @@ The compression used for a tarfile opened in stream mode can now be autodetected using the mode ``'r|*'``. (Contributed by Lars Gust?bel.) - .. % patch 918101 + .. patch 918101 * The :mod:`threading` module now lets you set the stack size used when new threads are created. The :func:`stack_size([*size*])` function returns the @@ -1593,7 +1593,7 @@ sets a new value. Not all platforms support changing the stack size, but Windows, POSIX threading, and OS/2 all do. (Contributed by Andrew MacIntyre.) - .. % Patch 1454481 + .. Patch 1454481 * The :mod:`unicodedata` module has been updated to use version 4.1.0 of the Unicode character database. Version 3.2.0 is required by some specifications, @@ -1643,29 +1643,29 @@ of additional browsers were added to the supported list such as Firefox, Opera, Konqueror, and elinks. (Contributed by Oleg Broytmann and Georg Brandl.) - .. % Patch #754022 + .. Patch #754022 * The :mod:`xmlrpclib` module now supports returning :class:`datetime` objects for the XML-RPC date type. Supply ``use_datetime=True`` to the :func:`loads` function or the :class:`Unmarshaller` class to enable this feature. (Contributed by Skip Montanaro.) - .. % Patch 1120353 + .. Patch 1120353 * The :mod:`zipfile` module now supports the ZIP64 version of the format, meaning that a .zip archive can now be larger than 4 GiB and can contain individual files larger than 4 GiB. (Contributed by Ronald Oussoren.) - .. % Patch 1446489 + .. Patch 1446489 * The :mod:`zlib` module's :class:`Compress` and :class:`Decompress` objects now support a :meth:`copy` method that makes a copy of the object's internal state and returns a new :class:`Compress` or :class:`Decompress` object. (Contributed by Chris AtLee.) - .. % Patch 1435422 + .. Patch 1435422 -.. % ====================================================================== +.. ====================================================================== .. _module-ctypes: @@ -1746,7 +1746,7 @@ The documentation for the :mod:`ctypes` module. -.. % ====================================================================== +.. ====================================================================== .. _module-etree: @@ -1863,7 +1863,7 @@ http://effbot.org/zone/element-index.htm Official documentation for ElementTree. -.. % ====================================================================== +.. ====================================================================== .. _module-hashlib: @@ -1917,7 +1917,7 @@ The documentation for the :mod:`hashlib` module. -.. % ====================================================================== +.. ====================================================================== .. _module-sqlite: @@ -2026,7 +2026,7 @@ :pep:`249` - Database API Specification 2.0 PEP written by Marc-Andr? Lemburg. -.. % ====================================================================== +.. ====================================================================== .. _module-wsgiref: @@ -2039,7 +2039,7 @@ The :mod:`wsgiref` package is a reference implementation of the WSGI specification. -.. % XXX should this be in a PEP 333 section instead? +.. XXX should this be in a PEP 333 section instead? The package includes a basic HTTP server that will run a WSGI application; this server is useful for debugging but isn't intended for production use. Setting @@ -2054,8 +2054,8 @@ httpd = simple_server.make_server(host, port, wsgi_app) httpd.serve_forever() -.. % XXX discuss structure of WSGI applications? -.. % XXX provide an example using Django or some other framework? +.. XXX discuss structure of WSGI applications? +.. XXX provide an example using Django or some other framework? .. seealso:: @@ -2066,7 +2066,7 @@ :pep:`333` - Python Web Server Gateway Interface v1.0 PEP written by Phillip J. Eby. -.. % ====================================================================== +.. ====================================================================== .. _build-api: @@ -2125,8 +2125,8 @@ Schemenauer, plus the participants in a number of AST sprints at conferences such as PyCon. - .. % List of names taken from Jeremy's python-dev post at - .. % http://mail.python.org/pipermail/python-dev/2005-October/057500.html + .. List of names taken from Jeremy's python-dev post at + .. http://mail.python.org/pipermail/python-dev/2005-October/057500.html * Evan Jones's patch to obmalloc, first described in a talk at PyCon DC 2005, was applied. Python 2.4 allocated small objects in 256K-sized arenas, but never @@ -2194,7 +2194,7 @@ range = PyObject_CallFunction((PyObject*) &PyRange_Type, "lll", start, stop, step); -.. % ====================================================================== +.. ====================================================================== .. _ports: @@ -2214,7 +2214,7 @@ extension modules. :file:`.pyd` is now the only filename extension that will be searched for. -.. % ====================================================================== +.. ====================================================================== .. _porting: @@ -2269,7 +2269,7 @@ allocated with one family's :cfunc:`\*_Malloc` must be freed with the corresponding family's :cfunc:`\*_Free` function. -.. % ====================================================================== +.. ====================================================================== .. _acks: Modified: python/branches/py3k/Doc/whatsnew/2.6.rst ============================================================================== --- python/branches/py3k/Doc/whatsnew/2.6.rst (original) +++ python/branches/py3k/Doc/whatsnew/2.6.rst Mon Dec 31 17:14:33 2007 @@ -2,54 +2,53 @@ What's New in Python 2.6 **************************** -.. % XXX mention switch to reST for documentation -.. % XXX mention switch to Roundup for bug tracking +.. XXX mention switch to Roundup for bug tracking :Author: A.M. Kuchling :Release: |release| :Date: |today| -.. % $Id: whatsnew26.tex 55963 2007-06-13 18:07:49Z guido.van.rossum $ -.. % Rules for maintenance: -.. % -.. % * Anyone can add text to this document. Do not spend very much time -.. % on the wording of your changes, because your text will probably -.. % get rewritten to some degree. -.. % -.. % * The maintainer will go through Misc/NEWS periodically and add -.. % changes; it's therefore more important to add your changes to -.. % Misc/NEWS than to this file. -.. % -.. % * This is not a complete list of every single change; completeness -.. % is the purpose of Misc/NEWS. Some changes I consider too small -.. % or esoteric to include. If such a change is added to the text, -.. % I'll just remove it. (This is another reason you shouldn't spend -.. % too much time on writing your addition.) -.. % -.. % * If you want to draw your new text to the attention of the -.. % maintainer, add 'XXX' to the beginning of the paragraph or -.. % section. -.. % -.. % * It's OK to just add a fragmentary note about a change. For -.. % example: "XXX Describe the transmogrify() function added to the -.. % socket module." The maintainer will research the change and -.. % write the necessary text. -.. % -.. % * You can comment out your additions if you like, but it's not -.. % necessary (especially when a final release is some months away). -.. % -.. % * Credit the author of a patch or bugfix. Just the name is -.. % sufficient; the e-mail address isn't necessary. -.. % -.. % * It's helpful to add the bug/patch number as a comment: -.. % -.. % % Patch 12345 -.. % XXX Describe the transmogrify() function added to the socket -.. % module. -.. % (Contributed by P.Y. Developer.) -.. % -.. % This saves the maintainer the effort of going through the SVN log -.. % when researching a change. +.. $Id: whatsnew26.tex 55746 2007-06-02 18:33:53Z neal.norwitz $ + Rules for maintenance: + + * Anyone can add text to this document. Do not spend very much time + on the wording of your changes, because your text will probably + get rewritten to some degree. + + * The maintainer will go through Misc/NEWS periodically and add + changes; it's therefore more important to add your changes to + Misc/NEWS than to this file. + + * This is not a complete list of every single change; completeness + is the purpose of Misc/NEWS. Some changes I consider too small + or esoteric to include. If such a change is added to the text, + I'll just remove it. (This is another reason you shouldn't spend + too much time on writing your addition.) + + * If you want to draw your new text to the attention of the + maintainer, add 'XXX' to the beginning of the paragraph or + section. + + * It's OK to just add a fragmentary note about a change. For + example: "XXX Describe the transmogrify() function added to the + socket module." The maintainer will research the change and + write the necessary text. + + * You can comment out your additions if you like, but it's not + necessary (especially when a final release is some months away). + + * Credit the author of a patch or bugfix. Just the name is + sufficient; the e-mail address isn't necessary. + + * It's helpful to add the bug/patch number as a comment: + + % Patch 12345 + XXX Describe the transmogrify() function added to the socket + module. + (Contributed by P.Y. Developer.) + + This saves the maintainer the effort of going through the SVN log + when researching a change. This article explains the new features in Python 2.6. No release date for Python 2.6 has been set; it will probably be released in mid 2008. @@ -60,14 +59,14 @@ complete implementation and design rationale, refer to the PEP for a particular new feature. -.. % Compare with previous release in 2 - 3 sentences here. -.. % add hyperlink when the documentation becomes available online. +.. Compare with previous release in 2 - 3 sentences here. + add hyperlink when the documentation becomes available online. -.. % ====================================================================== -.. % Large, PEP-level features and changes should be described here. -.. % Should there be a new section here for 3k migration? -.. % Or perhaps a more general section describing module changes/deprecation? -.. % ====================================================================== +.. ======================================================================== +.. Large, PEP-level features and changes should be described here. +.. Should there be a new section here for 3k migration? +.. Or perhaps a more general section describing module changes/deprecation? +.. ======================================================================== Python 3.0 ================ @@ -156,7 +155,7 @@ `Docutils `__: The fundamental reStructured Text parser and toolset. - `Documenting Python `__: Describes how to write for + :ref:`documenting-index`: Describes how to write for Python's documentation. @@ -407,7 +406,7 @@ The documentation for the :mod:`contextlib` module. -.. % ====================================================================== +.. ====================================================================== .. _pep-0366: @@ -425,7 +424,7 @@ that implements the :option:`-m` switch now does this, so relative imports can now be used in scripts running from inside a package. -.. % ====================================================================== +.. ====================================================================== .. _pep-3110: @@ -475,7 +474,7 @@ :pep:`3110` - Catching Exceptions in Python 3000 PEP written and implemented by Collin Winter. -.. % ====================================================================== +.. ====================================================================== .. _pep-3119: @@ -509,14 +508,14 @@ >>> f(**ud) ['a', 'b'] - .. % Patch 1686487 + .. Patch 1686487 * The built-in types now have improved support for extended slicing syntax, where various combinations of ``(start, stop, step)`` are supplied. Previously, the support was partial and certain corner cases wouldn't work. (Implemented by Thomas Wouters.) - .. % Revision 57619 + .. Revision 57619 * Properties now have two attributes, :attr:`setter` and :attr:`deleter`, that are useful shortcuts for @@ -544,14 +543,14 @@ This is a backport of a Python 3.0 change. (Contributed by Mark Dickinson.) - .. % Patch #1675423 + .. Patch #1675423 A numerical nicety: when creating a complex number from two floats on systems that support signed zeros (-0 and +0), the :func:`complex()` constructor will now preserve the sign of the zero. - .. % Patch 1507 + .. Patch 1507 * Changes to the :class:`Exception` interface as dictated by :pep:`352` continue to be made. For 2.6, @@ -564,26 +563,26 @@ will not inadvertently catch :exc:`GeneratorExit`. (Contributed by Chad Austin.) - .. % Patch #1537 + .. Patch #1537 * The :func:`compile` built-in function now accepts keyword arguments as well as positional parameters. (Contributed by Thomas Wouters.) - .. % Patch 1444529 + .. Patch 1444529 * The :func:`complex` constructor now accepts strings containing parenthesized complex numbers, letting ``complex(repr(cmplx))`` will now round-trip values. For example, ``complex('(3+4j)')`` now returns the value (3+4j). - .. % Patch 1491866 + .. Patch 1491866 * The string :meth:`translate` method now accepts ``None`` as the translation table parameter, which is treated as the identity transformation. This makes it easier to carry out operations that only delete characters. (Contributed by Bengt Richter.) - .. % Patch 1193128 + .. Patch 1193128 * The built-in :func:`dir` function now checks for a :meth:`__dir__` method on the objects it receives. This method must return a list @@ -592,14 +591,14 @@ Objects that have :meth:`__getattr__` or :meth:`__getattribute__` methods can use this to advertise pseudo-attributes they will honor. - .. % Patch 1591665 + .. Patch 1591665 * An obscure change: when you use the the :func:`locals` function inside a :keyword:`class` statement, the resulting dictionary no longer returns free variables. (Free variables, in this case, are variables referred to in the :keyword:`class` statement that aren't attributes of the class.) -.. % ====================================================================== +.. ====================================================================== Optimizations @@ -612,7 +611,7 @@ The net result of the 2.6 optimizations is that Python 2.6 runs the pystone benchmark around XX% faster than Python 2.5. -.. % ====================================================================== +.. ====================================================================== New, Improved, and Deprecated Modules @@ -627,7 +626,7 @@ available, instead of restricting itself to protocol 1. (Contributed by W. Barnes.) - .. % Patch 1551443 + .. Patch 1551443 * A new data type in the :mod:`collections` module: :class:`namedtuple(typename, fieldnames)` is a factory function that creates subclasses of the standard tuple @@ -677,14 +676,14 @@ * The :mod:`ctypes` module now supports a :class:`c_bool` datatype that represents the C99 ``bool`` type. (Contributed by David Remahl.) - .. % Patch 1649190 + .. Patch 1649190 The :mod:`ctypes` string, buffer and array types also have improved support for extended slicing syntax, where various combinations of ``(start, stop, step)`` are supplied. (Implemented by Thomas Wouters.) - .. % Revision 57769 + .. Revision 57769 * A new method in the :mod:`curses` module: for a window, :meth:`chgat` changes @@ -722,12 +721,12 @@ to drop the built-in in the 2.x series. (Patched by Christian Heimes.) - .. % Patch 1739906 + .. Patch 1739906 * The :func:`glob.glob` function can now return Unicode filenames if a Unicode path was used and Unicode filenames are matched within the directory. - .. % Patch #1001604 + .. Patch #1001604 * The :mod:`gopherlib` module has been removed. @@ -760,7 +759,7 @@ :func:`macostools.touched` function to be removed because it depended on the :mod:`macfs` module. - .. % Patch #1490190 + .. Patch #1490190 * The :mod:`new` module has been removed from Python 3.0. Importing it therefore @@ -783,13 +782,13 @@ into an infinite recursion if there's a symlink that points to a parent directory. - .. % Patch 1273829 + .. Patch 1273829 * The ``os.environ`` object's :meth:`clear` method will now unset the environment variables using :func:`os.unsetenv` in addition to clearing the object's keys. (Contributed by Martin Horcicka.) - .. % Patch #1181 + .. Patch #1181 * In the :mod:`os.path` module, the :func:`splitext` function has been changed to not split on leading period characters. @@ -797,27 +796,27 @@ For example, ``os.path.splitext('.ipython')`` now returns ``('.ipython', '')`` instead of ``('', '.ipython')``. - .. % Bug #115886 + .. Bug #115886 A new function, :func:`relpath(path, start)` returns a relative path from the ``start`` path, if it's supplied, or from the current working directory to the destination ``path``. (Contributed by Richard Barran.) - .. % Patch 1339796 + .. Patch 1339796 On Windows, :func:`os.path.expandvars` will now expand environment variables in the form "%var%", and "~user" will be expanded into the user's home directory path. (Contributed by Josiah Carlson.) - .. % Patch 957650 + .. Patch 957650 * The Python debugger provided by the :mod:`pdb` module gained a new command: "run" restarts the Python program being debugged, and can optionally take new command-line arguments for the program. (Contributed by Rocky Bernstein.) - .. % Patch #1393667 + .. Patch #1393667 * New functions in the :mod:`posix` module: :func:`chflags` and :func:`lchflags` are wrappers for the corresponding system calls (where they're available). @@ -833,7 +832,7 @@ on earlier versions of Python. (Contributed by Shawn Ligocki.) - .. % Issue 1727780 + .. Issue 1727780 * The :mod:`rgbimg` module has been removed. @@ -876,7 +875,7 @@ added by Facundo Batista; LMTP implemented by Leif Hedstrom.) - .. % Patch #957003 + .. Patch #957003 * A new variable in the :mod:`sys` module, :attr:`float_info`, is a dictionary @@ -887,7 +886,7 @@ (smallest difference between 1.0 and the next largest value representable), and several others. (Contributed by Christian Heimes.) - .. % Patch 1534 + .. Patch 1534 * The :mod:`tarfile` module now supports POSIX.1-2001 (pax) and POSIX.1-1988 (ustar) format tarfiles, in addition to the GNU tar @@ -923,7 +922,7 @@ behaviour can now be changed by passing ``delete=False`` to the constructor. (Contributed by Damien Miller.) - .. % Patch #1537850 + .. Patch #1537850 * The :mod:`test.test_support` module now contains a :func:`EnvironmentVarGuard` @@ -960,7 +959,7 @@ whitespace. >>> - .. % Patch #1581073 + .. Patch #1581073 * The :mod:`timeit` module now accepts callables as well as strings for the statement being timed and for the setup code. @@ -970,7 +969,7 @@ ``timeit(stmt, setup, time, number)`` create an instance and call the corresponding method. (Contributed by Erik Demaine.) - .. % Patch #1533909 + .. Patch #1533909 * An optional ``timeout`` parameter was added to the :func:`urllib.urlopen` function and the @@ -995,7 +994,7 @@ open the socket and begin listening for connections. (Contributed by Peter Parente.) - .. % Patch 1599845 + .. Patch 1599845 :class:`SimpleXMLRPCServer` also has a :attr:`_send_traceback_header` attribute; if true, the exception and formatted traceback are returned @@ -1005,8 +1004,8 @@ information. (Contributed by Alan McIntyre as part of his project for Google's Summer of Code 2007.) -.. % ====================================================================== -.. % whole new modules get described in subsections here +.. ====================================================================== +.. whole new modules get described in subsections here Improved SSL Support -------------------------------------------------- @@ -1028,7 +1027,7 @@ SSL module documentation. -.. % ====================================================================== +.. ====================================================================== Build and C API Changes @@ -1045,7 +1044,7 @@ that wish to use the :mod:`bsddb` module for their own purposes. (Contributed by Duncan Grisby.) - .. % Patch 1551895 + .. Patch 1551895 * Several functions return information about the platform's floating-point support. :cfunc:`PyFloat_GetMax` returns @@ -1057,9 +1056,9 @@ (smallest difference between 1.0 and the next largest value representable), and several others. - .. % Issue 1534 + .. Issue 1534 -.. % ====================================================================== +.. ====================================================================== Port-Specific Changes @@ -1067,7 +1066,7 @@ Platform-specific changes go here. -.. % ====================================================================== +.. ====================================================================== .. _section-other: @@ -1084,7 +1083,7 @@ * Details will go here. -.. % ====================================================================== +.. ====================================================================== Porting to Python 2.6 @@ -1098,9 +1097,9 @@ :exc:`StandardError` but now it is, through :exc:`IOError`. (Implemented by Gregory P. Smith.) - .. % http://bugs.python.org/issue1706815 + .. Issue 1706815 -.. % ====================================================================== +.. ====================================================================== .. _acks: Modified: python/branches/py3k/Lib/distutils/command/bdist_wininst.py ============================================================================== --- python/branches/py3k/Lib/distutils/command/bdist_wininst.py (original) +++ python/branches/py3k/Lib/distutils/command/bdist_wininst.py Mon Dec 31 17:14:33 2007 @@ -304,5 +304,5 @@ directory = os.path.dirname(__file__) # we must use a wininst-x.y.exe built with the same C compiler # used for python. XXX What about mingw, borland, and so on? - filename = os.path.join(directory, "wininst-%s.exe" % bv) + filename = os.path.join(directory, "wininst-%.1f.exe" % bv) return open(filename, "rb").read() Deleted: /python/branches/py3k/Lib/distutils/command/wininst-6.exe ============================================================================== Binary file. No diff available. Deleted: /python/branches/py3k/Lib/distutils/command/wininst-8.exe ============================================================================== Binary file. No diff available. Modified: python/branches/py3k/Lib/test/output/test_cProfile ============================================================================== --- python/branches/py3k/Lib/test/output/test_cProfile (original) +++ python/branches/py3k/Lib/test/output/test_cProfile Mon Dec 31 17:14:33 2007 @@ -5,7 +5,7 @@ ncalls tottime percall cumtime percall filename:lineno(function) 1 0.000 0.000 1.000 1.000 :1() - 2 0.000 0.000 0.000 0.000 io.py:1211(flush) + 2 0.000 0.000 0.000 0.000 io.py:1212(flush) 1 0.000 0.000 0.000 0.000 io.py:269(flush) 1 0.000 0.000 0.000 0.000 io.py:656(closed) 1 0.000 0.000 0.000 0.000 io.py:874(flush) @@ -30,7 +30,7 @@ Function called... ncalls tottime cumtime :1() -> 1 0.270 1.000 test_cProfile.py:30(testfunc) -io.py:1211(flush) -> 1 0.000 0.000 io.py:269(flush) +io.py:1212(flush) -> 1 0.000 0.000 io.py:269(flush) 1 0.000 0.000 io.py:874(flush) io.py:269(flush) -> io.py:656(closed) -> @@ -53,7 +53,7 @@ test_cProfile.py:93(helper2) -> 8 0.064 0.080 test_cProfile.py:103(subhelper) 8 0.000 0.008 {hasattr} {exec} -> 1 0.000 1.000 :1() - 2 0.000 0.000 io.py:1211(flush) + 2 0.000 0.000 io.py:1212(flush) {hasattr} -> 12 0.012 0.012 test_cProfile.py:115(__getattr__) {method 'append' of 'list' objects} -> {method 'disable' of '_lsprof.Profiler' objects} -> @@ -65,10 +65,10 @@ Function was called by... ncalls tottime cumtime :1() <- 1 0.000 1.000 {exec} -io.py:1211(flush) <- 2 0.000 0.000 {exec} -io.py:269(flush) <- 1 0.000 0.000 io.py:1211(flush) +io.py:1212(flush) <- 2 0.000 0.000 {exec} +io.py:269(flush) <- 1 0.000 0.000 io.py:1212(flush) io.py:656(closed) <- 1 0.000 0.000 io.py:874(flush) -io.py:874(flush) <- 1 0.000 0.000 io.py:1211(flush) +io.py:874(flush) <- 1 0.000 0.000 io.py:1212(flush) test_cProfile.py:103(subhelper) <- 8 0.064 0.080 test_cProfile.py:93(helper2) test_cProfile.py:115(__getattr__) <- 16 0.016 0.016 test_cProfile.py:103(subhelper) 12 0.012 0.012 {hasattr} Modified: python/branches/py3k/Lib/test/output/test_profile ============================================================================== --- python/branches/py3k/Lib/test/output/test_profile (original) +++ python/branches/py3k/Lib/test/output/test_profile Mon Dec 31 17:14:33 2007 @@ -10,7 +10,7 @@ 12 0.000 0.000 0.012 0.001 :0(hasattr) 1 0.000 0.000 0.000 0.000 :0(setprofile) 1 0.000 0.000 1.000 1.000 :1() - 2 0.000 0.000 0.000 0.000 io.py:1211(flush) + 2 0.000 0.000 0.000 0.000 io.py:1212(flush) 1 0.000 0.000 0.000 0.000 io.py:269(flush) 1 0.000 0.000 0.000 0.000 io.py:656(closed) 1 0.000 0.000 0.000 0.000 io.py:874(flush) @@ -33,11 +33,11 @@ :0(append) -> :0(exc_info) -> :0(exec) -> :1()(1) 1.000 - io.py:1211(flush)(2) 0.000 + io.py:1212(flush)(2) 0.000 :0(hasattr) -> test_profile.py:115(__getattr__)(12) 0.028 :0(setprofile) -> :1() -> test_profile.py:30(testfunc)(1) 1.000 -io.py:1211(flush) -> io.py:269(flush)(1) 0.000 +io.py:1212(flush) -> io.py:269(flush)(1) 0.000 io.py:874(flush)(1) 0.000 io.py:269(flush) -> io.py:656(closed) -> @@ -74,10 +74,10 @@ test_profile.py:93(helper2)(8) 0.400 :0(setprofile) <- profile:0(testfunc())(1) 1.000 :1() <- :0(exec)(1) 1.000 -io.py:1211(flush) <- :0(exec)(2) 1.000 -io.py:269(flush) <- io.py:1211(flush)(1) 0.000 +io.py:1212(flush) <- :0(exec)(2) 1.000 +io.py:269(flush) <- io.py:1212(flush)(1) 0.000 io.py:656(closed) <- io.py:874(flush)(1) 0.000 -io.py:874(flush) <- io.py:1211(flush)(1) 0.000 +io.py:874(flush) <- io.py:1212(flush)(1) 0.000 profile:0(profiler) <- profile:0(testfunc()) <- profile:0(profiler)(1) 0.000 test_profile.py:103(subhelper) <- test_profile.py:93(helper2)(8) 0.400 Modified: python/branches/py3k/Tools/buildbot/build-amd64.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/build-amd64.bat (original) +++ python/branches/py3k/Tools/buildbot/build-amd64.bat Mon Dec 31 17:14:33 2007 @@ -3,4 +3,4 @@ cmd /c Tools\buildbot\external-amd64.bat call "%VS71COMNTOOLS%vsvars32.bat" REM cmd /q/c Tools\buildbot\kill_python.bat -devenv.com /build ReleaseAMD64 PCbuild\pcbuild.sln +devenv.com /build ReleaseAMD64 PC\VS7.1\pcbuild.sln Modified: python/branches/py3k/Tools/buildbot/build.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/build.bat (original) +++ python/branches/py3k/Tools/buildbot/build.bat Mon Dec 31 17:14:33 2007 @@ -2,4 +2,4 @@ cmd /c Tools\buildbot\external.bat call "%VS71COMNTOOLS%vsvars32.bat" cmd /q/c Tools\buildbot\kill_python.bat -devenv.com /useenv /build Debug PCbuild\pcbuild.sln +devenv.com /useenv /build Debug PC\VS7.1\pcbuild.sln Modified: python/branches/py3k/Tools/buildbot/buildmsi.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/buildmsi.bat (original) +++ python/branches/py3k/Tools/buildbot/buildmsi.bat Mon Dec 31 17:14:33 2007 @@ -9,7 +9,7 @@ @rem build Python cmd /q/c Tools\buildbot\kill_python.bat -devenv.com /useenv /build Release PCbuild\pcbuild.sln +devenv.com /useenv /build Release PC\VS7.1\pcbuild.sln @rem build the documentation bash.exe -c 'cd Doc;make PYTHON=python2.5 update htmlhelp' Modified: python/branches/py3k/Tools/buildbot/clean-amd64.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/clean-amd64.bat (original) +++ python/branches/py3k/Tools/buildbot/clean-amd64.bat Mon Dec 31 17:14:33 2007 @@ -1,6 +1,6 @@ @rem Used by the buildbot "clean" step. call "%VS71COMNTOOLS%vsvars32.bat" -cd PCbuild +cd PC\VS7.1 @echo Deleting .pyc/.pyo files ... del /s Lib\*.pyc Lib\*.pyo devenv.com /clean ReleaseAMD64 pcbuild.sln Modified: python/branches/py3k/Tools/buildbot/clean.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/clean.bat (original) +++ python/branches/py3k/Tools/buildbot/clean.bat Mon Dec 31 17:14:33 2007 @@ -1,6 +1,6 @@ @rem Used by the buildbot "clean" step. call "%VS71COMNTOOLS%vsvars32.bat" -cd PCbuild +cd PC\VS7.1 @echo Deleting .pyc/.pyo files ... del /s Lib\*.pyc Lib\*.pyo devenv.com /clean Release pcbuild.sln Modified: python/branches/py3k/Tools/buildbot/kill_python.c ============================================================================== --- python/branches/py3k/Tools/buildbot/kill_python.c (original) +++ python/branches/py3k/Tools/buildbot/kill_python.c Mon Dec 31 17:14:33 2007 @@ -1,4 +1,4 @@ -/* This program looks for processes which have build\PCbuild\python.exe +/* This program looks for processes which have build\PC\VS7.1\python.exe in their path and terminates them. */ #include #include @@ -46,14 +46,14 @@ /* Check if we are running a buildbot version of Python. On Windows, this will always be a debug build from the - PCbuild directory. build\\PCbuild\\python_d.exe + PC\VS7.1 directory. build\\PC\\VS7.1\\python_d.exe On Cygwin, the pathname is similar to other Unixes. Use \\build\\python.exe to ensure we don't match - PCbuild\\python.exe which could be a normal instance + PC\\VS7.1\\python.exe which could be a normal instance of Python running on vanilla Windows. */ - if ((strstr(path, "build\\pcbuild\\python_d.exe") != NULL) || + if ((strstr(path, "build\\pc\\vs7.1\\python_d.exe") != NULL) || (strstr(path, "\\build\\python.exe") != NULL)) { printf("Terminating %s (pid %d)\n", path, pids[i]); if (!TerminateProcess(hProcess, 1)) { Modified: python/branches/py3k/Tools/buildbot/test-amd64.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/test-amd64.bat (original) +++ python/branches/py3k/Tools/buildbot/test-amd64.bat Mon Dec 31 17:14:33 2007 @@ -1,3 +1,3 @@ @rem Used by the buildbot "test" step. -cd PCbuild +cd PC\VS7.1 call rt.bat -q -uall -rw Modified: python/branches/py3k/Tools/buildbot/test.bat ============================================================================== --- python/branches/py3k/Tools/buildbot/test.bat (original) +++ python/branches/py3k/Tools/buildbot/test.bat Mon Dec 31 17:14:33 2007 @@ -1,3 +1,3 @@ @rem Used by the buildbot "test" step. -cd PCbuild +cd PC\VS7.1 call rt.bat -d -q -uall -rw -n Modified: python/branches/py3k/Tools/msi/msi.py ============================================================================== --- python/branches/py3k/Tools/msi/msi.py (original) +++ python/branches/py3k/Tools/msi/msi.py Mon Dec 31 17:14:33 2007 @@ -27,7 +27,7 @@ # Where is sqlite3.dll located, relative to srcdir? sqlite_dir = "../sqlite-source-3.3.4" # path to PCbuild directory -PCBUILD="PCbuild" +PCBUILD="PC/VS7.1" #PCBUILD="PCbuild9" # msvcrt version MSVCR = "71" Modified: python/branches/py3k/configure ============================================================================== --- python/branches/py3k/configure (original) +++ python/branches/py3k/configure Mon Dec 31 17:14:33 2007 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 59533 . +# From configure.in Revision: 59558 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61 for python 3.0. # @@ -1838,14 +1838,6 @@ _ACEOF -# OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is -# also defined. This can be overridden by defining _BSD_SOURCE - -cat >>confdefs.h <<\_ACEOF -#define _BSD_SOURCE 1 -_ACEOF - - # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables # u_int on Irix 5.3. Defining _BSD_TYPES brings it back. @@ -2012,7 +2004,16 @@ # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0]) - define_xopen_source=no;; + define_xopen_source=no + # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is + # also defined. This can be overridden by defining _BSD_SOURCE + # As this has a different meaning on Linux, only define it on OpenBSD + +cat >>confdefs.h <<\_ACEOF +#define _BSD_SOURCE 1 +_ACEOF + + ;; # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by # Marc Recht Modified: python/branches/py3k/configure.in ============================================================================== --- python/branches/py3k/configure.in (original) +++ python/branches/py3k/configure.in Mon Dec 31 17:14:33 2007 @@ -50,10 +50,6 @@ # them. AC_DEFINE(__BSD_VISIBLE, 1, [Define on FreeBSD to activate all library features]) -# OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is -# also defined. This can be overridden by defining _BSD_SOURCE -AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) - # The later defininition of _XOPEN_SOURCE and _POSIX_C_SOURCE disables # u_int on Irix 5.3. Defining _BSD_TYPES brings it back. AC_DEFINE(_BSD_TYPES, 1, [Define on Irix to enable u_int]) @@ -206,7 +202,12 @@ # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) - define_xopen_source=no;; + define_xopen_source=no + # OpenBSD undoes our definition of __BSD_VISIBLE if _XOPEN_SOURCE is + # also defined. This can be overridden by defining _BSD_SOURCE + # As this has a different meaning on Linux, only define it on OpenBSD + AC_DEFINE(_BSD_SOURCE, 1, [Define on OpenBSD to activate all library features]) + ;; # Defining _XOPEN_SOURCE on NetBSD version prior to the introduction of # _NETBSD_SOURCE disables certain features (eg. setgroups). Reported by # Marc Recht From python-3000-checkins at python.org Mon Dec 31 17:16:18 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 31 Dec 2007 17:16:18 +0100 (CET) Subject: [Python-3000-checkins] r59626 - python/branches/py3k/PCbuild Message-ID: <20071231161618.E1CF51E400B@bag.python.org> Author: christian.heimes Date: Mon Dec 31 17:16:18 2007 New Revision: 59626 Modified: python/branches/py3k/PCbuild/ (props changed) Log: Fixed svn:ignore From python-3000-checkins at python.org Mon Dec 31 17:18:23 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 31 Dec 2007 17:18:23 +0100 (CET) Subject: [Python-3000-checkins] r59628 - in python/branches/py3k: PC/VS7.1/_bsddb.vcproj PC/VS7.1/_ctypes.vcproj PC/VS7.1/_ctypes_test.vcproj PC/VS7.1/_elementtree.vcproj PC/VS7.1/_msi.vcproj PC/VS7.1/_socket.vcproj PC/VS7.1/_sqlite3.vcproj PC/VS7.1/_ssl.vcproj PC/VS7.1/_testcapi.vcproj PC/VS7.1/_tkinter.vcproj PC/VS7.1/bz2.vcproj PC/VS7.1/make_versioninfo.vcproj PC/VS7.1/pyexpat.vcproj PC/VS7.1/python.vcproj PC/VS7.1/pythoncore.vcproj PC/VS7.1/pythonw.vcproj PC/VS7.1/select.vcproj PC/VS7.1/unicodedata.vcproj PC/VS7.1/w9xpopen.vcproj PC/VS7.1/winsound.vcproj Message-ID: <20071231161823.9CA9D1E4021@bag.python.org> Author: christian.heimes Date: Mon Dec 31 17:18:22 2007 New Revision: 59628 Modified: python/branches/py3k/ (props changed) python/branches/py3k/PC/VS7.1/_bsddb.vcproj python/branches/py3k/PC/VS7.1/_ctypes.vcproj python/branches/py3k/PC/VS7.1/_ctypes_test.vcproj python/branches/py3k/PC/VS7.1/_elementtree.vcproj python/branches/py3k/PC/VS7.1/_msi.vcproj python/branches/py3k/PC/VS7.1/_socket.vcproj python/branches/py3k/PC/VS7.1/_sqlite3.vcproj python/branches/py3k/PC/VS7.1/_ssl.vcproj python/branches/py3k/PC/VS7.1/_testcapi.vcproj python/branches/py3k/PC/VS7.1/_tkinter.vcproj python/branches/py3k/PC/VS7.1/bz2.vcproj python/branches/py3k/PC/VS7.1/make_versioninfo.vcproj python/branches/py3k/PC/VS7.1/pyexpat.vcproj python/branches/py3k/PC/VS7.1/python.vcproj python/branches/py3k/PC/VS7.1/pythoncore.vcproj python/branches/py3k/PC/VS7.1/pythonw.vcproj python/branches/py3k/PC/VS7.1/select.vcproj python/branches/py3k/PC/VS7.1/unicodedata.vcproj python/branches/py3k/PC/VS7.1/w9xpopen.vcproj python/branches/py3k/PC/VS7.1/winsound.vcproj Log: Merged revisions 59625-59627 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk ........ r59627 | christian.heimes | 2007-12-31 17:17:13 +0100 (Mon, 31 Dec 2007) | 1 line Fixed include paths of PC/VS7.1 ........ Modified: python/branches/py3k/PC/VS7.1/_bsddb.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_bsddb.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_bsddb.vcproj Mon Dec 31 17:18:22 2007 @@ -20,7 +20,7 @@ + RelativePath="..\..\Modules\_bsddb.c"> Modified: python/branches/py3k/PC/VS7.1/_ctypes.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_ctypes.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_ctypes.vcproj Mon Dec 31 17:18:22 2007 @@ -20,7 +20,7 @@ + RelativePath="..\..\Modules\_ctypes\_ctypes.c"> + RelativePath="..\..\Modules\_ctypes\callbacks.c"> + RelativePath="..\..\Modules\_ctypes\callproc.c"> + RelativePath="..\..\Modules\_ctypes\cfield.c"> + RelativePath="..\..\Modules\_ctypes\libffi_msvc\ffi.c"> + RelativePath="..\..\Modules\_ctypes\malloc_closure.c"> + RelativePath="..\..\Modules\_ctypes\libffi_msvc\prep_cif.c"> + RelativePath="..\..\Modules\_ctypes\stgdict.c"> + RelativePath="..\..\Modules\_ctypes\libffi_msvc\win32.c"> @@ -277,7 +277,7 @@ + RelativePath="..\..\Modules\_ctypes\libffi_msvc\win64.asm"> Modified: python/branches/py3k/PC/VS7.1/_ctypes_test.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_ctypes_test.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_ctypes_test.vcproj Mon Dec 31 17:18:22 2007 @@ -19,7 +19,7 @@ + RelativePath="..\..\Modules\_ctypes\_ctypes_test.c"> Modified: python/branches/py3k/PC/VS7.1/_elementtree.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_elementtree.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_elementtree.vcproj Mon Dec 31 17:18:22 2007 @@ -21,7 +21,7 @@ + RelativePath="..\..\Modules\_elementtree.c"> + RelativePath="..\..\Modules\expat\xmlparse.c"> + RelativePath="..\..\Modules\expat\xmlrole.c"> + RelativePath="..\..\Modules\expat\xmltok.c"> Modified: python/branches/py3k/PC/VS7.1/_msi.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_msi.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_msi.vcproj Mon Dec 31 17:18:22 2007 @@ -5,7 +5,7 @@ Name="_msi" ProjectGUID="{2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}" SccProjectName="_msi" - SccLocalPath="..\pc"> + SccLocalPath="..\..\pc"> @@ -22,7 +22,7 @@ + RelativePath="..\..\PC\_msi.c"> Modified: python/branches/py3k/PC/VS7.1/_socket.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_socket.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_socket.vcproj Mon Dec 31 17:18:22 2007 @@ -20,7 +20,7 @@ + RelativePath="..\..\Modules\socketmodule.c"> Modified: python/branches/py3k/PC/VS7.1/_sqlite3.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_sqlite3.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_sqlite3.vcproj Mon Dec 31 17:18:22 2007 @@ -21,7 +21,7 @@ + RelativePath="..\..\Modules\_sqlite\cache.c"> + RelativePath="..\..\Modules\_sqlite\connection.c"> + RelativePath="..\..\Modules\_sqlite\cursor.c"> + RelativePath="..\..\Modules\_sqlite\microprotocols.c"> + RelativePath="..\..\Modules\_sqlite\module.c"> + RelativePath="..\..\Modules\_sqlite\prepare_protocol.c"> + RelativePath="..\..\Modules\_sqlite\row.c"> + RelativePath="..\..\Modules\_sqlite\statement.c"> + RelativePath="..\..\Modules\_sqlite\util.c"> Modified: python/branches/py3k/PC/VS7.1/_ssl.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_ssl.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_ssl.vcproj Mon Dec 31 17:18:22 2007 @@ -73,10 +73,10 @@ + RelativePath="..\..\Modules\_ssl.c"> + RelativePath="..\..\Modules\_hashopenssl.c"> Modified: python/branches/py3k/PC/VS7.1/_testcapi.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_testcapi.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_testcapi.vcproj Mon Dec 31 17:18:22 2007 @@ -22,7 +22,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\Include,..\PC" + AdditionalIncludeDirectories="..\..\Include,..\..\PC" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" StringPooling="TRUE" RuntimeLibrary="2" @@ -74,7 +74,7 @@ + RelativePath="..\..\Modules\_testcapimodule.c"> Modified: python/branches/py3k/PC/VS7.1/_tkinter.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/_tkinter.vcproj (original) +++ python/branches/py3k/PC/VS7.1/_tkinter.vcproj Mon Dec 31 17:18:22 2007 @@ -4,7 +4,7 @@ Version="7.10" Name="_tkinter" SccProjectName="_tkinter" - SccLocalPath="..\..\.."> + SccLocalPath="..\..\..\.."> @@ -21,7 +21,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\..\tcltk\include,..\Include,..\PC" + AdditionalIncludeDirectories="..\..\..\tcltk\include,..\..\Include,..\..\PC" PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;WITH_APPINIT" StringPooling="TRUE" RuntimeLibrary="2" @@ -35,7 +35,7 @@ Name="VCCustomBuildTool"/> + RelativePath="..\..\Modules\_tkinter.c"> + RelativePath="..\..\Modules\tkappinit.c"> Modified: python/branches/py3k/PC/VS7.1/bz2.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/bz2.vcproj (original) +++ python/branches/py3k/PC/VS7.1/bz2.vcproj Mon Dec 31 17:18:22 2007 @@ -21,7 +21,7 @@ + RelativePath="..\..\Modules\bz2module.c"> Modified: python/branches/py3k/PC/VS7.1/make_versioninfo.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/make_versioninfo.vcproj (original) +++ python/branches/py3k/PC/VS7.1/make_versioninfo.vcproj Mon Dec 31 17:18:22 2007 @@ -23,7 +23,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\Include,..\PC" + AdditionalIncludeDirectories="..\..\Include,..\..\PC" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" StringPooling="TRUE" RuntimeLibrary="2" @@ -35,9 +35,9 @@ CompileAs="0"/> + Outputs="..\..\PC\pythonnt_rc.h"/> + CommandLine="$(TargetFileName) > ..\..\PC\python_nt.h"/> + Outputs="..\..\PC\pythonnt_rc_d.h"/> + CommandLine="$(TargetFileName) > ..\..\PC\python_nt_d.h"/> + RelativePath="..\..\PC\make_versioninfo.c"> Modified: python/branches/py3k/PC/VS7.1/pyexpat.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/pyexpat.vcproj (original) +++ python/branches/py3k/PC/VS7.1/pyexpat.vcproj Mon Dec 31 17:18:22 2007 @@ -20,7 +20,7 @@ + RelativePath="..\..\Modules\pyexpat.c"> + RelativePath="..\..\Modules\expat\xmlparse.c"> + RelativePath="..\..\Modules\expat\xmlrole.c"> + RelativePath="..\..\Modules\expat\xmltok.c"> Modified: python/branches/py3k/PC/VS7.1/python.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/python.vcproj (original) +++ python/branches/py3k/PC/VS7.1/python.vcproj Mon Dec 31 17:18:22 2007 @@ -22,7 +22,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\Include,..\PC" + AdditionalIncludeDirectories="..\..\Include,..\..\PC" PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" StringPooling="TRUE" RuntimeLibrary="2" @@ -80,7 +80,7 @@ + AdditionalIncludeDirectories="..\..\Include"/> + RelativePath="..\..\PC\pycon.ico"> + RelativePath="..\..\Modules\python.c"> + RelativePath="..\..\PC\python_exe.rc"> Modified: python/branches/py3k/PC/VS7.1/pythoncore.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/pythoncore.vcproj (original) +++ python/branches/py3k/PC/VS7.1/pythoncore.vcproj Mon Dec 31 17:18:22 2007 @@ -24,7 +24,7 @@ AdditionalOptions="/Zm200 " Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\Include,..\PC" + AdditionalIncludeDirectories="..\..\Include,..\..\PC" PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;USE_DL_EXPORT" StringPooling="TRUE" RuntimeLibrary="2" @@ -63,7 +63,7 @@ Name="VCResourceCompilerTool" PreprocessorDefinitions="NDEBUG" Culture="1033" - AdditionalIncludeDirectories="..\Include"/> + AdditionalIncludeDirectories="..\..\Include"/> + AdditionalIncludeDirectories="..\..\Include"/> + AdditionalIncludeDirectories="..\..\Include"/> + AdditionalIncludeDirectories="..\..\Include"/> + RelativePath="..\..\Modules\zlib\adler32.c"> + RelativePath="..\..\Modules\zlib\compress.c"> + RelativePath="..\..\Modules\zlib\crc32.c"> + RelativePath="..\..\Modules\zlib\deflate.c"> + RelativePath="..\..\Modules\zlib\gzio.c"> + RelativePath="..\..\Modules\zlib\infback.c"> + RelativePath="..\..\Modules\zlib\inffast.c"> + RelativePath="..\..\Modules\zlib\inflate.c"> + RelativePath="..\..\Modules\zlib\inftrees.c"> + RelativePath="..\..\Modules\zlib\trees.c"> + RelativePath="..\..\Modules\zlib\uncompr.c"> + RelativePath="..\..\Modules\zlibmodule.c"> + AdditionalIncludeDirectories="..\..\Modules\zlib"/> + AdditionalIncludeDirectories="..\..\Modules\zlib"/> + AdditionalIncludeDirectories="..\..\Modules\zlib"/> + AdditionalIncludeDirectories="..\..\Modules\zlib"/> + RelativePath="..\..\Modules\zlib\zutil.c"> + RelativePath="..\..\Modules\_bisectmodule.c"> + RelativePath="..\..\Modules\cjkcodecs\_codecs_cn.c"> + RelativePath="..\..\Modules\cjkcodecs\_codecs_hk.c"> + RelativePath="..\..\Modules\cjkcodecs\_codecs_iso2022.c"> + RelativePath="..\..\Modules\cjkcodecs\_codecs_jp.c"> + RelativePath="..\..\Modules\cjkcodecs\_codecs_kr.c"> + RelativePath="..\..\Modules\cjkcodecs\_codecs_tw.c"> + RelativePath="..\..\Modules\_codecsmodule.c"> + RelativePath="..\..\Modules\_csv.c"> + RelativePath="..\..\Modules\_functoolsmodule.c"> + RelativePath="..\..\Modules\_heapqmodule.c"> + RelativePath="..\..\Modules\_hotshot.c"> + RelativePath="..\..\Modules\_localemodule.c"> + RelativePath="..\..\Modules\_lsprof.c"> + RelativePath="..\..\Modules\_randommodule.c"> + RelativePath="..\..\Modules\_sre.c"> + RelativePath="..\..\Modules\_struct.c"> + RelativePath="..\..\Pc\_subprocess.c"> + RelativePath="..\..\Modules\_typesmodule.c"> + RelativePath="..\..\Modules\_weakref.c"> + RelativePath="..\..\Pc\_winreg.c"> + RelativePath="..\..\Objects\abstract.c"> + RelativePath="..\..\Parser\acceler.c"> + RelativePath="..\..\Modules\arraymodule.c"> + RelativePath="..\..\Python\asdl.c"> + RelativePath="..\..\Python\ast.c"> + RelativePath="..\..\Modules\audioop.c"> + RelativePath="..\..\Modules\binascii.c"> + RelativePath="..\..\Parser\bitset.c"> + RelativePath="..\..\Python\bltinmodule.c"> + RelativePath="..\..\Objects\boolobject.c"> + RelativePath="..\..\Objects\bufferobject.c"> + RelativePath="..\..\Objects\cellobject.c"> + RelativePath="..\..\Python\ceval.c"> + RelativePath="..\..\Objects\classobject.c"> + RelativePath="..\..\Modules\cmathmodule.c"> + RelativePath="..\..\Objects\cobject.c"> + RelativePath="..\..\Python\codecs.c"> + RelativePath="..\..\Objects\codeobject.c"> + RelativePath="..\..\Modules\_collectionsmodule.c"> + RelativePath="..\..\Python\compile.c"> + RelativePath="..\..\Objects\complexobject.c"> + RelativePath="..\..\PC\config.c"> + RelativePath="..\..\Modules\cPickle.c"> + RelativePath="..\..\Modules\cStringIO.c"> + RelativePath="..\..\Modules\datetimemodule.c"> + RelativePath="..\..\Objects\descrobject.c"> + RelativePath="..\..\Objects\dictobject.c"> + RelativePath="..\..\PC\dl_nt.c"> + RelativePath="..\..\Python\dynload_win.c"> + RelativePath="..\..\Objects\enumobject.c"> + RelativePath="..\..\Modules\errnomodule.c"> + RelativePath="..\..\Python\errors.c"> + RelativePath="..\..\Objects\exceptions.c"> + RelativePath="..\..\Objects\fileobject.c"> + RelativePath="..\..\Parser\firstsets.c"> + RelativePath="..\..\Objects\floatobject.c"> + RelativePath="..\..\Objects\frameobject.c"> + RelativePath="..\..\Python\frozen.c"> + RelativePath="..\..\Objects\funcobject.c"> + RelativePath="..\..\Python\future.c"> + RelativePath="..\..\Modules\gcmodule.c"> + RelativePath="..\..\Objects\genobject.c"> + RelativePath="..\..\Python\getargs.c"> + RelativePath="..\..\Python\getcompiler.c"> + RelativePath="..\..\Python\getcopyright.c"> + RelativePath="..\..\Python\getmtime.c"> + RelativePath="..\..\Python\getopt.c"> + RelativePath="..\..\PC\getpathp.c"> + RelativePath="..\..\Python\getplatform.c"> + RelativePath="..\..\Python\getversion.c"> + RelativePath="..\..\Python\graminit.c"> + RelativePath="..\..\Parser\grammar.c"> + RelativePath="..\..\Parser\grammar1.c"> + RelativePath="..\..\Modules\imageop.c"> + RelativePath="..\..\Python\import.c"> + RelativePath="..\..\PC\import_nt.c"> + AdditionalIncludeDirectories="..\..\Python"/> + AdditionalIncludeDirectories="..\..\Python"/> + AdditionalIncludeDirectories="..\..\Python"/> + AdditionalIncludeDirectories="..\..\Python"/> + RelativePath="..\..\Python\importdl.c"> + RelativePath="..\..\Objects\intobject.c"> + RelativePath="..\..\Objects\iterobject.c"> + RelativePath="..\..\Modules\itertoolsmodule.c"> + RelativePath="..\..\Parser\listnode.c"> + RelativePath="..\..\Objects\listobject.c"> + RelativePath="..\..\Objects\longobject.c"> + RelativePath="..\..\Modules\main.c"> + RelativePath="..\..\Python\marshal.c"> + RelativePath="..\..\Modules\mathmodule.c"> + RelativePath="..\..\Modules\md5.c"> + RelativePath="..\..\Modules\md5module.c"> + RelativePath="..\..\Parser\metagrammar.c"> + RelativePath="..\..\Objects\methodobject.c"> + RelativePath="..\..\Modules\mmapmodule.c"> + RelativePath="..\..\Python\modsupport.c"> + RelativePath="..\..\Objects\moduleobject.c"> + RelativePath="..\..\PC\msvcrtmodule.c"> + RelativePath="..\..\Modules\cjkcodecs\multibytecodec.c"> + RelativePath="..\..\Parser\myreadline.c"> + RelativePath="..\..\Python\mysnprintf.c"> + RelativePath="..\..\Python\mystrtoul.c"> + RelativePath="..\..\Parser\node.c"> + RelativePath="..\..\Objects\object.c"> + RelativePath="..\..\Objects\obmalloc.c"> + RelativePath="..\..\Modules\operator.c"> + RelativePath="..\..\Parser\parser.c"> + RelativePath="..\..\Modules\parsermodule.c"> + RelativePath="..\..\Parser\parsetok.c"> + RelativePath="..\..\Python\peephole.c"> + RelativePath="..\..\Modules\posixmodule.c"> + RelativePath="..\..\Python\pyarena.c"> + RelativePath="..\..\Python\pyfpe.c"> + RelativePath="..\..\Python\pystate.c"> + RelativePath="..\..\Python\pystrtod.c"> + RelativePath="..\..\Python\Python-ast.c"> + RelativePath="..\..\PC\python_nt.rc"> + RelativePath="..\..\Python\pythonrun.c"> + RelativePath="..\..\Objects\rangeobject.c"> + RelativePath="..\..\Modules\rotatingtree.c"> + RelativePath="..\..\Objects\setobject.c"> + RelativePath="..\..\Modules\sha256module.c"> + RelativePath="..\..\Modules\sha512module.c"> + RelativePath="..\..\Modules\shamodule.c"> + RelativePath="..\..\Modules\signalmodule.c"> + RelativePath="..\..\Objects\sliceobject.c"> + RelativePath="..\..\Objects\stringobject.c"> + RelativePath="..\..\Modules\stropmodule.c"> + RelativePath="..\..\Python\structmember.c"> + RelativePath="..\..\Objects\structseq.c"> + RelativePath="..\..\Python\symtable.c"> + RelativePath="..\..\Modules\symtablemodule.c"> + RelativePath="..\..\Python\sysmodule.c"> + RelativePath="..\..\Python\thread.c"> + RelativePath="..\..\Modules\threadmodule.c"> + RelativePath="..\..\Modules\timemodule.c"> + RelativePath="..\..\Parser\tokenizer.c"> + RelativePath="..\..\Python\traceback.c"> + RelativePath="..\..\Objects\tupleobject.c"> + RelativePath="..\..\Objects\typeobject.c"> + RelativePath="..\..\Objects\unicodectype.c"> + RelativePath="..\..\Objects\unicodeobject.c"> + RelativePath="..\..\Objects\weakrefobject.c"> + RelativePath="..\..\Modules\xxsubtype.c"> + RelativePath="..\..\Modules\yuvconvert.c"> + RelativePath="..\..\Modules\zipimport.c"> Modified: python/branches/py3k/PC/VS7.1/pythonw.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/pythonw.vcproj (original) +++ python/branches/py3k/PC/VS7.1/pythonw.vcproj Mon Dec 31 17:18:22 2007 @@ -4,7 +4,7 @@ Version="7.10" Name="pythonw" SccProjectName="pythonw" - SccLocalPath="..\pc"> + SccLocalPath="..\..\pc"> @@ -20,7 +20,7 @@ + RelativePath="..\..\PC\python_exe.rc"> + RelativePath="..\..\PC\WinMain.c"> Modified: python/branches/py3k/PC/VS7.1/select.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/select.vcproj (original) +++ python/branches/py3k/PC/VS7.1/select.vcproj Mon Dec 31 17:18:22 2007 @@ -21,7 +21,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\Include,..\PC" + AdditionalIncludeDirectories="..\..\Include,..\..\PC" PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS" StringPooling="TRUE" RuntimeLibrary="2" @@ -77,7 +77,7 @@ + RelativePath="..\..\Modules\selectmodule.c"> Modified: python/branches/py3k/PC/VS7.1/unicodedata.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/unicodedata.vcproj (original) +++ python/branches/py3k/PC/VS7.1/unicodedata.vcproj Mon Dec 31 17:18:22 2007 @@ -22,7 +22,7 @@ Name="VCCLCompilerTool" Optimization="2" InlineFunctionExpansion="1" - AdditionalIncludeDirectories="..\Include,..\PC" + AdditionalIncludeDirectories="..\..\Include,..\..\PC" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MMAP_EXPORTS" StringPooling="TRUE" RuntimeLibrary="2" @@ -74,7 +74,7 @@ + RelativePath="..\..\Modules\unicodedata.c"> Modified: python/branches/py3k/PC/VS7.1/w9xpopen.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/w9xpopen.vcproj (original) +++ python/branches/py3k/PC/VS7.1/w9xpopen.vcproj Mon Dec 31 17:18:22 2007 @@ -113,7 +113,7 @@ + RelativePath="..\..\PC\w9xpopen.c"> Modified: python/branches/py3k/PC/VS7.1/winsound.vcproj ============================================================================== --- python/branches/py3k/PC/VS7.1/winsound.vcproj (original) +++ python/branches/py3k/PC/VS7.1/winsound.vcproj Mon Dec 31 17:18:22 2007 @@ -4,7 +4,7 @@ Version="7.10" Name="winsound" SccProjectName="winsound" - SccLocalPath="..\pc"> + SccLocalPath="..\..\pc"> @@ -21,7 +21,7 @@ + RelativePath="..\..\PC\winsound.c"> From python-3000-checkins at python.org Mon Dec 31 17:44:36 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 31 Dec 2007 17:44:36 +0100 (CET) Subject: [Python-3000-checkins] r59629 - python/branches/py3k/PCbuild/pyproject.vsprops python/branches/py3k/PCbuild/pythoncore.vcproj Message-ID: <20071231164436.C463B1E400B@bag.python.org> Author: christian.heimes Date: Mon Dec 31 17:44:35 2007 New Revision: 59629 Modified: python/branches/py3k/PCbuild/pyproject.vsprops python/branches/py3k/PCbuild/pythoncore.vcproj Log: Fixed svn merge issues Modified: python/branches/py3k/PCbuild/pyproject.vsprops ============================================================================== --- python/branches/py3k/PCbuild/pyproject.vsprops (original) +++ python/branches/py3k/PCbuild/pyproject.vsprops Mon Dec 31 17:44:35 2007 @@ -38,7 +38,7 @@ /> + + + + @@ -979,15 +987,15 @@ > - - @@ -1071,14 +1075,6 @@ > - - - - @@ -1107,15 +1103,15 @@ > - - @@ -1339,7 +1331,11 @@ > + + - @@ -1415,10 +1407,6 @@ > - - @@ -1431,6 +1419,10 @@ > + + @@ -1635,6 +1627,10 @@ > + + From python-3000-checkins at python.org Mon Dec 31 18:27:19 2007 From: python-3000-checkins at python.org (christian.heimes) Date: Mon, 31 Dec 2007 18:27:19 +0100 (CET) Subject: [Python-3000-checkins] r59630 - python/branches/py3k/Makefile.pre.in Message-ID: <20071231172719.C7F961E400F@bag.python.org> Author: christian.heimes Date: Mon Dec 31 18:27:19 2007 New Revision: 59630 Modified: python/branches/py3k/Makefile.pre.in Log: Removed doubledigit from Makefile Modified: python/branches/py3k/Makefile.pre.in ============================================================================== --- python/branches/py3k/Makefile.pre.in (original) +++ python/branches/py3k/Makefile.pre.in Mon Dec 31 18:27:19 2007 @@ -302,7 +302,6 @@ Objects/genobject.o \ Objects/fileobject.o \ Objects/floatobject.o \ - Objects/doubledigits.o \ Objects/frameobject.o \ Objects/funcobject.o \ Objects/iterobject.o \